fix: missing compilation flag on recent msvc version - #2032
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Thanks for this — the 1. It also hits compilers that don't want it. CMake's Suggest gating on the compiler ID instead: if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
# Only real cl.exe needs (and accepts) the conformant preprocessor switch;
# clang-cl / icx are already conformant and warn on it.
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor")
endif()
# /arch:AVX2 is only valid for x86/x64 targets, not ARM64
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _msvc_arch)
if(_msvc_arch MATCHES "x86|x64|amd64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
endif()
endif()2. It may not fix the failure it's aimed at. The flag lands in https://github.com/bitsandbytes-foundation/bitsandbytes/blob/a2b90e6/CMakeLists.txt#L197-L200 If the failure is nvcc-side, loosening that gate (e.g. keying on 3. Could you add the error to the description? All Windows jobs are green on If it turns out to be |
CMake's MSVC variable is also true for MSVC-emulating compilers (clang-cl, and Intel icx used by the XPU backend on Windows), which ship an already-conformant preprocessor and warn on the flag: icx: warning: argument unused during compilation: '-Zc:preprocessor' Restrict the switch to CMAKE_CXX_COMPILER_ID == MSVC.
In recent MSVC compiler versions it needs to specify which preprocessor to use.
This PR addresses this adding the required flag for MSVC.