17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-05 05:14:27 +01:00

use clang's GNU driver on Windows, not clang-cl

CMake wires up C++20 module scanning for Clang only when the frontend
variant is GNU; for clang-cl it sets nothing and refuses to generate:
"the compiler does not provide a way to discover the import graph
dependencies". Not a missing tool, a hard gap - Compiler/Clang-CXX.cmake
guards the whole scandep block on the GNU variant.

clang++ on Windows still targets x86_64-pc-windows-msvc, so the ABI, the
SDK, the vcpkg packages and D3D12 are unchanged. CMake then takes the
GNU path and leaves MSVC false, which is what the /MD /Zi /O2 block wants
anyway; the version resource had to move to a WIN32 guard to survive.
This commit is contained in:
maj00r
2026-09-10 13:49:54 +02:00
parent 7daf200748
commit 78c8961591
2 changed files with 19 additions and 13 deletions

View File

@@ -24,7 +24,7 @@ env:
jobs: jobs:
# ============================================================ # ============================================================
# Windows / Clang (clang-cl) # Windows / Clang (GNU driver, MSVC ABI)
# ============================================================ # ============================================================
windows: windows:
@@ -45,9 +45,11 @@ jobs:
python-version: "3.14" python-version: "3.14"
architecture: "x64" architecture: "x64"
# clang-cl rather than plain clang: it keeps the MSVC ABI, so it links # clang++ with its GNU driver, not clang-cl: CMake only wires up C++20
# against the same Windows SDK, vcpkg packages and D3D12 libraries, and # module scanning for the GNU frontend variant, and refuses to generate
# only the front end changes. Pinned to the version the Linux job uses. # otherwise. The default target on Windows is still x86_64-pc-windows-msvc,
# so the ABI, the Windows SDK, the vcpkg packages and D3D12 are unchanged.
# Pinned to the version the Linux job uses.
- name: Install LLVM and Ninja - name: Install LLVM and Ninja
shell: pwsh shell: pwsh
run: | run: |
@@ -60,7 +62,8 @@ jobs:
python --version python --version
cmake --version cmake --version
ninja --version ninja --version
& "$env:ProgramFiles\LLVM\bin\clang-cl.exe" --version & "$env:ProgramFiles\LLVM\bin\clang++.exe" --version
& "$env:ProgramFiles\LLVM\bin\clang-scan-deps.exe" --version
Write-Host "Python:" Write-Host "Python:"
Get-Command python Get-Command python
@@ -79,7 +82,7 @@ jobs:
call setup.bat call setup.bat
# Ninja, not MSBuild: CMake's module dependency scanning is best supported # Ninja, not MSBuild: CMake's module dependency scanning is best supported
# there, and vcvars64 supplies the SDK and library paths clang-cl needs. # there, and vcvars64 supplies the SDK and library paths clang needs.
- name: Configure - name: Configure
shell: cmd shell: cmd
run: | run: |
@@ -89,8 +92,9 @@ jobs:
cmake -S . -B build ^ cmake -S . -B build ^
-G Ninja ^ -G Ninja ^
-DCMAKE_BUILD_TYPE=%CONFIG_WIN% ^ -DCMAKE_BUILD_TYPE=%CONFIG_WIN% ^
-DCMAKE_C_COMPILER="%ProgramFiles%/LLVM/bin/clang-cl.exe" ^ -DCMAKE_C_COMPILER="%ProgramFiles%/LLVM/bin/clang.exe" ^
-DCMAKE_CXX_COMPILER="%ProgramFiles%/LLVM/bin/clang-cl.exe" ^ -DCMAKE_CXX_COMPILER="%ProgramFiles%/LLVM/bin/clang++.exe" ^
-DCMAKE_RC_COMPILER="%ProgramFiles%/LLVM/bin/llvm-rc.exe" ^
-DPython3_ROOT_DIR=%PYROOT% -DPython3_ROOT_DIR=%PYROOT%
- name: Build - name: Build

View File

@@ -445,15 +445,17 @@ set(GLM_INCLUDE_DIR ${GLM_INCLUDE_DIR} "${DEPS_DIR}/glm/")
configure_file(${CMAKE_SOURCE_DIR}/eu07.rc.in configure_file(${CMAKE_SOURCE_DIR}/eu07.rc.in
${CMAKE_BINARY_DIR}/eu07.rc @ONLY) ${CMAKE_BINARY_DIR}/eu07.rc @ONLY)
# MSVC is true for clang-cl as well - it targets the same ABI and takes the same # Gated on WIN32, not MSVC: CMake only sets MSVC for the MSVC-style driver, and
# command line. Testing CMAKE_CXX_COMPILER_ID instead would silently drop the # the Windows build uses clang's GNU driver, which needs the version resource
# version resource and the icon from a clang-cl build. # and the icon just the same.
if (MSVC) if (WIN32)
# the Visual Studio generators enable RC on their own; Ninja does not # the Visual Studio generators enable RC on their own; Ninja does not
enable_language(RC) enable_language(RC)
set(SOURCES ${SOURCES} ${CMAKE_BINARY_DIR}/eu07.rc) set(SOURCES ${SOURCES} ${CMAKE_BINARY_DIR}/eu07.rc)
set(SOURCES ${SOURCES} eu07.ico) set(SOURCES ${SOURCES} eu07.ico)
add_compile_options("/utf-8") if (MSVC)
add_compile_options("/utf-8") # clang's GNU driver already reads UTF-8
endif()
endif() endif()
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})