TheGreatMcPain / TheGreatMcPain-overlay

My Personal Gentoo Overlay (mirror)
https://gitlab.com/TheGreatMcPain/TheGreatMcPain-overlay
GNU General Public License v2.0
8 stars 4 forks source link

crossdev: issues creating mingw toolchain #1

Closed telans closed 4 years ago

telans commented 4 years ago

Hello, I know that this isn't the correct place to report these bug but it you could provide any help regarding this issue I would be very grateful.

I have been trying to set up the mingw build environment in order to build wine-staging with mingw, but it's not going that well.

I've been encountering linking errors with the gcc-stage2 build failing, occuring with both 9.3.0 as well as 10.1.0. The first issue with this I had is with the USE flag fortran which once disabled allows me to progress a little further.

At first I thought it might have been due to the GentooLTO flags, however crossdev strips all of these so I don't see how that could be an issue.

Fortran error:

libtool: link: /usr/libexec/gcc/i686-w64-mingw32/ranlib .libs/libgfortran.a
libtool: link: rm -fr .libs/libgfortran.lax .libs/libgfortran.lax
libtool: link: ( cd ".libs" && rm -f "libgfortran.la" && ln -s "../libgfortran.la" "libgfortran.la" )
make[3]: Leaving directory '/var/tmp/portage/cross-i686-w64-mingw32/gcc-9.3.0/work/build/i686-w64-mingw32/libgfortran'
make[2]: Leaving directory '/var/tmp/portage/cross-i686-w64-mingw32/gcc-9.3.0/work/build/i686-w64-mingw32/libgfortran'
make[1]: Leaving directory '/var/tmp/portage/cross-i686-w64-mingw32/gcc-9.3.0/work/build'
make: *** [Makefile:953: all] Error 2

cross-i686-w64-mingw32-gcc-stage2.log.zip (remove ".zip" if you want to take a look, github being weird)

The issue I have after disabling Fortran is the following linking error with libstdc++6.dll:

crt/pesect.c:18:25: warning: type of '_image_base__' does not match original declaration [-Wlto-type-mismatch]
crt/pseudo-reloc.c:50:13: note: type 'char' should match type 'struct IMAGE_DOS_HEADER'
crt/pseudo-reloc.c:50:13: note: '_image_base__' was previously declared here
/usr/libexec/gcc/i686-w64-mingw32/ld: /var/tmp/portage/cross-i686-w64-mingw32/gcc-9.3.0/temp/libstdc++-6.dll.9B4CEJ.ltrans0.ltrans.o:<artificial>:(.text+0x9c07): undefined reference to `strnlen'
/usr/libexec/gcc/i686-w64-mingw32/ld: /var/tmp/portage/cross-i686-w64-mingw32/gcc-9.3.0/temp/libstdc++-6.dll.9B4CEJ.ltrans0.ltrans.o:<artificial>:(.text+0x9d51): undefined reference to `strnlen'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:696: libstdc++.la] Error 1

no-fortran-cross-i686-w64-mingw32-gcc-stage2.log.zip

USE="-sanitize" hasn't changed anything for me either.

I have looked all over the Gentoo bug tracker for anything fitting my issue, but I've had no luck finding anything useful.

Thanks

TheGreatMcPain commented 4 years ago

I don't mind if issues are reported here, and I also use GentooLTO.

Is your mingw64-runtime built with LTO? (nevermind this my mingw64-runtime fails with LTO)

Can you send me the output of emerge --info

telans commented 4 years ago

~Is your mingw64-runtime built with LTO?~ (nevermind this my mingw64-runtime fails with LTO)

Yeah it's just built using the default crossdev flags. I may have been an idiot and forgot to include USE="-vtv", so that's building at the moment.

emerge --info: https://hastebin.com/opidigopuh.sql

emerge --info from PORTAGE_CONFIGROOT=/usr/i686-w64-mingw32:

https://hastebin.com/ucuyizedew.makefile

Cheers

EDIT: USE="-vtv" didn't help unfortunately.

TheGreatMcPain commented 4 years ago

I noticed you have the lto useflag enabled globally.

Based on the errors in your first post I think you need to disable the lto useflag for gcc via package.use.

cross-i686-w64-mingw32/gcc -lto
cross-x86_64-w64-mingw32/gcc -lto

I'm going to see if building cross-i686-w64-mingw32/gcc-10.1.0 with USE=lto causes the same error.

EDIT: cross-i686-w64-mingw32/gcc-10.1.0 with USE=lto built without issues I'll try again with gcc-9.3.0.

telans commented 4 years ago

I definitely put -lto within package.use/cross-i686-w64-mingw32 but looks like that got reset... Thanks for poing that out, rebuilding now

EDIT: No change with the error.

This is the command I'm using when building the toolchain from scractch: crossdev --ov-output /var/db/repos/telans/ i686-w64-mingw32 --env 'USE="-fortran -vtv -sanitize -lto -pgo"', I'm sure there's nothing iffy there right? Using crossdev-9999

TheGreatMcPain commented 4 years ago

I don't see anything iffy, but then again I don't normally use the --env option. I also use crossdev version 20200131, but I don't see how that would cause your error.

Also, I was able to rebuild cross-i686-w64-mingw32/gcc-9.3.0 with the lto useflag, so I'm still not sure how to reproduce this. I'll see what happens if I create the toolchain from scratch.

In the meantime can you send me your /etc/portage/make.conf?

telans commented 4 years ago

Sure thing:

From /: https://hastebin.com/ujebazesej.makefile From /usr/i686-w64-mingw32/: https://hastebin.com/omugukaqaz.ini

I really do need to clean up my globals. I know gcc uses zstd, so I've disabled that flag and am rebuilding to test that

EDIT: Nope, still errors out

TheGreatMcPain commented 4 years ago

I still can't reproduce your error.

What version of glibc do you have, and does it have the custom-cflags useflag set?

telans commented 4 years ago

sys-libs/glibc-2.31-r3, only multiarch & ssp are enabled. Thanks for your help, I'm just as stumped as you are. Perhaps it might be time to file a bug report?

Just to confirm, crossdev --ov-output /something i686-w64-mingw32 builds fine for you with ~x86/amd64?

TheGreatMcPain commented 4 years ago

I use crossdev -t i686-w64-mingw32 since I already have a local overlay called crossdev I don't need --ov-output.

I have *FLAGS-=-flto* set for mingw64-runtime in my package.cflags.

I also apply a patch to binutils-2.34 that fixes a crash that DXVK has if built with it.

My default keyword is amd64, but my gcc, glibc, and binutils are ~amd64.

telans commented 4 years ago

I commented out all my global USE flags (make.conf), commented out everything GentooLTO and it built. At least that gives me an area to narrow it down to. I'm just glad it's working now, thanks! I have a feeling I probably need *FLAGS-=-flto* set

EDIT: Failed with just GentooLTO, trying *FLAGS-=-flto* with mingw64-runtime

TheGreatMcPain commented 4 years ago

The only packages that I needed *FLAGS-=-flto* is mingw64-runtime.

I've commented out my package.cflags mingw64-runtime entries to see if something else happens.

telans commented 4 years ago

Yep, that flag setting alone fixes it. Thanks! I should probably submit a PR to GentooLTO about it

TheGreatMcPain commented 4 years ago

Removing those mingw64-runtime entries triggered the error.

I'll update my guide with those package.cflags entries.

telans commented 4 years ago

cross-i686-w64-mingw32/mingw64-runtime: 35 seconds average for 38 merges

On a side note, the "Will also need to enable the libraries useflag in mingw64-runtime" section in the app-emulation readme has incorrect package category names, "w64" is missing

TheGreatMcPain commented 4 years ago

Oof, Thanks for catching that. I keep forgetting to add w64.