Skip to content

Commit 3376785

Browse files
committed
Use C++ driver when C++ interop is enabled
This aligns the old driver with the behavior of the new driver. When building with C++ interop enabled, it's important that we link a C++ runtime, which is handled by the clang++ driver. The new driver uses clang++ when linking with C++ enabled, either through the c++ interoperability mode flag or the experimental C++ interop flag. The old driver only enabled it with the experimental C++ interop flag. This results in the C++ interop tests failing on FreeBSD and a behavioral difference between what we are testing and what we are shipping.
1 parent 276261c commit 3376785

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,9 +1656,10 @@ const char *ToolChain::getClangLinkerDriver(
16561656
// a C++ standard library if it's not needed, in particular because the
16571657
// standard library that `clang++` selects by default may not be the one that
16581658
// is desired.
1659-
const char *LinkerDriver =
1660-
Args.hasArg(options::OPT_enable_experimental_cxx_interop) ? "clang++"
1661-
: "clang";
1659+
bool useCxxLinker = Args.hasArg(options::OPT_enable_experimental_cxx_interop);
1660+
if (Arg *arg = Args.getLastArg(options::OPT_cxx_interoperability_mode))
1661+
useCxxLinker |= StringRef(arg->getValue()) != "off";
1662+
const char *LinkerDriver = useCxxLinker ? "clang++" : "clang";
16621663
if (const Arg *A = Args.getLastArg(options::OPT_tools_directory)) {
16631664
StringRef toolchainPath(A->getValue());
16641665

0 commit comments

Comments
 (0)