Skip to content

Commit f889bcc

Browse files
tienexhpux735
authored andcommitted
Implement -use-ld= switch in Swift
1 parent 9638e29 commit f889bcc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ def no_link_objc_runtime : Flag<["-"], "no-link-objc-runtime">,
254254
Flags<[HelpHidden, DoesNotAffectIncrementalBuild]>,
255255
HelpText<"Don't link in additions to the Objective-C runtime">;
256256

257+
def use_ld : Joined<["-"], "use-ld=">,
258+
Flags<[DoesNotAffectIncrementalBuild]>,
259+
HelpText<"Specifies the linker to be used">;
260+
257261
def Xlinker : Separate<["-"], "Xlinker">,
258262
Flags<[DoesNotAffectIncrementalBuild]>,
259263
HelpText<"Specifies an option which should be passed to the linker">;

lib/Driver/ToolChains.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,17 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
11301130
Arguments.push_back(context.Args.MakeArgString(context.OI.SDKPath));
11311131
}
11321132

1133+
// Select the linker to use
1134+
llvm::SmallString<128> Linker;
1135+
1136+
if (const Arg *A = context.Args.getLastArg(options::OPT_use_ld)) {
1137+
Linker = A->getValue();
1138+
}
1139+
1140+
if (!Linker.empty()) {
1141+
Arguments.push_back(context.Args.MakeArgString("-fuse-ld=" + Linker));
1142+
}
1143+
11331144
// Add the runtime library link path, which is platform-specific and found
11341145
// relative to the compiler.
11351146
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime

0 commit comments

Comments
 (0)