Skip to content

Commit feeb039

Browse files
committed
IPO/LTO support for ICX (IntelLLVM) compiler
pybind#4080
1 parent 9727dcd commit feeb039

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tools/pybind11Common.cmake

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,22 @@ function(_pybind11_generate_lto target prefer_thin_lto)
311311
HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS
312312
PYBIND11_LTO_LINKER_FLAGS)
313313
endif()
314+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
315+
# IntelLLVM equivalent to LTO is called IPO; also IntelLLVM is WIN32/UNIX
316+
if(WIN32)
317+
_pybind11_return_if_cxx_and_linker_flags_work(
318+
HAS_INTEL_IPO "-Qipo" "-Qipo"
319+
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
320+
else()
321+
_pybind11_return_if_cxx_and_linker_flags_work(
322+
HAS_INTEL_IPO "-ipo" "-ipo"
323+
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
324+
endif()
314325
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
315326
# Intel equivalent to LTO is called IPO
316-
_pybind11_return_if_cxx_and_linker_flags_work(HAS_INTEL_IPO "-ipo" "-ipo"
317-
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
327+
_pybind11_return_if_cxx_and_linker_flags_work(
328+
HAS_INTEL_IPO "-ipo" "-ipo"
329+
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
318330
elseif(MSVC)
319331
# cmake only interprets libraries as linker flags when they start with a - (otherwise it
320332
# converts /LTCG to \LTCG as if it was a Windows path). Luckily MSVC supports passing flags

0 commit comments

Comments
 (0)