Skip to content

Commit 3993f03

Browse files
authored
Merge pull request #73906 from tshortli/allow-skip-non-exportable-with-skip-all-function-bodies-6.0
[6.0] Frontend: Lift restrictions on lazy type checking options
2 parents 91a3abc + 15a2d30 commit 3993f03

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,11 +1150,6 @@ def experimental_skip_all_function_bodies:
11501150
Flag<["-"], "experimental-skip-all-function-bodies">,
11511151
HelpText<"Skip type-checking function bodies and all SIL generation">;
11521152

1153-
def experimental_skip_non_inlinable_function_bodies_is_lazy
1154-
: Flag<["-"], "experimental-skip-non-inlinable-function-bodies-is-lazy">,
1155-
HelpText<"Infer lazy typechecking for "
1156-
"-experimental-skip-non-inlinable-function-bodies">;
1157-
11581153
def experimental_allow_module_with_compiler_errors:
11591154
Flag<["-"], "experimental-allow-module-with-compiler-errors">,
11601155
Flags<[HelpHidden]>,

lib/Frontend/CompilerInvocation.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,19 +1159,20 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
11591159

11601160
Opts.EnableSkipExplicitInterfaceModuleBuildRemarks = Args.hasArg(OPT_remark_skip_explicit_interface_build);
11611161

1162-
if (Args.hasArg(OPT_enable_library_evolution)) {
1163-
Opts.SkipNonExportableDecls |=
1164-
Args.hasArg(OPT_experimental_skip_non_exportable_decls);
1165-
1166-
Opts.SkipNonExportableDecls |=
1167-
Args.hasArg(OPT_experimental_skip_non_inlinable_function_bodies) &&
1168-
Args.hasArg(
1169-
OPT_experimental_skip_non_inlinable_function_bodies_is_lazy);
1170-
} else {
1171-
if (Args.hasArg(OPT_experimental_skip_non_exportable_decls))
1162+
if (Args.hasArg(OPT_experimental_skip_non_exportable_decls)) {
1163+
// Only allow -experimental-skip-non-exportable-decls if either library
1164+
// evolution is enabled (in which case the module's ABI is independent of
1165+
// internal declarations) or when -experimental-skip-all-function-bodies is
1166+
// present. The latter implies the module will not be used for code
1167+
// generation, so omitting details needed for ABI should be safe.
1168+
if (Args.hasArg(OPT_enable_library_evolution) ||
1169+
Args.hasArg(OPT_experimental_skip_all_function_bodies)) {
1170+
Opts.SkipNonExportableDecls |= true;
1171+
} else {
11721172
Diags.diagnose(SourceLoc(), diag::ignoring_option_requires_option,
11731173
"-experimental-skip-non-exportable-decls",
11741174
"-enable-library-evolution");
1175+
}
11751176
}
11761177

11771178
Opts.AllowNonResilientAccess =
@@ -1690,23 +1691,18 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16901691
Opts.DebugGenericSignatures |= Args.hasArg(OPT_debug_generic_signatures);
16911692
Opts.DebugInverseRequirements |= Args.hasArg(OPT_debug_inverse_requirements);
16921693

1693-
if (Args.hasArg(OPT_enable_library_evolution)) {
1694-
Opts.EnableLazyTypecheck |= Args.hasArg(OPT_experimental_lazy_typecheck);
1695-
Opts.EnableLazyTypecheck |=
1696-
Args.hasArg(OPT_experimental_skip_non_inlinable_function_bodies) &&
1697-
Args.hasArg(
1698-
OPT_experimental_skip_non_inlinable_function_bodies_is_lazy);
1699-
} else {
1700-
if (Args.hasArg(OPT_experimental_lazy_typecheck))
1694+
if (Args.hasArg(OPT_experimental_lazy_typecheck)) {
1695+
// Same restrictions as -experimental-skip-non-exportable-decls. These
1696+
// could be relaxed in the future, since lazy typechecking is probably not
1697+
// inherently unsafe without these options.
1698+
if (Args.hasArg(OPT_enable_library_evolution) ||
1699+
Args.hasArg(OPT_experimental_skip_all_function_bodies)) {
1700+
Opts.EnableLazyTypecheck |= Args.hasArg(OPT_experimental_lazy_typecheck);
1701+
} else {
17011702
Diags.diagnose(SourceLoc(), diag::ignoring_option_requires_option,
17021703
"-experimental-lazy-typecheck",
17031704
"-enable-library-evolution");
1704-
1705-
if (Args.hasArg(
1706-
OPT_experimental_skip_non_inlinable_function_bodies_is_lazy))
1707-
Diags.diagnose(SourceLoc(), diag::ignoring_option_requires_option,
1708-
"-experimental-skip-non-inlinable-function-bodies-is-lazy",
1709-
"-enable-library-evolution");
1705+
}
17101706
}
17111707

17121708
// HACK: The driver currently erroneously passes all flags to module interface

test/Serialization/lazy-typecheck.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -enable-library-evolution -parse-as-library -package-name Package -DFLAG -emit-module -emit-module-path %t/lazy-skip-all/lazy_typecheck.swiftmodule -debug-forbid-typecheck-prefix NoTypecheck -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-skip-non-exportable-decls
1212
// RUN: %target-swift-frontend -package-name Package -typecheck -verify %S/../Inputs/lazy_typecheck_client.swift -DFLAG -I %t/lazy-skip-all
1313

14+
// (2a) Verify that -experimental-lazy-typecheck and -experimental-skip-non-exportable-decls do not require
15+
// -enable-library-evolution if -experimental-skip-all-function-bodies is specified.
16+
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -parse-as-library -package-name Package -DFLAG -emit-module -emit-module-path %t/lazy-skip-all-non-resilient/lazy_typecheck.swiftmodule -debug-forbid-typecheck-prefix NoTypecheck -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-skip-non-exportable-decls
17+
// RUN: %target-swift-frontend -package-name Package -typecheck -verify %S/../Inputs/lazy_typecheck_client.swift -DFLAG -I %t/lazy-skip-all-non-resilient
18+
1419
// (3) Verify that a module built with -experimental-lazy-typecheck, -experimental-skip-non-inlinable-function-bodies,
1520
// and -experimental-skip-non-exportable-decls can be used by the same client as in (1).
1621
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -enable-library-evolution -parse-as-library -package-name Package -DFLAG -emit-module -emit-module-path %t/lazy-skip-non-inlinable/lazy_typecheck.swiftmodule -debug-forbid-typecheck-prefix NoTypecheck -experimental-lazy-typecheck -experimental-skip-non-inlinable-function-bodies -experimental-skip-non-exportable-decls
1722
// RUN: %target-swift-frontend -package-name Package -typecheck -verify %S/../Inputs/lazy_typecheck_client.swift -DFLAG -I %t/lazy-skip-non-inlinable
18-
19-
// (4) Verify that a module built with -experimental-skip-non-inlinable-function-bodies-is-lazy implies
20-
// -experimental-lazy-typecheck and -experimental-skip-non-exportable-decls.
21-
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -enable-library-evolution -parse-as-library -package-name Package -DFLAG -emit-module -emit-module-path %t/lazy-skip-non-inlinable-is-lazy/lazy_typecheck.swiftmodule -debug-forbid-typecheck-prefix NoTypecheck -experimental-skip-non-inlinable-function-bodies -experimental-skip-non-inlinable-function-bodies-is-lazy
22-
// RUN: %target-swift-frontend -package-name Package -typecheck -verify %S/../Inputs/lazy_typecheck_client.swift -DFLAG -I %t/lazy-skip-non-inlinable-is-lazy

0 commit comments

Comments
 (0)