Skip to content

Could not verify LLVM version with Emscripten on NixOS #230

Description

@ThibaultLemaire

When trying to compile the minimal example from stdweb to emscripten target, I get the following error:

cargo web start --target=wasm32-unknown-emscripten

error: linking with `emcc` failed: exit code: 1
  |
  = note: "emcc" "-s" ...
  = note: CRITICAL:root:Could not verify LLVM version: [Errno 2] No such file or directory
          CRITICAL:root:fastcomp in use, but LLVM has not been built with the JavaScript backend as a target, llc reports:
          ===========================================================================
          (no targets could be identified: [Errno 2] No such file or directory)
          ===========================================================================
          CRITICAL:root:you can fall back to the older (pre-fastcomp) compiler core, although that is not recommended, see http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html
          INFO:root:(Emscripten: Running sanity checks)
          ERROR:root:failing sanity checks due to previous fastcomp failure

(some output elided)

My best guess is that emscripten can't find llvm (It should be discoverable at least through pkg-config).

Additionally, I noticed cargo-web downloaded its own version of emscripten.
I believe providing my own version of emscripten would solve the issue (from my system's packages), how can I do that?


Misc information:

❯ cargo web --version
cargo-web 0.6.26

❯ cargo --version
cargo 1.42.0-nightly (86134e766 2019-12-23)

❯ llc --version # This is from my system, I'm pretty sure it's not found
LLVM (http://llvm.org/):
  LLVM version 7.1.0
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge
...

❯ rustup target list
...
asmjs-unknown-emscripten (installed)
...
wasm32-unknown-emscripten (installed)
wasm32-unknown-unknown (installed)
...
x86_64-unknown-linux-gnu (installed)
...

❯ emcc --version # From my system, I don't think it was found by cargo-web
emcc (Emscripten gcc/clang-like replacement) 1.38.28 ((unknown revision))

❯ uname --all
Linux ... 4.19.91 #1-NixOS SMP Sat Dec 21 09:57:45 UTC 2019 x86_64 GNU/Linux

This error is the same regardless of what I try to compile. I gave the minimal example for illustration and reproducibility, but I can actually reproduce with any other example project and a few other projects.

Also of note is that the wasm32-unknown-unknown target successfully compiled for every example I tried.

Activity

  1. tanis2000 commented on Jan 8, 2020

    @tanis2000

    You can try to run cargo web build --use-system-emscripten to use your own emscripten version. It's in the help if you check cargo web build --help

  2. ThibaultLemaire commented on Jan 8, 2020

    @ThibaultLemaire
    Author

    Thank you, I was reading the source code as well and I just stumbled on that flag!

    I was thinking it should be more prominent in the docs (I don't know why I didn't think of checking the --help)

    I'll test that and post back here.

  3. ThibaultLemaire commented on Jan 8, 2020

    @ThibaultLemaire
    Author

    Well it's not the same error so that's progress I guess?

    ❯ cargo web build --use-system-emscripten --target=wasm32-unknown-emscripten --verbose
    ...
    error: linking with `emcc` failed: exit code: 1
      |
      = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.17qvp3wvy3ge36bp.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.29ezgwktcliapzds.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.2dixcyq2dznoqf6f.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.2e3sp2f5hdniw8dq.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.2stwxpje5swges4g.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.39faxkgwwrs762t7.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.3eb8m1razly0qf8f.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.3tzo732szfa65bgw.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.443gbpfb1fa8iu4a.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.5dl1mmeah6wfm5cu.rcgu.o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.c2srm2fuob3bb6p.rcgu.o" "-o" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/minimal.dbnavdkjs80i37r.rcgu.o" "-O0" "--memory-init-file" "0" "-g4" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps" "-L" "/home/user/dev/stdweb/examples/target/debug/deps" "-L" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libstdweb-7a6929fc6b0490d1.rlib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libdiscard-61ecf5c35989b1da.rlib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libstdweb_internal_runtime-6eee130e7adc7143.rlib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libserde_json-c735cd759ad596de.rlib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libryu-c64b79a8ce6acb24.rlib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libitoa-17a5036565265a53.rlib" "/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libserde-db64dd451a129519.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libstd-55787d58fb5ea6fe.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libpanic_unwind-f59a7a55c9d2b3e1.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libhashbrown-dfc95e57308ebe8f.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_alloc-69c81ff795157707.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libbacktrace-977f4d06be3c4d88.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_demangle-0bd9079b201eae64.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libunwind-d452119022cae4dc.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcfg_if-1cada331e1cd4d54.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liblibc-f5e8192cc8a59183.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc-b3d1e9d085a55269.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_core-c13c0ad8f20110e1.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-9f7cee0f9a15a27c.rlib" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcompiler_builtins-13394c9769210e34.rlib" "-l" "c" "-s" "NO_EXIT_RUNTIME=1" "-s" "ALLOW_MEMORY_GROWTH=1" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1" "-s" "ASSERTIONS=1" "-s" "ABORTING_MALLOC=0" "-Wl,--fatal-warnings"
      = note: shared:WARNING: object /run/user/1000/emscripten_temp_RyTEXP_archive_contents/stdweb-7a6929fc6b0490d1.11ivc8q9b1ak0uju.rcgu.o is not valid according to llvm-nm, cannot link
              shared:WARNING: object /run/user/1000/emscripten_temp_RyTEXP_archive_contents/stdweb-7a6929fc6b0490d1.11mnvucp52kumo9.rcgu.o is not valid according to llvm-nm, cannot link
    ...
    532 lines omitted
    ...
              shared:WARNING: object /run/user/1000/emscripten_temp_fQbSlr_archive_contents/compiler_builtins-13394c9769210e34.compiler_builtins.5m4is7s4-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
              shared:WARNING: object /run/user/1000/emscripten_temp_fQbSlr_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
              shared:WARNING: object /run/user/1000/emscripten_temp_fQbSlr_archive_contents/compiler_builtins-13394c9769210e34.compiler_builtins.5m4is7s4-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
              shared:ERROR: undefined exported function: "_main"
              
    
    error: could not compile `minimal`.
    
    Caused by:
      process didn't exit successfully: `rustc --crate-name minimal minimal/src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=618e83af52622a74 --out-dir /home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps --target wasm32-unknown-emscripten -C incremental=/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/incremental -L dependency=/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps -L dependency=/home/user/dev/stdweb/examples/target/debug/deps --extern stdweb=/home/user/dev/stdweb/examples/target/wasm32-unknown-emscripten/debug/deps/libstdweb-7a6929fc6b0490d1.rlib --cfg cargo_web -C link-arg=-s -C link-arg=NO_EXIT_RUNTIME=1 -C link-arg=-s -C link-arg=ALLOW_MEMORY_GROWTH=1` (exit code: 1)
    error: aborting due to previous error
    error: build failed
    
  4. elichai commented on Jan 9, 2020

    @elichai
    Contributor

    Same error for me. What's going on? did emcc bump the llvm version so it doesn't match anymore?

  5. ThibaultLemaire commented on Jan 9, 2020

    @ThibaultLemaire
    Author

    @elichai Are you sure it's the same error?

    If you're referring to the Could not verify LLVM version error, in my case I'm pretty sure it's not due to a specific version of LLVM not being found, but rather LLVM not being found at all.

  6. elichai commented on Jan 9, 2020

    @elichai
    Contributor

    Nope, Don't think it's the same anymore, sorry: #233

  7. ThibaultLemaire commented on Jan 9, 2020

    @ThibaultLemaire
    Author

    @elichai Actually, you were right! For my second error it's indeed the rust compiler >=1.40.0 that's at fault!

    I have successfully compiled the minimal example with version 1.39.0!

    For the record:

    ❯ cargo --version
    cargo 1.39.0 (1c6ec66d5 2019-09-30)
    
    ❯ cargo web start --use-system-emscripten --target=wasm32-unknown-emscripten
    ...
        Finished dev [unoptimized + debuginfo] target(s) in 1m 10s
    ...
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions