-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support building with clang-cl #100
base: getsentry
Are you sure you want to change the base?
Conversation
Thanks, @Nerixyz; I started with a As you can see, I also changed the build scripts for What stopped me was that we have a couple of compile conditionals in the code (ours and crashpad) that query the platform/toolchain, where the paths expressed considered clang always not to be MSVC, and that can be problematic even if no compile errors happen. |
Sorry for the late reply @supervacuus, I checked a few headers in
Could you point out some conditionals in crashpad that assume this? Maybe these can be changed upstream (or maybe
You added the flags for each CMake target in 2237d97...e5c4398 (that's probably why it looks quite big). I added the flags in Looking at diff --git a/build/clang-cl.bat b/build/msvc.bat
index 18964946..fee41ba0 100644
--- a/build/clang-cl.bat
+++ b/build/msvc.bat
@@ -1,6 +1,6 @@
-D:\LLVM\bin\clang-cl.exe
+"D:\VisualStudio 2022\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64\cl.exe"
/nologo
--TP
+/TP
-DCRASHPAD_FLOCK_ALWAYS_SUPPORTED=1
-DCRASHPAD_LSS_SOURCE_EMBEDDED
-DNOMINMAX
@@ -35,11 +35,8 @@ D:\LLVM\bin\clang-cl.exe
/wd4324
/wd4351
/wd4577
--Wno-missing-field-initializers
--Wno-sign-compare
--Wno-microsoft-cast
/Fotools\crash-handler\lib\crashpad\third_party\mini_chromium\CMakeFiles\mini_chromium.dir\mini_chromium\base\threading\thread_local_storage_win.cc.obj
/FdTARGET_COMPILE_PDB
+/FS
-c
---
G:\Projects\c2\tools\crash-handler\lib\crashpad\third_party\mini_chromium\mini_chromium\base\threading\thread_local_storage_win.cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Nerixyz, sorry for the long response gap.
I cannot compile the current PR proposal with clang-cl. Does a build run successfully if you configure (either this fork or sentry-native with your crashpad changes) with
cmake -B build_cl -G "Visual Studio 17 2022" -T ClangCL
because this immediately leads to further warnings/errors in my setup.
Could you point out some conditionals in crashpad that assume this? Maybe these can be changed upstream (or maybe mini_chromium could officially support clang-cl (?)).
I mostly meant conditionals in the CMake build scripts. But there are a few #ifdef
s affecting clang-cl too: __debugbreak();
vs. __builtin_trap();
for instance, though that is less relevant.
You added the flags for each CMake target
Yes, this was intentional because the overlap between the targets was relatively small if you look into my changes. I am more than open to adding warning suppressions to the interface once the build works if those warnings appear in all targets (like -Wno-unused-parameter
, which curiously does not appear in your PR), but I would like to limit suppressions as much as possible to the affected targets.
This PR also needs a clang-cl build step, so that changes from upstream or us are checked against clang-cl.
Same for me. It seems like MsBuild or the VS generator swallows the I usually use Ninja to build, which works fine with both the cmake -B build_cl2 -GNinja -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl Even Visual Studio itself will use Ninja by default. So if you select Omitting the
It doesn't appear, because clang translates |
Thanks for the check! While the behavior makes little sense, it is consistent with other generator differences on Windows we observe, and I think this is a sufficient discriminator. That means we only have to add
Of course, switching to Ninja on Windows is an option for us (and preferable, given the significant performance difference and increasing tool support). But if we add support for Are you okay with me taking over so that I can work on the Native SDK integration and CI support? |
Sure! We only use this library, so I don't have much experience with the SDK. I could add the remaining flags later but feel free to just do that if you have time. |
Finally updated the branch. I moved to generator expressions to unify the flags for MSVC and clang-cl. @supervacuus feel free to push to this branch. |
This PR adds support for building crashpad with
clang-cl
(see getsentry/sentry-native#689). It adds the following flags tocrashpad_interface
:-Wno-missing-field-initializers
(e.g. required in util/file/file_io_win.cc)-Wno-sign-compare
(e.g. required in third_party/mini_chromium/mini_chromium/base/threading/thread_local_storage.h)-Wno-microsoft-cast
(e.g. required in client/crashpad_client_win.cc)Crashpad itself (or rather mini_chromium) doesn't appear to support
clang-cl
and defaults tocl
on Windows (though I don't know gn that well).