Search code examples
c++unixaixxlc

Same source code, different executable size?


In AIX, can different versions of compiler makes executables(or libraries) size different?

Questions

What can affects on size of executable/libraries?

  • Different version of compiler.
  • Different compile options.
  • Different os version and its libraries(like libm.a, libpthread.a ..).
  • More?

Some background.

In here, we have bunch of old executables and libraries which are not source code under version control. We need to figure out the executables are built from source code we have. So we build it again, but the result(exec, libs) is not same in size.

Tries..

I tried..

  • dump -X64 -c : it shows some infos of compiler that was used when build it. The binarie's compiler version is 'IBM XL C/C++ .. 11.1.0.14'. But compiler's version which we have is 'IBM .. 11.1.0.13'. Can these make difference?
  • ar -X64 -x : comparing extracted files from archive. when I do "make" some library, object files(*.o) were generated. most of files are same in size, but some's are not same. When dump them(files that has different size), the compiler is not same.

Any help, advice, links will be helpful. Thank you.


Solution

  • What can affects on size of executable/libraries?

    Different version of compiler.

    Of course! It can generate very different binaries not only different in size. It starts with different locations of code and totally different assemble for the same source.

    Different compile options.

    It must change the size! If you optimize for size or for speed the result must be different. Think about loop unrolling...

    Different os version and its libraries(like libm.a, libpthread.a ..).

    As they are also compiled with different compilers, the answer is recursive :-)

    More?

    Maybe a endless list? Ordering of files while linking, different linker options, ...

    My hint:

    The size of the executable is only the first check. You can have different executables with the same size, quite clear.

    Even if you have the same compiler with the same libs and the same OS running, you need to build with the same build script/make to get the same result. If anything is different ( compiler/libs/compiler and/or linker flags, file ordering, is different, your linked executable is different!

    In a short: If you can't reproduce an exact copy of the environment for your build, you will never see the same executable, even if the sources are the same!