diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index bc3f37b2fc5..1921d97dc52 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -162,12 +162,14 @@ check_set_compiler_property(APPEND PROPERTY hosted -fno-freestanding) # gcc flag for a freestandingapplication set_compiler_property(PROPERTY freestanding -ffreestanding) -# Flag to enable debugging -set_compiler_property(PROPERTY debug -g) +if(NOT DEFINED GCC_NO_G_FLAG) + # Flag to enable debugging + set_compiler_property(PROPERTY debug -g) -# GCC 11 by default emits DWARF version 5 which cannot be parsed by -# pyelftools. Can be removed once pyelftools supports v5. -check_set_compiler_property(APPEND PROPERTY debug -gdwarf-4) + # GCC 11 by default emits DWARF version 5 which cannot be parsed by + # pyelftools. Can be removed once pyelftools supports v5. + check_set_compiler_property(APPEND PROPERTY debug -gdwarf-4) +endif() set_compiler_property(PROPERTY no_common -fno-common) diff --git a/cmake/compiler/xcc/compiler_flags.cmake b/cmake/compiler/xcc/compiler_flags.cmake index a6205bbf546..6642eac2a6a 100644 --- a/cmake/compiler/xcc/compiler_flags.cmake +++ b/cmake/compiler/xcc/compiler_flags.cmake @@ -1,6 +1,10 @@ # No special flags are needed for xcc. # Only select whether gcc or clang flags should be inherited. if(CC STREQUAL "clang") + if($ENV{XCC_NO_G_FLAG}) + set(GCC_NO_G_FLAG 1) + endif() + include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake) else() include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake)