0

I am trying to compare two build systems - GNUMake and Gradle and trying to find out which best fits my software development. For the same Git commit, if I try to compile my C sources on the two build systems using the same version of GCC compiler and linker, will the generated object files look alike?

I generated the two sets of objects and I ran a command like this:

diff GNUMake_file.o Gradle_file.o

And i got the output as:

Binary files GNUMake_file.o and Gradle_file.o differ

I also did a cmp -l for the two sets and I get huge number of lines similar to this:

13699 11 21

13700 4 363

13704 346 302

13707 15 12

13711 0 22

13712 0 13

13715 0 7

13716 6 317

13719 6 14

I think this means obviously the two object files are different at many places. Is my comparison correct? Is there a way in finding out if they are different and if so why? I have tried to the best of my abilities to make the compiler flags and command look alike on both the systems. Comments from those who have done this before or have a fair idea on what this is all about will be welcome.

Also attached are the compiler commands for an arbitary C source file from the directory:

With GNUMake

sparc-rtems-gcc -MD -MF 'dep/my_source.dep' -MP -MT 'obj/my_source.o dep/my_source.dep' -W -Wall -Waggregate-return -Wcast-align -Wchar-subscripts -Wbad-function-cast -Wcomment -Wformat -Wimplicit -Winline -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wparentheses -Wpointer-arith -Wshadow -Wswitch -Wuninitialized -Wunused -Wwrite-strings -Wno-conversion -Wreturn-type -I/all/include/file/locations -I/all/include/file/locations -I/all/include/file/locations -I/all/include/file/locations -I/all/include/file/locations -DCPU=SCOC3 -DCPU_SCOC3 -DINLINE=inline -fno-common -fno-strict-aliasing -fno-builtin-sqrt -fno-builtin-sqrtf -fno-builtin-acos -fno-builtin-acosf -fno-builtin-asin -fno-builtin-asinf -fno-builtin-atan -fno-builtin-atanf -fno-builtin-atan2 -fno-builtin-atan2f -fno-builtin-cos -fno-builtin-cosf -fno-builtin-sin -fno-builtin-sinf -fno-builtin-tan -fno-builtin-tanf -fno-builtin-scalbn -fno-builtin-scalbnf -fno-builtin-floor -fno-builtin-floorf -fno-builtin-fabs -fno-builtin-fabsf -fno-builtin-copysign -fno-builtin-copysignf -fno-builtin-exp -fno-builtin-expf -fno-builtin-log -fno-builtin-logf -fno-builtin-exp2 -fno-builtin-exp2f -fno-builtin-log2 -fno-builtin-log2f -fno-builtin-exp10 -fno-builtin-exp10f -fno-builtin-log10 -fno-builtin-log10f -fno-builtin-pow -fno-builtin-powf -fno-builtin-pow10 -fno-builtin-pow10f -D__OBJECTS_inl -DRTEMS_QUALIF -mv8 -mgrfpu -mgrcache -O2 -gdwarf-2 -c my_source.c -o obj/my_source.o

With Gradle

Command: /opt/rtems/4.6_20130612/bin/sparc-rtems-gcc -x c -c -W -Wall -Waggregate-return -Wcast-align -Wchar-subscripts -Wbad-function-cast -Wcomment -Wformat -Wimplicit -Winline -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wparentheses -Wpointer-arith -Wshadow -Wswitch -Wuninitialized -Wunused -Wwrite-strings -Wno-conversion -Wreturn-type -DCPU=SCOC3 -DCPU_SCOC3 -DINLINE=inline -fno-common -fno-strict-aliasing -fno-builtin-sqrt -fno-builtin-sqrtf -fno-builtin-acos -fno-builtin-acosf -fno-builtin-asin -fno-builtin-asinf -fno-builtin-atan -fno-builtin-atanf -fno-builtin-atan2 -fno-builtin-atan2f -fno-builtin-cos -fno-builtin-cosf -fno-builtin-sin -fno-builtin-sinf -fno-builtin-tan -fno-builtin-tanf -fno-builtin-scalbn -fno-builtin-scalbnf -fno-builtin-floor -fno-builtin-floorf -fno-builtin-fabs -fno-builtin-fabsf -fno-builtin-copysign -fno-builtin-copysignf -fno-builtin-exp -fno-builtin-expf -fno-builtin-log -fno-builtin-logf -fno-builtin-exp2 -fno-builtin-exp2f -fno-builtin-log2 -fno-builtin-log2f -fno-builtin-exp10 -fno-builtin-exp10f -fno-builtin-log10 -fno-builtin-pow -fno-builtin-powf -fno-builtin-pow10 -fno-builtin-pow10f -D__OBJECTS_inl -DRTEMS_QUALIF -mv8 -mgrfpu -mgrcache -O2 -gdwarf-2 -I all/include/file/locations -I all/include/file/locations all/include/file/locations my_source.c -o my_source.o

Müller
  • 973
  • 6
  • 19
  • 38
  • If you use the same compiler and the same flags then the only difference should be things like timestamps or similar. I don't know about Gradle, but `make` by default shows the complete command line it executes, can you do the same with Gradle? Do the compilation commands differ in any way? – Some programmer dude Nov 10 '16 at 09:58
  • Yes, I ran make and gradle both in such a way that all the commands are displayed on the screen and it pretty much looks the same. Only the order in which the flags were on the command line are different. But others were pretty much same. Should I post them along with the question? – Müller Nov 10 '16 at 10:02
  • 1
    Yes please include the output from the builds as well. – Some programmer dude Nov 10 '16 at 10:03
  • There are many things that can be embedded into object files that differ from run to run. If you compare the objects created by one run, then clear and re-run the same tool, you'll probably find those objects differ as well. As mentioned above there are often timestamps there. Another thing to consider is the pathname of the source files is embedded in the object file, so if the paths to the sources differ that will be a problem. And you can't go by how many bytes are different: as soon as there's an offset of even one byte huge chunks of the file will be offset. – MadScientist Nov 11 '16 at 16:42
  • Possible duplicate of [How to produce deterministic binary output with g++?](http://stackoverflow.com/questions/14653874/how-to-produce-deterministic-binary-output-with-g) – Tim Nov 12 '16 at 00:08
  • In addition to the things mentioned in the other question, you will need to use *exactly* the same command line options. – Tim Nov 12 '16 at 00:10

0 Answers0