Package: binutils Version: 2.20.1-11 Severity: wishlist Tags: patch Here is a simple patch for your consideration that modifies the rules makefile for the binutils package to allow an option to build statically when creating a cross compiler by passing the environment variable 'BUILD_STATIC=yes' on the command line to dpkg-buildpackage.
The rationale for providing the ability to compile a statically linked binutils is to allow greater portability of that toolchain to environments other than the stock Debian environment in which the toolchain was built. This becomes especially interesting in the embedded world where cross compilers (such as ones that can be created in Debian) have long lifetimes and can be deployed to varied buildserver enviroments to support cross compiling software for target embedded systems. It removes the dependence on such things as having the exact correct version of GLIBC (and other libraries) installed on the buildserver and makes the toolchain standalone. A static toolchain also provides the ultimate in repeatablilty, since it does not depend on dynamically loadable modules that can change on the build system. The patch required a simple change to allow an intermediate build target that performs a make on the target 'configure-host' prior to doing the full make with the additional LDFLAGS="-all-static", which gets passed to libtool to create static binaries. Without the intermediate target, configuration would fail when it tries to test gcc and passes the unknown -all-static flag to gcc. I have tested this patch by using dpkg-buildpackage to build binutils version 2.20.51.20100710-2. The resulting binaries were not dynamic. The resulting binutils package was then used to compile gcc-4.4-4.4.4-7 (for which am am submitting a similar patch). -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.32-5-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages binutils depends on: ii libc6 2.11.2-2 Embedded GNU C Library: Shared lib ii libgcc1 1:4.4.4-5 GCC support library ii libstdc++6 4.4.4-5 The GNU Standard C++ Library v3 ii zlib1g 1:1.2.3.4.dfsg-3 compression library - runtime binutils recommends no packages. Versions of packages binutils suggests: pn binutils-doc <none> (no description available) -- no debconf information
--- binutils-2.20.51.20100710/debian/rules.orig 2010-07-22 15:47:52.000000000 -0400 +++ binutils-2.20.51.20100710/debian/rules 2010-07-22 15:07:37.000000000 -0400 @@ -459,7 +459,11 @@ build_stamps += build-spu-stamp endif ifneq (,$(TARGET)) + ifeq ($(BUILD_STATIC),yes) + build_stamps = build-static-cross-stamp + else build_stamps = build-cross-stamp + endif endif build: pre-build build-stamp @@ -480,7 +484,11 @@ install_stamps += install-spu-stamp endif ifneq (,$(TARGET)) - install_stamps = install-cross-stamp + ifeq ($(BUILD_STATIC),yes) + install_stamps = install-static-cross-stamp + else + install_stamps = install-cross-stamp + endif endif install: $(install_stamps) install-stamp: checkroot build-stamp @@ -1095,6 +1103,20 @@ gzip -9 $(d_cross)/$(PF)/share/man/man1/* touch $@ +configure-host-cross-stamp: configure-cross-stamp + $(checkdir) + test "" != "$(TARGET)" + $(MAKE) configure-host -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" + touch $@ + +build-static-cross-stamp: configure-host-cross-stamp + $(checkdir) + test "" != "$(TARGET)" + $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" LDFLAGS="-all-static" + touch $@ + +install-static-cross-stamp: build-static-cross-stamp install-cross-stamp + binary-cross: @echo "Please use dpkg-buildpackage instead of calling binary-cross directly; see README.cross" @false