Skip to content

Conversation

@AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Oct 28, 2025

Customer Impact

  • Customer reported
  • Found internally

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 PR #120775.

.NET 10: #121124
.NET 8: #121150

Regression

  • Yes
  • No

Build with the new clang-21 compiler will cause the runtime to crash.

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 has zero impact on our production build since we specifically target clang-18. This is only valid for those partners that are using clang-20+.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a 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 updates compiler flags for Clang version 20 and above on Unix hosts. When Clang 20+ is detected, it switches from using -fwrapv to using -fno-strict-overflow (which implies -fwrapv and -fwrapv-pointer in Clang 20+) and also adds -fno-strict-aliasing to match MSVC behavior.

Key changes:

  • Adds version detection for Clang 20.0 and above
  • Uses -fno-strict-overflow and -fno-strict-aliasing for Clang 20+
  • Maintains existing -fwrapv flag for older compiler versions

@jkotas
Copy link
Member

jkotas commented Oct 28, 2025

Does this need to include the fix for the debugger build break as well?

cc @tmds

Comment on lines +529 to +530
if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 20.0) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.0))
Copy link
Member

Choose a reason for hiding this comment

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

Any concern here about Clang on macOS? If so, this should use MATCHES instead of STREQUAL.

@jkotas jkotas changed the title Add flags when the clang's major version is > 20.0 [release/9.0-staging] Add flags when the clang's major version is > 20.0 Oct 29, 2025
@tmds
Copy link
Member

tmds commented Oct 29, 2025

This is missing the CorDebugUserState change (which is a compiler error and not a warning):

di/rspriv.h:6357:36: error: in-class initializer for static data member is not a constant expression
       6357 |     static const CorDebugUserState kInvalidUserState = CorDebugUserState(-1);

@tmds
Copy link
Member

tmds commented Oct 29, 2025

Does this need to include the fix for the debugger build break as well?

We should fix anything that is in dotnet/dotnet that ends up in the distro's DOTNET_ROOT.

It's not needed to fix sources that Microsoft compiles (with clang < 21) and ships through nuget.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Infrastructure-coreclr Servicing-consider Issue for next servicing release review

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants