[Bug 2033450] [NEW] Cannot find WASI libc++ headers without normal libc++ headers installed

Daniel Richard G. 2033450 at bugs.launchpad.net
Wed Aug 30 02:13:58 UTC 2023


Public bug reported:

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

** Affects: llvm-toolchain-16 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: lunar mantic

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to llvm-toolchain-16 in Ubuntu.
https://bugs.launchpad.net/bugs/2033450

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

Status in llvm-toolchain-16 package in Ubuntu:
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-16/+bug/2033450/+subscriptions




More information about the foundations-bugs mailing list