Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / cpp / gcc / config / darwin.h
blob3682bd2b2c5303dd769b22644579d1138e42b152
1 /* Target definitions for Darwin (Mac OS X) systems.
2 Copyright (C) 1989-2022 Free Software Foundation, Inc.
3 Contributed by Apple Computer 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 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.
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/>. */
26 #ifndef CONFIG_DARWIN_H
27 #define CONFIG_DARWIN_H
29 /* The definitions in this file are common to all processor types
30 running Darwin, which is the kernel for Mac OS X. Darwin is
31 basically a BSD user layer laid over a Mach kernel, then evolved
32 for many years (at NeXT) in parallel with other Unix systems. So
33 while the runtime is a somewhat idiosyncratic Mach-based thing,
34 other definitions look like they would for a BSD variant. */
36 /* Although NeXT ran on many different architectures, as of Jan 2001
37 the only supported Darwin targets are PowerPC and x86. */
39 /* One of Darwin's NeXT legacies is the Mach-O format, which is partly
40 like a.out and partly like COFF, with additional features like
41 multi-architecture binary support. */
43 #define DARWIN_X86 0
44 #define DARWIN_PPC 0
46 #define OBJECT_FORMAT_MACHO 1
48 /* Suppress g++ attempt to link in the math library automatically. */
49 #define MATH_LIBRARY ""
51 /* We have atexit. */
53 #define HAVE_ATEXIT
55 /* Define an empty body for the function do_global_dtors() in libgcc2.c. */
57 #define DO_GLOBAL_DTORS_BODY
59 /* Register static destructors to run from __cxa_atexit instead of putting
60 them into a .mod_term_funcs section. */
62 #define TARGET_DTORS_FROM_CXA_ATEXIT true
64 /* The string value for __SIZE_TYPE__. */
66 #ifndef SIZE_TYPE
67 #define SIZE_TYPE "long unsigned int"
68 #endif
70 /* Type used for ptrdiff_t, as a string used in a declaration. */
72 #undef PTRDIFF_TYPE
73 #define PTRDIFF_TYPE "int"
75 /* wchar_t is int. */
77 #undef WCHAR_TYPE
78 #define WCHAR_TYPE "int"
79 #undef WCHAR_TYPE_SIZE
80 #define WCHAR_TYPE_SIZE 32
82 #define INT8_TYPE "signed char"
83 #define INT16_TYPE "short int"
84 #define INT32_TYPE "int"
85 #define INT64_TYPE "long long int"
86 #define UINT8_TYPE "unsigned char"
87 #define UINT16_TYPE "short unsigned int"
88 #define UINT32_TYPE "unsigned int"
89 #define UINT64_TYPE "long long unsigned int"
91 #define INT_LEAST8_TYPE "signed char"
92 #define INT_LEAST16_TYPE "short int"
93 #define INT_LEAST32_TYPE "int"
94 #define INT_LEAST64_TYPE "long long int"
95 #define UINT_LEAST8_TYPE "unsigned char"
96 #define UINT_LEAST16_TYPE "short unsigned int"
97 #define UINT_LEAST32_TYPE "unsigned int"
98 #define UINT_LEAST64_TYPE "long long unsigned int"
100 #define INT_FAST8_TYPE "signed char"
101 #define INT_FAST16_TYPE "short int"
102 #define INT_FAST32_TYPE "int"
103 #define INT_FAST64_TYPE "long long int"
104 #define UINT_FAST8_TYPE "unsigned char"
105 #define UINT_FAST16_TYPE "short unsigned int"
106 #define UINT_FAST32_TYPE "unsigned int"
107 #define UINT_FAST64_TYPE "long long unsigned int"
109 #define INTPTR_TYPE "long int"
110 #define UINTPTR_TYPE "long unsigned int"
112 #define SIG_ATOMIC_TYPE "int"
114 /* Default to using the NeXT-style runtime, since that's what is
115 pre-installed on Darwin systems. */
117 #define NEXT_OBJC_RUNTIME 100508
119 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
120 we want to retain compatibility with older gcc versions. */
122 #undef DEFAULT_PCC_STRUCT_RETURN
123 #define DEFAULT_PCC_STRUCT_RETURN 0
125 /* True if pragma ms_struct is in effect. */
126 extern GTY(()) int darwin_ms_struct;
128 /* Darwin has a user convenience feature where some linker options are exposed
129 at the driver level (so one can type "-all_load" instead of "-Wl,-all_load"
130 or "-Xlinker -all_load"). We retain this, but now these options are all
131 marked as 'Driver' and we process them as early as possible so that they
132 get allocated to the right toolchain command. There are a couple of special
133 cases where these driver opts are used multiple times, or to control
134 operations on more than one command (e.g. dynamiclib). These are handled
135 specially and we then add %<xxxx specs for the commands that _don't_ need
136 them. NOTE: the order of 'shared' and 'dynamiclib' is significant, hence
137 they are placed out of alphabetical order at the start. Likewise, we keep
138 a couple of cases where a negative option originally appeared after the
139 positive alternate, potentially overriding it.
140 When we report an error with %e, it seems necessary to strip the option
141 before doing so, otherwise it survives to the cc1 command line (%e doesn't
142 appear to abort the program before this).
143 Right now there's no mechanism to split up the "variable portion" (%*) of
144 the matched spec string, so where we have some driver specs that take 2
145 or 3 arguments, these cannot be processed here, but are deferred until the
146 LINK_SPEC, where they are copied verbatim.
147 We have a "safe" version of the MacOS version string, that's been sanity-
148 checked and truncated to minor version. If the 'tiny' (3rd) portion of the
149 value is not significant, it's better to use this in version-compare(). */
151 #undef SUBTARGET_DRIVER_SELF_SPECS
152 #define SUBTARGET_DRIVER_SELF_SPECS \
153 "%{shared:%{!dynamiclib:-dynamiclib}} %<shared", \
154 "%{static:%{dynamic|dynamiclib:%econflicting code generation switches}}",\
155 "%{dynamiclib:-Xlinker -dylib \
156 %{allowable_client*:-Xlinker -allowable_client -Xlinker %*} \
157 %<allowable_client* \
158 %{bundle_loader*: %<bundle_loader* \
159 %e-bundle_loader not allowed with -dynamiclib} \
160 %{client_name*: %<client_name* \
161 %e-client_name not allowed with -dynamiclib} \
162 %{compatibility_version*:\
163 -Xlinker -dylib_compatibility_version -Xlinker %*} \
164 %<compatibility_version* \
165 %{current_version*:-Xlinker -dylib_current_version -Xlinker %*} \
166 %<current_version* \
167 %{install_name*:-Xlinker -dylib_install_name -Xlinker %* } \
168 %<install_name* \
169 %{keep_private_externs: %<keep_private_externs \
170 %e-keep_private_externs not allowed with -dynamiclib} \
171 %{private_bundle: %<private_bundle \
172 %e-private_bundle not allowed with -dynamiclib} \
173 }", \
174 "%{!dynamiclib: \
175 %{bundle_loader*:-Xlinker -bundle_loader -Xlinker %*} \
176 %<bundle_loader* \
177 %{client_name*:-Xlinker -client_name -Xlinker %*} \
178 %<client_name* \
179 %{compatibility_version*: %<compatibility_version* \
180 %e-compatibility_version only allowed with -dynamiclib} \
181 %{current_version*: %<current_version* \
182 %e-current_version only allowed with -dynamiclib} \
183 %{install_name*: %<install_name* \
184 %e-install_name only allowed with -dynamiclib} \
185 %{keep_private_externs:-Xlinker -keep_private_externs} \
186 %<keep_private_externs \
187 %{private_bundle:-Xlinker -private_bundle} \
188 %<private_bundle \
189 }", \
190 "%{all_load:-Xlinker -all_load} %<all_load", \
191 "%{arch_errors_fatal:-Xlinker -arch_errors_fatal} \
192 %<arch_errors_fatal", \
193 "%{bind_at_load:-Xlinker -bind_at_load} %<bind_at_load", \
194 "%{bundle:%{!dynamiclib:-Xlinker -bundle; \
195 :%e-bundle not allowed with -dynamiclib}}", \
196 "%{dead_strip:-Xlinker -dead_strip} %<dead_strip", \
197 "%{dylib_file*:-Xlinker -dylib_file -Xlinker %*} %<dylib_file*", \
198 "%{dylinker:-Xlinker -dylinker} %<dylinker", \
199 "%{dylinker_install_name*:-Xlinker -dylinker_install_name -Xlinker %*}\
200 %<dylinker_install_name*", \
201 "%{exported_symbols_list*:-Xlinker -exported_symbols_list -Xlinker %*}\
202 %<exported_symbols_list", \
203 "%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls", \
204 "%{fterminated-vtables: -fapple-kext} %<fterminated-vtables", \
205 "%{fapple-kext|mkernel:-static}", \
206 "%{filelist*:-Xlinker -filelist -Xlinker %*} %<filelist*", \
207 "%{flat_namespace:-Xlinker -flat_namespace} %<flat_namespace", \
208 "%{force_cpusubtype_ALL:-Xassembler -force_cpusubtype_ALL} ", \
209 "%{force_flat_namespace: \
210 %{!dynamiclib:-Xlinker -force_flat_namespace; \
211 :%e-force_flat_namespace not allowed with -dynamiclib}} \
212 %<force_flat_namespace", \
213 "%{framework*:-Xlinker -framework -Xlinker %*} %<framework*", \
214 "%{gfull:-g -fno-eliminate-unused-debug-symbols} %<gfull", \
215 "%{gused:-g -feliminate-unused-debug-symbols} %<gused", \
216 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
217 %<gsplit-dwarf", \
218 "%{headerpad_max_install_names:-Xlinker -headerpad_max_install_names}\
219 %<headerpad_max_install_names", \
220 "%{image_base*:-Xlinker -image_base -Xlinker %*} %<image_base*", \
221 "%{init*:-Xlinker -init -Xlinker %*} %<init*", \
222 "%{multi_module:-Xlinker -multi_module} %<multi_module", \
223 "%{multiply_defined*:-Xlinker -multiply_defined -Xlinker %*; \
224 :%{shared-libgcc: \
225 %:version-compare(< 10.5 asm_macosx_version_min= -Xlinker) \
226 %:version-compare(< 10.5 asm_macosx_version_min= -multiply_defined) \
227 %:version-compare(< 10.5 asm_macosx_version_min= -Xlinker) \
228 %:version-compare(< 10.5 asm_macosx_version_min= suppress)}} \
229 %<multiply_defined*", \
230 "%{multiplydefinedunused*:\
231 -Xlinker -multiply_defined_unused -Xlinker %*} \
232 %<multiplydefinedunused* ", \
233 "%{no_dead_strip_inits_and_terms:\
234 -Xlinker -no_dead_strip_inits_and_terms} \
235 %<no_dead_strip_inits_and_terms", \
236 "%{nofixprebinding:-Xlinker -nofixprebinding} %<nofixprebinding", \
237 "%{nomultidefs:-Xlinker -nomultidefs} %<nomultidefs", \
238 "%{pagezero_size*:-Xlinker -pagezero_size -Xlinker %*} \
239 %<pagezero_size", \
240 "%{prebind:-Xlinker -prebind} %<prebind", \
241 "%{noprebind:-Xlinker -noprebind} %<noprebind", \
242 "%{prebind_all_twolevel_modules:\
243 -Xlinker -prebind_all_twolevel_modules} \
244 %<prebind_all_twolevel_modules", \
245 "%{preload:-Xlinker -preload} %<preload", \
246 "%{read_only_relocs*:-Xlinker -read_only_relocs -Xlinker %*} \
247 %<read_only_relocs*", \
248 "%{rpath*: -Xlinker -rpath -Xlinker %*}", \
249 "%{seg_addr_table_filename*: \
250 -Xlinker -seg_addr_table_filename -Xlinker %*} \
251 %<seg_addr_table_filename*", \
252 "%{seg_addr_table*:-Xlinker -seg_addr_table -Xlinker %*} \
253 %<seg_addr_table*", \
254 "%{seg1addr*:-Xlinker -image_base -Xlinker %*} %<seg1addr*", \
255 "%{seglinkedit:-Xlinker -seglinkedit} %<seglinkedit", \
256 "%{noseglinkedit:-Xlinker -noseglinkedit} %<noseglinkedit", \
257 "%{segs_read_only_addr*:-Xlinker -segs_read_only_addr -Xlinker %*} \
258 %<segs_read_only_addr*", \
259 "%{segs_read_write_addr*:-Xlinker -segs_read_write_addr -Xlinker %*} \
260 %<segs_read_write_addr*", \
261 "%{single_module:-Xlinker -single_module} %<single_module", \
262 "%{sub_library*:-Xlinker -sub_library -Xlinker %*} %<sub_library*", \
263 "%{sub_umbrella*:-Xlinker -sub_umbrella -Xlinker %*} %<sub_umbrella*",\
264 "%{twolevel_namespace:-Xlinker -twolevel_namespace} \
265 %<twolevel_namespace", \
266 "%{twolevel_namespace_hints:-Xlinker -twolevel_namespace_hints} \
267 %<twolevel_namespace_hints", \
268 "%{umbrella*:-Xlinker -umbrella -Xlinker %*} %<umbrella*", \
269 "%{undefined*:-Xlinker -undefined -Xlinker %*} %<undefined*", \
270 "%{unexported_symbols_list*:\
271 -Xlinker -unexported_symbols_list -Xlinker %*} \
272 %<unexported_symbols_list*", \
273 "%{weak_reference_mismatches*:\
274 -Xlinker -weak_reference_mismatches -Xlinker %*} \
275 %<weak_reference_mismatches*", \
276 "%{whyload:-Xlinker -whyload} %<whyload", \
277 "%{whatsloaded:-Xlinker -whatsloaded} %<whatsloaded", \
278 "%{w:-Xlinker -w}", \
279 "%<y*", \
280 "%<Mach "
282 #if LD64_HAS_EXPORT_DYNAMIC
283 #define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}"
284 #else
285 #define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
286 #endif
288 /* Code built with mdynamic-no-pic does not support PIE/PIC, so we disallow
289 these combinations; we also ensure that the no_pie option is passed to
290 ld64 on system versions that default to PIE when mdynamic-no-pic is given.
291 FIXME: we should check that the linker supports the -pie and -no_pie.
292 options. */
293 #define DARWIN_PIE_SPEC \
294 "%{pie|fpie|fPIE:\
295 %{mdynamic-no-pic: \
296 %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
297 :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }; \
298 mdynamic-no-pic:%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } "
300 #define DARWIN_NOPIE_SPEC \
301 "%{no-pie|fno-pie|fno-PIE: \
302 %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }"
304 #define DARWIN_CC1_SPEC \
305 "%<dynamic %<dynamiclib %<force_cpusubtype_ALL "
307 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
308 do { \
309 darwin_override_options (); \
310 } while (0)
312 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do { \
313 if (flag_mkernel || flag_apple_kext) \
315 if (flag_use_cxa_atexit == 2) \
316 flag_use_cxa_atexit = 0; \
317 /* kexts should always be built without the coalesced sections \
318 because the kernel loader doesn't grok such sections. */ \
319 flag_weak = 0; \
320 /* No RTTI in kexts. */ \
321 flag_rtti = 0; \
323 } while (0)
325 /* Machine dependent cpp options. Don't add more options here, add
326 them to darwin_cpp_builtins in darwin-c.cc. */
328 #undef CPP_SPEC
329 #define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \
330 " %{pthread:-D_REENTRANT} "
332 /* This is a fix for PR41260 by passing -no_compact_unwind on darwin10 and
333 later until the assembler, linker and libunwind are able to deal with the
334 output from GCC.
336 FIXME: we should check that the linker supports the option.
339 #define DARWIN_NOCOMPACT_UNWIND \
340 " %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) "
342 /* In Darwin linker specs we can put -lcrt0.o and ld will search the library
343 path for crt0.o or -lcrtx.a and it will search for libcrtx.a. As for
344 other ports, we can also put xxx.{o,a}%s and get the appropriate complete
345 startfile absolute directory. This latter point is important when we want
346 to override ld's rule of .dylib being found ahead of .a and the user wants
347 the convenience library to be linked. */
349 /* The LINK_COMMAND spec is mostly a clone of the standard LINK_COMMAND_SPEC,
350 plus precomp, libtool, and fat build additions.
352 In general, random Darwin linker flags should go into LINK_SPEC
353 instead of LINK_COMMAND_SPEC. The command spec is better for
354 specifying the handling of options understood by generic Unix
355 linkers, and for positional arguments like libraries. */
357 #define LINK_COMMAND_SPEC_A \
358 "%{!c:%{!E:%{!S:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*: \
359 %(linker)" \
360 LINK_PLUGIN_SPEC \
361 "%{flto*:%<fcompare-debug*} \
362 %{flto} %{fno-lto} %{flto=*} \
363 %l " LINK_COMPRESS_DEBUG_SPEC \
364 "%X %{s} %{t} %{Z} %{u*} \
365 %{e*} %{r} \
366 %{o*}%{!o:-o a.out} \
367 %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \
368 %{L*} %(link_libgcc) %o \
369 %{!r:%{!nostdlib:%{!nodefaultlibs:\
370 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
371 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \
372 %{static|static-libgcc|static-libstdc++|static-libgfortran: \
373 libgomp.a%s; : -lgomp }} \
374 %{fgnu-tm: \
375 %{static|static-libgcc|static-libstdc++|static-libgfortran: \
376 libitm.a%s; : -litm }} \
377 %{%:sanitize(address): -lasan } \
378 %{%:sanitize(undefined): -lubsan } \
379 %(link_ssp) \
380 %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \
381 %(link_gcc_c_sequence) \
382 %{!nodefaultexport:%{dylib|dynamiclib|bundle: \
383 %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
384 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
385 %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
386 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
387 %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
388 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
389 %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
390 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
391 }} \
392 }}}\
393 %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
394 DARWIN_PIE_SPEC \
395 DARWIN_NOPIE_SPEC \
396 DARWIN_RDYNAMIC \
397 DARWIN_NOCOMPACT_UNWIND \
398 "}}}}}}} %<pie %<no-pie %<rdynamic %<X %<rpath "
400 /* Spec that controls whether the debug linker is run automatically for
401 a link step. This needs to be done if there is a source file on the
402 command line which will result in a temporary object (and debug is
403 enabled). */
405 #define DSYMUTIL_SPEC \
406 "%{!c:%{!E:%{!S:%{!r:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*:\
407 %{g*:%{!gctf:%{!gbtf:%{!gstabs*:%{%:debug-level-gt(0): -idsym \
408 %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\
409 .f95|.f03|.f77|.for|.F|.F90|.F95|.F03|.d: -dsym }\
410 }}}}}\
411 }}}}}}}}"
413 #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC
415 /* Tell collect2 to run dsymutil for us as necessary. */
416 #define COLLECT_RUN_DSYMUTIL 1
418 /* We only want one instance of %G, since libSystem (Darwin's -lc) does not
419 depend on libgcc. */
420 #undef LINK_GCC_C_SEQUENCE_SPEC
421 #define LINK_GCC_C_SEQUENCE_SPEC \
422 "%G %{!nolibc:%L} "
424 /* ld64 supports a sysroot, it just has a different name and there's no easy
425 way to check for it at config time. */
426 #undef HAVE_LD_SYSROOT
427 #define HAVE_LD_SYSROOT 1
428 /* It seems the only (working) way to get a space after %R is to append a
429 dangling '/'. */
430 #define SYSROOT_SPEC "%{!isysroot*:-syslibroot %R/ } "
432 /* Do the same as clang, for now, and insert the sysroot for ld when an
433 isysroot is specified. */
434 #define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*} "
436 /* Suppress the addition of extra prefix paths when a sysroot is in use. */
437 #define STANDARD_STARTFILE_PREFIX_1 ""
438 #define STANDARD_STARTFILE_PREFIX_2 ""
441 /* Please keep the random linker options in alphabetical order.
442 Note that options taking arguments may appear multiple times on a command
443 line with different arguments each time, so put a * after their names so
444 all of them get passed. */
445 #define LINK_SPEC \
446 "%{static}%{!static:%{!dynamic:-dynamic}} \
447 %:remove-outfile(-ldl) \
448 %:remove-outfile(-lm) \
449 %:remove-outfile(-lpthread) \
450 %{fgnu-runtime: %{static|static-libgcc: \
451 %:replace-outfile(-lobjc libobjc-gnu.a%s); \
452 :%:replace-outfile(-lobjc -lobjc-gnu )}}\
453 %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\
454 %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos libgphobos.a%s)}\
455 %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\
456 %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\
457 %{force_cpusubtype_ALL:-arch %(darwin_arch)} \
458 %{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\
459 LINK_SYSROOT_SPEC \
460 "%{mmacosx-version-min=*:-macosx_version_min %*} \
461 %{sectalign*} %{sectcreate*} %{sectobjectsymbols*} %{sectorder*} \
462 %{segaddr*} %{segcreate*} %{segprot*} "
464 /* Machine dependent libraries. */
466 #define LIB_SPEC "%{!static:-lSystem}"
469 Note that by default, -lgcc_eh is not linked against.
470 This is because,in general, we need to unwind through system libraries that
471 are linked with the shared unwinder in libunwind (or libgcc_s for 10.4/5).
473 For -static-libgcc: < 10.6, use the unwinder in libgcc_eh (and find
474 the emultls impl. there too).
476 For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and
477 we find the emutls impl from lemutls_w. In either case, the builtins etc.
478 are linked from -lgcc.
480 When we have specified shared-libgcc or any case that might require
481 exceptions, we pull the libgcc content (including emulated tls) from
482 -lgcc_s.1 in GCC and the unwinder from /usr/lib/libgcc_s.1 for < 10.6 and
483 libSystem for >= 10.6 respectively.
484 Otherwise, we just link the emutls/builtins from convenience libs.
486 If we need exceptions, prior to 10.3.9, then we have to link the static
487 eh lib, since there's no shared version on the system.
489 In all cases, libgcc_s.1 will be installed with the compiler, or any app
490 built using it, so we can link the builtins and emutls shared on all.
492 We have to work around that DYLD_XXXX are disabled in macOS 10.11+ which
493 means that any bootstrap trying to use a shared libgcc with a bumped SO-
494 name will fail. This means that we do not accept shared libgcc for these
495 versions.
497 For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and
498 we find the emutls impl from lemutls_w. In either case, the builtins etc.
499 are linked from -lgcc.
501 Otherwise, we just link the shared version of gcc_s.1.1 and pick up
502 exceptions:
503 * Prior to 10.3.9, then we have to link the static eh lib, since there
504 is no shared version on the system.
505 * from 10.3.9 to 10.5, from /usr/lib/libgcc_s.1.dylib
506 * from 10.6 onwards, from libSystem.dylib
508 In all cases, libgcc_s.1.1 will be installed with the compiler, or any app
509 built using it, so we can link the builtins and emutls shared on all.
511 #undef REAL_LIBGCC_SPEC
512 #define REAL_LIBGCC_SPEC \
513 "%{static-libgcc|static: \
514 %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \
515 %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w); \
516 shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
517 %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \
518 %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) \
519 %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \
520 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
521 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5); \
522 : -lemutls_w \
523 } -lgcc "
525 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
527 #undef STARTFILE_SPEC
528 #define STARTFILE_SPEC \
529 "%{dynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \
530 %{!dynamiclib:%{bundle:%(darwin_bundle1)} \
531 %{!bundle:%{pg:%{static:-lgcrt0.o} \
532 %{!static:%{object:-lgcrt0.o} \
533 %{!object:%{preload:-lgcrt0.o} \
534 %{!preload:-lgcrt1.o \
535 %:version-compare(>= 10.8 mmacosx-version-min= -no_new_main) \
536 %(darwin_crt2)}}}} \
537 %{!pg:%{static:-lcrt0.o} \
538 %{!static:%{object:-lcrt0.o} \
539 %{!object:%{preload:-lcrt0.o} \
540 %{!preload: %(darwin_crt1) \
541 %(darwin_crt2)}}}}}} \
542 %(darwin_crt3) %<dynamiclib "
544 /* We want a destructor last in the list. */
545 #define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
546 #define ENDFILE_SPEC TM_DESTRUCTOR
548 #define DARWIN_EXTRA_SPECS \
549 { "darwin_crt1", DARWIN_CRT1_SPEC }, \
550 { "darwin_crt2", DARWIN_CRT2_SPEC }, \
551 { "darwin_crt3", DARWIN_CRT3_SPEC }, \
552 { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \
553 { "darwin_bundle1", DARWIN_BUNDLE1_SPEC },
555 #define DARWIN_CRT1_SPEC \
556 "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \
557 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o) \
558 %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \
559 %{fgnu-tm: -lcrttms.o}"
561 #define DARWIN_CRT2_SPEC ""
563 /* crt3.o provides __cxa_atexit on systems that don't have it (and a fix
564 up for faulty versions on 10.4). Since it's only used with C++, which
565 requires passing -shared-libgcc, key off that to avoid unnecessarily
566 adding a destructor to every program built for 10.4 or earlier. */
568 #define DARWIN_CRT3_SPEC \
569 "%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
571 #define DARWIN_DYLIB1_SPEC \
572 "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \
573 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)"
575 #define DARWIN_BUNDLE1_SPEC \
576 "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \
577 %{fgnu-tm: -lcrttms.o}}"
579 #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
580 /* Emit macosx version (but only major). */
581 #define ASM_MMACOSX_VERSION_MIN_SPEC \
582 "%{asm_macosx_version_min=*: -mmacosx-version-min=%* } \
583 %<asm_macosx_version_min=* "
584 #else
585 #define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=* "
586 #endif
588 #if HAVE_GNU_AS
589 /* The options are added in gcc.cc for this case. */
590 #define ASM_OPTIONS ""
591 #else
592 /* When we detect that we're cctools or llvm as, we need to insert the right
593 additional options. Actually, currently these are the same as GAS. */
594 #define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
595 #endif
597 /* Default Darwin ASM_SPEC, very simple. */
598 #define ASM_SPEC \
599 "%{static} -arch %(darwin_arch) " \
600 ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC
602 #ifdef HAVE_AS_STABS_DIRECTIVE
603 /* We only pass a debug option to the assembler if that supports stabs, since
604 dwarf is not uniformly supported in the assemblers. */
605 #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}"
606 #else
607 #define ASM_DEBUG_SPEC ""
608 #endif
610 #undef ASM_DEBUG_OPTION_SPEC
611 #define ASM_DEBUG_OPTION_SPEC ""
613 #define ASM_FINAL_SPEC \
614 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
615 %<gsplit-dwarf"
617 /* We now require C++11 to bootstrap and newer tools than those based on
618 stabs, so require DWARF-2, even if stabs is supported by the assembler. */
620 #define DWARF2_DEBUGGING_INFO 1
621 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
623 #ifdef HAVE_AS_STABS_DIRECTIVE
624 #define DBX_DEBUGGING_INFO 1
625 #endif
627 #define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug"
628 #define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug"
629 #define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug"
630 #define DEBUG_ARANGES_SECTION "__DWARF,__debug_aranges,regular,debug"
631 #define DEBUG_MACINFO_SECTION "__DWARF,__debug_macinfo,regular,debug"
632 #define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug"
633 #define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug"
634 #define DEBUG_LOCLISTS_SECTION "__DWARF,__debug_loclists,regular,debug"
636 #define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug"
637 #define DEBUG_STR_OFFSETS_SECTION "__DWARF,__debug_str_offs,regular,debug"
638 #define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug"
639 #define DEBUG_RNGLISTS_SECTION "__DWARF,__debug_rnglists,regular,debug"
640 #define DEBUG_MACRO_SECTION "__DWARF,__debug_macro,regular,debug"
642 #define DEBUG_LTO_INFO_SECTION "__GNU_DWARF_LTO,__debug_info,regular,debug"
643 #define DEBUG_LTO_ABBREV_SECTION "__GNU_DWARF_LTO,__debug_abbrev,regular,debug"
644 #define DEBUG_LTO_MACINFO_SECTION "__GNU_DWARF_LTO,__debug_macinfo,regular,debug"
645 #define DEBUG_LTO_LINE_SECTION "__GNU_DWARF_LTO,__debug_line,regular,debug"
646 #define DEBUG_LTO_STR_SECTION "__GNU_DWARF_LTO,__debug_str,regular,debug"
647 #define DEBUG_LTO_MACRO_SECTION "__GNU_DWARF_LTO,__debug_macro,regular,debug"
649 #define TARGET_WANT_DEBUG_PUB_SECTIONS true
650 #define DEBUG_PUBNAMES_SECTION ((debug_generate_pub_sections == 2) \
651 ? "__DWARF,__debug_gnu_pubn,regular,debug" \
652 : "__DWARF,__debug_pubnames,regular,debug")
654 #define DEBUG_PUBTYPES_SECTION ((debug_generate_pub_sections == 2) \
655 ? "__DWARF,__debug_gnu_pubt,regular,debug" \
656 : "__DWARF,__debug_pubtypes,regular,debug")
658 /* When generating stabs debugging, use N_BINCL entries. */
660 #define DBX_USE_BINCL
662 /* There is no limit to the length of stabs strings. */
664 #define DBX_CONTIN_LENGTH 0
666 /* gdb needs a null N_SO at the end of each file for scattered loading. */
668 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
670 /* GCC's definition of 'one_only' is the same as its definition of 'weak'. */
671 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
673 /* Mach-O supports 'weak imports', and 'weak definitions' in coalesced
674 sections. machopic_select_section ensures that weak variables go in
675 coalesced sections. Weak aliases (or any other kind of aliases) are
676 not supported. Weak symbols that aren't visible outside the .s file
677 are not supported. */
678 #define ASM_WEAKEN_DECL(FILE, DECL, NAME, ALIAS) \
679 do { \
680 if (ALIAS) \
682 warning (0, "alias definitions not supported in Mach-O; ignored"); \
683 break; \
686 if (! DECL_EXTERNAL (DECL) && TREE_PUBLIC (DECL)) \
687 targetm.asm_out.globalize_label (FILE, NAME); \
688 if (DECL_EXTERNAL (DECL)) \
689 fputs ("\t.weak_reference ", FILE); \
690 else if (lookup_attribute ("weak_import", DECL_ATTRIBUTES (DECL))) \
691 break; \
692 else if (TREE_PUBLIC (DECL)) \
693 fputs ("\t.weak_definition ", FILE); \
694 else \
695 break; \
696 assemble_name (FILE, NAME); \
697 fputc ('\n', FILE); \
698 } while (0)
700 /* Darwin has the pthread routines in libSystem, which every program
701 links to, so there's no need for weak-ness for that. */
702 #define GTHREAD_USE_WEAK 0
704 /* On Darwin, we don't (at the time of writing) have linkonce sections
705 with names, so it's safe to make the class data not comdat. */
706 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false
708 /* For efficiency, on Darwin the RTTI information that is always
709 emitted in the standard C++ library should not be COMDAT. */
710 #define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false
712 /* We make exception information linkonce. */
713 #undef TARGET_USES_WEAK_UNWIND_INFO
714 #define TARGET_USES_WEAK_UNWIND_INFO 1
716 /* We need to use a nonlocal label for the start of an EH frame: the
717 Darwin linker requires that a coalesced section start with a label.
718 Unfortunately, it also requires that 'debug' sections don't contain
719 labels. */
720 #undef FRAME_BEGIN_LABEL
721 #define FRAME_BEGIN_LABEL (for_eh ? "EH_frame" : "Lframe")
723 /* Emit a label for the FDE corresponding to DECL. EMPTY means
724 emit a label for an empty FDE. */
725 #define TARGET_ASM_EMIT_UNWIND_LABEL darwin_emit_unwind_label
727 /* Emit a label to separate the exception table. */
728 #define TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL darwin_emit_except_table_label
730 /* Make an EH (personality or LDSA) symbol indirect as needed. */
731 #define TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT darwin_make_eh_symbol_indirect
733 /* Some of Darwin's unwinders need current frame address state to be reset
734 after a DW_CFA_restore_state recovers the register values. */
735 #undef TARGET_ASM_SHOULD_RESTORE_CFA_STATE
736 #define TARGET_ASM_SHOULD_RESTORE_CFA_STATE darwin_should_restore_cfa_state
738 /* Our profiling scheme doesn't LP labels and counter words. */
740 #define NO_PROFILE_COUNTERS 1
742 #undef INIT_SECTION_ASM_OP
743 #define INIT_SECTION_ASM_OP ""
745 #undef INVOKE__main
747 #define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor
748 #define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor
750 /* Always prefix with an underscore. */
752 #define USER_LABEL_PREFIX "_"
754 /* A dummy symbol that will be replaced with the function base name. */
755 #define MACHOPIC_FUNCTION_BASE_NAME "<pic base>"
757 /* Don't output a .file directive. That is only used by the assembler for
758 error reporting. */
759 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
760 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
762 #undef TARGET_ASM_FILE_END
763 #define TARGET_ASM_FILE_END darwin_file_end
765 /* Because Mach-O relocations have a counter from 1 to 255 for the
766 section number they apply to, it is necessary to output all
767 normal sections before the LTO sections, to make sure that the
768 sections that may have relocations always have a section number
769 smaller than 255. */
770 #undef TARGET_ASM_LTO_START
771 #define TARGET_ASM_LTO_START darwin_asm_lto_start
772 #undef TARGET_ASM_LTO_END
773 #define TARGET_ASM_LTO_END darwin_asm_lto_end
775 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
776 fprintf (FILE, "\t.space " HOST_WIDE_INT_PRINT_UNSIGNED"\n", SIZE)
778 /* Give ObjC methods pretty symbol names. */
780 #undef OBJC_GEN_METHOD_LABEL
781 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
782 do { if (CAT_NAME) \
783 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
784 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
785 else \
786 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
787 (CLASS_NAME), (SEL_NAME)); \
788 } while (0)
790 #undef ASM_DECLARE_OBJECT_NAME
791 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
792 darwin_asm_declare_object_name ((FILE), (NAME), (DECL))
794 /* The RTTI data (e.g., __ti4name) is common and public (and static),
795 but it does need to be referenced via indirect PIC data pointers.
796 The machopic_define_symbol calls are telling the machopic subsystem
797 that the name *is* defined in this module, so it doesn't need to
798 make them indirect. */
800 #undef ASM_DECLARE_FUNCTION_NAME
801 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
802 do { \
803 const char *xname = NAME; \
804 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
805 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
806 if (! DECL_WEAK (DECL) \
807 && ((TREE_STATIC (DECL) \
808 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
809 || DECL_INITIAL (DECL))) \
810 machopic_define_symbol (DECL_RTL (DECL)); \
811 if ((TREE_STATIC (DECL) \
812 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
813 || DECL_INITIAL (DECL)) \
814 (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
815 ASM_OUTPUT_FUNCTION_LABEL (FILE, xname, DECL); \
816 } while (0)
818 #undef TARGET_ASM_DECLARE_CONSTANT_NAME
819 #define TARGET_ASM_DECLARE_CONSTANT_NAME darwin_asm_declare_constant_name
821 /* Wrap new method names in quotes so the assembler doesn't gag.
822 Make Objective-C internal symbols local and in doing this, we need
823 to accommodate the name mangling done by c++ on file scope locals. */
825 int darwin_label_is_anonymous_local_objc_name (const char *name);
827 #undef ASM_OUTPUT_LABELREF
828 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
829 do { \
830 const char *xname = (NAME); \
831 if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME)) \
832 machopic_output_function_base_name(FILE); \
833 else if (xname[0] == '&' || xname[0] == '*') \
835 int len = strlen (xname); \
836 if (len > 6 && !strcmp ("$stub", xname + len - 5)) \
837 machopic_validate_stub_or_non_lazy_ptr (xname); \
838 else if (len > 7 && !strcmp ("$stub\"", xname + len - 6)) \
839 machopic_validate_stub_or_non_lazy_ptr (xname); \
840 else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \
841 machopic_validate_stub_or_non_lazy_ptr (xname); \
842 else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14)) \
843 machopic_validate_stub_or_non_lazy_ptr (xname); \
844 if (xname[1] != '"' && name_needs_quotes (&xname[1])) \
845 fprintf (FILE, "\"%s\"", &xname[1]); \
846 else \
847 fputs (&xname[1], FILE); \
849 else if (xname[0] == '+' || xname[0] == '-') \
850 fprintf (FILE, "\"%s\"", xname); \
851 else if (darwin_label_is_anonymous_local_objc_name (xname)) \
852 fprintf (FILE, "L%s", xname); \
853 else if (xname[0] != '"' && name_needs_quotes (xname)) \
854 asm_fprintf (FILE, "\"%U%s\"", xname); \
855 else \
856 asm_fprintf (FILE, "%U%s", xname); \
857 } while (0)
859 /* Output before executable code. */
860 #undef TEXT_SECTION_ASM_OP
861 #define TEXT_SECTION_ASM_OP "\t.text"
863 /* Output before writable data. */
865 #undef DATA_SECTION_ASM_OP
866 #define DATA_SECTION_ASM_OP "\t.data"
868 #undef ALIGN_ASM_OP
869 #define ALIGN_ASM_OP ".align"
871 #undef ASM_OUTPUT_ALIGN
872 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
873 if ((LOG) != 0) \
874 fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG))
876 /* The maximum alignment which the object file format can support in bits
877 which depends on the OS version and whether the object is a common
878 variable. */
880 #undef MAX_OFILE_ALIGNMENT
881 #define MAX_OFILE_ALIGNMENT ((1U << L2_MAX_OFILE_ALIGNMENT) * 8U)
883 /* These are the three variants that emit referenced blank space. */
884 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
885 darwin_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
887 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
888 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
889 darwin_asm_output_aligned_decl_local \
890 ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
892 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
893 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
894 darwin_asm_output_aligned_decl_common \
895 ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
897 /* The generic version, archs should over-ride where required. */
898 #define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer"
900 /* Declare the section variables. */
901 #ifndef USED_FOR_TARGET
902 enum darwin_section_enum {
903 #define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) NAME,
904 #include "darwin-sections.def"
905 #undef DEF_SECTION
906 NUM_DARWIN_SECTIONS
908 extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
909 #endif
911 #undef TARGET_ASM_SELECT_SECTION
912 #define TARGET_ASM_SELECT_SECTION machopic_select_section
914 #undef TARGET_ASM_FUNCTION_SECTION
915 #define TARGET_ASM_FUNCTION_SECTION darwin_function_section
917 #undef TARGET_ASM_SELECT_RTX_SECTION
918 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
919 #undef TARGET_ASM_UNIQUE_SECTION
920 #define TARGET_ASM_UNIQUE_SECTION darwin_unique_section
921 #undef TARGET_ASM_FUNCTION_RODATA_SECTION
922 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
924 #undef TARGET_ASM_TM_CLONE_TABLE_SECTION
925 #define TARGET_ASM_TM_CLONE_TABLE_SECTION darwin_tm_clone_table_section
927 #undef TARGET_ASM_RELOC_RW_MASK
928 #define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask
930 /* Globalizing directive for a label. */
931 #define GLOBAL_ASM_OP "\t.globl "
932 #define TARGET_ASM_GLOBALIZE_LABEL darwin_globalize_label
934 /* Emit an assembler directive to set visibility for a symbol. Used
935 to support visibility attribute and Darwin's private extern
936 feature. */
937 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
938 #define TARGET_ASM_ASSEMBLE_VISIBILITY darwin_assemble_visibility
940 /* Extra attributes for Darwin. */
941 #define SUBTARGET_ATTRIBUTE_TABLE \
942 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, \
943 affects_type_identity, handler, exclude } */ \
944 { "apple_kext_compatibility", 0, 0, false, true, false, false, \
945 darwin_handle_kext_attribute, NULL }, \
946 { "weak_import", 0, 0, true, false, false, false, \
947 darwin_handle_weak_import_attribute, NULL }
949 /* Make local constant labels linker-visible, so that if one follows a
950 weak_global constant, ld64 will be able to separate the atoms. */
951 #undef ASM_GENERATE_INTERNAL_LABEL
952 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
953 do { \
954 if (strcmp ("LC", PREFIX) == 0) \
955 sprintf (LABEL, "*%s%ld", "lC", (long)(NUM)); \
956 else if (strcmp ("Lubsan_data", PREFIX) == 0) \
957 sprintf (LABEL, "*%s%ld", "lubsan_data", (long)(NUM));\
958 else if (strcmp ("Lubsan_type", PREFIX) == 0) \
959 sprintf (LABEL, "*%s%ld", "lubsan_type", (long)(NUM));\
960 else if (strcmp ("LASAN", PREFIX) == 0) \
961 sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\
962 else if (strcmp ("LTRAMP", PREFIX) == 0) \
963 sprintf (LABEL, "*%s%ld", "lTRAMP", (long)(NUM));\
964 else \
965 sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \
966 } while (0)
968 #undef TARGET_ASM_MARK_DECL_PRESERVED
969 #define TARGET_ASM_MARK_DECL_PRESERVED darwin_mark_decl_preserved
971 /* Any port using this header needs to define the first available
972 subtarget symbol bit: SYMBOL_FLAG_SUBT_DEP. */
974 /* Is a variable. */
975 #define MACHO_SYMBOL_FLAG_VARIABLE (SYMBOL_FLAG_SUBT_DEP)
976 #define MACHO_SYMBOL_VARIABLE_P(RTX) \
977 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_VARIABLE) != 0)
979 /* Set on a symbol that must be indirected, even when there is a
980 definition in the TU. The ABI mandates that common symbols are so
981 indirected, as are weak. If 'fix-and-continue' is operational then
982 data symbols might also be. */
984 #define MACHO_SYMBOL_FLAG_MUST_INDIRECT ((SYMBOL_FLAG_SUBT_DEP) << 1)
985 #define MACHO_SYMBOL_MUST_INDIRECT_P(RTX) \
986 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_MUST_INDIRECT) != 0)
988 /* Set on a symbol with SYMBOL_FLAG_FUNCTION or MACHO_SYMBOL_FLAG_VARIABLE
989 to indicate that the function or variable is considered defined in this
990 translation unit. */
992 #define MACHO_SYMBOL_FLAG_DEFINED ((SYMBOL_FLAG_SUBT_DEP) << 2)
993 #define MACHO_SYMBOL_DEFINED_P(RTX) \
994 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0)
996 /* Set on a symbol that has specified non-default visibility. */
998 #define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3)
999 #define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \
1000 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0)
1002 /* Set on a symbol that should be made visible to the linker (overriding
1003 'L' symbol prefixes). */
1005 #define MACHO_SYMBOL_FLAG_LINKER_VIS ((SYMBOL_FLAG_SUBT_DEP) << 4)
1006 #define MACHO_SYMBOL_LINKER_VIS_P(RTX) \
1007 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_LINKER_VIS) != 0)
1009 /* Set on a symbol that is a pic stub or symbol indirection (i.e. the
1010 L_xxxxx${stub,non_lazy_ptr,lazy_ptr}. */
1012 #define MACHO_SYMBOL_FLAG_INDIRECTION ((SYMBOL_FLAG_SUBT_DEP) << 5)
1013 #define MACHO_SYMBOL_INDIRECTION_P(RTX) \
1014 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_INDIRECTION) != 0)
1016 /* Set on a symbol to indicate when fix-and-continue style code
1017 generation is being used and the symbol refers to a static symbol
1018 that should be rebound from new instances of a translation unit to
1019 the original instance of the data. */
1021 #define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 6)
1022 #define MACHO_SYMBOL_STATIC_P(RTX) \
1023 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_STATIC) != 0)
1025 /* Symbolic names for various things we might know about a symbol. */
1027 enum machopic_addr_class {
1028 MACHOPIC_UNDEFINED,
1029 MACHOPIC_DEFINED_DATA,
1030 MACHOPIC_UNDEFINED_DATA,
1031 MACHOPIC_DEFINED_FUNCTION,
1032 MACHOPIC_UNDEFINED_FUNCTION
1035 /* Macros defining the various PIC cases. */
1037 #undef MACHO_DYNAMIC_NO_PIC_P
1038 #define MACHO_DYNAMIC_NO_PIC_P (TARGET_MACHO_DYNAMIC_NO_PIC)
1039 #undef MACHOPIC_INDIRECT
1040 #define MACHOPIC_INDIRECT (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
1041 #define MACHOPIC_JUST_INDIRECT (MACHO_DYNAMIC_NO_PIC_P)
1042 #undef MACHOPIC_PURE
1043 #define MACHOPIC_PURE (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P)
1045 #undef TARGET_ENCODE_SECTION_INFO
1046 #define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info
1047 #undef TARGET_STRIP_NAME_ENCODING
1048 #define TARGET_STRIP_NAME_ENCODING default_strip_name_encoding
1050 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
1051 do { \
1052 const char *const stub_ = (STUB); \
1053 char *buffer_ = (BUF); \
1054 strcpy (buffer_, stub_); \
1055 if (stub_[0] == '"') \
1057 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
1059 else \
1061 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
1063 } while (0)
1065 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
1066 do { \
1067 const char *const symbol_ = (SYMBOL); \
1068 char *buffer_ = (BUF); \
1069 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
1071 sprintf (buffer_, "\"%s\"", symbol_); \
1073 else \
1075 strcpy (buffer_, symbol_); \
1077 } while (0)
1079 /* Given a symbol name string, create the lazy pointer version
1080 of the symbol name. */
1082 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
1083 do { \
1084 const char *symbol_ = (SYMBOL); \
1085 char *buffer_ = (BUF); \
1086 if (symbol_[0] == '"') \
1088 strcpy (buffer_, "\"L"); \
1089 strcpy (buffer_ + 2, symbol_ + 1); \
1090 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
1092 else if (name_needs_quotes (symbol_)) \
1094 strcpy (buffer_, "\"L"); \
1095 strcpy (buffer_ + 2, symbol_); \
1096 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
1098 else \
1100 strcpy (buffer_, "L"); \
1101 strcpy (buffer_ + 1, symbol_); \
1102 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
1104 } while (0)
1106 #define EH_FRAME_SECTION_NAME "__TEXT"
1107 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support"
1109 #undef ASM_PREFERRED_EH_DATA_FORMAT
1110 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
1111 (((CODE) == 2 && (GLOBAL) == 1) \
1112 ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \
1113 ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
1115 #define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2) \
1116 darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0)
1118 #define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE) \
1119 darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE)
1121 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) \
1122 if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) { \
1123 darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR); \
1124 goto DONE; \
1127 /* Experimentally, putting jump tables in text is faster on SPEC.
1128 Also this is needed for correctness for coalesced functions. */
1130 #ifndef JUMP_TABLES_IN_TEXT_SECTION
1131 #define JUMP_TABLES_IN_TEXT_SECTION 1
1132 #endif
1134 #define TARGET_TERMINATE_DW2_EH_FRAME_INFO false
1136 #define TARGET_ASM_INIT_SECTIONS darwin_init_sections
1137 #undef TARGET_ASM_NAMED_SECTION
1138 #define TARGET_ASM_NAMED_SECTION darwin_asm_named_section
1140 #define DARWIN_REGISTER_TARGET_PRAGMAS() \
1141 do { \
1142 if (!flag_preprocess_only) \
1143 cpp_register_pragma (parse_in, NULL, "mark", \
1144 darwin_pragma_ignore, false); \
1145 c_register_pragma (0, "options", darwin_pragma_options); \
1146 c_register_pragma (0, "segment", darwin_pragma_ignore); \
1147 c_register_pragma (0, "unused", darwin_pragma_unused); \
1148 c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \
1149 } while (0)
1151 #undef ASM_APP_ON
1152 #define ASM_APP_ON ""
1153 #undef ASM_APP_OFF
1154 #define ASM_APP_OFF ""
1156 void darwin_register_frameworks (const char *, const char *, int);
1157 void darwin_register_objc_includes (const char *, const char *, int);
1158 #define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes
1159 #define TARGET_EXTRA_INCLUDES darwin_register_frameworks
1161 void add_framework_path (char *);
1162 #define TARGET_OPTF add_framework_path
1164 #define TARGET_POSIX_IO
1166 #define WINT_TYPE "int"
1168 /* Every program on darwin links against libSystem which contains the pthread
1169 routines, so there's no need to explicitly call out when doing threaded
1170 work. */
1172 #undef GOMP_SELF_SPECS
1173 #define GOMP_SELF_SPECS ""
1174 #undef GTM_SELF_SPECS
1175 #define GTM_SELF_SPECS ""
1177 /* Darwin disables section anchors by default.
1178 They should be enabled per arch where support exists in that arch. */
1179 #define TARGET_ASM_OUTPUT_ANCHOR NULL
1180 #define DARWIN_SECTION_ANCHORS 0
1182 #define HAVE_ENABLE_EXECUTE_STACK
1184 /* For Apple KEXTs, we make the constructors return this to match gcc
1185 2.95. */
1186 #define TARGET_CXX_CDTOR_RETURNS_THIS (darwin_kextabi_p)
1187 #define TARGET_KEXTABI flag_apple_kext
1189 /* We have target-specific builtins. */
1190 #define SUBTARGET_FOLD_BUILTIN darwin_fold_builtin
1192 #define TARGET_N_FORMAT_TYPES 1
1193 #define TARGET_FORMAT_TYPES darwin_additional_format_types
1195 #ifndef USED_FOR_TARGET
1196 extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
1197 #define GCC_DRIVER_HOST_INITIALIZATION \
1198 darwin_driver_init (&decoded_options_count, &decoded_options)
1199 #endif
1201 /* The Apple assembler and linker do not support constructor priorities. */
1202 #undef SUPPORTS_INIT_PRIORITY
1203 #define SUPPORTS_INIT_PRIORITY 0
1205 #undef STACK_CHECK_STATIC_BUILTIN
1206 #define STACK_CHECK_STATIC_BUILTIN 1
1208 /* When building cross-compilers (and native crosses) we shall default to
1209 providing an osx-version-min of this unless overridden by the User.
1210 10.5 is the only version that fully supports all our archs so that's the
1211 fall-back default. */
1212 #ifndef DEF_MIN_OSX_VERSION
1213 #define DEF_MIN_OSX_VERSION "10.5"
1214 #endif
1216 /* Later versions of ld64 support coalescing weak code/data without requiring
1217 that they be placed in specially identified sections. This is the earliest
1218 _tested_ version known to support this so far. */
1219 #define MIN_LD64_NO_COAL_SECTS "236.3"
1221 /* From at least version 62.1, ld64 can build symbol indirection stubs as
1222 needed, and there is no need for the compiler to emit them. */
1223 #define MIN_LD64_OMIT_STUBS "62.1"
1225 /* Emit start labels for init and term sections from this version. */
1226 #define MIN_LD64_INIT_TERM_START_LABELS "136.0"
1228 /* If we have no definition for the linker version, pick the minimum version
1229 that will bootstrap the compiler. */
1230 #ifndef LD64_VERSION
1231 # ifndef DEF_LD64
1232 # define LD64_VERSION "85.2.1"
1233 # else
1234 # define LD64_VERSION DEF_LD64
1235 # endif
1236 #endif
1238 /* CTF and BTF support. */
1239 #undef CTF_INFO_SECTION_NAME
1240 #define CTF_INFO_SECTION_NAME "__CTF_BTF,__ctf,regular,debug"
1241 #undef BTF_INFO_SECTION_NAME
1242 #define BTF_INFO_SECTION_NAME "__CTF_BTF,__btf,regular,debug"
1244 #endif /* CONFIG_DARWIN_H */