Skip to content

Commit 7947379

Browse files
committed
Darwin: Fix empty g++ command lines [PR105599].
An empty g++ command line should produce a diagnostic that there are no inputs. The PR is that currently Darwin produces a dignostic about missing link items instead - this is because (errnoeously), for this driver, we are creating a link job for empty command lines. The problem occurs in four stages: The g++ driver appends -shared-libgcc to the command line. The Darwin driver_init code in the backend does not see this (it sees an empty command line). When the back end driver code driver sees an empty command line, it does not add any supplementary flags (e.g. asm-macosx-version-min) - precisely to avoid anything being claimed as an input_file and therefore triggering a link line. Since we do not have a value for asm-macosx-version-min when processing the driver specs, we unconditionally inject 'multiply_defined suppress' which is used with shared libgcc (but only intended on very old Darwin). This then causes the generation of a link job. The solution, for the present, is to move version-specific link params to the LINK_SPEC so that they are only processed when a link job has already been decided. Signed-off-by: Iain Sandoe <[email protected]> PR target/105599 gcc/ChangeLog: * config/darwin.h: Move versions-specific handling of multiply_defined from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.
1 parent da5f0cc commit 7947379

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

gcc/config/darwin.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ extern GTY(()) int darwin_ms_struct;
143143
Right now there's no mechanism to split up the "variable portion" (%*) of
144144
the matched spec string, so where we have some driver specs that take 2
145145
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(). */
146+
LINK_SPEC, where they are copied verbatim. */
150147

151148
#undef SUBTARGET_DRIVER_SELF_SPECS
152149
#define SUBTARGET_DRIVER_SELF_SPECS \
@@ -220,13 +217,8 @@ extern GTY(()) int darwin_ms_struct;
220217
"%{image_base*:-Xlinker -image_base -Xlinker %*} %<image_base*", \
221218
"%{init*:-Xlinker -init -Xlinker %*} %<init*", \
222219
"%{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*", \
220+
"%{multiply_defined*:-Xlinker -multiply_defined -Xlinker %*} \
221+
%<multiply_defined* ", \
230222
"%{multiplydefinedunused*:\
231223
-Xlinker -multiply_defined_unused -Xlinker %*} \
232224
%<multiplydefinedunused* ", \
@@ -458,6 +450,9 @@ extern GTY(()) int darwin_ms_struct;
458450
%{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\
459451
LINK_SYSROOT_SPEC \
460452
"%{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) }} \
461456
%{sectalign*} %{sectcreate*} %{sectobjectsymbols*} %{sectorder*} \
462457
%{segaddr*} %{segcreate*} %{segprot*} "
463458

0 commit comments

Comments
 (0)