merge selected patches from milepost-integration:
[official-gcc.git] / gcc / config / freebsd-spec.h
blobc726a158c6bfa95efebb5e0396a77bb1f8cea8fb
1 /* Base configuration file for all FreeBSD targets.
2 Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
4 This file is part of GCC.
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 3, or (at your option)
9 any later version.
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.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 /* Common FreeBSD configuration.
26 All FreeBSD architectures should include this file, which will specify
27 their commonalities.
28 Adapted from gcc/config/freebsd.h by
29 David O'Brien <obrien@FreeBSD.org>
30 Loren J. Rittle <ljrittle@acm.org>. */
33 /* In case we need to know. */
34 #define USING_CONFIG_FREEBSD_SPEC 1
36 /* This defines which switch letters take arguments. On FreeBSD, most of
37 the normal cases (defined in gcc.c) apply, and we also have -h* and
38 -z* options (for the linker) (coming from SVR4).
39 We also have -R (alias --rpath), no -z, --soname (-h), --assert etc. */
41 #define FBSD_SWITCH_TAKES_ARG(CHAR) \
42 (DEFAULT_SWITCH_TAKES_ARG (CHAR) \
43 || (CHAR) == 'h' \
44 || (CHAR) == 'z' /* ignored by ld */ \
45 || (CHAR) == 'R')
47 /* This defines which multi-letter switches take arguments. */
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"))
55 #define FBSD_TARGET_OS_CPP_BUILTINS() \
56 do \
57 { \
58 builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR); \
59 builtin_define_std ("unix"); \
60 builtin_define ("__KPRINTF_ATTRIBUTE__"); \
61 builtin_assert ("system=unix"); \
62 builtin_assert ("system=bsd"); \
63 builtin_assert ("system=FreeBSD"); \
64 FBSD_TARGET_CPU_CPP_BUILTINS(); \
65 } \
66 while (0)
68 /* Define the default FreeBSD-specific per-CPU hook code. */
69 #define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
71 /* Provide a CPP_SPEC appropriate for FreeBSD. We just deal with the GCC
72 option `-posix', and PIC issues. */
74 #define FBSD_CPP_SPEC " \
75 %(cpp_cpu) \
76 %(cpp_arch) \
77 %{posix:-D_POSIX_SOURCE}"
79 /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add
80 the magical crtbegin.o file (see crtstuff.c) which provides part
81 of the support for getting C++ file-scope static object constructed
82 before entering `main'. */
84 #define FBSD_STARTFILE_SPEC \
85 "%{!shared: \
86 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
87 %{!p:%{profile:gcrt1.o%s} \
88 %{!profile:crt1.o%s}}}} \
89 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
91 /* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on
92 the magical crtend.o file (see crtstuff.c) which provides part of
93 the support for getting C++ file-scope static object constructed
94 before entering `main', followed by a normal "finalizer" file,
95 `crtn.o'. */
97 #define FBSD_ENDFILE_SPEC \
98 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
100 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
101 required by the user-land thread model. Before __FreeBSD_version
102 500016, select the appropriate libc, depending on whether we're
103 doing profiling or need threads support. At __FreeBSD_version
104 500016 and later, when threads support is requested include both
105 -lc and the threading lib instead of only -lc_r. To make matters
106 interesting, we can't actually use __FreeBSD_version provided by
107 <osreldate.h> directly since it breaks cross-compiling. As a final
108 twist, make it a hard error if -pthread is provided on the command
109 line and gcc was configured with --disable-threads (this will help
110 avoid bug reports from users complaining about threading when they
111 misconfigured the gcc bootstrap but are later consulting FreeBSD
112 manual pages that refer to the mythical -pthread option). */
114 /* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate
115 libc, depending on whether we're doing profiling or need threads support.
116 (similar to the default, except no -lg, and no -p). */
118 #ifdef FBSD_NO_THREADS
119 #define FBSD_LIB_SPEC " \
120 %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
121 is built with the --enable-threads configure-time option.} \
122 %{!shared: \
123 %{!pg: -lc} \
124 %{pg: -lc_p} \
126 #else
127 #if FBSD_MAJOR < 5
128 #define FBSD_LIB_SPEC " \
129 %{!shared: \
130 %{!pg: \
131 %{!pthread:-lc} \
132 %{pthread:-lc_r}} \
133 %{pg: \
134 %{!pthread:-lc_p} \
135 %{pthread:-lc_r_p}} \
137 #else
138 #define FBSD_LIB_SPEC " \
139 %{!shared: \
140 %{!pg: %{pthread:-lpthread} -lc} \
141 %{pg: %{pthread:-lpthread_p} -lc_p} \
143 #endif
144 #endif
146 #if FBSD_MAJOR < 6
147 #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
148 #else
149 #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
150 #endif