-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[Emscripten] fail rustc by #4 0x000055cd94ae00ce lld::wasm::(anonymous namespace)::Writer::run() Writer.cpp:0:0
#117352
Comments
@rustbot label A-linkage O-wasm |
This looks like an exact duplicate of #116655, which you say you're using nightly to avoid? I do not understand. |
|
Did you use LTO during the building process? If so, I think you might be impacted by llvm/llvm-project#62243. |
This is a debug build with LTO disabled according to the rustc arguments shown in the log. |
Reduced to: Details$ curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --target wasm32-unknown-emscripten --default-toolchain nightly-2023-11-08 --component rust-src
$ source "$HOME/.cargo/env"
$ cargo new foo
$ cd foo/
$ cat <<EOT > src/main.rs
use ort::OrtResult;
fn main() -> OrtResult<()> {
Ok(())
}
EOT
$ cat <<EOT >> Cargo.toml
ort = { git = "https://github.com/pykeio/ort.git", branch = "1.15", default-features = false }
EOT
$ git clone --recursive https://github.com/Microsoft/onnxruntime
$ cd onnxruntime/
$ ./build.sh --config Release --build_wasm_static_lib --skip_tests --disable_wasm_exception_catching --disable_rtti
$ cd ../
$ export ORT_LIB_LOCATION="$PWD/onnxruntime/build/Linux/Release"
$ cargo build --release -Zbuild-std=panic_abort,std --target wasm32-unknown-emscripten
...
Compiling ort v1.15.5 (https://github.com/pykeio/ort.git?branch=1.15#bca00dc9)
Compiling foo v0.1.0 (/home/kleisauke/foo)
error: linking with `emcc` failed: exit status: 1
...
#0 0x00005584dd0621f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0xf4e1f8)
#1 0x00005584dd05f82e llvm::sys::RunSignalHandlers() (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0xf4b82e)
#2 0x00005584dd062e35 SignalHandler(int) Signals.cpp:0:0
#3 0x00007f33d603b9a0 __restore_rt (/lib64/libc.so.6+0x3e9a0)
#4 0x00005584dd46782e lld::wasm::(anonymous namespace)::Writer::run() Writer.cpp:0:0
#5 0x00005584dd45c5c8 lld::wasm::writeResult() (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0x13485c8)
#6 0x00005584dd435eb3 lld::wasm::(anonymous namespace)::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) Driver.cpp:0:0
#7 0x00005584dd431b0c lld::wasm::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0x131db0c)
#8 0x00005584dd064ffe lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0xf50ffe)
#9 0x00005584dcfad1c2 lld_main(int, char**, llvm::ToolContext const&) (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0xe991c2)
#10 0x00005584dcfad8bc main (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0xe998bc)
#11 0x00007f33d602514a __libc_start_call_main (/lib64/libc.so.6+0x2814a)
#12 0x00007f33d602520b __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2820b)
#13 0x00005584dcf230ea _start (/home/kleisauke/emsdk/upstream/bin/wasm-ld+0xe0f0ea)
...
error: could not compile `foo` (bin "foo") due to previous error
$ echo $?
101 So, it looks like you're indeed impacted by llvm/llvm-project#62243 as If you disable that, everything works properly again, for example: --- a/cmake/adjust_global_compile_flags.cmake
+++ b/cmake/adjust_global_compile_flags.cmake
@@ -21,7 +21,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_UNIMPLEMENTED_SYSCALLS=1")
# Enable LTO for release single-thread build
- if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+ if (FALSE)
# NOTES:
# (1) LTO does not work for WebAssembly multi-thread. (segment fault in worker)
# (2) "-flto=thin" does not work correctly for wasm-ld. $ cd onnxruntime/
$ rm -rf build/
$ sed -i '0,/NOT CMAKE_BUILD_TYPE STREQUAL "Debug"/s//FALSE/' cmake/adjust_global_compile_flags.cmake
$ ./build.sh --config Release --build_wasm_static_lib --skip_tests --disable_wasm_exception_catching --disable_rtti
$ cd ../
$ cargo clean
$ cargo build --release -Zbuild-std=panic_abort,std --target wasm32-unknown-emscripten
...
Compiling ort v1.15.5 (https://github.com/pykeio/ort.git?branch=1.15#bca00dc9)
Compiling foo v0.1.0 (/home/kleisauke/foo)
Finished release [optimized] target(s) in 10.65s
$ echo $?
0
$ node target/wasm32-unknown-emscripten/release/foo.js
$ echo $?
0 |
This should be fixed in Emscripten 3.1.50, see: llvm/llvm-project#73095. |
I tried this code:
Instead, this happened: compilation failed
Meta
rustc --version --verbose
:I'm using nightly because avoid #116655
Backtrace
RUST_BACKTRACE=1 cargo test --target wasm32-unknown-emscripten -v
The text was updated successfully, but these errors were encountered: