Emscripten Error - Could not create LLVM TargetMachine

So I've been really interested in trying out Emscripten in some way, and after hearing about the new compilation targets, I thought I'd try it out, but I've had a snag. I'm running this on a Windows 10.

I've followed the commands in the post linked above, but when I try to run:

rustc --target=asmjs-unknown-emscripten hello.rs

I get this error:

error: Could not create LLVM TargetMachine for triple: asmjs-unknown-emscripten: No available targets are compatible with this triple.

rustup show gives me:

installed targets for active toolchain


Similarly, when I run rustc --print target-list I do see asmjs-unknown-emscripten in the list. (But not wasm32-unknown-emscripten).

I don't know enough about this to know how to debug it or what to look for. Any advice or insight?

1 Like

I don't see this behavior on rustc 1.14.0 (e8a012324 2016-12-16) on Windows. The error you are seeing indicates that LLVM wasn't compiled with the JS backend, which is surprising. The combined symptoms you describe, an installed asmjs std package, a broken LLVM backend, and rustc reporting support for asmjs but not wasm32, are quite suspicious in aggregate. I can't think of anything that would explain it, but I'd first make sure you have rustc 1.14 or greater. The missing wasm32 support makes me think you could be on an old toolchain.

Even once you get it building, I'd temper my expectations as there are plenty of bugs.

Oh, that was it!

I already had Rust installed (1.12) before I installed rustup. So I just deleted that and now running with 1.15 I don't get this error.

I did run into this error next:


And after some fiddling with my PATH, I got it to work by manually writing out the command in the terminal (emcc -L .....). At least I think it's building. It's saying:

INFO:root:generating system library: libc.bc... (this will be cached in "C:\Users\Omar\.emscripten_cache\asmjs\libc.bc" for subsequent builds)

Thank you so much for the quick reply and pointing me in the right direction!

And I appreciate the warning. I'm mostly hoping to get the hello world to compile and get to a point where I can perhaps contribute reporting bugs and such!

Edit: It works!!!

1 Like