Skip to content

Nothing builds under latest nightly release on windows #25072

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

Closed
bryal opened this issue May 3, 2015 · 6 comments · Fixed by #25103 or #25134
Closed

Nothing builds under latest nightly release on windows #25072

bryal opened this issue May 3, 2015 · 6 comments · Fixed by #25103 or #25134
Labels
O-windows Operating system: Windows

Comments

@bryal
Copy link

bryal commented May 3, 2015

Whatever the code being compiled, ld complains about not finding crt2.o, crtbegin.o, and crtend.o, even though these files should all be found by GCC, and is so on beta.

E:\Dropbox\Program\Rust\test-rs
λ set PATH=C:/Program Files/Rust nightly/bin/

E:\Dropbox\Program\Rust\test-rs
λ rustc -V
rustc 1.1.0-nightly (c42c1e7a6 2015-05-02) (built 2015-05-02)

E:\Dropbox\Program\Rust\test-rs
λ echo fn main() { println!("test") } | rustc -
error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-libgcc" "-m64" "-L" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib" "-o" "rust_out.exe" "rust_out.o" "-Wl,--gc-sections" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c.rlib" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libcollections-4e7c5e5c.rlib" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\librustc_unicode-4e7c5e5c.rlib" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\librand-4e7c5e5c.rlib" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\liballoc-4e7c5e5c.rlib" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\liblibc-4e7c5e5c.rlib" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libcore-4e7c5e5c.rlib" "-L" "\\?\C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib" "-L" "E:\Dropbox\Program\Rust\test-rs\.rust\bin\x86_64-pc-windows-gnu" "-L" "E:\Dropbox\Program\Rust\test-rs\bin\x86_64-pc-windows-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-lws2_32" "-luserenv" "-lcompiler-rt"
note: ld: cannot find crt2.o: No such file or directory
ld: cannot find crtbegin.o: No such file or directory
ld: cannot find crtend.o: No such file or directory

error: aborting due to previous error

E:\Dropbox\Program\Rust\test-rs
λ set PATH=C:/Program Files/Rust beta/bin/

E:\Dropbox\Program\Rust\test-rs
λ rustc -V
rustc 1.0.0-beta.3 (5241bf9c3 2015-04-25) (built 2015-04-25)

E:\Dropbox\Program\Rust\test-rs
λ echo fn main() { println!("test") } | rustc -

E:\Dropbox\Program\Rust\test-rs
λ rust_out.exe
test

As can be seen in the log, the crt files are not found, even though the "-L" "C:\Program Files\Rust nightly\bin\rustlib\x86_64-pc-windows-gnu\lib" option is set for gcc, and the files do exist:

C:\Users\Johan
λ ls -l "C:/Program Files/Rust nightly/bin/rustlib/x86_64-pc-windows-gnu/lib/" | grep crt
-rw-r--r-- 1 Johan Users     5770 May  2 04:43 crt2.o
-rw-r--r-- 1 Johan Users      450 May  2 04:43 crtbegin.o
-rw-r--r-- 1 Johan Users      450 May  2 04:43 crtend.o
-rw-r--r-- 1 Johan Users     3473 May  2 04:43 dllcrt2.o
-rw-r--r-- 1 Johan Users   962194 May  2 04:43 libmsvcrt.a
-rw-r--r-- 1 Johan Users   418504 May  2 04:43 librpcrt4.a

I'm even more confused by the fact that everything works fine on rust beta, even though the setup is the same.

edit: I am running this with 64-bit versions of rust nightly and rust beta

@Diggsey
Copy link
Contributor

Diggsey commented May 3, 2015

I can reproduce this, but only if I invoke "rustc" from 32-bit versions of cygwin or msys2/mingw. If I run it via windows cmd, or the 64-bit versions it works fine.

edit:
I realised the problem: either windows or the terminal itself is rewriting "Program Files" to "Program Files (x86)" when in 32-bit mode, resulting in the object files not being found.

@tomaka
Copy link
Contributor

tomaka commented May 4, 2015

Appveyor builds of official crates have been failing because of this issue, for example: https://ci.appveyor.com/project/alexcrichton/time

It's a regression, as it used to work until last week or so: https://ci.appveyor.com/project/alexcrichton/time/history

alexcrichton added a commit to alexcrichton/rust that referenced this issue May 4, 2015
This was one last spot where directories were being leaked through with
arguments of the form `\\?\` which neither `ld.exe` nor `gcc.exe` does
understands so the prefix needed to be stripped.

Closes rust-lang#25072
bors added a commit that referenced this issue May 4, 2015
This was one last spot where directories were being leaked through with
arguments of the form `\\?\` which neither `ld.exe` nor `gcc.exe` does
understands so the prefix needed to be stripped.

Closes #25072
@RinCamelia
Copy link

Tested this issue on

rustc 1.1.0-nightly (435622028 2015-05-04) (built 2015-05-05)

and I still get the above reported issue with this project. Waiting for latest nightly build to test and see if it works there. My version of the error log:

$>cargo build
   Compiling unicode-segmentation v0.1.0
   Compiling rustc-serialize v0.3.14
   Compiling regex v0.1.30
   Compiling libc v0.1.6
   Compiling rand v0.3.8 (https://github.com/rust-lang/rand.git#93544850)
   Compiling word_generator v0.0.1
             (file:///C:/Users/Sean/Documents/Rust%20Projects/word_generator)
error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-libgcc" "-m64" "-L" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib" "-o" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\word_generator.exe" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\word_generator.o" "-Wl,--gc-sections" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\deps\librustc_serialize-9ef26f158d5284e0.rlib" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\deps\libunicode_segmentation-57da89e19b25ee00.rlib" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\deps\libregex-3bea3061fd389532.rlib" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\deps\librand-3b6646ffd596e899.rlib" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\deps\liblibc-9b7976990ae0dbd4.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libcollections-4e7c5e5c.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\librustc_unicode-4e7c5e5c.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\librand-4e7c5e5c.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\liballoc-4e7c5e5c.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\liblibc-4e7c5e5c.rlib" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libcore-4e7c5e5c.rlib" "-L" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug" "-L" "C:\Users\Sean\Documents\Rust Projects\word_generator\target\debug\deps" "-L" "C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib" "-L" "C:\Users\Sean\Documents\Rust Projects\word_generator\.rust\bin\x86_64-pc-windows-gnu" "-L" "C:\Users\Sean\Documents\Rust Projects\word_generator\bin\x86_64-pc-windows-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-                whole-archive" "-Wl,-Bdynamic" "-lws2_32" "-luserenv" "-lcompiler-rt"
note: ld: cannot find crt2.o: No such file or directory
ld: cannot find crtbegin.o: No such file or directory
ld: cannot find crtend.o: No such file or directory

error: aborting due to previous error
Could not compile `word_generator`.

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

@retep998
Copy link
Member

retep998 commented May 5, 2015

For the record I am using a locally built Rust and I do not get the error. Therefore this bug may be a symptom of the way the nightlies are being packaged.

Peter@Win81-SSD MINGW64 ~/word_generator
$ cargo build
    Updating git repository `https://github.com/rust-lang/rand.git`
 Downloading unicode-segmentation v0.1.0
   Compiling regex v0.1.30
   Compiling rustc-serialize v0.3.14
   Compiling unicode-segmentation v0.1.0
   Compiling libc v0.1.6
   Compiling rand v0.3.8 (https://github.com/rust-lang/rand.git#93544850)
   Compiling word_generator v0.0.1 (file:///C:/msys64/home/Peter/word_generator)

Peter@Win81-SSD MINGW64 ~/word_generator
$ rustc -vV
rustc 1.1.0-dev (31e3cb7c4 2015-05-05) (built 2015-05-05)
binary: rustc
commit-hash: 31e3cb7c4e8895fff23aa67e1cd6b58d798cdac4
commit-date: 2015-05-05
build-date: 2015-05-05
host: x86_64-pc-windows-gnu
release: 1.1.0-dev

@tomaka
Copy link
Contributor

tomaka commented May 5, 2015

@retep998 Maybe this doesn't happen if you have MinGW installed separately.

@retep998
Copy link
Member

retep998 commented May 5, 2015

Yep, it seems it is the bundled MinGW that is broken

C:\msys64\home\Peter\word_generator>cargo build
    Updating git repository `https://github.com/rust-lang/rand.git`
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading libc v0.1.6
 Downloading rustc-serialize v0.3.14
 Downloading unicode-segmentation v0.1.0
 Downloading regex v0.1.30
   Compiling unicode-segmentation v0.1.0
   Compiling rustc-serialize v0.3.14
   Compiling libc v0.1.6
   Compiling regex v0.1.30
   Compiling rand v0.3.8 (https://github.com/rust-lang/rand.git#93544850)
   Compiling word_generator v0.0.1 (file:///C:/msys64/home/Peter/word_generator)
error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-lib
gcc" "-m64" "-L" "C:\Rust64\bin\rustlib\x86_64-pc-windows-gnu\lib" "-o" "C:\msys64\home\Peter\word_g
enerator\target\debug\word_generator.exe" "C:\msys64\home\Peter\word_generator\target\debug\word_gen
erator.o" "-Wl,--gc-sections" "C:\msys64\home\Peter\word_generator\target\debug\deps\librustc_serial
ize-9ef26f158d5284e0.rlib" "C:\msys64\home\Peter\word_generator\target\debug\deps\libunicode_segment
ation-57da89e19b25ee00.rlib" "C:\msys64\home\Peter\word_generator\target\debug\deps\libregex-3bea306
1fd389532.rlib" "C:\msys64\home\Peter\word_generator\target\debug\deps\librand-3b6646ffd596e899.rlib
" "C:\msys64\home\Peter\word_generator\target\debug\deps\liblibc-9b7976990ae0dbd4.rlib" "C:\Rust64\b
in\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c.rlib" "C:\Rust64\bin\rustlib\x86_64-pc-windows-
gnu\lib\libcollections-4e7c5e5c.rlib" "C:\Rust64\bin\rustlib\x86_64-pc-windows-gnu\lib\librustc_unic
ode-4e7c5e5c.rlib" "C:\Rust64\bin\rustlib\x86_64-pc-windows-gnu\lib\librand-4e7c5e5c.rlib" "C:\Rust6
4\bin\rustlib\x86_64-pc-windows-gnu\lib\liballoc-4e7c5e5c.rlib" "C:\Rust64\bin\rustlib\x86_64-pc-win
dows-gnu\lib\liblibc-4e7c5e5c.rlib" "C:\Rust64\bin\rustlib\x86_64-pc-windows-gnu\lib\libcore-4e7c5e5
c.rlib" "-L" "C:\msys64\home\Peter\word_generator\target\debug" "-L" "C:\msys64\home\Peter\word_gene
rator\target\debug\deps" "-L" "C:\Rust64\bin\rustlib\x86_64-pc-windows-gnu\lib" "-L" "C:\msys64\home
\Peter\word_generator\.rust\bin\x86_64-pc-windows-gnu" "-L" "C:\msys64\home\Peter\word_generator\bin
\x86_64-pc-windows-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic
" "-lws2_32" "-luserenv" "-lcompiler-rt"
note: ld: cannot find crt2.o: No such file or directory
ld: cannot find crtbegin.o: No such file or directory
ld: cannot find crtend.o: No such file or directory

error: aborting due to previous error
Could not compile `word_generator`.

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

C:\msys64\home\Peter\word_generator>rustc -vV
rustc 1.1.0-nightly (435622028 2015-05-04) (built 2015-05-05)
binary: rustc
commit-hash: 435622028f37085819843f4ac8938557501f0468
commit-date: 2015-05-04
build-date: 2015-05-05
host: x86_64-pc-windows-gnu
release: 1.1.0-nightly

If I install that nightly with the bundled MinGW and invoke it from cmd.exe then it gets the error.
If I install that nightly without the bundled MinGW and use the one provided by Msys2 instead, then everything works fine.

@huonw huonw added the O-windows Operating system: Windows label May 5, 2015
@huonw huonw reopened this May 5, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue May 5, 2015
Turns out that a verbatim path was leaking through to gcc via the PATH
environment variable (pointing to the bundled gcc provided by the main
distribution) which was wreaking havoc when gcc itself was run. The fix here is
to just stop passing verbatim paths down by adding more liberal uses of
`fix_windows_verbatim_for_gcc`.

Closes rust-lang#25072
alexcrichton added a commit to alexcrichton/rust that referenced this issue May 5, 2015
Turns out that a verbatim path was leaking through to gcc via the PATH
environment variable (pointing to the bundled gcc provided by the main
distribution) which was wreaking havoc when gcc itself was run. The fix here is
to just stop passing verbatim paths down by adding more liberal uses of
`fix_windows_verbatim_for_gcc`.

Closes rust-lang#25072
bors added a commit that referenced this issue May 6, 2015
…rson

Turns out that a verbatim path was leaking through to gcc via the PATH
environment variable (pointing to the bundled gcc provided by the main
distribution) which was wreaking havoc when gcc itself was run. The fix here is
to just stop passing verbatim paths down by adding more liberal uses of
`fix_windows_verbatim_for_gcc`.

Closes #25072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
6 participants