Small ChangeLog tweak.
[official-gcc.git] / gcc / config / sol2.h
blob1ae7f9f0e0135e59a3a52f49fa5c95a55a9fbee2
1 /* Operating system specific defines to be used when targeting GCC for any
2 Solaris 2 system.
3 Copyright (C) 2002-2017 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 ("__EXTENSIONS__"); \
118 TARGET_SUB_OS_CPP_BUILTINS(); \
119 } while (0)
121 #define SUBTARGET_OVERRIDE_OPTIONS \
122 do { \
123 solaris_override_options (); \
124 } while (0)
126 #if DEFAULT_ARCH32_P
127 #define MULTILIB_DEFAULTS { "m32" }
128 #else
129 #define MULTILIB_DEFAULTS { "m64" }
130 #endif
132 #if DEFAULT_ARCH32_P
133 #define DEF_ARCH32_SPEC(__str) "%{!m64:" __str "}"
134 #define DEF_ARCH64_SPEC(__str) "%{m64:" __str "}"
135 #else
136 #define DEF_ARCH32_SPEC(__str) "%{m32:" __str "}"
137 #define DEF_ARCH64_SPEC(__str) "%{!m32:" __str "}"
138 #endif
140 /* It's safe to pass -s always, even if -g is not used. Those options are
141 handled by both Sun as and GNU as. */
142 #define ASM_SPEC_BASE \
143 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
145 #define ASM_PIC_SPEC " %{" FPIE_OR_FPIC_SPEC ":-K PIC}"
147 #undef ASM_CPU_DEFAULT_SPEC
148 #define ASM_CPU_DEFAULT_SPEC \
149 (DEFAULT_ARCH32_P ? "\
150 %{m64:" ASM_CPU64_DEFAULT_SPEC "} \
151 %{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
152 " : "\
153 %{m32:" ASM_CPU32_DEFAULT_SPEC "} \
154 %{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
157 #undef LIB_SPEC
158 #define LIB_SPEC \
159 "%{!symbolic:\
160 %{pthreads|pthread:-lpthread} \
161 %{p|pg:-ldl} -lc}"
163 #ifndef CROSS_DIRECTORY_STRUCTURE
164 #undef MD_EXEC_PREFIX
165 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
166 #endif
168 /* Enable constructor priorities if the configured linker supports it. */
169 #undef SUPPORTS_INIT_PRIORITY
170 #define SUPPORTS_INIT_PRIORITY HAVE_INITFINI_ARRAY_SUPPORT
172 #undef STARTFILE_ARCH_SPEC
173 #define STARTFILE_ARCH_SPEC "%{ansi:values-Xc.o%s} \
174 %{!ansi:values-Xa.o%s}"
176 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
177 #define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \
178 %{" PIE_SPEC ":crtbeginS.o%s} \
179 %{" NO_PIE_SPEC ":crtbegin.o%s}"
180 #else
181 #define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s"
182 #endif
184 #if ENABLE_VTABLE_VERIFY
185 #if SUPPORTS_INIT_PRIORITY
186 #define STARTFILE_VTV_SPEC \
187 "%{fvtable-verify=none:%s; \
188 fvtable-verify=preinit:vtv_start_preinit.o%s; \
189 fvtable-verify=std:vtv_start.o%s}"
190 #define ENDFILE_VTV_SPEC \
191 "%{fvtable-verify=none:%s; \
192 fvtable-verify=preinit:vtv_end_preinit.o%s; \
193 fvtable-verify=std:vtv_end.o%s}"
194 #else /* !SUPPORTS_INIT_PRIORITY */
195 #define STARTFILE_VTV_SPEC \
196 "%{fvtable-verify=*: \
197 %e-fvtable-verify=%* is not supported in this configuration}"
198 #define ENDFILE_VTV_SPEC ""
199 #endif /* !SUPPORTS_INIT_PRIORITY */
200 #else /* !ENABLE_VTABLE_VERIFY */
201 #define STARTFILE_VTV_SPEC ""
202 #define ENDFILE_VTV_SPEC ""
203 #endif /* !ENABLE_VTABLE_VERIFY */
205 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
206 #undef STARTFILE_SPEC
207 #ifdef HAVE_SOLARIS_CRTS
208 /* Since Solaris 11.x and Solaris 12, the OS delivers crt1.o, crti.o, and
209 crtn.o, with a hook for compiler-dependent stuff like profile handling. */
210 #define STARTFILE_SPEC "%{!shared:%{!symbolic: \
211 crt1.o%s \
212 %{p:%e-p is not supported; \
213 pg:crtpg.o%s gmon.o%s; \
214 :crtp.o%s}}} \
215 crti.o%s %(startfile_arch) %(startfile_crtbegin) \
216 %(startfile_vtv)"
217 #else
218 #define STARTFILE_SPEC "%{!shared:%{!symbolic: \
219 %{p:mcrt1.o%s; \
220 pg:gcrt1.o%s gmon.o%s; \
221 :crt1.o%s}}} \
222 crti.o%s %(startfile_arch) %(startfile_crtbegin) \
223 %(startfile_vtv)"
224 #endif
226 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
227 #define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \
228 %{" PIE_SPEC ":crtendS.o%s} \
229 %{" NO_PIE_SPEC ":crtend.o%s}}"
230 #else
231 #define ENDFILE_CRTEND_SPEC "crtend.o%s"
232 #endif
234 #undef ENDFILE_SPEC
235 #define ENDFILE_SPEC \
236 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
237 %(endfile_arch) %(endfile_vtv) %(endfile_crtend) crtn.o%s"
239 #undef LINK_ARCH32_SPEC_BASE
240 #define LINK_ARCH32_SPEC_BASE \
241 "%{G:-G} \
242 %{YP,*} \
243 %{R*} \
244 %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp%R/lib:%R/usr/lib} \
245 %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib}}}"
247 #undef LINK_ARCH32_SPEC
248 #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
250 /* This should be the same as LINK_ARCH32_SPEC_BASE, except with
251 ARCH64_SUBDIR appended to the paths. */
252 #undef LINK_ARCH64_SPEC_BASE
253 #define LINK_ARCH64_SPEC_BASE \
254 "%{G:-G} \
255 %{YP,*} \
256 %{R*} \
257 %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp/" ARCH64_SUBDIR ":%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "} \
258 %{!p:%{!pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "}}}"
260 #undef LINK_ARCH64_SPEC
261 #ifndef USE_GLD
262 /* FIXME: Used to be SPARC-only. Not SPARC-specfic but for the model name! */
263 #define LINK_ARCH64_SPEC \
264 "%{mcmodel=medlow:-M /usr/lib/ld/" ARCH64_SUBDIR "/map.below4G} " \
265 LINK_ARCH64_SPEC_BASE
266 #else
267 #define LINK_ARCH64_SPEC LINK_ARCH64_SPEC_BASE
268 #endif
270 #ifdef USE_GLD
271 #if DEFAULT_ARCH32_P
272 #define ARCH_DEFAULT_EMULATION ARCH32_EMULATION
273 #else
274 #define ARCH_DEFAULT_EMULATION ARCH64_EMULATION
275 #endif
276 #define TARGET_LD_EMULATION "%{m32:-m " ARCH32_EMULATION "}" \
277 "%{m64:-m " ARCH64_EMULATION "}" \
278 "%{!m32:%{!m64:-m " ARCH_DEFAULT_EMULATION "}} "
279 #else
280 #define TARGET_LD_EMULATION ""
281 #endif
283 #undef LINK_ARCH_SPEC
284 #if DISABLE_MULTILIB
285 #if DEFAULT_ARCH32_P
286 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
287 %{m32:%(link_arch32)} \
288 %{m64:%edoes not support multilib} \
289 %{!m32:%{!m64:%(link_arch_default)}} \
291 #else
292 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
293 %{m32:%edoes not support multilib} \
294 %{m64:%(link_arch64)} \
295 %{!m32:%{!m64:%(link_arch_default)}} \
297 #endif
298 #else
299 #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
300 %{m32:%(link_arch32)} \
301 %{m64:%(link_arch64)} \
302 %{!m32:%{!m64:%(link_arch_default)}}"
303 #endif
305 #define LINK_ARCH_DEFAULT_SPEC \
306 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
308 #undef SUBTARGET_EXTRA_SPECS
309 #define SUBTARGET_EXTRA_SPECS \
310 { "startfile_arch", STARTFILE_ARCH_SPEC }, \
311 { "startfile_crtbegin", STARTFILE_CRTBEGIN_SPEC }, \
312 { "startfile_vtv", STARTFILE_VTV_SPEC }, \
313 { "link_arch32", LINK_ARCH32_SPEC }, \
314 { "link_arch64", LINK_ARCH64_SPEC }, \
315 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
316 { "link_arch", LINK_ARCH_SPEC }, \
317 { "endfile_arch", ENDFILE_ARCH_SPEC }, \
318 { "endfile_crtend", ENDFILE_CRTEND_SPEC }, \
319 { "endfile_vtv", ENDFILE_VTV_SPEC }, \
320 SUBTARGET_CPU_EXTRA_SPECS
322 /* C++11 programs need -lrt for nanosleep. */
323 #define TIME_LIBRARY "rt"
325 #ifndef USE_GLD
326 /* With Sun ld, -rdynamic is a no-op. */
327 #define RDYNAMIC_SPEC ""
328 #else
329 /* GNU ld needs --export-dynamic to implement -rdynamic. */
330 #define RDYNAMIC_SPEC "--export-dynamic"
331 #endif
333 #ifndef USE_GLD
334 /* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder. */
335 #define LINK_LIBGCC_MAPFILE_SPEC \
336 "%{shared|shared-libgcc:-M %slibgcc-unwind.map}"
337 #else
338 /* GNU ld doesn't support direct binding. */
339 #define LINK_LIBGCC_MAPFILE_SPEC ""
340 #endif
342 /* Clear hardware capabilities, either explicitly or with OpenMP:
343 #pragma openmp declare simd creates clones for SSE2, AVX, and AVX2. */
344 #ifdef HAVE_LD_CLEARCAP
345 #define LINK_CLEARCAP_SPEC " %{mclear-hwcap|fopenmp*:-M %sclearcap.map}"
346 #else
347 #define LINK_CLEARCAP_SPEC ""
348 #endif
350 #undef LINK_SPEC
351 #define LINK_SPEC \
352 "%{h*} %{v:-V} \
353 %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \
354 %{static:-dn -Bstatic} \
355 %{shared:-G -dy %{!mimpure-text:-z text}} " \
356 LINK_LIBGCC_MAPFILE_SPEC LINK_CLEARCAP_SPEC " \
357 %{symbolic:-Bsymbolic -G -dy -z text} \
358 %(link_arch) \
359 %{Qy:} %{!Qn:-Qy}"
361 /* Use --as-needed/-z ignore -lgcc_s for eh support. */
362 #ifdef HAVE_LD_AS_NEEDED
363 #define USE_LD_AS_NEEDED 1
364 #endif
366 #ifdef USE_GLD
367 /* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs
368 --eh-frame-hdr to create the required .eh_frame_hdr sections. */
369 #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
370 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
371 #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
372 #endif
374 #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
375 #ifdef USE_GLD
376 /* Assert -z text by default to match Solaris ld. */
377 #define LD_PIE_SPEC "-pie %{!mimpure-text:-z text}"
378 #else
379 /* Solaris ld needs -z type=pie instead of -pie. */
380 #define LD_PIE_SPEC "-z type=pie %{mimpure-text:-z textoff}"
381 #endif
382 #else
383 /* Error out if some part of PIE support is missing. */
384 #define LINK_PIE_SPEC \
385 "%{no-pie:} %{pie:%e-pie is not supported in this configuration} "
386 #endif
388 /* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
389 produce the same format. */
390 #define NM_FLAGS "-png"
392 /* The system headers under Solaris 2 are C++-aware since 2.0. */
393 #define NO_IMPLICIT_EXTERN_C
395 #define STDC_0_IN_SYSTEM_HEADERS 1
397 /* Support Solaris-specific format checking for cmn_err. */
398 #define TARGET_N_FORMAT_TYPES 1
399 #define TARGET_FORMAT_TYPES solaris_format_types
401 /* #pragma init and #pragma fini are implemented on top of init and
402 fini attributes. */
403 #define SOLARIS_ATTRIBUTE_TABLE \
404 { "init", 0, 0, true, false, false, NULL, false }, \
405 { "fini", 0, 0, true, false, false, NULL, false }
407 /* Solaris-specific #pragmas are implemented on top of attributes. Hook in
408 the bits from config/sol2.c. */
409 #define SUBTARGET_INSERT_ATTRIBUTES solaris_insert_attributes
410 #define SUBTARGET_ATTRIBUTE_TABLE SOLARIS_ATTRIBUTE_TABLE
412 /* Allow macro expansion in #pragma pack. */
413 #define HANDLE_PRAGMA_PACK_WITH_EXPANSION
415 #define TARGET_CXX_DECL_MANGLING_CONTEXT solaris_cxx_decl_mangling_context
417 /* Solaris/x86 as and gas support unquoted section names. */
418 #ifndef SECTION_NAME_FORMAT
419 #define SECTION_NAME_FORMAT "%s"
420 #endif
422 /* This is how to declare the size of a function. For Solaris, we output
423 any .init or .fini entries here. */
424 #undef ASM_DECLARE_FUNCTION_SIZE
425 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
426 do \
428 if (!flag_inhibit_size_directive) \
429 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
430 solaris_output_init_fini (FILE, DECL); \
432 while (0)
434 #ifndef USE_GAS
435 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
436 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
438 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
440 /* The Solaris assembler cannot grok .stabd directives. */
441 #undef NO_DBX_BNSYM_ENSYM
442 #define NO_DBX_BNSYM_ENSYM 1
443 #endif
445 /* Solaris has an implementation of __enable_execute_stack. */
446 #define HAVE_ENABLE_EXECUTE_STACK
448 /* Static stack checking is supported by means of probes. */
449 #define STACK_CHECK_STATIC_BUILTIN 1
451 #define TARGET_POSIX_IO
453 /* Solaris 10 has the float and long double forms of math functions.
454 We redefine this hook so the version from elfos.h header won't be used. */
455 #undef TARGET_LIBC_HAS_FUNCTION
456 #define TARGET_LIBC_HAS_FUNCTION default_libc_has_function
458 extern GTY(()) tree solaris_pending_aligns;
459 extern GTY(()) tree solaris_pending_inits;
460 extern GTY(()) tree solaris_pending_finis;