Rustup beta/nightly linker error on Windows 10


#1

Hey all,
Basic question.

I installed rustup and instead of the suggested default install I started with stable-x86_64-pc_windows-gnu (or however the tripple goes).

Then I ran rustup and installed beta and nightly (also 64-bit gnu). No errors.

I did “cargo new hello --bin”, “cd hello”, “cargo run”. Got the hello world, no errors.

Then I did “rustup default beta-gnu” and it said it was using the existing beta.
I did “cargo run” and got this:

C:\Users\jerem\Documents\projects\rust\hello>rustup default beta
info: using existing install for 'beta-x86_64-pc-windows-gnu’
info: default toolchain set to ‘beta-x86_64-pc-windows-gnu’

beta-x86_64-pc-windows-gnu unchanged - rustc 1.19.0-beta.1 (a87984118 2017-06-06)

C:\Users\jerem\Documents\projects\rust\hello>cargo run
Compiling hello v0.1.0 (file:///C:/Users/jerem/Documents/projects/rust/hello)
error: could not exec the linker gcc: The system cannot find the file specified. (os error 2)
|
= note: “gcc” “-Wl,–enable-long-section-names” “-fno-use-linker-plugin” “-Wl,–nxcompat” “-nostdlib” “-m64” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsbegin.o” “-L” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib” “C:\Users\jerem\Documents\projects\rust\hello\target\debug\deps\hello-e6b0664317cff6fb.0.o” “-o” “C:\Users\jerem\Documents\projects\rust\hello\target\debug\deps\hello-e6b0664317cff6fb.exe” “-Wl,–gc-sections” “-nodefaultlibs” “-L” “C:\Users\jerem\Documents\projects\rust\hello\target\debug\deps” “-L” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib” “-Wl,-Bstatic” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-5a958d157a8d8d98.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librand-ce86047000b56785.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcollections-b8b9a576d130e244.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd_unicode-9fbe5d3bbc85c563.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-14e8bb7ca07ebf2c.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libunwind-a4bc20050f473f79.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liblibc-892bd58ec617c3bd.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc-b9c9173c47c20c41.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc_system-141f235246f01712.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcore-3a6338503b91076c.rlib” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcompiler_builtins-e9e280acad4314a4.rlib” “-Wl,-Bdynamic” “-l” “advapi32” “-l” “ws2_32” “-l” “userenv” “-l” “shell32” “-Wl,-Bstatic” “-l” “gcc_eh” “-l” “pthread” “-Wl,-Bdynamic” “-lmingwex” “-lmingw32” “-lgcc” “-lmsvcrt” “-luser32” “-lkernel32” “C:\Users\jerem\.rustup\toolchains\beta-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsend.o”

error: aborting due to previous error(s)

error: Could not compile hello.

To learn more, run the command again with --verbose.

Switched to nightly and got the same thing. I made another hello project with nightly as the default and it had the same problem.

Here is the output when I originally installed the beta:

C:\Users\jerem>rustup install beta-gnu
info: syncing channel updates for 'beta-x86_64-pc-windows-gnu’
info: downloading component 'rustc’
46.5 MiB / 46.5 MiB (100 %) 448.0 KiB/s ETA: 0 s
info: downloading component 'rust-std’
68.8 MiB / 68.8 MiB (100 %) 448.0 KiB/s ETA: 0 s
info: downloading component 'cargo’
4.3 MiB / 4.3 MiB (100 %) 448.0 KiB/s ETA: 0 s
info: downloading component 'rust-docs’
12.4 MiB / 12.4 MiB (100 %) 444.8 KiB/s ETA: 0 s
info: downloading component 'rust-mingw’
7.9 MiB / 7.9 MiB (100 %) 448.0 KiB/s ETA: 0 s
info: installing component 'rustc’
info: installing component 'rust-std’
info: installing component 'cargo’
info: installing component 'rust-docs’
info: installing component ‘rust-mingw’

beta-x86_64-pc-windows-gnu installed - rustc 1.19.0-beta.1 (a87984118 2017-06-06)

Am I missing something?


#2

Did you try the msvc target? Windows doesn’t have gcc you will need mingw or msys2 for it.


#3

The rust-mingw component exists just to provide gcc, which the log above does show.


#4

My question is why would I have to do that for beta and nightly but not for stable?


#5

This seems like a regression in Windows/MinGW that was in nightly for at least 3 days.
I notified the infrastructure team on IRC.

Ping @brson, @alexcrichton, @frewsxcv, @shepmaster, @aidanhs, @TimNN, @carols10cents, @Mark_Simulacrum, @erickt, @aturon


#6

https://github.com/rust-lang/rust/issues/42422 is the relevant issue, which should be fixed either on the current or next nightly (probably next). It will eventually get a beta backport as well and then beta should resume working.


#7

This is now fixed on the latest nightly.
@JeremySorensen you can try that again after running rustup update