Skip to content

Commit 133e1f2

Browse files
committed
Driver: emit a diagnostic if clang++ is not found
Rather than aborting due to an assertion failure, emit a diagnostic. This is much safer and generally easier to understand why the command failed. It solves the problem of running swiftc from the build without the path being set such that the clang++ driver is found by the swift driver.
1 parent 7076671 commit 133e1f2

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/Driver/WindowsToolChains.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ toolchains::Windows::constructInvocation(const DynamicLinkJobAction &job,
8080

8181
// Configure the toolchain.
8282
// By default, use the system clang++ to link.
83-
const char *Clang = nullptr;
83+
const char *Clang = "clang++";
8484
if (const Arg *A = context.Args.getLastArg(options::OPT_tools_directory)) {
8585
StringRef toolchainPath(A->getValue());
8686

@@ -89,12 +89,6 @@ toolchains::Windows::constructInvocation(const DynamicLinkJobAction &job,
8989
llvm::sys::findProgramByName("clang++", {toolchainPath}))
9090
Clang = context.Args.MakeArgString(toolchainClang.get());
9191
}
92-
if (Clang == nullptr) {
93-
if (auto pathClang = llvm::sys::findProgramByName("clang++", None))
94-
Clang = context.Args.MakeArgString(pathClang.get());
95-
}
96-
assert(Clang &&
97-
"clang++ was not found in the toolchain directory or system path.");
9892

9993
std::string Target = getTriple().str();
10094
if (!Target.empty()) {

test/Driver/windows-link-job.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: env PATH= %swiftc_driver_plain -target x86_64-unknown-windows-msvc -### -module-name link -emit-library %s 2>&1 | %FileCheck %s
2+
// CHECK: {{^}}clang++

0 commit comments

Comments
 (0)