Skip to content

Remove emitSwiftModuleSeparately option #6779

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

Merged
merged 1 commit into from
Aug 7, 2023
Merged
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
137 changes: 0 additions & 137 deletions Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -592,143 +592,6 @@ public final class SwiftTargetBuildDescription {
return result
}

/// Command-line for emitting just the Swift module.
public func emitModuleCommandLine() throws -> [String] {
guard self.buildParameters.emitSwiftModuleSeparately else {
throw InternalError("expecting emitSwiftModuleSeparately in build parameters")
}

var result: [String] = []
result.append(self.buildParameters.toolchain.swiftCompilerPath.pathString)

result.append("-module-name")
result.append(self.target.c99name)
result.append("-emit-module")
result.append("-emit-module-path")
result.append(self.moduleOutputPath.pathString)
result.append(contentsOf: packageNameArgumentIfSupported(with: self.package, packageAccess: self.target.packageAccess))
result += self.buildParameters.toolchain.extraFlags.swiftCompilerFlags

result.append("-Xfrontend")
result.append("-experimental-skip-non-inlinable-function-bodies")
result.append("-force-single-frontend-invocation")

// FIXME: Handle WMO

for source in self.target.sources.paths {
result.append(source.pathString)
}

result.append("-I")
result.append(self.buildParameters.buildPath.pathString)

// FIXME: Maybe refactor these into "common args".
result += try self.buildParameters.targetTripleArgs(for: self.target)
result += ["-swift-version", self.swiftVersion.rawValue]
result += self.optimizationArguments
result += self.testingArguments

result += ["-j\(self.buildParameters.workers)"]
result += self.activeCompilationConditions
result += self.additionalFlags
result += try self.moduleCacheArgs
result += self.stdlibArguments
result += try self.buildSettingsFlags()
result += try self.macroArguments()

// Pass default include paths from the toolchain.
for includeSearchPath in self.buildParameters.toolchain.includeSearchPaths {
result += ["-I", includeSearchPath.pathString]
}

return result
}

/// Command-line for emitting the object files.
///
/// Note: This doesn't emit the module.
public func emitObjectsCommandLine() throws -> [String] {
guard self.buildParameters.emitSwiftModuleSeparately else {
throw InternalError("expecting emitSwiftModuleSeparately in build parameters")
}

var result: [String] = []
result.append(self.buildParameters.toolchain.swiftCompilerPath.pathString)

// pass `-v` during verbose builds.
if self.buildParameters.verboseOutput {
result += ["-v"]
}

result.append("-module-name")
result.append(self.target.c99name)
result.append(contentsOf: packageNameArgumentIfSupported(with: self.package, packageAccess: self.target.packageAccess))
result.append("-incremental")
result.append("-emit-dependencies")

result.append("-output-file-map")
// FIXME: Eliminate side effect.
result.append(try self.writeOutputFileMap().pathString)

// FIXME: Handle WMO

result.append("-c")
for source in self.target.sources.paths {
result.append(source.pathString)
}

result.append("-I")
result.append(self.buildParameters.buildPath.pathString)

result += try self.buildParameters.targetTripleArgs(for: self.target)
result += ["-swift-version", self.swiftVersion.rawValue]

result += self.buildParameters.indexStoreArguments(for: self.target)
result += self.optimizationArguments
result += self.testingArguments

result += ["-j\(self.buildParameters.workers)"]
result += self.activeCompilationConditions
result += self.additionalFlags
result += try self.moduleCacheArgs
result += self.stdlibArguments
result += self.buildParameters.sanitizers.compileSwiftFlags()
result += ["-parseable-output"]
result += try self.buildSettingsFlags()

result += self.buildParameters.toolchain.extraFlags.swiftCompilerFlags
// User arguments (from -Xswiftc) should follow generated arguments to allow user overrides
result += self.buildParameters.flags.swiftCompilerFlags

result += self.buildParameters.toolchain.extraFlags.cCompilerFlags.asSwiftcCCompilerFlags()
// User arguments (from -Xcc) should follow generated arguments to allow user overrides
result += self.buildParameters.flags.cCompilerFlags.asSwiftcCCompilerFlags()

// TODO: Pass -Xcxx flags to swiftc (#6491)
// Uncomment when downstream support arrives.
// result += self.buildParameters.toolchain.extraFlags.cxxCompilerFlags.asSwiftcCXXCompilerFlags()
// // User arguments (from -Xcxx) should follow generated arguments to allow user overrides
// result += self.buildParameters.flags.cxxCompilerFlags.asSwiftcCXXCompilerFlags()

// Enable the correct lto mode if requested.
switch self.buildParameters.linkTimeOptimizationMode {
case nil:
break
case .full:
result += ["-lto=llvm-full"]
case .thin:
result += ["-lto=llvm-thin"]
}

// Pass default include paths from the toolchain.
for includeSearchPath in self.buildParameters.toolchain.includeSearchPaths {
result += ["-I", includeSearchPath.pathString]
}

result += try self.macroArguments()
return result
}

/// Returns true if ObjC compatibility header should be emitted.
private var shouldEmitObjCCompatibilityHeader: Bool {
self.buildParameters.targetTriple.isDarwin() && self.target.type == .library
Expand Down
33 changes: 0 additions & 33 deletions Sources/Build/LLBuildManifestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,6 @@ extension LLBuildManifestBuilder {
objectNodes: objectNodes,
moduleNode: moduleNode
)
} else if self.buildParameters.emitSwiftModuleSeparately {
try self.addSwiftCmdsEmitSwiftModuleSeparately(
target,
inputs: inputs,
objectNodes: objectNodes,
moduleNode: moduleNode
)
} else {
try self.addCmdWithBuiltinSwiftTool(target, inputs: inputs, cmdOutputs: cmdOutputs)
}
Expand Down Expand Up @@ -580,32 +573,6 @@ extension LLBuildManifestBuilder {
)
}

private func addSwiftCmdsEmitSwiftModuleSeparately(
_ target: SwiftTargetBuildDescription,
inputs: [Node],
objectNodes: [Node],
moduleNode: Node
) throws {
// FIXME: We need to ingest the emitted dependencies.

self.manifest.addShellCmd(
name: target.moduleOutputPath.pathString,
description: "Emitting module for \(target.target.name)",
inputs: inputs,
outputs: [moduleNode],
arguments: try target.emitModuleCommandLine()
)

let cmdName = target.target.getCommandName(config: self.buildConfig)
self.manifest.addShellCmd(
name: cmdName,
description: "Compiling module \(target.target.name)",
inputs: inputs,
outputs: objectNodes,
arguments: try target.emitObjectsCommandLine()
)
}

private func addCmdWithBuiltinSwiftTool(
_ target: SwiftTargetBuildDescription,
inputs: [Node],
Expand Down
4 changes: 0 additions & 4 deletions Sources/CoreCommands/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ public struct BuildOptions: ParsableArguments {
@Option(name: .shortAndLong, help: "The number of jobs to spawn in parallel during the build process")
public var jobs: UInt32?

/// Emit the Swift module separately from the object files.
@Flag()
public var emitSwiftModuleSeparately: Bool = false

/// Whether to use the integrated Swift driver rather than shelling out
/// to a separate process.
@Flag()
Expand Down
1 change: 0 additions & 1 deletion Sources/CoreCommands/SwiftTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ public final class SwiftTool {
enableCodeCoverage: false, // set by test commands when appropriate
indexStoreMode: options.build.indexStoreMode.buildParameter,
enableParseableModuleInterfaces: options.build.shouldEnableParseableModuleInterfaces,
emitSwiftModuleSeparately: options.build.emitSwiftModuleSeparately,
useIntegratedSwiftDriver: options.build.useIntegratedSwiftDriver,
useExplicitModuleBuild: options.build.useExplicitModuleBuild,
isXcodeBuildSystemEnabled: options.build.buildSystem == .xcode,
Expand Down
10 changes: 0 additions & 10 deletions Sources/SPMBuildCore/BuildParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ public struct BuildParameters: Encodable {
/// `.swiftmodule`s.
public var enableParseableModuleInterfaces: Bool

/// Emit Swift module separately from object files. This can enable more parallelism
/// since downstream targets can begin compiling without waiting for the entire
/// module to finish building.
public var emitSwiftModuleSeparately: Bool

/// Whether to use the integrated Swift driver rather than shelling out
/// to a separate process.
public var useIntegratedSwiftDriver: Bool
Expand Down Expand Up @@ -292,7 +287,6 @@ public struct BuildParameters: Encodable {
enableCodeCoverage: Bool = false,
indexStoreMode: IndexStoreMode = .auto,
enableParseableModuleInterfaces: Bool = false,
emitSwiftModuleSeparately: Bool = false,
useIntegratedSwiftDriver: Bool = false,
useExplicitModuleBuild: Bool = false,
isXcodeBuildSystemEnabled: Bool = false,
Expand Down Expand Up @@ -325,7 +319,6 @@ public struct BuildParameters: Encodable {
enableCodeCoverage: enableCodeCoverage,
indexStoreMode: indexStoreMode,
enableParseableModuleInterfaces: enableParseableModuleInterfaces,
emitSwiftModuleSeparately: emitSwiftModuleSeparately,
useIntegratedSwiftDriver: useIntegratedSwiftDriver,
useExplicitModuleBuild: useExplicitModuleBuild,
isXcodeBuildSystemEnabled: isXcodeBuildSystemEnabled,
Expand Down Expand Up @@ -360,7 +353,6 @@ public struct BuildParameters: Encodable {
enableCodeCoverage: Bool = false,
indexStoreMode: IndexStoreMode = .auto,
enableParseableModuleInterfaces: Bool = false,
emitSwiftModuleSeparately: Bool = false,
useIntegratedSwiftDriver: Bool = false,
useExplicitModuleBuild: Bool = false,
isXcodeBuildSystemEnabled: Bool = false,
Expand Down Expand Up @@ -422,7 +414,6 @@ public struct BuildParameters: Encodable {
self.enableCodeCoverage = enableCodeCoverage
self.indexStoreMode = indexStoreMode
self.enableParseableModuleInterfaces = enableParseableModuleInterfaces
self.emitSwiftModuleSeparately = emitSwiftModuleSeparately
self.useIntegratedSwiftDriver = useIntegratedSwiftDriver
self.useExplicitModuleBuild = useExplicitModuleBuild
self.isXcodeBuildSystemEnabled = isXcodeBuildSystemEnabled
Expand Down Expand Up @@ -482,7 +473,6 @@ public struct BuildParameters: Encodable {
enableCodeCoverage: self.enableCodeCoverage,
indexStoreMode: self.indexStoreMode,
enableParseableModuleInterfaces: self.enableParseableModuleInterfaces,
emitSwiftModuleSeparately: self.emitSwiftModuleSeparately,
useIntegratedSwiftDriver: self.useIntegratedSwiftDriver,
useExplicitModuleBuild: self.useExplicitModuleBuild,
isXcodeBuildSystemEnabled: self.isXcodeBuildSystemEnabled,
Expand Down