Skip to content

[Explicit Module Build] Enable use of '-direct-clang-cc1-module-build' for supporting compilers #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT

/// Does this compile support `.explicitInterfaceModuleBuild`
private var supportsExplicitInterfaceBuild: Bool
/// Does this compile support `.directClangCC1ModuleBuild`
private var supportsDirectClangFrontendPCMBuild: Bool

public init(dependencyGraph: InterModuleDependencyGraph,
toolchain: Toolchain,
integratedDriver: Bool = true,
supportsExplicitInterfaceBuild: Bool = false) throws {
supportsExplicitInterfaceBuild: Bool = false,
supportsDirectClangFrontendPCMBuild: Bool = false) throws {
self.dependencyGraph = dependencyGraph
self.toolchain = toolchain
self.integratedDriver = integratedDriver
self.mainModuleName = dependencyGraph.mainModuleName
self.reachabilityMap = try dependencyGraph.computeTransitiveClosure()
self.supportsExplicitInterfaceBuild = supportsExplicitInterfaceBuild
self.supportsDirectClangFrontendPCMBuild = supportsDirectClangFrontendPCMBuild
}

/// Generate build jobs for all dependencies of the main module.
Expand Down Expand Up @@ -242,6 +246,9 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
outputs.append(TypedVirtualPath(file: targetEncodedModulePath, type: .pcm))
commandLine.appendFlags("-emit-pcm", "-module-name", moduleId.moduleName,
"-o", targetEncodedModulePath.description)
if (supportsDirectClangFrontendPCMBuild) {
commandLine.appendFlag("-direct-clang-cc1-module-build")
}

// Fixup "-o -Xcc -Xclang -Xcc '<replace-me>'"
if let outputIndex = commandLine.firstIndex(of: .flag("<replace-me>")) {
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Jobs/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,9 @@ extension Driver {
toolchain: toolchain,
integratedDriver: integratedDriver,
supportsExplicitInterfaceBuild:
isFrontendArgSupported(.explicitInterfaceModuleBuild))
isFrontendArgSupported(.explicitInterfaceModuleBuild),
supportsDirectClangFrontendPCMBuild:
isFrontendArgSupported(.directClangCc1ModuleBuild))

return try explicitDependencyBuildPlanner!.generateExplicitModuleDependenciesBuildJobs()
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/SwiftOptions/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ extension Option {
public static let diagnosticsEditorMode: Option = Option("-diagnostics-editor-mode", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnostics will be used in editor")
public static let digesterBreakageAllowlistPath: Option = Option("-digester-breakage-allowlist-path", .separate, attributes: [.noInteractive, .argumentIsPath], metaVar: "<path>", helpText: "The path to a list of permitted breaking changes the API digester should ignore")
public static let digesterMode: Option = Option("-digester-mode", .separate, attributes: [.noInteractive], metaVar: "<api|abi>", helpText: "Whether the API digester should run in API or ABI mode (defaults to API checking)")
public static let directClangCc1ModuleBuild: Option = Option("-direct-clang-cc1-module-build", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Use the specified command-line to build a PCM by using Clang frontend directly, bypassing the Clang driver")
public static let disableAccessControl: Option = Option("-disable-access-control", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't respect access control restrictions")
public static let disableActorDataRaceChecks: Option = Option("-disable-actor-data-race-checks", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Disable runtime checks for actor data races")
public static let disableArcOpts: Option = Option("-disable-arc-opts", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't run SIL ARC optimization passes.")
Expand Down Expand Up @@ -328,6 +329,8 @@ extension Option {
public static let enableExperimentalFeature: Option = Option("-enable-experimental-feature", .separate, attributes: [.frontend], helpText: "Enable an experimental feature")
public static let enableExperimentalFlowSensitiveConcurrentCaptures: Option = Option("-enable-experimental-flow-sensitive-concurrent-captures", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable flow-sensitive concurrent captures")
public static let enableExperimentalForwardModeDifferentiation: Option = Option("-enable-experimental-forward-mode-differentiation", .flag, attributes: [.frontend], helpText: "Enable experimental forward mode differentiation")
public static let enableExperimentalImplicitSome: Option = Option("-enable-experimental-implicit-some", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental implicit some")
public static let enableExperimentalLayoutPrespecialization: Option = Option("-enable-experimental-layout-prespecialization", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable experimental support for layout based pre-specializations")
public static let enableExperimentalMoveOnly: Option = Option("-enable-experimental-move-only", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Enable experimental move only")
public static let enableExperimentalNamedOpaqueTypes: Option = Option("-enable-experimental-named-opaque-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental support for named opaque result types")
public static let enableExperimentalOpaqueTypeErasure: Option = Option("-enable-experimental-opaque-type-erasure", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Type-erases opaque types that conform to @_typeEraser protocols")
Expand Down Expand Up @@ -826,6 +829,7 @@ extension Option {
Option.diagnosticsEditorMode,
Option.digesterBreakageAllowlistPath,
Option.digesterMode,
Option.directClangCc1ModuleBuild,
Option.disableAccessControl,
Option.disableActorDataRaceChecks,
Option.disableArcOpts,
Expand Down Expand Up @@ -1047,6 +1051,8 @@ extension Option {
Option.enableExperimentalFeature,
Option.enableExperimentalFlowSensitiveConcurrentCaptures,
Option.enableExperimentalForwardModeDifferentiation,
Option.enableExperimentalImplicitSome,
Option.enableExperimentalLayoutPrespecialization,
Option.enableExperimentalMoveOnly,
Option.enableExperimentalNamedOpaqueTypes,
Option.enableExperimentalOpaqueTypeErasure,
Expand Down