Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -740,16 +740,12 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
}
}

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

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

let environment: [(String, String)] = self.environmentFromSpec(cbc, delegate)
// Add dependencies for any arguments indicating a file path.
Self.addAdditionalDependenciesFromCommandLine(cbc, commandLine, EnvironmentBindings(environment), &inputs, &outputs, delegate)

Expand Down
3 changes: 1 addition & 2 deletions Sources/SWBCore/SpecImplementations/Tools/TouchTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ final class TouchToolSpec : CommandLineToolSpec, SpecIdentifierType, @unchecked
delegate.error("Can't determine path to cmd.exe because the ComSpec environment variable is not set")
return
}
// FIXME: Need to properly quote the path here, or generally handle this better
commandLine = [commandShellPath, "/c", "copy /b \"\(input.absolutePath.str)\" +,,"]
commandLine = [commandShellPath, "/c", "copy", "/b", input.absolutePath.str, "+,,"]
} else {
commandLine = ["/usr/bin/touch", "-c", input.absolutePath.str]
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SWBWindowsPlatform/Specs/WindowsCompile.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Type = Compiler;
BasedOn = "default:com.apple.compilers.llvm.clang.1_0";
EnvironmentVariables = {
"TEMP" = "$(OBJROOT)";
"TMP" = "$(OBJROOT)";
};
Name = "Apple LLVM Windows";
Description = "Apple LLVM Windows compiler";
Expand Down
4 changes: 3 additions & 1 deletion Sources/SWBWindowsPlatform/Specs/WindowsLd.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
IsAbstract = Yes;
SupportsInputFileList = No;
EnvironmentVariables = {
"TEMP" = "$(TEMP)";
"TEMP" = "$(OBJROOT)";
"TMP" = "$(OBJROOT)";
"TMPDIR" = "$(OBJROOT)";
"PATH" = "$(TOOLCHAIN_DIR)/usr/bin;$(DEVELOPER_DIR)/Runtimes/$(TOOLCHAIN_VERSION)/usr/bin;$(PATH)";
};
Options = (
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWBCoreTests/CommandLineSpecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ import SWBMacro
#expect(task.execDescription == "Touch input")
if core.hostOperatingSystem == .windows {
let commandShellPath = try #require(getEnvironmentVariable("ComSpec"), "Can't determine path to cmd.exe because the ComSpec environment variable is not set")
task.checkCommandLine([commandShellPath, "/c", "copy /b \"\(Path.root.join("tmp/input").str)\" +,,"])
task.checkCommandLine([commandShellPath, "/c", "copy", "/b", Path.root.join("tmp/input").str, "+,,"])
} else {
task.checkCommandLine(["/usr/bin/touch", "-c", Path.root.join("tmp/input").str])
}
Expand Down
Loading