-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making non functional source changes triggers a .bin
difference despite CONFIG_APP_REPRODUCIBLE_BUILD
being set (IDFGH-14646)
#15394
Comments
CONFIG_APP_REPRODUCIBLE_BUILD
being set.bin
difference despite CONFIG_APP_REPRODUCIBLE_BUILD
being set
.bin
difference despite CONFIG_APP_REPRODUCIBLE_BUILD
being set.bin
difference despite CONFIG_APP_REPRODUCIBLE_BUILD
being set (IDFGH-14646)
Hello @soliis-jones , the reason is that even if you do a non-functional change, the dwarf sections will change in the elf file, because of changed line references. I tested this with esp32c3 and the hello_world example by deleting one comment from the
As you can see the I guess this is expected behavior. Thank you |
@fhrbata Thank you for your response!
I was aware of this behavior, and confirmed by looking at the .elf file that this was the case. For those reading that would like some more info on this, see the relevant esp-idf documentation and esptool documentation.
Maybe I'm missing something, but I confirmed that the arguments were removed after adding the following lines in my
And seeing the following output after executing
But the sha is still present in the output I also attempted to |
After some poking around in esp-idf/esptool and learning more about cmake I discovered the following: There is a The only (hacky) way I could successfully get list(REMOVE_ITEM esptool_elf2image_args --elf-sha256-offset 0xb0)
add_custom_command(OUTPUT "${build_dir}/.bin_timestamp" APPEND
COMMAND echo "Repeating .bin file generation with the following elf2image arguments: ${esptool_elf2image_args}"
COMMAND ${ESPTOOLPY} elf2image ${esptool_elf2image_args}
-o "${build_dir}/${unsigned_project_binary}" "$<TARGET_FILE:$<GENEX_EVAL:${elf}>>"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.bin_timestamp"
) My tests confirm this produces the desired result: non functional diffs and build environment changes (different users/computers) produce equivalent .bin files. I'm sure I'm not the only esp-idf user that desires this result while still being able to use the I have 1 last question: does omitting this elf file sha have any negative impact on the OTA process? |
Just chiming in regarding the OTA process: it depends on the method you use to compare the versions available locally and offered over the air. If you don't rely on the ELF file hash in this process, then there should be no impact. However please keep in mind that for production builds it is highly recommended to keep the ELF files for each application binary you release, as that later helps debugging application crashes, should they occur. In this case, having the ELF file hash recorded in the binary image header helps avoid any mixup between the ELF files. Accurate debug info is also important if you are collecting core dumps from devices in the field. By the way, I am curious to learn why you consider that nonfunctional changes to source code should not affect the built binary. It doesn't seem to be a part of the common definition of reproducible builds. It's probably something reasonable, but we definitely haven't considered this requirement when designing the reproducible builds feature in IDF. |
Answers checklist.
IDF version.
v5.5-dev-1860-g0d6099ec53, v5.3.2
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
What is the expected behavior?
Making non functional changes to a source file (specifically tested removing comments) does not result in a modified
.bin
file ifCONFIG_APP_REPRODUCIBLE_BUILD
is set.What is the actual behavior?
Built
.bin
files differ because the contained sha256 of the underlying.elf
file is modified.Steps to reproduce.
sdkconfig.txt
Build or installation Logs.
More Information.
Performing clean builds and/or resetting ccache does not affect this issue.
I am inheriting an old project, but as far as I can tell there isn't anything in the sdkconfig or the source itself (FILE, DATE, etc) that would explain this.
I have made some slight modifications to the top level
CMakeLists.txt
in an attempt to eliminate this problem:If this can't be directly addressed, I would also be interested in steps to produce a
.bin
file that omits the.elf
sha256.The text was updated successfully, but these errors were encountered: