2015-09-29 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / config / sol2.h
blobf444e48659db7d9cc039b13d8eb1e34fd0332217
1 /* Operating system specific defines to be used when targeting GCC for any
2 Solaris 2 system.
3 Copyright (C) 2002-2015 Free Software Foundation, Inc.
5 This file is part of GCC.
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.
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 /* We are compiling for Solaris 2 now. */
22 #define TARGET_SOLARIS 1
24 /* wchar_t is called differently in <wchar.h> for 32 and 64-bit
25 compilations. This is called for by SCD 2.4.1, p. 6-83, Figure 6-65
26 (32-bit) and p. 6P-10, Figure 6.38 (64-bit). */
28 #undef WCHAR_TYPE
29 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
31 #undef WCHAR_TYPE_SIZE
32 #define WCHAR_TYPE_SIZE 32
34 /* Same for wint_t. See SCD 2.4.1, p. 6-83, Figure 6-66 (32-bit). There's
35 no corresponding 64-bit definition, but this is what Solaris 8
36 <iso/wchar_iso.h> uses. */
38 #undef WINT_TYPE
39 #define WINT_TYPE (TARGET_64BIT ? "int" : "long int")
41 #undef WINT_TYPE_SIZE
42 #define WINT_TYPE_SIZE 32
44 #define SIG_ATOMIC_TYPE "int"
46 /* ??? This definition of int8_t follows the system header but does
47 not conform to C99. Likewise int_fast8_t, int_least8_t. */
48 #define INT8_TYPE "char"
49 #define INT16_TYPE "short int"
50 #define INT32_TYPE "int"
51 #define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
52 #define UINT8_TYPE "unsigned char"
53 #define UINT16_TYPE "short unsigned int"
54 #define UINT32_TYPE "unsigned int"
55 #define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
57 #define INT_LEAST8_TYPE "char"
58 #define INT_LEAST16_TYPE "short int"
59 #define INT_LEAST32_TYPE "int"
60 #define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
61 #define UINT_LEAST8_TYPE "unsigned char"
62 #define UINT_LEAST16_TYPE "short unsigned int"
63 #define UINT_LEAST32_TYPE "unsigned int"
64 #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
66 #define INT_FAST8_TYPE "char"
67 #define INT_FAST16_TYPE "int"
68 #define INT_FAST32_TYPE "int"
69 #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
70 #define UINT_FAST8_TYPE "unsigned char"
71 #define UINT_FAST16_TYPE "unsigned int"
72 #define UINT_FAST32_TYPE "unsigned int"
73 #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
75 #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
76 #define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
78 #undef CPP_SUBTARGET_SPEC
79 #define CPP_SUBTARGET_SPEC "\
80 %{pthreads|pthread:-D_REENTRANT -D_PTHREADS}"
82 /* Names to predefine in the preprocessor for this target machine. */
83 #define TARGET_SUB_OS_CPP_BUILTINS()
84 #define TARGET_OS_CPP_BUILTINS() \
85 do { \
86 builtin_define_std ("unix"); \
87 builtin_define_std ("sun"); \
88 builtin_define ("__svr4__"); \
89 builtin_define ("__SVR4"); \
90 builtin_assert ("system=unix"); \
91 builtin_assert ("system=svr4"); \
92 /* For C++ we need to add some additional macro \
93 definitions required by the C++ standard \
94 library. */ \
95 if (c_dialect_cxx ()) \
96 { \
97 builtin_define ("__STDC_VERSION__=199901L");\
98 builtin_define ("_XOPEN_SOURCE=600"); \
99 builtin_define ("_LARGEFILE_SOURCE=1"); \
100 builtin_define ("_LARGEFILE64_SOURCE=1"); \
101 builtin_define ("__EXTENSIONS__"); \
103 TARGET_SUB_OS_CPP_BUILTINS(); \
104 } while (0)
106 #define SUBTARGET_OVERRIDE_OPTIONS \
107 do { \
108 solaris_override_options (); \
109 } while (0)
111 #if DEFAULT_ARCH32_P
112 #define MULTILIB_DEFAULTS { "m32" }
113 #else
114 #define MULTILIB_DEFAULTS { "m64" }
115 #endif
117 #if DEFAULT_ARCH32_P
118 #define DEF_ARCH32_SPEC(__str) "%{!m64:" __str "}"
119 #define DEF_ARCH64_SPEC(__str) "%{m64:" __str "}"
120 #else
121 #define DEF_ARCH32_SPEC(__str) "%{m32:" __str "}"
122 #define DEF_ARCH64_SPEC(__str) "%{!m32:" __str "}"
123 #endif
125 /* It's safe to pass -s always, even if -g is not used. Those options are
126 handled by both Sun as and GNU as. */
127 #define ASM_SPEC_BASE \
128 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
130 #define ASM_PIC_SPEC " %{" FPIE_OR_FPIC_SPEC ":-K PIC}"
132 #undef ASM_CPU_DEFAULT_SPEC
133 #define ASM_CPU_DEFAULT_SPEC \
134 (DEFAULT_ARCH32_P ? "\
135 %{m64:" ASM_CPU64_DEFAULT_SPEC "} \
136 %{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
137 " : "\
138 %{m32:" ASM_CPU32_DEFAULT_SPEC "} \
139 %{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
142 #undef LIB_SPEC
143 #define LIB_SPEC \
144 "%{!symbolic:\
145 %{pthreads|pthread:-lpthread} \
146 %{p|pg:-ldl} -lc}"
148 #ifndef CROSS_DIRECTORY_STRUCTURE
149 #undef MD_EXEC_PREFIX
150 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
151 #endif
153 #undef STARTFILE_ARCH_SPEC
154 #define STARTFILE_ARCH_SPEC "%{ansi:values-Xc.o%s} \
155 %{!ansi:values-Xa.o%s}"
157 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
158 #define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \
159 %{" PIE_SPEC ":crtbeginS.o%s} \
160 %{" NO_PIE_SPEC ":crtbegin.o%s}"
161 #else
162 #define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s"
163 #endif
165 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
166 #undef STARTFILE_SPEC
167 #ifdef HAVE_SOLARIS_CRTS
168 /* Since Solaris 11.x and Solaris 12, the OS delivers crt1.o, crti.o, and
169 crtn.o, with a hook for compiler-dependent stuff like profile handling. */
170 #define STARTFILE_SPEC "%{!shared:%{!symbolic: \
171 crt1.o%s \
172 %{p:%e-p is not supported; \
173 pg:crtpg.o%s gmon.o%s; \
174 :crtp.o%s}}} \
175 crti.o%s %(startfile_arch) %(startfile_crtbegin)"
176 #else
177 #define STARTFILE_SPEC "%{!shared:%{!symbolic: \
178 %{p:mcrt1.o%s; \
179 pg:gcrt1.o%s gmon.o%s; \
180 :crt1.o%s}}} \
181 crti.o%s %(startfile_arch) %(startfile_crtbegin)"
182 #endif
184 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
185 #define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \
186 %{" PIE_SPEC ":crtendS.o%s} \
187 %{" NO_PIE_SPEC ":crtend.o%s}}"
188 #else
189 #define ENDFILE_CRTEND_SPEC "crtend.o%s"
190 #endif
192 #undef ENDFILE_SPEC
193 #define ENDFILE_SPEC \
194 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
195 %(endfile_arch) %(endfile_crtend) crtn.o%s"
197 #undef LINK_ARCH32_SPEC_BASE
198 #define LINK_ARCH32_SPEC_BASE \
199 "%{G:-G} \
200 %{YP,*} \
201 %{R*} \
202 %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp%R/lib:%R/usr/lib} \
203 %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib}}}"
205 #undef LINK_ARCH32_SPEC
206 #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
208 /* This should be the same as LINK_ARCH32_SPEC_BASE, except with
209 ARCH64_SUBDIR appended to the paths. */
210 #undef LINK_ARCH64_SPEC_BASE
211 #define LINK_ARCH64_SPEC_BASE \
212 "%{G:-G} \
213 %{YP,*} \
214 %{R*} \
215 %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp/" ARCH64_SUBDIR ":%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "} \
216 %{!p:%{!pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "}}}"
218 #undef LINK_ARCH64_SPEC
219 #ifndef USE_GLD
220 /* FIXME: Used to be SPARC-only. Not SPARC-specfic but for the model name! */
221 #define LINK_ARCH64_SPEC \
222 "%{mcmodel=medlow:-M /usr/lib/ld/" ARCH64_SUBDIR "/map.below4G} " \
223 LINK_ARCH64_SPEC_BASE
224 #else
225 #define LINK_ARCH64_SPEC LINK_ARCH64_SPEC_BASE
226 #endif
228 #ifdef USE_GLD
229 #if DEFAULT_ARCH32_P
230 #define ARCH_DEFAULT_EMULATION ARCH32_EMULATION
231 #else
232 #define ARCH_DEFAULT_EMULATION ARCH64_EMULATION
233 #endif
234 #define TARGET_LD_EMULATION "%{m32:-m " ARCH32_EMULATION "}" \
235 "%{m64:-m " ARCH64_EMULATION "}" \
236 "%{!m32:%{!m64:-m " ARCH_DEFAULT_EMULATION "}} "
237 #else
238 #define TARGET_LD_EMULATION ""
239 #endif
241 #undef LINK_ARCH_SPEC
242 #if DISABLE_MULTILIB
243 #if DEFAULT_ARCH32_P
244 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
245 %{m32:%(link_arch32)} \
246 %{m64:%edoes not support multilib} \
247 %{!m32:%{!m64:%(link_arch_default)}} \
249 #else
250 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
251 %{m32:%edoes not support multilib} \
252 %{m64:%(link_arch64)} \
253 %{!m32:%{!m64:%(link_arch_default)}} \
255 #endif
256 #else
257 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
258 %{m32:%(link_arch32)} \
259 %{m64:%(link_arch64)} \
260 %{!m32:%{!m64:%(link_arch_default)}}"
261 #endif
263 #define LINK_ARCH_DEFAULT_SPEC \
264 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
266 #undef SUBTARGET_EXTRA_SPECS
267 #define SUBTARGET_EXTRA_SPECS \
268 { "startfile_arch", STARTFILE_ARCH_SPEC }, \
269 { "startfile_crtbegin", STARTFILE_CRTBEGIN_SPEC }, \
270 { "link_arch32", LINK_ARCH32_SPEC }, \
271 { "link_arch64", LINK_ARCH64_SPEC }, \
272 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
273 { "link_arch", LINK_ARCH_SPEC }, \
274 { "endfile_arch", ENDFILE_ARCH_SPEC }, \
275 { "endfile_crtend", ENDFILE_CRTEND_SPEC }, \
276 SUBTARGET_CPU_EXTRA_SPECS
278 /* C++11 programs need -lrt for nanosleep. */
279 #define TIME_LIBRARY "rt"
281 #ifndef USE_GLD
282 /* With Sun ld, -rdynamic is a no-op. */
283 #define RDYNAMIC_SPEC ""
284 #else
285 /* GNU ld needs --export-dynamic to implement -rdynamic. */
286 #define RDYNAMIC_SPEC "--export-dynamic"
287 #endif
289 #ifndef USE_GLD
290 /* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder. */
291 #define LINK_LIBGCC_MAPFILE_SPEC \
292 "%{shared|shared-libgcc:-M %slibgcc-unwind.map}"
293 #else
294 /* GNU ld doesn't support direct binding. */
295 #define LINK_LIBGCC_MAPFILE_SPEC ""
296 #endif
298 /* Clear hardware capabilities, either explicitly or with OpenMP:
299 #pragma openmp declare simd creates clones for SSE2, AVX, and AVX2. */
300 #ifdef HAVE_LD_CLEARCAP
301 #define LINK_CLEARCAP_SPEC " %{mclear-hwcap|fopenmp*:-M %sclearcap.map}"
302 #else
303 #define LINK_CLEARCAP_SPEC ""
304 #endif
306 #undef LINK_SPEC
307 #define LINK_SPEC \
308 "%{h*} %{v:-V} \
309 %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \
310 %{static:-dn -Bstatic} \
311 %{shared:-G -dy %{!mimpure-text:-z text}} " \
312 LINK_LIBGCC_MAPFILE_SPEC LINK_CLEARCAP_SPEC " \
313 %{symbolic:-Bsymbolic -G -dy -z text} \
314 %(link_arch) \
315 %{Qy:} %{!Qn:-Qy}"
317 /* Use --as-needed/-z ignore -lgcc_s for eh support. */
318 #ifdef HAVE_LD_AS_NEEDED
319 #define USE_LD_AS_NEEDED 1
320 #endif
322 #ifdef USE_GLD
323 /* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs
324 --eh-frame-hdr to create the required .eh_frame_hdr sections. */
325 #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
326 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
327 #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
328 #endif
330 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
331 #ifdef USE_GLD
332 /* Assert -z text by default to match Solaris ld. */
333 #define LD_PIE_SPEC "-pie %{!mimpure-text:-z text}"
334 #else
335 /* Solaris ld needs -z type=pie instead of -pie. */
336 #define LD_PIE_SPEC "-z type=pie %{mimpure-text:-z textoff}"
337 #endif
338 #else
339 /* Error out if some part of PIE support is missing. */
340 #define LINK_PIE_SPEC \
341 "%{no-pie:} %{pie:%e-pie is not supported in this configuration} "
342 #endif
344 /* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
345 produce the same format. */
346 #define NM_FLAGS "-png"
348 /* The system headers under Solaris 2 are C++-aware since 2.0. */
349 #define NO_IMPLICIT_EXTERN_C
351 #define STDC_0_IN_SYSTEM_HEADERS 1
353 /* Support Solaris-specific format checking for cmn_err. */
354 #define TARGET_N_FORMAT_TYPES 1
355 #define TARGET_FORMAT_TYPES solaris_format_types
357 /* #pragma init and #pragma fini are implemented on top of init and
358 fini attributes. */
359 #define SOLARIS_ATTRIBUTE_TABLE \
360 { "init", 0, 0, true, false, false, NULL, false }, \
361 { "fini", 0, 0, true, false, false, NULL, false }
363 /* Solaris-specific #pragmas are implemented on top of attributes. Hook in
364 the bits from config/sol2.c. */
365 #define SUBTARGET_INSERT_ATTRIBUTES solaris_insert_attributes
366 #define SUBTARGET_ATTRIBUTE_TABLE SOLARIS_ATTRIBUTE_TABLE
368 /* Allow macro expansion in #pragma pack. */
369 #define HANDLE_PRAGMA_PACK_WITH_EXPANSION
371 #define TARGET_CXX_DECL_MANGLING_CONTEXT solaris_cxx_decl_mangling_context
373 /* Solaris/x86 as and gas support unquoted section names. */
374 #ifndef SECTION_NAME_FORMAT
375 #define SECTION_NAME_FORMAT "%s"
376 #endif
378 /* This is how to declare the size of a function. For Solaris, we output
379 any .init or .fini entries here. */
380 #undef ASM_DECLARE_FUNCTION_SIZE
381 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
382 do \
384 if (!flag_inhibit_size_directive) \
385 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
386 solaris_output_init_fini (FILE, DECL); \
388 while (0)
390 #ifndef USE_GAS
391 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
392 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
394 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
396 /* The Solaris assembler cannot grok .stabd directives. */
397 #undef NO_DBX_BNSYM_ENSYM
398 #define NO_DBX_BNSYM_ENSYM 1
399 #endif
401 #ifndef USE_GLD
402 /* The Solaris linker doesn't understand constructor priorities. */
403 #undef SUPPORTS_INIT_PRIORITY
404 #define SUPPORTS_INIT_PRIORITY 0
405 #endif
407 /* Solaris has an implementation of __enable_execute_stack. */
408 #define HAVE_ENABLE_EXECUTE_STACK
410 /* Static stack checking is supported by means of probes. */
411 #define STACK_CHECK_STATIC_BUILTIN 1
413 #define TARGET_POSIX_IO
415 /* Solaris 10 has the float and long double forms of math functions.
416 We redefine this hook so the version from elfos.h header won't be used. */
417 #undef TARGET_LIBC_HAS_FUNCTION
418 #define TARGET_LIBC_HAS_FUNCTION default_libc_has_function
420 extern GTY(()) tree solaris_pending_aligns;
421 extern GTY(()) tree solaris_pending_inits;
422 extern GTY(()) tree solaris_pending_finis;