I am facing an issue where the binary output of my STM32CubeIDE project built on Linux and Windows is inconsistent. I have installed STM32CubeIDE Version 1.6.1 and the fixed Toolchain: GNU Tools for STM32 (7-2018-q2-update) on both platforms. Upon comparing the makefiles, I found that they match, but the resulting binaries do not.
Can you suggest steps that I can take to ensure consistent binary output on both platforms? Additionally, which files should I compare to troubleshoot the issue?
Update: If I build the same source code on two different Windows machines, I get the same binary.
Update 2: I have created a basic stm32 project using only the code generated by CubeMX. I have observed that the binary output is identical when I compile the project on Windows and on Linux. This indicates that the toolchain is functioning correctly, and any differences observed are likely due to my own source code.
In general what you are hoping for is not possible with standard embedded tools.
Enabling reproducible builds is an active area of development in open source toolchains. I have personally given up on it (for now at least) in embedded projects.
Many reasons for non-determinism and steps to take against it are listed in the related question How to produce deterministic binary output with g++.
A common one I have found is different linking order on different platforms. Also, as soon as you change the linking order you introduce different amounts of padding, so not even the size will remain exactly the same.