Skip to content

Deprecate -embed-bitcode functionality #1793

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
Feb 4, 2025
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
1 change: 0 additions & 1 deletion Sources/SwiftDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ add_library(SwiftDriver

Jobs/APIDigesterJobs.swift
Jobs/AutolinkExtractJob.swift
Jobs/BackendJob.swift
Jobs/CommandLineArguments.swift
Jobs/CompileJob.swift
Jobs/DarwinToolchain+LinkerSupport.swift
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2424,8 +2424,8 @@ extension Driver {
linkerOutputType = .executable
}

// warn if -embed-bitcode is set and the output type is not an object
if parsedOptions.hasArgument(.embedBitcode) && compilerOutputType != .object {
// warn if -embed-bitcode is set
if parsedOptions.hasArgument(.embedBitcode) {
diagnosticsEngine.emit(.warn_ignore_embed_bitcode)
parsedOptions.eraseArgument(.embedBitcode)
}
Expand All @@ -2449,7 +2449,7 @@ extension Diagnostic.Message {
}

static var warn_ignore_embed_bitcode: Diagnostic.Message {
.warning("ignoring -embed-bitcode since no object file is being generated")
.warning("'-embed-bitcode' has been deprecated")
}

static var warn_ignore_embed_bitcode_marker: Diagnostic.Message {
Expand Down
44 changes: 22 additions & 22 deletions Sources/SwiftDriver/IncrementalCompilation/FirstWaveComputer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ extension IncrementalCompilationState {

public func compute(batchJobFormer: inout Driver) throws -> FirstWave {
return try blockingConcurrentAccessOrMutation {
let (initiallySkippedCompileGroups, mandatoryJobsInOrder) =
let (initiallySkippedCompileJobs, mandatoryJobsInOrder) =
try computeInputsAndGroups(batchJobFormer: &batchJobFormer)
return FirstWave(
initiallySkippedCompileGroups: initiallySkippedCompileGroups,
initiallySkippedCompileJobs: initiallySkippedCompileJobs,
mandatoryJobsInOrder: mandatoryJobsInOrder)
}
}
Expand All @@ -76,33 +76,33 @@ extension IncrementalCompilationState.FirstWaveComputer {
/// At this stage the graph will have all external dependencies found in the swiftDeps or in the priors
/// listed in fingerprintExternalDependencies.
private func computeInputsAndGroups(batchJobFormer: inout Driver)
throws -> (initiallySkippedCompileGroups: [TypedVirtualPath: CompileJobGroup],
throws -> (initiallySkippedCompileJobs: [TypedVirtualPath: Job],
mandatoryJobsInOrder: [Job])
{
let compileGroups =
let compileJobs =
Dictionary(uniqueKeysWithValues:
jobsInPhases.compileGroups.map { ($0.primaryInput, $0) })
jobsInPhases.compileJobs.map { ($0.primaryInputs[0], $0) })
let buildRecord = self.moduleDependencyGraph.buildRecord
let jobCreatingPch = jobsInPhases.beforeCompiles.first(where: {$0.kind == .generatePCH})
guard !buildRecord.inputInfos.isEmpty else {
func everythingIsMandatory()
throws -> (initiallySkippedCompileGroups: [TypedVirtualPath: CompileJobGroup],
throws -> (initiallySkippedCompileJobs: [TypedVirtualPath: Job],
mandatoryJobsInOrder: [Job])
{
let mandatoryCompileGroupsInOrder = self.inputFiles.swiftSourceFiles.compactMap {
input -> CompileJobGroup? in
compileGroups[input.typedFile]
let mandatoryCompileJobsInOrder = self.inputFiles.swiftSourceFiles.compactMap {
input -> Job? in
compileJobs[input.typedFile]
}

let mandatoryJobsInOrder = try
jobsInPhases.beforeCompiles +
batchJobFormer.formBatchedJobs(
mandatoryCompileGroupsInOrder.flatMap {$0.allJobs()},
mandatoryCompileJobsInOrder,
showJobLifecycle: showJobLifecycle,
jobCreatingPch: jobCreatingPch)

moduleDependencyGraph.setPhase(to: .buildingAfterEachCompilation)
return (initiallySkippedCompileGroups: [:],
return (initiallySkippedCompileJobs: [:],
mandatoryJobsInOrder: mandatoryJobsInOrder)
}
return try everythingIsMandatory()
Expand All @@ -114,17 +114,17 @@ extension IncrementalCompilationState.FirstWaveComputer {
moduleDependencyGraph,
buildRecord)

let initiallySkippedCompileGroups = compileGroups.filter { initiallySkippedInputs.contains($0.key) }
let initiallySkippedCompileJobs = compileJobs.filter { initiallySkippedInputs.contains($0.key) }

let mandatoryCompileGroupsInOrder = inputFiles.compactMap {
input -> CompileJobGroup? in
let mandatoryCompileJobsInOrder = inputFiles.compactMap {
input -> Job? in
initiallySkippedInputs.contains(input)
? nil
: compileGroups[input]
: compileJobs[input]
}

let batchedCompilationJobs = try batchJobFormer.formBatchedJobs(
mandatoryCompileGroupsInOrder.flatMap {$0.allJobs()},
mandatoryCompileJobsInOrder,
showJobLifecycle: showJobLifecycle,
jobCreatingPch: jobCreatingPch)

Expand All @@ -133,7 +133,7 @@ extension IncrementalCompilationState.FirstWaveComputer {
// have any dependencies on them.
let skipAllJobs = batchedCompilationJobs.isEmpty ? !nonVerifyAfterCompileJobsDependOnBeforeCompileJobs() : false
let mandatoryJobsInOrder = skipAllJobs ? [] : jobsInPhases.beforeCompiles + batchedCompilationJobs
return (initiallySkippedCompileGroups: initiallySkippedCompileGroups,
return (initiallySkippedCompileJobs: initiallySkippedCompileJobs,
mandatoryJobsInOrder: mandatoryJobsInOrder)
}

Expand All @@ -156,7 +156,7 @@ extension IncrementalCompilationState.FirstWaveComputer {
_ moduleDependencyGraph: ModuleDependencyGraph,
_ buildRecord: BuildRecord
) -> Set<TypedVirtualPath> {
let allGroups = jobsInPhases.compileGroups
let allCompileJobs = jobsInPhases.compileJobs
// Input == source file
let changedInputs = computeChangedInputs(moduleDependencyGraph, buildRecord)

Expand All @@ -176,9 +176,9 @@ extension IncrementalCompilationState.FirstWaveComputer {
reporter.report("Has malformed dependency source; will queue", input)
}
}
let inputsMissingOutputs = allGroups.compactMap {
let inputsMissingOutputs = allCompileJobs.compactMap {
$0.outputs.contains { (try? !fileSystem.exists($0.file)) ?? true }
? $0.primaryInput
? $0.primaryInputs[0]
: nil
}
if let reporter = reporter {
Expand Down Expand Up @@ -257,8 +257,8 @@ extension IncrementalCompilationState.FirstWaveComputer {
_ moduleDependencyGraph: ModuleDependencyGraph,
_ outOfDateBuildRecord: BuildRecord
) -> [ChangedInput] {
jobsInPhases.compileGroups.compactMap { group in
let input = group.primaryInput
jobsInPhases.compileJobs.compactMap { job in
let input = job.primaryInputs[0]
let modDate = buildRecordInfo.compilationInputModificationDates[input] ?? .distantFuture
let inputInfo = outOfDateBuildRecord.inputInfos[input.file]
let previousCompilationStatus = inputInfo?.status ?? .newlyAdded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension IncrementalCompilationState {
///
/// This state is modified during the incremental build. All accesses must
/// be protected by the confinement queue.
fileprivate var skippedCompileGroups: [TypedVirtualPath: CompileJobGroup]
fileprivate var skippedCompileJobs: [TypedVirtualPath: Job]

/// Sadly, has to be `var` for formBatchedJobs
///
Expand All @@ -37,11 +37,11 @@ extension IncrementalCompilationState {
fileprivate let jobCreatingPch: Job?
fileprivate let reporter: Reporter?

init(skippedCompileGroups: [TypedVirtualPath: CompileJobGroup],
init(skippedCompileJobs: [TypedVirtualPath: Job],
_ moduleDependencyGraph: ModuleDependencyGraph,
_ jobCreatingPch: Job?,
_ driver: inout Driver) {
self.skippedCompileGroups = skippedCompileGroups
self.skippedCompileJobs = skippedCompileJobs
self.moduleDependencyGraph = moduleDependencyGraph
self.reporter = moduleDependencyGraph.info.reporter
self.jobCreatingPch = jobCreatingPch
Expand Down Expand Up @@ -112,25 +112,25 @@ extension IncrementalCompilationState.ProtectedState {
}
self.reporter?.report(
"Failed to read some dependencies source; compiling everything", input)
return TransitivelyInvalidatedSwiftSourceFileSet(skippedCompileGroups.keys.swiftSourceFiles)
return TransitivelyInvalidatedSwiftSourceFileSet(skippedCompileJobs.keys.swiftSourceFiles)
}

/// Find the jobs that now must be run that were not originally known to be needed.
fileprivate mutating func getUnbatchedJobs(
for invalidatedInputs: Set<SwiftSourceFile>
) throws -> [Job] {
mutationSafetyPrecondition()
return invalidatedInputs.flatMap { input -> [Job] in
if let group = skippedCompileGroups.removeValue(forKey: input.typedFile) {
let primaryInputs = group.compileJob.primarySwiftSourceFiles
return invalidatedInputs.compactMap { input -> Job? in
if let job = skippedCompileJobs.removeValue(forKey: input.typedFile) {
let primaryInputs = job.primarySwiftSourceFiles
assert(primaryInputs.count == 1)
assert(primaryInputs[0] == input)
self.reporter?.report("Scheduling invalidated", input)
return group.allJobs()
return job
}
else {
self.reporter?.report("Tried to schedule invalidated input again", input)
return []
return nil
}
}
}
Expand All @@ -141,13 +141,12 @@ extension IncrementalCompilationState.ProtectedState {
extension IncrementalCompilationState.ProtectedState {
var skippedCompilationInputs: Set<TypedVirtualPath> {
accessSafetyPrecondition()
return Set(skippedCompileGroups.keys)
return Set(skippedCompileJobs.keys)
}
public var skippedJobs: [Job] {
accessSafetyPrecondition()
return skippedCompileGroups.values
.sorted {$0.primaryInput.file.name < $1.primaryInput.file.name}
.flatMap {$0.allJobs()}
return skippedCompileJobs.values
.sorted {$0.primaryInputs[0].file.name < $1.primaryInputs[0].file.name}
}

func writeGraph(to path: VirtualPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extension IncrementalCompilationState {
/// The set of compile jobs we can definitely skip given the state of the
/// incremental dependency graph and the status of the input files for this
/// incremental build.
let initiallySkippedCompileGroups: [TypedVirtualPath: CompileJobGroup]
let initiallySkippedCompileJobs: [TypedVirtualPath: Job]
/// All of the pre-compile or compilation job (groups) known to be required
/// for the first wave to execute.
/// The primaries could be other than .swift files, i.e. .sib
Expand All @@ -90,12 +90,6 @@ extension Driver {
because: "it is not compatible with \(compilerMode)"))
return false
}
guard !parsedOptions.hasArgument(.embedBitcode) else {
diagnosticEngine.emit(
.remark_incremental_compilation_has_been_disabled(
because: "is not currently compatible with embedding LLVM IR bitcode"))
return false
}
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class IncrementalCompilationState {
self.info = initialState.graph.info
self.upToDateInterModuleDependencyGraph = driver.interModuleDependencyGraph
self.protectedState = ProtectedState(
skippedCompileGroups: firstWave.initiallySkippedCompileGroups,
skippedCompileJobs: firstWave.initiallySkippedCompileJobs,
initialState.graph,
jobsInPhases.allJobs.first(where: {$0.kind == .generatePCH}),
&driver)
Expand Down
81 changes: 0 additions & 81 deletions Sources/SwiftDriver/Jobs/BackendJob.swift

This file was deleted.

4 changes: 1 addition & 3 deletions Sources/SwiftDriver/Jobs/DarwinToolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ extension DarwinToolchain {
}
}

if parsedOptions.contains(.embedBitcode) {
commandLine.appendFlag("-fembed-bitcode")
} else if parsedOptions.contains(.embedBitcodeMarker) {
if parsedOptions.contains(.embedBitcodeMarker) {
commandLine.appendFlag("-fembed-bitcode=marker")
}

Expand Down
Loading