Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cfstras/9f94a710c90d0161f23d to your computer and use it in GitHub Desktop.
Save cfstras/9f94a710c90d0161f23d to your computer and use it in GitHub Desktop.
Build static versions of binutils, for example ld, gprof, nm, strip, objdump, ar, strings; with mingw or on *nix
See the bash script below. :)
Tested on debian bookworm-slim (`docker pull debian:bookworm-slim`).
### Prerequisites
```bash
apt update
apt install -y build-essential wget bison
```
### Build
```bash
wget https://gist.githubusercontent.com/cfstras/9f94a710c90d0161f23d/raw/build.sh
chmod a+x build.sh
./build.sh
```
#!/bin/bash
set -euo pipefail
VERSION=2.41
[[ -s "binutils-$VERSION.tar.gz" ]] || wget "http://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.gz"
tar xzf "binutils-$VERSION.tar.gz"
cd "binutils-$VERSION"
./configure --disable-nls --prefix="$(pwd)/bin"
make configure-host
make LDFLAGS="-all-static"
make install
echo "output in binutils-$VERSION/bin/bin:"
ls bin/bin
@cfstras
Copy link
Author

cfstras commented Mar 29, 2024

@rubyFeedback Just tested this successfully on Debian bookworm -- what OS and compiler are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment