Latest nightly build of rustc, fresh installation of Empscripten, Windows 10, 64-bit.
Given this basic hello.rs:
fn main() { println!("Hello, Emscripten!"); }
This is what I get when I try to compile it with Emscripten:
C:\Users\me\AppData\Local\Temp>rustc --target=wasm32-unknown-emscripten hello.rs -C linker=emcc.bat
error: linking with `emcc.bat` failed: exit code: 1
|
= note: "emcc.bat" "-L" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib" "hello.0.o" "-o" "hello.js" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libstd-17342542cc541012.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librand-46ed9b788a6928f6.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcollections-e32369d7fef31fbf.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libstd_unicode-7f34decaf2f17f36.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libpanic_unwind-f78756b576499725.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libunwind-11f7709e0c71505b.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liballoc-24699c1ddb055eb0.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liballoc_system-3e467e865c8fa572.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liblibc-60365c932e50e382.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcore-d9873b515905cac5.rlib" "C:\\Users\\me\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcompiler_builtins-e428224f6caf212a.rlib" "-l" "c" "-s" "BINARYEN=1" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1"
= note: WARNING:root:Assigning a non-existent settings attribute "BINARYEN"
WARNING:root: - perhaps a typo in emcc's -s X=Y notation?
WARNING:root: - (see src/settings.js for valid values)
error: Unknown attribute kind (52)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Invalid type for value
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (52)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Invalid type for value
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (48)
error: Unknown attribute kind (52)
Traceback (most recent call last):
File "C:\Program Files\Emscripten\emscripten\1.35.0\\emcc", line 1309, in <module>
final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL)
File "C:\Program Files\Emscripten\emscripten\1.35.0\tools\shared.py", line 1471, in llvm_opt
assert os.path.exists(target), 'Failed to run llvm optimizations: ' + output
AssertionError: Failed to run llvm optimizations:
error: aborting due to previous error
/cc @kripken; not sure if this should be here or in https://github.com/kripken/emscripten.
One possibility is the emscripten version is too old. We actually just updated it yesterday, so that should fix it if that's the issue. You should see emcc -v say the version is 1.37.0.
Same error on portable Emscripten SDK for OS X.
@kripken you are right, emcc is 1.35.0
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.35.0
clang version 3.7.0 (https://github.com/kripken/emscripten-fastcomp-clang dbe68fecd03d6f646bd075963c3cc0e7130e5767) (https://github.com/kripken/emscripten-fastcomp 4e83be90903250ec5142edc57971ed4c633c5e25)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
INFO:root:(Emscripten: Running sanity checks)
is there a way to update emcc right from Portable SDK?
also I see 1.37.0 as latest but emsdk install latest installs 1.35.0
➜ emsdk_portable ./emsdk update
Downloading: /Users/Chico/c0d1n9/emsdk_portable/zips/emsdk_unix_update.tar.gz from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emsdk_unix_update.tar.gz
Unpacking '/Users/Chico/c0d1n9/emsdk_portable/zips/emsdk_unix_update.tar.gz' to '/Users/Chico/c0d1n9/emsdk_portable'
x emscripten-tags.txt
x emsdk
x emsdk_env.sh
x emsdk_manifest.json
x README.md
Fetching all tags from Emscripten Github repository...
Done. 87 tagged releases available, latest is 1.37.0.
➜ emsdk_portable ./emsdk install latest
Installing SDK 'sdk-1.35.0-64bit'..
Installing tool 'clang-e1.35.0-64bit'..
The contents of file 'emscripten-clang_e1.35.0.tar.gz' already exist in destination '/Users/Chico/c0d1n9/emsdk_portable/clang/e1.35.0_64bit', skipping.
Done installing tool 'clang-e1.35.0-64bit'.
Installing tool 'node-4.1.1-64bit'..
The contents of file 'node-v4.1.1-darwin-x64.tar.gz' already exist in destination '/Users/Chico/c0d1n9/emsdk_portable/node/4.1.1_64bit', skipping.
Done installing tool 'node-4.1.1-64bit'.
Installing tool 'emscripten-1.35.0'..
The contents of file 'emscripten-1.35.0.tar.gz' already exist in destination '/Users/Chico/c0d1n9/emsdk_portable/emscripten/1.35.0', skipping.
Done installing tool 'emscripten-1.35.0'.
Done installing SDK 'sdk-1.35.0-64bit'.
Strange, maybe a bug in the emsdk? cc @juj
Solution is emsdk install sdk-incoming-64bit. It will compile 1.37.0 from sources.
Heya
I can confirm there's a bug somehow in emsdk. Update says 1.37.1 is latest, but installing latest stays on 1.35.
PS hello_rust_emscripten> emsdk update
Downloading: C:/Program Files/Emscripten/zips/emsdk_windows_update.zip from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emsdk_windows_update.zip
Unpacking 'C:/Program Files/Emscripten/zips/emsdk_windows_update.zip' to 'C:/Program Files/Emscripten'
Fetching all tags from Emscripten Github repository...
Done. 88 tagged releases available, latest is 1.37.1.
PS hello_rust_emscripten> emsdk install latest
Installing SDK 'sdk-1.35.0-64bit'..
Installing tool 'clang-e1.35.0-64bit'..
The contents of file 'emscripten-clang_e1.35.0.zip' already exist in destination 'C:/Program Files/Emscripten/clang/e1.35.0_64bit', skipping.
Done installing tool 'clang-e1.35.0-64bit'.
Installing tool 'node-4.1.1-64bit'..
The contents of file 'node_4.1.1_64bit.zip' already exist in destination 'C:/Program Files/Emscripten/node/4.1.1_64bit', skipping.
Done installing tool 'node-4.1.1-64bit'.
Installing tool 'python-2.7.5.3-64bit'..
The contents of file 'python_2.7.5.3_64bit.zip' already exist in destination 'C:/Program Files/Emscripten/python/2.7.5.3_64bit', skipping.
Done installing tool 'python-2.7.5.3-64bit'.
Installing tool 'emscripten-1.35.0'..
The contents of file 'emscripten-1.35.0.zip' already exist in destination 'C:/Program Files/Emscripten/emscripten/1.35.0', skipping.
Done installing tool 'emscripten-1.35.0'.
Done installing SDK 'sdk-1.35.0-64bit'.
PS hello_rust_emscripten>
@sheldon there are no pre-built binaries for versions >1.35.0. Try emsdk install sdk-incoming-64bit instead. It will build 1.37.1 for you.
thanks, running it now, just wanted to let you know it's not just you 😄
@chicoxyzzy Thanks, that fixed issue for me on Windows.
Thanks for the help @kripken, @chicoxyzzy. Does upgrading emcc fix the issue for you @chris-morgan?
Seems like there's nothing to be done here Rust side.
I can confirm this worked perfectly for asmjs compilation. All good to close 👍
@chicoxyzzy Will there be prebuilt binaries for those versions in the future?
@NeoLegends IDK. AFAIK @juj is maintainer of emsdk
I'm getting a similar error:
error: linking with 'emcc.bat' failed: exit code: 2
...
= note: python: can't open file 'c:CodeRusttesthello\emcc': [Errno 2] No such file or directory
New issue?
I can confirm there's a bug somehow in emsdk. Update says 1.37.1 is latest, but installing latest stays on 1.35.
This was a bug in emsdk updating mechanism, https://groups.google.com/d/msg/emscripten-discuss/bKCQxN6Q76Y/IsIw8LeXBgAJ
@chicoxyzzy Will there be prebuilt binaries for those versions in the future?
Emscripten SDK CI infrastructure does create precompiled binaries for all tagged versions, so you should see even the latest versions there. You may need to reinstall emsdk from scratch to resolve the bug linked to above.
= note: python: can't open file 'c:CodeRusttesthelloemcc': [Errno 2] No such file or directory
If this is coming from the line that emcc.bat is crafting, then that path looks wrong. emcc.bat refers to python "%~dp0\emcc" %* (see https://github.com/kripken/emscripten/blob/master/emcc.bat), and there %~dp0 should expand to the directory where emcc.bat lives in, and not the location where the code being compiled lives in. 'c:\Code\Rust\test\hello' looks like a project source directory, rather than Emscripten installation directory.
Thanks for the insights, juj. I altered emcc.bat to explicitly locate emcc:
@echo off
python "C:\emsdk\emscripten\incoming\emcc" %*
and, although it's no longer portable, I was able to compile to WASM for the first time. grin
I'm still getting an error in the javascript console, but this is progress.
Most helpful comment
@sheldon there are no pre-built binaries for versions >1.35.0. Try
emsdk install sdk-incoming-64bitinstead. It will build 1.37.1 for you.