Skip to content

Commit 7a6ec3d

Browse files
authored
Merge pull request #831 from owenv/owenv/linker-temps
Set TMPDIR when invoking linker drivers on Windows
2 parents 699b4d5 + 2c2be3d commit 7a6ec3d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,15 +723,18 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
723723
}
724724
}
725725

726-
let environment: EnvironmentBindings = self.environmentFromSpec(cbc, delegate)
727-
726+
var environment: [(String, String)] = self.environmentFromSpec(cbc, delegate)
727+
// On Windows, some linker drivers require TMPDIR to be set.
728+
if cbc.producer.hostOperatingSystem == .windows {
729+
environment.append(("TMPDIR", cbc.scope.evaluate(BuiltinMacros.OBJROOT).str))
730+
}
728731
// Compute the inputs and outputs.
729732
var inputs: [any PlannedNode] = inputPaths.map{ delegate.createNode($0) }
730733

731734
await inputs.append(contentsOf: additionalInputDependencies(cbc, delegate, optionContext: discoveredCommandLineToolSpecInfo(cbc.producer, cbc.scope, delegate), lookup: lookup).map(delegate.createNode))
732735

733736
// Add dependencies for any arguments indicating a file path.
734-
Self.addAdditionalDependenciesFromCommandLine(cbc, commandLine, environment, &inputs, &outputs, delegate)
737+
Self.addAdditionalDependenciesFromCommandLine(cbc, commandLine, EnvironmentBindings(environment), &inputs, &outputs, delegate)
735738

736739
let architecture = cbc.scope.evaluate(BuiltinMacros.arch)
737740
let buildVariant = cbc.scope.evaluate(BuiltinMacros.variant)
@@ -777,7 +780,7 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
777780
let otherInputs = delegate.buildDirectories.sorted().compactMap { path in ldSearchPaths.contains(path.str) ? delegate.createBuildDirectoryNode(absolutePath: path) : nil } + cbc.commandOrderingInputs
778781

779782
// Create the task.
780-
delegate.createTask(type: self, dependencyData: dependencyInfo, payload: payload, ruleInfo: defaultRuleInfo(cbc, delegate), commandLine: commandLine, environment: environment, workingDirectory: cbc.producer.defaultWorkingDirectory, inputs: inputs + otherInputs, outputs: outputs, action: delegate.taskActionCreationDelegate.createDeferredExecutionTaskActionIfRequested(userPreferences: cbc.producer.userPreferences), execDescription: resolveExecutionDescription(cbc, delegate), enableSandboxing: enableSandboxing)
783+
delegate.createTask(type: self, dependencyData: dependencyInfo, payload: payload, ruleInfo: defaultRuleInfo(cbc, delegate), commandLine: commandLine, environment: EnvironmentBindings(environment), workingDirectory: cbc.producer.defaultWorkingDirectory, inputs: inputs + otherInputs, outputs: outputs, action: delegate.taskActionCreationDelegate.createDeferredExecutionTaskActionIfRequested(userPreferences: cbc.producer.userPreferences), execDescription: resolveExecutionDescription(cbc, delegate), enableSandboxing: enableSandboxing)
781784
}
782785

783786
public static func addAdditionalDependenciesFromCommandLine(_ cbc: CommandBuildContext, _ commandLine: [String], _ environment: EnvironmentBindings, _ inputs: inout [any PlannedNode], _ outputs: inout [any PlannedNode], _ delegate: any TaskGenerationDelegate) {

0 commit comments

Comments
 (0)