Skip to content

Emscripten target broken on win32 with 1.20.0 release #44443

Closed

Description

@vvanders

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://github.com/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

Activity

  1. krampenschiesser commented on Sep 10, 2017

    @krampenschiesser
    Contributor

    Got the same issue here :(

  2. alexcrichton commented on Sep 11, 2017

    @alexcrichton
    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!

  3. vvanders commented on Sep 13, 2017

    @vvanders
    ContributorAuthor

    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.

  4. alexcrichton commented on Sep 13, 2017

    @alexcrichton
    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?

  5. vvanders commented on Sep 13, 2017

    @vvanders
    ContributorAuthor

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

  6. alexcrichton commented on Sep 13, 2017

    @alexcrichton
    Member

    Ok excellent! I'll prepare a PR for this

  7. added
    P-medium
    regression-from-stable-to-beta
    T-compiler
    on Sep 13, 2017
  8. alexcrichton commented on Sep 13, 2017

    @alexcrichton
    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

  9. alexcrichton commented on Sep 13, 2017

    @alexcrichton
    Member

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

  10. added
    regression-from-stable-to-stable
    and removed
    regression-from-stable-to-beta
    on Sep 13, 2017
  11. added this to the 1.21 milestone on Sep 13, 2017
  12. alexcrichton commented on Sep 15, 2017

    @alexcrichton
    Member

    Beta backported in #44357

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumT-compilerregression-from-stable-to-stable

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions