Bug#1057838: clang-17: c++ include dir from sysroot unexpectedly in include paths when in wasm c mode

Israel Galadima izzygaladima at gmail.com
Fri Dec 15 12:15:22 GMT 2023


Dear Maintainers,

I have looked further into this and I think these lines in the patch 
file at debian/patches/wasm/wasm-sysroot-usr.diff
are responsible.

40 +    if (!getDriver().SysRoot.empty()) {
41 +        // Second add the generic one.
42 +        addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + 
Version);
43 +        // Third the backward one.
44 +        addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + 
Version + "/backward");
45 +    }

The above lines are adding c++ include paths in the 
method (WebAssembly::AddClangSystemIncludeArgs)
for adding only system/c include paths.
I think the c++ include paths should only be added in the methods for adding
libc++ (WebAssembly::addLibCxxIncludePaths) or libstdc++ 
(WebAssembly::addLibStdCXXIncludePaths) include
paths.

Some context on why I need this fixed. I'm updating emscripten in Debian 
and need to
provide pre-compiled libraries to the end user. However, when compiling 
c files in compiler-rt
that include stdatomic.h, an issue arises. The system's stdatomic.h file 
uses an include_next
to select any other stdatomic.h it finds in the include paths, and since 
there's another stdatomic.h [1]
in the c++ include path of the emscripten sysroot, it gets selected. 
Ideally, the other stdatomic.h
shouldn't be seen, but when compiling c files, clang-17 wrongly adds the 
c++ include directory from
the emscripten sysroot to the include paths which causes the conflict.

1. 
https://github.com/emscripten-core/emscripten/blob/main/system/lib/libcxx/include/stdatomic.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x3679ECB87B7CEC0C.asc
Type: application/pgp-keys
Size: 3143 bytes
Desc: OpenPGP public key
URL: <http://alioth-lists.debian.net/pipermail/pkg-llvm-team/attachments/20231215/85a81e06/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-llvm-team/attachments/20231215/85a81e06/attachment.sig>


More information about the Pkg-llvm-team mailing list