Skip to content

Commit 844a0f2

Browse files
authored
Merge pull request #1519 from xymus/pass-down-no-verify
Pass down the -no-verify-emitted-module-interface flag to the frontend
2 parents a768642 + caafc82 commit 844a0f2

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ extension Driver {
420420
}
421421
}
422422

423+
// Pass along -no-verify-emitted-module-interface only if it's effective.
424+
// Assume verification by default as we want to know only when the user skips
425+
// the verification.
426+
if !parsedOptions.hasFlag(positive: .verifyEmittedModuleInterface,
427+
negative: .noVerifyEmittedModuleInterface,
428+
default: true) {
429+
commandLine.appendFlag("-no-verify-emitted-module-interface")
430+
}
431+
423432
// Repl Jobs shouldn't include -module-name.
424433
if compilerMode != .repl && compilerMode != .intro {
425434
commandLine.appendFlags("-module-name", moduleOutputInfo.name)

Sources/SwiftOptions/Options.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ extension Option {
171171
public static let disableDeserializationSafety: Option = Option("-disable-deserialization-safety", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't avoid reading potentially unsafe decls in swiftmodules")
172172
public static let disableDiagnosticPasses: Option = Option("-disable-diagnostic-passes", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't run diagnostic passes")
173173
public static let disableEmitGenericClassRoTList: Option = Option("-disable-emit-generic-class-ro_t-list", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable emission of a section with references to class_ro_t of generic class patterns")
174+
public static let disableExperimentalAssociatedTypeInference: Option = Option("-disable-experimental-associated-type-inference", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable experimental associated type inference improvements")
174175
public static let disableExperimentalClangImporterDiagnostics: Option = Option("-disable-experimental-clang-importer-diagnostics", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Disable experimental diagnostics when importing C, C++, and Objective-C libraries")
175176
public static let disableExperimentalOpenedExistentialTypes: Option = Option("-disable-experimental-opened-existential-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable experimental support for implicitly opened existentials")
177+
public static let disableExperimentalParserRoundTrip: Option = Option("-disable-experimental-parser-round-trip", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable round trip through the new swift parser")
176178
public static let disableExperimentalStringProcessing: Option = Option("-disable-experimental-string-processing", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable experimental string processing")
177179
public static let disableFailOnError: Option = Option("-disable-fail-on-error", .flag, attributes: [.noDriver], helpText: "Don't exit with a nonzero status if errors are emitted")
178180
public static let disableFailOnError_: Option = Option("--disable-fail-on-error", .flag, alias: Option.disableFailOnError, attributes: [.noDriver], helpText: "Don't exit with a nonzero status if errors are emitted")
@@ -377,7 +379,7 @@ extension Option {
377379
public static let enableDynamicReplacementChaining: Option = Option("-enable-dynamic-replacement-chaining", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable chaining of dynamic replacements")
378380
public static let enableEmitGenericClassRoTList: Option = Option("-enable-emit-generic-class-ro_t-list", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable emission of a section with references to class_ro_t of generic class patterns")
379381
public static let enableExperimentalAdditiveArithmeticDerivation: Option = Option("-enable-experimental-additive-arithmetic-derivation", .flag, attributes: [.frontend], helpText: "Enable experimental 'AdditiveArithmetic' derived conformances")
380-
public static let enableExperimentalAssociatedTypeInference: Option = Option("-enable-experimental-associated-type-inference", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental associated type inference via type witness systems")
382+
public static let enableExperimentalAssociatedTypeInference: Option = Option("-enable-experimental-associated-type-inference", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental associated type inference improvements")
381383
public static let enableAsyncDemotion: Option = Option("-enable-experimental-async-demotion", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enables an optimization pass to demote async functions.")
382384
public static let enableExperimentalAsyncTopLevel: Option = Option("-enable-experimental-async-top-level", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable experimental concurrency in top-level code")
383385
public static let enableExperimentalConcisePoundFile: Option = Option("-enable-experimental-concise-pound-file", .flag, attributes: [.frontend, .moduleInterface], helpText: "Enable experimental concise '#file' identifier")
@@ -588,6 +590,7 @@ extension Option {
588590
public static let module: Option = Option("-module", .separate, attributes: [.noDriver], metaVar: "<name>", helpText: "Names of modules")
589591
public static let module_: Option = Option("--module", .separate, alias: Option.module, attributes: [.noDriver], metaVar: "<name>", helpText: "Names of modules")
590592
public static let newDriverPath: Option = Option("-new-driver-path", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<path>", helpText: "Path of the new driver to be used")
593+
public static let noAllocations: Option = Option("-no-allocations", .flag, attributes: [.helpHidden, .frontend], helpText: "Diagnose any code that needs to heap allocate (classes, closures, etc.)")
591594
public static let noClangIncludeTree: Option = Option("-no-clang-include-tree", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Do not use clang include tree, fallback to use CAS filesystem to build clang modules")
592595
public static let noClangModuleBreadcrumbs: Option = Option("-no-clang-module-breadcrumbs", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't emit DWARF skeleton CUs for imported Clang modules. Use this when building a redistributable static archive.")
593596
public static let noColorDiagnostics: Option = Option("-no-color-diagnostics", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Do not print diagnostics in color")
@@ -600,15 +603,14 @@ extension Option {
600603
public static let noStdlibRpath: Option = Option("-no-stdlib-rpath", .flag, attributes: [.helpHidden, .doesNotAffectIncrementalBuild], helpText: "Don't add any rpath entries.")
601604
public static let noStrictImplicitModuleContext: Option = Option("-no-strict-implicit-module-context", .flag, attributes: [.helpHidden, .frontend], helpText: "Disable the strict forwarding of compilation context to downstream implicit module dependencies")
602605
public static let noToolchainStdlibRpath: Option = Option("-no-toolchain-stdlib-rpath", .flag, attributes: [.helpHidden, .doesNotAffectIncrementalBuild], helpText: "Do not add an rpath entry for the toolchain's standard library (default)")
603-
public static let noVerifyEmittedModuleInterface: Option = Option("-no-verify-emitted-module-interface", .flag, attributes: [.noInteractive, .doesNotAffectIncrementalBuild], helpText: "Don't check that module interfaces emitted during compilation typecheck")
606+
public static let noVerifyEmittedModuleInterface: Option = Option("-no-verify-emitted-module-interface", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Don't check that module interfaces emitted during compilation typecheck")
604607
public static let noWarningsAsErrors: Option = Option("-no-warnings-as-errors", .flag, attributes: [.frontend], helpText: "Don't treat warnings as errors")
605608
public static let noWholeModuleOptimization: Option = Option("-no-whole-module-optimization", .flag, attributes: [.frontend, .noInteractive], helpText: "Disable optimizing input files together instead of individually")
606609
public static let driverScanDependenciesNonLib: Option = Option("-nonlib-dependency-scanner", .flag, attributes: [.helpHidden], helpText: "Use calls to `swift-frontend -scan-dependencies` instead of dedicated dependency scanning library")
607610
public static let nostartfiles: Option = Option("-nostartfiles", .flag, attributes: [.helpHidden, .frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Do not link in the Swift language startup routines")
608611
public static let nostdimport: Option = Option("-nostdimport", .flag, attributes: [.frontend], helpText: "Don't search the standard library import path for modules")
609612
public static let numThreads: Option = Option("-num-threads", .separate, attributes: [.frontend, .doesNotAffectIncrementalBuild, .cacheInvariant], metaVar: "<n>", helpText: "Enable multi-threading and specify number of threads")
610613
public static let omitExtensionBlockSymbols: Option = Option("-omit-extension-block-symbols", .flag, attributes: [.helpHidden, .frontend, .noInteractive, .supplementaryOutput], helpText: "Directly associate members and conformances with the extended nominal when generating symbol graphs instead of emitting 'swift.extension' symbols for extensions to external types")
611-
public static let extraClangOptionsOnly: Option = Option("-only-use-extra-clang-opts", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Options passed via -Xcc are sufficient for Clang configuration")
612614
public static let Onone: Option = Option("-Onone", .flag, attributes: [.frontend, .moduleInterface], helpText: "Compile without any optimization", group: .O)
613615
public static let Oplayground: Option = Option("-Oplayground", .flag, attributes: [.helpHidden, .frontend, .moduleInterface], helpText: "Compile with optimizations appropriate for a playground", group: .O)
614616
public static let Osize: Option = Option("-Osize", .flag, attributes: [.frontend, .moduleInterface], helpText: "Compile with optimizations and target small code size", group: .O)
@@ -696,7 +698,7 @@ extension Option {
696698
public static let sanitizeAddressUseOdrIndicator: Option = Option("-sanitize-address-use-odr-indicator", .flag, attributes: [.helpHidden, .frontend, .noInteractive], helpText: "When using AddressSanitizer enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size")
697699
public static let sanitizeCoverageEQ: Option = Option("-sanitize-coverage=", .commaJoined, attributes: [.frontend, .noInteractive], metaVar: "<type>", helpText: "Specify the type of coverage instrumentation for Sanitizers and additional options separated by commas")
698700
public static let sanitizeRecoverEQ: Option = Option("-sanitize-recover=", .commaJoined, attributes: [.frontend, .noInteractive], metaVar: "<check>", helpText: "Specify which sanitizer runtime checks (see -sanitize=) will generate instrumentation that allows error recovery. Listed checks should be comma separated. Default behavior is to not allow error recovery.")
699-
public static let sanitizeStableAbiEQ: Option = Option("-sanitize-stable-abi", .flag, attributes: [.frontend, .noInteractive], helpText: "ABI instrumentation for sanitizer runtime.")
701+
public static let sanitizeStableAbiEQ: Option = Option("-sanitize-stable-abi", .flag, attributes: [.frontend, .noInteractive], helpText: "Link against the Sanitizers stable ABI.")
700702
public static let sanitizeEQ: Option = Option("-sanitize=", .commaJoined, attributes: [.frontend, .noInteractive], metaVar: "<check>", helpText: "Turn on runtime checks for erroneous behavior.")
701703
public static let saveOptimizationRecordPasses: Option = Option("-save-optimization-record-passes", .separate, attributes: [.frontend], metaVar: "<regex>", helpText: "Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)")
702704
public static let saveOptimizationRecordPath: Option = Option("-save-optimization-record-path", .separate, attributes: [.frontend, .argumentIsPath], helpText: "Specify the file name of any generated optimization record")
@@ -999,8 +1001,10 @@ extension Option {
9991001
Option.disableDeserializationSafety,
10001002
Option.disableDiagnosticPasses,
10011003
Option.disableEmitGenericClassRoTList,
1004+
Option.disableExperimentalAssociatedTypeInference,
10021005
Option.disableExperimentalClangImporterDiagnostics,
10031006
Option.disableExperimentalOpenedExistentialTypes,
1007+
Option.disableExperimentalParserRoundTrip,
10041008
Option.disableExperimentalStringProcessing,
10051009
Option.disableFailOnError,
10061010
Option.disableFailOnError_,
@@ -1416,6 +1420,7 @@ extension Option {
14161420
Option.module,
14171421
Option.module_,
14181422
Option.newDriverPath,
1423+
Option.noAllocations,
14191424
Option.noClangIncludeTree,
14201425
Option.noClangModuleBreadcrumbs,
14211426
Option.noColorDiagnostics,
@@ -1436,7 +1441,6 @@ extension Option {
14361441
Option.nostdimport,
14371442
Option.numThreads,
14381443
Option.omitExtensionBlockSymbols,
1439-
Option.extraClangOptionsOnly,
14401444
Option.Onone,
14411445
Option.Oplayground,
14421446
Option.Osize,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5590,6 +5590,8 @@ final class SwiftDriverTests: XCTestCase {
55905590
"-no-verify-emitted-module-interface"], env: envVars)
55915591
let plannedJobs = try driver.planBuild()
55925592
XCTAssertEqual(plannedJobs.count, 2)
5593+
let emitJob = try plannedJobs.findJob(.emitModule)
5594+
XCTAssertTrue(emitJob.commandLine.contains("-no-verify-emitted-module-interface"))
55935595
}
55945596

55955597
// Disabled by default in merge-module
@@ -5628,6 +5630,8 @@ final class SwiftDriverTests: XCTestCase {
56285630
XCTAssertTrue(verifyJob.inputs.count == 1)
56295631
XCTAssertTrue(verifyJob.inputs[0] == emitInterfaceOutput[0])
56305632
XCTAssertTrue(verifyJob.commandLine.contains(.path(emitInterfaceOutput[0].file)))
5633+
XCTAssertFalse(emitJob.commandLine.contains("-no-verify-emitted-module-interface"))
5634+
XCTAssertFalse(emitJob.commandLine.contains("-verify-emitted-module-interface"))
56315635
}
56325636

56335637
// Whole-module
@@ -5650,6 +5654,19 @@ final class SwiftDriverTests: XCTestCase {
56505654
XCTAssertTrue(verifyJob.commandLine.contains(.path(emitInterfaceOutput[0].file)))
56515655
}
56525656

5657+
// Test the `-no-verify-emitted-module-interface` flag with whole-module
5658+
do {
5659+
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
5660+
"foo", "-emit-module-interface",
5661+
"-enable-library-evolution",
5662+
"-whole-module-optimization",
5663+
"-no-verify-emitted-module-interface"], env: envVars)
5664+
let plannedJobs = try driver.planBuild()
5665+
XCTAssertEqual(plannedJobs.count, 1)
5666+
let compileJob = try plannedJobs.findJob(.compile)
5667+
XCTAssertTrue(compileJob.commandLine.contains("-no-verify-emitted-module-interface"))
5668+
}
5669+
56535670
// Enabled by default when the library-level is api.
56545671
do {
56555672
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
@@ -5672,6 +5689,8 @@ final class SwiftDriverTests: XCTestCase {
56725689
let plannedJobs = try driver.planBuild()
56735690
XCTAssertEqual(plannedJobs.count, 1)
56745691
XCTAssertEqual(plannedJobs[0].kind, .compile)
5692+
let compileJob = try plannedJobs.findJob(.compile)
5693+
XCTAssertFalse(compileJob.commandLine.contains("-no-verify-emitted-module-interface"))
56755694
}
56765695

56775696
// The flag -check-api-availability-only is not passed down to the verify job.

0 commit comments

Comments
 (0)