diff options
author | Alex Deymo <deymo@chromium.org> | 2014-06-05 19:50:32 -0700 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-07-13 14:23:09 +0100 |
commit | 71e2ea773414b2316bbe6b803b9a52c38d3752e8 (patch) | |
tree | a535f4cf2c4b8580be95b3c53bf061239aa31e4b /man | |
parent | 9c128c0e4943421a73fb0cde4b06a2baa751fdeb (diff) | |
download | coreutils-71e2ea773414b2316bbe6b803b9a52c38d3752e8.tar.xz |
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.
Diffstat (limited to 'man')
-rw-r--r-- | man/coreutils.x | 4 | ||||
-rw-r--r-- | man/local.mk | 153 |
2 files changed, 37 insertions, 120 deletions
diff --git a/man/coreutils.x b/man/coreutils.x new file mode 100644 index 000000000..a7a487999 --- /dev/null +++ b/man/coreutils.x @@ -0,0 +1,4 @@ +[NAME] +coreutils \- single binary for coreutils programs +[DESCRIPTION] +.\" Add any additional description here diff --git a/man/local.mk b/man/local.mk index 7ce426bb6..0f0b66e25 100644 --- a/man/local.mk +++ b/man/local.mk @@ -35,13 +35,6 @@ ALL_MANS = $(man1_MANS) $(EXTRA_MANS) CLEANFILES += $(ALL_MANS) -# This is required because we have subtle inter-directory dependencies: -# in order to generate all man pages, even those for which we don't -# install a binary, require that all programs be built at distribution -# time. We can't use 'dist-hook' for this, since it would run too late: -# the manpages must be generated before the distdir is created and filled. -$(EXTRA_MANS): $(all_programs) - # This is a kludge to remove generated 'man/*.1' from a non-srcdir build. # Without this, "make distcheck" might fail. distclean-local: @@ -59,114 +52,34 @@ mandeps += $(top_srcdir)/src/system.h $(ALL_MANS): $(mandeps) -# Most prog.1 man pages depend on src/prog. List the exceptions: -# Note that dir and vdir are exceptions only if you consider the name -# of the .c file upon which they depend: ls.c. -man/arch.1: src/uname -man/dir.1: src/dir -man/install.1: src/ginstall -man/vdir.1: src/vdir - -man/base64.1: src/base64 -man/basename.1: src/basename -man/cat.1: src/cat -man/chcon.1: src/chcon -man/chgrp.1: src/chgrp -man/chmod.1: src/chmod -man/chown.1: src/chown -man/chroot.1: src/chroot -man/cksum.1: src/cksum -man/comm.1: src/comm -man/cp.1: src/cp -man/csplit.1: src/csplit -man/cut.1: src/cut -man/date.1: src/date -man/dd.1: src/dd -man/df.1: src/df -man/dircolors.1: src/dircolors -man/dirname.1: src/dirname -man/du.1: src/du -man/echo.1: src/echo -man/env.1: src/env -man/expand.1: src/expand -man/expr.1: src/expr -man/factor.1: src/factor -man/false.1: src/false -man/fmt.1: src/fmt -man/fold.1: src/fold -man/groups.1: src/groups -man/head.1: src/head -man/hostid.1: src/hostid -man/hostname.1: src/hostname -man/id.1: src/id -man/join.1: src/join -man/kill.1: src/kill -man/link.1: src/link -man/ln.1: src/ln -man/logname.1: src/logname -man/ls.1: src/ls -man/md5sum.1: src/md5sum -man/mkdir.1: src/mkdir -man/mkfifo.1: src/mkfifo -man/mknod.1: src/mknod -man/mktemp.1: src/mktemp -man/mv.1: src/mv -man/nice.1: src/nice -man/nl.1: src/nl -man/nohup.1: src/nohup -man/nproc.1: src/nproc -man/numfmt.1: src/numfmt -man/od.1: src/od -man/paste.1: src/paste -man/pathchk.1: src/pathchk -man/pinky.1: src/pinky -man/pr.1: src/pr -man/printenv.1: src/printenv -man/printf.1: src/printf -man/ptx.1: src/ptx -man/pwd.1: src/pwd -man/readlink.1: src/readlink -man/realpath.1: src/realpath -man/rm.1: src/rm -man/rmdir.1: src/rmdir -man/runcon.1: src/runcon -man/seq.1: src/seq -man/sha1sum.1: src/sha1sum -man/sha224sum.1: src/sha224sum -man/sha256sum.1: src/sha256sum -man/sha384sum.1: src/sha384sum -man/sha512sum.1: src/sha512sum -man/shred.1: src/shred -man/shuf.1: src/shuf -man/sleep.1: src/sleep -man/sort.1: src/sort -man/split.1: src/split -man/stat.1: src/stat -man/stdbuf.1: src/stdbuf -man/stty.1: src/stty -man/sum.1: src/sum -man/sync.1: src/sync -man/tac.1: src/tac -man/tail.1: src/tail -man/tee.1: src/tee -man/test.1: src/test -man/timeout.1: src/timeout -man/touch.1: src/touch -man/tr.1: src/tr -man/true.1: src/true -man/truncate.1: src/truncate -man/tsort.1: src/tsort -man/tty.1: src/tty -man/uname.1: src/uname -man/unexpand.1: src/unexpand -man/uniq.1: src/uniq -man/unlink.1: src/unlink -man/uptime.1: src/uptime -man/users.1: src/users -man/wc.1: src/wc -man/who.1: src/who -man/whoami.1: src/whoami -man/yes.1: src/yes +# Most prog.1 man pages depend on src/$prog, except when they are part of a +# single binary, in which case they depend on src/coreutils. The exceptions +# are handled by converting $name to $prog on the following code. +# $(ALL_MANS) includes the $(EXTRA_MANS) so even the programs that are not +# being installed will have the right dependency for the manpages. +CLEANFILES += man/dynamic-deps.mk +man/dynamic-deps.mk: Makefile + $(AM_V_GEN)rm -f $@ $@-t + $(AM_V_at)for man in $(ALL_MANS); do \ + name=$${man:4: -2} ; # Space is important \ + case $$name in \ + arch) prog='uname';; \ + install) prog='ginstall';; \ + test) prog='[';; \ + *) prog=$$name;; \ + esac; \ + case " $(single_binary_progs) " in \ + *" $$prog "*) \ + echo $$man: src/coreutils$(EXEEXT);; \ + *) \ + echo $$man: src/$$prog$(EXEEXT);; \ + esac \ + done > $@-t \ + && chmod a-w $@-t \ + && mv $@-t $@ + +# Include the generated man dependencies. +-include man/dynamic-deps.mk .x.1: $(AM_V_GEN)name=`echo $@ | sed 's|.*/||; s|\.1$$||'` || exit 1; \ @@ -174,9 +87,9 @@ man/yes.1: src/yes ## creating 'install.1'. Similarly, ensure that it uses the 'src/[' binary ## to create 'test.1'. case $$name in \ - install) prog='ginstall';; \ - test) prog='[';; \ - *) prog=$$name;; \ + install) prog='ginstall'; argv=$$name;; \ + test) prog='['; argv='[';; \ + *) prog=$$name; argv=$$prog;; \ esac; \ ## Note the use of $$t/$*, rather than just '$*' as in other packages. ## That is necessary to avoid failures for programs that are also shell @@ -185,11 +98,11 @@ man/yes.1: src/yes && t=$*.td \ && rm -rf $$t \ && $(MKDIR_P) $$t \ - && (cd $$t && $(LN_S) '$(abs_top_builddir)/src/'$$prog $$name) \ + && (cd $$t && $(LN_S) '$(abs_top_builddir)/src/'$$prog $$argv) \ && $(run_help2man) \ --source='$(PACKAGE_STRING)' \ --include=$(srcdir)/man/$$name.x \ - --output=$$t/$$name.1 $$t/$$name \ + --output=$$t/$$name.1 $$t/$$argv \ --info-page='coreutils \(aq'$$name' invocation\(aq' \ && sed \ -e 's|$*\.td/||g' \ |