Search code examples
linuxbashmakefilegnu-coreutils

Why the bash I compiled(3.8M) is bigger the one my system provided(937K)?


I have download the bash shell version 4.2 form here: http://ftp.gnu.org/gnu/bash/, and then compiled it by my self using the following command:

./configure
make

But the bash I compiled is much bigger then one system provided:

This is my bash:

$ ls -lh bash
-rwxrwxr-x 1 unimous unimous 3.8M Oct 31 23:57 bash

This is the system's bash:

$ ls -hl /bin/bash 
-rwxr-xr-x 1 root root 937K Sep 19 21:40 /bin/bash

Solution

  • Assuming you have downloaded the source for bash that directly matches the version of your system, there are several things that could be different:

    • Bash has a lot of build configuration options because it's one of the most portable pieces of software in existence. The default ./configure will select options that most people would want that will work on the system you're using to build it.

    • The production install targets for bash do not strip the installed executable. Most people that download the source for bash and build it themselves are probably doing so because they want different behavior than their OS provides, or a different version altogether. In either case, people would want debug symbols left until stability has been established.

    • 'Special sauce' added by the distribution

    To directly reproduce the build, you'd need to get the source to the package your distro provided, and use the build tools (or, just grab the build config options out of them and apply them to the version you downloaded), then strip the resulting executable.

    Keep in mind, distros are absolutely free to apply their own patches (or 'sauce') to the things they package. You have to check for this as well, and be sure to apply the same patches to bash that your distro did.

    In short, it's easier to just grab the source package from your distro if all you want to do is reproduce the build, unless you want to use the official release version that GNU provides.