From 71e2ea773414b2316bbe6b803b9a52c38d3752e8 Mon Sep 17 00:00:00 2001 From: Alex Deymo Date: Thu, 5 Jun 2014 19:50:32 -0700 Subject: build: support building all tools in a single binary Add the --enable-single-binary option to the configure file. When enabled, this option builds a single binary file containing the selected tools. Which tool gets executed depends on the value of argv[0] which can be set implicitly through symlinks to the single program. This setup reduces significantly the size of a complete coreutils install, since code from lib/libcoreutils.a is not duplicated in every one of the more than 100 binaries. Runtime overhead is increased due to more dynamic libraries being loaded, and extra initialization being performed for all utils. Also initially a larger binary is loaded from storage, though this is usually alleviated due to caching and lazy mmaping of unused blocks, and in fact the single binary should have better caching characteristics. Comparing the size of the individual versus single binary on x86_64: $ cd src $ size coreutils $ size -t $(../build-aux/gen-lists-of-programs.sh --list-progs | grep -Ev '(coreutils|libstdbuf)') | tail -n1 text data bss dec hex filename 1097416 5388 88432 1191236 122d44 src/coreutils 4901010 124964 163768 5189742 4f306e (TOTALS) Storage requirements are reduced similarly: $ cd src $ du -h coreutils $ du -ch $(../build-aux/gen-lists-of-programs.sh --list-progs | grep -Ev '(coreutils|libstdbuf)') | tail -n1 1.2M coreutils 5.3M total When installing, the makefile will create either symlinks or shebangs based on the --enable-single-binary setting, for each configured tool. In this way, all the tools are still callable individually, but they are all implemented by the same "coreutils" binary installed on the same directory. * .gitignore: Add new generated files. * Makefile.am: New rules to generate build-aux/gen-single-binary.sh and install symlinks. * NEWS: Mention the new feature. * README: Add "coreutils" to the list of utils. * bootstrap.conf: Regenerate src/single-binary.mk * build-aux/gen-lists-of-programs.sh: New --list-progs option. * build-aux/gen-single-binary.sh: Regenerate * configure.ac: New --enable-single-binary option and other variables. Disallow --enable-single-binary=symlinks with --program-prefix et. al. * man/coreutils.x: Manpage hook. * man/local.mk: Add manpage hook and fix dependencies. * src/coreutils.c: Multicall implementation. * src/local.mk: New rules for the single binary option. * tests/local.mk: Add $single_binary_progs to support require_built_() from init.cfg * tests/misc/env.sh: Avoid the use of symlink to echo. * tests/misc/help-version.sh: Add exception for coreutils. * tests/install/basic-1.sh: Really avoid using ginstall strip functionality if there is an issue with the independent strip command. * src/kill.c: Changes to call exit() in main. * src/readlink.c: Likewise. * src/shuf.c: Likewise. * src/timeout.c: Likewise. * src/truncate.c: Likewise. --- NEWS | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 4e90b793b..2bd739683 100644 --- a/NEWS +++ b/NEWS @@ -101,6 +101,24 @@ GNU coreutils NEWS -*- outline -*- od accepts a new option: --endian=TYPE to handle inputs with different byte orders, or to provide consistent output on systems with disparate endianness. + configure accepts the new option --enable-single-binary to build all the + selected programs in a single binary called "coreutils". The selected + programs can still be called directly using symlinks to "coreutils" or + shebangs with the option --coreutils-prog= passed to this program. The + install behavior is determined by the option --enable-single-binary=symlinks + or --enable-single-binary=shebangs (the default). With the symlinks option, + you can't make a second symlink to any program because that will change the + name of the called program, which is used by coreutils to determine the + desired program. The shebangs option doesn't suffer from this problem, but + the /proc/$pid/cmdline file might not be updated on all the platforms. The + functionality of each program is not affected but this single binary will + depend on all the required dynamic libraries even to run simple programs. + If you desire to build some tools outside the single binary file, you can + pass the option --enable-single-binary-exceptions=PROG_LIST with the comma + separated list of programs you want to build separately. This flag + considerably reduces the overall size of the installed binaries which makes + it suitable for embedded system. + ** Changes in behavior chroot with an argument of "/" no longer implicitly changes the current -- cgit v1.2.3-70-g09d2