Skip to content

[WebAssembly][lld] excessive undefined symbol errors when building a shared library #103592

@yamt

Description

@yamt

after 22b7b84,
wasm-ld complains on undefined symbols when building -shared/-pie. it's nice.

however, it even complains on symbols which are expected to be provided/imported by wasm-ld itself. (eg. __heap_base)
i consider it a bug.

i saw it while buliding wasi-libc: WebAssembly/wasi-libc#526

a smaller recipe to reproduce: https://github.com/yamt/garbage/tree/master/wasm/ld-shared

with:

clang version 20.0.0git (https://github.com/llvm/llvm-project.git c31ac810910ac87531de636ea508abec6e29e8ff)

spacetanuki% ./test.sh

+ CC=/Volumes/PortableSSD/llvm/build/bin/clang
+ /Volumes/PortableSSD/llvm/build/bin/clang -o liba.so -nostdlib -shared -mexception-handling -fPIC -fvisibility=default -Wl,--no-entry a.c
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __heap_base
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __heap_end
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __cpp_exception
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __c_longjmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions