Skip to content

Commit b05548c

Browse files
committed
Merge pull request #12 from apple/clang++
2 parents 0819891 + ad7c4bb commit b05548c

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Sources/swift-build/main.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import dep
1212
import POSIX
1313
import sys
1414

15+
1516
// Initialize the resource support.
1617
public var globalSymbolInMainBinary = 0
1718
Resources.initialize(&globalSymbolInMainBinary)
@@ -50,8 +51,26 @@ do {
5051
try llbuild(srcroot: pkg.path, targets: try pkg.targets(), dependencies: dependencies, prefix: builddir, tmpdir: Path.join(builddir, "\(pkg.name).o"), configuration: configuration)
5152
}
5253

53-
// build the current directory
54-
try llbuild(srcroot: rootd, targets: targets, dependencies: dependencies, prefix: builddir, tmpdir: Path.join(builddir, "\(pkgname).o"), configuration: configuration)
54+
do {
55+
// build the current directory
56+
try llbuild(srcroot: rootd, targets: targets, dependencies: dependencies, prefix: builddir, tmpdir: Path.join(builddir, "\(pkgname).o"), configuration: configuration)
57+
} catch POSIX.Error.ExitStatus(let foo) {
58+
#if os(Linux)
59+
// it is a common error on Linux for clang++ to not be installed, but
60+
// we need it for linking. swiftc itself gives a non-useful error, so
61+
// we try to help here.
62+
63+
//TODO really we should figure out if clang++ is installed in a better way
64+
// however, since this is an error path, the performance implications are
65+
// less severe, so it will do for now.
66+
67+
if (try? popen(["clang++", "--version"], redirectStandardError: true)) == nil {
68+
print("warning: clang++ not found: this will cause build failure", toStream: &stderr)
69+
}
70+
#endif
71+
throw POSIX.Error.ExitStatus(foo)
72+
}
73+
5574

5675
case .Version:
5776
print("Apple Swift Package Manager 0.1")

0 commit comments

Comments
 (0)