I downloaded and installed the Rust and Cargo nightlies on my machine, and used Cargo to generate a new binary project:
Cifram@Valyria ~
$ cargo new test --bin
Then I attempt to run this virgin project, again with a fresh, untarnished install of both Rust and Cargo, and get this:
Cifram@Valyria ~/test
$ cargo run --verbose
Compiling test v0.0.1 (file:///C:/cygwin64/home/Cifram/test)
Running `rustc C:\cygwin64\home\Cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir C:\cygwin64\home\Cifram\test\target --dep-info C:\cygwin64\home\Cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -L C:\cygwin64\home\Cifram\test\target -L C:\cygwin64\home\Cifram\test\target\deps`
error: linking with `gcc` failed: exit code: 1
note: gcc '-m64' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib' '-o' 'C:\cygwin64\home\Cifram\test\target\test.exe' 'C:\cygwin64\home\Cifram\test\target\test.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-fno-lto' '-fno-use-linker-plugin' '-Wl,--gc-sections' '-static-libgcc' '-Wl,--enable-long-section-names' '-Wl,--nxcompat' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libstd-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libsync-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\librustrt-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libcollections-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liballoc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libunicode-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liblibc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\librand-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libcore-4e7c5e5c.rlib' '-L' 'C:\cygwin64\home\Cifram\test\target' '-L' 'C:\cygwin64\home\Cifram\test\target\deps' '-L' 'C:\cygwin64\home\Cifram\test\.rust' '-L' 'C:\cygwin64\home\Cifram\test' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lws2_32' '-lcompiler-rt'
note: C:\cygwin64\home\Cifram\test\target\test.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
error: aborting due to previous error
Could not compile `test`.
Caused by:
Process didn't exit successfully: `rustc C:\cygwin64\home\Cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir C:\cygwin64\home\Cifram\test\target --dep-info C:\cygwin64\home\Cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -L C:\cygwin64\home\Cifram\test\target -L C:\cygwin64\home\Cifram\test\target\deps` (status=101)
I'm not sure why rustc is invoking gcc, since I understood it was built on top of LLVM. I do have gcc installed, through MinGW, so my first thought was that maybe that gcc install was interfering.
Cifram@Valyria ~
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)
So it's an up-to-date version of gcc. But still, it might not be what rustc is expecting. So I removed C:\MinGW\bin from my path and tried again, and got:
Cifram@Valyria ~/test
$ cargo run --verbose
Compiling test v0.0.1 (file:///C:/cygwin64/home/Cifram/test)
Running `rustc C:\cygwin64\home\Cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir C:\cygwin64\home\Cifram\test\target --dep-info C:\cygwin64\home\Cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -L C:\cygwin64\home\Cifram\test\target -L C:\cygwin64\home\Cifram\test\target\deps`
error: linking with `gcc` failed: exit code: 1
note: gcc '-m64' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib' '-o' 'C:\cygwin64\home\Cifram\test\target\test.exe' 'C:\cygwin64\home\Cifram\test\target\test.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-fno-lto' '-fno-use-linker-plugin' '-Wl,--gc-sections' '-static-libgcc' '-Wl,--enable-long-section-names' '-Wl,--nxcompat' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libstd-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\librand-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libsync-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\librustrt-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libcollections-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liballoc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liblibc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libunicode-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libcore-4e7c5e5c.rlib' '-L' 'C:\cygwin64\home\Cifram\test\target' '-L' 'C:\cygwin64\home\Cifram\test\target\deps' '-L' 'C:\cygwin64\home\Cifram\test\.rust' '-L' 'C:\cygwin64\home\Cifram\test' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lws2_32' '-lcompiler-rt'
note: ld: this linker was not configured to use sysroots
error: aborting due to previous error
Could not compile `test`.
Caused by:
Process didn't exit successfully: `rustc C:\cygwin64\home\Cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir C:\cygwin64\home\Cifram\test\target --dep-info C:\cygwin64\home\Cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -L C:\cygwin64\home\Cifram\test\target -L C:\cygwin64\home\Cifram\test\target\deps` (status=101)
Well, it's a somewhat different error, but not really any better. The same gcc command is failing, but, before the error was:
C:\cygwin64\home\Cifram\test\target\test.o: file not recognized: File format not recognized
And now it's:
ld: this linker was not configured to use sysroots
I don't find either of these terribly meaningful. I tried running "rustc main.rs" directly. Got the same errors (except it was "src\main.o" instead of "target\test.o"). Tried doing all of this from the native Windows commandline instead of cygwin. Same errors. So it doesn't seem to be Cargo or cygwin that's to blame. I also tried downloading the last "stable" release of Rust (0.12.0), and still got the same errors. I've googled for these errors, and come up empty. So I'm running out of ideas.
Help?