Skip to content

Commit 14fd230

Browse files
Refine compiler options for signed overflow and aliasing (#5618)
Updated comments and compile options for signed overflow and strict aliasing. See related code for dotnet/runtime - dotnet/runtime#120775
1 parent 73f1fdc commit 14fd230

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

eng/native/configurecompiler.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,14 @@ if (CLR_CMAKE_HOST_UNIX)
526526
# Disable frame pointer optimizations so profilers can get better call stacks
527527
add_compile_options(-fno-omit-frame-pointer)
528528

529-
# Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
529+
# Make signed overflow well-defined. Implies the following flags in clang-20 and above.
530+
# -fwrapv - Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
530531
# using twos-complement representation (this is normally undefined according to the C++ spec).
531-
add_compile_options(-fwrapv)
532+
# -fwrapv-pointer - The same as -fwrapv but for pointers.
533+
add_compile_options(-fno-strict-overflow)
534+
535+
# Suppress C++ strict aliasing rules. This matches our use of MSVC.
536+
add_compile_options(-fno-strict-aliasing)
532537

533538
if(CLR_CMAKE_HOST_APPLE)
534539
# Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand.

0 commit comments

Comments
 (0)