Skip to content

Commit 81fc0ae

Browse files
committed
Frontend: By default, assume -target-min-inlining-version min for modules compiled with -library-level api to catch availability issues in API swiftinterfaces.
Resolves rdar://90575987
1 parent 01a254f commit 81fc0ae

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
@@ -805,17 +805,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
805805
// First, set up default minimum inlining target versions.
806806
auto getDefaultMinimumInliningTargetVersion =
807807
[&](const llvm::Triple &triple) -> llvm::VersionTuple {
808-
#if SWIFT_DEFAULT_TARGET_MIN_INLINING_VERSION_TO_MIN
809-
// In ABI-stable modules, default to the version when Swift first became
810-
// available.
811-
if (FrontendOpts.EnableLibraryEvolution)
808+
// In API modules, default to the version when Swift first became available.
809+
if (Opts.LibraryLevel == LibraryLevel::API)
812810
if (auto minTriple = minimumAvailableOSVersionForTriple(triple))
813-
return minTriple;
814-
#endif
811+
return *minTriple;
815812

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