diff --git a/CMakeLists.txt b/CMakeLists.txt index bdf5e0c176f..a7701288975 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,10 @@ if(TOOLCHAIN_USE_CUSTOM) zephyr_compile_definitions(__TOOLCHAIN_CUSTOM__) endif() +# @Intent: Set compiler specific flag for disabling strict aliasing rule +zephyr_compile_options($<$:$>) +zephyr_compile_options($<$:$>) + # @Intent: Set compiler flags to enable buffer overflow checks in libc functions # @config in CONFIG_NO_OPTIMIZATIONS optional : Optimizations may affect security zephyr_compile_definitions($ ) diff --git a/cmake/compiler/compiler_flags_template.cmake b/cmake/compiler/compiler_flags_template.cmake index b6fb8eb4d46..28b2e7a805a 100644 --- a/cmake/compiler/compiler_flags_template.cmake +++ b/cmake/compiler/compiler_flags_template.cmake @@ -65,6 +65,9 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a) set_property(TARGET compiler-cpp PROPERTY dialect_cpp20) set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b) +# Flag for disabling strict aliasing rule in C and C++ +set_compiler_property(PROPERTY no_strict_aliasing) + # Flag for disabling exceptions in C++ set_property(TARGET compiler-cpp PROPERTY no_exceptions)