mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #41940 from tshortli/target-min-inlining-version-min-by-default
Assume `-target-min-inlining-version min` for `-library-level api` modules
This commit is contained in:
@@ -804,17 +804,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
|||||||
// First, set up default minimum inlining target versions.
|
// First, set up default minimum inlining target versions.
|
||||||
auto getDefaultMinimumInliningTargetVersion =
|
auto getDefaultMinimumInliningTargetVersion =
|
||||||
[&](const llvm::Triple &triple) -> llvm::VersionTuple {
|
[&](const llvm::Triple &triple) -> llvm::VersionTuple {
|
||||||
#if SWIFT_DEFAULT_TARGET_MIN_INLINING_VERSION_TO_MIN
|
// In API modules, default to the version when Swift first became available.
|
||||||
// In ABI-stable modules, default to the version when Swift first became
|
if (Opts.LibraryLevel == LibraryLevel::API)
|
||||||
// available.
|
|
||||||
if (FrontendOpts.EnableLibraryEvolution)
|
|
||||||
if (auto minTriple = minimumAvailableOSVersionForTriple(triple))
|
if (auto minTriple = minimumAvailableOSVersionForTriple(triple))
|
||||||
return minTriple;
|
return *minTriple;
|
||||||
#endif
|
|
||||||
|
|
||||||
// In ABI-unstable modules, we will never have to interoperate with
|
// In other modules, assume that availability is used less consistently
|
||||||
// older versions of the module, so we should default to the minimum
|
// and that library clients will generally raise deployment targets as the
|
||||||
// deployment target.
|
// library evolves so the min inlining version should be the deployment
|
||||||
|
// target by default.
|
||||||
unsigned major, minor, patch;
|
unsigned major, minor, patch;
|
||||||
if (triple.isMacOSX())
|
if (triple.isMacOSX())
|
||||||
triple.getMacOSXVersion(major, minor, patch);
|
triple.getMacOSXVersion(major, minor, patch);
|
||||||
|
|||||||
@@ -16,17 +16,29 @@
|
|||||||
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -target %target-next-stable-abi-triple -target-min-inlining-version min
|
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -target %target-next-stable-abi-triple -target-min-inlining-version min
|
||||||
|
|
||||||
|
|
||||||
|
// Check that `-library-level api` implies `-target-min-inlining-version min`
|
||||||
|
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -target %target-next-stable-abi-triple -library-level api
|
||||||
|
|
||||||
|
|
||||||
// Check that these rules are only applied when requested and that at least some
|
// Check that these rules are only applied when requested and that at least some
|
||||||
// diagnostics are not present without it.
|
// diagnostics are not present without it.
|
||||||
// RUN: not %target-typecheck-verify-swift -swift-version 5 -target %target-next-stable-abi-triple 2>&1 | %FileCheck --check-prefix NON_ABI %s
|
// RUN: not %target-typecheck-verify-swift -swift-version 5 -target %target-next-stable-abi-triple 2>&1 | %FileCheck --check-prefix NON_MIN %s
|
||||||
// NON_ABI: error: expected error not produced
|
|
||||||
// NON_ABI: {'BetweenTargets' is only available in}
|
|
||||||
|
// Check that -target-min-inlining-version overrides -library-level, allowing
|
||||||
|
// library owners to disable this behavior for API libraries if needed.
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
||||||
// Check that we respect -target-min-inlining-version by cranking it up high
|
// Check that we respect -target-min-inlining-version by cranking it up high
|
||||||
// enough to suppress any possible errors.
|
// enough to suppress any possible errors.
|
||||||
// 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
|
// 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
|
||||||
|
|
||||||
|
|
||||||
|
// NON_MIN: error: expected error not produced
|
||||||
|
// NON_MIN: {'BetweenTargets' is only available in}
|
||||||
|
|
||||||
|
|
||||||
/// Declaration with no availability annotation. Should be inferred as minimum
|
/// Declaration with no availability annotation. Should be inferred as minimum
|
||||||
/// inlining target.
|
/// inlining target.
|
||||||
public struct NoAvailable {
|
public struct NoAvailable {
|
||||||
|
|||||||
Reference in New Issue
Block a user