From f8153b536170f72d88012a48180e1e32ee92091d Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Mon, 28 Dec 2020 13:53:25 +0000 Subject: haskell-cabal.eclass: filter out -flto|-flto=* flags `ghc` uses partial linking to glue together object files produced by `gcc` and `ghc`. In case of -flto* flags we have a chance to mix IR section incorrectly due to ld deficiency: https://sourceware.org/PR12291 Let's filter out -flto-related flags until binutils is ready. Reported-by: matoro Closes: https://github.com/gentoo-haskell/gentoo-haskell/issues/1110 Signed-off-by: Sergei Trofimovich --- eclass/haskell-cabal.eclass | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'eclass') diff --git a/eclass/haskell-cabal.eclass b/eclass/haskell-cabal.eclass index 4908e4491e60..8706cc99478e 100644 --- a/eclass/haskell-cabal.eclass +++ b/eclass/haskell-cabal.eclass @@ -342,10 +342,34 @@ cabal-configure() { fi # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) - # so translate LDFLAGS to ghc parameters (without filtering) + # so translate LDFLAGS to ghc parameters (with mild filtering). local flag - for flag in $CFLAGS; do cabalconf+=(--ghc-option="-optc$flag"); done - for flag in $LDFLAGS; do cabalconf+=(--ghc-option="-optl$flag"); done + for flag in $CFLAGS; do + case "${flag}" in + -flto|-flto=*) + # binutils does not support partial linking yet: + # https://github.com/gentoo-haskell/gentoo-haskell/issues/1110 + # https://sourceware.org/PR12291 + einfo "Filter '${flag}' out of CFLAGS (avoid lto partial linking)" + continue + ;; + esac + + cabalconf+=(--ghc-option="-optc$flag") + done + for flag in $LDFLAGS; do + case "${flag}" in + -flto|-flto=*) + # binutils does not support partial linking yet: + # https://github.com/gentoo-haskell/gentoo-haskell/issues/1110 + # https://sourceware.org/PR12291 + einfo "Filter '${flag}' out of LDFLAGS (avoid lto partial linking)" + continue + ;; + esac + + cabalconf+=(--ghc-option="-optl$flag") + done # disable executable stripping for the executables, as portage will # strip by itself, and pre-stripping gives a QA warning. -- cgit v1.2.3-65-gdbad