Skip to content

Commit 4d94eff

Browse files
committed
Respect runtime-compatibility-version flag also for dynamic replacement compatibility library
rdar://56259688
1 parent f8209f2 commit 4d94eff

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,24 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
12281228

12291229
if (!Args.hasArg(options::
12301230
OPT_disable_autolinking_runtime_compatibility_dynamic_replacements)) {
1231+
Optional<llvm::VersionTuple> runtimeCompatibilityVersion;
1232+
if (auto versionArg =
1233+
Args.getLastArg(options::OPT_runtime_compatibility_version)) {
1234+
auto version = StringRef(versionArg->getValue());
1235+
if (version.equals("none")) {
1236+
runtimeCompatibilityVersion = None;
1237+
} else if (version.equals("5.0")) {
1238+
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
1239+
} else {
1240+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
1241+
versionArg->getAsString(Args), version);
1242+
}
1243+
} else {
1244+
runtimeCompatibilityVersion =
1245+
getSwiftRuntimeCompatibilityVersionForTarget(Triple);
1246+
}
12311247
Opts.AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion =
1232-
getSwiftRuntimeCompatibilityVersionForTarget(Triple);
1248+
runtimeCompatibilityVersion;
12331249
}
12341250
return false;
12351251
}

test/IRGen/autolink-runtime-compatibility.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -runtime-compatibility-version 5.0 -disable-autolinking-runtime-compatibility -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s
66

77
// Doesn't autolink compatibility library because runtime compatibility library is disabled
8-
// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -runtime-compatibility-version none -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s
8+
// RUN: %target-swift-frontend -runtime-compatibility-version none -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s
99

1010
// Doesn't autolink compatibility library because target OS doesn't need it
11-
// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -target x86_64-apple-macosx10.24 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s
11+
// RUN: %target-swift-frontend -target x86_64-apple-macosx10.24 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s
1212

1313
// Autolinks because compatibility library was explicitly asked for
1414
// RUN: %target-swift-frontend -runtime-compatibility-version 5.0 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD %s
@@ -18,8 +18,11 @@ public func foo() {}
1818

1919
// NO-FORCE-LOAD-NOT: FORCE_LOAD
2020
// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility50"}
21+
// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibilityDynamicReplacements"}
2122

2223
// FORCE-LOAD: declare {{.*}} @"_swift_FORCE_LOAD_$_swiftCompatibility50"
24+
// FORCE-LOAD: declare {{.*}} @"_swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements"
2325

2426
// FORCE-LOAD-DAG: [[AUTOLINK_SWIFT_COMPAT:![0-9]+]] = !{!"-lswiftCompatibility50"}
27+
// FORCE-LOAD-DAG: !{!"-lswiftCompatibilityDynamicReplacements"}
2528
// FORCE-LOAD-DAG: !llvm.linker.options = !{{{.*}}[[AUTOLINK_SWIFT_COMPAT]]{{[,}]}}

0 commit comments

Comments
 (0)