Merge branch 'fix/ldgen_template_fingerprint' into 'master'

fix(ldgen): add the linker template to the generation fingerprint

See merge request espressif/esp-idf!51620
This commit is contained in:
Frantisek Hrbata
2026-08-10 08:31:03 +02:00
2 changed files with 35 additions and 4 deletions
+26
View File
@@ -183,6 +183,32 @@ def test_rebuild_ldgen_fingerprint(idf_py: IdfPyFunc, test_app_copy: Path) -> No
assert skip_msg not in result.stdout, f'unexpected {skip_msg!r} in build output after fragment change'
@pytest.mark.usefixtures('idf_copy')
def test_rebuild_ldgen_template_change(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
"""Verify that a change to the linker script template reaches the generated
script. ldgen copies everything outside the mapping placeholders from the
template into its output verbatim, so the template is an input in its own
right and must not be hidden behind the fingerprint skip.
"""
skip_msg = 'Skipping linker script generation, section names unchanged'
idf_path = Path(os.environ['IDF_PATH'])
template = idf_path / 'components/esp_system/ld/esp32/sections.ld.in'
generated = Path('build/esp-idf/esp_system/ld/sections.ld')
# An absolute symbol assignment: it is copied through to the generated
# script and does not depend on anything else in the build.
probe = '_ldgen_template_probe'
logging.info('initial build')
idf_py('build')
logging.info('adding a symbol to the template leaves section names and fragment files unchanged')
with open(template, 'a') as f:
f.write(f'\n{probe} = 0x3ff00abc;\n')
result = idf_py('build')
assert skip_msg not in result.stdout, f'unexpected {skip_msg!r} in build output after template change'
assert probe in generated.read_text(), 'template change did not reach the generated linker script'
def test_rebuild_ldgen_lf_cache(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
"""Verify the ldgen lf cache: when section names change but fragment files
don't, parsed FragmentFile objects are loaded from cache rather than