Processing these in the driver self-specs and pushing the corresponding Xlinker 
lines
seemed like a good idea (nominally the Right Place to process driver specs).  
However,
it has the effect that the driver then supposes that there are linker inputs, 
and causes a
link line to be created even if it is not needed (of course, only if a linker 
option is given,
but still not desirable).

The solution is to place these drive specs into the link spec and claim them at 
the end
of that.  We can’t filter them at a lower level since RDYNAMIC, at least, is 
relevant to
kernel and kernel module code.

Tested on i686-darwin9, x86-64-darwin16, x86-64-darwin18
applied to mainline
thanks
Iain

2019-07-03  Iain Sandoe  <i...@sandoe.co.uk>

        * config/darwin.h (DRIVER_SELF_SPECS): Remove the linker cases.
        (RDYNAMIC): Rename to, DARWIN_RDYNAMIC.
        (DARWIN_PIE_SPEC, DARWIN_NOPIE_SPEC): Adjust to remove the Xlinker
        clauses.
        (LINK_COMMAND_SPEC_A): Add DARWIN_RDYNAMIC, DARWIN_PIE_SPEC and
        DARWIN_NOPIE_SPEC.

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 72215ce..e17bc64 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -124,30 +124,25 @@ extern GTY(()) int darwin_ms_struct;
   "%{fapple-kext|mkernel:-static}",                            \
   "%{shared:-Zdynamiclib} %<shared",                            \
   "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \
-     %<gsplit-dwarf",                                          \
-  DARWIN_PIE_SPEC,                                             \
-  DARWIN_NOPIE_SPEC,                                           \
-  RDYNAMIC
+     %<gsplit-dwarf"
 
 #if LD64_HAS_EXPORT_DYNAMIC
-#define RDYNAMIC "%{rdynamic:-Xlinker -export_dynamic} %<rdynamic"
+#define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}"
 #else
-#define RDYNAMIC "%{rdynamic:%nrdynamic is not supported} %<rdynamic"
+#define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
 #endif
 
 /* FIXME: we should check that the linker supports the -pie and -no_pie.
    options.  */
 #define DARWIN_PIE_SPEC \
-"%{pie|fpie|fPIE: \
+"%{pie|fpie|fPIE:\
    %{mdynamic-no-pic: \
-       %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
-     : %:version-compare(>= 10.5 mmacosx-version-min= -Xlinker) \
-       %:version-compare(>= 10.5 mmacosx-version-min= -pie) }} %<pie "
+     %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
+     :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }} "
 
 #define DARWIN_NOPIE_SPEC \
 "%{no-pie|fno-pie|fno-PIE: \
-   %:version-compare(>= 10.7 mmacosx-version-min= -Xlinker ) \
-   %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %<no-pie "
+   %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }"
 
 #define DARWIN_CC1_SPEC                                                        
\
   "%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls " \
@@ -227,8 +222,11 @@ extern GTY(()) int darwin_ms_struct;
       %(link_gcc_c_sequence) \
     }}}\
     %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} %{F*} "\
+    DARWIN_PIE_SPEC \
+    DARWIN_NOPIE_SPEC \
+    DARWIN_RDYNAMIC \
     DARWIN_NOCOMPACT_UNWIND \
-    "}}}}}}}"
+    "}}}}}}} %<pie %<no-pie %<rdynamic "
 
 #define DSYMUTIL "\ndsymutil"
 

Reply via email to