root icon indicating copy to clipboard operation
root copied to clipboard

ROOT does not compile with link-time optimizations (LTO) enabled

Open amadio opened this issue 3 years ago • 4 comments

Full bug report is at https://bugs.gentoo.org/879323.

Important part of the build log is below.


/usr/bin/cmake -E copy_if_different /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/jets.C /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08_build/tutorials/tree/jets.C
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/zebra.f:767:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
  767 |      + ISTAT)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:107:6: note: ‘cfget_’ was previously declared here
  107 | void cfget_(int *lundes, int *medium, int *nwrec, int *nwtak, char *mbuf,
      |      ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:107:6: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/kernlib.f:398:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
  398 |       CFSTAT = CFSTATI (NAME, INFO, LGN)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:171:5: note: type mismatch in parameter 4
  171 | int cfstati_(char *fname, int *info, int *lgname)
      |     ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:171:5: note: type ‘void’ should match type ‘long int’
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:171:5: note: ‘cfstati_’ was previously declared here
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/kernlib.f:386:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
  386 |       CALL CFOPEI (LUNDES,MEDIUM,NWREC,NVMODE,NBUF,NAME,ISTAT,LGN)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:225:6: note: type mismatch in parameter 9
  225 | void cfopei_(int *lundes, int *medium, int *nwrec, int *mode, int *nbuf,
      |      ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:225:6: note: type ‘void’ should match type ‘long int’
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:225:6: note: ‘cfopei_’ was previously declared here
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/hbook.f:542:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
  542 |                CALL UCOPY2(IQ(LCID+ITAG1),IQ(LCID+32),NW)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/kernlib.f:403:23: note: ‘ucopy2’ was previously declared here
  403 |       SUBROUTINE UCOPY2 (A,B,N)
      |                       ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/kernlib.f:403:23: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/main/src/g2root.f:1581:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
 1581 |       CALL VZERO(JNAMES,20)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/hbook.f:2184:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
 2184 |       CALL VZERO(I1,37)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/kernlib.f:105:22: note: ‘vzero’ was previously declared here
  105 |       SUBROUTINE VZERO (A,N)
      |                      ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/kernlib.f:105:22: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/hbook.f:1959:18: error: type of <E2><80>-Werror=lto-type-mismatch][]]
 1959 |       COMMON/PAWC/NWPAW,IXPAWC,IHDIV,IXHIGZ,IXKU,FENC(5),LMAIN,
      |                  ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/zebra.f:205:19: error: type of <E2><80>-Werror=lto-type-mismatch][]]
  205 |       COMMON /PAWC/  NWPAW,IXPAWC,IHBOOK,IXHIGZ,IXKU,IFENCE(5)
      |                   ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/main/src/g2root.f:278:18: note: ‘pawc’ was previously declared here
  278 |       common/pawc/paw(nwpaw)
      |                  ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/main/src/g2root.f:278:18: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
[ 56%] Copying /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/ntuple1.C
/usr/bin/cmake -E copy_if_different /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/ntuple1.C /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08_build/tutorials/tree/ntuple1.C
[ 56%] Copying /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/parallelcoord.C
/usr/bin/cmake -E copy_if_different /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/parallelcoord.C /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08_build/tutorials/tree/parallelcoord.C
[ 56%] Copying /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/parallelcoordtrans.C
/usr/bin/cmake -E copy_if_different /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/parallelcoordtrans.C /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08_build/tutorials/tree/parallelcoordtrans.C
[ 56%] Copying /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/printSizes.C
/usr/bin/cmake -E copy_if_different /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/printSizes.C /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08_build/tutorials/tree/printSizes.C
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-gfortran returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

amadio avatar Nov 03 '22 16:11 amadio

I looked at the first error.

/usr/bin/cmake -E copy_if_different /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/tutorials/tree/jets.C /var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08_build/tutorials/tree/jets.C
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/zebra.f:767:72: error: type of <E2><80>-Werror=lto-type-mismatch][]]
  767 |      + ISTAT)
      |                                                                        ^
/var/tmp/portage/sci-physics/root-6.26.08/work/root-6.26.08/misc/minicern/src/cernlib.c:107:6: note: ‘cfget_’ was previously declared here
  107 | void cfget_(int *lundes, int *medium, int *nwrec, int *nwtak, char *mbuf,
      |      ^

I checked the code. Seems to me it is correct. In the c part, istat is declared as int *istat. which is normal because FORTRAN always passes by address. and in the FORTRAN part, we have ISTAT which is an integer as it starts with I.

couet avatar Nov 04 '22 06:11 couet

I think the problem might actually be due to the char *mbuf that comes before. That looks like it's treated as int by Fortran too, no? The type that is mismatched is the type of the function, if I understood the error correctly.

amadio avatar Nov 04 '22 08:11 amadio

Note that there is also a problem with LLVM and LTO: https://github.com/root-project/root/issues/11135

eguiraud avatar Nov 08 '22 11:11 eguiraud

asan also reports some errors in these files, but on other lines: https://github.com/root-project/root/pull/18234#issue-2966181139

ferdymercury avatar Jun 17 '25 14:06 ferdymercury

Closing since building with LTO is not supported, as mentioned here: https://github.com/root-project/root/issues/11135

bellenot avatar Jun 26 '25 08:06 bellenot