From 58542a693bcf39b787fee8e0e237aa0c1d6a6310 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 5 Jun 2024 20:36:27 +0200 Subject: [PATCH] Where gold? --- CMakeLists.txt | 2 +- arch/posix/CMakeLists.txt | 1 + cmake/compiler/gcc/compiler_flags.cmake | 1 + cmake/linker/ld/target.cmake | 1 + samples/basic/blinky/prj.conf | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f654bf224..2262bd8828 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -822,7 +822,7 @@ target_include_directories(${OFFSETS_LIB} PRIVATE ) # Make sure that LTO will never be enabled when compiling offsets.c -set_source_files_properties(${OFFSETS_C_PATH} PROPERTIES COMPILE_OPTIONS $) +set_source_files_properties(${OFFSETS_C_PATH} PROPERTIES COMPILE_OPTIONS "$;$") target_link_libraries(${OFFSETS_LIB} zephyr_interface) add_dependencies(zephyr_interface diff --git a/arch/posix/CMakeLists.txt b/arch/posix/CMakeLists.txt index 7312b042d0..e02686fa29 100644 --- a/arch/posix/CMakeLists.txt +++ b/arch/posix/CMakeLists.txt @@ -161,6 +161,7 @@ endif() if(CONFIG_CFI) zephyr_compile_options(-flto) target_compile_options(native_simulator INTERFACE "-flto") + target_link_options(native_simulator INTERFACE "-flto") list(APPEND LLVM_SANITIZERS "cfi") endif() diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index be08cc18ba..0c83f9f42b 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -24,6 +24,7 @@ set_compiler_property(PROPERTY optimization_size -Os) if(CMAKE_C_COMPILER_VERSION GREATER_EQUAL "4.5.0") set_compiler_property(PROPERTY optimization_lto -flto) set_compiler_property(PROPERTY prohibit_lto -fno-lto) + set_compiler_property(PROPERTY prohibit_cfi -fno-sanitize=cfi) endif() ####################################################### diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index 2d60e8ea63..5b6cb7a23d 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -131,6 +131,7 @@ function(toolchain_ld_link_elf) ${TOPT} ${TOOLCHAIN_LD_LINK_ELF_LINKER_SCRIPT} ${TOOLCHAIN_LD_LINK_ELF_LIBRARIES_POST_SCRIPT} + -flto ${LINKERFLAGPREFIX},-Map=${TOOLCHAIN_LD_LINK_ELF_OUTPUT_MAP} ${LINKERFLAGPREFIX},--whole-archive diff --git a/samples/basic/blinky/prj.conf b/samples/basic/blinky/prj.conf index 52e93bacbb..65722b4a06 100644 --- a/samples/basic/blinky/prj.conf +++ b/samples/basic/blinky/prj.conf @@ -1,3 +1,4 @@ CONFIG_GPIO=y CONFIG_ASAN=y CONFIG_CFI=y +#CONFIG_LLVM_USE_LLD=y