mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
[esp32] Redefine __FILE__ to the basename so assert paths stay out of RAM (#19106)
This commit is contained in:
@@ -2609,6 +2609,13 @@ async def to_code(config):
|
||||
# NVS finds stored preferences by key, so preference key migration is possible
|
||||
cg.add_define("USE_PREFERENCE_KEY_LOOKUP")
|
||||
cg.add_build_flag("-Wl,-z,noexecstack")
|
||||
# assert(), HAL_ASSERT and ESP_ERROR_CHECK bake __FILE__ into rodata, and
|
||||
# IDF's noflash placement puts the flash driver's copies in DRAM. The
|
||||
# basename keeps the panic output useful at a fraction of the size.
|
||||
# __FILE_NAME__ is a GCC 12 builtin; IDF 5.0 still ships GCC 11.2.
|
||||
if idf_version() >= cv.Version(5, 1, 0):
|
||||
cg.add_build_flag("-D__FILE__=__FILE_NAME__")
|
||||
cg.add_build_flag("-Wno-builtin-macro-redefined")
|
||||
# Deferred so KEY_COMPONENTS is fully populated -- see the coroutine.
|
||||
CORE.add_job(_finalize_arduino_aware_flags)
|
||||
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 5.0.6
|
||||
@@ -658,6 +658,27 @@ def test_platformio_arduino_enables_reproducible_build(
|
||||
assert sdkconfig.get("CONFIG_APP_REPRODUCIBLE_BUILD") is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("config_file", "expected"),
|
||||
[
|
||||
("reproducible_build.yaml", True),
|
||||
("reproducible_build_arduino.yaml", True),
|
||||
("file_macro_idf_5_0.yaml", False),
|
||||
],
|
||||
)
|
||||
def test_file_macro_is_basename_only(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
config_file: str,
|
||||
expected: bool,
|
||||
) -> None:
|
||||
"""__FILE__ becomes the basename on GCC 12 toolchains; IDF 5.0 (GCC 11) is skipped."""
|
||||
generate_main(component_config_path(config_file))
|
||||
|
||||
assert ("-D__FILE__=__FILE_NAME__" in CORE.build_flags) is expected
|
||||
assert ("-Wno-builtin-macro-redefined" in CORE.build_flags) is expected
|
||||
|
||||
|
||||
def test_native_idf_enables_reproducible_build(
|
||||
component_config_path: Callable[[str], Path],
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user