build system: explicitly disable LTO plugin

... to reduce the number of simultaneously open files at link time.

When plugin support is enabled in the linker, BFD's (and the
corresponding file handles) are cached for the plugin to use. This
results in quite a large number of simultaneously open files, which
hits the default limit on macOS (256 files).

Since we aren't using LTO now, disable it explicitly when invoking the
linker.

Closes IDF-923
Closes IDFGH-1764
Closes https://github.com/espressif/esp-idf/issues/3989
This commit is contained in:
Ivan Grokhotkov 2019-11-20 14:18:28 +01:00
parent 9e49a5dc34
commit f49a78d543
2 changed files with 8 additions and 0 deletions

View File

@ -5,6 +5,7 @@ unset(compile_options)
unset(c_compile_options) unset(c_compile_options)
unset(cxx_compile_options) unset(cxx_compile_options)
unset(compile_definitions) unset(compile_definitions)
unset(link_options)
# Add the following build specifications here, since these seem to be dependent # Add the following build specifications here, since these seem to be dependent
# on config values on the root Kconfig. # on config values on the root Kconfig.
@ -62,11 +63,13 @@ elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
list(APPEND compile_options "-fstack-protector-all") list(APPEND compile_options "-fstack-protector-all")
endif() endif()
list(APPEND link_options "-fno-lto")
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND) idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND) idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND) idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND) idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS) idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)

View File

@ -460,6 +460,11 @@ endmacro()
# files used for linking, targets which should execute before creating the specified executable, # files used for linking, targets which should execute before creating the specified executable,
# generating additional binary files, generating files related to flashing, etc.) # generating additional binary files, generating files related to flashing, etc.)
function(idf_build_executable elf) function(idf_build_executable elf)
# Set additional link flags for the executable
idf_build_get_property(link_options LINK_OPTIONS)
# Using LINK_LIBRARIES here instead of LINK_OPTIONS, as the latter is not in CMake 3.5.
set_property(TARGET ${elf} APPEND PROPERTY LINK_LIBRARIES "${link_options}")
# Propagate link dependencies from component library targets to the executable # Propagate link dependencies from component library targets to the executable
idf_build_get_property(link_depends __LINK_DEPENDS) idf_build_get_property(link_depends __LINK_DEPENDS)
set_property(TARGET ${elf} APPEND PROPERTY LINK_DEPENDS "${link_depends}") set_property(TARGET ${elf} APPEND PROPERTY LINK_DEPENDS "${link_depends}")