Skip to content

Commit 4e99cca

Browse files
authored
Merge pull request #41940 from tshortli/target-min-inlining-version-min-by-default
Assume `-target-min-inlining-version min` for `-library-level api` modules
2 parents 00c33f8 + 81fc0ae commit 4e99cca

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -804,17 +804,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
804804
// First, set up default minimum inlining target versions.
805805
auto getDefaultMinimumInliningTargetVersion =
806806
[&](const llvm::Triple &triple) -> llvm::VersionTuple {
807-
#if SWIFT_DEFAULT_TARGET_MIN_INLINING_VERSION_TO_MIN
808-
// In ABI-stable modules, default to the version when Swift first became
809-
// available.
810-
if (FrontendOpts.EnableLibraryEvolution)
807+
// In API modules, default to the version when Swift first became available.
808+
if (Opts.LibraryLevel == LibraryLevel::API)
811809
if (auto minTriple = minimumAvailableOSVersionForTriple(triple))
812-
return minTriple;
813-
#endif
810+
return *minTriple;
814811

815-
// In ABI-unstable modules, we will never have to interoperate with
816-
// older versions of the module, so we should default to the minimum
817-
// deployment target.
812+
// In other modules, assume that availability is used less consistently
813+
// and that library clients will generally raise deployment targets as the
814+
// library evolves so the min inlining version should be the deployment
815+
// target by default.
818816
unsigned major, minor, patch;
819817
if (triple.isMacOSX())
820818
triple.getMacOSXVersion(major, minor, patch);

test/attr/attr_inlinable_available.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,29 @@
1616
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -target %target-next-stable-abi-triple -target-min-inlining-version min
1717

1818

19+
// Check that `-library-level api` implies `-target-min-inlining-version min`
20+
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -target %target-next-stable-abi-triple -library-level api
21+
22+
1923
// Check that these rules are only applied when requested and that at least some
2024
// diagnostics are not present without it.
21-
// RUN: not %target-typecheck-verify-swift -swift-version 5 -target %target-next-stable-abi-triple 2>&1 | %FileCheck --check-prefix NON_ABI %s
22-
// NON_ABI: error: expected error not produced
23-
// NON_ABI: {'BetweenTargets' is only available in}
25+
// RUN: not %target-typecheck-verify-swift -swift-version 5 -target %target-next-stable-abi-triple 2>&1 | %FileCheck --check-prefix NON_MIN %s
26+
27+
28+
// Check that -target-min-inlining-version overrides -library-level, allowing
29+
// library owners to disable this behavior for API libraries if needed.
30+
// RUN: not %target-typecheck-verify-swift -swift-version 5 -target %target-next-stable-abi-triple -target-min-inlining-version target -library-level api 2>&1 | %FileCheck --check-prefix NON_MIN %s
2431

2532

2633
// Check that we respect -target-min-inlining-version by cranking it up high
2734
// enough to suppress any possible errors.
2835
// RUN: %target-swift-frontend -typecheck -disable-objc-attr-requires-foundation-module %s -swift-version 5 -enable-library-evolution -target %target-next-stable-abi-triple -target-min-inlining-version 42.0
2936

37+
38+
// NON_MIN: error: expected error not produced
39+
// NON_MIN: {'BetweenTargets' is only available in}
40+
41+
3042
/// Declaration with no availability annotation. Should be inferred as minimum
3143
/// inlining target.
3244
public struct NoAvailable {

0 commit comments

Comments
 (0)