Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 644556

Summary: dev-util/mingw64-runtime USE=tools fails bootstrap (or builds target binaries), gendef and genidl are compiled for Windows
Product: Gentoo Linux Reporter: hanetzer
Component: Current packagesAssignee: Ionen Wolkens <ionen>
Status: RESOLVED FIXED    
Severity: normal CC: herrtimson, jfostiguy, luke-jr+gentoobugs, toolchain
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/gentoo/gentoo/pull/25365
https://bugs.gentoo.org/show_bug.cgi?id=853250
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: runtime build.log
runtime config.log
what it says on the tin
cross-x86_64-w64-mingw32-mingw64-runtime.log

Description hanetzer 2018-01-14 15:35:03 UTC
Per a discussion with ktietz (mingw-w64 developer) in
irc.oftc.net/#mingw-w64 when mingw-w64 is compiled as
a cross-compiler on linux the gendef/genidl tools are
supposed to be compiled as native ELF binaries and not
cross-compiled as win32 pe executables.
Comment 1 Fedja Beader 2019-02-19 02:29:16 UTC
Created attachment 565808 [details]
runtime build.log
Comment 2 Fedja Beader 2019-02-19 02:30:09 UTC
Created attachment 565810 [details]
runtime config.log
Comment 3 Fedja Beader 2019-02-19 02:31:28 UTC
Created attachment 565812 [details]
what it says on the tin
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2019-02-19 07:48:20 UTC
Was original bug report about build failure?
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2019-02-19 07:53:50 UTC
(In reply to Fedja Beader from comment #3)
> Created attachment 565812 [details]
> what it says on the tin

> configure:3432: i686-w64-mingw32-gcc -O2 -pipe -fomit-frame-pointer -march=core2  -I/tmp/portage/cross-i686-w64-mingw32/mingw64-runtime-6.0.0-r1/temp/tmproot/include -Wl,-O1 -Wl,--as-needed conftest.c  >&5
> /usr/libexec/gcc/i686-w64-mingw32/ld: cannot find crt2.o: No such file or directory
> /usr/libexec/gcc/i686-w64-mingw32/ld: cannot find -lmingw32

Do you have full cross-compiler installed to use USE=tools?

Try 'USE=-tools crossdev ...' if it works.
Comment 6 Fedja Beader 2019-02-19 19:38:24 UTC
USE="-tools -hardened" FEATURES="-fail-clean" crossdev --ov-output /var/portage/crossdev/ --overlays gentoo  -t i686-w64-mingw32

Produces a toolchain without failure.
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2019-02-19 22:04:26 UTC
Thank you! Let's see if we can just skip tools building at headers-only stage.
Comment 8 hanetzer 2019-02-21 15:48:13 UTC
(In reply to Sergei Trofimovich from comment #4)
> Was original bug report about build failure?

No, it was about a 'successful' build which built the genidl/etc
executables as windows binaries which are 'unusable' (without wine
or so) on linux.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2019-02-22 20:50:31 UTC
Thank you! Updated the title.
Comment 10 Luke-Jr 2020-04-20 14:59:55 UTC
(In reply to Sergei Trofimovich from comment #7)
> Thank you! Let's see if we can just skip tools building at headers-only
> stage.

They already seem to be.

But this fails at *any* stage, because it's trying to build them for the wrong platform (which isn't bootstrapped yet)
Comment 11 anna 2020-05-05 17:58:38 UTC
Created attachment 636272 [details]
cross-x86_64-w64-mingw32-mingw64-runtime.log
Comment 12 anna 2020-05-05 18:03:25 UTC
I am having this issue as well, it seems to be trying to build for a target that doesn't exist yet. I have tried all sorts of things but no workaround gets this to work and it is difficult to find anyone who knows anything about it, and mostly it just seems what it is trying to do is bizarre, as checking for whether the c compiler is capable of making an executable seems antiethical to the entire point of mingw in the first place.
Comment 13 tt_1 2020-05-05 18:37:54 UTC
you might want to try to bootstrap the whole toolchain with USE="-tools" (flipping  the libraries use flag might be also a good choice) and readd the useflags to cross-x86_64-w64-mingw32/mingw64-runtime when you're done with that. This way it should build, but the tools are still build as executables for windows.
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-05 20:52:24 UTC
(In reply to anna from comment #11)
> Created attachment 636272 [details]
> cross-x86_64-w64-mingw32-mingw64-runtime.log

I see you have --with-tools enabled. How do you enable USE=tools? Is it intentional?
Comment 15 Ionen Wolkens gentoo-dev 2022-04-17 02:39:21 UTC
May have a look eventually if anything can be improved in a sane way here but, as already mentioned, meanwhile don't enable USE=tools during bootstrap.

Renaming the USE could also be an option so it's less common and not enabled by accident by a global USE=tools.
Comment 16 Larry the Git Cow gentoo-dev 2022-05-13 02:48:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4b7c1923fca6533a51be68bfbacc793469a521d4

commit 4b7c1923fca6533a51be68bfbacc793469a521d4
Author:     Ionen Wolkens <ionen@gentoo.org>
AuthorDate: 2022-05-10 07:06:43 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2022-05-13 02:29:29 +0000

    dev-util/mingw64-runtime: build tools for CHOST and add widl
    
    Non-native USE=tools never made much sense, If a package is
    cross-compiling for mingw using e.g. widl, it'll need to be able
    to run the tool. This also prevents build failure (bug #644556)
    during bootstrap given this won't be trying to link with mingw
    (note that can cross-emerge mingw64-runtime for old behavior).
    
    wrt widl, it is provided by wine but that is a heavy dependency and
    some upstreams (e.g. vkd3d-proton) default to using *-w64-mingw32-widl
    instead -- small tool so may as well install it.
    
    Closes: https://bugs.gentoo.org/644556
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

 .../mingw64-runtime-10.0.0-r1.ebuild               | 33 +++++++++++++++++++---
 .../mingw64-runtime-8.0.0-r3.ebuild                | 33 +++++++++++++++++++---
 .../mingw64-runtime-9.0.0-r2.ebuild                | 33 +++++++++++++++++++---
 3 files changed, 87 insertions(+), 12 deletions(-)
Comment 17 Luke-Jr 2022-06-21 01:31:11 UTC
(In reply to Larry the Git Cow from comment #16)
> The bug has been closed via the following commit(s):
> 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=4b7c1923fca6533a51be68bfbacc793469a521d4

I don't think this works right. Trying to build on ppc64le, I'm getting:

In file included from ./include/windef.h:290,
                 from src/hash.c:24:
./include/winnt.h:1655:2: error: #error You need to define a CONTEXT for your CPU

But it doesn't make sense to be using winnt.h for a Linux system, nor to use host system parameters for the target. It seems likely this will mis-compile if building on a x86_64 host for a x86_32 target...
Comment 18 Ionen Wolkens gentoo-dev 2022-06-21 02:18:44 UTC
Full build.log? I don't quite see how tools would be using winnt.h considering it shouldn't be in any include paths (unless it's failing on something else entirely).

And tools don't use CHOST for the target, when it switches it's to build mingw64 libraries, otherwise it'd be like building a .dll for x86_64-pc-linux-gnu. All the commit did wrt that is move the CHOST=$CTARGET lower down.

x86_64 for 32bit target worked last I tried, e.g.
    cross-i686-w64-mingw32/mingw64-runtime[tools]
gives me native tools as
    /usr/bin/i686-w64-mingw32-genidl

and if cross-emerged for some reason, will get /usr/i686-w64-mingw32/bin/genidl.exe

No idea if anything of note that's ppc64le specific.