Skip to content

Commit 022df1d

Browse files
authored
Merge pull request #520 from CodaFi/across-the-universe
Re-Sync Options Flags
2 parents 60707ab + c7d8705 commit 022df1d

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

Sources/SwiftDriver/IncrementalCompilation/DependencyKey.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,8 @@ public struct DependencyKey: Hashable, CustomStringConvertible {
168168
/// The `name` of the file is a path to the `swiftdeps` file named in
169169
/// the output file map for a given Swift file.
170170
///
171-
/// If the filename is a swiftmodule, and if it was built by a compilation with
172-
/// `-enable-experimental-cross-module-incremental-build`, the swiftmodule file
173-
/// contains a special section with swiftdeps information for the module
174-
/// in it. In that case the enclosing node should have a fingerprint.
175-
///
176-
171+
/// Swiftmodule files may contain a special section with swiftdeps information
172+
/// for the module. In that case the enclosing node should have a fingerprint.
177173
case sourceFileProvide(name: String)
178174
/// A "nominal" type that is used, or defined by this file.
179175
///

Sources/SwiftDriver/Jobs/MergeModuleJob.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ extension Driver {
6161
try commandLine.appendLast(.emitSymbolGraph, from: &parsedOptions)
6262
try commandLine.appendLast(.emitSymbolGraphDir, from: &parsedOptions)
6363

64-
// Propagate cross-module incremental builds flag so dependency information
65-
// shows up in swiftmodules.
66-
try commandLine.appendLast(.enableExperimentalCrossModuleIncrementalBuild, from: &parsedOptions)
64+
// Propagate the disable flag for cross-module incremental builds
65+
// if necessary. Note because we're interested in *disabling* this feature,
66+
// we consider the disable form to be the positive and enable to be the
67+
// negative.
68+
if parsedOptions.hasFlag(positive: .disableIncrementalImports,
69+
negative: .enableIncrementalImports,
70+
default: false) {
71+
try commandLine.appendLast(.disableIncrementalImports, from: &parsedOptions)
72+
}
6773

6874
commandLine.appendFlag(.o)
6975
commandLine.appendPath(moduleOutputInfo.output!.outputPath)

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ extension Driver {
152152
if self.parsedOptions.contains(veriOpt) {
153153
options.formUnion(.verifyDependencyGraphAfterEveryImport)
154154
}
155-
if self.parsedOptions.contains(.enableExperimentalCrossModuleIncrementalBuild) {
155+
if self.parsedOptions.hasFlag(positive: .enableIncrementalImports,
156+
negative: .disableIncrementalImports,
157+
default: true) {
156158
options.formUnion(.enableCrossModuleIncrementalBuild)
157159
options.formUnion(.readPriorsFromModuleDependencyGraph)
158160
}

Sources/SwiftOptions/Options.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extension Option {
8787
public static let disableGenericMetadataPrespecialization: Option = Option("-disable-generic-metadata-prespecialization", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Do not statically specialize metadata for generic types at types that are known to be used in source.")
8888
public static let disableImplicitConcurrencyModuleImport: Option = Option("-disable-implicit-concurrency-module-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the implicit import of the _Concurrency module.")
8989
public static let disableImplicitSwiftModules: Option = Option("-disable-implicit-swift-modules", .flag, attributes: [.frontend, .noDriver], helpText: "Disable building Swift modules implicitly by the compiler")
90+
public static let disableIncrementalImports: Option = Option("-disable-incremental-imports", .flag, attributes: [.frontend], helpText: "Disable cross-module incremental build metadata and driver scheduling for Swift modules")
9091
public static let disableIncrementalLlvmCodegeneration: Option = Option("-disable-incremental-llvm-codegen", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable incremental llvm code generation.")
9192
public static let disableInterfaceLockfile: Option = Option("-disable-interface-lock", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't lock interface file when building module")
9293
public static let disableInvalidEphemeralnessAsError: Option = Option("-disable-invalid-ephemeralness-as-error", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnose invalid ephemeral to non-ephemeral conversions as warnings")
@@ -109,7 +110,6 @@ extension Option {
109110
public static let disablePreviousImplementationCallsInDynamicReplacements: Option = Option("-disable-previous-implementation-calls-in-dynamic-replacements", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable calling the previous implementation in dynamic replacements")
110111
public static let disableReflectionMetadata: Option = Option("-disable-reflection-metadata", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable emission of reflection metadata for nominal types")
111112
public static let disableReflectionNames: Option = Option("-disable-reflection-names", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable emission of names of stored properties and enum cases inreflection metadata")
112-
public static let disableRequestBasedIncrementalDependencies: Option = Option("-disable-request-based-incremental-dependencies", .flag, attributes: [.frontend], helpText: "Disable request-based name tracking")
113113
public static let disableSilOwnershipVerifier: Option = Option("-disable-sil-ownership-verifier", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Do not verify ownership invariants during SIL Verification ")
114114
public static let disableSilPartialApply: Option = Option("-disable-sil-partial-apply", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable use of partial_apply in SIL generation")
115115
public static let disableSilPerfOptzns: Option = Option("-disable-sil-perf-optzns", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't run SIL performance optimization passes")
@@ -223,14 +223,15 @@ extension Option {
223223
public static let enableExperimentalAdditiveArithmeticDerivation: Option = Option("-enable-experimental-additive-arithmetic-derivation", .flag, attributes: [.frontend], helpText: "Enable experimental 'AdditiveArithmetic' derived conformances")
224224
public static let enableExperimentalConcisePoundFile: Option = Option("-enable-experimental-concise-pound-file", .flag, attributes: [.frontend, .moduleInterface], helpText: "Enable experimental concise '#file' identifier")
225225
public static let enableExperimentalConcurrency: Option = Option("-enable-experimental-concurrency", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable experimental concurrency model")
226-
public static let enableExperimentalConcurrentValueChecking: Option = Option("-enable-experimental-concurrent-value-checking", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable ConcurrentValue checking")
227226
public static let enableExperimentalCrossModuleIncrementalBuild: Option = Option("-enable-experimental-cross-module-incremental-build", .flag, attributes: [.frontend], helpText: "(experimental) Enable cross-module incremental build metadata and driver scheduling")
228227
public static let enableExperimentalCxxInterop: Option = Option("-enable-experimental-cxx-interop", .flag, helpText: "Allow importing C++ modules into Swift (experimental feature)")
228+
public static let enableExperimentalEnumCodableDerivation: Option = Option("-enable-experimental-enum-codable-derivation", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable experimental derivation of Codable for enums")
229229
public static let enableExperimentalFlowSensitiveConcurrentCaptures: Option = Option("-enable-experimental-flow-sensitive-concurrent-captures", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable flow-sensitive concurrent captures")
230230
public static let enableExperimentalForwardModeDifferentiation: Option = Option("-enable-experimental-forward-mode-differentiation", .flag, attributes: [.frontend], helpText: "Enable experimental forward mode differentiation")
231231
public static let enableExperimentalStaticAssert: Option = Option("-enable-experimental-static-assert", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental #assert")
232232
public static let enableFuzzyForwardScanTrailingClosureMatching: Option = Option("-enable-fuzzy-forward-scan-trailing-closure-matching", .flag, attributes: [.frontend], helpText: "Enable fuzzy forward-scan trailing closure matching")
233233
public static let enableImplicitDynamic: Option = Option("-enable-implicit-dynamic", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Add 'dynamic' to all declarations")
234+
public static let enableIncrementalImports: Option = Option("-enable-incremental-imports", .flag, attributes: [.frontend], helpText: "Enable cross-module incremental build metadata and driver scheduling for Swift modules")
234235
public static let enableInferImportAsMember: Option = Option("-enable-infer-import-as-member", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Infer when a global could be imported as a member")
235236
public static let enableInvalidEphemeralnessAsError: Option = Option("-enable-invalid-ephemeralness-as-error", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnose invalid ephemeral to non-ephemeral conversions as errors")
236237
public static let enableLibraryEvolution: Option = Option("-enable-library-evolution", .flag, attributes: [.frontend, .moduleInterface], helpText: "Build the module to allow binary-compatible library evolution")
@@ -242,8 +243,8 @@ extension Option {
242243
public static let enableObjcInterop: Option = Option("-enable-objc-interop", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable Objective-C interop code generation and config directives")
243244
public static let enableOnlyOneDependencyFile: Option = Option("-enable-only-one-dependency-file", .flag, attributes: [.doesNotAffectIncrementalBuild], helpText: "Enables incremental build optimization that only produces one dependencies file")
244245
public static let enableOperatorDesignatedTypes: Option = Option("-enable-operator-designated-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable operator designated types")
246+
public static let enableOssaModules: Option = Option("-enable-ossa-modules", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Always serialize SIL in ossa form. If this flag is not passed in, when optimizing ownership will be lowered before serializing SIL")
245247
public static let enablePrivateImports: Option = Option("-enable-private-imports", .flag, attributes: [.helpHidden, .frontend, .noInteractive], helpText: "Allows this module's internal and private API to be accessed")
246-
public static let enableRequestBasedIncrementalDependencies: Option = Option("-enable-request-based-incremental-dependencies", .flag, attributes: [.frontend], helpText: "Enable request-based name tracking")
247248
public static let enableResilience: Option = Option("-enable-resilience", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Deprecated, use -enable-library-evolution instead")
248249
public static let enableSilOpaqueValues: Option = Option("-enable-sil-opaque-values", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable SIL Opaque Values")
249250
public static let enableSourceImport: Option = Option("-enable-source-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable importing of Swift source files")
@@ -590,6 +591,7 @@ extension Option {
590591
Option.disableGenericMetadataPrespecialization,
591592
Option.disableImplicitConcurrencyModuleImport,
592593
Option.disableImplicitSwiftModules,
594+
Option.disableIncrementalImports,
593595
Option.disableIncrementalLlvmCodegeneration,
594596
Option.disableInterfaceLockfile,
595597
Option.disableInvalidEphemeralnessAsError,
@@ -612,7 +614,6 @@ extension Option {
612614
Option.disablePreviousImplementationCallsInDynamicReplacements,
613615
Option.disableReflectionMetadata,
614616
Option.disableReflectionNames,
615-
Option.disableRequestBasedIncrementalDependencies,
616617
Option.disableSilOwnershipVerifier,
617618
Option.disableSilPartialApply,
618619
Option.disableSilPerfOptzns,
@@ -726,14 +727,15 @@ extension Option {
726727
Option.enableExperimentalAdditiveArithmeticDerivation,
727728
Option.enableExperimentalConcisePoundFile,
728729
Option.enableExperimentalConcurrency,
729-
Option.enableExperimentalConcurrentValueChecking,
730730
Option.enableExperimentalCrossModuleIncrementalBuild,
731731
Option.enableExperimentalCxxInterop,
732+
Option.enableExperimentalEnumCodableDerivation,
732733
Option.enableExperimentalFlowSensitiveConcurrentCaptures,
733734
Option.enableExperimentalForwardModeDifferentiation,
734735
Option.enableExperimentalStaticAssert,
735736
Option.enableFuzzyForwardScanTrailingClosureMatching,
736737
Option.enableImplicitDynamic,
738+
Option.enableIncrementalImports,
737739
Option.enableInferImportAsMember,
738740
Option.enableInvalidEphemeralnessAsError,
739741
Option.enableLibraryEvolution,
@@ -745,8 +747,8 @@ extension Option {
745747
Option.enableObjcInterop,
746748
Option.enableOnlyOneDependencyFile,
747749
Option.enableOperatorDesignatedTypes,
750+
Option.enableOssaModules,
748751
Option.enablePrivateImports,
749-
Option.enableRequestBasedIncrementalDependencies,
750752
Option.enableResilience,
751753
Option.enableSilOpaqueValues,
752754
Option.enableSourceImport,

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ extension IncrementalCompilationTests {
458458
(.driverShowIncremental, {$0.reporter != nil}),
459459
(.driverEmitFineGrainedDependencyDotFileAfterEveryImport, {$0.emitDependencyDotFileAfterEveryImport}),
460460
(.driverVerifyFineGrainedDependencyGraphAfterEveryImport, {$0.verifyDependencyGraphAfterEveryImport}),
461-
(.enableExperimentalCrossModuleIncrementalBuild, {$0.isCrossModuleIncrementalBuildEnabled}),
461+
(.enableIncrementalImports, {$0.isCrossModuleIncrementalBuildEnabled}),
462+
(.disableIncrementalImports, {!$0.isCrossModuleIncrementalBuildEnabled}),
462463
]
463464

464465
for (driverOption, stateOptionFn) in optionPairs {
@@ -516,12 +517,10 @@ extension IncrementalCompilationTests {
516517
expectNoDotFiles()
517518
try tryInitial(extraArguments: [
518519
"-driver-emit-fine-grained-dependency-dot-file-after-every-import",
519-
"-enable-experimental-cross-module-incremental-build"
520520
])
521521
removeDotFiles()
522522
tryTouchingOther(extraArguments: [
523523
"-driver-emit-fine-grained-dependency-dot-file-after-every-import",
524-
"-enable-experimental-cross-module-incremental-build"
525524
])
526525

527526
expect(dotFilesFor: [
@@ -594,7 +593,7 @@ extension IncrementalCompilationTests {
594593
// Leave off the part after the colon because it varies on Linux:
595594
// MacOS: The operation could not be completed. (TSCBasic.FileSystemError error 3.).
596595
// Linux: The operation couldn’t be completed. (TSCBasic.FileSystemError error 3.)
597-
"Disabling incremental cross-module building",
596+
"Enabling incremental cross-module building",
598597
"Incremental compilation: Incremental compilation could not read build record at",
599598
"Incremental compilation: Disabling incremental build: could not read build record",
600599
"Incremental compilation: Created dependency graph from swiftdeps files",
@@ -618,8 +617,8 @@ extension IncrementalCompilationTests {
618617
checkDiagnostics: checkDiagnostics,
619618
extraArguments: extraArguments,
620619
expectingRemarks: [
621-
"Disabling incremental cross-module building",
622-
"Incremental compilation: Created dependency graph from swiftdeps files",
620+
"Enabling incremental cross-module building",
621+
"Incremental compilation: Read dependency graph",
623622
"Incremental compilation: May skip current input: {compile: main.o <= main.swift}",
624623
"Incremental compilation: May skip current input: {compile: other.o <= other.swift}",
625624
"Incremental compilation: Skipping input: {compile: main.o <= main.swift}",
@@ -638,13 +637,13 @@ extension IncrementalCompilationTests {
638637
checkDiagnostics: checkDiagnostics,
639638
extraArguments: extraArguments,
640639
expectingRemarks: [
641-
"Disabling incremental cross-module building",
642-
"Incremental compilation: Created dependency graph from swiftdeps files",
640+
"Enabling incremental cross-module building",
643641
"Incremental compilation: May skip current input: {compile: main.o <= main.swift}",
644642
"Incremental compilation: Scheduing changed input {compile: other.o <= other.swift}",
645643
"Incremental compilation: Queuing (initial): {compile: other.o <= other.swift}",
646644
"Incremental compilation: not scheduling dependents of other.swift; unknown changes",
647645
"Incremental compilation: Skipping input: {compile: main.o <= main.swift}",
646+
"Incremental compilation: Read dependency graph",
648647
"Found 1 batchable job",
649648
"Forming into 1 batch",
650649
"Adding {compile: other.swift} to batch 0",
@@ -667,8 +666,8 @@ extension IncrementalCompilationTests {
667666
checkDiagnostics: checkDiagnostics,
668667
extraArguments: extraArguments,
669668
expectingRemarks: [
670-
"Disabling incremental cross-module building",
671-
"Incremental compilation: Created dependency graph from swiftdeps files",
669+
"Enabling incremental cross-module building",
670+
"Incremental compilation: Read dependency graph",
672671
"Incremental compilation: Scheduing changed input {compile: main.o <= main.swift}",
673672
"Incremental compilation: Scheduing changed input {compile: other.o <= other.swift}",
674673
"Incremental compilation: Queuing (initial): {compile: main.o <= main.swift}",
@@ -697,8 +696,8 @@ extension IncrementalCompilationTests {
697696
checkDiagnostics: checkDiagnostics,
698697
extraArguments: extraArguments,
699698
expectingRemarks: [
700-
"Disabling incremental cross-module building",
701-
"Incremental compilation: Created dependency graph from swiftdeps files",
699+
"Enabling incremental cross-module building",
700+
"Incremental compilation: Read dependency graph",
702701
"Incremental compilation: Scheduing changed input {compile: main.o <= main.swift}",
703702
"Incremental compilation: May skip current input: {compile: other.o <= other.swift}",
704703
"Incremental compilation: Queuing (initial): {compile: main.o <= main.swift}",
@@ -737,8 +736,8 @@ extension IncrementalCompilationTests {
737736
checkDiagnostics: checkDiagnostics,
738737
extraArguments: [extraArgument],
739738
expectingRemarks: [
740-
"Disabling incremental cross-module building",
741-
"Incremental compilation: Created dependency graph from swiftdeps files",
739+
"Enabling incremental cross-module building",
740+
"Incremental compilation: Read dependency graph",
742741
"Incremental compilation: May skip current input: {compile: other.o <= other.swift}",
743742
"Incremental compilation: Queuing (initial): {compile: main.o <= main.swift}",
744743
"Incremental compilation: scheduling dependents of main.swift; -driver-always-rebuild-dependents",
@@ -845,7 +844,6 @@ class CrossModuleIncrementalBuildTests: XCTestCase {
845844
"-emit-module",
846845
"-output-file-map", ofm.pathString,
847846
"-module-name", "MagicKit",
848-
"-enable-experimental-cross-module-incremental-build",
849847
"-working-directory", path.pathString,
850848
"-c",
851849
magic.pathString,
@@ -871,7 +869,6 @@ class CrossModuleIncrementalBuildTests: XCTestCase {
871869
"-emit-module",
872870
"-output-file-map", ofm.pathString,
873871
"-module-name", "theModule",
874-
"-enable-experimental-cross-module-incremental-build",
875872
"-I", path.pathString,
876873
"-working-directory", path.pathString,
877874
"-c",

0 commit comments

Comments
 (0)