IntelLLVM: Enable IPO for Linux and Windows
The first commit in the sequence updates Windows-IntelLLVM so that linking flags are passed to the compiler rather than the linker. Linker flags that the compiler does not understand and need to go to the linker will now need to be wrapped, as they are with clang and some other compilers, so that they pass through to the linker.
This change broke the ModuleDefinition
test because the /DEF option provided in the test did not get wrapped. Adding the .def
file to the sources for the test library caused the .def
file to be passed correctly. The other Windows-MSVC platforms in the test pass the .def
file by adding a link flag property which seems like a lower level solution.
The IntelLLVM compilers need the OpenMP flag to be passed to the linker under some circumstances -- for example, when doing target offload. That was previously not possible, because the link flags were passed directly to the linker rather than the compiler. Since it is now possible, I added the OpenMP flag to the linker flags in FindOpenMP.
In addition to setting the variables saying that IntelLLVM supports IPO, IPO wants to use ar
and ranlib
to build static libraries. Previously, IntelLLVM did not have a FindBinUtils, and it seemed to be working find with the normal tools
arand
ranlibthat CMake found. For non-IPO (and non-target offload) cases, these tools are the expected ones to use, but for IPO (and target offload) the .o files are in a non-standard format that require the LLVM versions of
arand
ranlib. So, I added
FindBinUtils-IntelLLVM` to help IPO find the right tools.
The last issue is that in building CMake itself, the -stack
parameter is added to the link flags to limit stack size. icx.exe
does not recognize the flag, prints a warning, and ignores the flag. I added the wrapper prefix so icx send the -stack
option to the linker, hoping it would be in a way that would work for any platform that needs to wrap linker flags passed to the compiler.
I tested building cmake on Ubuntu Linux 20.04.1, Windows Server 2022 Datacenter 21H2, and Windows 10 Enterprise with IPO, OpenMP, and MPI tests enabled, configuring with:
cmake -G Ninja -DCMAKE_INSTALL_PREFIX=${HOME}/ws/usr -DCMAKE_BUILD_TYPE=release ../cmake "-DCMake_TEST_IPO_WORKS_C:BOOL=ON" "-DCMake_TEST_IPO_WORKS_CXX:BOOL=ON" "-DCMake_TEST_IPO_WORKS_Fortran:BOOL=ON" -DCMake_TEST_FindOpenMP:BOOL=ON -DCMake_TEST_FindOpenMP_C:BOOL=ON -DCMake_TEST_FindOpenMP_CXX:BOOL=ON -DCMake_TEST_FindOpenMP_Fortran:BOOL=ON -DCMake_TEST_FindMPI:BOOL=ON -DCMake_TEST_FindMPI_C:BOOL=ON -DCMake_TEST_FindMPI_CXX:BOOL=ON -DCMake_TEST_FindMPI_Fortran:BOOL=ON
All the tests passed. I also tested building with MSVC on Windows and gcc 9.3 on Linux and tests passed that way as well.
Fixes: #23741 (closed), #23149 (closed)