pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

[BUG]: IPO isn't detected properly with IntelLLVM

Open mablanchard opened this issue 3 years ago • 1 comments

Required prerequisites

  • [X] Make sure you've read the documentation. Your issue may be addressed there.
  • [X] Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
  • [ ] Consider asking first in the Gitter chat room or in a Discussion.

Problem description

Running CMake find_package(pybind11) on Windows + Intel new ICX compiler (a.k.a. IntelLLVM) gives:

-- Performing Test HAS_INTEL_IPO -- Performing Test HAS_INTEL_IPO - Failed

From the CMakeError.log file:

clang-cl: warning: unknown argument ignored in clang-cl '-ipo'; did you mean '-Qipo'? [-Wunknown-argument]

Indeed, pybind11Common.cmake doesn't seem to handle the ICX compiler correctly and misinterpret its CMAKE_CXX_COMPILER_ID (being IntelLLVM for new ICX) for the Intel Classic compiler (being Intel for old ICC/ICL).

I believe the ICX compiler expects -ipo on UNIX but -Qipo on WIN32.

Reproducible example code

cmake_minimum_required(
  VERSION 3.23.0)

set(CMAKE_C_COMPILER "icx")
set(CMAKE_CXX_COMPILER "icx")

enable_language(C CXX)

project(CMake-IntelLLVM-WIN32)

find_package(pybind11 CONFIG)

add_executable(cmake-intelllvm-win32 main.cpp)

Ran like:

cmake -G Ninja -B build\ -Dpybind11_ROOT:PATH=[...] .

Gives:

-- The C compiler identification is IntelLLVM 2022.1.0 with MSVC-like command-line
-- The CXX compiler identification is IntelLLVM 2022.1.0 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/apps/Python310/python.exe (found version "3.10.4")
-- Found PythonLibs: C:/apps/Python310/libs/python310.lib
-- Performing Test HAS_INTEL_IPO
-- Performing Test HAS_INTEL_IPO - Failed
-- Found pybind11: D:/... (found version "2.9.2")
-- Configuring done
-- Generating done
-- Build files have been written to: D:/...

mablanchard avatar Jul 18 '22 15:07 mablanchard

@mablanchard We would welcome a PR that fixes this and adds testing of the IntelLLVM compiler to our CI. Feel free to open one.

Skylion007 avatar Jul 19 '22 15:07 Skylion007