Skip to content

Commit 2418b54

Browse files
authored
Merge pull request #24095 from jrose-apple/5.1-EARLY-enable-library-evolution
[5.1 EARLY] Rename -enable-resilience to -enable-library-evolution and make it a driver flag
2 parents 4b99272 + 70d0a2f commit 2418b54

File tree

16 files changed

+36
-25
lines changed

16 files changed

+36
-25
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ function(_compile_swift_files
225225
list(APPEND swift_flags "-Xfrontend" "-sil-verify-all")
226226
endif()
227227

228-
# The standard library and overlays are always built with resilience.
228+
# The standard library and overlays are always built resiliently.
229229
if(SWIFTFILE_IS_STDLIB)
230-
list(APPEND swift_flags "-Xfrontend" "-enable-resilience")
230+
list(APPEND swift_flags "-enable-library-evolution")
231231
endif()
232232

233233
if(SWIFT_STDLIB_USE_NONATOMIC_RC)

docs/SIL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3958,7 +3958,7 @@ unless the enum can be exhaustively switched in the current function, i.e. when
39583958
the compiler can be sure that it knows all possible present and future values
39593959
of the enum in question. This is generally true for enums defined in Swift, but
39603960
there are two exceptions: *non-frozen enums* declared in libraries compiled
3961-
with the ``-enable-resilience`` flag, which may grow new cases in the future in
3961+
with the ``-enable-library-evolution`` flag, which may grow new cases in the future in
39623962
an ABI-compatible way; and enums marked with the ``objc`` attribute, for which
39633963
other bit patterns are permitted for compatibility with C. All enums imported
39643964
from C are treated as "non-exhaustive" for the same reason, regardless of the

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ ERROR(indirect_case_without_payload,none,
13051305
ERROR(indirect_case_in_indirect_enum,none,
13061306
"enum case in 'indirect' enum cannot also be 'indirect'", ())
13071307
WARNING(enum_frozen_nonresilient,none,
1308-
"%0 has no effect without -enable-resilience", (DeclAttribute))
1308+
"%0 has no effect without -enable-library-evolution", (DeclAttribute))
13091309
WARNING(enum_frozen_nonpublic,none,
13101310
"%0 has no effect on non-public enums", (DeclAttribute))
13111311

include/swift/AST/Module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum class ResilienceStrategy : unsigned {
117117
/// Public nominal types: resilient
118118
/// Non-inlinable function bodies: resilient
119119
///
120-
/// This is the behavior with -enable-resilience.
120+
/// This is the behavior with -enable-library-evolution.
121121
Resilient
122122
};
123123

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class FrontendOptions {
214214
/// Enables the "fully resilient" resilience strategy.
215215
///
216216
/// \see ResilienceStrategy::Resilient
217-
bool EnableResilience = false;
217+
bool EnableLibraryEvolution = false;
218218

219219
/// Indicates that the frontend should emit "verbose" SIL
220220
/// (if asked to emit SIL).

include/swift/Option/FrontendOptions.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ def disable_objc_attr_requires_foundation_module :
175175
"Foundation module">;
176176

177177
def enable_resilience : Flag<["-"], "enable-resilience">,
178-
HelpText<"Compile the module to export resilient interfaces for all "
179-
"public declarations by default">;
178+
HelpText<"Deprecated, use -enable-library-evolution instead">;
180179

181180
def enable_class_resilience : Flag<["-"], "enable-class-resilience">,
182181
HelpText<"Enable resilient layout for classes containing resilient value types">;

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ def module_cache_path : Separate<["-"], "module-cache-path">,
305305
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,
306306
HelpText<"Specifies the Clang module cache path">;
307307

308+
def enable_library_evolution : Flag<["-"], "enable-library-evolution">,
309+
Flags<[FrontendOption, ParseableInterfaceOption]>,
310+
HelpText<"Build the module to allow binary-compatible library evolution">;
311+
308312
def module_name : Separate<["-"], "module-name">,
309313
Flags<[FrontendOption, ParseableInterfaceOption]>,
310314
HelpText<"Name of the module to build">;

include/swift/Sema/SourceLoader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ class SourceLoader : public ModuleLoader {
2525
private:
2626
ASTContext &Ctx;
2727
bool SkipBodies;
28-
bool EnableResilience;
28+
bool EnableLibraryEvolution;
2929

3030
explicit SourceLoader(ASTContext &ctx,
3131
bool skipBodies,
3232
bool enableResilience,
3333
DependencyTracker *tracker)
3434
: ModuleLoader(tracker), Ctx(ctx),
35-
SkipBodies(skipBodies), EnableResilience(enableResilience) {}
35+
SkipBodies(skipBodies), EnableLibraryEvolution(enableResilience) {}
3636

3737
public:
3838
static std::unique_ptr<SourceLoader>

lib/Driver/ToolChains.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ static void addCommonFrontendArgs(const ToolChain &TC, const OutputInfo &OI,
185185
inputArgs.AddLastArg(arguments, options::OPT_warn_implicit_overrides);
186186
inputArgs.AddLastArg(arguments, options::OPT_typo_correction_limit);
187187
inputArgs.AddLastArg(arguments, options::OPT_enable_app_extension);
188+
inputArgs.AddLastArg(arguments, options::OPT_enable_library_evolution);
188189
inputArgs.AddLastArg(arguments, options::OPT_enable_testing);
189190
inputArgs.AddLastArg(arguments, options::OPT_enable_private_imports);
190191
inputArgs.AddLastArg(arguments, options::OPT_g_Group);

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ bool ArgsToFrontendOptionsConverter::convert(
7171

7272
Opts.EnableTesting |= Args.hasArg(OPT_enable_testing);
7373
Opts.EnablePrivateImports |= Args.hasArg(OPT_enable_private_imports);
74-
Opts.EnableResilience |= Args.hasArg(OPT_enable_resilience);
74+
Opts.EnableLibraryEvolution |= Args.hasArg(OPT_enable_library_evolution);
75+
76+
// FIXME: Remove this flag
77+
Opts.EnableLibraryEvolution |= Args.hasArg(OPT_enable_resilience);
78+
7579
Opts.EnableImplicitDynamic |= Args.hasArg(OPT_enable_implicit_dynamic);
7680

7781
Opts.TrackSystemDeps |= Args.hasArg(OPT_track_system_dependencies);

lib/Frontend/Frontend.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,11 @@ bool CompilerInstance::setUpModuleLoaders() {
286286
if (hasSourceImport()) {
287287
bool immediate = FrontendOptions::isActionImmediate(
288288
Invocation.getFrontendOptions().RequestedAction);
289-
bool enableResilience = Invocation.getFrontendOptions().EnableResilience;
289+
bool enableLibraryEvolution =
290+
Invocation.getFrontendOptions().EnableLibraryEvolution;
290291
Context->addModuleLoader(SourceLoader::create(*Context,
291292
!immediate,
292-
enableResilience,
293+
enableLibraryEvolution,
293294
getDependencyTracker()));
294295
}
295296
auto MLM = ModuleLoadingMode::PreferSerialized;
@@ -528,7 +529,7 @@ ModuleDecl *CompilerInstance::getMainModule() {
528529
if (Invocation.getFrontendOptions().EnableImplicitDynamic)
529530
MainModule->setImplicitDynamicEnabled();
530531

531-
if (Invocation.getFrontendOptions().EnableResilience)
532+
if (Invocation.getFrontendOptions().EnableLibraryEvolution)
532533
MainModule->setResilienceStrategy(ResilienceStrategy::Resilient);
533534
}
534535
return MainModule;

lib/Sema/SourceLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ ModuleDecl *SourceLoader::loadModule(SourceLoc importLoc,
125125
bufferID = Ctx.SourceMgr.addNewSourceBuffer(std::move(inputFile));
126126

127127
auto *importMod = ModuleDecl::create(moduleID.first, Ctx);
128-
if (EnableResilience)
128+
if (EnableLibraryEvolution)
129129
importMod->setResilienceStrategy(ResilienceStrategy::Resilient);
130130
Ctx.LoadedModules[moduleID.first] = importMod;
131131

test/Serialization/attr-invalid.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// CHECK-RESILIENT: Frozen_DECL_ATTR
99
// CHECK-NON-RESILIENT-NOT: Frozen_DECL_ATTR
1010

11-
@_frozen // expected-warning {{@_frozen has no effect without -enable-resilience}}
11+
@_frozen // expected-warning {{@_frozen has no effect without -enable-library-evolution}}
1212
public enum SomeEnum {
1313
case x
1414
}

test/Serialization/resilience.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
// RUN: %empty-directory(%t)
22

3-
// This test checks that we serialize the -enable-resilience and -sil-serialize-all
4-
// flags correctly.
3+
// This test checks that we serialize the -enable-library-evolution
4+
// flag.
55

66
// RUN: %target-swift-frontend -emit-module -o %t %s
77
// RUN: llvm-bcanalyzer -dump %t/resilience.swiftmodule > %t/resilience.dump.txt
88
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=DEFAULT %s < %t/resilience.dump.txt
99

10-
// RUN: %target-swift-frontend -emit-module -o %t -enable-resilience %s
10+
// RUN: %target-swift-frontend -emit-module -o %t -enable-library-evolution %s
1111
// RUN: llvm-bcanalyzer -dump %t/resilience.swiftmodule > %t/resilience2.dump.txt
1212
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=RESILIENCE %s < %t/resilience2.dump.txt
13+
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t/resilience2.dump.txt
1314

14-
// RUN: %target-swift-frontend -emit-module -o %t %s
15-
// RUN: llvm-bcanalyzer -dump %t/resilience.swiftmodule > %t/resilience3.dump.txt
16-
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=FRAGILE %s < %t/resilience3.dump.txt
15+
// FIXME: The alternate -enable-resilience flag is going away soon.
1716

17+
// RUN: %target-swift-frontend -emit-module -o %t -enable-resilience %s
18+
// RUN: llvm-bcanalyzer -dump %t/resilience.swiftmodule > %t/resilience2.dump.txt
19+
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=RESILIENCE %s < %t/resilience2.dump.txt
1820
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t/resilience2.dump.txt
1921

2022
// CHECK: <MODULE_BLOCK {{.*}}>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
@_frozen public enum Exhaustive {} // expected-warning {{@_frozen has no effect without -enable-resilience}} {{1-10=}}
3+
@_frozen public enum Exhaustive {} // expected-warning {{@_frozen has no effect without -enable-library-evolution}} {{1-10=}}
44

5-
@_frozen enum NotPublic {} // expected-warning {{@_frozen has no effect without -enable-resilience}} {{1-10=}}
5+
@_frozen enum NotPublic {} // expected-warning {{@_frozen has no effect without -enable-library-evolution}} {{1-10=}}

tools/sil-opt/SILOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ int main(int argc, char **argv) {
305305
Invocation.setTargetTriple(Target);
306306
if (!ResourceDir.empty())
307307
Invocation.setRuntimeResourcePath(ResourceDir);
308-
Invocation.getFrontendOptions().EnableResilience = EnableResilience;
308+
Invocation.getFrontendOptions().EnableLibraryEvolution = EnableResilience;
309309
// Set the module cache path. If not passed in we use the default swift module
310310
// cache.
311311
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath;

0 commit comments

Comments
 (0)