Description
Following the instructions in the README, everything seemed to be working fine until ./y.rs build
.
The MSVC toolchain is not yet supported by rustc_codegen_cranelift.
Switch to the MinGW toolchain for Windows support.
Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to
set the global default target to MinGW
Ok, fair enough. Compatibility layer time!
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-Wl,C:\\Users\\{redacted}\\AppData\\Local\\Temp\\rustczVob4a\\list.def" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va"
// lots and lots of paths
= note: ld: cannot find -lcfgmgr32
warning: `rustc_codegen_cranelift` (lib) generated 1 warning
error: could not compile `rustc_codegen_cranelift` due to previous error; 1 warning emitted
Hmm, dang it. I can't seem to find helpful references to -lcfgmgr32
online. It sounds like mingw can't find the library it needs for cfgmgr32.dll
. I tried reinstalling my mingw header package with pacman
to no avail. I found out, as I understand it, that the x86_64-pc-windows-gnu
toolchain uses a bundled mingw in a rust-mingw
component, so my existing installation shouldn't matter anyway. What if I copy libcfgmgr32.a
from my local mingw into the "lib" folder of the cargo source for the winapi
it's referencing (that doesn't sound like the best idea...)? Huh, that... fixes it?
But now there's a new problem:
C:\Users\{redacted}\rustc_codegen_cranelift\build_sysroot\target\x86_64-pc-windows-gnu\release\deps\std-f372f6b22d805bdf.std.53bbqtws-cgu.0.rcgu.o:std.53bbqtws-cgu.0:(.debug_info+0x40): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_str'
and other variations on that theme until
C:\Users\{redacted}\rustc_codegen_cranelift\build_sysroot\target\x86_64-pc-windows-gnu\release\deps\std-f372f6b22d805bdf.std.53bbqtws-cgu.0.rcgu.o:std.53bbqtws-cgu.0:(.debug_info+0x56): additional relocation overflows omitted from the output
collect2.exe: error: ld returned 1 exit status
I found this (https://github.com/bjorn3/rustc_codegen_cranelift/issues/977#issuecomment-830650448), which seems to be related, except I'm not using MSVC. (How do I disable DWARF debuginfo?) Based on that comment/thread, I tried to comment out the bit in y.rs
that blows up on MSVC, just for laughs. No luck; not yet implemented: Unimplemented TLS model in x64 backend: Coff
Yep, that's what the July report said, and it seems to still be the case. From what I can gather, the ADDR32
bit of it has something to do with jumps into relocatable code being too large to fit in a 32-bit pointer. I can confirm that my installed gnu
toolchain compiles other crates successfully (I have nothing nearly as large as a sysroot, though).
I played around with a bunch of RUSTFLAGS
combination (both to rustc
and passthrough to gcc
codegen/linking) based on tangential information (very little info on IMAGE_REL_AMD64_ADDR32
specifically) to no avail. It's possible that this is an effective direction, and I just don't know enough about gcc
to make it work. It seems odd to me though, because there's no mention (that I could find) of special compiler args being necessary.
I tried a few scattershot previous commits, before and after the transition to a Rust-based build system. Same problem.
I tried cross-compiling with Ubuntu on WSL2. No luck:
❯ ./y.rs build
[BUILD] y.rs
info: syncing channel updates for 'nightly-2021-08-07-x86_64-pc-windows-gnu'
info: latest update on 2021-08-07, rust version 1.56.0-nightly (5ad7389bd 2021-08-06)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'llvm-tools-preview'
info: downloading component 'rust-docs'
info: downloading component 'rust-mingw'
info: downloading component 'rust-src'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustc-dev'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'llvm-tools-preview'
info: installing component 'rust-docs'
info: installing component 'rust-mingw'
info: installing component 'rust-src'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustc-dev'
info: installing component 'rustfmt'
error: the 'rustc' binary, normally provided by the 'rustc' component, is not applicable to the 'nightly-2021-08-07-x86_64-pc-windows-gnu' toolchain
What are you talking about? It says info: downloading component 'rustc'
and then info: installing component 'rustc'
RIGHT THERE. I have no idea what's going on, as I typically don't mess with nightly/betas.
I gave up on trying to compile from source and checked out the GHA artifacts. Looks like the uploading artifacts from the windows CI build is disabled? https://github.com/bjorn3/rustc_codegen_cranelift/blob/d498e6d6971575714353f11aa4d3e63a9d2030b2/.github/workflows/main.yml#L155-L162
Oh well, cross-x86_64-mingw
sounds promising.
$ ./cargo
bash: ./cargo: cannot execute binary file: Exec format error
Dang it.
$ file cargo
cargo: ELF 64-bit LSB shared object x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b8e72eb3363cc311d848656c88fa225cbaf411a7, for GNU/Linux 3.2.0, with debug_info, not stripped
Well, that definitely doesn't sound right.
./y.rs build --sysroot none
did compile, although it (understandably) does nothing and hangs forever when invoked. However:
$ file build/cargo
build/cargo: PE32+ executable (console) x86-64, for MS Windows
Unless I'm doing something wrong (quite possible), it seems that the cross-compile CI target isn't measuring what it's supposed to be measuring (successfully producing a Windows-runnable artifact from Linux).
TWIR sent me here. I've been following this on-and-off for a while, and it's really awesome to see how close it is to basically-feature-complete. I wanted to get in on it (faster debug builds? Yes please!), but I've tried as hard as I can on my own.