On Wed, Mar 08, 2023 at 09:08:13AM +0100, Sylvestre Ledru wrote:
> > Specifically, it looks like the entire patching of the method
> > WebAssembly::AddClangCXXStdlibIncludeArgs isn't happening anymore. One
> > of these differences was exactly about this -- the comment says:
> >    // don't include the host architecture's headers in the search path
> > 
> > Sylvestre, I think you did the 14->15 porting, right? Do you
> > know/remember what happened there?
> 
> Maybe i did a mistake in the merge?!

Upstream commit b5787a0 ("Support -stdlib=libstdc++ for WebAssembly")
reorganized the code a bit, which resulted in a merge conflict. It also
included half of what my patch did, namely the getDriver().SysRoot to
computeSysRoot() conversion, which probably resulted in you thinking
that this hunk isn't necessary anymore!

I'm attaching a diff that restores the second half of the diff, and I
believe should fix this bug. (LLVM is a pain to build and test, so I
haven't tested this at all yet; hoping that it's easier for Sylvestre to
test!). I'm also attaching the interdiff in case it helps anyone to
review.

I'm not submitting an MR because I noticed that "15" branch has
progressed further compared to 1-15.0.7-1, and I'm not sure how you'd
like to handle it; basically whether these changes are suitable for
bookworm at this point, or whether you'd like to to fork a branch for
bookworm.

Side-note unrelated to this bug, but confused me during its
investigation:
  # this is a badly named duplicate of debian/1%15.0.7-1
  git tag -d debian/1%15.0.71; git push origin :debian/1%15.0.71
  # cruft left behind from the move to debian/patches/wasm/
  git checkout 15; git rm debian/patches/wasm-*; git commit -m "Remove cruft"
  git checkout snapshot; git rm debian/patches/wasm-*; git commit -m "Remove 
cruft"

HTH!
Faidon
--- a/debian/patches/wasm/wasm-sysroot-usr.diff
+++ b/debian/patches/wasm/wasm-sysroot-usr.diff
@@ -57,6 +59,33 @@
  void WebAssembly::addLibCxxIncludePaths(
      const llvm::opt::ArgList &DriverArgs,
      llvm::opt::ArgStringList &CC1Args) const {
+@@ -499,7 +519,9 @@ void WebAssembly::addLibCxxIncludePaths(
+   }
+ 
+   // Second add the generic one.
+-  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
++  // don't include the host architecture's headers in the search path
++  if (!getDriver().SysRoot.empty())
++    addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
+ }
+ 
+ void WebAssembly::addLibStdCXXIncludePaths(
+@@ -546,8 +568,11 @@ void WebAssembly::addLibStdCXXIncludePat
+     addSystemInclude(DriverArgs, CC1Args, TargetDir);
+   }
+ 
+-  // Second add the generic one.
+-  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
+-  // Third the backward one.
+-  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward");
++  // don't include the host architecture's headers in the search path
++  if (!getDriver().SysRoot.empty()) {
++    // Second add the generic one.
++    addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
++    // Third the backward one.
++    addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward");
++  }
+ }
 --- a/clang/lib/Driver/ToolChains/WebAssembly.h
 +++ b/clang/lib/Driver/ToolChains/WebAssembly.h
 @@ -89,6 +89,8 @@ private:
diff -u b/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
--- b/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -519,7 +519,9 @@
   }
 
   // Second add the generic one.
-  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
+  // don't include the host architecture's headers in the search path
+  if (!getDriver().SysRoot.empty())
+    addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
 }
 
 void WebAssembly::addLibStdCXXIncludePaths(
@@ -568,6 +570,9 @@
 
-  // Second add the generic one.
-  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
-  // Third the backward one.
-  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward");
+  // don't include the host architecture's headers in the search path
+  if (!getDriver().SysRoot.empty()) {
+    // Second add the generic one.
+    addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
+    // Third the backward one.
+    addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward");
+  }
 }

Reply via email to