KhronosGroup/Vulkan-Loader

clang-cl arguments are being passed to clang on Windows

pgrossomoreira opened this issue · 2 comments

Hi,

When using vulkan-loader/1.3.268.0 from conan on Windows and compiling with clang (not clang-cl), the following compiler arguments are passed to clang:
/W4 /clang:-fno-strict-aliasing /clang:-fno-builtin-memcmp /GR- /guard:cf /wd4152 /wd4201

This results in the following error:

FAILED: loader/CMakeFiles/loader-opt.dir/unknown_ext_chain.c.obj
C:\PROGRA~1\LLVM\bin\clang.exe -DAPI_NAME=\"Vulkan\" -DVK_ENABLE_BETA_EXTENSIONS -DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN -IC:/Users/pedro/.conan2/p/b/vulka0a6b42b1a53c3/b/src/loader -IC:/Users/pedro/.conan2/p/b/vulka0a6b42b1a53c3/b/src/loader/generated -IC:/Users/pedro/.conan2/p/b/vulka0a6b42b1a53c3/b/build/Release/loader -isystem C:/Users/pedro/.conan2/p/vulka7665c156c662b/p/include -m64 -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt /W4 -Wno-missing-field-initializers /clang:-fno-strict-aliasing /clang:-fno-builtin-memcmp -Wpointer-arith /GR- /guard:cf /wd4152 /wd4201 -O -MD -MT loader/CMakeFiles/loader-opt.dir/unknown_ext_chain.c.obj -MF loader\CMakeFiles\loader-opt.dir\unknown_ext_chain.c.obj.d -o loader/CMakeFiles/loader-opt.dir/unknown_ext_chain.c.obj -c C:/Users/pedro/.conan2/p/b/vulka0a6b42b1a53c3/b/src/loader/unknown_ext_chain.c
clang: error: no such file or directory: '/W4'
clang: error: no such file or directory: '/clang:-fno-strict-aliasing'
clang: error: no such file or directory: '/clang:-fno-builtin-memcmp'
clang: error: no such file or directory: '/GR-'
clang: error: no such file or directory: '/guard:cf'
clang: error: no such file or directory: '/wd4152'
clang: error: no such file or directory: '/wd4201'

These arguments would probably work if they were passed to clang-cl, but they won't work with clang. The CMakeLists.txt file shouldn't assume that clang on Windows means clang-cl.

I'm no CMake expert, but perhaps CMAKE_CXX_COMPILER_ID and CMAKE_CXX_SIMULATE_ID aren't enough to determine which flags to pass to the compiler.

I'm no CMake expert, but perhaps CMAKE_CXX_COMPILER_ID and CMAKE_CXX_SIMULATE_ID aren't enough to determine which flags to pass to the compiler.

It's more of a matter of just adding a test configuration to CI. Getting all the compiler / linker permutations working is just difficult without testing.

We currently only test clang-cl on Windows:

windows_clang_cl:

I added additional to CI to prevent a regression like this:
#1418