]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/gcc/config/freebsd-spec.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / gcc / config / freebsd-spec.h
1 /* Base configuration file for all FreeBSD targets.
2    Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC 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 GCC 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 GCC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.  */
20
21 /* $FreeBSD$ */
22
23 /* Common FreeBSD configuration. 
24    All FreeBSD architectures should include this file, which will specify
25    their commonalities.
26    Adapted from gcc/config/freebsd.h by 
27    David O'Brien <obrien@FreeBSD.org>
28    Loren J. Rittle <ljrittle@acm.org>.  */
29
30
31 /* In case we need to know.  */
32 #define USING_CONFIG_FREEBSD_SPEC 1
33
34 /* This defines which switch letters take arguments.  On FreeBSD, most of
35    the normal cases (defined in gcc.c) apply, and we also have -h* and
36    -z* options (for the linker) (coming from SVR4).
37    We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
38
39 #define FBSD_SWITCH_TAKES_ARG(CHAR)                                     \
40   (DEFAULT_SWITCH_TAKES_ARG (CHAR)                                      \
41     || (CHAR) == 'h'                                                    \
42     || (CHAR) == 'z' /* ignored by ld */                                \
43     || (CHAR) == 'R')
44
45 /* This defines which multi-letter switches take arguments.  */
46
47 #define FBSD_WORD_SWITCH_TAKES_ARG(STR)                                 \
48   (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                                  \
49    || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")         \
50    || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym")            \
51    || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
52
53 #define FBSD_TARGET_OS_CPP_BUILTINS()                                   \
54   do                                                                    \
55     {                                                                   \
56         builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR);      \
57         builtin_define_std ("unix");                                    \
58         builtin_define_std ("__unix__");                                \
59         builtin_define ("__KPRINTF_ATTRIBUTE__");                       \
60         builtin_assert ("system=unix");                                 \
61         builtin_assert ("system=bsd");                                  \
62         builtin_assert ("system=FreeBSD");                              \
63         FBSD_NATIVE_TARGET_OS_CPP_BUILTINS();                           \
64         FBSD_TARGET_CPU_CPP_BUILTINS();                                 \
65     }                                                                   \
66   while (0)
67
68 /* Define the default FreeBSD-specific per-CPU hook code.  */
69 #define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
70
71 #ifdef FREEBSD_NATIVE
72 #define FBSD_NATIVE_TARGET_OS_CPP_BUILTINS()                            \
73   do {                                                                  \
74         builtin_define_with_int_value ("__FreeBSD_cc_version", FBSD_CC_VER); \
75   } while (0)
76 #else
77 #define FBSD_NATIVE_TARGET_OS_CPP_BUILTINS()                            \
78   do {} while (0)
79 #endif
80
81 /* Provide a CPP_SPEC appropriate for FreeBSD.  We just deal with the GCC
82    option `-posix', and PIC issues.  Try to detect support for the
83    `long long' type.  Unfortunately the GCC spec parser will not allow us
84    to properly detect the "iso9899:1990" and "iso9899:199409" forms of
85    -std=c89.  Because of the ':' in the -std argument. :-(  I have left
86    them in the spec as a place holder in hopes someone knows a way to make
87    the detection of them work.  */
88
89 #define FBSD_CPP_SPEC "                                                 \
90   %(cpp_cpu)                                                            \
91   %(cpp_arch)                                                           \
92   %{!ansi:%{!std=c89:%{!std=iso9899.1990:%{!std=iso9899.199409:-D_LONGLONG}}}} \
93   %{posix:-D_POSIX_SOURCE}"
94
95 /* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add the magical
96    crtbegin.o file (see crtstuff.c) which provides part of the support for
97    getting C++ file-scope static object constructed before entering `main'.  */
98
99 #define FBSD_STARTFILE_SPEC "\
100   %{!shared: \
101     %{pg:gcrt1.o%s} \
102     %{!pg: \
103       %{p:gcrt1.o%s} \
104       %{!p: \
105         %{profile:gcrt1.o%s} \
106         %{!profile: \
107           %{pie: Scrt1.o%s;:crt1.o%s}}}}} \
108   crti.o%s \
109   %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
110
111 /* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  Here we tack on
112    our own magical crtend.o file (see crtstuff.c) which provides part of
113    the support for getting C++ file-scope static object constructed before
114    entering `main', followed by the normal "finalizer" file, `crtn.o'.  */
115
116 #define FBSD_ENDFILE_SPEC "\
117   %{shared|pie:crtendS.o%s;:crtend.o%s} \
118   crtn.o%s "
119
120 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
121    required by the user-land thread model.  Before __FreeBSD_version
122    500016, select the appropriate libc, depending on whether we're
123    doing profiling or need threads support.  At __FreeBSD_version
124    500016 and later, when threads support is requested include both
125    -lc and the threading lib instead of only -lc_r.  To make matters
126    interesting, we can't actually use __FreeBSD_version provided by
127    <osreldate.h> directly since it breaks cross-compiling.  As a final
128    twist, make it a hard error if -pthread is provided on the command
129    line and gcc was configured with --disable-threads (this will help
130    avoid bug reports from users complaining about threading when they
131    misconfigured the gcc bootstrap but are later consulting FreeBSD
132    manual pages that refer to the mythical -pthread option).  */
133
134 /* Provide a LIB_SPEC appropriate for FreeBSD.  Just select the appropriate
135    libc, depending on whether we're doing profiling or need threads support.
136    (similar to the default, except no -lg, and no -p).  */
137
138 #ifdef FBSD_NO_THREADS
139 #define FBSD_LIB_SPEC "                                                 \
140   %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
141 is built with the --enable-threads configure-time option.}              \
142   %{!shared:                                                            \
143     %{!pg: -lc}                                                         \
144     %{pg:  -lc_p}                                                       \
145   }"
146 #else
147 #include <sys/param.h>
148 #if __FreeBSD_version < 500016
149 #define FBSD_LIB_SPEC "                                                 \
150   %{!shared:                                                            \
151     %{!pg:                                                              \
152       %{!pthread:-lc}                                                   \
153       %{pthread:-lc_r}}                                                 \
154     %{pg:                                                               \
155       %{!pthread:-lc_p}                                                 \
156       %{pthread:-lc_r_p}}                                               \
157   }"
158 #elif __FreeBSD_version < 700022
159 #define FBSD_LIB_SPEC "                                                 \
160   %{!shared:                                                            \
161     %{!pg: %{pthread:-lpthread} -lc}                                    \
162     %{pg:  %{pthread:-lpthread_p} -lc_p}                                \
163   }"
164 #else
165 #define FBSD_LIB_SPEC "                                                 \
166   %{!shared:                                                            \
167     %{!pg: %{pthread:-lpthread} -lc}                                    \
168     %{pg:  %{pthread:-lpthread_p} -lc_p}}                               \
169   %{shared:                                                             \
170     %{pthread:-lpthread} -lc}                                           \
171   %{fstack-protector|fstack-protector-all:-lssp_nonshared}              \
172   "
173 #endif
174 #endif
175
176 #if FBSD_MAJOR < 5
177 #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
178 #else
179 #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
180 #endif
181
182 #if defined(HAVE_LD_EH_FRAME_HDR)
183 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
184 #endif
185
186 /* Use --as-needed -lgcc_s for eh support.  */
187 #ifdef HAVE_LD_AS_NEEDED
188 #define USE_LD_AS_NEEDED 1
189 #endif
190
191 #define FBSD_SIZE_TYPE \
192         (POINTER_SIZE == 64 ? "long unsigned int" : "unsigned int")
193 #define FBSD_PTRDIFF_TYPE \
194         (POINTER_SIZE == 64 ? "long int" : "int")