@@ -1599,7 +1599,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
15991599
16001600 // Add the runtime library link path, which is platform-specific and found
16011601 // relative to the compiler.
1602- if (!staticExecutable && shouldProvideRPathToLinker ()) {
1602+ if (!( staticExecutable || staticStdlib) && shouldProvideRPathToLinker ()) {
16031603 // FIXME: We probably shouldn't be adding an rpath here unless we know
16041604 // ahead of time the standard library won't be copied.
16051605 Arguments.push_back (" -Xlinker" );
@@ -1615,8 +1615,6 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16151615 addPrimaryInputsOfType (Arguments, context.Inputs , types::TY_Object);
16161616 addInputsOfType (Arguments, context.InputActions , types::TY_Object);
16171617
1618- context.Args .AddAllArgs (Arguments, options::OPT_Xlinker);
1619- context.Args .AddAllArgs (Arguments, options::OPT_linker_option_Group);
16201618 for (const Arg *arg : context.Args .filtered (options::OPT_F,
16211619 options::OPT_Fsystem)) {
16221620 if (arg->getOption ().matches (options::OPT_Fsystem))
@@ -1631,6 +1629,14 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16311629 Arguments.push_back (context.Args .MakeArgString (context.OI .SDKPath ));
16321630 }
16331631
1632+ // Add any autolinking scripts to the arguments
1633+ for (const Job *Cmd : context.Inputs ) {
1634+ auto &OutputInfo = Cmd->getOutput ();
1635+ if (OutputInfo.getPrimaryOutputType () == types::TY_AutolinkFile)
1636+ Arguments.push_back (context.Args .MakeArgString (
1637+ Twine (" @" ) + OutputInfo.getPrimaryOutputFilename ()));
1638+ }
1639+
16341640 // Link the standard library.
16351641 Arguments.push_back (" -L" );
16361642
@@ -1692,14 +1698,8 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
16921698 Twine (" -u" , llvm::getInstrProfRuntimeHookVarName ())));
16931699 }
16941700
1695-
1696- // Add any autolinking scripts to the arguments
1697- for (const Job *Cmd : context.Inputs ) {
1698- auto &OutputInfo = Cmd->getOutput ();
1699- if (OutputInfo.getPrimaryOutputType () == types::TY_AutolinkFile)
1700- Arguments.push_back (context.Args .MakeArgString (
1701- Twine (" @" ) + OutputInfo.getPrimaryOutputFilename ()));
1702- }
1701+ context.Args .AddAllArgs (Arguments, options::OPT_Xlinker);
1702+ context.Args .AddAllArgs (Arguments, options::OPT_linker_option_Group);
17031703
17041704 // Just before the output option, allow GenericUnix toolchains to add
17051705 // additional inputs.
0 commit comments