Fix build on sparc64-linux-gnu.
[official-gcc.git] / gcc / config / sol2.h
blob8b67e78dee06d05ab845be5250ba858a9edbe9c1
1 /* Operating system specific defines to be used when targeting GCC for any
2 Solaris 2 system.
3 Copyright (C) 2002-2018 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 switch (cxx_dialect) \
98 { \
99 case cxx98: \
100 case cxx11: \
101 case cxx14: \
102 /* C++11 and C++14 are based on C99. \
103 libstdc++ makes use of C99 features \
104 even for C++98. */ \
105 builtin_define ("__STDC_VERSION__=199901L");\
106 break; \
108 default: \
109 /* C++17 is based on C11. */ \
110 builtin_define ("__STDC_VERSION__=201112L");\
111 break; \
113 builtin_define ("_XOPEN_SOURCE=600"); \
114 builtin_define ("_LARGEFILE_SOURCE=1"); \
115 builtin_define ("_LARGEFILE64_SOURCE=1"); \
116 builtin_define ("_FILE_OFFSET_BITS=64"); \
117 builtin_define ("__EXTENSIONS__"); \
119 TARGET_SUB_OS_CPP_BUILTINS(); \
120 } while (0)
122 #define SUBTARGET_OVERRIDE_OPTIONS \
123 do { \
124 solaris_override_options (); \
125 } while (0)
127 #if DEFAULT_ARCH32_P
128 #define MULTILIB_DEFAULTS { "m32" }
129 #else
130 #define MULTILIB_DEFAULTS { "m64" }
131 #endif
133 #if DEFAULT_ARCH32_P
134 #define DEF_ARCH32_SPEC(__str) "%{!m64:" __str "}"
135 #define DEF_ARCH64_SPEC(__str) "%{m64:" __str "}"
136 #else
137 #define DEF_ARCH32_SPEC(__str) "%{m32:" __str "}"
138 #define DEF_ARCH64_SPEC(__str) "%{!m32:" __str "}"
139 #endif
141 /* It's safe to pass -s always, even if -g is not used. Those options are
142 handled by both Sun as and GNU as. */
143 #define ASM_SPEC_BASE \
144 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
146 #define ASM_PIC_SPEC " %{" FPIE_OR_FPIC_SPEC ":-K PIC}"
148 #undef ASM_CPU_DEFAULT_SPEC
149 #define ASM_CPU_DEFAULT_SPEC \
150 (DEFAULT_ARCH32_P ? "\
151 %{m64:" ASM_CPU64_DEFAULT_SPEC "} \
152 %{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
153 " : "\
154 %{m32:" ASM_CPU32_DEFAULT_SPEC "} \
155 %{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
158 #undef LIB_SPEC
159 #define LIB_SPEC \
160 "%{!symbolic:\
161 %{pthreads|pthread:-lpthread} \
162 %{p|pg:-ldl} -lc}"
164 #ifndef CROSS_DIRECTORY_STRUCTURE
165 #undef MD_EXEC_PREFIX
166 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
167 #endif
169 /* Enable constructor priorities if the configured linker supports it. */
170 #undef SUPPORTS_INIT_PRIORITY
171 #define SUPPORTS_INIT_PRIORITY HAVE_INITFINI_ARRAY_SUPPORT
173 /* Solaris libc and libm implement multiple behaviours for various
174 interfaces that have changed over the years in different versions of the
175 C standard. The behaviour is controlled by linking corresponding
176 values-*.o objects. Each of these objects contain alternate definitions
177 of one or more variables that the libraries use to select which
178 conflicting behaviour they should exhibit. There are two sets of these
179 objects, values-X*.o and values-xpg*.o.
181 The values-X[ac].o objects set the variable _lib_version. The Studio C
182 compilers use values-Xc.o with either -Xc or (since Studio 12.6)
183 -pedantic to select strictly conformant ISO C behaviour, otherwise
184 values-Xa.o. Since -pedantic is a diagnostic option only in GCC, we
185 need to specifiy the -std=c* options and -std=iso9899:199409. We
186 traditionally include -ansi, which affects C and C++, and also -std=c++*
187 for consistency.
189 The values-xpg[46].o objects define either or both __xpg[46] variables,
190 selecting XPG4 mode (__xpg4) and conforming C99/SUSv3 behavior (__xpg6).
192 Since GCC 5, gcc defaults to -std=gnu11 or higher, so we link
193 values-xpg6.o to get C99 semantics. Besides, most of the runtime
194 libraries always require C99 semantics.
196 Since only one instance of _lib_version and __xpg[46] takes effekt (the
197 first in ld.so.1's search path), we only link the values-*.o files into
198 executable programs. */
199 #undef STARTFILE_ARCH_SPEC
200 #define STARTFILE_ARCH_SPEC \
201 "%{!shared:%{!symbolic: \
202 %{ansi|std=c*|std=iso9899\\:199409:values-Xc.o%s; :values-Xa.o%s} \
203 %{std=c90|std=gnu90:values-xpg4.o%s; :values-xpg6.o%s}}}"
205 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
206 #define STARTFILE_CRTBEGIN_SPEC "%{static:crtbegin.o%s; \
207 shared|" PIE_SPEC ":crtbeginS.o%s; \
208 :crtbegin.o%s}"
209 #else
210 #define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s"
211 #endif
213 #if ENABLE_VTABLE_VERIFY
214 #if SUPPORTS_INIT_PRIORITY
215 #define STARTFILE_VTV_SPEC \
216 "%{fvtable-verify=none:%s; \
217 fvtable-verify=preinit:vtv_start_preinit.o%s; \
218 fvtable-verify=std:vtv_start.o%s}"
219 #define ENDFILE_VTV_SPEC \
220 "%{fvtable-verify=none:%s; \
221 fvtable-verify=preinit:vtv_end_preinit.o%s; \
222 fvtable-verify=std:vtv_end.o%s}"
223 #else /* !SUPPORTS_INIT_PRIORITY */
224 #define STARTFILE_VTV_SPEC \
225 "%{fvtable-verify=*: \
226 %e-fvtable-verify=%* is not supported in this configuration}"
227 #define ENDFILE_VTV_SPEC ""
228 #endif /* !SUPPORTS_INIT_PRIORITY */
229 #else /* !ENABLE_VTABLE_VERIFY */
230 #define STARTFILE_VTV_SPEC ""
231 #define ENDFILE_VTV_SPEC ""
232 #endif /* !ENABLE_VTABLE_VERIFY */
234 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
235 #undef STARTFILE_SPEC
236 #ifdef HAVE_SOLARIS_CRTS
237 /* Since Solaris 11.4, the OS delivers crt1.o, crti.o, and crtn.o, with a hook
238 for compiler-dependent stuff like profile handling. */
239 #define STARTFILE_SPEC "%{!shared:%{!symbolic: \
240 crt1.o%s \
241 %{p:%e-p is not supported; \
242 pg:crtpg.o%s gmon.o%s; \
243 :crtp.o%s}}} \
244 crti.o%s %(startfile_arch) %(startfile_crtbegin) \
245 %(startfile_vtv)"
246 #else
247 #define STARTFILE_SPEC "%{!shared:%{!symbolic: \
248 %{p:mcrt1.o%s; \
249 pg:gcrt1.o%s gmon.o%s; \
250 :crt1.o%s}}} \
251 crti.o%s %(startfile_arch) %(startfile_crtbegin) \
252 %(startfile_vtv)"
253 #endif
255 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
256 #define ENDFILE_CRTEND_SPEC "%{static:crtend.o%s; \
257 shared|" PIE_SPEC ":crtendS.o%s; \
258 :crtend.o%s}"
259 #else
260 #define ENDFILE_CRTEND_SPEC "crtend.o%s"
261 #endif
263 #undef ENDFILE_SPEC
264 #define ENDFILE_SPEC \
265 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
266 %(endfile_arch) %(endfile_vtv) %(endfile_crtend) crtn.o%s"
268 #undef LINK_ARCH32_SPEC_BASE
269 #define LINK_ARCH32_SPEC_BASE \
270 "%{G:-G} \
271 %{YP,*} \
272 %{R*} \
273 %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp%R/lib:%R/usr/lib} \
274 %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib}}}"
276 #undef LINK_ARCH32_SPEC
277 #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
279 /* This should be the same as LINK_ARCH32_SPEC_BASE, except with
280 ARCH64_SUBDIR appended to the paths. */
281 #undef LINK_ARCH64_SPEC_BASE
282 #define LINK_ARCH64_SPEC_BASE \
283 "%{G:-G} \
284 %{YP,*} \
285 %{R*} \
286 %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp/" ARCH64_SUBDIR ":%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "} \
287 %{!p:%{!pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "}}}"
289 #undef LINK_ARCH64_SPEC
290 #ifndef USE_GLD
291 /* FIXME: Used to be SPARC-only. Not SPARC-specfic but for the model name! */
292 #define LINK_ARCH64_SPEC \
293 "%{mcmodel=medlow:-M /usr/lib/ld/" ARCH64_SUBDIR "/map.below4G} " \
294 LINK_ARCH64_SPEC_BASE
295 #else
296 #define LINK_ARCH64_SPEC LINK_ARCH64_SPEC_BASE
297 #endif
299 #ifdef USE_GLD
300 #if DEFAULT_ARCH32_P
301 #define ARCH_DEFAULT_EMULATION ARCH32_EMULATION
302 #else
303 #define ARCH_DEFAULT_EMULATION ARCH64_EMULATION
304 #endif
305 #define TARGET_LD_EMULATION "%{m32:-m " ARCH32_EMULATION "}" \
306 "%{m64:-m " ARCH64_EMULATION "}" \
307 "%{!m32:%{!m64:-m " ARCH_DEFAULT_EMULATION "}} "
308 #else
309 #define TARGET_LD_EMULATION ""
310 #endif
312 #undef LINK_ARCH_SPEC
313 #if DISABLE_MULTILIB
314 #if DEFAULT_ARCH32_P
315 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
316 %{m32:%(link_arch32)} \
317 %{m64:%edoes not support multilib} \
318 %{!m32:%{!m64:%(link_arch_default)}} \
320 #else
321 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
322 %{m32:%edoes not support multilib} \
323 %{m64:%(link_arch64)} \
324 %{!m32:%{!m64:%(link_arch_default)}} \
326 #endif
327 #else
328 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
329 %{m32:%(link_arch32)} \
330 %{m64:%(link_arch64)} \
331 %{!m32:%{!m64:%(link_arch_default)}}"
332 #endif
334 #define LINK_ARCH_DEFAULT_SPEC \
335 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
337 #undef SUBTARGET_EXTRA_SPECS
338 #define SUBTARGET_EXTRA_SPECS \
339 { "startfile_arch", STARTFILE_ARCH_SPEC }, \
340 { "startfile_crtbegin", STARTFILE_CRTBEGIN_SPEC }, \
341 { "startfile_vtv", STARTFILE_VTV_SPEC }, \
342 { "link_arch32", LINK_ARCH32_SPEC }, \
343 { "link_arch64", LINK_ARCH64_SPEC }, \
344 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
345 { "link_arch", LINK_ARCH_SPEC }, \
346 { "endfile_arch", ENDFILE_ARCH_SPEC }, \
347 { "endfile_crtend", ENDFILE_CRTEND_SPEC }, \
348 { "endfile_vtv", ENDFILE_VTV_SPEC }, \
349 SUBTARGET_CPU_EXTRA_SPECS
351 /* C++11 programs need -lrt for nanosleep. */
352 #define TIME_LIBRARY "rt"
354 #ifndef USE_GLD
355 /* With Sun ld, -rdynamic is a no-op. */
356 #define RDYNAMIC_SPEC ""
357 #else
358 /* GNU ld needs --export-dynamic to implement -rdynamic. */
359 #define RDYNAMIC_SPEC "--export-dynamic"
360 #endif
362 #ifndef USE_GLD
363 /* Prefer native form with Solaris ld. */
364 #define SYSROOT_SPEC "-z sysroot=%R"
365 #endif
367 #ifndef USE_GLD
368 /* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder. */
369 #define LINK_LIBGCC_MAPFILE_SPEC \
370 "%{shared|shared-libgcc:-M %slibgcc-unwind.map}"
371 #else
372 /* GNU ld doesn't support direct binding. */
373 #define LINK_LIBGCC_MAPFILE_SPEC ""
374 #endif
376 /* Clear hardware capabilities, either explicitly or with OpenMP:
377 #pragma openmp declare simd creates clones for SSE2, AVX, and AVX2. */
378 #ifdef HAVE_LD_CLEARCAP
379 #define LINK_CLEARCAP_SPEC " %{mclear-hwcap|fopenmp*:-M %sclearcap.map}"
380 #else
381 #define LINK_CLEARCAP_SPEC ""
382 #endif
384 #undef LINK_SPEC
385 #define LINK_SPEC \
386 "%{h*} %{v:-V} \
387 %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \
388 %{static:-dn -Bstatic} \
389 %{shared:-G -dy %{!mimpure-text:-z text}} " \
390 LINK_LIBGCC_MAPFILE_SPEC LINK_CLEARCAP_SPEC " \
391 %{symbolic:-Bsymbolic -G -dy -z text} \
392 %(link_arch) \
393 %{Qy:} %{!Qn:-Qy}"
395 /* Use --as-needed/-z ignore -lgcc_s for eh support. */
396 #ifdef HAVE_LD_AS_NEEDED
397 #define USE_LD_AS_NEEDED 1
398 #endif
400 #ifdef USE_GLD
401 /* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs
402 --eh-frame-hdr to create the required .eh_frame_hdr sections. */
403 #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
404 #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
405 #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
406 #endif
408 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
409 #ifdef USE_GLD
410 /* Assert -z text by default to match Solaris ld. */
411 #define LD_PIE_SPEC "-pie %{!mimpure-text:-z text}"
412 #else
413 /* Solaris ld needs -z type=pie instead of -pie. */
414 #define LD_PIE_SPEC "-z type=pie %{mimpure-text:-z textoff}"
415 #endif
416 #else
417 /* Error out if some part of PIE support is missing. */
418 #define LINK_PIE_SPEC \
419 "%{no-pie:} %{pie:%e-pie is not supported in this configuration} "
420 #endif
422 /* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
423 produce the same format. */
424 #define NM_FLAGS "-png"
426 #define STDC_0_IN_SYSTEM_HEADERS 1
428 /* Support Solaris-specific format checking for cmn_err. */
429 #define TARGET_N_FORMAT_TYPES 1
430 #define TARGET_FORMAT_TYPES solaris_format_types
432 /* #pragma init and #pragma fini are implemented on top of init and
433 fini attributes. */
434 #define SOLARIS_ATTRIBUTE_TABLE \
435 { "init", 0, 0, true, false, false, false, NULL, NULL }, \
436 { "fini", 0, 0, true, false, false, false, NULL, NULL }
438 /* Solaris-specific #pragmas are implemented on top of attributes. Hook in
439 the bits from config/sol2.c. */
440 #define SUBTARGET_INSERT_ATTRIBUTES solaris_insert_attributes
441 #define SUBTARGET_ATTRIBUTE_TABLE SOLARIS_ATTRIBUTE_TABLE
443 /* Allow macro expansion in #pragma pack. */
444 #define HANDLE_PRAGMA_PACK_WITH_EXPANSION
446 #define TARGET_CXX_DECL_MANGLING_CONTEXT solaris_cxx_decl_mangling_context
448 /* Solaris/x86 as and gas support unquoted section names. */
449 #ifndef SECTION_NAME_FORMAT
450 #define SECTION_NAME_FORMAT "%s"
451 #endif
453 /* This is how to declare the size of a function. For Solaris, we output
454 any .init or .fini entries here. */
455 #undef ASM_DECLARE_FUNCTION_SIZE
456 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
457 do \
459 if (!flag_inhibit_size_directive) \
460 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
461 solaris_output_init_fini (FILE, DECL); \
463 while (0)
465 #ifndef USE_GAS
466 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
467 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
469 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
471 /* The Solaris assembler cannot grok .stabd directives. */
472 #undef NO_DBX_BNSYM_ENSYM
473 #define NO_DBX_BNSYM_ENSYM 1
474 #endif
476 /* Solaris has an implementation of __enable_execute_stack. */
477 #define HAVE_ENABLE_EXECUTE_STACK
479 /* Static stack checking is supported by means of probes. */
480 #define STACK_CHECK_STATIC_BUILTIN 1
482 #define TARGET_POSIX_IO
484 /* Solaris 10 has the float and long double forms of math functions.
485 We redefine this hook so the version from elfos.h header won't be used. */
486 #undef TARGET_LIBC_HAS_FUNCTION
487 #define TARGET_LIBC_HAS_FUNCTION default_libc_has_function
489 extern GTY(()) tree solaris_pending_aligns;
490 extern GTY(()) tree solaris_pending_inits;
491 extern GTY(()) tree solaris_pending_finis;