brson/multirust

MSYS2. rustc cannot link binaries. -- could not exec the linker `gcc`: Access is denied. (os error 5)

jClaireCodesStuff opened this issue · 2 comments

A binary linking to SDL2 fails

$ multirust run stable cargo run -j1 --verbose
multirust: checking metadata version
multirust: got metadata version 2
   Compiling libc v0.2.10
     Running `rustc E:/home/.multirust/toolchains/stable/cargo\\registry\\src\\github.com-88ac128001ac3a9a\\libc-0.2.10\\src\\lib.rs --crate-name libc --crate-type lib -g --cfg feature=\"use_std\" --cfg feature=\"default\" -C metadata=12d5d911cf5411c3 -C extra-filename=-12d5d911cf5411c3 --out-dir E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --cap-lints allow`
   Compiling rustc-serialize v0.3.19
     Running `rustc E:/home/.multirust/toolchains/stable/cargo\\registry\\src\\github.com-88ac128001ac3a9a\\rustc-serialize-0.3.19\\src\\lib.rs --crate-name rustc_serialize --crate-type lib -g -C metadata=d9e72695d437325f -C extra-filename=-d9e72695d437325f --out-dir E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --cap-lints allow`
   Compiling rand v0.3.14
     Running `rustc E:/home/.multirust/toolchains/stable/cargo\\registry\\src\\github.com-88ac128001ac3a9a\\rand-0.3.14\\src\\lib.rs --crate-name rand --crate-type lib -g -C metadata=6fab17fc670a2bc8 -C extra-filename=-6fab17fc670a2bc8 --out-dir E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --extern libc=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps\\liblibc-12d5d911cf5411c3.rlib --cap-lints allow`
   Compiling lazy_static v0.1.16
     Running `rustc E:/home/.multirust/toolchains/stable/cargo\\registry\\src\\github.com-88ac128001ac3a9a\\lazy_static-0.1.16\\src\\lib.rs --crate-name lazy_static --crate-type lib -g -C metadata=e69e55dcc7527931 -C extra-filename=-e69e55dcc7527931 --out-dir E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --cap-lints allow`
   Compiling sdl2-sys v0.8.1
     Running `rustc E:/home/.multirust/toolchains/stable/cargo\\registry\\src\\github.com-88ac128001ac3a9a\\sdl2-sys-0.8.1\\build.rs --crate-name build_script_build --crate-type bin -g --cfg feature=\"default\" --out-dir E:\\home\\rst_prj\\bnoise\\target\\debug\\build\\sdl2-sys-7d2af11caee603cd --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps -L dependency=E:\\home\\rst_prj\\bnoise\\target\\debug\\deps --cap-lints allow`
error: could not exec the linker `gcc`: Access is denied. (os error 5)
Could not compile `sdl2-sys`.

Caused by:
  Process didn't exit successfully: `rustc E:/home/.multirust/toolchains/stable/cargo\registry\src\github.com-88ac128001ac3a9a\sdl2-sys-0.8.1\build.rs --crate-name build_script_build --crate-type bin -g --cfg feature="default" --out-dir E:\home\rst_prj\bnoise\target\debug\build\sdl2-sys-7d2af11caee603cd --emit=dep-info,link -L dependency=E:\home\rst_prj\bnoise\target\debug\deps -L dependency=E:\home\rst_prj\bnoise\target\debug\deps --cap-lints allow` (exit code: 101)

building a pure Rust library succeeds:

$ multirust run nightly cargo build -j1 --verbose
multirust: checking metadata version
multirust: got metadata version 2
   Compiling scratchpad v0.1.0 (file:///E:/home/rst_prj/scratchpad)
     Running `rustc src\\lib.rs --crate-name scratchpad --crate-type lib -g --out-dir E:\\home\\rst_prj\\scratchpad\\target\\debug --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\scratchpad\\target\\debug -L dependency=E:\\home\\rst_prj\\scratchpad\\target\\debug\\deps`
src\lib.rs:1:12: 1:16 warning: unused or unknown feature, #[warn(unused_features)] on by default
src\lib.rs:1 #![feature(test)]

But running its tests does not.

$ multirust run nightly cargo test -j1 --verbose
multirust: checking metadata version
multirust: got metadata version 2
   Compiling scratchpad v0.1.0 (file:///E:/home/rst_prj/scratchpad)
     Running `rustc src\\lib.rs --crate-name scratchpad --crate-type lib -g --test -C metadata=7603f6f9c621acdf -C extra-filename=-7603f6f9c621acdf --out-dir E:\\home\\rst_prj\\scratchpad\\target\\debug --emit=dep-info,link -L dependency=E:\\home\\rst_prj\\scratchpad\\target\\debug -L dependency=E:\\home\\rst_prj\\scratchpad\\target\\debug\\deps`
error: could not exec the linker `gcc`: Access is denied. (os error 5)
error: Could not compile `scratchpad`.

Caused by:
  Process didn't exit successfully: `rustc src\lib.rs --crate-name scratchpad --crate-type lib -g --test -C metadata=7603f6f9c621acdf -C extra-filename=-7603f6f9c621acdf --out-dir E:\home\rst_prj\scratchpad\target\debug --emit=dep-info,link -L dependency=E:\home\rst_prj\scratchpad\target\debug -L dependency=E:\home\rst_prj\scratchpad\target\debug\deps` (exit code: 101)

gcc runs from the command line

$ gcc --version
gcc.exe (Rev5, Built by MSYS2 project) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.

Both stable and nightly seem to be affected the same way.

Since there may be something funky in my path...

$ echo $PATH
/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

The *-windows-gnu binaries of Rust contains their own version of gcc.exe, that can be causing the problem.

For me i fixed this by setting permissions for folder "usr/local/lib/rustlib/x86_64-pc-windows-gnu/bin" using this command:

cd usr/local/lib/rustlib/x86_64-pc-windows-gnu/bin
TAKEOWN /F . /R && ICACLS . /inheritance:e /grant %USERNAME%:F /T