From c564d1730fb6dc38bb6fa3a30366d49ad3f73300 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Sun, 7 Apr 2019 20:33:56 +0800 Subject: [PATCH] esp_common: append gc sections link flag --- components/esp_common/CMakeLists.txt | 3 +++ tools/cmake/project.cmake | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp_common/CMakeLists.txt b/components/esp_common/CMakeLists.txt index 3ba1b8224d..18ffe93678 100644 --- a/components/esp_common/CMakeLists.txt +++ b/components/esp_common/CMakeLists.txt @@ -4,6 +4,7 @@ if(BOOTLOADER_BUILD) set(COMPONENT_REQUIRES ${IDF_COMPONENTS}) set(COMPONENT_SRCS ) register_component() + set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-Wl,--gc-sections") else() # Regular app build set(COMPONENT_SRCS @@ -26,4 +27,6 @@ else() "src/stack_check.c" PROPERTIES COMPILE_FLAGS -fno-stack-protector) + set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_LIBRARIES "-Wl,--gc-sections") + set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-Wl,--gc-sections") endif() diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 437e715a48..4522d0a2cf 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -352,7 +352,6 @@ macro(project project_name) add_executable(${project_elf} "${project_elf_src}") add_dependencies(${project_elf} _project_elf_src) - target_link_libraries(${project_elf} "-Wl,--gc-sections") target_link_libraries(${project_elf} "-Wl,--start-group") if(test_components)