Darwin: Amend REAL_LIBGCC_SPEC comment [NFC].
[official-gcc.git] / gcc / config / darwin.h
blobb73e12372d8021e62a92f3fa3fee938114a049f0
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}"
468 /* Note that by default, -lgcc_eh (which provides a statically-linked unwinder)
469 is not used. This is because, in general, we need to unwind through system
470 libraries that are linked with the shared unwinder in libunwind (or libgcc_s
471 for OSX 10.4/5 [darwin8/9]).
473 When -static-libgcc is forced: < 10.6, use the unwinder in libgcc_eh (and
474 find 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. The eh library is still available so that it could
479 be specified explicitly if there is some reason to do so.
481 When we have specified shared-libgcc or any case that might require
482 exceptions, we pull the libgcc content (including emulated tls) from
483 -lgcc_s.1.1 in GCC and the unwinder from /usr/lib/libgcc_s.1 for < 10.6 and
484 libSystem for >= 10.6 respectively.
485 Otherwise, we just link the emutls/builtins from convenience libs.
487 We have to work around that DYLD_XXXX are disabled in macOS 10.11+ which
488 means that any bootstrap trying to use a shared libgcc with a bumped SO-
489 name will fail. This means that we do not accept shared libgcc for these
490 versions (the primary reason for forcing a shared libgcc was that it
491 contained the unwinder on Darwin8 and 9).
493 When using the shared version of gcc_s.1.1 the unwinder is provided by:
494 * Prior to 10.3.9, then we have to link the static eh lib, since there
495 is no shared unwinder version on the system.
496 * from 10.3.9 to 10.5, from /usr/lib/libgcc_s.1.dylib
497 * from 10.6 onwards, from libSystem.dylib
499 #undef REAL_LIBGCC_SPEC
500 #define REAL_LIBGCC_SPEC \
501 "%{static-libgcc|static: \
502 %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \
503 %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w); \
504 shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
505 %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \
506 %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) \
507 %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \
508 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
509 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5); \
510 : -lemutls_w \
511 } -lgcc "
513 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
515 #undef STARTFILE_SPEC
516 #define STARTFILE_SPEC \
517 "%{dynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \
518 %{!dynamiclib:%{bundle:%(darwin_bundle1)} \
519 %{!bundle:%{pg:%{static:-lgcrt0.o} \
520 %{!static:%{object:-lgcrt0.o} \
521 %{!object:%{preload:-lgcrt0.o} \
522 %{!preload:-lgcrt1.o \
523 %:version-compare(>= 10.8 mmacosx-version-min= -no_new_main) \
524 %(darwin_crt2)}}}} \
525 %{!pg:%{static:-lcrt0.o} \
526 %{!static:%{object:-lcrt0.o} \
527 %{!object:%{preload:-lcrt0.o} \
528 %{!preload: %(darwin_crt1) \
529 %(darwin_crt2)}}}}}} \
530 %(darwin_crt3) %<dynamiclib "
532 /* We want a destructor last in the list. */
533 #define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
534 #define ENDFILE_SPEC TM_DESTRUCTOR
536 #define DARWIN_EXTRA_SPECS \
537 { "darwin_crt1", DARWIN_CRT1_SPEC }, \
538 { "darwin_crt2", DARWIN_CRT2_SPEC }, \
539 { "darwin_crt3", DARWIN_CRT3_SPEC }, \
540 { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \
541 { "darwin_bundle1", DARWIN_BUNDLE1_SPEC },
543 #define DARWIN_CRT1_SPEC \
544 "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \
545 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o) \
546 %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \
547 %{fgnu-tm: -lcrttms.o}"
549 #define DARWIN_CRT2_SPEC ""
551 /* crt3.o provides __cxa_atexit on systems that don't have it (and a fix
552 up for faulty versions on 10.4). Since it's only used with C++, which
553 requires passing -shared-libgcc, key off that to avoid unnecessarily
554 adding a destructor to every program built for 10.4 or earlier. */
556 #define DARWIN_CRT3_SPEC \
557 "%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
559 #define DARWIN_DYLIB1_SPEC \
560 "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \
561 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)"
563 #define DARWIN_BUNDLE1_SPEC \
564 "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \
565 %{fgnu-tm: -lcrttms.o}}"
567 #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
568 /* Emit macosx version (but only major). */
569 #define ASM_MMACOSX_VERSION_MIN_SPEC \
570 "%{asm_macosx_version_min=*: -mmacosx-version-min=%* } \
571 %<asm_macosx_version_min=* "
572 #else
573 #define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=* "
574 #endif
576 #if HAVE_GNU_AS
577 /* The options are added in gcc.cc for this case. */
578 #define ASM_OPTIONS ""
579 #else
580 /* When we detect that we're cctools or llvm as, we need to insert the right
581 additional options. Actually, currently these are the same as GAS. */
582 #define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
583 #endif
585 /* Default Darwin ASM_SPEC, very simple. */
586 #define ASM_SPEC \
587 "%{static} -arch %(darwin_arch) " \
588 ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC
590 #ifdef HAVE_AS_STABS_DIRECTIVE
591 /* We only pass a debug option to the assembler if that supports stabs, since
592 dwarf is not uniformly supported in the assemblers. */
593 #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}"
594 #else
595 #define ASM_DEBUG_SPEC ""
596 #endif
598 #undef ASM_DEBUG_OPTION_SPEC
599 #define ASM_DEBUG_OPTION_SPEC ""
601 #define ASM_FINAL_SPEC \
602 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
603 %<gsplit-dwarf"
605 /* We now require C++11 to bootstrap and newer tools than those based on
606 stabs, so require DWARF-2, even if stabs is supported by the assembler. */
608 #define DWARF2_DEBUGGING_INFO 1
609 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
611 #ifdef HAVE_AS_STABS_DIRECTIVE
612 #define DBX_DEBUGGING_INFO 1
613 #endif
615 #define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug"
616 #define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug"
617 #define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug"
618 #define DEBUG_ARANGES_SECTION "__DWARF,__debug_aranges,regular,debug"
619 #define DEBUG_MACINFO_SECTION "__DWARF,__debug_macinfo,regular,debug"
620 #define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug"
621 #define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug"
622 #define DEBUG_LOCLISTS_SECTION "__DWARF,__debug_loclists,regular,debug"
624 #define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug"
625 #define DEBUG_STR_OFFSETS_SECTION "__DWARF,__debug_str_offs,regular,debug"
626 #define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug"
627 #define DEBUG_RNGLISTS_SECTION "__DWARF,__debug_rnglists,regular,debug"
628 #define DEBUG_MACRO_SECTION "__DWARF,__debug_macro,regular,debug"
630 #define DEBUG_LTO_INFO_SECTION "__GNU_DWARF_LTO,__debug_info,regular,debug"
631 #define DEBUG_LTO_ABBREV_SECTION "__GNU_DWARF_LTO,__debug_abbrev,regular,debug"
632 #define DEBUG_LTO_MACINFO_SECTION "__GNU_DWARF_LTO,__debug_macinfo,regular,debug"
633 #define DEBUG_LTO_LINE_SECTION "__GNU_DWARF_LTO,__debug_line,regular,debug"
634 #define DEBUG_LTO_STR_SECTION "__GNU_DWARF_LTO,__debug_str,regular,debug"
635 #define DEBUG_LTO_MACRO_SECTION "__GNU_DWARF_LTO,__debug_macro,regular,debug"
637 #define TARGET_WANT_DEBUG_PUB_SECTIONS true
638 #define DEBUG_PUBNAMES_SECTION ((debug_generate_pub_sections == 2) \
639 ? "__DWARF,__debug_gnu_pubn,regular,debug" \
640 : "__DWARF,__debug_pubnames,regular,debug")
642 #define DEBUG_PUBTYPES_SECTION ((debug_generate_pub_sections == 2) \
643 ? "__DWARF,__debug_gnu_pubt,regular,debug" \
644 : "__DWARF,__debug_pubtypes,regular,debug")
646 /* When generating stabs debugging, use N_BINCL entries. */
648 #define DBX_USE_BINCL
650 /* There is no limit to the length of stabs strings. */
652 #define DBX_CONTIN_LENGTH 0
654 /* gdb needs a null N_SO at the end of each file for scattered loading. */
656 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
658 /* GCC's definition of 'one_only' is the same as its definition of 'weak'. */
659 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
661 /* Mach-O supports 'weak imports', and 'weak definitions' in coalesced
662 sections. machopic_select_section ensures that weak variables go in
663 coalesced sections. Weak aliases (or any other kind of aliases) are
664 not supported. Weak symbols that aren't visible outside the .s file
665 are not supported. */
666 #define ASM_WEAKEN_DECL(FILE, DECL, NAME, ALIAS) \
667 do { \
668 if (ALIAS) \
670 warning (0, "alias definitions not supported in Mach-O; ignored"); \
671 break; \
674 if (! DECL_EXTERNAL (DECL) && TREE_PUBLIC (DECL)) \
675 targetm.asm_out.globalize_label (FILE, NAME); \
676 if (DECL_EXTERNAL (DECL)) \
677 fputs ("\t.weak_reference ", FILE); \
678 else if (lookup_attribute ("weak_import", DECL_ATTRIBUTES (DECL))) \
679 break; \
680 else if (TREE_PUBLIC (DECL)) \
681 fputs ("\t.weak_definition ", FILE); \
682 else \
683 break; \
684 assemble_name (FILE, NAME); \
685 fputc ('\n', FILE); \
686 } while (0)
688 /* Darwin has the pthread routines in libSystem, which every program
689 links to, so there's no need for weak-ness for that. */
690 #define GTHREAD_USE_WEAK 0
692 /* On Darwin, we don't (at the time of writing) have linkonce sections
693 with names, so it's safe to make the class data not comdat. */
694 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false
696 /* For efficiency, on Darwin the RTTI information that is always
697 emitted in the standard C++ library should not be COMDAT. */
698 #define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false
700 /* We make exception information linkonce. */
701 #undef TARGET_USES_WEAK_UNWIND_INFO
702 #define TARGET_USES_WEAK_UNWIND_INFO 1
704 /* We need to use a nonlocal label for the start of an EH frame: the
705 Darwin linker requires that a coalesced section start with a label.
706 Unfortunately, it also requires that 'debug' sections don't contain
707 labels. */
708 #undef FRAME_BEGIN_LABEL
709 #define FRAME_BEGIN_LABEL (for_eh ? "EH_frame" : "Lframe")
711 /* Emit a label for the FDE corresponding to DECL. EMPTY means
712 emit a label for an empty FDE. */
713 #define TARGET_ASM_EMIT_UNWIND_LABEL darwin_emit_unwind_label
715 /* Emit a label to separate the exception table. */
716 #define TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL darwin_emit_except_table_label
718 /* Make an EH (personality or LDSA) symbol indirect as needed. */
719 #define TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT darwin_make_eh_symbol_indirect
721 /* Some of Darwin's unwinders need current frame address state to be reset
722 after a DW_CFA_restore_state recovers the register values. */
723 #undef TARGET_ASM_SHOULD_RESTORE_CFA_STATE
724 #define TARGET_ASM_SHOULD_RESTORE_CFA_STATE darwin_should_restore_cfa_state
726 /* Our profiling scheme doesn't LP labels and counter words. */
728 #define NO_PROFILE_COUNTERS 1
730 #undef INIT_SECTION_ASM_OP
731 #define INIT_SECTION_ASM_OP ""
733 #undef INVOKE__main
735 #define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor
736 #define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor
738 /* Always prefix with an underscore. */
740 #define USER_LABEL_PREFIX "_"
742 /* A dummy symbol that will be replaced with the function base name. */
743 #define MACHOPIC_FUNCTION_BASE_NAME "<pic base>"
745 /* Don't output a .file directive. That is only used by the assembler for
746 error reporting. */
747 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
748 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
750 #undef TARGET_ASM_FILE_END
751 #define TARGET_ASM_FILE_END darwin_file_end
753 /* Because Mach-O relocations have a counter from 1 to 255 for the
754 section number they apply to, it is necessary to output all
755 normal sections before the LTO sections, to make sure that the
756 sections that may have relocations always have a section number
757 smaller than 255. */
758 #undef TARGET_ASM_LTO_START
759 #define TARGET_ASM_LTO_START darwin_asm_lto_start
760 #undef TARGET_ASM_LTO_END
761 #define TARGET_ASM_LTO_END darwin_asm_lto_end
763 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
764 fprintf (FILE, "\t.space " HOST_WIDE_INT_PRINT_UNSIGNED"\n", SIZE)
766 /* Give ObjC methods pretty symbol names. */
768 #undef OBJC_GEN_METHOD_LABEL
769 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
770 do { if (CAT_NAME) \
771 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
772 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
773 else \
774 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
775 (CLASS_NAME), (SEL_NAME)); \
776 } while (0)
778 #undef ASM_DECLARE_OBJECT_NAME
779 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
780 darwin_asm_declare_object_name ((FILE), (NAME), (DECL))
782 /* The RTTI data (e.g., __ti4name) is common and public (and static),
783 but it does need to be referenced via indirect PIC data pointers.
784 The machopic_define_symbol calls are telling the machopic subsystem
785 that the name *is* defined in this module, so it doesn't need to
786 make them indirect. */
788 #undef ASM_DECLARE_FUNCTION_NAME
789 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
790 do { \
791 const char *xname = NAME; \
792 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
793 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
794 if (! DECL_WEAK (DECL) \
795 && ((TREE_STATIC (DECL) \
796 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
797 || DECL_INITIAL (DECL))) \
798 machopic_define_symbol (DECL_RTL (DECL)); \
799 if ((TREE_STATIC (DECL) \
800 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
801 || DECL_INITIAL (DECL)) \
802 (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
803 ASM_OUTPUT_FUNCTION_LABEL (FILE, xname, DECL); \
804 } while (0)
806 #undef TARGET_ASM_DECLARE_CONSTANT_NAME
807 #define TARGET_ASM_DECLARE_CONSTANT_NAME darwin_asm_declare_constant_name
809 /* Wrap new method names in quotes so the assembler doesn't gag.
810 Make Objective-C internal symbols local and in doing this, we need
811 to accommodate the name mangling done by c++ on file scope locals. */
813 int darwin_label_is_anonymous_local_objc_name (const char *name);
815 #undef ASM_OUTPUT_LABELREF
816 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
817 do { \
818 const char *xname = (NAME); \
819 if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME)) \
820 machopic_output_function_base_name(FILE); \
821 else if (xname[0] == '&' || xname[0] == '*') \
823 int len = strlen (xname); \
824 if (len > 6 && !strcmp ("$stub", xname + len - 5)) \
825 machopic_validate_stub_or_non_lazy_ptr (xname); \
826 else if (len > 7 && !strcmp ("$stub\"", xname + len - 6)) \
827 machopic_validate_stub_or_non_lazy_ptr (xname); \
828 else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \
829 machopic_validate_stub_or_non_lazy_ptr (xname); \
830 else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14)) \
831 machopic_validate_stub_or_non_lazy_ptr (xname); \
832 if (xname[1] != '"' && name_needs_quotes (&xname[1])) \
833 fprintf (FILE, "\"%s\"", &xname[1]); \
834 else \
835 fputs (&xname[1], FILE); \
837 else if (xname[0] == '+' || xname[0] == '-') \
838 fprintf (FILE, "\"%s\"", xname); \
839 else if (darwin_label_is_anonymous_local_objc_name (xname)) \
840 fprintf (FILE, "L%s", xname); \
841 else if (xname[0] != '"' && name_needs_quotes (xname)) \
842 asm_fprintf (FILE, "\"%U%s\"", xname); \
843 else \
844 asm_fprintf (FILE, "%U%s", xname); \
845 } while (0)
847 /* Output before executable code. */
848 #undef TEXT_SECTION_ASM_OP
849 #define TEXT_SECTION_ASM_OP "\t.text"
851 /* Output before writable data. */
853 #undef DATA_SECTION_ASM_OP
854 #define DATA_SECTION_ASM_OP "\t.data"
856 #undef ALIGN_ASM_OP
857 #define ALIGN_ASM_OP ".align"
859 #undef ASM_OUTPUT_ALIGN
860 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
861 if ((LOG) != 0) \
862 fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG))
864 /* The maximum alignment which the object file format can support in bits
865 which depends on the OS version and whether the object is a common
866 variable. */
868 #undef MAX_OFILE_ALIGNMENT
869 #define MAX_OFILE_ALIGNMENT ((1U << L2_MAX_OFILE_ALIGNMENT) * 8U)
871 /* These are the three variants that emit referenced blank space. */
872 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
873 darwin_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
875 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
876 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
877 darwin_asm_output_aligned_decl_local \
878 ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
880 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
881 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
882 darwin_asm_output_aligned_decl_common \
883 ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
885 /* The generic version, archs should over-ride where required. */
886 #define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer"
888 /* Declare the section variables. */
889 #ifndef USED_FOR_TARGET
890 enum darwin_section_enum {
891 #define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) NAME,
892 #include "darwin-sections.def"
893 #undef DEF_SECTION
894 NUM_DARWIN_SECTIONS
896 extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
897 #endif
899 #undef TARGET_ASM_SELECT_SECTION
900 #define TARGET_ASM_SELECT_SECTION machopic_select_section
902 #undef TARGET_ASM_FUNCTION_SECTION
903 #define TARGET_ASM_FUNCTION_SECTION darwin_function_section
905 #undef TARGET_ASM_SELECT_RTX_SECTION
906 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
907 #undef TARGET_ASM_UNIQUE_SECTION
908 #define TARGET_ASM_UNIQUE_SECTION darwin_unique_section
909 #undef TARGET_ASM_FUNCTION_RODATA_SECTION
910 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
912 #undef TARGET_ASM_TM_CLONE_TABLE_SECTION
913 #define TARGET_ASM_TM_CLONE_TABLE_SECTION darwin_tm_clone_table_section
915 #undef TARGET_ASM_RELOC_RW_MASK
916 #define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask
918 /* Globalizing directive for a label. */
919 #define GLOBAL_ASM_OP "\t.globl "
920 #define TARGET_ASM_GLOBALIZE_LABEL darwin_globalize_label
922 /* Emit an assembler directive to set visibility for a symbol. Used
923 to support visibility attribute and Darwin's private extern
924 feature. */
925 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
926 #define TARGET_ASM_ASSEMBLE_VISIBILITY darwin_assemble_visibility
928 /* Extra attributes for Darwin. */
929 #define SUBTARGET_ATTRIBUTE_TABLE \
930 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, \
931 affects_type_identity, handler, exclude } */ \
932 { "apple_kext_compatibility", 0, 0, false, true, false, false, \
933 darwin_handle_kext_attribute, NULL }, \
934 { "weak_import", 0, 0, true, false, false, false, \
935 darwin_handle_weak_import_attribute, NULL }
937 /* Make local constant labels linker-visible, so that if one follows a
938 weak_global constant, ld64 will be able to separate the atoms. */
939 #undef ASM_GENERATE_INTERNAL_LABEL
940 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
941 do { \
942 if (strcmp ("LC", PREFIX) == 0) \
943 sprintf (LABEL, "*%s%ld", "lC", (long)(NUM)); \
944 else if (strcmp ("Lubsan_data", PREFIX) == 0) \
945 sprintf (LABEL, "*%s%ld", "lubsan_data", (long)(NUM));\
946 else if (strcmp ("Lubsan_type", PREFIX) == 0) \
947 sprintf (LABEL, "*%s%ld", "lubsan_type", (long)(NUM));\
948 else if (strcmp ("LASAN", PREFIX) == 0) \
949 sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\
950 else if (strcmp ("LTRAMP", PREFIX) == 0) \
951 sprintf (LABEL, "*%s%ld", "lTRAMP", (long)(NUM));\
952 else \
953 sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \
954 } while (0)
956 #undef TARGET_ASM_MARK_DECL_PRESERVED
957 #define TARGET_ASM_MARK_DECL_PRESERVED darwin_mark_decl_preserved
959 /* Any port using this header needs to define the first available
960 subtarget symbol bit: SYMBOL_FLAG_SUBT_DEP. */
962 /* Is a variable. */
963 #define MACHO_SYMBOL_FLAG_VARIABLE (SYMBOL_FLAG_SUBT_DEP)
964 #define MACHO_SYMBOL_VARIABLE_P(RTX) \
965 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_VARIABLE) != 0)
967 /* Set on a symbol that must be indirected, even when there is a
968 definition in the TU. The ABI mandates that common symbols are so
969 indirected, as are weak. If 'fix-and-continue' is operational then
970 data symbols might also be. */
972 #define MACHO_SYMBOL_FLAG_MUST_INDIRECT ((SYMBOL_FLAG_SUBT_DEP) << 1)
973 #define MACHO_SYMBOL_MUST_INDIRECT_P(RTX) \
974 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_MUST_INDIRECT) != 0)
976 /* Set on a symbol with SYMBOL_FLAG_FUNCTION or MACHO_SYMBOL_FLAG_VARIABLE
977 to indicate that the function or variable is considered defined in this
978 translation unit. */
980 #define MACHO_SYMBOL_FLAG_DEFINED ((SYMBOL_FLAG_SUBT_DEP) << 2)
981 #define MACHO_SYMBOL_DEFINED_P(RTX) \
982 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0)
984 /* Set on a symbol that has specified non-default visibility. */
986 #define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3)
987 #define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \
988 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0)
990 /* Set on a symbol that should be made visible to the linker (overriding
991 'L' symbol prefixes). */
993 #define MACHO_SYMBOL_FLAG_LINKER_VIS ((SYMBOL_FLAG_SUBT_DEP) << 4)
994 #define MACHO_SYMBOL_LINKER_VIS_P(RTX) \
995 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_LINKER_VIS) != 0)
997 /* Set on a symbol that is a pic stub or symbol indirection (i.e. the
998 L_xxxxx${stub,non_lazy_ptr,lazy_ptr}. */
1000 #define MACHO_SYMBOL_FLAG_INDIRECTION ((SYMBOL_FLAG_SUBT_DEP) << 5)
1001 #define MACHO_SYMBOL_INDIRECTION_P(RTX) \
1002 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_INDIRECTION) != 0)
1004 /* Set on a symbol to indicate when fix-and-continue style code
1005 generation is being used and the symbol refers to a static symbol
1006 that should be rebound from new instances of a translation unit to
1007 the original instance of the data. */
1009 #define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 6)
1010 #define MACHO_SYMBOL_STATIC_P(RTX) \
1011 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_STATIC) != 0)
1013 /* Symbolic names for various things we might know about a symbol. */
1015 enum machopic_addr_class {
1016 MACHOPIC_UNDEFINED,
1017 MACHOPIC_DEFINED_DATA,
1018 MACHOPIC_UNDEFINED_DATA,
1019 MACHOPIC_DEFINED_FUNCTION,
1020 MACHOPIC_UNDEFINED_FUNCTION
1023 /* Macros defining the various PIC cases. */
1025 #undef MACHO_DYNAMIC_NO_PIC_P
1026 #define MACHO_DYNAMIC_NO_PIC_P (TARGET_MACHO_DYNAMIC_NO_PIC)
1027 #undef MACHOPIC_INDIRECT
1028 #define MACHOPIC_INDIRECT (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
1029 #define MACHOPIC_JUST_INDIRECT (MACHO_DYNAMIC_NO_PIC_P)
1030 #undef MACHOPIC_PURE
1031 #define MACHOPIC_PURE (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P)
1033 #undef TARGET_ENCODE_SECTION_INFO
1034 #define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info
1035 #undef TARGET_STRIP_NAME_ENCODING
1036 #define TARGET_STRIP_NAME_ENCODING default_strip_name_encoding
1038 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
1039 do { \
1040 const char *const stub_ = (STUB); \
1041 char *buffer_ = (BUF); \
1042 strcpy (buffer_, stub_); \
1043 if (stub_[0] == '"') \
1045 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
1047 else \
1049 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
1051 } while (0)
1053 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
1054 do { \
1055 const char *const symbol_ = (SYMBOL); \
1056 char *buffer_ = (BUF); \
1057 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
1059 sprintf (buffer_, "\"%s\"", symbol_); \
1061 else \
1063 strcpy (buffer_, symbol_); \
1065 } while (0)
1067 /* Given a symbol name string, create the lazy pointer version
1068 of the symbol name. */
1070 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
1071 do { \
1072 const char *symbol_ = (SYMBOL); \
1073 char *buffer_ = (BUF); \
1074 if (symbol_[0] == '"') \
1076 strcpy (buffer_, "\"L"); \
1077 strcpy (buffer_ + 2, symbol_ + 1); \
1078 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
1080 else if (name_needs_quotes (symbol_)) \
1082 strcpy (buffer_, "\"L"); \
1083 strcpy (buffer_ + 2, symbol_); \
1084 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
1086 else \
1088 strcpy (buffer_, "L"); \
1089 strcpy (buffer_ + 1, symbol_); \
1090 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
1092 } while (0)
1094 #define EH_FRAME_SECTION_NAME "__TEXT"
1095 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support"
1097 #undef ASM_PREFERRED_EH_DATA_FORMAT
1098 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
1099 (((CODE) == 2 && (GLOBAL) == 1) \
1100 ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \
1101 ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
1103 #define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2) \
1104 darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0)
1106 #define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE) \
1107 darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE)
1109 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) \
1110 if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) { \
1111 darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR); \
1112 goto DONE; \
1115 /* Experimentally, putting jump tables in text is faster on SPEC.
1116 Also this is needed for correctness for coalesced functions. */
1118 #ifndef JUMP_TABLES_IN_TEXT_SECTION
1119 #define JUMP_TABLES_IN_TEXT_SECTION 1
1120 #endif
1122 #define TARGET_TERMINATE_DW2_EH_FRAME_INFO false
1124 #define TARGET_ASM_INIT_SECTIONS darwin_init_sections
1125 #undef TARGET_ASM_NAMED_SECTION
1126 #define TARGET_ASM_NAMED_SECTION darwin_asm_named_section
1128 #define DARWIN_REGISTER_TARGET_PRAGMAS() \
1129 do { \
1130 if (!flag_preprocess_only) \
1131 cpp_register_pragma (parse_in, NULL, "mark", \
1132 darwin_pragma_ignore, false); \
1133 c_register_pragma (0, "options", darwin_pragma_options); \
1134 c_register_pragma (0, "segment", darwin_pragma_ignore); \
1135 c_register_pragma (0, "unused", darwin_pragma_unused); \
1136 c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \
1137 } while (0)
1139 #undef ASM_APP_ON
1140 #define ASM_APP_ON ""
1141 #undef ASM_APP_OFF
1142 #define ASM_APP_OFF ""
1144 void darwin_register_frameworks (const char *, const char *, int);
1145 void darwin_register_objc_includes (const char *, const char *, int);
1146 #define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes
1147 #define TARGET_EXTRA_INCLUDES darwin_register_frameworks
1149 void add_framework_path (char *);
1150 #define TARGET_OPTF add_framework_path
1152 #define TARGET_POSIX_IO
1154 #define WINT_TYPE "int"
1156 /* Every program on darwin links against libSystem which contains the pthread
1157 routines, so there's no need to explicitly call out when doing threaded
1158 work. */
1160 #undef GOMP_SELF_SPECS
1161 #define GOMP_SELF_SPECS ""
1162 #undef GTM_SELF_SPECS
1163 #define GTM_SELF_SPECS ""
1165 /* Darwin disables section anchors by default.
1166 They should be enabled per arch where support exists in that arch. */
1167 #define TARGET_ASM_OUTPUT_ANCHOR NULL
1168 #define DARWIN_SECTION_ANCHORS 0
1170 #define HAVE_ENABLE_EXECUTE_STACK
1172 /* For Apple KEXTs, we make the constructors return this to match gcc
1173 2.95. */
1174 #define TARGET_CXX_CDTOR_RETURNS_THIS (darwin_kextabi_p)
1175 #define TARGET_KEXTABI flag_apple_kext
1177 /* We have target-specific builtins. */
1178 #define SUBTARGET_FOLD_BUILTIN darwin_fold_builtin
1180 #define TARGET_N_FORMAT_TYPES 1
1181 #define TARGET_FORMAT_TYPES darwin_additional_format_types
1183 #ifndef USED_FOR_TARGET
1184 extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
1185 #define GCC_DRIVER_HOST_INITIALIZATION \
1186 darwin_driver_init (&decoded_options_count, &decoded_options)
1187 #endif
1189 /* The Apple assembler and linker do not support constructor priorities. */
1190 #undef SUPPORTS_INIT_PRIORITY
1191 #define SUPPORTS_INIT_PRIORITY 0
1193 #undef STACK_CHECK_STATIC_BUILTIN
1194 #define STACK_CHECK_STATIC_BUILTIN 1
1196 /* When building cross-compilers (and native crosses) we shall default to
1197 providing an osx-version-min of this unless overridden by the User.
1198 10.5 is the only version that fully supports all our archs so that's the
1199 fall-back default. */
1200 #ifndef DEF_MIN_OSX_VERSION
1201 #define DEF_MIN_OSX_VERSION "10.5"
1202 #endif
1204 /* Later versions of ld64 support coalescing weak code/data without requiring
1205 that they be placed in specially identified sections. This is the earliest
1206 _tested_ version known to support this so far. */
1207 #define MIN_LD64_NO_COAL_SECTS "236.3"
1209 /* From at least version 62.1, ld64 can build symbol indirection stubs as
1210 needed, and there is no need for the compiler to emit them. */
1211 #define MIN_LD64_OMIT_STUBS "62.1"
1213 /* Emit start labels for init and term sections from this version. */
1214 #define MIN_LD64_INIT_TERM_START_LABELS "136.0"
1216 /* If we have no definition for the linker version, pick the minimum version
1217 that will bootstrap the compiler. */
1218 #ifndef LD64_VERSION
1219 # ifndef DEF_LD64
1220 # define LD64_VERSION "85.2.1"
1221 # else
1222 # define LD64_VERSION DEF_LD64
1223 # endif
1224 #endif
1226 /* CTF and BTF support. */
1227 #undef CTF_INFO_SECTION_NAME
1228 #define CTF_INFO_SECTION_NAME "__CTF_BTF,__ctf,regular,debug"
1229 #undef BTF_INFO_SECTION_NAME
1230 #define BTF_INFO_SECTION_NAME "__CTF_BTF,__btf,regular,debug"
1232 #endif /* CONFIG_DARWIN_H */