Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28454 Discussions

Cmake build failure with LTO on Linux

Mark_Lewy
Valued Contributor I
677 Views

We have a Cmake build script set up to build our program on Linux.  This works fine with IFORT, but I'm having an issue with IFX and LTO (link time optimisation).  With IFORT we were using IPO (inter-procedural optimisation).

We have 4 shared libraries that are compiled with -ipo with IFORT); these now use -flto with IFX.

We also have a static library that is compiled with -ip with IFORT; when I change this to use -ftlo, I get a link error:

ld: error: LLVM gold plugin: Never resolved value found in function (Producer: 'Intel.oneAPI.DPCPP.Compiler_2023.1.0' Reader: 'Intel.oneAPI.DPCPP.Compiler_2023.1.0')

This links successfully if I omit -flto for the static library.

Before I try cutting this down, has anyone had similar issues or a solution?

OneAPI 2023.1

Ubuntu 20.04 LTS

Cmake 3.26.4

 

0 Kudos
1 Solution
Mark_Lewy
Valued Contributor I
641 Views

I found out what was happening, because I had similar link issues with LTO (/Qipo) on Windows with IFX.

I had to disable optimisation on one file in the static library because it ICEd otherwise (this has been reported (05854745) and should be fixed in OneAPI 2023.2).

Disabling optimisation also disables LTO.

It also appears that all files in a project need to be compiled with LTO enabled for it to link correctly.

Luckily, the code in the offending file is not used yet, so I could just comment it out and use the default project optimisation option.

 

One other point was that I was also having link issues with a C++ DLL using IFX/LTO dependent libraries on Windows.  In this case, the problem was the C++ project was using the Microsoft VS 2019 Platform Toolset (so not using the LLVM linker).  Switching to Intel C++ resolved this.

 

View solution in original post

1 Reply
Mark_Lewy
Valued Contributor I
642 Views

I found out what was happening, because I had similar link issues with LTO (/Qipo) on Windows with IFX.

I had to disable optimisation on one file in the static library because it ICEd otherwise (this has been reported (05854745) and should be fixed in OneAPI 2023.2).

Disabling optimisation also disables LTO.

It also appears that all files in a project need to be compiled with LTO enabled for it to link correctly.

Luckily, the code in the offending file is not used yet, so I could just comment it out and use the default project optimisation option.

 

One other point was that I was also having link issues with a C++ DLL using IFX/LTO dependent libraries on Windows.  In this case, the problem was the C++ project was using the Microsoft VS 2019 Platform Toolset (so not using the LLVM linker).  Switching to Intel C++ resolved this.

 

Reply