Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrade adds /wd*** warning disablements to "clang.exe" on windows. #149

Open
jonesmz opened this issue Sep 11, 2022 · 1 comment
Open
Projects
Milestone

Comments

@jonesmz
Copy link

jonesmz commented Sep 11, 2022

See CI run here: https://github.com/jonesmz/osp-magnum/runs/8295594455

Note that this isn't clang-cl.exe, this is clang.exe

During the configuration we get :

-- The CXX compiler identification is Clang 15.0.0 with GNU-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- IPO / LTO enabled
-- The C compiler identification is Clang 15.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done

Note that in the same run, ClangCL has this configuration output:

-- The CXX compiler identification is Clang 14.0.5 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- IPO / LTO enabled
-- The C compiler identification is Clang 14.0.5 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done

and then later:

FAILED: 3rdparty/corrade/src/Corrade/CMakeFiles/CorradeMain.dir/CorradeMain.cpp.obj 
C:\PROGRA~1\LLVM\bin\c++.exe -DNOMINMAX -DUNICODE -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -ID:/a/osp-magnum/osp-magnum/3rdparty/corrade/src -ID:/a/osp-magnum/osp-magnum/build/3rdparty/corrade/src -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -flto=thin -fno-omit-frame-pointer /W4 /wd4127 /wd4251 /wd4244 /wd4267 /wd4324 /wd4351 /wd4373 /wd4458 /wd4510 /wd4610 /wd4512 /wd4661 /wd4702 /wd4706 /wd4800 /wd4910 -Wno-microsoft-cast -std=c++20 -MD -MT 3rdparty/corrade/src/Corrade/CMakeFiles/CorradeMain.dir/CorradeMain.cpp.obj -MF 3rdparty\corrade\src\Corrade\CMakeFiles\CorradeMain.dir\CorradeMain.cpp.obj.d -o 3rdparty/corrade/src/Corrade/CMakeFiles/CorradeMain.dir/CorradeMain.cpp.obj -c D:/a/osp-magnum/osp-magnum/3rdparty/corrade/src/Corrade/CorradeMain.cpp
c++: error: no such file or directory: '/W4'
c++: error: no such file or directory: '/wd4127'
c++: error: no such file or directory: '/wd4251'
c++: error: no such file or directory: '/wd4244'
c++: error: no such file or directory: '/wd4267'
c++: error: no such file or directory: '/wd4324'
c++: error: no such file or directory: '/wd4351'
c++: error: no such file or directory: '/wd4373'
c++: error: no such file or directory: '/wd4458'
c++: error: no such file or directory: '/wd4510'
c++: error: no such file or directory: '/wd4610'
c++: error: no such file or directory: '/wd4512'
c++: error: no such file or directory: '/wd4661'
c++: error: no such file or directory: '/wd4702'
c++: error: no such file or directory: '/wd4706'
c++: error: no such file or directory: '/wd4800'
c++: error: no such file or directory: '/wd4910'

These appear to be coming from https://github.com/mosra/corrade/blob/master/modules/UseCorrade.cmake around line 158

Which is perplexing, as i see this check

elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")

Obviously the COMPILER_ID isn't "MSVC", but perhaps cmake has somehow decided that Clang 15.0.0 with GNU-like command-line is simulating "MSVC"?

Looking at this issue in the cmake bug tracker, there's apparently also a CMAKE_CXX_COMPILER_FRONTEND_VARIANT which will be set to either "MSVC" or "GNU" depending on if we're using clang-cl.exe or clang.exe

https://gitlab.kitware.com/cmake/cmake/-/issues/19724

@mosra
Copy link
Owner

mosra commented Sep 13, 2022

What a cursed issue you got into, heh... wasn't even aware of such distinction. Going with _FRONTEND_VARIANT seems to be the way, yes, but looking at https://discourse.cmake.org/t/clang-on-windows-detected-with-msvc-interface/3470/9 linked from there it seems it won't be that simple and likely more changes will be needed to get non-CL Clang fully working 😅

Once you make this work, could you open a PR with the necessary changes to UseCorrade? Ideally it would do the detection correctly just once at the top:

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CORRADE_TARGET_CLANG 1)
if(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(CORRADE_TARGET_CLANG_CL 1)
set(CORRADE_TARGET_MSVC 1)
else()
set(CORRADE_TARGET_GCC 1)
endif()
endif()

and then use the CORRADE_TARGET_ defines from there onwards, instead of repeating complex checks for CMAKE_CXX_COMPILER_ID etc. Thanks in advance! 👍

@mosra mosra added this to the 2022.0a milestone Sep 13, 2022
@mosra mosra added this to TODO in Platforms via automation Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Platforms
  
TODO
Development

No branches or pull requests

2 participants