I created a simple project, compiled with the same version of the compiler under Windows and Ubuntu respectively, but the generated elf files are different, and the actual execution time of the program is also different, which in some cases may cause Unexpected results appear. Why does this happen? Is there any solution?
The compiler version is as follows:
Ubuntu:
powerpc-eabivle-gcc (GCC) 4.9.4 20160726 (Sat May 27 11:09:55 CDT 2017 build.sh rev=gd8b6c20 s=F494 ELe200 -V release_gd8b6c20_build_Fed_ELe200_ML0)
Windows:
powerpc-eabivle-gcc (GCC) 4.9.4 20160726 (Tue Oct 17 13:22:54 CDT 2017 build.sh rev=g0812845 s=F494 ELe200 -V release_g0812845_build_Fed_ELe200_ML0)
1. At least you use different GCC builds that may result in different code generated due to some changes/fixes in codegen respectively.
2. GCC relies on OS system libraries and some functions may behave differently. Most popular example is qsort() function implementation on Windows vs Linux.
Hi John,
It's not something special unless the generated code works in both cases.
Each OS has it's own variance e.g. different OS time-outs may cause the optimizations stage is shorter on one OS causing that some additional instructions keeps non-optimized.
We also observed differences between OSes related to qsort(). See more info below:
MinGW - Minimalist GNU for Windows / Issues / #1699 Bug in qsort when number of elements is small
Hope it helps.
Stan
Hi Stanislav,
This is not a program running under different operating systems, but the result of cross-compilation using different platforms. The codes and library files used by them are exactly the same. According to my understanding, the executable files generated should also be the same, but this is not the case, which caused some strange problems.
Best Regards
John