Question

If I build the same source code, link to the same version of the same libraries, with the same tool chain ( 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 reasonable to assume that binaries produced should be identical?

The context behind this is my code has 'undefined behaviour' which 'works' on one configuration but not the other, the obvious answer is to fix this, but I would be interested to know if my assumption that binaries produced should be the identical is correct.

I notice a few hundred bytes difference in size, the location of the symbols shown with the 'nm' command differ slightly, even though the symbols are the same.

Was it helpful?

Solution

Normally I would expect a date and/or meta data to vary slightly even between builds on the same host.

You also neglected to mention compiler flags, (optimization and #defines from the command line for example).

I would however initially suspect the files should come out to the same size, which leads us to the conclusion that something is not the same across the two systems. The most likely candidates are system headers (just one root-level feature in the OS install could cause an entirely different view of these files) and any dependent libraries.

You can check that the headers are the same by preprocessing with g++ -E or similar. You can also follow the library path and confirm that the linked-to files are identical on each system.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top