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

wasm32-unknown-emscripten target not working #817

Closed
semtexzv opened this issue Sep 30, 2018 · 10 comments
Closed

wasm32-unknown-emscripten target not working #817

semtexzv opened this issue Sep 30, 2018 · 10 comments

Comments

@semtexzv
Copy link

Package can't be compiled for "wasm32-unknown-unknown" target. Even compiling the tests fails with "corrupted double-linked list" error during linking using llc.

Command to reproduce:
cargo web test --target=wasm32-unknown-emscripten

This is probably caused by some low-level bit manipulation code somewhere in the library.

@tomaka
Copy link
Contributor

tomaka commented Sep 30, 2018

What is the error message that you're getting?

@semtexzv
Copy link
Author

Multiple ones,
corrupted double-linked list
corrupted size vs. prev_size
double free or corruption (!prev)

Seems there is some kind of memory access pattern in gray_to_luma8 function, that confuses some tool in emscripten toolchain. #818 seems to get the crate compiling on this target.

@HeroicKatora
Copy link
Member

What does cargo web test do, it is not a standard command.

@tomaka
Copy link
Contributor

tomaka commented Sep 30, 2018

Multiple ones,
corrupted double-linked list
corrupted size vs. prev_size
double free or corruption (!prev)

Seems there is some kind of memory access pattern in gray_to_luma8 function, that confuses some tool in emscripten toolchain. #818 seems to get the crate compiling on this target.

Can you paste the exact message? We have no idea what produces these messages.

@philipc
Copy link
Contributor

philipc commented Oct 1, 2018

https://travis-ci.org/stevebob/gfx/jobs/429755777 has a failure message from running docker exec -it emscripten cargo test --all --target=asmjs-unknown-emscripten:

*** Error in `/emsdk_portable/llvm/clang/bin/llc': corrupted double-linked list: 0x0000000003148920 ***
*** Error in `/emsdk_portable/llvm/clang/bin/llc': corrupted double-linked list: 0x0000000003f6c780 ***

cargo-web is a cargo subcommand that makes it easy to build and run for emscripten. I've run this a few times though, and the tests have always compiled successfully. I tried both asmjs and wasm32.

@semtexzv #818 isn't an appropriate fix. Why do you think low level bit manipulation is the problem? Is this a known problem with emscripten? Why would this cause errors in llc? Do you have any links with info about this?

@semtexzv
Copy link
Author

semtexzv commented Oct 1, 2018

Running "cargo test --target=asmjs-unknown-emscripten"
results in following error:

... Multiple repeated warnings like this
WARNING:root:object /tmp/emscripten_temp_zkyi_kyn_archive_contents/compiler_builtins-eb5df2804a31c9b8.compiler_builtins.22h4jw28-cgu.8.rcgu.bc.z is not valid according to llvm-nm, cannot link
WARNING:root:object /tmp/emscripten_temp_zkyi_kyn_archive_contents/compiler_builtins-eb5df2804a31c9b8.compiler_builtins.22h4jw28-cgu.9.rcgu.bc.z is not valid according to llvm-nm, cannot link
          corrupted double-linked list                                                                                                                                                         
          Traceback (most recent call last):                                                                                                                                                   
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emcc.py", line 3062, in <module>                                                                                                     
              sys.exit(run())                                                                                                                                                                  
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emcc.py", line 1778, in run                                                                                                          
              final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)                                                                                               
            File "/home/semtexzv/emsdk/emscripten/1.38.12/tools/shared.py", line 2268, in emscripten                                                                                           
              emscripten._main(cmdline)                                                                                                                                                        
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emscripten.py", line 2228, in _main                                                                                                  
              return temp_files.run_and_clean(lambda: main(                                                                                                                                    
            File "/home/semtexzv/emsdk/emscripten/1.38.12/tools/tempfiles.py", line 93, in run_and_clean                                                                                       
              return func()                                                                                                                                                                    
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emscripten.py", line 2233, in <lambda>                                                                                               
              DEBUG=DEBUG,                                                                                                                                                                     
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emscripten.py", line 2159, in main                                                                                                   
              temp_files=temp_files, DEBUG=DEBUG)                                                                                                                                              
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emscripten.py", line 81, in emscript                                                                                                 
              backend_output = compile_js(infile, temp_files, DEBUG)                                                                                                                           
            File "/home/semtexzv/emsdk/emscripten/1.38.12/emscripten.py", line 110, in compile_js                                                                                              
              jsrun.timeout_run(subprocess.Popen(backend_args, stdout=subprocess.PIPE, universal_newlines=True), note_args=backend_args)                                                       
            File "/home/semtexzv/emsdk/emscripten/1.38.12/tools/jsrun.py", line 20, in timeout_run                                                                                             
              raise Exception('Subprocess "' + ' '.join(note_args) + '" failed with exit code ' + str(proc.returncode) + '!')                                                                  
          Exception: Subprocess "/home/semtexzv/emsdk/clang/e1.38.12_64bit/llc /tmp/tmpv0m12f1v/scaledown-3ad8c81761a28695.bc -march=js -filetype=asm -o /tmp/tmpliuka_l0.4.js -emscripten-stack-size=5242880 -O0 -emscripten-assertions=1 -emscripten-no-aliasing-function-pointers -emscripten-global-base=8 -enable-emscripten-cpp-exceptions -emscripten-no-exit-runtime" failed with exit code -6!

Running this command on #818 correctly builds the crate and generates .js files for tests, even though cargo can't run these on it's own.

The result is the same when running "cargo test --target=asmjs-unknown-emscripten"

@philipc I know it isn't an appropriate fix, but at least crate is compilling, and we know where the issue is.

@tomaka
Copy link
Contributor

tomaka commented Oct 1, 2018

rust-lang/rust#54312

@philipc
Copy link
Contributor

philipc commented Oct 1, 2018

No, we don't know where issue is, because I could run the test successfully. However, updating my rust from 1.28.0 to 1.29.1 caused the problem to start occurring. Can you try rust 1.28?

I think this needs to be fixed in rust, not by rewriting gray_to_luma8. Even if the problem can be worked around by rewriting gray_to_luma8, I can't rewrite it without knowing what the problem is that I'm meant to be avoiding. That's why I asked for more info about why you think it is due to low level bit manipulation.

Also, this kind of problem has happened before for gfx: rust-lang/rust#47023

@acidicX
Copy link

acidicX commented Mar 7, 2019

I can compile it with 1.35 nightly.

@semtexzv
Copy link
Author

Solved a long time ago, this issue was forgotten. Closing.

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

Successfully merging a pull request may close this issue.

5 participants