CMake different build output in windows and linux for ARM M0

Hi all !

We are using cmake in combination with Ninja and gcc-arm compiler for doing cross-compiling for ARM M0 microcontroller processor. The output of this is an .hex file
It is quite interesting that using exactly same cmake, ninja and compiler version and of course same set-up (same CMakeList, code, etc) it brings completely different compilation result (different .hex files) when we compile on Windows and Linux.

Is this normal? What is the explanation for this? Or are we doing something wrong?

I had a look on the Cmake logs and they are pretty similar but it loos the building order is a little bit different on Windows and on Linux. Can this be solved somehow? Is it possible to define the build order?

Thanks a lot for your help!

Usually this means that your build is under-specified. Some add_custom_command is likely missing a DEPENDS or OUTPUT path that would hook things up properly. I usually use ninja -t debug to figure out what ninja is looking at for recompilation. Knowing a bit about how ninja works internally, it does sort various bits based on pointer values, so the build order could be different even with similar allocation patterns given the differences in malloc implementations on the two platforms.

As for the difference in the .hex files, I would try to minimize what makes the output to try and determine what, exactly, is the difference in the files. It could be padding or metadata that is different.