cmake: compiler: Remove -fshort-enums

"-fshort-enums" changes the ABI. It's not enabled for gcc, so it's not
clear why it's enabled for clang (only ARM) and armclang, other than it
looks like some users of these toolchains may be linking against code
that is compiled with "-fshort-enums".

As an example, when compiling with clang, CONFIG_LTO, and a toolchain
built without "-fshort-enums", the linker warns:

ld.lld: error: linking module flags 'min_enum_size': IDs have
conflicting values in
'/usr/armv7m-cros-eabi/usr/lib/libc++_static.a(string.cpp.o at 784090)'
and 'ld-temp.o'

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
This commit is contained in:
Tom Hughes 2025-05-30 13:56:43 -07:00 committed by Benjamin Cabé
commit b6766aeb6b
2 changed files with 0 additions and 11 deletions

View file

@ -16,10 +16,6 @@ include(${ZEPHYR_BASE}/cmake/gcc-m-fpu.cmake)
# 'cortex-m33+nodsp' we need that to be 'cortex-m33' for CMAKE_SYSTEM_PROCESSOR
string(REGEX REPLACE "\\+.*" "" CMAKE_SYSTEM_PROCESSOR ${GCC_M_CPU})
list(APPEND TOOLCHAIN_C_FLAGS
-fshort-enums
)
if(CONFIG_ARM64)
list(APPEND TOOLCHAIN_C_FLAGS -mcpu=${GCC_M_CPU})

View file

@ -29,13 +29,6 @@ if(NOT "${ARCH}" STREQUAL "posix")
include(${ZEPHYR_BASE}/cmake/gcc-m-fpu.cmake)
if("${ARCH}" STREQUAL "arm")
list(APPEND TOOLCHAIN_C_FLAGS
-fshort-enums
)
list(APPEND TOOLCHAIN_LD_FLAGS
-fshort-enums
)
include(${ZEPHYR_BASE}/cmake/compiler/clang/target_arm.cmake)
elseif("${ARCH}" STREQUAL "arm64")
include(${ZEPHYR_BASE}/cmake/compiler/clang/target_arm64.cmake)