From ecbebd0a8fd344a73c54963f287387a950b99213 Mon Sep 17 00:00:00 2001 From: Faidon Liambotis Date: Sun, 13 Nov 2022 09:51:30 +0200 Subject: [PATCH] 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/. 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//c++/v1. Nothing installs anything on those paths there yet, so this is mostly preparatory for subsequent changes. --- debian/patches/wasm/wasm-sysroot-usr.diff | 27 +++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/debian/patches/wasm/wasm-sysroot-usr.diff b/debian/patches/wasm/wasm-sysroot-usr.diff index 165de408..0d884214 100644 --- a/debian/patches/wasm/wasm-sysroot-usr.diff +++ b/debian/patches/wasm/wasm-sysroot-usr.diff @@ -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); }