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

Emscripten target broken on win32 with 1.20.0 release #44443

Closed
vvanders opened this issue Sep 9, 2017 · 9 comments
Closed

Emscripten target broken on win32 with 1.20.0 release #44443

vvanders opened this issue Sep 9, 2017 · 9 comments
Labels
P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@vvanders
Copy link
Contributor

vvanders commented Sep 9, 2017

It looks like the recent change in how Command executes batch files(see rust-lang/cc-rs#239 for details) has also caused the emscripten target to regress and fail to compile on win32.

I'm also seeing the libc::c_char type change from *const i8 to *const u8 which is causing problems with a bunch of C bindings I have.

Below example works fine when I switch back to 1.19.0.

I tried this code:
https:/vvanders/rust_command_repro

I expected to see this happen: Successful compile

Instead, this happened:

C:\dev\command_repro>cargo build --release --target=asmjs-unknown-emscripten
   Compiling command_repro v0.1.0 (file:///C:/dev/command_repro)
error: linking with `emcc.bat` failed: exit code: 2
  |
  = note: "emcc.bat" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib" "C:\\dev\\command_repro\\target\\asmjs-unknown-emscripten\\release\\deps\\command_repro-0b0fbd0388217b85.0.o" "-o" "C:\\dev\\command_repro\\target\\asmjs-unknown-emscripten\\release\\deps\\command_repro-0b0fbd0388217b85.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"___rdl_shrink_in_place\",\"___rdl_alloc_excess\",\"___rdl_usable_size\",\"___rdl_alloc\",\"___rdl_realloc_excess\",\"___rdl_realloc\",\"___rdl_oom\",\"___rdl_grow_in_place\",\"___rdl_alloc_zeroed\",\"___rdl_dealloc\",\"_rust_eh_personality\"]" "C:\\dev\\command_repro\\target\\asmjs-unknown-emscripten\\release\\deps\\command_repro-0b0fbd0388217b85.crate.allocator.o" "-O3" "--memory-init-file" "0" "-g0" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "C:\\dev\\command_repro\\target\\asmjs-unknown-emscripten\\release\\deps" "-L" "C:\\dev\\command_repro\\target\\release\\deps" "-L" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\libstd-881b9fdbdf1d515b.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\liballoc_system-3c10208cdd7e61cb.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\librand-32f648f7f7567c6c.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\libpanic_unwind-9cbadc6554202be9.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\liballoc-bc70b4efeaeb398c.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\libstd_unicode-a0ad42dc8f5856aa.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\libunwind-618c266cf9124966.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\liblibc-16f3b02b9a976b94.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\libcore-21491ce3d14f1ef2.rlib" "C:\\Users\\valer\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\asmjs-unknown-emscripten\\lib\\libcompiler_builtins-b9713bd7f605c0b2.rlib" "-l" "c" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1"
  = note: python: can't open file 'C:\dev\command_repro\\emcc': [Errno 2] No such file or directory

Meta

rustc --version --verbose:
C:\dev\command_repro>rustc --version --verbose
rustc 1.20.0 (f3d6973 2017-08-27)
binary: rustc
commit-hash: f3d6973
commit-date: 2017-08-27
host: x86_64-pc-windows-msvc
release: 1.20.0
LLVM version: 4.0

@krampenschiesser
Copy link

Got the same issue here :(

@alexcrichton
Copy link
Member

Thanks for opening this up @vvanders!

Could you test out a possible solution for this? If you use -C linker to override the linker used here, does this program work?

use std::env;
use std::process::{self, Command};

fn main() {
    let status = Command::new("cmd")
        .arg("/c")
        .arg("emcc.bat")
        .args(&env::args().skip(1).collect::<Vec<_>>())
        .status()
        .expect("failed to spawn `cmd`");
    process::exit(status.code().unwrap());
}

My hope is that we just need to do cmd /c emcc.bat rather than emcc.bat, but that'd help confirm the fix!

@vvanders
Copy link
Contributor Author

Hey @alexcrichton, can you explain down to use -C linker flag in a bit more detail? I'm not totally following the steps you listed out above.

@alexcrichton
Copy link
Member

Oh sure yeah, so ideally you could do:

# Compile the program in the comment above
$ rustc foo.rs -o foo.exe

# Compile a "hello world"
$ rustc hello.rs --target asmjs-unknown-emscripten -C linker=./foo.exe

And see if that works?

@vvanders
Copy link
Contributor Author

Yup, that appears to work. I'll look into the libc changes on the other issue but this should address things on Win32.

@alexcrichton
Copy link
Member

Ok excellent! I'll prepare a PR for this

@alexcrichton alexcrichton added P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 13, 2017
@alexcrichton
Copy link
Member

Ok I've opened a PR for this change at #44542

I've also nominated that for beta to make sure we fix this in 1.21

@alexcrichton
Copy link
Member

In the meantime I've also tagged this as a stable regression, but it should be fixed by the PR above

@alexcrichton alexcrichton added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Sep 13, 2017
@alexcrichton alexcrichton added this to the 1.21 milestone Sep 13, 2017
@alexcrichton
Copy link
Member

Beta backported in #44357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants