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

CMake: Enable using clang-cl on windows #1651

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

enetheru
Copy link
Contributor

@enetheru enetheru commented Nov 24, 2024

As listed here: #1250
clang-cl on windows installed from official llvm website fails because it emulates the msvc interface.

Prior solution assumed that because compiler is clang it uses gnu interface.

CMake offers some helper variables to account for this simulation/emulation of other compilers like:
CMAKE_CXX_COMPILER_FRONTEND_VARIANT

This PR detects the difference and sets the helper variables to match what is in use.
It isn't robust enough to mix and match compiler and linker interfaces though, so using a gnu style linker with an msvc style compiler will fail.

I've tested this on windows and mac, with windows based compilers msvc, msys-gcc msys-clang, llvm, mingw64, without issue.

Fixes #1250

@enetheru enetheru requested a review from a team as a code owner November 24, 2024 03:54
@dsnopek dsnopek added cmake topic:buildsystem Related to the buildsystem or CI setup labels Nov 25, 2024
@dsnopek dsnopek added this to the 4.x milestone Nov 25, 2024
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I haven't tested (Windows isn't my main dev environment), but the code seems OK from a quick skimming, and CI is passing :-)

@enetheru
Copy link
Contributor Author

I've also fixed the commit message like asked.

@dsnopek
Copy link
Collaborator

dsnopek commented Nov 28, 2024

This one will need a rebase - there's a conflict after having merged a few of your other PRs

@enetheru enetheru marked this pull request as draft November 28, 2024 13:52
@enetheru enetheru force-pushed the clang-cl branch 2 times, most recently from d8eeba2 to 9b7b073 Compare November 28, 2024 15:18
@kelteseth
Copy link

@enetheru this is exactly what I needed, perfect timing haha 💖. Thank you! I do get the following warning for every file:

[build] [148/3524] Building CXX object xxxx\godot-cpp\CMakeFiles\template_debug.dir\gen\src\classes\gpu_particles_collision_sphere3d.cpp.obj
[build] clang-cl: warning: argument unused during compilation: '/MP31' [-Wunused-command-line-argument]

common_compiler_flags.cmake:78

            # MSVC only
            $<${IS_MSVC}:
                /MP${PROC_N}

31 because my 32 threads Ryzen -1

@enetheru
Copy link
Contributor Author

enetheru commented Dec 2, 2024

Thanks for the catch, looks like clang-cl doesnt care about that flag where MSVC does. I will account for it before I take the PR out of draft. Cheers.

@enetheru enetheru force-pushed the clang-cl branch 3 times, most recently from 76acc44 to 3b13aac Compare December 4, 2024 23:45
@enetheru
Copy link
Contributor Author

enetheru commented Dec 4, 2024

Rebased ontop of #1648

@enetheru enetheru marked this pull request as ready for review December 4, 2024 23:52
@enetheru enetheru requested a review from dsnopek December 4, 2024 23:52
@enetheru enetheru force-pushed the clang-cl branch 2 times, most recently from e19bba4 to 59574ab Compare December 6, 2024 23:34
detect clang with MSVC frontend using CMAKE_CXX_COMPILER_FRONTEND_VARIANT
@dsnopek dsnopek merged commit 38056d1 into godotengine:master Dec 9, 2024
11 checks passed
@dsnopek
Copy link
Collaborator

dsnopek commented Dec 9, 2024

Thanks!

@enetheru enetheru deleted the clang-cl branch December 9, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding fails on Windows using Ninja + Clang
3 participants