Skip to content

Commit cbc4e44

Browse files
authored
Merge pull request #60340 from tshortli/weak-link-at-target
Frontend: Rename -enable-ad-hoc-availability to -weak-link-at-target
2 parents a436f98 + 34012db commit cbc4e44

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ namespace swift {
170170
/// Only check the availability of the API, ignore function bodies.
171171
bool CheckAPIAvailabilityOnly = false;
172172

173-
/// Causes the compiler to treat declarations available at the current
174-
/// runtime OS version as potentially unavailable.
175-
bool EnableAdHocAvailability = false;
173+
/// Causes the compiler to use weak linkage for symbols belonging to
174+
/// declarations introduced at the deployment target.
175+
bool WeakLinkAtTarget = false;
176176

177177
/// Should conformance availability violations be diagnosed as errors?
178178
bool EnableConformanceAvailabilityErrors = false;

include/swift/Option/FrontendOptions.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,11 @@ def clang_header_expose_public_decls:
10651065
HelpText<"Expose all public declarations in the generated clang header">,
10661066
Flags<[FrontendOption, HelpHidden]>;
10671067

1068-
def enable_ad_hoc_availability :
1069-
Flag<["-"], "enable-ad-hoc-availability">,
1070-
HelpText<"Enable experimental support for ad hoc availability">;
1068+
def weak_link_at_target :
1069+
Flag<["-"], "weak-link-at-target">,
1070+
HelpText<"Weakly link symbols for declarations that were introduced at the "
1071+
"deployment target. Symbols introduced before the deployment "
1072+
"target are still strongly linked.">;
10711073

10721074
def concurrency_model :
10731075
Separate<["-"], "concurrency-model">,

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ bool Decl::isWeakImported(ModuleDecl *fromModule) const {
10091009
auto &ctx = fromModule->getASTContext();
10101010
auto deploymentTarget = AvailabilityContext::forDeploymentTarget(ctx);
10111011

1012-
if (ctx.LangOpts.EnableAdHocAvailability)
1012+
if (ctx.LangOpts.WeakLinkAtTarget)
10131013
return !availability.isSupersetOf(deploymentTarget);
10141014

10151015
return !deploymentTarget.isContainedIn(availability);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
497497
Args.hasArg(OPT_disable_availability_checking);
498498
Opts.CheckAPIAvailabilityOnly |=
499499
Args.hasArg(OPT_check_api_availability_only);
500-
Opts.EnableAdHocAvailability |=
501-
Args.hasArg(OPT_enable_ad_hoc_availability);
500+
Opts.WeakLinkAtTarget |= Args.hasArg(OPT_weak_link_at_target);
502501

503502
if (auto A = Args.getLastArg(OPT_enable_conformance_availability_errors,
504503
OPT_disable_conformance_availability_errors)) {

lib/SIL/IR/SILFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ bool SILFunction::isWeakImported() const {
480480
auto deploymentTarget =
481481
AvailabilityContext::forDeploymentTarget(getASTContext());
482482

483-
if (getASTContext().LangOpts.EnableAdHocAvailability)
483+
if (getASTContext().LangOpts.WeakLinkAtTarget)
484484
return !Availability.isSupersetOf(deploymentTarget);
485485

486486
return !deploymentTarget.isContainedIn(Availability);

test/IRGen/weak_import_availability.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.50 | %FileCheck %s --check-prefix=CHECK-NEW
66
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.60 | %FileCheck %s --check-prefix=CHECK-NEW
77

8-
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.50 -enable-ad-hoc-availability | %FileCheck %s --check-prefix=CHECK-OLD
9-
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.60 -enable-ad-hoc-availability | %FileCheck %s --check-prefix=CHECK-NEW
8+
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.50 -weak-link-at-target | %FileCheck %s --check-prefix=CHECK-OLD
9+
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.60 -weak-link-at-target | %FileCheck %s --check-prefix=CHECK-NEW
1010

1111
// REQUIRES: OS=macosx
1212

0 commit comments

Comments
 (0)