Skip to content

Commit 165ce9c

Browse files
authored
Merge pull request #73717 from apple/elsh/override-flags
Override flags that prevent package-cmo if allow-non-resilient-access is enabled
2 parents 478d8a6 + 84a7c63 commit 165ce9c

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
@@ -1582,6 +1582,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15821582

15831583
static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
15841584
DiagnosticEngine &Diags,
1585+
const LangOptions &LangOpts,
15851586
const FrontendOptions &FrontendOpts) {
15861587
using namespace options;
15871588

@@ -1622,17 +1623,43 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16221623
// Check for SkipFunctionBodies arguments in order from skipping less to
16231624
// skipping more.
16241625
if (Args.hasArg(
1625-
OPT_experimental_skip_non_inlinable_function_bodies_without_types))
1626-
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinableWithoutTypes;
1626+
OPT_experimental_skip_non_inlinable_function_bodies_without_types)) {
1627+
if (LangOpts.AllowNonResilientAccess)
1628+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1629+
"-experimental-skip-non-inlinable-function-bodies-without-types",
1630+
"-experimental-allow-non-resilient-access");
1631+
else
1632+
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinableWithoutTypes;
1633+
}
16271634

16281635
// If asked to perform InstallAPI, go ahead and enable non-inlinable function
16291636
// body skipping.
1630-
if (Args.hasArg(OPT_experimental_skip_non_inlinable_function_bodies) ||
1631-
Args.hasArg(OPT_tbd_is_installapi))
1632-
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1637+
if (Args.hasArg(OPT_experimental_skip_non_inlinable_function_bodies)) {
1638+
if (LangOpts.AllowNonResilientAccess)
1639+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1640+
"-experimental-skip-non-inlinable-function-bodies",
1641+
"-experimental-allow-non-resilient-access");
1642+
else
1643+
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1644+
}
1645+
1646+
if (Args.hasArg(OPT_tbd_is_installapi)) {
1647+
if (LangOpts.AllowNonResilientAccess)
1648+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1649+
"-tbd-is-installapi",
1650+
"-experimental-allow-non-resilient-access");
1651+
else
1652+
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1653+
}
16331654

1634-
if (Args.hasArg(OPT_experimental_skip_all_function_bodies))
1635-
Opts.SkipFunctionBodies = FunctionBodySkipping::All;
1655+
if (Args.hasArg(OPT_experimental_skip_all_function_bodies)) {
1656+
if (LangOpts.AllowNonResilientAccess)
1657+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1658+
"-experimental-skip-all-function-bodies",
1659+
"-experimental-allow-non-resilient-access");
1660+
else
1661+
Opts.SkipFunctionBodies = FunctionBodySkipping::All;
1662+
}
16361663

16371664
if (Opts.SkipFunctionBodies != FunctionBodySkipping::None &&
16381665
FrontendOpts.ModuleName == SWIFT_ONONE_SUPPORT) {
@@ -1704,6 +1731,14 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
17041731
"-enable-library-evolution");
17051732
}
17061733

1734+
if (LangOpts.AllowNonResilientAccess &&
1735+
Opts.EnableLazyTypecheck) {
1736+
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
1737+
"-experimental-lazy-typecheck",
1738+
"-experimental-allow-non-resilient-access");
1739+
Opts.EnableLazyTypecheck = false;
1740+
}
1741+
17071742
// HACK: The driver currently erroneously passes all flags to module interface
17081743
// verification jobs. -experimental-skip-non-exportable-decls is not
17091744
// appropriate for verification tasks and should be ignored, though.
@@ -3429,7 +3464,7 @@ bool CompilerInvocation::parseArgs(
34293464
return true;
34303465
}
34313466

3432-
if (ParseTypeCheckerArgs(TypeCheckerOpts, ParsedArgs, Diags, FrontendOpts)) {
3467+
if (ParseTypeCheckerArgs(TypeCheckerOpts, ParsedArgs, Diags, LangOpts, FrontendOpts)) {
34333468
return true;
34343469
}
34353470

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)