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

Compilation error when using emscripten #10

Closed
dariost opened this issue Jan 16, 2020 · 4 comments
Closed

Compilation error when using emscripten #10

dariost opened this issue Jan 16, 2020 · 4 comments

Comments

@dariost
Copy link

dariost commented Jan 16, 2020

Trying to compile this crate using asmjs-unknown-emscripten or wasm32-unknown-emscripten as targets results in the following error:

$ cargo build --target=asmjs-unknown-emscripten
   Compiling adler32 v1.0.4 (/tmp/adler32-rs)
Referencing function in another module!
  call void <badref>(i8* %22), !dbg !35
; ModuleID = '3nlanbjp406orsjk'
void (i8*)* <badref>
; ModuleID = '
error: could not compile `adler32`.

Caused by:
  process didn't exit successfully: `rustc --crate-name adler32 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=cf98768c19d4c01d -C extra-filename=-cf98768c19d4c01d --out-dir /tmp/adler32-rs/target/asmjs-unknown-emscripten/debug/deps --target asmjs-unknown-emscripten -C incremental=/tmp/adler32-rs/target/asmjs-unknown-emscripten/debug/incremental -L dependency=/tmp/adler32-rs/target/asmjs-unknown-emscripten/debug/deps -L dependency=/tmp/adler32-rs/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)```
@remram44
Copy link
Owner

It's hard to tell what the problem is from this error. It works on my simple tests, using both asmjs-unknown-emscripten and wasm32-unknown-emscripten.

What kind of Read object are you passing it?

My test

src/main.rs:

extern crate adler32;

use std::io::Cursor;

fn main() {
    let data = b"abcdefghijklmnopqrstuvwxyz";
    println!("{:x}", adler32::adler32(Cursor::new(data)).unwrap());
}

Cargo.toml:

[package]
name = "testadler32"
version = "0.1.0"
authors = ["Remi Rampin <[email protected]>"]

[dependencies]
adler32 = "1.0.4"
$ cargo web deploy --target asmjs-unknown-emscripten

In browser console, see 90860b20

@dariost
Copy link
Author

dariost commented Jan 16, 2020

What kind of Read object are you passing it?

I was just trying to compile this crate without any main function, but trying with the example you provided gives the same error:

$ cargo web deploy --target asmjs-unknown-emscripten
   Compiling adler32 v1.0.4
Referencing function in another module!
  call void <badref>(i8* %22), !dbg !35
; ModuleID = 'adler32.3rv277ty-cgu.3'
void (i8*)* <badref>
; ModuleID = '
error: could not compile `adler32`.

error: build failed

I don't know how to get a more verbose output, but I can at least give you the versions I am using:

$ rustc --version
rustc 1.40.0 (73528e339 2019-12-16)
$ cargo --version
cargo 1.40.0 (bc8e4c8be 2019-11-22)
$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.39.6 ((unknown revision))
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ lsb_release -a
LSB Version:	1.4
Distributor ID:	Arch
Description:	Arch Linux
Release:	rolling
Codename:	n/a

@remram44
Copy link
Owner

A web search brings up some LLVM-related issues? I don't know enough about emscripten to track this down, sorry. You might have some luck trying different versions (I'm using rustc 1.39.0 and emscripten 1.38.19).

@dariost
Copy link
Author

dariost commented Jan 16, 2020

Turns out it's a LLVM bug, and it has been already addressed here: rust-lang/rust#66308

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

No branches or pull requests

2 participants