Darwin: Revise handling of some driver opts.

Darwin has a user convenience feature where some linker options are exposed
at the driver level (so one can type '-all_load' instead of '-Wl,-all_load'
or '-Xlinker -all_load').  We retain this feature, but now these options are
all marked as 'Driver' and we process them as early as possible so that they
get allocated to the right toolchain command.  There are a couple of special
cases where these driver opts are used multiple times, or to control
operations on more than one command (e.g. dynamiclib).  These are handled
specially and we then add %<xxxx specs for the commands that _do not_ need
them.  NOTE: the ordering of 'shared' and 'dynamiclib' is significant, hence
they are placed out of alphabetical order at the start.  Likewise, we keep
a couple of cases where a negative option originally appeared after the
positive alternate, potentially overriding it.

When we report an error with %e, it seems necessary to strip the option
before doing so, otherwise it survives to the cc1 command line (%e does not
appear to abort the program before this).

Right now there is no mechanism to split up the 'variable portion' (%*) of
the matched spec string, so where we have some driver specs that take 2 or
3 arguments, these cannot be processed here, but are deferred until the
LINK_SPEC, where they are copied verbatim.

We have a 'safe' version of the macOS version string, that has been sanity-
checked and truncated to minor version.  If the 'tiny' (3rd) portion of the
value is not significant, it is better to use the safe one in version-compare().

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/ChangeLog:

	* config/darwin-driver.c (darwin_driver_init): Revise comments, handle
	filelist and framework options in specs instead of code.
	* config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Update to handle link
	specs that are really driver ones.
	(DARWIN_CC1_SPEC): Likewise.
	(CPP_SPEC): Likewise.
	(SYSROOT_SPEC): Append space.
	(LINK_SYSROOT_SPEC): Remove most driver link specs.
	(STANDARD_STARTFILE_PREFIX_2): Update link-related specs.
	(STARTFILE_SPEC): Likewise.
	(ASM_MMACOSX_VERSION_MIN_SPEC): Fix line wrap.
	(ASM_SPEC): Update driver-related specs.
	(ASM_FINAL_SPEC): Likewise.
	* config/darwin.opt: Remove now unused option aliases.
	* config/i386/darwin.h (EXTRA_ASM_OPTS): Ensure space after opt.
	(ASM_SPEC): Update driver-related specs.
This commit is contained in:
Iain Sandoe 2019-06-14 19:14:30 +01:00
parent 730f52e05a
commit 353cb291a4
4 changed files with 228 additions and 264 deletions

View File

@ -259,14 +259,11 @@ maybe_get_sysroot_from_sdkroot ()
return xstrndup (maybe_sysroot, strlen (maybe_sysroot));
}
/* Translate -filelist and -framework options in *DECODED_OPTIONS
(size *DECODED_OPTIONS_COUNT) to use -Xlinker so that they are
considered to be linker inputs in the case that no other inputs are
specified. Handling these options in DRIVER_SELF_SPECS does not
suffice because specs are too late to add linker inputs, and
handling them in LINK_SPEC does not suffice because the linker will
not be called if there are no other inputs. When native, also
default the -mmacosx-version-min flag. */
/* Handle the deduction of m32/m64 from -arch flags and the interactions
between them (i.e. try to warn a user who thinks that they have a driver
that can produce multi-slice "FAT" outputs with more than one arch).
Default the -mmacosx-version-min flag, which requires a system call on
native hosts. */
void
darwin_driver_init (unsigned int *decoded_options_count,
@ -326,23 +323,6 @@ darwin_driver_init (unsigned int *decoded_options_count,
seenM64 = true;
break;
case OPT_filelist:
case OPT_framework:
++*decoded_options_count;
*decoded_options = XRESIZEVEC (struct cl_decoded_option,
*decoded_options,
*decoded_options_count);
memmove (*decoded_options + i + 2,
*decoded_options + i + 1,
((*decoded_options_count - i - 2)
* sizeof (struct cl_decoded_option)));
generate_option (OPT_Xlinker, (*decoded_options)[i].arg, 1,
CL_DRIVER, &(*decoded_options)[i + 1]);
generate_option (OPT_Xlinker,
(*decoded_options)[i].canonical_option[0], 1,
CL_DRIVER, &(*decoded_options)[i]);
break;
case OPT_mmacosx_version_min_:
seen_version_min = true;
vers_string =

View File

@ -118,25 +118,164 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* True if pragma ms_struct is in effect. */
extern GTY(()) int darwin_ms_struct;
/* The majority of Darwin's special driver opts are direct access to ld flags
(to save the user typing -Wl,xxxxx or Xlinker xxxxx) but we can't process
them here, since doing so will make it appear that there are linker infiles
and the linker will invoked even when it is not necessary.
/* Darwin has a user convenience feature where some linker options are exposed
at the driver level (so one can type "-all_load" instead of "-Wl,-all_load"
or "-Xlinker -all_load"). We retain this, but now these options are all
marked as 'Driver' and we process them as early as possible so that they
get allocated to the right toolchain command. There are a couple of special
cases where these driver opts are used multiple times, or to control
operations on more than one command (e.g. dynamiclib). These are handled
specially and we then add %<xxxx specs for the commands that _don't_ need
them. NOTE: the order of 'shared' and 'dynamiclib' is significant, hence
they are placed out of alphabetical order at the start. Likewise, we keep
a couple of cases where a negative option originally appeared after the
positive alternate, potentially overriding it.
When we report an error with %e, it seems necessary to strip the option
before doing so, otherwise it survives to the cc1 command line (%e doesn't
appear to abort the program before this).
Right now there's no mechanism to split up the "variable portion" (%*) of
the matched spec string, so where we have some driver specs that take 2
or 3 arguments, these cannot be processed here, but are deferred until the
LINK_SPEC, where they are copied verbatim.
We have a "safe" version of the MacOS version string, that's been sanity-
checked and truncated to minor version. If the 'tiny' (3rd) portion of the
value is not significant, it's better to use this in version-compare(). */
However, a few can be handled and we can elide options that are silently-
ignored defaults, plus warn on obsolete ones that no longer function. */
#undef SUBTARGET_DRIVER_SELF_SPECS
#define SUBTARGET_DRIVER_SELF_SPECS \
"%{fapple-kext|mkernel:-static}", \
"%{gfull:-g -fno-eliminate-unused-debug-symbols} %<gfull", \
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
%<gsplit-dwarf", \
"%{gused:-g -feliminate-unused-debug-symbols} %<gused", \
"%{rpath*: -Xlinker -rpath -Xlinker %*}", \
"%{shared:-Zdynamiclib} %<shared", \
"%{static:%{Zdynamic:%e conflicting code gen style switches are used}}",\
"%{y*:%nthe y option is obsolete and ignored} %<y*", \
"%<Mach "
"%{shared:%{!dynamiclib:-dynamiclib}} %<shared", \
"%{static:%{dynamic|dynamiclib:%econflicting code generation switches}}",\
"%{dynamiclib:-Xlinker -dylib \
%{allowable_client*:-Xlinker -allowable_client -Xlinker %*} \
%<allowable_client* \
%{bundle_loader*: %<bundle_loader* \
%e-bundle_loader not allowed with -dynamiclib} \
%{client_name*: %<client_name* \
%e-client_name not allowed with -dynamiclib} \
%{compatibility_version*:\
-Xlinker -dylib_compatibility_version -Xlinker %*} \
%<compatibility_version* \
%{current_version*:-Xlinker -dylib_current_version -Xlinker %*} \
%<current_version* \
%{install_name*:-Xlinker -dylib_install_name -Xlinker %* } \
%<install_name* \
%{keep_private_externs: %<keep_private_externs \
%e-keep_private_externs not allowed with -dynamiclib} \
%{private_bundle: %<private_bundle \
%e-private_bundle not allowed with -dynamiclib} \
}", \
"%{!dynamiclib: \
%{bundle_loader*:-Xlinker -bundle_loader -Xlinker %*} \
%<bundle_loader* \
%{client_name*:-Xlinker -client_name -Xlinker %*} \
%<client_name* \
%{compatibility_version*: %<compatibility_version* \
%e-compatibility_version only allowed with -dynamiclib} \
%{current_version*: %<current_version* \
%e-current_version only allowed with -dynamiclib} \
%{install_name*: %<install_name* \
%e-install_name only allowed with -dynamiclib} \
%{keep_private_externs:-Xlinker -keep_private_externs} \
%<keep_private_externs \
%{private_bundle:-Xlinker -private_bundle} \
%<private_bundle \
}", \
"%{all_load:-Xlinker -all_load} %<all_load", \
"%{arch_errors_fatal:-Xlinker -arch_errors_fatal} \
%<arch_errors_fatal", \
"%{bind_at_load:-Xlinker -bind_at_load} %<bind_at_load", \
"%{bundle:%{!dynamiclib:-Xlinker -bundle; \
:%e-bundle not allowed with -dynamiclib}}", \
"%{dead_strip:-Xlinker -dead_strip} %<dead_strip", \
"%{dylib_file*:-Xlinker -dylib_file -Xlinker %*} %<dylib_file*", \
"%{dylinker:-Xlinker -dylinker} %<dylinker", \
"%{dylinker_install_name*:-Xlinker -dylinker_install_name -Xlinker %*}\
%<dylinker_install_name*", \
"%{exported_symbols_list*:-Xlinker -exported_symbols_list -Xlinker %*}\
%<exported_symbols_list", \
"%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls", \
"%{fterminated-vtables: -fapple-kext} %<fterminated-vtables", \
"%{fapple-kext|mkernel:-static}", \
"%{filelist*:-Xlinker -filelist -Xlinker %*} %<filelist*", \
"%{flat_namespace:-Xlinker -flat_namespace} %<flat_namespace", \
"%{force_cpusubtype_ALL:-Xassembler -force_cpusubtype_ALL} ", \
"%{force_flat_namespace: \
%{!dynamiclib:-Xlinker -force_flat_namespace; \
:%e-force_flat_namespace not allowed with -dynamiclib}} \
%<force_flat_namespace", \
"%{framework*:-Xlinker -framework -Xlinker %*} %<framework*", \
"%{gfull:-g -fno-eliminate-unused-debug-symbols} %<gfull", \
"%{gused:-g -feliminate-unused-debug-symbols} %<gused", \
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
%<gsplit-dwarf", \
"%{headerpad_max_install_names:-Xlinker -headerpad_max_install_names}\
%<headerpad_max_install_names", \
"%{image_base*:-Xlinker -image_base -Xlinker %*} %<image_base*", \
"%{init*:-Xlinker -init -Xlinker %*} %<init*", \
"%{multi_module:-Xlinker -multi_module} %<multi_module", \
"%{multiply_defined*:-Xlinker -multiply_defined -Xlinker %*; \
:%{shared-libgcc: \
%:version-compare(< 10.5 asm_macosx_version_min= -Xlinker) \
%:version-compare(< 10.5 asm_macosx_version_min= -multiply_defined) \
%:version-compare(< 10.5 asm_macosx_version_min= -Xlinker) \
%:version-compare(< 10.5 asm_macosx_version_min= suppress)}} \
%<multiply_defined*", \
"%{multiplydefinedunused*:\
-Xlinker -multiply_defined_unused -Xlinker %*} \
%<multiplydefinedunused* ", \
"%{no_dead_strip_inits_and_terms:\
-Xlinker -no_dead_strip_inits_and_terms} \
%<no_dead_strip_inits_and_terms", \
"%{nofixprebinding:-Xlinker -nofixprebinding} %<nofixprebinding", \
"%{nomultidefs:-Xlinker -nomultidefs} %<nomultidefs", \
"%{pagezero_size*:-Xlinker -pagezero_size -Xlinker %*} \
%<pagezero_size", \
"%{prebind:-Xlinker -prebind} %<prebind", \
"%{noprebind:-Xlinker -noprebind} %<noprebind", \
"%{prebind_all_twolevel_modules:\
-Xlinker -prebind_all_twolevel_modules} \
%<prebind_all_twolevel_modules", \
"%{preload:-Xlinker -preload} %<preload", \
"%{read_only_relocs*:-Xlinker -read_only_relocs -Xlinker %*} \
%<read_only_relocs*", \
"%{rpath*: -Xlinker -rpath -Xlinker %*}", \
"%{seg_addr_table_filename*: \
-Xlinker -seg_addr_table_filename -Xlinker %*} \
%<seg_addr_table_filename*", \
"%{seg_addr_table*:-Xlinker -seg_addr_table -Xlinker %*} \
%<seg_addr_table*", \
"%{seg1addr*:-Xlinker -image_base -Xlinker %*} %<seg1addr*", \
"%{seglinkedit:-Xlinker -seglinkedit} %<seglinkedit", \
"%{noseglinkedit:-Xlinker -noseglinkedit} %<noseglinkedit", \
"%{segs_read_only_addr*:-Xlinker -segs_read_only_addr -Xlinker %*} \
%<segs_read_only_addr*", \
"%{segs_read_write_addr*:-Xlinker -segs_read_write_addr -Xlinker %*} \
%<segs_read_write_addr*", \
"%{single_module:-Xlinker -single_module} %<single_module", \
"%{sub_library*:-Xlinker -sub_library -Xlinker %*} %<sub_library*", \
"%{sub_umbrella*:-Xlinker -sub_umbrella -Xlinker %*} %<sub_umbrella*",\
"%{twolevel_namespace:-Xlinker -twolevel_namespace} \
%<twolevel_namespace", \
"%{twolevel_namespace_hints:-Xlinker -twolevel_namespace_hints} \
%<twolevel_namespace_hints", \
"%{umbrella*:-Xlinker -umbrella -Xlinker %*} %<umbrella*", \
"%{undefined*:-Xlinker -undefined -Xlinker %*} %<undefined*", \
"%{unexported_symbols_list*:\
-Xlinker -unexported_symbols_list -Xlinker %*} \
%<unexported_symbols_list*", \
"%{!weak_reference_mismatches*:\
%:version-compare(< 10.5 asm_macosx_version_min= -Xlinker) \
%:version-compare(< 10.5 asm_macosx_version_min= -weak_reference_mismatches) \
%:version-compare(< 10.5 asm_macosx_version_min= -Xlinker) \
%:version-compare(< 10.5 asm_macosx_version_min= non-weak)}", \
"%{weak_reference_mismatches*:\
-Xlinker -weak_reference_mismatches -Xlinker %*} \
%<weak_reference_mismatches*", \
"%{whyload:-Xlinker -whyload} %<whyload", \
"%{whatsloaded:-Xlinker -whatsloaded} %<whatsloaded", \
"%{w:-Xlinker -w}", \
"%<y*", \
"%<Mach "
#if LD64_HAS_EXPORT_DYNAMIC
#define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}"
@ -157,9 +296,7 @@ extern GTY(()) int darwin_ms_struct;
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }"
#define DARWIN_CC1_SPEC \
"%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls " \
"%{fterminated-vtables: -fapple-kext} %<fterminated-vtables " \
"%<filelist* %<framework*"
"%<dynamic %<dynamiclib %<force_cpusubtype_ALL "
#define SUBSUBTARGET_OVERRIDE_OPTIONS \
do { \
@ -184,7 +321,7 @@ extern GTY(()) int darwin_ms_struct;
#undef CPP_SPEC
#define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \
" %{pthread:-D_REENTRANT}"
" %{pthread:-D_REENTRANT} "
/* This is a fix for PR41260 by passing -no_compact_unwind on darwin10 and
later until the assembler, linker and libunwind are able to deal with the
@ -274,101 +411,38 @@ extern GTY(()) int darwin_ms_struct;
#define HAVE_LD_SYSROOT 1
/* It seems the only (working) way to get a space after %R is to append a
dangling '/'. */
#define SYSROOT_SPEC "%{!isysroot*:-syslibroot %R/ }"
#define SYSROOT_SPEC "%{!isysroot*:-syslibroot %R/ } "
/* Do the same as clang, for now, and insert the sysroot for ld when an
isysroot is specified. */
#define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*}"
#define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*} "
/* Suppress the addition of extra prefix paths when a sysroot is in use. */
#define STANDARD_STARTFILE_PREFIX_1 ""
#define STANDARD_STARTFILE_PREFIX_2 ""
/* Please keep the random linker options in alphabetical order (modulo
'Z' and 'no' prefixes). Note that options taking arguments may appear
multiple times on a command line with different arguments each time,
so put a * after their names so all of them get passed. */
/* Please keep the random linker options in alphabetical order.
Note that options taking arguments may appear multiple times on a command
line with different arguments each time, so put a * after their names so
all of them get passed. */
#define LINK_SPEC \
"%{static}%{!static:-dynamic} \
"%{static}%{!static:%{!dynamic:-dynamic}} \
%:remove-outfile(-ldl) \
%:remove-outfile(-lm) \
%:remove-outfile(-lpthread) \
%{fgnu-runtime: %{static|static-libgcc: \
%:replace-outfile(-lobjc libobjc-gnu.a%s); \
:%:replace-outfile(-lobjc -lobjc-gnu ) } }\
:%:replace-outfile(-lobjc -lobjc-gnu )}}\
%{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\
%{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\
%{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\
%{!Zdynamiclib: \
%{Zforce_cpusubtype_ALL:-arch %(darwin_arch) -force_cpusubtype_ALL} \
%{!Zforce_cpusubtype_ALL:-arch %(darwin_subarch)} \
%{Zbundle:-bundle} \
%{Zbundle_loader*:-bundle_loader %*} \
%{client_name*} \
%{compatibility_version*:%e-compatibility_version only allowed with -dynamiclib\
} \
%{current_version*:%e-current_version only allowed with -dynamiclib} \
%{Zforce_flat_namespace:-force_flat_namespace} \
%{Zinstall_name*:%e-install_name only allowed with -dynamiclib} \
%{keep_private_externs} \
%{private_bundle} \
} \
%{Zdynamiclib: -dylib \
%{Zbundle:%e-bundle not allowed with -dynamiclib} \
%{Zbundle_loader*:%e-bundle_loader not allowed with -dynamiclib} \
%{client_name*:%e-client_name not allowed with -dynamiclib} \
%{compatibility_version*:-dylib_compatibility_version %*} \
%{current_version*:-dylib_current_version %*} \
%{Zforce_cpusubtype_ALL:-arch %(darwin_arch)} \
%{!Zforce_cpusubtype_ALL: -arch %(darwin_subarch)} \
%{Zforce_flat_namespace:%e-force_flat_namespace not allowed with -dynamiclib} \
%{Zinstall_name*:-dylib_install_name %*} \
%{keep_private_externs:%e-keep_private_externs not allowed with -dynamiclib} \
%{private_bundle:%e-private_bundle not allowed with -dynamiclib} \
} \
%{Zall_load:-all_load} \
%{Zallowable_client*:-allowable_client %*} \
%{Zbind_at_load:-bind_at_load} \
%{Zarch_errors_fatal:-arch_errors_fatal} \
%{Zdead_strip:-dead_strip} \
%{Zno_dead_strip_inits_and_terms:-no_dead_strip_inits_and_terms} \
%{Zdylib_file*:-dylib_file %*} \
%{Zdynamic:-dynamic}\
%{Zexported_symbols_list*:-exported_symbols_list %*} \
%{Zflat_namespace:-flat_namespace} \
%{headerpad_max_install_names} \
%{Zimage_base*:-image_base %*} \
%{Zinit*:-init %*} \
%{mmacosx-version-min=*:-macosx_version_min %*} \
%{nomultidefs} \
%{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \
%{Zmultiply_defined*:-multiply_defined %*} \
%{!Zmultiply_defined*:%{shared-libgcc: \
%:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \
%:version-compare(< 10.5 mmacosx-version-min= suppress)}} \
%{Zmultiplydefinedunused*:-multiply_defined_unused %*} \
%{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \
%{read_only_relocs} \
%{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} \
%{Zsegaddr*:-segaddr %*} \
%{Zsegs_read_only_addr*:-segs_read_only_addr %*} \
%{Zsegs_read_write_addr*:-segs_read_write_addr %*} \
%{Zseg_addr_table*: -seg_addr_table %*} \
%{Zfn_seg_addr_table_filename*:-seg_addr_table_filename %*} \
%{sub_library*} %{sub_umbrella*} \
" LINK_SYSROOT_SPEC " \
%{twolevel_namespace} %{twolevel_namespace_hints} \
%{Zumbrella*: -umbrella %*} \
%{undefined*} \
%{Zunexported_symbols_list*:-unexported_symbols_list %*} \
%{Zweak_reference_mismatches*:-weak_reference_mismatches %*} \
%{!Zweak_reference_mismatches*:-weak_reference_mismatches non-weak} \
%{w} \
%{pagezero_size*} %{segs_read_*} %{seglinkedit} %{noseglinkedit} \
%{sectalign*} %{sectobjectsymbols*} %{segcreate*} %{whyload} \
%{whatsloaded} %{dylinker_install_name*} \
%{dylinker} "
%{force_cpusubtype_ALL:-arch %(darwin_arch)} \
%{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\
LINK_SYSROOT_SPEC \
"%{mmacosx-version-min=*:-macosx_version_min %*} \
%{sectalign*} %{sectcreate*} %{sectobjectsymbols*} %{sectorder*} \
%{segaddr*} %{segcreate*} %{segprot*} "
/* Machine dependent libraries. */
@ -410,9 +484,9 @@ extern GTY(()) int darwin_ms_struct;
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
"%{Zdynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \
%{!Zdynamiclib:%{Zbundle:%(darwin_bundle1)} \
%{!Zbundle:%{pg:%{static:-lgcrt0.o} \
"%{dynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \
%{!dynamiclib:%{bundle:%(darwin_bundle1)} \
%{!bundle:%{pg:%{static:-lgcrt0.o} \
%{!static:%{object:-lgcrt0.o} \
%{!object:%{preload:-lgcrt0.o} \
%{!preload:-lgcrt1.o \
@ -423,7 +497,7 @@ extern GTY(()) int darwin_ms_struct;
%{!object:%{preload:-lcrt0.o} \
%{!preload: %(darwin_crt1) \
%(darwin_crt2)}}}}}} \
%(darwin_crt3)"
%(darwin_crt3) %<dynamiclib "
/* We want a destructor last in the list. */
#define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
@ -463,24 +537,25 @@ extern GTY(()) int darwin_ms_struct;
#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
/* Emit macosx version (but only major). */
#define ASM_MMACOSX_VERSION_MIN_SPEC \
" %{asm_macosx_version_min=*: -mmacosx-version-min=%*} %<asm_macosx_version_min=*"
"%{asm_macosx_version_min=*: -mmacosx-version-min=%* } \
%<asm_macosx_version_min=* "
#else
#define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=*"
#define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=* "
#endif
/* When we detect that we're cctools or llvm as, we need to insert the right
additional options. */
#if HAVE_GNU_AS
/* The options are added in gcc.c for this case. */
#define ASM_OPTIONS ""
#else
/* When we detect that we're cctools or llvm as, we need to insert the right
additional options. Actually, currently these are the same as GAS. */
#define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
#endif
/* Default Darwin ASM_SPEC, very simple. */
#define ASM_SPEC "-arch %(darwin_arch) \
" ASM_OPTIONS " \
%{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
%{static}" ASM_MMACOSX_VERSION_MIN_SPEC
#define ASM_SPEC \
"%{static} -arch %(darwin_arch) " \
ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC
#ifdef HAVE_AS_STABS_DIRECTIVE
/* We only pass a debug option to the assembler if that supports stabs, since
@ -494,7 +569,8 @@ extern GTY(()) int darwin_ms_struct;
#define ASM_DEBUG_OPTION_SPEC ""
#define ASM_FINAL_SPEC \
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} %<gsplit-dwarf"
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
%<gsplit-dwarf"
/* We now require C++11 to bootstrap and newer tools than those based on
stabs, so require DWARF-2, even if stabs is supported by the assembler. */

View File

@ -90,11 +90,11 @@ Target RejectNegative Joined Separate Var(darwin_target_linker) Init(LD64_VERSIO
; Driver options.
all_load
Driver RejectNegative Alias(Zall_load)
Driver RejectNegative
Load all members of archive libraries, rather than only those that satisfy undefined symbols.
allowable_client
Driver RejectNegative Separate Alias(Zallowable_client)
Driver RejectNegative Separate
-allowable_client <name> The output dylib is private to the client <name>.
arch
@ -102,7 +102,7 @@ Driver RejectNegative Separate
-arch <name> Generate output for architecture <name>.
arch_errors_fatal
Driver RejectNegative Alias(Zarch_errors_fatal)
Driver RejectNegative
Mismatches between file architecture and one specified by \"-arch\" are errors instead of warnings.
asm_macosx_version_min=
@ -110,15 +110,15 @@ Driver RejectNegative Joined
The earliest macOS version on which this program will run (formatted for the assembler).
bind_at_load
Driver RejectNegative Alias(Zbind_at_load)
Driver RejectNegative
Generate an output executable that binds symbols on load, rather than lazily.
bundle
Driver RejectNegative Alias(Zbundle)
Driver RejectNegative
Generate a Mach-O bundle (file type MH_BUNDLE).
bundle_loader
Driver RejectNegative Separate Alias(Zbundle_loader)
Driver RejectNegative Separate
-bundle_loader <executable> Treat <executable> (that will be loading this bundle) as if it was one of the dynamic libraries the bundle is linked against for symbol resolution.
client_name
@ -134,11 +134,12 @@ Driver RejectNegative Separate
-current_version <number> Set the current version for the library to <number>.
dead_strip
Driver RejectNegative Alias(Zdead_strip)
Driver RejectNegative
Remove code and data that is unreachable from any exported symbol (including the entry point).
dylib_file
Driver Separate Alias(Zdylib_file)
Driver RejectNegative Separate
-dylib_file install_name:file_name This allows linking of a dylib with \"install_name\" but to be found in a different install position \"file_name\"
dylinker
Driver RejectNegative
@ -149,15 +150,15 @@ Driver RejectNegative Separate
-dylinker_install_name <path> Only used for building dyld.
dynamic
Driver RejectNegative Alias(Zdynamic)
Driver RejectNegative
The default (and opposite of -static), implied by user mode executables, shared libraries and bundles.
dynamiclib
Driver RejectNegative Alias(Zdynamiclib)
Driver RejectNegative
Produce a Mach-O shared library (file type MH_DYLIB), synonym for \"-shared\".
exported_symbols_list
Driver RejectNegative Separate Alias(Zexported_symbols_list)
Driver RejectNegative Separate
-exported_symbols_list <filename> Export global symbols in <filename> in linked output file; any symbols not mentioned will be treated as \"hidden\".
filelist
@ -169,15 +170,15 @@ Driver RejectNegative
Used for generating code for some older kernel revisions.
flat_namespace
Driver RejectNegative Alias(Zflat_namespace)
Driver RejectNegative
Ignore the normal two-level namespace; resolve symbols in command line order and do not record which library provided the resolved symbol.
force_cpusubtype_ALL
Driver RejectNegative Alias(Zforce_cpusubtype_ALL)
Driver RejectNegative
For the assembler (and linker) permit any architecture sub-variant to be used without error.
force_flat_namespace
Driver RejectNegative Alias(Zforce_flat_namespace)
Driver RejectNegative
Set the output object such that, on loading, dyld will ignore any two-level namespace information and resolve symbols in the discovery order for loaded libs.
framework
@ -201,15 +202,15 @@ Driver RejectNegative
Automatically adds space for longer path names in load commands (up to MAXPATHLEN).
image_base
Driver RejectNegative Separate Alias(Zimage_base)
Driver RejectNegative Separate
-image_base <address> Specify <address> as the base address for a dylib or bundle.
init
Driver RejectNegative Separate Alias(Zinit)
Driver RejectNegative Separate
-init <symbol_name> The symbol <symbol_name> will be used as the first initialiser for a dylib.
install_name
Driver RejectNegative Separate Alias(Zinstall_name)
Driver RejectNegative Separate
-install_name <name> Set the install name for a dylib.
keep_private_externs
@ -217,19 +218,19 @@ Driver RejectNegative
Usually \"private extern\" (hidden) symbols are made local when linking, this command suppresses that such that they remain exported.
multi_module
Driver RejectNegative Alias(Zmulti_module)
Driver RejectNegative
(Obsolete after 10.4) Multi modules are ignored at runtime since macOS 10.4.
multiply_defined
Driver RejectNegative Separate Alias(Zmultiply_defined)
Driver RejectNegative Separate
(Obsolete after 10.4) -multiply_defined <treatment> Provided a mechanism for warning about symbols defined in multiple dylibs.
multiply_defined_unused
Driver RejectNegative Separate Alias(Zmultiplydefinedunused)
Driver RejectNegative Separate
(Obsolete after 10.4) -multiply_defined_unused <treatment> Provided a mechanism for warning about symbols defined in the current executable also being defined in linked dylibs.
no_dead_strip_inits_and_terms
Driver RejectNegative Alias(Zno_dead_strip_inits_and_terms)
Driver RejectNegative
(Obsolete) Current linkers never dead-strip these items, so the option is not needed.
nofixprebinding
@ -299,12 +300,12 @@ Driver RejectNegative Separate Args(3)
(Obsolete) -sectorder <segname> <sectname> <orderfile> Replaced by a more general option \"-order_file\".
seg_addr_table
Driver RejectNegative Separate Alias(Zseg_addr_table)
Driver RejectNegative Separate
-seg_addr_table <file> Specify the base addresses for dynamic libraries; <file> contains a line for each library.
; This is only usable by the ld_classic linker.
seg_addr_table_filename
Driver RejectNegative Separate Alias(Zfn_seg_addr_table_filename)
Driver RejectNegative Separate
(Obsolete, ld_classic only) -seg_addr_table_filename <path>.
seg1addr
@ -312,7 +313,7 @@ Driver RejectNegative Separate
Synonym for \"image_base\".
segaddr
Driver RejectNegative Separate Args(2) Alias(Zsegaddr)
Driver RejectNegative Separate Args(2)
-segaddr <name> <address> Set the base address of segment <name> to <address> which must be aligned to a page boundary (currently 4kb).
; This is only usable by the ld_classic linker.
@ -329,15 +330,15 @@ Driver RejectNegative Separate Args(3)
-segprot <segname> <max_prot> <init_prot> The virtual memory protections for segment <segname> have maximum and initial values <max_prot> and <init_prot> respectively. The specified values may contain \"r\", \"w\", \"x\" or \"-\" the latter meaning \"no access\".
segs_read_only_addr
Driver RejectNegative Separate Alias(Zsegs_read_only_addr)
Driver RejectNegative Separate
-segs_read_only_addr <address> Specify that <address> is the base address of the read-only segments of a dylib.
segs_read_write_addr
Driver RejectNegative Separate Alias(Zsegs_read_write_addr)
Driver RejectNegative Separate
-segs_read_write_addr <address> Specify that <address> is the base address address of the read-write segments of a dylib.
single_module
Driver RejectNegative Alias(Zsingle_module)
Driver RejectNegative
(Obsolete) This is the default.
sub_library
@ -357,7 +358,7 @@ Driver RejectNegative
Add extra information to the executable that can speed up dynamic loading (provided that dependent libraries are unchanged).
umbrella
Driver RejectNegative Separate Alias(Zumbrella)
Driver RejectNegative
-umbrella <framework> The specified framework will be re-exported.
undefined
@ -365,11 +366,11 @@ Driver RejectNegative Separate
-undefined <treatment> Specify the handling for undefined symbols (default is error).
unexported_symbols_list
Driver RejectNegative Separate Alias(Zunexported_symbols_list)
Driver RejectNegative Separate
-unexported_symbols_list <filename> Do not export the global symbols listed in <filename>.
weak_reference_mismatches
Driver RejectNegative Separate Alias(Zweak_reference_mismatches)
Driver RejectNegative Separate
-weak_reference_mismatches <treatment> Specifies what to do if a symbol import conflicts between file (weak in one and not in another) the default is to treat the symbol as non-weak.
whatsloaded
@ -391,97 +392,3 @@ Driver RejectNegative Joined
Mach
Driver RejectNegative
(Obsolete and unhandled by ld64, ignored) ld should produce an executable (only handled by ld_classic).
;; These are not "real" options, but placeholders used to hide the real options
;; from generic options processing... FIXME: they can be eliminated now.
Zall_load
Driver
Zallowable_client
Driver Separate
Zarch_errors_fatal
Driver
Zbind_at_load
Driver
Zbundle
Driver
Zbundle_loader
Driver Separate
Zdead_strip
Driver
Zdylib_file
Driver Separate
Zdynamic
Driver
Zdynamiclib
Driver
Zexported_symbols_list
Driver Separate
Zfn_seg_addr_table_filename
Driver Separate
Zflat_namespace
Driver
Zforce_cpusubtype_ALL
Driver
Zforce_flat_namespace
Driver
Zimage_base
Driver Separate
Zinit
Driver Separate
Zinstall_name
Driver Separate
Zmulti_module
Driver
Zmultiply_defined
Driver Separate
Zmultiplydefinedunused
Driver Separate
Zno_dead_strip_inits_and_terms
Driver
Zseg_addr_table
Driver Separate
Zsegaddr
Driver Separate Args(2)
Zsegs_read_only_addr
Driver Separate
Zsegs_read_write_addr
Driver Separate
Zsingle_module
Driver
Zumbrella
Driver Separate
Zunexported_symbols_list
Driver Separate
Zweak_reference_mismatches
Driver Separate

View File

@ -128,15 +128,16 @@ along with GCC; see the file COPYING3. If not see
/* This is a workaround for a tool bug: see PR100340. */
#ifdef HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN
#define EXTRA_ASM_OPTS " -mllvm -x86-pad-for-align=false"
#define EXTRA_ASM_OPTS " -mllvm -x86-pad-for-align=false "
#else
#define EXTRA_ASM_OPTS ""
#endif
#undef ASM_SPEC
#define ASM_SPEC "-arch %(darwin_arch) \
" ASM_OPTIONS " -force_cpusubtype_ALL \
%{static}" ASM_MMACOSX_VERSION_MIN_SPEC EXTRA_ASM_OPTS
#define ASM_SPEC \
"%{static} -arch %(darwin_arch) " \
ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC EXTRA_ASM_OPTS \
"%{!force_cpusubtype_ALL:-force_cpusubtype_ALL} "
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \