sol2.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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.
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GCC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. /* We are compiling for Solaris 2 now. */
  17. #define TARGET_SOLARIS 1
  18. /* wchar_t is called differently in <wchar.h> for 32 and 64-bit
  19. compilations. This is called for by SCD 2.4.1, p. 6-83, Figure 6-65
  20. (32-bit) and p. 6P-10, Figure 6.38 (64-bit). */
  21. #undef WCHAR_TYPE
  22. #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
  23. #undef WCHAR_TYPE_SIZE
  24. #define WCHAR_TYPE_SIZE 32
  25. /* Same for wint_t. See SCD 2.4.1, p. 6-83, Figure 6-66 (32-bit). There's
  26. no corresponding 64-bit definition, but this is what Solaris 8
  27. <iso/wchar_iso.h> uses. */
  28. #undef WINT_TYPE
  29. #define WINT_TYPE (TARGET_64BIT ? "int" : "long int")
  30. #undef WINT_TYPE_SIZE
  31. #define WINT_TYPE_SIZE 32
  32. #define SIG_ATOMIC_TYPE "int"
  33. /* ??? This definition of int8_t follows the system header but does
  34. not conform to C99. Likewise int_fast8_t, int_least8_t. */
  35. #define INT8_TYPE "char"
  36. #define INT16_TYPE "short int"
  37. #define INT32_TYPE "int"
  38. #define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
  39. #define UINT8_TYPE "unsigned char"
  40. #define UINT16_TYPE "short unsigned int"
  41. #define UINT32_TYPE "unsigned int"
  42. #define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
  43. #define INT_LEAST8_TYPE "char"
  44. #define INT_LEAST16_TYPE "short int"
  45. #define INT_LEAST32_TYPE "int"
  46. #define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
  47. #define UINT_LEAST8_TYPE "unsigned char"
  48. #define UINT_LEAST16_TYPE "short unsigned int"
  49. #define UINT_LEAST32_TYPE "unsigned int"
  50. #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
  51. #define INT_FAST8_TYPE "char"
  52. #define INT_FAST16_TYPE "int"
  53. #define INT_FAST32_TYPE "int"
  54. #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
  55. #define UINT_FAST8_TYPE "unsigned char"
  56. #define UINT_FAST16_TYPE "unsigned int"
  57. #define UINT_FAST32_TYPE "unsigned int"
  58. #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
  59. #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
  60. #define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
  61. #undef CPP_SUBTARGET_SPEC
  62. #define CPP_SUBTARGET_SPEC "\
  63. %{pthreads|pthread:-D_REENTRANT -D_PTHREADS}"
  64. /* Names to predefine in the preprocessor for this target machine. */
  65. #define TARGET_SUB_OS_CPP_BUILTINS()
  66. #define TARGET_OS_CPP_BUILTINS() \
  67. do { \
  68. builtin_define_std ("unix"); \
  69. builtin_define_std ("sun"); \
  70. builtin_define ("__svr4__"); \
  71. builtin_define ("__SVR4"); \
  72. builtin_assert ("system=unix"); \
  73. builtin_assert ("system=svr4"); \
  74. /* For C++ we need to add some additional macro \
  75. definitions required by the C++ standard \
  76. library. */ \
  77. if (c_dialect_cxx ()) \
  78. { \
  79. builtin_define ("__STDC_VERSION__=199901L");\
  80. builtin_define ("_XOPEN_SOURCE=600"); \
  81. builtin_define ("_LARGEFILE_SOURCE=1"); \
  82. builtin_define ("_LARGEFILE64_SOURCE=1"); \
  83. builtin_define ("__EXTENSIONS__"); \
  84. } \
  85. TARGET_SUB_OS_CPP_BUILTINS(); \
  86. } while (0)
  87. #define SUBTARGET_OVERRIDE_OPTIONS \
  88. do { \
  89. solaris_override_options (); \
  90. } while (0)
  91. #if DEFAULT_ARCH32_P
  92. #define MULTILIB_DEFAULTS { "m32" }
  93. #else
  94. #define MULTILIB_DEFAULTS { "m64" }
  95. #endif
  96. #if DEFAULT_ARCH32_P
  97. #define DEF_ARCH32_SPEC(__str) "%{!m64:" __str "}"
  98. #define DEF_ARCH64_SPEC(__str) "%{m64:" __str "}"
  99. #else
  100. #define DEF_ARCH32_SPEC(__str) "%{m32:" __str "}"
  101. #define DEF_ARCH64_SPEC(__str) "%{!m32:" __str "}"
  102. #endif
  103. /* It's safe to pass -s always, even if -g is not used. Those options are
  104. handled by both Sun as and GNU as. */
  105. #define ASM_SPEC_BASE \
  106. "%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
  107. #define ASM_PIC_SPEC " %{fpic|fpie|fPIC|fPIE:-K PIC}"
  108. #undef ASM_CPU_DEFAULT_SPEC
  109. #define ASM_CPU_DEFAULT_SPEC \
  110. (DEFAULT_ARCH32_P ? "\
  111. %{m64:" ASM_CPU64_DEFAULT_SPEC "} \
  112. %{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
  113. " : "\
  114. %{m32:" ASM_CPU32_DEFAULT_SPEC "} \
  115. %{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
  116. ")
  117. #undef LIB_SPEC
  118. #define LIB_SPEC \
  119. "%{!symbolic:\
  120. %{pthreads|pthread:-lpthread} \
  121. %{p|pg:-ldl} -lc}"
  122. #ifndef CROSS_DIRECTORY_STRUCTURE
  123. #undef MD_EXEC_PREFIX
  124. #define MD_EXEC_PREFIX "/usr/ccs/bin/"
  125. #endif
  126. #undef STARTFILE_ARCH_SPEC
  127. #define STARTFILE_ARCH_SPEC "%{ansi:values-Xc.o%s} \
  128. %{!ansi:values-Xa.o%s}"
  129. /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
  130. #undef STARTFILE_SPEC
  131. #define STARTFILE_SPEC "%{!shared: \
  132. %{!symbolic: \
  133. %{p:mcrt1.o%s} \
  134. %{!p: \
  135. %{pg:gcrt1.o%s gmon.o%s} \
  136. %{!pg:crt1.o%s}}}} \
  137. crti.o%s %(startfile_arch) \
  138. crtbegin.o%s"
  139. #undef ENDFILE_SPEC
  140. #define ENDFILE_SPEC \
  141. "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
  142. crtend.o%s crtn.o%s"
  143. #undef LINK_ARCH32_SPEC_BASE
  144. #define LINK_ARCH32_SPEC_BASE \
  145. "%{G:-G} \
  146. %{YP,*} \
  147. %{R*} \
  148. %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp%R/lib:%R/usr/lib} \
  149. %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib}}}"
  150. #undef LINK_ARCH32_SPEC
  151. #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
  152. /* This should be the same as LINK_ARCH32_SPEC_BASE, except with
  153. ARCH64_SUBDIR appended to the paths. */
  154. #undef LINK_ARCH64_SPEC_BASE
  155. #define LINK_ARCH64_SPEC_BASE \
  156. "%{G:-G} \
  157. %{YP,*} \
  158. %{R*} \
  159. %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp/" ARCH64_SUBDIR ":%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "} \
  160. %{!p:%{!pg:-Y P,%R/lib/" ARCH64_SUBDIR ":%R/usr/lib/" ARCH64_SUBDIR "}}}"
  161. #undef LINK_ARCH64_SPEC
  162. #ifndef USE_GLD
  163. /* FIXME: Used to be SPARC-only. Not SPARC-specfic but for the model name! */
  164. #define LINK_ARCH64_SPEC \
  165. "%{mcmodel=medlow:-M /usr/lib/ld/" ARCH64_SUBDIR "/map.below4G} " \
  166. LINK_ARCH64_SPEC_BASE
  167. #else
  168. #define LINK_ARCH64_SPEC LINK_ARCH64_SPEC_BASE
  169. #endif
  170. #ifdef USE_GLD
  171. #if DEFAULT_ARCH32_P
  172. #define ARCH_DEFAULT_EMULATION ARCH32_EMULATION
  173. #else
  174. #define ARCH_DEFAULT_EMULATION ARCH64_EMULATION
  175. #endif
  176. #define TARGET_LD_EMULATION "%{m32:-m " ARCH32_EMULATION "}" \
  177. "%{m64:-m " ARCH64_EMULATION "}" \
  178. "%{!m32:%{!m64:-m " ARCH_DEFAULT_EMULATION "}} "
  179. #else
  180. #define TARGET_LD_EMULATION ""
  181. #endif
  182. #undef LINK_ARCH_SPEC
  183. #if DISABLE_MULTILIB
  184. #if DEFAULT_ARCH32_P
  185. #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
  186. %{m32:%(link_arch32)} \
  187. %{m64:%edoes not support multilib} \
  188. %{!m32:%{!m64:%(link_arch_default)}} \
  189. "
  190. #else
  191. #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
  192. %{m32:%edoes not support multilib} \
  193. %{m64:%(link_arch64)} \
  194. %{!m32:%{!m64:%(link_arch_default)}} \
  195. "
  196. #endif
  197. #else
  198. #define LINK_ARCH_SPEC TARGET_LD_EMULATION " \
  199. %{m32:%(link_arch32)} \
  200. %{m64:%(link_arch64)} \
  201. %{!m32:%{!m64:%(link_arch_default)}}"
  202. #endif
  203. #define LINK_ARCH_DEFAULT_SPEC \
  204. (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
  205. #undef SUBTARGET_EXTRA_SPECS
  206. #define SUBTARGET_EXTRA_SPECS \
  207. { "startfile_arch", STARTFILE_ARCH_SPEC }, \
  208. { "link_arch32", LINK_ARCH32_SPEC }, \
  209. { "link_arch64", LINK_ARCH64_SPEC }, \
  210. { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
  211. { "link_arch", LINK_ARCH_SPEC }, \
  212. SUBTARGET_CPU_EXTRA_SPECS
  213. /* C++11 programs need -lrt for nanosleep. */
  214. #define TIME_LIBRARY "rt"
  215. #ifndef USE_GLD
  216. /* With Sun ld, -rdynamic is a no-op. */
  217. #define RDYNAMIC_SPEC ""
  218. #else
  219. /* GNU ld needs --export-dynamic to implement -rdynamic. */
  220. #define RDYNAMIC_SPEC "--export-dynamic"
  221. #endif
  222. #ifndef USE_GLD
  223. /* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder. */
  224. #define LINK_LIBGCC_MAPFILE_SPEC \
  225. "%{shared|shared-libgcc:-M %slibgcc-unwind.map}"
  226. #else
  227. /* GNU ld doesn't support direct binding. */
  228. #define LINK_LIBGCC_MAPFILE_SPEC ""
  229. #endif
  230. /* Clear hardware capabilities, either explicitly or with OpenMP:
  231. #pragma openmp declare simd creates clones for SSE2, AVX, and AVX2. */
  232. #ifdef HAVE_LD_CLEARCAP
  233. #define LINK_CLEARCAP_SPEC " %{mclear-hwcap|fopenmp*:-M %sclearcap.map}"
  234. #else
  235. #define LINK_CLEARCAP_SPEC ""
  236. #endif
  237. #undef LINK_SPEC
  238. #define LINK_SPEC \
  239. "%{h*} %{v:-V} \
  240. %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \
  241. %{static:-dn -Bstatic} \
  242. %{shared:-G -dy %{!mimpure-text:-z text}} " \
  243. LINK_LIBGCC_MAPFILE_SPEC LINK_CLEARCAP_SPEC " \
  244. %{symbolic:-Bsymbolic -G -dy -z text} \
  245. %(link_arch) \
  246. %{Qy:} %{!Qn:-Qy}"
  247. /* Use --as-needed/-z ignore -lgcc_s for eh support. */
  248. #ifdef HAVE_LD_AS_NEEDED
  249. #define USE_LD_AS_NEEDED 1
  250. #endif
  251. #ifdef USE_GLD
  252. /* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs
  253. --eh-frame-hdr to create the required .eh_frame_hdr sections. */
  254. #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
  255. #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
  256. #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
  257. #endif
  258. /* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
  259. produce the same format. */
  260. #define NM_FLAGS "-png"
  261. /* The system headers under Solaris 2 are C++-aware since 2.0. */
  262. #define NO_IMPLICIT_EXTERN_C
  263. #define STDC_0_IN_SYSTEM_HEADERS 1
  264. /* Support Solaris-specific format checking for cmn_err. */
  265. #define TARGET_N_FORMAT_TYPES 1
  266. #define TARGET_FORMAT_TYPES solaris_format_types
  267. /* #pragma init and #pragma fini are implemented on top of init and
  268. fini attributes. */
  269. #define SOLARIS_ATTRIBUTE_TABLE \
  270. { "init", 0, 0, true, false, false, NULL, false }, \
  271. { "fini", 0, 0, true, false, false, NULL, false }
  272. /* Solaris-specific #pragmas are implemented on top of attributes. Hook in
  273. the bits from config/sol2.c. */
  274. #define SUBTARGET_INSERT_ATTRIBUTES solaris_insert_attributes
  275. #define SUBTARGET_ATTRIBUTE_TABLE SOLARIS_ATTRIBUTE_TABLE
  276. /* Allow macro expansion in #pragma pack. */
  277. #define HANDLE_PRAGMA_PACK_WITH_EXPANSION
  278. #define TARGET_CXX_DECL_MANGLING_CONTEXT solaris_cxx_decl_mangling_context
  279. /* Solaris/x86 as and gas support unquoted section names. */
  280. #ifndef SECTION_NAME_FORMAT
  281. #define SECTION_NAME_FORMAT "%s"
  282. #endif
  283. /* This is how to declare the size of a function. For Solaris, we output
  284. any .init or .fini entries here. */
  285. #undef ASM_DECLARE_FUNCTION_SIZE
  286. #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
  287. do \
  288. { \
  289. if (!flag_inhibit_size_directive) \
  290. ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
  291. solaris_output_init_fini (FILE, DECL); \
  292. } \
  293. while (0)
  294. #ifndef USE_GAS
  295. #undef TARGET_ASM_ASSEMBLE_VISIBILITY
  296. #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
  297. #define AS_NEEDS_DASH_FOR_PIPED_INPUT
  298. /* The Solaris assembler cannot grok .stabd directives. */
  299. #undef NO_DBX_BNSYM_ENSYM
  300. #define NO_DBX_BNSYM_ENSYM 1
  301. #endif
  302. #ifndef USE_GLD
  303. /* The Solaris linker doesn't understand constructor priorities. */
  304. #undef SUPPORTS_INIT_PRIORITY
  305. #define SUPPORTS_INIT_PRIORITY 0
  306. #endif
  307. /* Solaris has an implementation of __enable_execute_stack. */
  308. #define HAVE_ENABLE_EXECUTE_STACK
  309. /* Static stack checking is supported by means of probes. */
  310. #define STACK_CHECK_STATIC_BUILTIN 1
  311. #define TARGET_POSIX_IO
  312. /* Solaris 10 has the float and long double forms of math functions.
  313. We redefine this hook so the version from elfos.h header won't be used. */
  314. #undef TARGET_LIBC_HAS_FUNCTION
  315. #define TARGET_LIBC_HAS_FUNCTION default_libc_has_function
  316. extern GTY(()) tree solaris_pending_aligns;
  317. extern GTY(()) tree solaris_pending_inits;
  318. extern GTY(()) tree solaris_pending_finis;