Skip to content

Commit b5fd2de

Browse files
committed
Fix swift integration tests
This was indeed bad logic in SwiftPM.
1 parent 769fc0d commit b5fd2de

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/swift-build/UserToolchain.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import protocol Build.Toolchain
12+
import struct Utility.Path
1213
import enum Multitool.Error
1314
import POSIX
1415

@@ -39,10 +40,14 @@ struct UserToolchain: Toolchain {
3940

4041
init() throws {
4142
do {
42-
SWIFT_EXEC = try getenv("SWIFT_EXEC") ?? popen(["which", "swiftc"]).chomp().abspath()
43+
SWIFT_EXEC = getenv("SWIFT_EXEC")
44+
// see if user has put something earlier in the path
45+
?? (try? POSIX.popen(["which", "swiftc"]))?.chomp().abspath()
46+
// use the swiftc installed alongside ourselves
47+
?? Path.join(Process.arguments[0], "../swiftc").abspath()
4348
clang = try getenv("CC") ?? popen(["which", "clang"]).chomp().abspath()
4449
sysroot = nil
45-
} catch is POSIX.ShellError {
50+
} catch POSIX.Error.ExitStatus {
4651
throw Multitool.Error.InvalidToolchain
4752
}
4853
guard !SWIFT_EXEC.isEmpty && !clang.isEmpty else {

0 commit comments

Comments
 (0)