diff --git a/esphome/core/buildinfo.cpp b/esphome/core/buildinfo.cpp index 912b506790..839bee9857 100644 --- a/esphome/core/buildinfo.cpp +++ b/esphome/core/buildinfo.cpp @@ -22,7 +22,11 @@ namespace esphome { namespace buildinfo { // Reference the linker symbols as uintptr_t from the *data* section to -// avoid issues with pc-relative relocations on 64-bit platforms. +// avoid issues with pc-relative relocations on 64-bit platforms. And +// don't let the compiler know they're const or it'll optimise away the +// whole thing and emit a relocation to the ESPHOME_XXX symbols above +// directly, which defaults the whole point! +// // NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables) static uintptr_t config_hash = (uintptr_t) &ESPHOME_CONFIG_HASH; static uintptr_t build_time = (uintptr_t) &ESPHOME_BUILD_TIME;