Rust: i686-pc-windows-gnu linker failures

So I was trying to migrate the ctest crate [0] from appveyor to travis and the following targets pretty much worked out-of-the-box:

  • x86_64-pc-windows-gnu
  • x86_64-pc-windows-msvc
  • i686-pc-windows-msvc

but I am running into linker errors with the i686-pc-windows-gnu target. My .travis.yml (ctest windows branch) file is pretty much just (you can check out the branch for all the details):

  - name: "x86_64-pc-windows-gnu"
      env: TARGET=x86_64-pc-windows-gnu
      os: windows
    - name: "i686-pc-windows-gnu"
      # Try hard to get the right gcc / ld versions used:
      env: TARGET=i686-pc-windows-gnu PATH=$PATH:/c/Program\ Files\ (x86)/Rust/bin:/c/msys64/mingw32/bin
      os: windows
    - name: "x86_64-pc-windows-msvc"
      env: TARGET=x86_64-pc-windows-msvc
      install: true
      os: windows
    - name: "i686-pc-windows-msvc"
      env: TARGET=i686-pc-windows-msvc
      os: windows

install: rustup target add ${TARGET} 
script: cargo test --all --target=${TARGET}

produces this error:

error: linking with `gcc` failed: exit code: 1
  |
  = note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-Wl,--large-address-aware" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\crt2.o" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsbegin.o" "-L" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.10ygozpgsu0ud2lu.rcgu.o" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.1y16o1qfye96o7m0.rcgu.o" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.2226fh7p4842q6ww.rcgu.o" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.3rngp6bm2u2q5z0y.rcgu.o" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.4oc10dk278mpk1vy.rcgu.o" "-o" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.exe" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\ctest-77fdecdd840c9128.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps" "-L" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\debug\\deps" "-L" "C:\\Users\\travis\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\winapi-i686-pc-windows-gnu-0.4.0\\lib" "-L" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libtest-4a2f24e66abfa214.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libterm-f03408d8257ed9ff.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libgetopts-772aed0843c97b22.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libsyntex_syntax-21fdf66118d64686.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libunicode_xid-be4c8686bf4bd918.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libserde_json-5028a290b2406db2.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libryu-b83cd47d5935ca08.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libitoa-38cdbb7126b88808.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libextprim-843f620c5f2062b6.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libnum_traits-3dab603956b4d409.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\librand-5c5ceafdcc6d0264.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libwinapi-b8b236ba826e6431.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libsyntex_errors-5214c06806aaedf3.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libsyntex_pos-5cfa9234b640ff48.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libserde-f6ed8a71825307c1.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\liblibc-b01d181682497a43.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libterm-91a4506a80002801.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libkernel32-065ee2d6f088e2bd.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libwinapi-23a727283701989f.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libbitflags-380d656fbed897ef.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\liblog-d5da500d757bd26d.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\liblog-a5f0a6547adb0e61.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libcfg_if-12224e575c559a10.rlib" "C:\\Users\\travis\\build\\gnzlbg\\ctest\\target\\i686-pc-windows-gnu\\debug\\deps\\libcc-b6f2f2765b3bc0ea.rlib" "-Wl,--start-group" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libstd-ebc1fd97c06265bb.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libpanic_unwind-c2dea241d10ef1d1.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libunwind-f8b5a53793aaecd8.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liblibc-6f37db0e550df2b3.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liballoc_system-1f1be265c96b7dd4.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liballoc-85075aa5d1316ca8.rlib" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcore-f61e8e83f7620964.rlib" "-Wl,--end-group" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcompiler_builtins-7602506b990ae91e.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lwinapi_advapi32" "-lwinapi_credui" "-lwinapi_kernel32" "-lwinapi_secur32" "-lkernel32" "-ladvapi32" "-lole32" "-loleaut32" "-ladvapi32" "-lws2_32" "-luserenv" "-lshell32" "-Wl,-Bstatic" "-lgcc_eh" "-lpthread" "-Wl,-Bdynamic" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "C:\\Users\\travis\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsend.o"
  = note: C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: unrecognized option '--large-address-aware'
          C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: use the --help option for usage information
          collect2.exe: error: ld returned 1 exit status

I’d guess that’s because an incorrect mingw version is being picked up (I tried jugling with PATH without much luck). Am I doing something wrong? (is this working as intended?) Is there a better way to configure which mingw version is used?

[0] the ctest crate is used to verify the ABI of Rust C FFI library wrappers like the libc wrapper which is used by the std library.

1 Like

I also got this link error. Maybe it’s related:
https://travis-ci.org/gallactic/gallactic/jobs/462814226#L281

Looks like a problem with cargo – it doesn’t support cross-compilation or something: https://github.com/rust-lang/cargo/issues/3915

Can’t say anything more specific without seeing build output anyway.