mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'fix/ldgen_stale_output' into 'master'
fix(cmake): track transitive includes in linker script preprocessing Closes IDF-16033 See merge request espressif/esp-idf!51580
This commit is contained in:
@@ -231,16 +231,23 @@ function(preprocess_linker_file cmake_target script_in output_var preserve_suffi
|
||||
# Keep comments (-C): historical behavior for cmakev1 linker scripts. It was
|
||||
# previously hardcoded in linker_script_preprocessor.cmake, which now leaves
|
||||
# comment handling to the caller.
|
||||
# Ask the preprocessor to emit all transitive #include dependencies. Without
|
||||
# a depfile, CMake only knows about script_in and sdkconfig.h, so changes to
|
||||
# files such as ld.common leave script_out stale.
|
||||
set(depfile "${script_out}.d")
|
||||
set(depfile_flags "-MD -MF \"${depfile}\" -MT \"${script_out}\"")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${script_out}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DCC=${CMAKE_C_COMPILER}"
|
||||
"-DSOURCE=${script_in}"
|
||||
"-DTARGET=${script_out}"
|
||||
"-DCFLAGS=-C -I\"${config_dir}\" ${extra_cflags}"
|
||||
"-DCFLAGS=-C -I\"${config_dir}\" ${depfile_flags} ${extra_cflags}"
|
||||
-P "${linker_script_generator}"
|
||||
MAIN_DEPENDENCY ${script_in}
|
||||
DEPENDS ${sdkconfig_header}
|
||||
DEPFILE "${depfile}"
|
||||
COMMENT "Preprocessing linker script ${script_in} -> ${script_out}"
|
||||
VERBATIM)
|
||||
|
||||
|
||||
@@ -139,6 +139,14 @@ def test_rebuild_linker(idf_py: IdfPyFunc) -> None:
|
||||
(idf_path / 'components/esp_system/ld/esp32/memory.ld.in').touch()
|
||||
rebuild_and_check(idf_py, APP_BINS, BOOTLOADER_BINS + PARTITION_BIN)
|
||||
|
||||
logging.info('Updating an included ld file should preprocess the scripts and re-link only the app')
|
||||
(idf_path / 'components/esp_system/ld/ld.common').touch()
|
||||
preprocessed_scripts = [
|
||||
'build/esp-idf/esp_system/ld/memory.ld',
|
||||
'build/esp-idf/esp_system/ld/sections.ld.in',
|
||||
]
|
||||
rebuild_and_check(idf_py, APP_BINS + preprocessed_scripts, BOOTLOADER_BINS + PARTITION_BIN)
|
||||
|
||||
logging.info('Updating fragment file should only re-link the app')
|
||||
(idf_path / 'components/esp_common/common.lf').touch()
|
||||
rebuild_and_check(idf_py, APP_BINS, BOOTLOADER_BINS + PARTITION_BIN)
|
||||
|
||||
Reference in New Issue
Block a user