Conversation
This is necessary to make w64devkit compatible with LTO objects compiled by other mingw-w64 toolchains
I was already looking into lifting zstd up so that Binutils and GDB could use it, but it's trickier than it looks. Look carefully at the Binutils logs from your build and you'll find: Binutils uses pkg-config to detect zstd, and there's no However this still doesn't work, I suspect because Autotools is using pkg-config incorrectly, but I haven't gotten to the bottom of it yet. |
|
Yikes. Yeah, I did not test that sufficiently. |
|
here's the responsible code in the configure script. Some analysis from chatgpt: That analysis is also backed up by this comment. I will try setting ZSTD_LIBS and ZSTD_CFLAGS instead. I am really curious why zstd is being handled in this unusual way. None of the other dependencies attempt to call pkg-config to resolve themselves, as far as I can tell... |
|
In my local build "zstd attempt 2" did not work either, though I do not understand why. Maybe the flags variables are not making into the subdirectory |
|
Your intuition seems correct... There is a list of "precious vars" that do get propagated through, it seems. My guess is that the precious vars get hardcoded into the generated makefiles. While the not-precious ones need to be passed on both the configure AND the And ZSTD_CFLAGS and ZSTD_LIBS are not on this list. |
|
Looks like you reached the same conclusion as me, though I wrote it: ENV ZSTD_CFLAGS=... ZSTD_LIBS=...Your version saves a layer, so I like it better. I've completed a build with the above, and the logs indicate Binutils is happy, but when I try |
|
This is so cursed. I will figure it out at another time. |
|
I'm not sure if it's the problem here, but I noticed a discrepancy in the documentation between gcc 16 and gcc 15 for -gz. https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gz Only gcc 16 mentions |
|
So no COFF/PE compression, sadly. I haven't checked yet if LTO supports compression in COFF, but I'm starting to doubt it. GCC enables/disables it depending on the presence of |
|
Unrelated to compression: I'm still hesitant about enabling LTO not just because I don't really trust it, but also because it makes the whole toolchain misbehave even if it's not actually in use. Here was the final straw that made me turn it off in the first place. First, on the LTO-disabled toolchain this extracts a single symbol from libgcc: I've plucked Same experiment: I now have a mysterious The fact that LTO is active even when I don't ask for it makes me nervous. |
|
Right, well, I think that dwarf compression is simply not supported for PE. The gcc documentation only says: And the mingw-w64 package of Arch Linux gives me the same error. However, I did confirm, for LTO, that same toolchain is definitely emitting zstd compressed sections. decls.bin starts with the following: Which are zstd magic bytes. |
This PR was just intended to be a testing ground to see if I can improve the situation regarding gcc LTO for windows. I tried to mark it as a draft, but couldn't... |
|
https://sourceware.org/bugzilla/show_bug.cgi?id=30343 seems related. |
Ah, right, I meant to try myself. Looks like it worked. |
This is my personal branch of w64devkit with LTO support.
NOTE: GCC for mingw-w64 targets has known bugs:
https://gcc.gnu.org/PR106103
This branch includes my patch for adding BigObj support to libiberty, which GCC uses to parse LTO information out of object files.
It will be included with gcc 16.
I added zstd support to GCC, binutils, and GDB in order to be compatible with LTO object files compiled by other toolchains, for example, the mingw-w64 package of Arch Linux.