Patch the WebAssembly include paths for C++ as well

In wasm-sysroot-usr.diff we have changes to support compilation without
a sysroot and with system paths. These so far have applied to the C
include paths (among other things), i.e. /usr/include/<triple>. This was
mainly because that's what I had at hand to test and wanted to keep
things limited as a first iteration.

Now that we're iterated on it and cleared out some issues, make the
exact same changes for the C++ include paths as well, i.e.
/usr/include/<triple>/c++/v1. Nothing installs anything on those paths
there yet, so this is mostly preparatory for subsequent changes.
This commit is contained in:
Faidon Liambotis 2022-11-13 09:51:30 +02:00
parent b91115bd58
commit ecbebd0a8f

View File

@ -27,7 +27,7 @@ Index: llvm-toolchain-14-14.0.6/clang/lib/Driver/ToolChains/WebAssembly.cpp
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
SmallString<128> P(D.ResourceDir);
@@ -419,12 +421,20 @@ void WebAssembly::AddClangSystemIncludeA
@@ -419,27 +421,39 @@ void WebAssembly::AddClangSystemIncludeA
return;
}
@ -51,7 +51,30 @@ Index: llvm-toolchain-14-14.0.6/clang/lib/Driver/ToolChains/WebAssembly.cpp
}
void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
@@ -467,3 +477,15 @@ SanitizerMask WebAssembly::getSupportedS
ArgStringList &CC1Args) const {
+ std::string SysRoot = computeSysRoot();
+
if (!DriverArgs.hasArg(options::OPT_nostdlibinc) &&
!DriverArgs.hasArg(options::OPT_nostdincxx)) {
if (getTriple().getOS() != llvm::Triple::UnknownOS) {
const std::string MultiarchTriple =
- getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
+ getMultiarchTriple(getDriver(), getTriple(), SysRoot);
addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/include/" + MultiarchTriple +
+ SysRoot + "/include/" + MultiarchTriple +
"/c++/v1");
}
- addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/include/c++/v1");
+
+ // don't include the host architecture's headers in the search path
+ if (!getDriver().SysRoot.empty())
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include/c++/v1");
}
}
@@ -467,3 +481,15 @@ SanitizerMask WebAssembly::getSupportedS
Tool *WebAssembly::buildLinker() const {
return new tools::wasm::Linker(*this);
}