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

Bug 593892

Summary: dev-lang/ghc embeds -nopie CFLAG into wrapper on on gcc-spes-pie gcc, breaks on sys-devel/gcc-6.2.0: unrecognized command line option ‘-nopie’; did you mean ‘-no-pie’?
Product: Gentoo Linux Reporter: jeremiah <jamiahx>
Component: Current packagesAssignee: Gentoo's Haskell Language team <haskell>
Status: RESOLVED FIXED    
Severity: normal CC: gentoo, jamiahx
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=631138
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 582084, 582688    
Attachments: Complete build log for dev-haskell/dlist-0.8.0.2
config.log

Description jeremiah 2016-09-15 16:58:33 UTC
This line pretty much sums it all up:
x86_64-pc-linux-gnu-gcc: error: unrecognized command line option ‘-nopie’; did you mean ‘-no-pie’?

Apparently GCC 6 no longer allows "-nopie".

Got it with every attempted update or install of a dev-haskell/* package. Haskell overlay is present, but the error persisted when a package was forced with "::gentoo".
Comment 1 Sergei Trofimovich gentoo-dev 2016-09-15 18:59:00 UTC
Can you post an example build.log for a faulty package?
Comment 2 jeremiah 2016-09-15 19:29:40 UTC
Created attachment 445866 [details]
Complete build log for dev-haskell/dlist-0.8.0.2
Comment 3 Sergei Trofimovich gentoo-dev 2016-09-15 20:46:43 UTC
Can you post your

$ emerge --info sys-devel/gcc

I guess you are using USE=pie gcc.
Comment 4 Sergei Trofimovich gentoo-dev 2016-09-15 21:17:46 UTC
Basically the issue is:

gentoo-specific pardened patches added '-pie'/'-nopie' commandline flag
while upstream gcc-6 slightly changed flag name to '-pie'/'-no-pie'

Upstream issue is https://ghc.haskell.org/trac/ghc/ticket/11834
where ghc needs to learn to autodetect gcc -fPIC/-fno-PIC default.

Meanwhile in gentoo we can use test-flag-CC from flag-o-matic.eclass
to pick from '-no-pie' / '-nopie'.
Comment 5 jeremiah 2016-10-04 15:39:58 UTC
the error does not persist after upgrading to ghc-8.0.1 and cabal-1.24; however, this is not really a fix
Comment 6 eroen 2016-11-15 14:51:13 UTC
(In reply to jeremiah from comment #5)
> the error does not persist after upgrading to ghc-8.0.1 and cabal-1.24;
> however, this is not really a fix

But how? ghc ebuild still does 

    gcc-specs-pie && append-ghc-cflags persistent compile link -nopie

in src_prepare(). Fwiw, I at least still can't build ghc with gcc-6.

Please, could someone replace the line above (236 in ghc-8.0.1.ebuild) with something like

    if test-flags -nopie >/dev/null ; then
        gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
    else
        gcc-specs-pie && append-ghc-cflags persistent compile link -no-pie
    fi

flag-o-matic is already inherited by the ebuild. The same pattern is used by filter-flags() in flag-o-matic.eclass, an alternative would be to just use that in stead of embedding toolchain checks in the ebuild.
Comment 7 Sergei Trofimovich gentoo-dev 2017-02-27 22:52:46 UTC
ghc-8.0.2 should handle -nopie/-no-pie better.
It will still require rebuilding ghc to get rid of -no-pie from wrapper.
Comment 8 eroen 2017-02-28 08:40:25 UTC
Created attachment 465496 [details]
config.log

checking target system type... x86_64-pc-linux-gnu
GHC build  : x86_64-unknown-linux
GHC host   : x86_64-unknown-linux
GHC target : x86_64-unknown-linux
configure: Building in-tree ghc-pwd
x86_64-pc-linux-gnu-gcc: error: unrecognized command line option '-nopie'; did you mean '-no-pie'?
configure: error: Building ghc-pwd failed

!!! Please attach the following file when seeking support:
!!! /var/tmp/portage/dev-lang/ghc-8.0.2/work/ghc-8.0.2/config.log
 * ERROR: dev-lang/ghc-8.0.2::haskell failed (configure phase):
 *   econf failed

Same with ghc from gentoo proper. This is with gcc-6.3.0.
Comment 9 eroen 2017-02-28 08:50:21 UTC
(In reply to eroen from comment #8)
Nevermind, this is because of USE=ghcbootstrap. Please disregard, sorry.