mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(cmakev2): wrap library archives with --start-group/--end-group
Attach the flags as the first and last entries of the library's INTERFACE_LINK_LIBRARIES so the linker re-scans archives until all symbols resolve.
This commit is contained in:
@@ -361,11 +361,25 @@ function(idf_build_library library)
|
|||||||
|
|
||||||
# Include the requested components and link their interface targets to the
|
# Include the requested components and link their interface targets to the
|
||||||
# library.
|
# library.
|
||||||
|
#
|
||||||
|
# On the GNU linker, bracket the component interface list with
|
||||||
|
# --start-group/--end-group so the linker re-scans archives until all
|
||||||
|
# symbols resolve. Required when the archive defining a __wrap_*
|
||||||
|
# implementation is encountered after the archive consuming the wrapped
|
||||||
|
# symbol on the link line; without group iteration the wrap symbol is
|
||||||
|
# unresolved.
|
||||||
|
idf_build_get_property(linker_type LINKER_TYPE)
|
||||||
|
if("${linker_type}" STREQUAL "GNU")
|
||||||
|
target_link_libraries("${library}" INTERFACE "-Wl,--start-group")
|
||||||
|
endif()
|
||||||
foreach(component_name IN LISTS ARG_COMPONENTS)
|
foreach(component_name IN LISTS ARG_COMPONENTS)
|
||||||
idf_component_include("${component_name}")
|
idf_component_include("${component_name}")
|
||||||
idf_component_get_property(component_interface "${component_name}" COMPONENT_INTERFACE)
|
idf_component_get_property(component_interface "${component_name}" COMPONENT_INTERFACE)
|
||||||
target_link_libraries("${library}" INTERFACE "${component_interface}")
|
target_link_libraries("${library}" INTERFACE "${component_interface}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
if("${linker_type}" STREQUAL "GNU")
|
||||||
|
target_link_libraries("${library}" INTERFACE "-Wl,--end-group")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Process optional requirements in DEFERRED mode only (no-op in IMMEDIATE or when unset).
|
# Process optional requirements in DEFERRED mode only (no-op in IMMEDIATE or when unset).
|
||||||
idf_build_get_property(opt_req_mode IDF_COMPONENT_OPTIONAL_REQUIRES_MODE)
|
idf_build_get_property(opt_req_mode IDF_COMPONENT_OPTIONAL_REQUIRES_MODE)
|
||||||
|
|||||||
Reference in New Issue
Block a user