From 09db6445d8da6e918c2d2be3aa4e7b0ddd8077c7 Mon Sep 17 00:00:00 2001 From: Martin Blanchard <49144287+mablanchard@users.noreply.github.com> Date: Fri, 16 Dec 2022 06:10:46 +0100 Subject: [PATCH] IPO/LTO support for ICX (IntelLLVM) compiler (#4402) * IPO/LTO support for ICX (IntelLLVM) compiler https://github.com/pybind/pybind11/issues/4080 * style: pre-commit fixes * Add WARNING/HELP WANTED comment. Co-authored-by: Martin Blanchard Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve --- tools/pybind11Common.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index e1fb601a..0c985bc8 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -311,6 +311,16 @@ function(_pybind11_generate_lto target prefer_thin_lto) HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS) endif() + elseif(CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") + # IntelLLVM equivalent to LTO is called IPO; also IntelLLVM is WIN32/UNIX + # WARNING/HELP WANTED: This block of code is currently not covered by pybind11 GitHub Actions! + if(WIN32) + _pybind11_return_if_cxx_and_linker_flags_work( + HAS_INTEL_IPO "-Qipo" "-Qipo" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS) + else() + _pybind11_return_if_cxx_and_linker_flags_work( + HAS_INTEL_IPO "-ipo" "-ipo" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS) + endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") # Intel equivalent to LTO is called IPO _pybind11_return_if_cxx_and_linker_flags_work(HAS_INTEL_IPO "-ipo" "-ipo"