mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Use autolinking to pull in compatibility libraries.
Many build systems that support Swift don't use swiftc to drive the linker. To make things easier for these build systems, also use autolinking to pull in the needed compatibility libraries. This is less ideal than letting the driver add it at link time, since individual compile jobs don't know whether they're building an executable or not. Introduce a `-disable-autolink-runtime-compatibility` flag, which build systems that do drive the linker with swiftc can pass to avoid autolinking. rdar://problem/50057445
This commit is contained in:
@@ -1158,6 +1158,30 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
A->getAsString(Args), A->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Autolink runtime compatibility libraries, if asked to.
|
||||
if (!Args.hasArg(options::OPT_disable_autolinking_runtime_compatibility)) {
|
||||
Optional<llvm::VersionTuple> runtimeCompatibilityVersion;
|
||||
|
||||
if (auto versionArg = Args.getLastArg(
|
||||
options::OPT_runtime_compatibility_version)) {
|
||||
auto version = StringRef(versionArg->getValue());
|
||||
if (version.equals("none")) {
|
||||
runtimeCompatibilityVersion = None;
|
||||
} else if (version.equals("5.0")) {
|
||||
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
|
||||
} else {
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
|
||||
versionArg->getAsString(Args), version);
|
||||
}
|
||||
} else {
|
||||
runtimeCompatibilityVersion =
|
||||
getSwiftRuntimeCompatibilityVersionForTarget(Triple);
|
||||
}
|
||||
|
||||
Opts.AutolinkRuntimeCompatibilityLibraryVersion =
|
||||
runtimeCompatibilityVersion;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user