Skip to content

Commit 19211f0

Browse files
Modify compiler options for overflow and aliasing
Updated compiler options to improve signed overflow handling and suppress strict aliasing rules. See related code for dotnet/runtime#120775
1 parent afb5429 commit 19211f0

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
@@ -276,9 +276,14 @@ if (CLR_CMAKE_HOST_UNIX)
276276
#-fms-compatibility Enable full Microsoft Visual C++ compatibility
277277
#-fms-extensions Accept some non-standard constructs supported by the Microsoft compiler
278278

279-
# Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
279+
# Make signed overflow well-defined. Implies the following flags in clang-20 and above.
280+
# -fwrapv - Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
280281
# using twos-complement representation (this is normally undefined according to the C++ spec).
281-
add_compile_options(-fwrapv)
282+
# -fwrapv-pointer - The same as -fwrapv but for pointers.
283+
add_compile_options(-fno-strict-overflow)
284+
285+
# Suppress C++ strict aliasing rules. This matches our use of MSVC.
286+
add_compile_options(-fno-strict-aliasing)
282287

283288
if(CLR_CMAKE_HOST_OSX)
284289
# We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)

0 commit comments

Comments
 (0)