Skip to content

Commit 1533894

Browse files
committed
ModuleInterface: write down the -no-verify flag in the swiftinterface
The flag -no-verify-emitted-module-interface tells the driver to skip verifying the swiftinterfaces emitted by the compiler. It used to be passed only to the driver. Let's pass it down to the frontend as well and write it in the swiftinterfaces. This will help understand them from the reader side.
1 parent d976ea6 commit 1533894

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

include/swift/Option/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ def verify_emitted_module_interface :
599599
HelpText<"Check that module interfaces emitted during compilation typecheck">;
600600
def no_verify_emitted_module_interface :
601601
Flag<["-"], "no-verify-emitted-module-interface">,
602-
Flags<[NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
602+
Flags<[NoInteractiveOption, DoesNotAffectIncrementalBuild,
603+
FrontendOption, ModuleInterfaceOptionIgnorable]>,
603604
HelpText<"Don't check that module interfaces emitted during compilation typecheck">;
604605

605606
def avoid_emit_module_source_info :

lib/Driver/ToolChains.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,14 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
375375

376376
addPluginArguments(inputArgs, arguments);
377377

378+
// Pass along -no-verify-emitted-module-interface only if it's effective.
379+
// Assume verification by default as we want to know only when the user skips
380+
// the verification.
381+
if (!inputArgs.hasFlag(options::OPT_verify_emitted_module_interface,
382+
options::OPT_no_verify_emitted_module_interface,
383+
true))
384+
arguments.push_back("-no-verify-emitted-module-interface");
385+
378386
// Pass through any subsystem flags.
379387
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
380388
inputArgs.AddAllArgs(arguments, options::OPT_Xcc);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %empty-directory(%t)
2+
// REQUIRES: swift-driver-change
3+
4+
/// Check that the flag -no-verify-emitted-module-interface is written down in the swiftinterface.
5+
// RUN: %target-build-swift -emit-library -enable-library-evolution -emit-module-interface -emit-module -swift-version 5 -o %t/NoVerified.o -no-verify-emitted-module-interface -module-name NoVerified %s
6+
// RUN: cat %t/NoVerified.swiftinterface | %FileCheck --check-prefix FLAG %s
7+
// FLAG: swift-module-flags-ignorable:
8+
// FLAG-SAME: -no-verify-emitted-module-interface
9+
10+
/// Check that there's no skip flag in the swiftinterface.
11+
// RUN: %target-build-swift -emit-library -enable-library-evolution -emit-module-interface -emit-module -swift-version 5 -o %t/Verified.o -verify-emitted-module-interface -module-name Verified %s
12+
// RUN: cat %t/Verified.swiftinterface | %FileCheck --check-prefix NO-FLAG %s
13+
// NO-FLAG-NOT: verify-emitted-module-interface
14+
15+
/// Check last flag priority.
16+
// RUN: %target-build-swift -emit-library -enable-library-evolution -emit-module-interface -emit-module -swift-version 5 -o %t/VerifiedManyFlags.o -no-verify-emitted-module-interface -module-name VerifiedManyFlags %s -verify-emitted-module-interface
17+
// RUN: cat %t/VerifiedManyFlags.swiftinterface | %FileCheck --check-prefix NO-FLAG %s
18+
19+
// RUN: %target-build-swift -emit-library -enable-library-evolution -emit-module-interface -emit-module -swift-version 5 -o %t/NoVerifiedManyFlags.o -verify-emitted-module-interface -module-name NoVerifiedManyFlags %s -no-verify-emitted-module-interface
20+
// RUN: cat %t/NoVerifiedManyFlags.swiftinterface | %FileCheck --check-prefix FLAG %s
21+
22+
public struct MyStruct {}

0 commit comments

Comments
 (0)