Can you expect two shared libraries to be built on two identical platforms?

If I build the same source code, link to the same version of the same libraries, with the same toolchain (same compiler, linker, etc., GCC 4.4), with the same version of the same operating system (Centos 5 Linux in my case), but on two different machines;

Is it safe to assume that the generated binaries should be identical?

In this context, my code has "undefined behavior" which "works" on one configuration but not on the other, the obvious answer is to fix this, but I would be interested to know if my guess was that there should be identical.

I notice a difference in size of several hundred bytes, the arrangement of the characters shown by the "nm" command is slightly different, although the characters are the same.

+3


source to share


1 answer


Normally, I would expect the date and / or metadata to be slightly different even between lines on the same host.

You also neglected to mention compiler flags (optimization and #define

from the command line, for example).



In the beginning, I assumed that the files should come out in the same size, which leads us to the conclusion that something is not the same on the two systems. The most likely candidates are system headers (only one root-level function in an OS installation can lead to a completely different presentation of these files) and any dependent libraries.

You can check the headers are the same by preprocessing with g++ -E

or similar. You can also follow the path of the library and confirm that the linked files are the same for every system.

+1


source







All Articles