Can the object files output by gcc differ between compilations of the same source with the same parameters?

Is gcc output of an object file (C language) output between compilations? There is no time information, no changes to the compilation options or source code. No changes to linked libraries and environment variables. This is the VxWorks MIPS64 cross-compiler, if that helps. I personally believe that this should not change. But I observe that sometimes at random, instructions generated change. I do not know the reason. Can anyone shed some light on this?

+5
source share
5 answers

How is it built? For example, if I built the same Linux kernel, it includes a counter that increments each assembly. GCC has options for using profiler information to control code generation if the profiling information changes, just like code.

What did you analyze? Generated assembly, objdump object files or executable? How did you compare the different versions? Are you sure you were looking for executable code, not compiler / assembler / linker timestamps?

Has anything changed in the environment? New libraries (and header / declaration / macro definition files!)? New compiler, linker? New kernel (yes, some header files are taken from the kernel source code and come with it)?

( , , , , IP-, )?

( , , ).

...

+1

g++. Pre 4.3 . 4.3 ( ?) - -g . , (, ). , .o, . () ( ). g++ -c file.C; strip file.o; cmp file.o origfile.o

+1

? . :

for i in `seq 1000`; do gcc 1.c; md5sum a.out; done | sort | uniq | wc -l

1. 1.c a.out .

, gcc 1000 .

0

, , . :

dir1. .

, , dir2 (dir1!= dir2). .

, toolchain - libs . . dir1 md5sum, dir2.

BeyondCompare, - , , , .

, dir1, dir1. , dir2.

, - include.

0

gcc . .

Sometimes this causes linker errors, as one possible object file is invalid. Re-compiling a different version usually fixes the linker error.

Gcc version is 4.3.4 on Suse Linux Enterprise. Gcc options:

cc -std=c++0x -Wall -fno-builtin -march=native -g -I<path1> -I<path2> -I<path3> -o obj/file.o -c file.cpp

If someone is experiencing the same effect, then please let me know.

-1
source

All Articles