Hello the ARM Community,Context:We have an STM32 project we build using the arm-none-eabi 10.3-2021.07 toolchain.The development/debug is mainly done on Windows.Then we came to setup a continuous integration system (on Linux server/workers), using the linux build of the same toolchain version.Both toolchains came from developer.arm.com/.../downloads.
Problem:Using the same source, same cmake file, same linker script, the binary outputs are 99% identical, except for a few functions that are not compiled the same way.The disassembling shows the differences are quite light.Both binaries seem to run flawlessly (as far as I can tell), but from a validation point of view I find it worrisome as if differences can occur some in the future could be less innocuous, and I would prefer that both binaries be the same (apart from the build date, etc., though are reproducible build should even be feasible).
Questions:
1. Does anybody stumbled in the same kind of problem?2. Is there a known way to avoid this difference? (except running the windows toolchain on linux or vice versa)
All suggestion or welcome.Have a nice day!
Solved the issue.
Compiled function differences came from... a wrongly synchronized source file. (yeah, no comment)
But, there was also a difference in a .data section.A global array of struct, sized implicitely by its initializers was producing a different output depending of the compilation platform.Considering a structure like that:typedef struct {char * str;func1 pfunc1; //function pointersfunc2 pfunc2; //func3 pfunc3; //func4 pfunc4; //} mystruct_t;The global array
.data
typedef struct {
char * str;
func1 pfunc1; //function pointers
func2 pfunc2; //
func3 pfunc3; //
func4 pfunc4; //
} mystruct_t;
mystruct_t g_list[] = { {"test", myfunc1, myfunc2, myfunc3, myfunc4}, {NULL, NULL, NULL, NULL, NULL}};was not compiled/linked the same way (size mismatch) thanmystruct_t g_list[2] = { {"test", myfunc1, myfunc2, myfunc3, myfunc4}, {NULL, NULL, NULL, NULL, NULL}};This time addresses and dissassembled codes match when cross-compiled on windows and linux.
mystruct_t g_list[] = {
{"test", myfunc1, myfunc2, myfunc3, myfunc4},
{NULL, NULL, NULL, NULL, NULL}
};
mystruct_t g_list[2] = {