Skip to content

Commit c8c81fa

Browse files
authored
Sanitize environment for XCBuild (#5998)
We need to sanitize `DYLD_LIBRARY_PATH` in the environment before launching XCBuild because otherwise just built dependencies of SwiftPM can interfere with the linked dependencies of XCBuild which will typically not end well. This can e.g. happen during bootstrap builds.
1 parent c47671b commit c8c81fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/XCBuildSupport/XcodeBuildSystem.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
141141
stderrBuffer.append(contentsOf: bytes)
142142
})
143143

144-
let process = TSCBasic.Process(arguments: arguments, outputRedirection: redirection)
144+
// We need to sanitize the environment we are passing to XCBuild because we could otherwise interfere with its linked dependencies e.g. when we have a custom swift-driver dynamic library in the path.
145+
var sanitizedEnvironment = ProcessEnv.vars
146+
sanitizedEnvironment["DYLD_LIBRARY_PATH"] = nil
147+
148+
let process = TSCBasic.Process(arguments: arguments, environment: sanitizedEnvironment, outputRedirection: redirection)
145149
try process.launch()
146150
let result = try process.waitUntilExit()
147151

0 commit comments

Comments
 (0)