WASI libc++ contains undefined exception-related symbols

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

Bug Description

This concerns libc++-16-dev-wasm32 1:16.0.6-10 in Ubuntu mantic, and also applies to libc++-15-dev-wasm32 1:15.0.7-3ubuntu0.23.04.1 in Ubuntu lunar. (Both are the default versions for each respective release.)

In the course of building Firefox, I encountered this error:

    ----begin build log excerpt----
    make[3]: Entering directory '/tmp/firefox-117.0/build-browser/security/rlbox'
    security/rlbox/rlbox.wasm
    rm -f rlbox.wasm
    /usr/bin/clang++ --target=wasm32-wasi -o rlbox.wasm -Wl,--export-all -Wl,--stack-first -Wl,-z,stack-size=262144 -Wl,--no-entry -Wl,--growable-table -Wl,--import-memory -Wl,--import-table ogg_alloc.wasm ogg_bitwise.wasm ogg_framing.wasm xmlparse.wasm xmlrole.wasm xmltok.wasm wasm2c_sandbox_wrapper.wasm mozHunspellRLBoxSandbox.wasm affentry.wasm affixmgr.wasm csutil.wasm hashmgr.wasm hunspell.wasm phonet.wasm replist.wasm suggestmgr.wasm GraphiteExtra.wasm CmapCache.wasm Code.wasm Collider.wasm Decompressor.wasm Face.wasm FeatureMap.wasm Font.wasm GlyphCache.wasm GlyphFace.wasm Intervals.wasm Justifier.wasm NameTable.wasm Pass.wasm Position.wasm Segment.wasm Silf.wasm Slot.wasm Sparse.wasm TtfUtil.wasm UtfCodec.wasm call_machine.wasm gr_char_info.wasm gr_face.wasm gr_features.wasm gr_font.wasm gr_segment.wasm gr_slot.wasm mozalloc.wasm RLBoxWOFF2Sandbox.wasm table_tags.wasm variable_length.wasm woff2_common.wasm woff2_dec.wasm woff2_out.wasm -lwasi-emulated-process-clocks
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_allocate_exception
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(stdlib_new_delete.cpp.o): undefined symbol: __cxa_throw
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(ios.cpp.o): undefined symbol: __cxa_rethrow
    wasm-ld-16: error: /usr/lib/wasm32-wasi/libc++.a(ios.cpp.o): undefined symbol: __cxa_rethrow
    wasm-ld-16: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[3]: *** [/tmp/firefox-117.0/config/rules.mk:496: rlbox.wasm] Error 1
    make[3]: Leaving directory '/tmp/firefox-117.0/build-browser/security/rlbox'
    make[2]: *** [/tmp/firefox-117.0/config/recurse.mk:72: security/rlbox/pre-compile] Error 2
    make[2]: Leaving directory '/tmp/firefox-117.0/build-browser'
    make[1]: *** [/tmp/firefox-117.0/config/recurse.mk:34: compile] Error 2
    make[1]: Leaving directory '/tmp/firefox-117.0/build-browser'
    make: *** [/tmp/firefox-117.0/config/rules.mk:361: default] Error 2
    ----end build log excerpt----

If we look inside the WASI libc++ library for __cxa_allocate_exception (as just one example), we see several references to it and no definitions, just as the linker is complaining:

    $ llvm-nm -A /usr/lib/wasm32-wasi/libc++.a | grep __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:cxa_aux_runtime.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:cxa_vector.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:stdlib_new_delete.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:atomic.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:barrier.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:condition_variable.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:condition_variable_destructor.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:future.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:hash.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:mutex_destructor.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:new.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:shared_mutex.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:string.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:thread.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:typeinfo.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:system_error.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:vector.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:valarray.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:ios.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:ios.instantiations.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:locale.cpp.o: U __cxa_allocate_exception

Here is that same command, run on Debian unstable:

    $ llvm-nm -A /usr/lib/wasm32-wasi/libc++.a | grep __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++.a:atomic.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:barrier.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:condition_variable.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:condition_variable_destructor.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:future.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:mutex_destructor.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:shared_mutex.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:thread.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:typeinfo.cpp.o: no symbols
    /usr/lib/wasm32-wasi/libc++.a:vector.cpp.o: no symbols

I don't get the link error on Debian unstable. Something is wrong with how the WASI C++ library is being built for Ubuntu.

Tags: lunar mantic
description: updated
Revision history for this message
Daniel Richard G. (skunk) wrote :

Additionally, in case it is of interest, on Ubuntu:

    $ llvm-nm -A /usr/lib/wasm32-wasi/libc++abi.a | grep __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++abi.a:cxa_aux_runtime.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++abi.a:cxa_vector.cpp.o: U __cxa_allocate_exception
    /usr/lib/wasm32-wasi/libc++abi.a:stdlib_new_delete.cpp.o: U __cxa_allocate_exception

On Debian unstable:

    $ llvm-nm -A /usr/lib/wasm32-wasi/libc++abi.a | grep __cxa_allocate_exception
    (no output)

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.