Skip to content

Commit 84a7c63

Browse files
committed
Override flags that prevent package-cmo if allow-non-resilient-access is enabled
1 parent 295c845 commit 84a7c63

File tree

2 files changed

+110
-10
lines changed

2 files changed

+110
-10
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15761576

15771577
static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
15781578
DiagnosticEngine &Diags,
1579+
const LangOptions &LangOpts,
15791580
const FrontendOptions &FrontendOpts) {
15801581
using namespace options;
15811582

@@ -1616,17 +1617,43 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16161617
// Check for SkipFunctionBodies arguments in order from skipping less to
16171618
// skipping more.
16181619
if (Args.hasArg(
1619-
OPT_experimental_skip_non_inlinable_function_bodies_without_types))
1620-
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinableWithoutTypes;
1620+
OPT_experimental_skip_non_inlinable_function_bodies_without_types)) {
1621+
if (LangOpts.AllowNonResilientAccess)
1622+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1623+
"-experimental-skip-non-inlinable-function-bodies-without-types",
1624+
"-experimental-allow-non-resilient-access");
1625+
else
1626+
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinableWithoutTypes;
1627+
}
16211628

16221629
// If asked to perform InstallAPI, go ahead and enable non-inlinable function
16231630
// body skipping.
1624-
if (Args.hasArg(OPT_experimental_skip_non_inlinable_function_bodies) ||
1625-
Args.hasArg(OPT_tbd_is_installapi))
1626-
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1631+
if (Args.hasArg(OPT_experimental_skip_non_inlinable_function_bodies)) {
1632+
if (LangOpts.AllowNonResilientAccess)
1633+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1634+
"-experimental-skip-non-inlinable-function-bodies",
1635+
"-experimental-allow-non-resilient-access");
1636+
else
1637+
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1638+
}
1639+
1640+
if (Args.hasArg(OPT_tbd_is_installapi)) {
1641+
if (LangOpts.AllowNonResilientAccess)
1642+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1643+
"-tbd-is-installapi",
1644+
"-experimental-allow-non-resilient-access");
1645+
else
1646+
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1647+
}
16271648

1628-
if (Args.hasArg(OPT_experimental_skip_all_function_bodies))
1629-
Opts.SkipFunctionBodies = FunctionBodySkipping::All;
1649+
if (Args.hasArg(OPT_experimental_skip_all_function_bodies)) {
1650+
if (LangOpts.AllowNonResilientAccess)
1651+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1652+
"-experimental-skip-all-function-bodies",
1653+
"-experimental-allow-non-resilient-access");
1654+
else
1655+
Opts.SkipFunctionBodies = FunctionBodySkipping::All;
1656+
}
16301657

16311658
if (Opts.SkipFunctionBodies != FunctionBodySkipping::None &&
16321659
FrontendOpts.ModuleName == SWIFT_ONONE_SUPPORT) {
@@ -1698,6 +1725,14 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16981725
"-enable-library-evolution");
16991726
}
17001727

1728+
if (LangOpts.AllowNonResilientAccess &&
1729+
Opts.EnableLazyTypecheck) {
1730+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1731+
"-experimental-lazy-typecheck",
1732+
"-experimental-allow-non-resilient-access");
1733+
Opts.EnableLazyTypecheck = false;
1734+
}
1735+
17011736
// HACK: The driver currently erroneously passes all flags to module interface
17021737
// verification jobs. -experimental-skip-non-exportable-decls is not
17031738
// appropriate for verification tasks and should be ignored, though.
@@ -3423,7 +3458,7 @@ bool CompilerInvocation::parseArgs(
34233458
return true;
34243459
}
34253460

3426-
if (ParseTypeCheckerArgs(TypeCheckerOpts, ParsedArgs, Diags, FrontendOpts)) {
3461+
if (ParseTypeCheckerArgs(TypeCheckerOpts, ParsedArgs, Diags, LangOpts, FrontendOpts)) {
34273462
return true;
34283463
}
34293464

test/SILGen/package_bypass_resilience.swift

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,73 @@
4343
// RUN: -experimental-skip-non-exportable-decls \
4444
// RUN: -experimental-allow-non-resilient-access \
4545
// RUN: -emit-module -emit-module-path %t/Utils.swiftmodule \
46-
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-EXP
47-
// CHECK-DIAG-EXP: warning: ignoring -experimental-skip-non-exportable-decls (overriden by -experimental-allow-non-resilient-access)
46+
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-1
47+
// CHECK-DIAG-1: warning: ignoring -experimental-skip-non-exportable-decls (overriden by -experimental-allow-non-resilient-access)
48+
// RUN: llvm-bcanalyzer --dump %t/Utils.swiftmodule | %FileCheck %s --check-prefix=CHECK-ON
49+
50+
/// Override -experimental-skip-non-inlinable-function-bodies-without-types with warning
51+
// RUN: rm -rf %t/Utils.swiftmodule
52+
// RUN: %target-swift-frontend %t/Utils.swift \
53+
// RUN: -module-name Utils -swift-version 5 -I %t \
54+
// RUN: -package-name mypkg \
55+
// RUN: -enable-library-evolution \
56+
// RUN: -experimental-skip-non-inlinable-function-bodies-without-types \
57+
// RUN: -experimental-allow-non-resilient-access \
58+
// RUN: -emit-module -emit-module-path %t/Utils.swiftmodule \
59+
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-2
60+
// CHECK-DIAG-2: warning: ignoring -experimental-skip-non-inlinable-function-bodies-without-types (overriden by -experimental-allow-non-resilient-access)
61+
// RUN: llvm-bcanalyzer --dump %t/Utils.swiftmodule | %FileCheck %s --check-prefix=CHECK-ON
62+
63+
/// Override -experimental-skip-non-inlinable-function-bodies with warning
64+
// RUN: rm -rf %t/Utils.swiftmodule
65+
// RUN: %target-swift-frontend %t/Utils.swift \
66+
// RUN: -module-name Utils -swift-version 5 -I %t \
67+
// RUN: -package-name mypkg \
68+
// RUN: -enable-library-evolution \
69+
// RUN: -experimental-skip-non-inlinable-function-bodies \
70+
// RUN: -experimental-allow-non-resilient-access \
71+
// RUN: -emit-module -emit-module-path %t/Utils.swiftmodule \
72+
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-3
73+
// CHECK-DIAG-3: warning: ignoring -experimental-skip-non-inlinable-function-bodies (overriden by -experimental-allow-non-resilient-access)
74+
// RUN: llvm-bcanalyzer --dump %t/Utils.swiftmodule | %FileCheck %s --check-prefix=CHECK-ON
75+
76+
/// Override -experimental-skip-all-function-bodies with warning
77+
// RUN: rm -rf %t/Utils.swiftmodule
78+
// RUN: %target-swift-frontend %t/Utils.swift \
79+
// RUN: -module-name Utils -swift-version 5 -I %t \
80+
// RUN: -package-name mypkg \
81+
// RUN: -enable-library-evolution \
82+
// RUN: -experimental-skip-all-function-bodies \
83+
// RUN: -experimental-allow-non-resilient-access \
84+
// RUN: -emit-module -emit-module-path %t/Utils.swiftmodule \
85+
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-4
86+
// CHECK-DIAG-4: warning: ignoring -experimental-skip-all-function-bodies (overriden by -experimental-allow-non-resilient-access)
87+
// RUN: llvm-bcanalyzer --dump %t/Utils.swiftmodule | %FileCheck %s --check-prefix=CHECK-ON
88+
89+
/// Override -experimental-lazy-typecheck with warning
90+
// RUN: rm -rf %t/Utils.swiftmodule
91+
// RUN: %target-swift-frontend %t/Utils.swift \
92+
// RUN: -module-name Utils -swift-version 5 -I %t \
93+
// RUN: -package-name mypkg \
94+
// RUN: -enable-library-evolution \
95+
// RUN: -experimental-lazy-typecheck \
96+
// RUN: -experimental-allow-non-resilient-access \
97+
// RUN: -emit-module -emit-module-path %t/Utils.swiftmodule \
98+
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-5
99+
// CHECK-DIAG-5: warning: ignoring -experimental-lazy-typecheck (overriden by -experimental-allow-non-resilient-access)
100+
// RUN: llvm-bcanalyzer --dump %t/Utils.swiftmodule | %FileCheck %s --check-prefix=CHECK-ON
101+
102+
/// Override -tbd-is-installapi with warning
103+
// RUN: rm -rf %t/Utils.swiftmodule
104+
// RUN: %target-swift-frontend %t/Utils.swift \
105+
// RUN: -module-name Utils -swift-version 5 -I %t \
106+
// RUN: -package-name mypkg \
107+
// RUN: -enable-library-evolution \
108+
// RUN: -tbd-is-installapi \
109+
// RUN: -experimental-allow-non-resilient-access \
110+
// RUN: -emit-module -emit-module-path %t/Utils.swiftmodule \
111+
// RUN: 2>&1 | %FileCheck %s --check-prefix=CHECK-DIAG-TBD
112+
// CHECK-DIAG-TBD: warning: ignoring -tbd-is-installapi (overriden by -experimental-allow-non-resilient-access)
48113
// RUN: llvm-bcanalyzer --dump %t/Utils.swiftmodule | %FileCheck %s --check-prefix=CHECK-ON
49114

50115
/// Build Utils interface files.

0 commit comments

Comments
 (0)