PR96463: Optimise svld1rq from vectors for little endian AArch64 targets.
[official-gcc.git] / gcc / config / darwin.h
blobf82ec62cf2092ec99a0d8c68ba18374ca5160b86
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. */
148 #undef SUBTARGET_DRIVER_SELF_SPECS
149 #define SUBTARGET_DRIVER_SELF_SPECS \
150 "%{shared:%{!dynamiclib:-dynamiclib}} %<shared", \
151 "%{static:%{dynamic|dynamiclib:%econflicting code generation switches}}",\
152 "%{dynamiclib:-Xlinker -dylib \
153 %{allowable_client*:-Xlinker -allowable_client -Xlinker %*} \
154 %<allowable_client* \
155 %{bundle_loader*: %<bundle_loader* \
156 %e-bundle_loader not allowed with -dynamiclib} \
157 %{client_name*: %<client_name* \
158 %e-client_name not allowed with -dynamiclib} \
159 %{compatibility_version*:\
160 -Xlinker -dylib_compatibility_version -Xlinker %*} \
161 %<compatibility_version* \
162 %{current_version*:-Xlinker -dylib_current_version -Xlinker %*} \
163 %<current_version* \
164 %{install_name*:-Xlinker -dylib_install_name -Xlinker %* } \
165 %<install_name* \
166 %{keep_private_externs: %<keep_private_externs \
167 %e-keep_private_externs not allowed with -dynamiclib} \
168 %{private_bundle: %<private_bundle \
169 %e-private_bundle not allowed with -dynamiclib} \
170 }", \
171 "%{!dynamiclib: \
172 %{bundle_loader*:-Xlinker -bundle_loader -Xlinker %*} \
173 %<bundle_loader* \
174 %{client_name*:-Xlinker -client_name -Xlinker %*} \
175 %<client_name* \
176 %{compatibility_version*: %<compatibility_version* \
177 %e-compatibility_version only allowed with -dynamiclib} \
178 %{current_version*: %<current_version* \
179 %e-current_version only allowed with -dynamiclib} \
180 %{install_name*: %<install_name* \
181 %e-install_name only allowed with -dynamiclib} \
182 %{keep_private_externs:-Xlinker -keep_private_externs} \
183 %<keep_private_externs \
184 %{private_bundle:-Xlinker -private_bundle} \
185 %<private_bundle \
186 }", \
187 "%{all_load:-Xlinker -all_load} %<all_load", \
188 "%{arch_errors_fatal:-Xlinker -arch_errors_fatal} \
189 %<arch_errors_fatal", \
190 "%{bind_at_load:-Xlinker -bind_at_load} %<bind_at_load", \
191 "%{bundle:%{!dynamiclib:-Xlinker -bundle; \
192 :%e-bundle not allowed with -dynamiclib}}", \
193 "%{dead_strip:-Xlinker -dead_strip} %<dead_strip", \
194 "%{dylib_file*:-Xlinker -dylib_file -Xlinker %*} %<dylib_file*", \
195 "%{dylinker:-Xlinker -dylinker} %<dylinker", \
196 "%{dylinker_install_name*:-Xlinker -dylinker_install_name -Xlinker %*}\
197 %<dylinker_install_name*", \
198 "%{exported_symbols_list*:-Xlinker -exported_symbols_list -Xlinker %*}\
199 %<exported_symbols_list", \
200 "%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls", \
201 "%{fterminated-vtables: -fapple-kext} %<fterminated-vtables", \
202 "%{fapple-kext|mkernel:-static}", \
203 "%{filelist*:-Xlinker -filelist -Xlinker %*} %<filelist*", \
204 "%{flat_namespace:-Xlinker -flat_namespace} %<flat_namespace", \
205 "%{force_cpusubtype_ALL:-Xassembler -force_cpusubtype_ALL} ", \
206 "%{force_flat_namespace: \
207 %{!dynamiclib:-Xlinker -force_flat_namespace; \
208 :%e-force_flat_namespace not allowed with -dynamiclib}} \
209 %<force_flat_namespace", \
210 "%{framework*:-Xlinker -framework -Xlinker %*} %<framework*", \
211 "%{gfull:-g -fno-eliminate-unused-debug-symbols} %<gfull", \
212 "%{gused:-g -feliminate-unused-debug-symbols} %<gused", \
213 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
214 %<gsplit-dwarf", \
215 "%{headerpad_max_install_names:-Xlinker -headerpad_max_install_names}\
216 %<headerpad_max_install_names", \
217 "%{image_base*:-Xlinker -image_base -Xlinker %*} %<image_base*", \
218 "%{init*:-Xlinker -init -Xlinker %*} %<init*", \
219 "%{multi_module:-Xlinker -multi_module} %<multi_module", \
220 "%{multiply_defined*:-Xlinker -multiply_defined -Xlinker %*} \
221 %<multiply_defined* ", \
222 "%{multiplydefinedunused*:\
223 -Xlinker -multiply_defined_unused -Xlinker %*} \
224 %<multiplydefinedunused* ", \
225 "%{no_dead_strip_inits_and_terms:\
226 -Xlinker -no_dead_strip_inits_and_terms} \
227 %<no_dead_strip_inits_and_terms", \
228 "%{nofixprebinding:-Xlinker -nofixprebinding} %<nofixprebinding", \
229 "%{nomultidefs:-Xlinker -nomultidefs} %<nomultidefs", \
230 "%{pagezero_size*:-Xlinker -pagezero_size -Xlinker %*} \
231 %<pagezero_size", \
232 "%{prebind:-Xlinker -prebind} %<prebind", \
233 "%{noprebind:-Xlinker -noprebind} %<noprebind", \
234 "%{prebind_all_twolevel_modules:\
235 -Xlinker -prebind_all_twolevel_modules} \
236 %<prebind_all_twolevel_modules", \
237 "%{preload:-Xlinker -preload} %<preload", \
238 "%{read_only_relocs*:-Xlinker -read_only_relocs -Xlinker %*} \
239 %<read_only_relocs*", \
240 "%{rpath*: -Xlinker -rpath -Xlinker %*}", \
241 "%{seg_addr_table_filename*: \
242 -Xlinker -seg_addr_table_filename -Xlinker %*} \
243 %<seg_addr_table_filename*", \
244 "%{seg_addr_table*:-Xlinker -seg_addr_table -Xlinker %*} \
245 %<seg_addr_table*", \
246 "%{seg1addr*:-Xlinker -image_base -Xlinker %*} %<seg1addr*", \
247 "%{seglinkedit:-Xlinker -seglinkedit} %<seglinkedit", \
248 "%{noseglinkedit:-Xlinker -noseglinkedit} %<noseglinkedit", \
249 "%{segs_read_only_addr*:-Xlinker -segs_read_only_addr -Xlinker %*} \
250 %<segs_read_only_addr*", \
251 "%{segs_read_write_addr*:-Xlinker -segs_read_write_addr -Xlinker %*} \
252 %<segs_read_write_addr*", \
253 "%{single_module:-Xlinker -single_module} %<single_module", \
254 "%{sub_library*:-Xlinker -sub_library -Xlinker %*} %<sub_library*", \
255 "%{sub_umbrella*:-Xlinker -sub_umbrella -Xlinker %*} %<sub_umbrella*",\
256 "%{twolevel_namespace:-Xlinker -twolevel_namespace} \
257 %<twolevel_namespace", \
258 "%{twolevel_namespace_hints:-Xlinker -twolevel_namespace_hints} \
259 %<twolevel_namespace_hints", \
260 "%{umbrella*:-Xlinker -umbrella -Xlinker %*} %<umbrella*", \
261 "%{undefined*:-Xlinker -undefined -Xlinker %*} %<undefined*", \
262 "%{unexported_symbols_list*:\
263 -Xlinker -unexported_symbols_list -Xlinker %*} \
264 %<unexported_symbols_list*", \
265 "%{weak_reference_mismatches*:\
266 -Xlinker -weak_reference_mismatches -Xlinker %*} \
267 %<weak_reference_mismatches*", \
268 "%{whyload:-Xlinker -whyload} %<whyload", \
269 "%{whatsloaded:-Xlinker -whatsloaded} %<whatsloaded", \
270 "%{w:-Xlinker -w}", \
271 "%<y*", \
272 "%<Mach "
274 #if LD64_HAS_EXPORT_DYNAMIC
275 #define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}"
276 #else
277 #define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
278 #endif
280 /* Code built with mdynamic-no-pic does not support PIE/PIC, so we disallow
281 these combinations; we also ensure that the no_pie option is passed to
282 ld64 on system versions that default to PIE when mdynamic-no-pic is given.
283 FIXME: we should check that the linker supports the -pie and -no_pie.
284 options. */
285 #define DARWIN_PIE_SPEC \
286 "%{pie|fpie|fPIE:\
287 %{mdynamic-no-pic: \
288 %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
289 :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }; \
290 mdynamic-no-pic:%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } "
292 #define DARWIN_NOPIE_SPEC \
293 "%{no-pie|fno-pie|fno-PIE: \
294 %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }"
296 #define DARWIN_CC1_SPEC \
297 "%<dynamic %<dynamiclib %<force_cpusubtype_ALL "
299 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
300 do { \
301 darwin_override_options (); \
302 } while (0)
304 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do { \
305 if (flag_mkernel || flag_apple_kext) \
307 if (flag_use_cxa_atexit == 2) \
308 flag_use_cxa_atexit = 0; \
309 /* kexts should always be built without the coalesced sections \
310 because the kernel loader doesn't grok such sections. */ \
311 flag_weak = 0; \
312 /* No RTTI in kexts. */ \
313 flag_rtti = 0; \
315 } while (0)
317 /* Machine dependent cpp options. Don't add more options here, add
318 them to darwin_cpp_builtins in darwin-c.cc. */
320 #undef CPP_SPEC
321 #define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \
322 " %{pthread:-D_REENTRANT} "
324 /* This is a fix for PR41260 by passing -no_compact_unwind on darwin10 and
325 later until the assembler, linker and libunwind are able to deal with the
326 output from GCC.
328 FIXME: we should check that the linker supports the option.
331 #define DARWIN_NOCOMPACT_UNWIND \
332 " %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) "
334 /* In Darwin linker specs we can put -lcrt0.o and ld will search the library
335 path for crt0.o or -lcrtx.a and it will search for libcrtx.a. As for
336 other ports, we can also put xxx.{o,a}%s and get the appropriate complete
337 startfile absolute directory. This latter point is important when we want
338 to override ld's rule of .dylib being found ahead of .a and the user wants
339 the convenience library to be linked. */
341 /* The LINK_COMMAND spec is mostly a clone of the standard LINK_COMMAND_SPEC,
342 plus precomp, libtool, and fat build additions.
344 In general, random Darwin linker flags should go into LINK_SPEC
345 instead of LINK_COMMAND_SPEC. The command spec is better for
346 specifying the handling of options understood by generic Unix
347 linkers, and for positional arguments like libraries. */
349 #define LINK_COMMAND_SPEC_A \
350 "%{!c:%{!E:%{!S:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*: \
351 %(linker)" \
352 LINK_PLUGIN_SPEC \
353 "%{flto*:%<fcompare-debug*} \
354 %{flto} %{fno-lto} %{flto=*} \
355 %l " LINK_COMPRESS_DEBUG_SPEC \
356 "%X %{s} %{t} %{Z} %{u*} \
357 %{e*} %{r} \
358 %{o*}%{!o:-o a.out} \
359 %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \
360 %{L*} %(link_libgcc) %o \
361 %{!r:%{!nostdlib:%{!nodefaultlibs:\
362 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
363 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \
364 %{static|static-libgcc|static-libstdc++|static-libgfortran: \
365 libgomp.a%s; : -lgomp }} \
366 %{fgnu-tm: \
367 %{static|static-libgcc|static-libstdc++|static-libgfortran: \
368 libitm.a%s; : -litm }} \
369 %{%:sanitize(address): -lasan } \
370 %{%:sanitize(undefined): -lubsan } \
371 %(link_ssp) \
372 %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \
373 %(link_gcc_c_sequence) \
374 %{!nodefaultexport:%{dylib|dynamiclib|bundle: \
375 %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
376 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
377 %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
378 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
379 %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
380 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
381 %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
382 %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
383 }} \
384 }}}\
385 %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
386 DARWIN_PIE_SPEC \
387 DARWIN_NOPIE_SPEC \
388 DARWIN_RDYNAMIC \
389 DARWIN_NOCOMPACT_UNWIND \
390 "}}}}}}} %<pie %<no-pie %<rdynamic %<X %<rpath "
392 /* Spec that controls whether the debug linker is run automatically for
393 a link step. This needs to be done if there is a source file on the
394 command line which will result in a temporary object (and debug is
395 enabled). */
397 #define DSYMUTIL_SPEC \
398 "%{!c:%{!E:%{!S:%{!r:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*:\
399 %{g*:%{!gctf:%{!gbtf:%{!gstabs*:%{%:debug-level-gt(0): -idsym \
400 %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\
401 .f95|.f03|.f77|.for|.F|.F90|.F95|.F03|.d: -dsym }\
402 }}}}}\
403 }}}}}}}}"
405 #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC
407 /* Tell collect2 to run dsymutil for us as necessary. */
408 #define COLLECT_RUN_DSYMUTIL 1
410 /* We only want one instance of %G, since libSystem (Darwin's -lc) does not
411 depend on libgcc. */
412 #undef LINK_GCC_C_SEQUENCE_SPEC
413 #define LINK_GCC_C_SEQUENCE_SPEC \
414 "%G %{!nolibc:%L} "
416 /* ld64 supports a sysroot, it just has a different name and there's no easy
417 way to check for it at config time. */
418 #undef HAVE_LD_SYSROOT
419 #define HAVE_LD_SYSROOT 1
420 /* It seems the only (working) way to get a space after %R is to append a
421 dangling '/'. */
422 #define SYSROOT_SPEC "%{!isysroot*:-syslibroot %R/ } "
424 /* Do the same as clang, for now, and insert the sysroot for ld when an
425 isysroot is specified. */
426 #define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*} "
428 /* Suppress the addition of extra prefix paths when a sysroot is in use. */
429 #define STANDARD_STARTFILE_PREFIX_1 ""
430 #define STANDARD_STARTFILE_PREFIX_2 ""
433 /* Please keep the random linker options in alphabetical order.
434 Note that options taking arguments may appear multiple times on a command
435 line with different arguments each time, so put a * after their names so
436 all of them get passed. */
437 #define LINK_SPEC \
438 "%{static}%{!static:%{!dynamic:-dynamic}} \
439 %:remove-outfile(-ldl) \
440 %:remove-outfile(-lm) \
441 %:remove-outfile(-lpthread) \
442 %{fgnu-runtime: %{static|static-libgcc: \
443 %:replace-outfile(-lobjc libobjc-gnu.a%s); \
444 :%:replace-outfile(-lobjc -lobjc-gnu )}}\
445 %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\
446 %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos libgphobos.a%s)}\
447 %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\
448 %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\
449 %{force_cpusubtype_ALL:-arch %(darwin_arch)} \
450 %{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\
451 LINK_SYSROOT_SPEC \
452 "%{mmacosx-version-min=*:-macosx_version_min %*} \
453 %{!multiply_defined*:%{shared-libgcc: \
454 %:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \
455 %:version-compare(< 10.5 mmacosx-version-min= suppress) }} \
456 %{sectalign*} %{sectcreate*} %{sectobjectsymbols*} %{sectorder*} \
457 %{segaddr*} %{segcreate*} %{segprot*} "
459 /* Machine dependent libraries. */
461 #define LIB_SPEC "%{!static:-lSystem}"
463 /* Note that by default, -lgcc_eh (which provides a statically-linked unwinder)
464 is not used. This is because, in general, we need to unwind through system
465 libraries that are linked with the shared unwinder in libunwind (or libgcc_s
466 for OSX 10.4/5 [darwin8/9]).
468 When -static-libgcc is forced: < 10.6, use the unwinder in libgcc_eh (and
469 find the emultls impl. there too).
471 For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and
472 we find the emutls impl from lemutls_w. In either case, the builtins etc.
473 are linked from -lgcc. The eh library is still available so that it could
474 be specified explicitly if there is some reason to do so.
476 When we have specified shared-libgcc or any case that might require
477 exceptions, we pull the libgcc content (including emulated tls) from
478 -lgcc_s.1.1 in GCC and the unwinder from /usr/lib/libgcc_s.1 for < 10.6 and
479 libSystem for >= 10.6 respectively.
480 Otherwise, we just link the emutls/builtins from convenience libs.
482 We have to work around that DYLD_XXXX are disabled in macOS 10.11+ which
483 means that any bootstrap trying to use a shared libgcc with a bumped SO-
484 name will fail. This means that we do not accept shared libgcc for these
485 versions (the primary reason for forcing a shared libgcc was that it
486 contained the unwinder on Darwin8 and 9).
488 When using the shared version of gcc_s.1.1 the unwinder is provided by:
489 * Prior to 10.3.9, then we have to link the static eh lib, since there
490 is no shared unwinder version on the system.
491 * from 10.3.9 to 10.5, from /usr/lib/libgcc_s.1.dylib
492 * from 10.6 onwards, from libSystem.dylib
494 #undef REAL_LIBGCC_SPEC
495 #define REAL_LIBGCC_SPEC \
496 "%{static-libgcc|static: \
497 %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \
498 %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w); \
499 shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
500 %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \
501 %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) \
502 %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \
503 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
504 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5); \
505 : -lemutls_w \
506 } -lgcc "
508 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
510 #undef STARTFILE_SPEC
511 #define STARTFILE_SPEC \
512 "%{dynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \
513 %{!dynamiclib:%{bundle:%(darwin_bundle1)} \
514 %{!bundle:%{pg:%{static:-lgcrt0.o} \
515 %{!static:%{object:-lgcrt0.o} \
516 %{!object:%{preload:-lgcrt0.o} \
517 %{!preload:-lgcrt1.o \
518 %:version-compare(>= 10.8 mmacosx-version-min= -no_new_main) \
519 %(darwin_crt2)}}}} \
520 %{!pg:%{static:-lcrt0.o} \
521 %{!static:%{object:-lcrt0.o} \
522 %{!object:%{preload:-lcrt0.o} \
523 %{!preload: %(darwin_crt1) \
524 %(darwin_crt2)}}}}}} \
525 %(darwin_crt3) %<dynamiclib "
527 /* We want a destructor last in the list. */
528 #define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
529 #define ENDFILE_SPEC TM_DESTRUCTOR
531 #define DARWIN_EXTRA_SPECS \
532 { "darwin_crt1", DARWIN_CRT1_SPEC }, \
533 { "darwin_crt2", DARWIN_CRT2_SPEC }, \
534 { "darwin_crt3", DARWIN_CRT3_SPEC }, \
535 { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \
536 { "darwin_bundle1", DARWIN_BUNDLE1_SPEC },
538 #define DARWIN_CRT1_SPEC \
539 "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \
540 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o) \
541 %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \
542 %{fgnu-tm: -lcrttms.o}"
544 #define DARWIN_CRT2_SPEC ""
546 /* crt3.o provides __cxa_atexit on systems that don't have it (and a fix
547 up for faulty versions on 10.4). Since it's only used with C++, which
548 requires passing -shared-libgcc, key off that to avoid unnecessarily
549 adding a destructor to every program built for 10.4 or earlier. */
551 #define DARWIN_CRT3_SPEC \
552 "%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
554 #define DARWIN_DYLIB1_SPEC \
555 "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \
556 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)"
558 #define DARWIN_BUNDLE1_SPEC \
559 "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \
560 %{fgnu-tm: -lcrttms.o}}"
562 #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
563 /* Emit macosx version (but only major). */
564 #define ASM_MMACOSX_VERSION_MIN_SPEC \
565 "%{asm_macosx_version_min=*: -mmacosx-version-min=%* } \
566 %<asm_macosx_version_min=* "
567 #else
568 #define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=* "
569 #endif
571 #if HAVE_GNU_AS
572 /* The options are added in gcc.cc for this case. */
573 #define ASM_OPTIONS ""
574 #else
575 /* When we detect that we're cctools or llvm as, we need to insert the right
576 additional options. Actually, currently these are the same as GAS. */
577 #define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
578 #endif
580 /* Default Darwin ASM_SPEC, very simple. */
581 #define ASM_SPEC \
582 "%{static} -arch %(darwin_arch) " \
583 ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC
585 #ifdef HAVE_AS_STABS_DIRECTIVE
586 /* We only pass a debug option to the assembler if that supports stabs, since
587 dwarf is not uniformly supported in the assemblers. */
588 #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}"
589 #else
590 #define ASM_DEBUG_SPEC ""
591 #endif
593 #undef ASM_DEBUG_OPTION_SPEC
594 #define ASM_DEBUG_OPTION_SPEC ""
596 #define ASM_FINAL_SPEC \
597 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
598 %<gsplit-dwarf"
600 /* We now require C++11 to bootstrap and newer tools than those based on
601 stabs, so require DWARF-2, even if stabs is supported by the assembler. */
603 #define DWARF2_DEBUGGING_INFO 1
604 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
606 #ifdef HAVE_AS_STABS_DIRECTIVE
607 #define DBX_DEBUGGING_INFO 1
608 #endif
610 #define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug"
611 #define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug"
612 #define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug"
613 #define DEBUG_ARANGES_SECTION "__DWARF,__debug_aranges,regular,debug"
614 #define DEBUG_MACINFO_SECTION "__DWARF,__debug_macinfo,regular,debug"
615 #define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug"
616 #define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug"
617 #define DEBUG_LOCLISTS_SECTION "__DWARF,__debug_loclists,regular,debug"
619 #define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug"
620 #define DEBUG_STR_OFFSETS_SECTION "__DWARF,__debug_str_offs,regular,debug"
621 #define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug"
622 #define DEBUG_RNGLISTS_SECTION "__DWARF,__debug_rnglists,regular,debug"
623 #define DEBUG_MACRO_SECTION "__DWARF,__debug_macro,regular,debug"
625 #define DEBUG_LTO_INFO_SECTION "__GNU_DWARF_LTO,__debug_info,regular,debug"
626 #define DEBUG_LTO_ABBREV_SECTION "__GNU_DWARF_LTO,__debug_abbrev,regular,debug"
627 #define DEBUG_LTO_MACINFO_SECTION "__GNU_DWARF_LTO,__debug_macinfo,regular,debug"
628 #define DEBUG_LTO_LINE_SECTION "__GNU_DWARF_LTO,__debug_line,regular,debug"
629 #define DEBUG_LTO_STR_SECTION "__GNU_DWARF_LTO,__debug_str,regular,debug"
630 #define DEBUG_LTO_MACRO_SECTION "__GNU_DWARF_LTO,__debug_macro,regular,debug"
632 #define TARGET_WANT_DEBUG_PUB_SECTIONS true
633 #define DEBUG_PUBNAMES_SECTION ((debug_generate_pub_sections == 2) \
634 ? "__DWARF,__debug_gnu_pubn,regular,debug" \
635 : "__DWARF,__debug_pubnames,regular,debug")
637 #define DEBUG_PUBTYPES_SECTION ((debug_generate_pub_sections == 2) \
638 ? "__DWARF,__debug_gnu_pubt,regular,debug" \
639 : "__DWARF,__debug_pubtypes,regular,debug")
641 /* When generating stabs debugging, use N_BINCL entries. */
643 #define DBX_USE_BINCL
645 /* There is no limit to the length of stabs strings. */
647 #define DBX_CONTIN_LENGTH 0
649 /* gdb needs a null N_SO at the end of each file for scattered loading. */
651 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
653 /* GCC's definition of 'one_only' is the same as its definition of 'weak'. */
654 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
656 /* Mach-O supports 'weak imports', and 'weak definitions' in coalesced
657 sections. machopic_select_section ensures that weak variables go in
658 coalesced sections. Weak aliases (or any other kind of aliases) are
659 not supported. Weak symbols that aren't visible outside the .s file
660 are not supported. */
661 #define ASM_WEAKEN_DECL(FILE, DECL, NAME, ALIAS) \
662 do { \
663 if (ALIAS) \
665 warning (0, "alias definitions not supported in Mach-O; ignored"); \
666 break; \
669 if (! DECL_EXTERNAL (DECL) && TREE_PUBLIC (DECL)) \
670 targetm.asm_out.globalize_label (FILE, NAME); \
671 if (DECL_EXTERNAL (DECL)) \
672 fputs ("\t.weak_reference ", FILE); \
673 else if (lookup_attribute ("weak_import", DECL_ATTRIBUTES (DECL))) \
674 break; \
675 else if (TREE_PUBLIC (DECL)) \
676 fputs ("\t.weak_definition ", FILE); \
677 else \
678 break; \
679 assemble_name (FILE, NAME); \
680 fputc ('\n', FILE); \
681 } while (0)
683 /* Darwin has the pthread routines in libSystem, which every program
684 links to, so there's no need for weak-ness for that. */
685 #define GTHREAD_USE_WEAK 0
687 /* On Darwin, we don't (at the time of writing) have linkonce sections
688 with names, so it's safe to make the class data not comdat. */
689 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false
691 /* For efficiency, on Darwin the RTTI information that is always
692 emitted in the standard C++ library should not be COMDAT. */
693 #define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false
695 /* We make exception information linkonce. */
696 #undef TARGET_USES_WEAK_UNWIND_INFO
697 #define TARGET_USES_WEAK_UNWIND_INFO 1
699 /* We need to use a nonlocal label for the start of an EH frame: the
700 Darwin linker requires that a coalesced section start with a label.
701 Unfortunately, it also requires that 'debug' sections don't contain
702 labels. */
703 #undef FRAME_BEGIN_LABEL
704 #define FRAME_BEGIN_LABEL (for_eh ? "EH_frame" : "Lframe")
706 /* Emit a label for the FDE corresponding to DECL. EMPTY means
707 emit a label for an empty FDE. */
708 #define TARGET_ASM_EMIT_UNWIND_LABEL darwin_emit_unwind_label
710 /* Emit a label to separate the exception table. */
711 #define TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL darwin_emit_except_table_label
713 /* Make an EH (personality or LDSA) symbol indirect as needed. */
714 #define TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT darwin_make_eh_symbol_indirect
716 /* Some of Darwin's unwinders need current frame address state to be reset
717 after a DW_CFA_restore_state recovers the register values. */
718 #undef TARGET_ASM_SHOULD_RESTORE_CFA_STATE
719 #define TARGET_ASM_SHOULD_RESTORE_CFA_STATE darwin_should_restore_cfa_state
721 /* Our profiling scheme doesn't LP labels and counter words. */
723 #define NO_PROFILE_COUNTERS 1
725 #undef INIT_SECTION_ASM_OP
726 #define INIT_SECTION_ASM_OP ""
728 #undef INVOKE__main
730 #define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor
731 #define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor
733 /* Always prefix with an underscore. */
735 #define USER_LABEL_PREFIX "_"
737 /* A dummy symbol that will be replaced with the function base name. */
738 #define MACHOPIC_FUNCTION_BASE_NAME "<pic base>"
740 /* Don't output a .file directive. That is only used by the assembler for
741 error reporting. */
742 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
743 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
745 #undef TARGET_ASM_FILE_END
746 #define TARGET_ASM_FILE_END darwin_file_end
748 /* Because Mach-O relocations have a counter from 1 to 255 for the
749 section number they apply to, it is necessary to output all
750 normal sections before the LTO sections, to make sure that the
751 sections that may have relocations always have a section number
752 smaller than 255. */
753 #undef TARGET_ASM_LTO_START
754 #define TARGET_ASM_LTO_START darwin_asm_lto_start
755 #undef TARGET_ASM_LTO_END
756 #define TARGET_ASM_LTO_END darwin_asm_lto_end
758 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
759 fprintf (FILE, "\t.space " HOST_WIDE_INT_PRINT_UNSIGNED"\n", SIZE)
761 /* Give ObjC methods pretty symbol names. */
763 #undef OBJC_GEN_METHOD_LABEL
764 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
765 do { if (CAT_NAME) \
766 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
767 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
768 else \
769 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
770 (CLASS_NAME), (SEL_NAME)); \
771 } while (0)
773 #undef ASM_DECLARE_OBJECT_NAME
774 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
775 darwin_asm_declare_object_name ((FILE), (NAME), (DECL))
777 /* The RTTI data (e.g., __ti4name) is common and public (and static),
778 but it does need to be referenced via indirect PIC data pointers.
779 The machopic_define_symbol calls are telling the machopic subsystem
780 that the name *is* defined in this module, so it doesn't need to
781 make them indirect. */
783 #undef ASM_DECLARE_FUNCTION_NAME
784 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
785 do { \
786 const char *xname = NAME; \
787 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
788 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
789 if (! DECL_WEAK (DECL) \
790 && ((TREE_STATIC (DECL) \
791 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
792 || DECL_INITIAL (DECL))) \
793 machopic_define_symbol (DECL_RTL (DECL)); \
794 if ((TREE_STATIC (DECL) \
795 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
796 || DECL_INITIAL (DECL)) \
797 (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
798 ASM_OUTPUT_FUNCTION_LABEL (FILE, xname, DECL); \
799 } while (0)
801 #undef TARGET_ASM_DECLARE_CONSTANT_NAME
802 #define TARGET_ASM_DECLARE_CONSTANT_NAME darwin_asm_declare_constant_name
804 /* Wrap new method names in quotes so the assembler doesn't gag.
805 Make Objective-C internal symbols local and in doing this, we need
806 to accommodate the name mangling done by c++ on file scope locals. */
808 int darwin_label_is_anonymous_local_objc_name (const char *name);
810 #undef ASM_OUTPUT_LABELREF
811 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
812 do { \
813 const char *xname = (NAME); \
814 if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME)) \
815 machopic_output_function_base_name(FILE); \
816 else if (xname[0] == '&' || xname[0] == '*') \
818 int len = strlen (xname); \
819 if (len > 6 && !strcmp ("$stub", xname + len - 5)) \
820 machopic_validate_stub_or_non_lazy_ptr (xname); \
821 else if (len > 7 && !strcmp ("$stub\"", xname + len - 6)) \
822 machopic_validate_stub_or_non_lazy_ptr (xname); \
823 else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \
824 machopic_validate_stub_or_non_lazy_ptr (xname); \
825 else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14)) \
826 machopic_validate_stub_or_non_lazy_ptr (xname); \
827 if (xname[1] != '"' && name_needs_quotes (&xname[1])) \
828 fprintf (FILE, "\"%s\"", &xname[1]); \
829 else \
830 fputs (&xname[1], FILE); \
832 else if (xname[0] == '+' || xname[0] == '-') \
833 fprintf (FILE, "\"%s\"", xname); \
834 else if (darwin_label_is_anonymous_local_objc_name (xname)) \
835 fprintf (FILE, "L%s", xname); \
836 else if (xname[0] != '"' && name_needs_quotes (xname)) \
837 asm_fprintf (FILE, "\"%U%s\"", xname); \
838 else \
839 asm_fprintf (FILE, "%U%s", xname); \
840 } while (0)
842 /* Output before executable code. */
843 #undef TEXT_SECTION_ASM_OP
844 #define TEXT_SECTION_ASM_OP "\t.text"
846 /* Output before writable data. */
848 #undef DATA_SECTION_ASM_OP
849 #define DATA_SECTION_ASM_OP "\t.data"
851 #undef ALIGN_ASM_OP
852 #define ALIGN_ASM_OP ".align"
854 #undef ASM_OUTPUT_ALIGN
855 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
856 if ((LOG) != 0) \
857 fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG))
859 /* The maximum alignment which the object file format can support in bits
860 which depends on the OS version and whether the object is a common
861 variable. */
863 #undef MAX_OFILE_ALIGNMENT
864 #define MAX_OFILE_ALIGNMENT ((1U << L2_MAX_OFILE_ALIGNMENT) * 8U)
866 /* These are the three variants that emit referenced blank space. */
867 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
868 darwin_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
870 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
871 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
872 darwin_asm_output_aligned_decl_local \
873 ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
875 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
876 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
877 darwin_asm_output_aligned_decl_common \
878 ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
880 /* The generic version, archs should over-ride where required. */
881 #define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer"
883 /* Declare the section variables. */
884 #ifndef USED_FOR_TARGET
885 enum darwin_section_enum {
886 #define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) NAME,
887 #include "darwin-sections.def"
888 #undef DEF_SECTION
889 NUM_DARWIN_SECTIONS
891 extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
892 #endif
894 #undef TARGET_ASM_SELECT_SECTION
895 #define TARGET_ASM_SELECT_SECTION machopic_select_section
897 #undef TARGET_ASM_FUNCTION_SECTION
898 #define TARGET_ASM_FUNCTION_SECTION darwin_function_section
900 #undef TARGET_ASM_SELECT_RTX_SECTION
901 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
902 #undef TARGET_ASM_UNIQUE_SECTION
903 #define TARGET_ASM_UNIQUE_SECTION darwin_unique_section
904 #undef TARGET_ASM_FUNCTION_RODATA_SECTION
905 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
907 #undef TARGET_ASM_TM_CLONE_TABLE_SECTION
908 #define TARGET_ASM_TM_CLONE_TABLE_SECTION darwin_tm_clone_table_section
910 #undef TARGET_ASM_RELOC_RW_MASK
911 #define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask
913 /* Globalizing directive for a label. */
914 #define GLOBAL_ASM_OP "\t.globl "
915 #define TARGET_ASM_GLOBALIZE_LABEL darwin_globalize_label
917 /* Emit an assembler directive to set visibility for a symbol. Used
918 to support visibility attribute and Darwin's private extern
919 feature. */
920 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
921 #define TARGET_ASM_ASSEMBLE_VISIBILITY darwin_assemble_visibility
923 /* Extra attributes for Darwin. */
924 #define SUBTARGET_ATTRIBUTE_TABLE \
925 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, \
926 affects_type_identity, handler, exclude } */ \
927 { "apple_kext_compatibility", 0, 0, false, true, false, false, \
928 darwin_handle_kext_attribute, NULL }, \
929 { "weak_import", 0, 0, true, false, false, false, \
930 darwin_handle_weak_import_attribute, NULL }
932 /* Make local constant labels linker-visible, so that if one follows a
933 weak_global constant, ld64 will be able to separate the atoms. */
934 #undef ASM_GENERATE_INTERNAL_LABEL
935 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
936 do { \
937 if (strcmp ("LC", PREFIX) == 0) \
938 sprintf (LABEL, "*%s%ld", "lC", (long)(NUM)); \
939 else if (strcmp ("Lubsan_data", PREFIX) == 0) \
940 sprintf (LABEL, "*%s%ld", "lubsan_data", (long)(NUM));\
941 else if (strcmp ("Lubsan_type", PREFIX) == 0) \
942 sprintf (LABEL, "*%s%ld", "lubsan_type", (long)(NUM));\
943 else if (strcmp ("LASAN", PREFIX) == 0) \
944 sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\
945 else if (strcmp ("LTRAMP", PREFIX) == 0) \
946 sprintf (LABEL, "*%s%ld", "lTRAMP", (long)(NUM));\
947 else \
948 sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \
949 } while (0)
951 #undef TARGET_ASM_MARK_DECL_PRESERVED
952 #define TARGET_ASM_MARK_DECL_PRESERVED darwin_mark_decl_preserved
954 /* Any port using this header needs to define the first available
955 subtarget symbol bit: SYMBOL_FLAG_SUBT_DEP. */
957 /* Is a variable. */
958 #define MACHO_SYMBOL_FLAG_VARIABLE (SYMBOL_FLAG_SUBT_DEP)
959 #define MACHO_SYMBOL_VARIABLE_P(RTX) \
960 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_VARIABLE) != 0)
962 /* Set on a symbol that must be indirected, even when there is a
963 definition in the TU. The ABI mandates that common symbols are so
964 indirected, as are weak. If 'fix-and-continue' is operational then
965 data symbols might also be. */
967 #define MACHO_SYMBOL_FLAG_MUST_INDIRECT ((SYMBOL_FLAG_SUBT_DEP) << 1)
968 #define MACHO_SYMBOL_MUST_INDIRECT_P(RTX) \
969 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_MUST_INDIRECT) != 0)
971 /* Set on a symbol with SYMBOL_FLAG_FUNCTION or MACHO_SYMBOL_FLAG_VARIABLE
972 to indicate that the function or variable is considered defined in this
973 translation unit. */
975 #define MACHO_SYMBOL_FLAG_DEFINED ((SYMBOL_FLAG_SUBT_DEP) << 2)
976 #define MACHO_SYMBOL_DEFINED_P(RTX) \
977 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0)
979 /* Set on a symbol that has specified non-default visibility. */
981 #define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3)
982 #define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \
983 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0)
985 /* Set on a symbol that should be made visible to the linker (overriding
986 'L' symbol prefixes). */
988 #define MACHO_SYMBOL_FLAG_LINKER_VIS ((SYMBOL_FLAG_SUBT_DEP) << 4)
989 #define MACHO_SYMBOL_LINKER_VIS_P(RTX) \
990 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_LINKER_VIS) != 0)
992 /* Set on a symbol that is a pic stub or symbol indirection (i.e. the
993 L_xxxxx${stub,non_lazy_ptr,lazy_ptr}. */
995 #define MACHO_SYMBOL_FLAG_INDIRECTION ((SYMBOL_FLAG_SUBT_DEP) << 5)
996 #define MACHO_SYMBOL_INDIRECTION_P(RTX) \
997 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_INDIRECTION) != 0)
999 /* Set on a symbol to indicate when fix-and-continue style code
1000 generation is being used and the symbol refers to a static symbol
1001 that should be rebound from new instances of a translation unit to
1002 the original instance of the data. */
1004 #define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 6)
1005 #define MACHO_SYMBOL_STATIC_P(RTX) \
1006 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_STATIC) != 0)
1008 /* Symbolic names for various things we might know about a symbol. */
1010 enum machopic_addr_class {
1011 MACHOPIC_UNDEFINED,
1012 MACHOPIC_DEFINED_DATA,
1013 MACHOPIC_UNDEFINED_DATA,
1014 MACHOPIC_DEFINED_FUNCTION,
1015 MACHOPIC_UNDEFINED_FUNCTION
1018 /* Macros defining the various PIC cases. */
1020 #undef MACHO_DYNAMIC_NO_PIC_P
1021 #define MACHO_DYNAMIC_NO_PIC_P (TARGET_MACHO_DYNAMIC_NO_PIC)
1022 #undef MACHOPIC_INDIRECT
1023 #define MACHOPIC_INDIRECT (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
1024 #define MACHOPIC_JUST_INDIRECT (MACHO_DYNAMIC_NO_PIC_P)
1025 #undef MACHOPIC_PURE
1026 #define MACHOPIC_PURE (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P)
1028 #undef TARGET_ENCODE_SECTION_INFO
1029 #define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info
1030 #undef TARGET_STRIP_NAME_ENCODING
1031 #define TARGET_STRIP_NAME_ENCODING default_strip_name_encoding
1033 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
1034 do { \
1035 const char *const stub_ = (STUB); \
1036 char *buffer_ = (BUF); \
1037 strcpy (buffer_, stub_); \
1038 if (stub_[0] == '"') \
1040 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
1042 else \
1044 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
1046 } while (0)
1048 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
1049 do { \
1050 const char *const symbol_ = (SYMBOL); \
1051 char *buffer_ = (BUF); \
1052 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
1054 sprintf (buffer_, "\"%s\"", symbol_); \
1056 else \
1058 strcpy (buffer_, symbol_); \
1060 } while (0)
1062 /* Given a symbol name string, create the lazy pointer version
1063 of the symbol name. */
1065 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
1066 do { \
1067 const char *symbol_ = (SYMBOL); \
1068 char *buffer_ = (BUF); \
1069 if (symbol_[0] == '"') \
1071 strcpy (buffer_, "\"L"); \
1072 strcpy (buffer_ + 2, symbol_ + 1); \
1073 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
1075 else if (name_needs_quotes (symbol_)) \
1077 strcpy (buffer_, "\"L"); \
1078 strcpy (buffer_ + 2, symbol_); \
1079 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
1081 else \
1083 strcpy (buffer_, "L"); \
1084 strcpy (buffer_ + 1, symbol_); \
1085 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
1087 } while (0)
1089 #define EH_FRAME_SECTION_NAME "__TEXT"
1090 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support"
1092 #undef ASM_PREFERRED_EH_DATA_FORMAT
1093 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
1094 (((CODE) == 2 && (GLOBAL) == 1) \
1095 ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \
1096 ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
1098 #define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2) \
1099 darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0)
1101 #define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE) \
1102 darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE)
1104 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) \
1105 if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) { \
1106 darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR); \
1107 goto DONE; \
1110 /* Experimentally, putting jump tables in text is faster on SPEC.
1111 Also this is needed for correctness for coalesced functions. */
1113 #ifndef JUMP_TABLES_IN_TEXT_SECTION
1114 #define JUMP_TABLES_IN_TEXT_SECTION 1
1115 #endif
1117 #define TARGET_TERMINATE_DW2_EH_FRAME_INFO false
1119 #define TARGET_ASM_INIT_SECTIONS darwin_init_sections
1120 #undef TARGET_ASM_NAMED_SECTION
1121 #define TARGET_ASM_NAMED_SECTION darwin_asm_named_section
1123 #define DARWIN_REGISTER_TARGET_PRAGMAS() \
1124 do { \
1125 if (!flag_preprocess_only) \
1126 cpp_register_pragma (parse_in, NULL, "mark", \
1127 darwin_pragma_ignore, false); \
1128 c_register_pragma (0, "options", darwin_pragma_options); \
1129 c_register_pragma (0, "segment", darwin_pragma_ignore); \
1130 c_register_pragma (0, "unused", darwin_pragma_unused); \
1131 c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \
1132 } while (0)
1134 #undef ASM_APP_ON
1135 #define ASM_APP_ON ""
1136 #undef ASM_APP_OFF
1137 #define ASM_APP_OFF ""
1139 void darwin_register_frameworks (const char *, const char *, int);
1140 void darwin_register_objc_includes (const char *, const char *, int);
1141 #define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes
1142 #define TARGET_EXTRA_INCLUDES darwin_register_frameworks
1144 void add_framework_path (char *);
1145 #define TARGET_OPTF add_framework_path
1147 #define TARGET_POSIX_IO
1149 #define WINT_TYPE "int"
1151 /* Every program on darwin links against libSystem which contains the pthread
1152 routines, so there's no need to explicitly call out when doing threaded
1153 work. */
1155 #undef GOMP_SELF_SPECS
1156 #define GOMP_SELF_SPECS ""
1157 #undef GTM_SELF_SPECS
1158 #define GTM_SELF_SPECS ""
1160 /* Darwin disables section anchors by default.
1161 They should be enabled per arch where support exists in that arch. */
1162 #define TARGET_ASM_OUTPUT_ANCHOR NULL
1163 #define DARWIN_SECTION_ANCHORS 0
1165 #define HAVE_ENABLE_EXECUTE_STACK
1167 /* For Apple KEXTs, we make the constructors return this to match gcc
1168 2.95. */
1169 #define TARGET_CXX_CDTOR_RETURNS_THIS (darwin_kextabi_p)
1170 #define TARGET_KEXTABI flag_apple_kext
1172 /* We have target-specific builtins. */
1173 #define SUBTARGET_FOLD_BUILTIN darwin_fold_builtin
1175 #define TARGET_N_FORMAT_TYPES 1
1176 #define TARGET_FORMAT_TYPES darwin_additional_format_types
1178 #ifndef USED_FOR_TARGET
1179 extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
1180 #define GCC_DRIVER_HOST_INITIALIZATION \
1181 darwin_driver_init (&decoded_options_count, &decoded_options)
1182 #endif
1184 /* The Apple assembler and linker do not support constructor priorities. */
1185 #undef SUPPORTS_INIT_PRIORITY
1186 #define SUPPORTS_INIT_PRIORITY 0
1188 #undef STACK_CHECK_STATIC_BUILTIN
1189 #define STACK_CHECK_STATIC_BUILTIN 1
1191 /* When building cross-compilers (and native crosses) we shall default to
1192 providing an osx-version-min of this unless overridden by the User.
1193 10.5 is the only version that fully supports all our archs so that's the
1194 fall-back default. */
1195 #ifndef DEF_MIN_OSX_VERSION
1196 #define DEF_MIN_OSX_VERSION "10.5"
1197 #endif
1199 /* Later versions of ld64 support coalescing weak code/data without requiring
1200 that they be placed in specially identified sections. This is the earliest
1201 _tested_ version known to support this so far. */
1202 #define MIN_LD64_NO_COAL_SECTS "236.3"
1204 /* From at least version 62.1, ld64 can build symbol indirection stubs as
1205 needed, and there is no need for the compiler to emit them. */
1206 #define MIN_LD64_OMIT_STUBS "62.1"
1208 /* Emit start labels for init and term sections from this version. */
1209 #define MIN_LD64_INIT_TERM_START_LABELS "136.0"
1211 /* If we have no definition for the linker version, pick the minimum version
1212 that will bootstrap the compiler. */
1213 #ifndef LD64_VERSION
1214 # ifndef DEF_LD64
1215 # define LD64_VERSION "85.2.1"
1216 # else
1217 # define LD64_VERSION DEF_LD64
1218 # endif
1219 #endif
1221 /* CTF and BTF support. */
1222 #undef CTF_INFO_SECTION_NAME
1223 #define CTF_INFO_SECTION_NAME "__CTF_BTF,__ctf,regular,debug"
1224 #undef BTF_INFO_SECTION_NAME
1225 #define BTF_INFO_SECTION_NAME "__CTF_BTF,__btf,regular,debug"
1227 #endif /* CONFIG_DARWIN_H */