Skip to content

Commit 29e43c4

Browse files
committed
Add SDKROOT when proxying on macOS based on xcrun information (swiftlang#316)
* Strip newlines from xcrun output
1 parent 0f1aa94 commit 29e43c4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/SwiftlyCore/Platform.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ extension Platform {
166166
for (key, value) in env {
167167
newEnv[key] = value
168168
}
169+
170+
#if os(macOS)
171+
// On macOS, we try to set SDKROOT if its empty for tools like clang++ that need it to
172+
// find standard libraries that aren't in the toolchain, like libc++. Here we
173+
// use xcrun to tell us what the default sdk root should be.
174+
if newEnv["SDKROOT"] == nil {
175+
newEnv["SDKROOT"] = (try? await self.runProgramOutput("/usr/bin/xcrun", "--show-sdk-path"))?.replacingOccurrences(of: "\n", with: "")
176+
}
177+
#endif
178+
169179
try self.runProgram([command] + arguments, env: newEnv)
170180
}
171181

0 commit comments

Comments
 (0)