From 38010adc026e54c320073b830380347c5205225f Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Tue, 25 Jun 2024 16:56:08 +0800 Subject: [PATCH] nuttx/mm: fix cmake kasan flags Signed-off-by: xuxingliang --- mm/kasan/CMakeLists.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mm/kasan/CMakeLists.txt b/mm/kasan/CMakeLists.txt index 3f7e32d668..56b8e5425a 100644 --- a/mm/kasan/CMakeLists.txt +++ b/mm/kasan/CMakeLists.txt @@ -22,11 +22,21 @@ set(SRCS hook.c) if(CONFIG_MM_KASAN) - list(APPEND SRCS generic.c) - set_source_files_properties(generic.c PROPERTIES COMPILE_FLAGS - -fno-sanitize=kernel-address) - set_source_files_properties(generic.c PROPERTIES COMPILE_FLAGS -fno-builtin) - set_source_files_properties(generic.c PROPERTIES COMPILE_FLAGS -fno-lto) + list(APPEND FLAGS -fno-builtin) + if(CONFIG_MM_KASAN_GENERIC) + list(APPEND SRCS generic.c) + list(APPEND FLAGS -fno-sanitize=kernel-address) + endif() + + if(CONFIG_MM_KASAN_SW_TAGS) + list(APPEND SRCS sw_tags.c) + list(APPEND FLAGS -fno-sanitize=kernel-hwaddress) + endif() + + if(CONFIG_LTO_NONE) + list(APPEND FLAGS -fno-lto) + endif() endif() target_sources(mm PRIVATE ${SRCS}) +target_compile_options(mm PRIVATE ${FLAGS})