This repository provides a cross-build toolchain for targeting glibc 2.17 on x86_64 using GCC 5.x. It is designed for building and running binaries on modern systems with full runtime support via sysroot redirection.
Contents:
- GCC 5.x cross toolchain
- glibc 2.17 runtime and development headers
- libstdc++, libgcc, and sysroot layout
- Example wrapper script for runtime execution
Build and run legacy-compatible binaries on the same host, using glibc 2.17 and older ABI rules — without touching or downgrading the host system’s glibc.
| Item | Value |
|---|---|
| Architecture | x86_64 |
| Compiler | GCC 5.x |
| C library | glibc 2.17 |
| Sysroot layout | Fully relocatable |
| Host Compatibility | Ubuntu ≥ 20.04, WSL2, etc. |
mkdir -p $HOME/x-tools
tar -xJf x86_64-pc-linux-gnu-toolchain.tar.xz -C $HOME/x-tools/
export TOOLCHAIN_ROOT=$HOME/x-tools/x86_64-pc-linux-gnuexport PATH="$TOOLCHAIN_ROOT/bin:$PATH"
x86_64-pc-linux-gnu-gcc -O2 -static-libgcc -static-libstdc++ -o hello hello.cTo run binaries using glibc 2.17 instead of your host glibc:
export GLIBC217_LIB="$TOOLCHAIN_ROOT/x86_64-pc-linux-gnu/lib"
LD_LIBRARY_PATH="$GLIBC217_LIB:$LD_LIBRARY_PATH" ./hellopatchelf --set-interpreter "$GLIBC217_LIB/ld-2.17.so" --set-rpath "$GLIBC217_LIB" ./hello
./helloCreate a run-with-sysroot.sh:
#!/bin/bash
TOOLCHAIN="$HOME/x-tools/x86_64-pc-linux-gnu"
export LD_LIBRARY_PATH="$TOOLCHAIN/x86_64-pc-linux-gnu/lib:$LD_LIBRARY_PATH"
exec "$@"Usage:
chmod +x run-with-sysroot.sh
./run-with-sysroot.sh ./helloThis toolchain was built with Crosstool-NG using the config: .config
Key settings:
GCC version: 5.5.0glibc version: 2.17Binutils: 2.26Enable C++ support: yesEnable threads: yesSysroot: enabled and isolated
Toolchain components are covered by:
- GPLv2+/LGPL for GCC, glibc
- FLOSS-compatible licenses
Issues and pull requests welcome! If you build variants (e.g. musl, static-only, ARM targets), feel free to contribute configs.