Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 644930 - i686-w64-mingw32 compiled programs don't work (no output)
Summary: i686-w64-mingw32 compiled programs don't work (no output)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Overlays (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 661572 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-01-18 11:03 UTC by Dmitri Filov
Modified: 2018-08-19 12:24 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitri Filov 2018-01-18 11:03:02 UTC
According this manual I have installed i686-w64-mingw32.
When I try to run a compiled program, I get an empty output.

USE="-fortran" crossdev -t i686-w64-mingw32 --stable -oO /usr/crossdev-overlay

Example:
$ cat hello.cpp 
#include <iostream>
using namespace std;

int main() {
        cout << "Hello, World" << endl;
        return 0;
}

$ i686-w64-mingw32-g++ -O2 hello.cpp -o hello.exe -mconsole -static-libgcc -static-libstdc++

$ wine hello.exe 

$
Comment 1 Dmitri Filov 2018-01-18 11:04:03 UTC
Link to mingw32 manual: https://wiki.gentoo.org/wiki/Mingw
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2018-01-18 23:21:54 UTC
(In reply to Dmitri Filov from comment #0)
> According this manual I have installed i686-w64-mingw32.
> When I try to run a compiled program, I get an empty output.
> 
> USE="-fortran" crossdev -t i686-w64-mingw32 --stable -oO
> /usr/crossdev-overlay
> 
> Example:
> $ cat hello.cpp 
> #include <iostream>
> using namespace std;
> 
> int main() {
>         cout << "Hello, World" << endl;
>         return 0;
> }
> 
> $ i686-w64-mingw32-g++ -O2 hello.cpp -o hello.exe -mconsole -static-libgcc
> -static-libstdc++
> 
> $ wine hello.exe 
> 
> $

Does adding '-no-pie' help?
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2018-01-20 11:40:10 UTC
(In reply to Sergei Trofimovich from comment #2)
> (In reply to Dmitri Filov from comment #0)
> > $ i686-w64-mingw32-g++ -O2 hello.cpp -o hello.exe -mconsole -static-libgcc
> > -static-libstdc++
> > 
> > $ wine hello.exe 
> > 
> > $
> 
> Does adding '-no-pie' help?

Assuming workaround does help: https://www.linux.org.ru/forum/development/13966748?lastmod=1516422156800&filter=show#comment-13968613

It means mingw startup code is not compatible with --enable-default-pie.

To avoid passing -no-pie into every linked program you can disable gcc[pie] as:
   $ USE="-pie" crossdev -t i686-w64-mingw32
or override default in
   /etc/portage/package.use/cross-i686-w64-mingw32
Comment 4 Larry the Git Cow gentoo-dev 2018-01-20 12:37:37 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=1803a14a1ad634a1e1153efd2f906aa1c7bb0fc1

commit 1803a14a1ad634a1e1153efd2f906aa1c7bb0fc1
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-01-20 12:30:01 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-01-20 12:30:01 +0000

    crossdev: blacklist known broken targets for PIE and SSP, bug #644930
    
    - SSP is not supported by alpha, hppa, ia64, avr, nios2, mmix
    - PIE is not supported by avr, mmix, mingw32
    
    Bug: https://bugs.gentoo.org/644930
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 crossdev | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)}
Comment 5 Larry the Git Cow gentoo-dev 2018-01-20 18:55:30 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5239f0b88b067302a5897a199554c76afa61b1bc

commit 5239f0b88b067302a5897a199554c76afa61b1bc
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-01-20 18:54:16 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-01-20 18:55:24 +0000

    sys-devel/crossdev: bump up to 20180120
    
    Closes: https://bugs.gentoo.org/644930
    Package-Manager: Portage-2.3.19, Repoman-2.3.6

 sys-devel/crossdev/Manifest                 |  1 +
 sys-devel/crossdev/crossdev-20180120.ebuild | 35 +++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
Comment 6 Jernej Simončič 2018-05-01 17:39:00 UTC
Looks like x86_64-w64-mingw32 needs the same fix, otherwise it also produces executables that just hang.
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2018-05-01 20:55:01 UTC
(In reply to Jernej Simoncic from comment #6)
> Looks like x86_64-w64-mingw32 needs the same fix, otherwise it also produces
> executables that just hang.

Did you have a chance to try to rebuild gcc with USE=-pie? If it helps you I'll extend the hack to all mingw targets.
Comment 8 Jernej Simončič 2018-05-08 21:19:14 UTC
Yes, with USE=-pie the resulting x64 executables work fine (tested on GIMP 2.10)
Comment 9 Larry the Git Cow gentoo-dev 2018-05-08 21:40:09 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=56de3cc88635c85f96298072111a81dadf424e9f

commit 56de3cc88635c85f96298072111a81dadf424e9f
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-05-08 21:38:40 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-05-08 21:38:40 +0000

    crossdev: disable USE=pie for all mingw targets
    
    Jernej reports that x86_64-w64-mingw32 also exhibits
    the same runtime failures with USE=pie.
    
    Reported-by: Jernej Simoncic
    Bug: https://bugs.gentoo.org/644930
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 crossdev | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 10 Larry the Git Cow gentoo-dev 2018-05-08 21:45:02 UTC
The bug has been closed via the following commit(s):

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

commit e42f1893098bfc973c2c869cfc33e6df7d31e9fd
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-05-08 21:44:02 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-05-08 21:44:46 +0000

    sys-devel/crossdev: bump up to 20180508, bug #644930
    
    Single new patch: "disable USE=pie for all mingw targets"
    
    Reported-by: Jernej Simoncic
    Closes: https://bugs.gentoo.org/644930
    Package-Manager: Portage-2.3.36, Repoman-2.3.9

 sys-devel/crossdev/Manifest                 |  1 +
 sys-devel/crossdev/crossdev-20180508.ebuild | 39 +++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Comment 11 Sergei Trofimovich (RETIRED) gentoo-dev 2018-05-08 21:45:54 UTC
Thanks for the report and test! crossdev-20180508 should default to saner toolchain now.
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2018-08-19 12:24:52 UTC
*** Bug 661572 has been marked as a duplicate of this bug. ***