xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/freebsd-spec.h (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
1 /* Base configuration file for all FreeBSD targets.
2    Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2009, 2011
3    Free Software Foundation, Inc.
4 
5 This file is part of GCC.
6 
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11 
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16 
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20 
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 <http://www.gnu.org/licenses/>.  */
25 
26 /* Common FreeBSD configuration.
27    All FreeBSD architectures should include this file, which will specify
28    their commonalities.
29    Adapted from gcc/config/freebsd.h by
30    David O'Brien <obrien@FreeBSD.org>
31    Loren J. Rittle <ljrittle@acm.org>.  */
32 
33 
34 /* In case we need to know.  */
35 #define USING_CONFIG_FREEBSD_SPEC 1
36 
37 /* This defines which switch letters take arguments.  On FreeBSD, most of
38    the normal cases (defined in gcc.c) apply, and we also have -h* and
39    -z* options (for the linker) (coming from SVR4).
40    We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
41 
42 #define FBSD_SWITCH_TAKES_ARG(CHAR)					\
43   (DEFAULT_SWITCH_TAKES_ARG (CHAR)					\
44     || (CHAR) == 'h'							\
45     || (CHAR) == 'z' /* ignored by ld */				\
46     || (CHAR) == 'R')
47 
48 /* This defines which multi-letter switches take arguments.  */
49 
50 #define FBSD_WORD_SWITCH_TAKES_ARG(STR)					\
51   (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
52    || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")		\
53    || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym") 		\
54    || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
55 
56 #define FBSD_TARGET_OS_CPP_BUILTINS()					\
57   do									\
58     {									\
59 	builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR);	\
60 	builtin_define_std ("unix");					\
61 	builtin_define ("__KPRINTF_ATTRIBUTE__");		       	\
62 	builtin_assert ("system=unix");					\
63 	builtin_assert ("system=bsd");					\
64 	builtin_assert ("system=FreeBSD");				\
65 	FBSD_TARGET_CPU_CPP_BUILTINS();					\
66     }									\
67   while (0)
68 
69 /* Define the default FreeBSD-specific per-CPU hook code.  */
70 #define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
71 
72 /* Provide a CPP_SPEC appropriate for FreeBSD.  We just deal with the GCC
73    option `-posix', and PIC issues.  */
74 
75 #define FBSD_CPP_SPEC "							\
76   %(cpp_cpu)								\
77   %(cpp_arch)								\
78   %{posix:-D_POSIX_SOURCE}"
79 
80 /* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add
81    the magical crtbegin.o file (see crtstuff.c) which provides part
82 	of the support for getting C++ file-scope static object constructed
83 	before entering `main'.  */
84 
85 #define FBSD_STARTFILE_SPEC \
86   "%{!shared: \
87      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
88 		       %{!p:%{profile:gcrt1.o%s} \
89 			 %{!profile:crt1.o%s}}}} \
90    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
91 
92 /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
93    the magical crtend.o file (see crtstuff.c) which provides part of
94 	the support for getting C++ file-scope static object constructed
95 	before entering `main', followed by a normal "finalizer" file,
96 	`crtn.o'.  */
97 
98 #define FBSD_ENDFILE_SPEC \
99   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
100 
101 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
102    required by the user-land thread model.  Before __FreeBSD_version
103    500016, select the appropriate libc, depending on whether we're
104    doing profiling or need threads support.  At __FreeBSD_version
105    500016 and later, when threads support is requested include both
106    -lc and the threading lib instead of only -lc_r.  To make matters
107    interesting, we can't actually use __FreeBSD_version provided by
108    <osreldate.h> directly since it breaks cross-compiling.  As a final
109    twist, make it a hard error if -pthread is provided on the command
110    line and gcc was configured with --disable-threads (this will help
111    avoid bug reports from users complaining about threading when they
112    misconfigured the gcc bootstrap but are later consulting FreeBSD
113    manual pages that refer to the mythical -pthread option).  */
114 
115 /* Provide a LIB_SPEC appropriate for FreeBSD.  Just select the appropriate
116    libc, depending on whether we're doing profiling or need threads support.
117    (similar to the default, except no -lg, and no -p).  */
118 
119 #ifdef FBSD_NO_THREADS
120 #define FBSD_LIB_SPEC "							\
121   %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
122 is built with the --enable-threads configure-time option.}		\
123   %{!shared:								\
124     %{!pg: -lc}								\
125     %{pg:  -lc_p}							\
126   }"
127 #else
128 #if FBSD_MAJOR < 5
129 #define FBSD_LIB_SPEC "							\
130   %{!shared:								\
131     %{!pg:								\
132       %{!pthread:-lc}							\
133       %{pthread:-lc_r}}							\
134     %{pg:								\
135       %{!pthread:-lc_p}							\
136       %{pthread:-lc_r_p}}						\
137   }"
138 #else
139 #define FBSD_LIB_SPEC "							\
140   %{!shared:								\
141     %{!pg: %{pthread:-lpthread} -lc}					\
142     %{pg:  %{pthread:-lpthread_p} -lc_p}				\
143   }									\
144   %{shared:								\
145     %{pthread:-lpthread} -lc						\
146   }"
147 #endif
148 #endif
149 
150 #if FBSD_MAJOR < 6
151 #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
152 #else
153 #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
154 #endif
155 
156 #if defined(HAVE_LD_EH_FRAME_HDR) && !defined(LINK_EH_SPEC)
157 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
158 #endif
159 
160 /* Use --as-needed -lgcc_s for eh support.  */
161 #ifdef HAVE_LD_AS_NEEDED
162 #define USE_LD_AS_NEEDED 1
163 #endif
164