How to statically link coreutils

Tested on amazon linux

Install glibc-static, gcc and make

$ sudo yum install glibc-static gcc make

Download and unpack latest release from

$ curl -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 5590k  100 5590k    0     0  8195k      0 --:--:-- --:--:-- --:--:-- 8197k
$ tar xf coreutils-8.25.tar.xz

Gcc object file crtbeginT.o needs to be replaced

$ cd /usr/lib/gcc/x86_64-amazon-linux/4.8.3/
$ sudo cp crtbeginT.o crtbeginT.orig.o
$ sudo cp crtbeginS.o crtbeginT.o

Now coreutils can be configured and built

$ cd ~/coreutils-8.25
$ ./configure
$ make SHARED=0 CFLAGS='-static -std=gnu99 -static-libgcc -static-libstdc++ -fPIC'

Once it completes, src/ contains statically linked binaries

 file src/mkfifo
src/mkfifo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.35, BuildID[sha1]=5397e6a4919328ea9559965a03cb59d55df89460, not stripped