Cannot find WASI libc++ headers without normal libc++ headers installed

Bug #2033450 reported by Daniel Richard G.
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
llvm-toolchain-16 (Ubuntu)
New
Undecided
Unassigned

Bug Description

This bug concerns libc++-16-dev-wasm32 in Ubuntu mantic, but also applies to libc++-15-dev-wasm32 in Ubuntu lunar.

The problem can be seen in the following series of steps, starting with a minimal system:

  # apt-get install clang libc++-dev-wasm32

  $ echo '#include <cstring>' >test.cpp

  $ /usr/bin/clang++ --target=wasm32-wasi test.cpp -c
  tst.cpp:1:10: fatal error: 'cstring' file not found
  #include <cstring>
           ^~~~~~~~~
  1 error generated.

  # apt-get install libc++-dev

  $ /usr/bin/clang++ --target=wasm32-wasi test.cpp -c
  (success)

Note that Clang, with --target=wasm32-wasi, does not use any headers provided by libc++-16-dev; it uses the ones in libc++-16-dev-wasm32:

  $ /usr/bin/clang++ --target=wasm32-wasi test.cpp -c -H
  . /usr/include/wasm32-wasi/c++/v1/cstring
  .. /usr/include/wasm32-wasi/c++/v1/__assert
  ... /usr/include/wasm32-wasi/c++/v1/__config
  [...]

The headers provided by libc++-16-dev are extraneous to the requested compilation, so why is the compile affected by their absence/presence?

I encountered this issue in the course of attempting to build Firefox on the system. The following build log excerpt tells how this issue first arose:

  [...]
  checking the wasm C++ compiler works... yes
  checking the wasm C++ compiler can find wasi headers...
  DEBUG: Creating `/tmp/conftest.7wwkmmac.cpp` with content:
  DEBUG: | #include <cstring>
  DEBUG: | int
  DEBUG: | main(void)
  DEBUG: | {
  DEBUG: |
  DEBUG: | ;
  DEBUG: | return 0;
  DEBUG: | }
  DEBUG: Executing: `/usr/bin/clang++ --target=wasm32-wasi /tmp/conftest.7wwkmmac.cpp -c`
  DEBUG: The command returned non-zero exit status 1.
  DEBUG: Its error output was:
  DEBUG: | /tmp/conftest.7wwkmmac.cpp:1:10: fatal error: 'cstring' file not found
  DEBUG: | #include <cstring>
  DEBUG: | ^~~~~~~~~
  DEBUG: | 1 error generated.
  ERROR: Cannot find wasi headers or problem with the wasm compiler. Please fix the problem. Or build with --without-wasm-sandboxed-libraries.
  make[1]: *** [debian/rules:235: stamps/configure-browser] Error 1
  make[1]: Leaving directory '/home/build/firefox/firefox-116.0'
  make: *** [debian/rules:341: build] Error 2
  dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

Tags: lunar mantic
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.