- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.2k
[release/10.0] Apply changes for building with clang-21 #121124
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
base: release/10.0
Are you sure you want to change the base?
Conversation
| Tagging subscribers to this area: @hoyosjs | 
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.
Pull Request Overview
This PR addresses build failures when using clang-21 on Fedora 43 by adapting to a breaking change introduced in clang-20. The clang-20 compiler split the -fwrapv flag into separate -fwrapv and -fwrapv-pointer flags, and this PR migrates to using -fno-strict-overflow which implies both behaviors.
Key Changes:
- Replaced -fwrapvwith-fno-strict-overflowto handle signed arithmetic overflow behavior in a way compatible with clang-20+
- Fixed type casting issues in CoreCLR debug interface code to avoid enum-to-int implicit conversion errors
- Added -fno-strict-aliasingflag to match MSVC behavior
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| src/mono/CMakeLists.txt | Replaced -fwrapvwith-fno-strict-overflowand updated comments to explain the clang-20+ behavior | 
| src/coreclr/debug/di/rsthread.cpp | Added explicit cast from m_userStatetoCorDebugUserStateenum and changed local variable type toint | 
| src/coreclr/debug/di/rspriv.h | Changed m_userStatemember variable type fromCorDebugUserStatetointand updatedkInvalidUserStateconstant accordingly | 
| eng/native/configurecompiler.cmake | Replaced -fwrapvwith-fno-strict-overflowand added-fno-strict-aliasingflag with updated comments | 
Customer Impact
These issues were reported in #119706 as problems with clang-21 on Fedora 43. The investigation uncovered that clang introduced a potentially breaking change in clang-20 that we do not currently consume. These build changes impact VMR related builds when linux distrobutions performing source build adopt clang-21.
clang-20 breaking change log - https://releases.llvm.org/20.1.0/tools/clang/docs/ReleaseNotes.html#potentially-breaking-changes.
This PR contains the minimal changes needed to fix issues from the following PRs #120644 and #120775.
Regression
Moving to the new clang-21 compiler will cause the runtime to crash. This is a regression from using .NET 10 and the default compiler of clang-19.
Testing
This has been validated using various legs and examples to demonstrate the usage of undefined behavior these flags convert into "defined" behavior in C/C++.
Risk
Low. This makes clang-21 more permissive and is limited to non official product builds.