From 38e5cbead06a968b5bd528d8629720e0a0605267 Mon Sep 17 00:00:00 2001 From: guoshichao Date: Wed, 12 Mar 2025 09:57:04 +0800 Subject: [PATCH] ghs: move the -fmacro-prefix-map compile option to compiler specific the -fmacro-prefix-map compile option is gcc/clang/armclang specific compile option, and greenhills do not recognize this compile option, if we add this option is CMakeLists.txt, the following warning will be reported when each file is being compiled: ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/nuttx=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/apps=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/vendor/flagchip/boards/mann/dcu/fc4150f1m-labm_a1=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/vendor/flagchip/chips/fc4150=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/nuttx=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/apps=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/vendor/flagchip/boards/mann/dcu/fc4150f1m-labm_a1=" passed to linker ccarm: Warning: Unknown option "-fmacro-prefix-map=/home/guoshichao/work_profile/vela_os/vela_car_5/vendor/flagchip/chips/fc4150=" passed to linker Signed-off-by: guoshichao --- CMakeLists.txt | 16 ---------------- cmake/nuttx_toolchain.cmake | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82ff10e2cd9..148b05047c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -502,22 +502,6 @@ if(CONFIG_NDEBUG) add_compile_options(-DNDEBUG) endif() -# Cmake build provide absolute paths to compile files. If __FILE__ macros are -# used in the source code(ASSERT), the binary will contain many invalid paths. -# This saves some memory, stops exposing build systems locations in binaries, -# make failure logs more deterministic and most importantly makes builds more -# failure logs more deterministic and most importantly makes builds more -# deterministic. Debuggers usually have a path mapping feature to ensure the -# files are still found. -if(NOT MSVC) - if(CONFIG_OUTPUT_STRIP_PATHS) - add_compile_options(-fmacro-prefix-map=${NUTTX_DIR}=) - add_compile_options(-fmacro-prefix-map=${NUTTX_APPS_DIR}=) - add_compile_options(-fmacro-prefix-map=${NUTTX_BOARD_ABS_DIR}=) - add_compile_options(-fmacro-prefix-map=${NUTTX_CHIP_ABS_DIR}=) - endif() -endif() - add_definitions(-D__NuttX__) add_compile_options($<$:-D__ASSEMBLY__>) diff --git a/cmake/nuttx_toolchain.cmake b/cmake/nuttx_toolchain.cmake index 0b728f2c47f..beecf63424a 100644 --- a/cmake/nuttx_toolchain.cmake +++ b/cmake/nuttx_toolchain.cmake @@ -30,6 +30,22 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") endif() endif() +# Cmake build provide absolute paths to compile files. If __FILE__ macros are +# used in the source code(ASSERT), the binary will contain many invalid paths. +# This saves some memory, stops exposing build systems locations in binaries, +# make failure logs more deterministic and most importantly makes builds more +# failure logs more deterministic and most importantly makes builds more +# deterministic. Debuggers usually have a path mapping feature to ensure the +# files are still found. +if((NOT MSVC) AND (NOT CONFIG_ARCH_TOOLCHAIN_GHS)) + if(CONFIG_OUTPUT_STRIP_PATHS) + add_compile_options(-fmacro-prefix-map=${NUTTX_DIR}=) + add_compile_options(-fmacro-prefix-map=${NUTTX_APPS_DIR}=) + add_compile_options(-fmacro-prefix-map=${NUTTX_BOARD_ABS_DIR}=) + add_compile_options(-fmacro-prefix-map=${NUTTX_CHIP_ABS_DIR}=) + endif() +endif() + # Support CMake to define additional configuration options if(EXTRA_FLAGS)