2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / config / freebsd-spec.h
blob8e7700669731499ddbe33dc05670c8d4d726588b
1 /* Base configuration file for all FreeBSD targets.
2 Copyright (C) 1999-2014 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 #define FBSD_TARGET_OS_CPP_BUILTINS() \
37 do \
38 { \
39 builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR); \
40 builtin_define_std ("unix"); \
41 builtin_define ("__KPRINTF_ATTRIBUTE__"); \
42 builtin_assert ("system=unix"); \
43 builtin_assert ("system=bsd"); \
44 builtin_assert ("system=FreeBSD"); \
45 FBSD_TARGET_CPU_CPP_BUILTINS(); \
46 } \
47 while (0)
49 /* Define the default FreeBSD-specific per-CPU hook code. */
50 #define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
52 /* Provide a CPP_SPEC appropriate for FreeBSD. We just deal with the GCC
53 option `-posix', and PIC issues. */
55 #define FBSD_CPP_SPEC " \
56 %(cpp_cpu) \
57 %(cpp_arch) \
58 %{posix:-D_POSIX_SOURCE}"
60 /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add
61 the magical crtbegin.o file (see crtstuff.c) which provides part
62 of the support for getting C++ file-scope static object constructed
63 before entering `main'. */
65 #define FBSD_STARTFILE_SPEC \
66 "%{!shared: \
67 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
68 %{!p:%{profile:gcrt1.o%s} \
69 %{!profile:crt1.o%s}}}} \
70 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
72 /* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on
73 the magical crtend.o file (see crtstuff.c) which provides part of
74 the support for getting C++ file-scope static object constructed
75 before entering `main', followed by a normal "finalizer" file,
76 `crtn.o'. */
78 #define FBSD_ENDFILE_SPEC \
79 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
81 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
82 required by the user-land thread model. Before __FreeBSD_version
83 500016, select the appropriate libc, depending on whether we're
84 doing profiling or need threads support. At __FreeBSD_version
85 500016 and later, when threads support is requested include both
86 -lc and the threading lib instead of only -lc_r. To make matters
87 interesting, we can't actually use __FreeBSD_version provided by
88 <osreldate.h> directly since it breaks cross-compiling. As a final
89 twist, make it a hard error if -pthread is provided on the command
90 line and gcc was configured with --disable-threads (this will help
91 avoid bug reports from users complaining about threading when they
92 misconfigured the gcc bootstrap but are later consulting FreeBSD
93 manual pages that refer to the mythical -pthread option). */
95 /* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate
96 libc, depending on whether we're doing profiling or need threads support.
97 (similar to the default, except no -lg, and no -p). */
99 #ifdef FBSD_NO_THREADS
100 #define FBSD_LIB_SPEC " \
101 %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
102 is built with the --enable-threads configure-time option.} \
103 %{!shared: \
104 %{!pg: -lc} \
105 %{pg: -lc_p} \
107 #else
108 #if FBSD_MAJOR < 5
109 #define FBSD_LIB_SPEC " \
110 %{!shared: \
111 %{!pg: \
112 %{!pthread:-lc} \
113 %{pthread:-lc_r}} \
114 %{pg: \
115 %{!pthread:-lc_p} \
116 %{pthread:-lc_r_p}} \
118 #else
119 #define FBSD_LIB_SPEC " \
120 %{!shared: \
121 %{!pg: %{pthread:-lpthread} -lc} \
122 %{pg: %{pthread:-lpthread_p} -lc_p} \
124 %{shared: \
125 %{pthread:-lpthread} -lc \
127 #endif
128 #endif
130 #if FBSD_MAJOR < 6
131 #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
132 #else
133 #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
134 #endif
136 /* NOTE: The freebsd-spec.h header is included also for various
137 non-FreeBSD powerpc targets, thus it should never define macros
138 other than FBSD_* prefixed ones, or USING_CONFIG_FREEBSD_SPEC. */