From c13010c61a0f6909d8cecb701fbf527c71720740 Mon Sep 17 00:00:00 2001 From: Artem Chikin Date: Tue, 16 Aug 2022 09:07:58 -0700 Subject: [PATCH 1/2] Update 'Options.swift' --- Sources/SwiftOptions/Options.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftOptions/Options.swift b/Sources/SwiftOptions/Options.swift index 7c643f3a5..92e03d8cc 100644 --- a/Sources/SwiftOptions/Options.swift +++ b/Sources/SwiftOptions/Options.swift @@ -127,6 +127,7 @@ extension Option { public static let disableDebuggerShadowCopies: Option = Option("-disable-debugger-shadow-copies", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable debugger shadow copies of local variables.This option is only useful for testing the compiler.") public static let disableDeserializationRecovery: Option = Option("-disable-deserialization-recovery", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't attempt to recover from missing xrefs (etc) in swiftmodules") public static let disableDiagnosticPasses: Option = Option("-disable-diagnostic-passes", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't run diagnostic passes") + 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") 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") public static let disableExperimentalOpenedExistentialTypes: Option = Option("-disable-experimental-opened-existential-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable experimental support for implicitly opened existentials") public static let disableExperimentalStringProcessing: Option = Option("-disable-experimental-string-processing", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable experimental string processing") @@ -148,6 +149,7 @@ extension Option { public static let disableMigratorFixits: Option = Option("-disable-migrator-fixits", .flag, attributes: [.frontend, .noInteractive], helpText: "Disable the Migrator phase which automatically applies fix-its") public static let disableModulesValidateSystemHeaders: Option = Option("-disable-modules-validate-system-headers", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable validating system headers in the Clang importer") public static let disableNamedLazyMemberLoading: Option = Option("-disable-named-lazy-member-loading", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable per-name lazy member loading") + public static let disableNewLlvmPassManager: Option = Option("-disable-new-llvm-pass-manager", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the new llvm pass manager") public static let disableNewOperatorLookup: Option = Option("-disable-new-operator-lookup", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the new operator decl and precedencegroup lookup behavior") public static let disableNonfrozenEnumExhaustivityDiagnostics: Option = Option("-disable-nonfrozen-enum-exhaustivity-diagnostics", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Allow switches over non-frozen enums without catch-all cases") public static let disableNskeyedarchiverDiagnostics: Option = Option("-disable-nskeyedarchiver-diagnostics", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Allow classes with unstable mangled names to adopt NSCoding") @@ -172,6 +174,7 @@ extension Option { public static let disableSilOwnershipVerifier: Option = Option("-disable-sil-ownership-verifier", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Do not verify ownership invariants during SIL Verification ") public static let disableSilPartialApply: Option = Option("-disable-sil-partial-apply", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable use of partial_apply in SIL generation") public static let disableSilPerfOptzns: Option = Option("-disable-sil-perf-optzns", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't run SIL performance optimization passes") + public static let disableStackProtector: Option = Option("-disable-stack-protector", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the stack-protector") public static let disableStandardSubstitutionsInReflectionMangling: Option = Option("-disable-standard-substitutions-in-reflection-mangling", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable referencing stdlib symbols via mangled names in reflection mangling") public static let disableSubstSilFunctionTypes: Option = Option("-disable-subst-sil-function-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable substituted function types for SIL type lowering of function values") public static let disableSwiftBridgeAttr: Option = Option("-disable-swift-bridge-attr", .flag, attributes: [.helpHidden, .frontend], helpText: "Disable using the swift bridge attribute") @@ -286,7 +289,6 @@ extension Option { public static let emptyBaseline_: Option = Option("--empty-baseline", .flag, alias: Option.emptyBaseline, attributes: [.noDriver], helpText: "Use empty baseline for diagnostics") public static let enableAccessControl: Option = Option("-enable-access-control", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Respect access control restrictions") public static let enableActorDataRaceChecks: Option = Option("-enable-actor-data-race-checks", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Emit runtime checks for actor data races") - public static let enableAdHocAvailability: Option = Option("-enable-ad-hoc-availability", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental support for ad hoc availability") public static let enableAnonymousContextMangledNames: Option = Option("-enable-anonymous-context-mangled-names", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable emission of mangled names in anonymous context descriptors") public static let enableAstVerifier: Option = Option("-enable-ast-verifier", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Run the AST verifier during compilation. NOTE: This lets the user override the default behavior on whether or not the ASTVerifier is run. The default behavior is to run the verifier when asserts are enabled and not run it when asserts are disabled. NOTE: Can not be used if disable-ast-verifier is used as well") public static let enableBareSlashRegex: Option = Option("-enable-bare-slash-regex", .flag, attributes: [.frontend], helpText: "Enable the use of forward slash regular-expression literal syntax") @@ -300,6 +302,7 @@ extension Option { public static let enableDeserializationRecovery: Option = Option("-enable-deserialization-recovery", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Attempt to recover from missing xrefs (etc) in swiftmodules") public static let enableDestroyHoisting: Option = Option("-enable-destroy-hoisting=", .joined, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "true|false", helpText: "Whether to enable destroy hoisting") public static let enableDynamicReplacementChaining: Option = Option("-enable-dynamic-replacement-chaining", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable chaining of dynamic replacements") + 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") public static let enableExperimentalAdditiveArithmeticDerivation: Option = Option("-enable-experimental-additive-arithmetic-derivation", .flag, attributes: [.frontend], helpText: "Enable experimental 'AdditiveArithmetic' derived conformances") 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") 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") @@ -331,7 +334,7 @@ extension Option { public static let enableLlvmValueNames: Option = Option("-enable-llvm-value-names", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Add names to local values in LLVM IR") public static let enableLlvmVfe: Option = Option("-enable-llvm-vfe", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Use LLVM IR Virtual Function Elimination on Swift class virtual tables") public static let enableLlvmWme: Option = Option("-enable-llvm-wme", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Use LLVM IR Witness Method Elimination on Swift protocol witness tables") - public static let enableNewLlvmPassManager: Option = Option("-enable-new-llvm-pass-manager", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable new llvm pass manager") + public static let enableNewLlvmPassManager: Option = Option("-enable-new-llvm-pass-manager", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable the new llvm pass manager") public static let enableNewOperatorLookup: Option = Option("-enable-new-operator-lookup", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable the new operator decl and precedencegroup lookup behavior") public static let enableNonfrozenEnumExhaustivityDiagnostics: Option = Option("-enable-nonfrozen-enum-exhaustivity-diagnostics", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnose switches over non-frozen enums without catch-all cases") public static let enableNskeyedarchiverDiagnostics: Option = Option("-enable-nskeyedarchiver-diagnostics", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnose classes with unstable mangled names adopting NSCoding") @@ -348,6 +351,7 @@ extension Option { public static let enableSingleModuleLlvmEmission: Option = Option("-enable-single-module-llvm-emission", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Emit LLVM IR into a single LLVM module in multithreaded mode.") public static let enableSourceImport: Option = Option("-enable-source-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable importing of Swift source files") public static let enableSpecDevirt: Option = Option("-enable-spec-devirt", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable speculative devirtualization pass.") + public static let enableStackProtector: Option = Option("-enable-stack-protector", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable the stack protector") public static let enableSwift3ObjcInference: Option = Option("-enable-swift3-objc-inference", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable Swift 3's @objc inference rules for NSObject-derived classes and 'dynamic' members (emulates Swift 3 behavior)") public static let enableTargetOsChecking: Option = Option("-enable-target-os-checking", .flag, attributes: [.frontend, .noDriver], helpText: "Enable checking the target OS of serialized modules") public static let enableTestableAttrRequiresTestableModule: Option = Option("-enable-testable-attr-requires-testable-module", .flag, attributes: [.frontend, .noDriver], helpText: "Enable checking of @testable") @@ -370,6 +374,7 @@ extension Option { public static let experimentalSkipNonInlinableFunctionBodiesWithoutTypes: Option = Option("-experimental-skip-non-inlinable-function-bodies-without-types", .flag, attributes: [.helpHidden, .frontend], helpText: "Skip work on non-inlinable function bodies that do not declare nested types") public static let experimentalSkipNonInlinableFunctionBodies: Option = Option("-experimental-skip-non-inlinable-function-bodies", .flag, attributes: [.helpHidden, .frontend], helpText: "Skip type-checking and SIL generation for non-inlinable function bodies") public static let experimentalSpiImports: Option = Option("-experimental-spi-imports", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental support for SPI imports") + public static let explicitInterfaceModuleBuild: Option = Option("-explicit-interface-module-build", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Use the specified command-line to build the module from interface, instead of flags specified in the interface") public static let explicitSwiftModuleMap: Option = Option("-explicit-swift-module-map-file", .separate, attributes: [.frontend, .noDriver], metaVar: "", helpText: "Specify a JSON file containing information of explicit Swift modules") public static let externalPassPipelineFilename: Option = Option("-external-pass-pipeline-filename", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "", helpText: "Use the pass pipeline defined by ") public static let FEQ: Option = Option("-F=", .joined, alias: Option.F, attributes: [.frontend, .argumentIsPath]) @@ -682,6 +687,7 @@ extension Option { public static let warnSwift3ObjcInferenceMinimal: Option = Option("-warn-swift3-objc-inference-minimal", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Warn about deprecated @objc inference in Swift 3 based on direct uses of the Objective-C entrypoint") public static let warnSwift3ObjcInference: Option = Option("-warn-swift3-objc-inference", .flag, alias: Option.warnSwift3ObjcInferenceComplete, attributes: [.helpHidden, .frontend, .doesNotAffectIncrementalBuild]) public static let warningsAsErrors: Option = Option("-warnings-as-errors", .flag, attributes: [.frontend], helpText: "Treat warnings as errors") + public static let weakLinkAtTarget: Option = Option("-weak-link-at-target", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Weakly link symbols for declarations that were introduced at the deployment target. Symbols introduced before the deployment target are still strongly linked.") public static let wholeModuleOptimization: Option = Option("-whole-module-optimization", .flag, attributes: [.frontend, .noInteractive], helpText: "Optimize input files together instead of individually") public static let wmo: Option = Option("-wmo", .flag, alias: Option.wholeModuleOptimization, attributes: [.helpHidden, .frontend, .noInteractive]) public static let workingDirectoryEQ: Option = Option("-working-directory=", .joined, alias: Option.workingDirectory) @@ -813,6 +819,7 @@ extension Option { Option.disableDebuggerShadowCopies, Option.disableDeserializationRecovery, Option.disableDiagnosticPasses, + Option.disableEmitGenericClassRoTList, Option.disableExperimentalClangImporterDiagnostics, Option.disableExperimentalOpenedExistentialTypes, Option.disableExperimentalStringProcessing, @@ -834,6 +841,7 @@ extension Option { Option.disableMigratorFixits, Option.disableModulesValidateSystemHeaders, Option.disableNamedLazyMemberLoading, + Option.disableNewLlvmPassManager, Option.disableNewOperatorLookup, Option.disableNonfrozenEnumExhaustivityDiagnostics, Option.disableNskeyedarchiverDiagnostics, @@ -858,6 +866,7 @@ extension Option { Option.disableSilOwnershipVerifier, Option.disableSilPartialApply, Option.disableSilPerfOptzns, + Option.disableStackProtector, Option.disableStandardSubstitutionsInReflectionMangling, Option.disableSubstSilFunctionTypes, Option.disableSwiftBridgeAttr, @@ -972,7 +981,6 @@ extension Option { Option.emptyBaseline_, Option.enableAccessControl, Option.enableActorDataRaceChecks, - Option.enableAdHocAvailability, Option.enableAnonymousContextMangledNames, Option.enableAstVerifier, Option.enableBareSlashRegex, @@ -986,6 +994,7 @@ extension Option { Option.enableDeserializationRecovery, Option.enableDestroyHoisting, Option.enableDynamicReplacementChaining, + Option.enableEmitGenericClassRoTList, Option.enableExperimentalAdditiveArithmeticDerivation, Option.enableExperimentalAssociatedTypeInference, Option.enableExperimentalAsyncTopLevel, @@ -1034,6 +1043,7 @@ extension Option { Option.enableSingleModuleLlvmEmission, Option.enableSourceImport, Option.enableSpecDevirt, + Option.enableStackProtector, Option.enableSwift3ObjcInference, Option.enableTargetOsChecking, Option.enableTestableAttrRequiresTestableModule, @@ -1056,6 +1066,7 @@ extension Option { Option.experimentalSkipNonInlinableFunctionBodiesWithoutTypes, Option.experimentalSkipNonInlinableFunctionBodies, Option.experimentalSpiImports, + Option.explicitInterfaceModuleBuild, Option.explicitSwiftModuleMap, Option.externalPassPipelineFilename, Option.FEQ, @@ -1368,6 +1379,7 @@ extension Option { Option.warnSwift3ObjcInferenceMinimal, Option.warnSwift3ObjcInference, Option.warningsAsErrors, + Option.weakLinkAtTarget, Option.wholeModuleOptimization, Option.wmo, Option.workingDirectoryEQ, From 84bc1d7aef605f394babb9dfcbb81db7d2450d12 Mon Sep 17 00:00:00 2001 From: Artem Chikin Date: Tue, 16 Aug 2022 09:57:55 -0700 Subject: [PATCH 2/2] [Explicit Modules] Pass '-explicit-interface-module-build' to interface build jobs. --- Package.resolved | 4 ++-- .../ExplicitDependencyBuildPlanner.swift | 13 ++++++++++++- Sources/SwiftDriver/Jobs/Planning.swift | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index 21bb16e6c..c066541aa 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,7 +15,7 @@ "repositoryURL": "https://github.com/apple/swift-llbuild.git", "state": { "branch": "main", - "revision": "40ee0e2a91d1bd3e37beb83baaea927f86346f1d", + "revision": "efb176d866e3e99855a5b799da224a9f95058f2e", "version": null } }, @@ -33,7 +33,7 @@ "repositoryURL": "https://github.com/apple/swift-tools-support-core.git", "state": { "branch": "main", - "revision": "3f140d7e256f5ec7eaa93a44090fea831da6fb61", + "revision": "0b77e67c484e532444ceeab60119b8536f8cd648", "version": null } }, diff --git a/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift b/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift index 7c684cd6a..9bfde51d2 100644 --- a/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift +++ b/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift @@ -50,14 +50,19 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT /// We avoid re-running the hash computation with the use of this cache private var hashedModuleNameCache: [String: String] = [:] + /// Does this compile support `.explicitInterfaceModuleBuild` + private var supportsExplicitInterfaceBuild: Bool + public init(dependencyGraph: InterModuleDependencyGraph, toolchain: Toolchain, - integratedDriver: Bool = true) throws { + integratedDriver: Bool = true, + supportsExplicitInterfaceBuild: Bool = false) throws { self.dependencyGraph = dependencyGraph self.toolchain = toolchain self.integratedDriver = integratedDriver self.mainModuleName = dependencyGraph.mainModuleName self.reachabilityMap = try dependencyGraph.computeTransitiveClosure() + self.supportsExplicitInterfaceBuild = supportsExplicitInterfaceBuild } /// Generate build jobs for all dependencies of the main module. @@ -165,6 +170,12 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT } } + if supportsExplicitInterfaceBuild { + // Ensure the compiler flags specified in the interface are ignored + // because they are already captured in the dependency scanner output + commandLine.appendFlag(.explicitInterfaceModuleBuild) + } + // Set the output path commandLine.appendFlag(.o) commandLine.appendPath(VirtualPath.lookup(moduleInfo.modulePath.path)) diff --git a/Sources/SwiftDriver/Jobs/Planning.swift b/Sources/SwiftDriver/Jobs/Planning.swift index 39e7aa71b..9a9242f2a 100644 --- a/Sources/SwiftDriver/Jobs/Planning.swift +++ b/Sources/SwiftDriver/Jobs/Planning.swift @@ -626,7 +626,9 @@ extension Driver { explicitDependencyBuildPlanner = try ExplicitDependencyBuildPlanner(dependencyGraph: dependencyGraph, toolchain: toolchain, - integratedDriver: integratedDriver) + integratedDriver: integratedDriver, + supportsExplicitInterfaceBuild: + isFrontendArgSupported(.explicitInterfaceModuleBuild)) return try explicitDependencyBuildPlanner!.generateExplicitModuleDependenciesBuildJobs() }