OSDN Git Service

2001-11-07 David O'Brien <obrien@FreeBSD.org>
[pf3gnuchains/gcc-fork.git] / gcc / config / freebsd.h
1 /* Base configuration file for all FreeBSD targets.
2    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Common FreeBSD configuration. 
22    All FreeBSD architectures should include this file, which will specify
23    their commonalities.
24    Adapted from gcc/config/i386/freebsd-elf.h by 
25    David O'Brien <obrien@FreeBSD.org>.  
26    Further work by David O'Brien <obrien@FreeBSD.org> and
27    Loren J. Rittle <ljrittle@acm.org>.  */
28
29
30 /* To help with rs6000/sysv4.h carnal knowledge problem.  */
31 #define _USING_CONFIG_FREEBSD 1
32
33 /* This defines which switch letters take arguments.  On FreeBSD, most of
34    the normal cases (defined in gcc.c) apply, and we also have -h* and
35    -z* options (for the linker) (coming from SVR4).
36    We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
37
38 #define FBSD_SWITCH_TAKES_ARG(CHAR)                                     \
39   (DEFAULT_SWITCH_TAKES_ARG (CHAR)                                      \
40     || (CHAR) == 'h'                                                    \
41     || (CHAR) == 'z' /* ignored by ld */                                \
42     || (CHAR) == 'R')
43
44 #undef  SWITCH_TAKES_ARG
45 #define SWITCH_TAKES_ARG(CHAR) (FBSD_SWITCH_TAKES_ARG(CHAR))
46
47 /* This defines which multi-letter switches take arguments.  */
48
49 #define FBSD_WORD_SWITCH_TAKES_ARG(STR)                                 \
50   (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                                  \
51    || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")         \
52    || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym")            \
53    || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
54
55 #undef  WORD_SWITCH_TAKES_ARG
56 #define WORD_SWITCH_TAKES_ARG(STR) (FBSD_WORD_SWITCH_TAKES_ARG(STR))
57
58 #if FBSD_MAJOR == 6
59 #define FBSD_CPP_PREDEFINES \
60   "-D__FreeBSD__=6 -Dunix -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -Asystem=unix -Asystem=bsd -Asystem=FreeBSD"
61 #endif
62
63 #if FBSD_MAJOR == 5
64 #define FBSD_CPP_PREDEFINES \
65   "-D__FreeBSD__=5 -Dunix -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -Asystem=unix -Asystem=bsd -Asystem=FreeBSD"
66 #endif
67
68 #if FBSD_MAJOR == 4
69 #define FBSD_CPP_PREDEFINES \
70   "-D__FreeBSD__=4 -Dunix -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -Asystem=unix -Asystem=bsd -Asystem=FreeBSD"
71 #endif
72
73 #if FBSD_MAJOR == 3
74 #define FBSD_CPP_PREDEFINES \
75   "-D__FreeBSD__=3 -Dunix -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -Asystem=unix -Asystem=bsd -Asystem=FreeBSD"
76 #endif
77
78 #ifndef FBSD_CPP_PREDEFINES
79 #define FBSD_CPP_PREDEFINES \
80   "-D__FreeBSD__   -Dunix -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -Asystem=unix -Asystem=bsd -Asystem=FreeBSD"
81 #endif
82
83 #undef  CPP_PREDEFINES
84 #define CPP_PREDEFINES FBSD_CPP_PREDEFINES
85
86 /* Provide a CPP_SPEC appropriate for FreeBSD.  We just deal with the GCC 
87    option `-posix', and PIC issues.  */
88
89 #define FBSD_CPP_SPEC "                                                 \
90   %(cpp_cpu)                                                            \
91   %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}               \
92   %{posix:-D_POSIX_SOURCE}"
93
94 #undef  CPP_SPEC
95 #define CPP_SPEC FBSD_CPP_SPEC
96
97 /* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add
98    the magical crtbegin.o file (see crtstuff.c) which provides part 
99         of the support for getting C++ file-scope static object constructed 
100         before entering `main'. */
101    
102 #define FBSD_STARTFILE_SPEC \
103   "%{!shared: \
104      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
105                        %{!p:%{profile:gcrt1.o%s} \
106                          %{!profile:crt1.o%s}}}} \
107    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
108
109 /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
110    the magical crtend.o file (see crtstuff.c) which provides part of 
111         the support for getting C++ file-scope static object constructed 
112         before entering `main', followed by a normal "finalizer" file, 
113         `crtn.o'.  */
114
115 #define FBSD_ENDFILE_SPEC \
116   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
117
118 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
119    required by the user-land thread model.  Before __FreeBSD_version
120    500016, select the appropriate libc, depending on whether we're
121    doing profiling or need threads support.  At __FreeBSD_version
122    500016 and later, when threads support is requested include both
123    -lc and -lc_r instead of only -lc_r.  To make matters interesting,
124    we can't actually use __FreeBSD_version provided by <osreldate.h>
125    directly since it breaks cross-compiling.  As a final twist, make
126    it a hard error if -pthread is provided on the command line and gcc
127    was configured with --disable-threads (this will help avoid bug
128    reports from users complaining about threading when they
129    misconfigured the gcc bootstrap but are later consulting FreeBSD
130    manual pages that refer to the mythical -pthread option).  */
131
132 /* Provide a LIB_SPEC appropriate for FreeBSD.  Just select the appropriate
133    libc, depending on whether we're doing profiling or need threads support.
134    (simular to the default, except no -lg, and no -p).  */
135
136 #ifdef FBSD_NO_THREADS
137 #define FBSD_LIB_SPEC "                                                 \
138   %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
139 is built with the --enable-threads configure-time option.}              \
140   %{!shared:                                                            \
141     %{!pg: -lc}                                                         \
142     %{pg:  -lc_p}                                                       \
143   }"
144 #else
145 #if FBSD_MAJOR >= 5
146 #define FBSD_LIB_SPEC "                                                 \
147   %{!shared:                                                            \
148     %{!pg: %{pthread:-lc_r} -lc}                                        \
149     %{pg:  %{pthread:-lc_r_p} -lc_p}                                    \
150   }"
151 #else
152 #define FBSD_LIB_SPEC "                                                 \
153   %{!shared:                                                            \
154     %{!pg:                                                              \
155       %{!pthread:-lc}                                                   \
156       %{pthread:-lc_r}}                                                 \
157     %{pg:                                                               \
158       %{!pthread:-lc_p}                                                 \
159       %{pthread:-lc_r_p}}                                               \
160   }"
161 #endif
162 #endif
163
164 #undef  LIB_SPEC
165 #define LIB_SPEC FBSD_LIB_SPEC
166
167
168 /************************[  Target stuff  ]***********************************/
169
170 /* Don't assume anything about the header files.  */
171 #undef  NO_IMPLICIT_EXTERN_C
172 #define NO_IMPLICIT_EXTERN_C
173
174 /* Allow #sccs in preprocessor.  */
175 #undef  SCCS_DIRECTIVE
176 #define SCCS_DIRECTIVE
177
178 /* Make gcc agree with FreeBSD's standard headers (<machine/ansi.h>, etc...)  */
179
180 #undef  WCHAR_TYPE
181 #define WCHAR_TYPE "int"
182
183 #undef  WCHAR_UNSIGNED
184 #define WCHAR_UNSIGNED 0
185
186 /* Code generation parameters.  */
187
188 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
189    we want to retain compatibility with older gcc versions
190    (even though the SVR4 ABI for the i386 says that records and unions are
191    returned in memory).  */
192 #undef  DEFAULT_PCC_STRUCT_RETURN
193 #define DEFAULT_PCC_STRUCT_RETURN 0
194
195 /* Use periods rather than dollar signs in special g++ assembler names.
196    This ensures the configuration knows our system correctly so we can link
197    with libraries compiled with the native cc.  */
198 #undef NO_DOLLAR_IN_LABEL
199
200 /* The prefix to add to user-visible assembler symbols.
201    For System V Release 4 & ELF the convention is *not* to prepend a leading
202    underscore onto user-level symbol names. Some CPU files such as
203    config/sparc/sparc.h set this wrong for ELF.  */
204
205 #undef  USER_LABEL_PREFIX
206 #define USER_LABEL_PREFIX ""
207
208 /* Handle #pragma weak and #pragma pack.  */
209 #undef  HANDLE_SYSV_PRAGMA
210 #define HANDLE_SYSV_PRAGMA
211
212 /* Use more efficient ``thunks'' to implement C++ vtables.  */
213 #undef DEFAULT_VTABLE_THUNKS
214 #define DEFAULT_VTABLE_THUNKS 1
215
216 /************************[  Assembler stuff  ]********************************/
217
218 #undef  IDENT_ASM_OP
219 #define IDENT_ASM_OP "\t.ident\t"
220
221 /* Output #ident as a .ident.  */
222
223 #undef  ASM_OUTPUT_IDENT
224 #define ASM_OUTPUT_IDENT(FILE, NAME)                                    \
225   fprintf ((FILE), "%s\"%s\"\n", IDENT_ASM_OP, (NAME));
226
227 /************************[  Debugger stuff  ]*********************************/
228
229 /* All ELF targets can support DWARF-2.  */
230 #undef  DWARF2_DEBUGGING_INFO
231 #define DWARF2_DEBUGGING_INFO
232
233 /* This is BSD, so we want the DBX format.  */
234 #undef  DBX_DEBUGGING_INFO
235 #define DBX_DEBUGGING_INFO
236
237 /* Even though this is BSD, ELF and the GNU tools operates better with dwarf2
238    than stabs.  Since we don't have any native tools to be compatible with,
239    defaulting to dwarf2 is OK.  */
240 #undef  PREFERRED_DEBUGGING_TYPE
241 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG