Bug 1863601 - LTO causing lot of warnings on unregisterised ghc (s390x) for profiling libraries
Summary: LTO causing lot of warnings on unregisterised ghc (s390x) for profiling libra...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: ghc-rpm-macros
Version: 35
Hardware: s390x
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Jens Petersen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1863614
TreeView+ depends on / blocked
 
Reported: 2020-08-03 16:50 UTC by Jens Petersen
Modified: 2022-12-12 05:56 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-12-12 05:56:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jens Petersen 2020-08-03 16:50:54 UTC
Description of problem:
Link Time Optimization was enabled in Fedora 33 Rawhide and
it causes lot of linker warnings via ghc(-8.8.4) for unregisterised
s390x:

+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=zEC12 -mtune=z13 -fasynchronous-unwind-tables -fstack-clash-protection'
+ export CFLAGS
+ export 'LDFLAGS=-Wl,-z,relro -Wl,--as-needed  '
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed  '
+ '[' -f Setup.hs -o -f Setup.lhs ']'
+ '[' -x Setup ']'
+ ghc --make -package Cabal -no-user-package-db -dynamic Setup
[1 of 1] Compiling Main             ( Setup.hs, Setup.o )
Linking Setup ...
+ LANG=C.utf8
+ ./Setup --version
Cabal library version 3.0.1.0
+ '[' -x Setup ']'
+ LANG=C.utf8
++ echo ' -O2' -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=zEC12 -mtune=z13 -fasynchronous-unwind-tables -fstack-clash-protection
++ sed -e 's/ / -optc/g'
++ echo ' -Wl,-z,relro' -Wl,--as-needed
++ sed -e 's/ / -optl/g'
+ ./Setup configure --prefix=/usr --libdir=/usr/lib64 --docdir=/usr/share/licenses/ghc-cryptonite '--libsubdir=$compiler/$pkgid' '--datasubdir=$pkgid' '--libexecsubdir=$pkgid' --ghc --dynlibdir=/usr/lib64 --global '--ghc-options= -optc-O2 -optc-flto=auto -optc-ffat-lto-objects -optc-fexceptions -optc-g -optc-grecord-gcc-switches -optc-pipe -optc-Wp,-D_FORTIFY_SOURCE=2 -optc-Wp,-D_GLIBCXX_ASSERTIONS -optc-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -optc-fstack-protector-strong -optc-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -optc-m64 -optc-march=zEC12 -optc-mtune=z13 -optc-fasynchronous-unwind-tables -optc-fstack-clash-protection  -optl-Wl,-z,relro -optl-Wl,--as-needed' -p --enable-shared --htmldir=/usr/share/doc/ghc/html/libraries/cryptonite-0.26 --global
Configuring cryptonite-0.26...
+ '[' -x Setup ']'
+ LANG=C.utf8
+ ./Setup build
Preprocessing library for cryptonite-0.26..
Building library for cryptonite-0.26..
:
:
[131 of 131] Compiling Crypto.Tutorial  ( Crypto/Tutorial.hs, dist/build/Crypto/Tutorial.o )
[  1 of 131] Compiling Crypto.Cipher.DES.Primitive ( Crypto/Cipher/DES/Primitive.hs, dist/build/Crypto/Cipher/DES/Primitive.p_o )
/usr/bin/ld.gold: warning: incremental linking of LTO and non-LTO objects; using -flinker-output=nolto-rel which will bypass whole program optimization
/tmp/ghc794663_0/ghc_19.c:11:19: error:
     warning: type of ‘cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc’ does not match original declaration [-Wlto-type-mismatch]
       11 | extern CostCentre cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc[];
          |                   ^
   |
11 | extern CostCentre cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc[];
   |                   ^
/tmp/ghc794663_0/ghc_18.hc:44:9: error:
     note: type ‘StgWord’ should match type ‘struct CostCentre’
       44 | StgWord cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc[]__attribute__((aligned(8)))= {
          |         ^
   |
44 | StgWord cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc[]__attribute__((aligned(8)))= {
   |         ^
/tmp/ghc794663_0/ghc_18.hc:44:9: error:
     note: ‘cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc’ was previously declared here
   |
44 | StgWord cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc[]__attribute__((aligned(8)))= {
   |         ^
/tmp/ghc794663_0/ghc_18.hc:44:9: error:
     note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
   |
44 | StgWord cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc[]__attribute__((aligned(8)))= {
   |         ^
/tmp/ghc794663_0/ghc_19.c:12:24: error:
     warning: type of ‘cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc_ccs’ does not match original declaration [-Wlto-type-mismatch]
       12 | extern CostCentreStack cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc_ccs[];
          |                        ^
   |
12 | extern CostCentreStack cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc_ccs[];
   |                        ^
/tmp/ghc794663_0/ghc_18.hc:50:9: error:
     note: type ‘StgWord’ should match type ‘struct CostCentreStack’
       50 | StgWord cryptonitezm0zi26zmIKFu0XykBrR53imeIPM2Uw_CryptoziCipherziDESziPrimitive_CAFs_cc_ccs[]__attribute__((aligned(8)))= {
          |         ^
:
:
/usr/include/bits/string_fortified.h:59:1: error:
     error: inlining failed in call to ‘always_inline’ ‘memset’: function body can be overwritten at link time
       59 | __NTH (memset (void *__dest, int __ch, size_t __len))
          | ^
   |
59 | __NTH (memset (void *__dest, int __ch, size_t __len))
   | ^
/usr/include/bits/string_fortified.h:71:10: error:
     note: called from here
       71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
          |          ^
   |
71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
   |          ^
lto-wrapper: fatal error: /usr/bin/gcc returned 1 exit status
compilation terminated.
/usr/bin/ld.gold: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
error: Bad exit status from /var/tmp/rpm-tmp.eeilOC (%build)

Version-Release number of selected component (if applicable):
ghc-compiler-8.8.4-107.fc33.s390x
gcc-10.2.1-1.fc33.s390x
annobin-9.27-1.fc33.s390x
binutils-2.35-10.fc33.s390x

How reproducible:
100%

Steps to Reproduce:
1. build Haskell package for F33 on s390x

Actual results:
Additionally this caused ghc-cryptonite-0.26-3.fc33
and ghc-haskell-src-exts-1.23.1-3.fc33 to fail:

https://koji.fedoraproject.org/koji/taskinfo?taskID=48408236
https://koji.fedoraproject.org/koji/taskinfo?taskID=48322376

Expected results:
No problems

Additional info:
For now I will disable lto for s390x in ghc-rpm-macros.
When we move to ghc-8.10 we can switch s390x from gcc to the llvm
backend I hope then this problem should go away.

Comment 1 Jens Petersen 2020-08-04 17:28:55 UTC
Actually I am seeing warnings also for x86_64 for example (from a local rpmbuild of rpmbuild-order):

/usr/bin/ld.gold: warning: incremental linking of LTO and non-LTO objects; using -flinker-output=nolto-rel which will bypass whole program optimization

Comment 2 Ben Cotton 2020-08-11 14:02:23 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 33 development cycle.
Changing version to 33.

Comment 3 Jens Petersen 2022-02-21 05:43:13 UTC
I think this might be fixed in ghc-rpm-macros-2.3.14 (in F36+)

Comment 4 Ben Cotton 2022-11-29 16:49:16 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.


Note You need to log in before you can comment on or make changes to this bug.