Merge branch 'bugfix/generic_cmake_gc_sections' into 'master'

generic cmake: Always use gc-sections when linking IDF libraries

See merge request idf/esp-idf!3873
This commit is contained in:
Angus Gratton 2018-12-04 11:01:51 +08:00
commit 2b557523ba
2 changed files with 5 additions and 3 deletions

View File

@ -246,6 +246,9 @@ function(idf_link_components target components)
endforeach()
if(libraries)
# gc-sections is necessary for linking some IDF binary libraries
# (and without it, IDF apps are much larger than they should be)
target_link_libraries(${target} "-Wl,--gc-sections")
target_link_libraries(${target} "-Wl,--start-group")
target_link_libraries(${target} ${libraries})
message(STATUS "Component libraries: ${IDF_COMPONENT_LIBRARIES}")
@ -258,4 +261,4 @@ endfunction()
function(idf_import_components var idf_path build_path)
add_subdirectory(${idf_path} ${build_path})
set(${var} ${BUILD_COMPONENTS} PARENT_SCOPE)
endfunction()
endfunction()

View File

@ -102,8 +102,7 @@ macro(project name)
set(mapfile "${CMAKE_PROJECT_NAME}.map")
target_link_libraries(${IDF_PROJECT_EXECUTABLE} "-Wl,--gc-sections \
-Wl,--cref -Wl,--Map=${mapfile}")
target_link_libraries(${IDF_PROJECT_EXECUTABLE} "-Wl,--cref -Wl,--Map=${mapfile}")
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES