Skip to content
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

Cannot build cdylib for wasm32-unknown-emscripten #80775

Closed
dalcde opened this issue Jan 7, 2021 · 1 comment
Closed

Cannot build cdylib for wasm32-unknown-emscripten #80775

dalcde opened this issue Jan 7, 2021 · 1 comment
Labels
C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@dalcde
Copy link
Contributor

dalcde commented Jan 7, 2021

Create an empty file test.rs and run

rustc -C link-args='-s SIDE_MODULE' --target wasm32-unknown-emscripten --crate-type cdylib test.rs

It gives the error

error: linking with `emcc` failed: exit code: 1
  |
  = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib" "-L" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/self-contained" "test.test.3a1fbbbh-cgu.0.rcgu.o" "-o" "test.wasm" "-s" "EXPORTED_FUNCTIONS=[\"_rust_eh_personality\"]" "test.2h4nzeicjcod1ad3.rcgu.o" "-O0" "--memory-init-file" "0" "-g0" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libstd-d69e7237ec2ec907.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libpanic_unwind-cf6146279e321a86.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_demangle-30de99a0feadb118.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libhashbrown-744fdda8cec61518.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_alloc-1bd061abaa6299ee.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libunwind-790ede63273b678e.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcfg_if-33e32972cf91da62.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liblibc-455b1f1bdddd2493.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc-38821dae73c49cdd.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_core-f752c0f2f8e113a2.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-79c24dc82f9ff182.rlib" "/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcompiler_builtins-da221c4cef139dc0.rlib" "-l" "c" "-s" "SIDE_MODULE" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1" "-s" "ASSERTIONS=1" "-s" "ABORTING_MALLOC=0" "-Wl,--fatal-warnings"
  = note: wasm-ld: error: unknown file type: lib.rmeta
          emcc: error: '/opt/emscripten-llvm/bin/wasm-ld -o test.wasm --whole-archive -L/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib -L/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/self-contained test.test.3a1fbbbh-cgu.0.rcgu.o -L/usr/lib/emscripten/system/local/lib -L/usr/lib/emscripten/system/lib test.2h4nzeicjcod1ad3.rcgu.o -L/home/$USER/.emscripten_cache/wasm-pic -L/home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libstd-d69e7237ec2ec907.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libpanic_unwind-cf6146279e321a86.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_demangle-30de99a0feadb118.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libhashbrown-744fdda8cec61518.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_alloc-1bd061abaa6299ee.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libunwind-790ede63273b678e.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcfg_if-33e32972cf91da62.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liblibc-455b1f1bdddd2493.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc-38821dae73c49cdd.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_core-f752c0f2f8e113a2.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-79c24dc82f9ff182.rlib /home/$USER/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcompiler_builtins-da221c4cef139dc0.rlib /home/$USER/.emscripten_cache/wasm-pic/libc.a --fatal-warnings --no-whole-archive -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --strip-debug --no-gc-sections --export-dynamic --export-all --experimental-pic -shared' failed (1)
@hoodmane
Copy link
Contributor

As an update, the solution to this is to use -sSIDE_MODULE=2. If you also want everything to be exported, you could try -sSIDE_MODULE=2 -sEXPORT_ALL.

@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@jieyouxu jieyouxu added O-wasm Target: WASM (WebAssembly), http://webassembly.org/ and removed needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. labels Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

No branches or pull requests

4 participants