JuliaPackaging / BinaryBuilder.jl

Binary Dependency Builder for Julia
https://binarybuilder.org
Other
391 stars 99 forks source link

Rust windows toolchain has broken libraries #499

Open staticfloat opened 4 years ago

staticfloat commented 4 years ago

This seems to be an upstream problem, but there also seems to be a workaround:

With $target = i686-w64-mingw32:

# rustc -o ${prefix}/bin/hello_world${exeext} -g /usr/share/testsuite/rust/hello_world/hello_world.rs
...
[00:15:41]   = note: /opt/x86_64-linux-gnu/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/crt2.o:crtexe.c:(.text+0x75): undefined reference to `__onexitend'
[00:15:41]           /opt/x86_64-linux-gnu/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/crt2.o:crtexe.c:(.text+0x7a): undefined reference to `__onexitbegin'
[00:15:41]           /opt/i686-w64-mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.5/../../../../i686-w64-mingw32/bin/ld: /opt/x86_64-linux-gnu/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/crt2.o: bad reloc address 0x0 in section `.CRT$XCAA'
[00:15:41]           collect2: error: ld returned 1 exit status

X-ref: https://github.com/rust-lang/rust/issues/32859#issuecomment-210364708

giordano commented 2 years ago

The above issue is gone, but now we have (again for i686-w64-mingw32):

sandbox:${WORKSPACE} # mkdir -p ${bindir}
sandbox:${WORKSPACE} # rustc -o ${bindir}/hello_world${exeext} -g /usr/share/testsuite/rust/hello_world/hello_world.rs
 WARN rustc_codegen_ssa::back::link Linker does not support -no-pie command line option. Retrying without.
error: linking with `i686-w64-mingw32-gcc` failed: exit status: 1
  |
  = note: "i686-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-Wl,--large-address-aware" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.0.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.1.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.2.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.3.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.4.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.5.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.6.rcgu.o" "/workspace/destdir/bin/hello_world.hello_world.f26c5fe2-cgu.7.rcgu.o" "/workspace/destdir/bin/hello_world.2vww31saalyanugl.rcgu.o" "-L" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_abort-9f279b9941a87043.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libobject-a568171fb90f4868.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libmemchr-8bebec6c9064cd12.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libaddr2line-3e23d9be6db03a84.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libgimli-9e986033c2483920.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd_detect-50f69ef8f2cb05e1.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/librustc_demangle-048e5b2eebdc4235.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libhashbrown-3a8b7c7477fe25f8.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/librustc_std_workspace_alloc-d7d97010a0a1c998.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libunwind-5065a97eae0b8509.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libcfg_if-290774ef6aa5cd40.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/liblibc-4f6e03f208e0d53b.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/liballoc-166e042e6cd01510.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/librustc_std_workspace_core-9b8d5d7d829afd65.rlib" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libcore-376497abbd8b512b.rlib" "-Wl,--end-group" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libcompiler_builtins-730befa83ea003e3.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lws2_32" "-lbcrypt" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib" "-o" "/workspace/destdir/bin/hello_world.exe" "-Wl,--gc-sections" "-nodefaultlibs" "/opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/rsend.o"
  = note: /opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib(std-3566ebb723257252.std.5f2a8faf-cgu.0.rcgu.o): In function `ZN5alloc11collections5btree3mem7replace17h18298a3a0fe7eecdE':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\alloc\src\collections\btree/mem.rs:35: undefined reference to `_Unwind_Resume'
          /opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib(std-3566ebb723257252.std.5f2a8faf-cgu.0.rcgu.o): In function `ZN64_$LT$std..backtrace..BytesOrWide$u20$as$u20$core..fmt..Debug$GT$3fmt17h64e5e6ce2fa98deaE':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src/backtrace.rs:247: undefined reference to `_Unwind_Resume'
          /opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib(std-3566ebb723257252.std.5f2a8faf-cgu.0.rcgu.o): In function `ZN4core3ops8function6FnOnce9call_once17h21e9840e4b0f898dE':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops/function.rs:227: undefined reference to `_Unwind_Resume'
          /opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib(std-3566ebb723257252.std.5f2a8faf-cgu.0.rcgu.o): In function `ZN3std9backtrace7Capture7resolve17h6f0e2e010e4b7c54E':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src/backtrace.rs:485: undefined reference to `_Unwind_Resume'
          /opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib(std-3566ebb723257252.std.5f2a8faf-cgu.0.rcgu.o): In function `ZN4core3ops8function6FnOnce9call_once17hf9f1e4e2bb527f08E':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops/function.rs:227: undefined reference to `_Unwind_Resume'
          /opt/x86_64-linux-musl/toolchains/1.57.0-x86_64-unknown-linux-musl/lib/rustlib/i686-pc-windows-gnu/lib/libstd-3566ebb723257252.rlib(std-3566ebb723257252.std.5f2a8faf-cgu.0.rcgu.o):/rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ptr/mod.rs:188: more undefined references to `_Unwind_Resume' follow
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: aborting due to previous error

Good news is that only 32-bit Windows has problems, all other platforms are in a much better shape now.