Skip to content

Dynamic linking compilation crashes with -g #24166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
quanterion opened this issue Apr 22, 2025 · 4 comments
Open

Dynamic linking compilation crashes with -g #24166

quanterion opened this issue Apr 22, 2025 · 4 comments

Comments

@quanterion
Copy link

quanterion commented Apr 22, 2025

Tried to compile simple repo at https://github.com/quanterion/WASMDynamicLinking with debug information enabled (adding -g to compilation flag) results in crash:
user@comp:~/WASMDynamicLinking$ ./CompileToWasm.sh PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. emcc: error: '/home/rem/emsdk/upstream/bin/wasm-ld @/tmp/emscripten_4yn7fmll.rsp.utf-8' failed (received SIGSEGV (-11))

through compilation works just fine if remove "-g" flag from https://github.com/quanterion/WASMDynamicLinking/blob/main/CompileToWasm.sh

@sbc100
Copy link
Collaborator

sbc100 commented Apr 22, 2025

Can you trying installing the -asserts version of the sdk (e.g. ./emsdk install latest-asserts) and include the backtrace, and the full failing command line?

@sbc100 sbc100 transferred this issue from emscripten-core/emsdk Apr 22, 2025
@quanterion
Copy link
Author

@sbc100 Here is it:

user@comp:~/WASMDynamicLinking$ ./CompileToWasm.sh 
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
emcc: error: '/home/rem/emsdk/upstream/bin/wasm-ld @/tmp/emscripten_xzq32t5r.rsp.utf-8' failed (received SIGABRT (-6))

@sbc100
Copy link
Collaborator

sbc100 commented Apr 23, 2025

I don't see the emcc command line here. Perhaps you could have your compile script echo the commands? Especially the ones that fail?

Also, sadly the wasm-ld command here is using a response file which makes it hard to see that is being passed to wasm-ld.

I'm also somewhat surprised as the lack of information in the output that comes with the PLEASE submit a bug report. Normally you get a lot more useful backtrace information that that.

But just having the full emcc and wasm-ld commands would be useful.

@quanterion
Copy link
Author

quanterion commented Apr 28, 2025

@sbc100 here is it, those command just executed from this file: https://github.com/quanterion/WASMDynamicLinking/blob/main/CompileToWasm.sh

user@pc:~/WASMDynamicLinking$ emcc -sSIDE_MODULE=1 -sMAIN_MODULE=0 -s EXPORT_ALL=1 -sPROXY_TO_PTHREAD -pthread -sSHARED_MEMORY=1 -Wno-experimental -g -o Build/libcalc.so Src/calc.cpp
user@pc:~/WASMDynamicLinking$ emcc -sMAIN_MODULE=2 -sAUTOLOAD_DYLIBS=0 -sPROXY_TO_PTHREAD -pthread -sSHARED_MEMORY=1 -Wno-experimental -g -o Build/main.html Build/libcalc.so Src/main.cpp
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
emcc: error: '/home/rem/emsdk/upstream/bin/wasm-ld @/tmp/emscripten_ixv7uy_a.rsp.utf-8' failed (received SIGABRT (-6))

anyway linked repo is the very minimal repro https://github.com/quanterion/WASMDynamicLinking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants