Skip to content

Repository files navigation

toolchains_gcc_packages

This repository builds packaged GNU toolchains with Crosstool-NG and emits versioned tarballs under output/. It produces toolchains for GCC 12 and GCC 15 on x86_64 and aarch64 Linux targets, and includes the configuration, container image, per-package checksum overrides, and any backported security patches needed to reproduce those builds.

What This Repository Does

The build flow has three parts:

  1. Dockerfile creates a build image with Crosstool-NG 1.28.0 and the host dependencies needed to run ct-ng.
  2. docker_build_and_run.sh builds that image and launches build.sh inside the container with the requested architecture and GCC major version.
  3. build.sh runs ct-ng defconfig and ct-ng build, then packages the generated toolchain into a .tar.gz archive plus a SHA-256 checksum file.

The result is a redistributable toolchain archive rooted at the target triplet, for example x86_64-unknown-linux-gnu, with bin/, lib/, include/, sysroot/, and related directories inside it.

Current Build Matrix

The checked-in target configurations currently cover:

Target triplet ARCH value GCC Config file
x86_64-unknown-linux-gnu x86_64 12 configs/x86_64-unknown-linux-gnu_gcc12
x86_64-unknown-linux-gnu x86_64 15 configs/x86_64-unknown-linux-gnu_gcc15
aarch64-unknown-linux-gnu arm64 or aarch64 12 configs/aarch64-unknown-linux-gnu_gcc12
aarch64-unknown-linux-gnu arm64 or aarch64 15 configs/aarch64-unknown-linux-gnu_gcc15

All configs are pinned to the following component versions:

Component GCC 12 toolchains GCC 15 toolchains
Crosstool-NG 1.28.0 1.28.0
GCC 12.2.0 15.3.0
Linux headers 5.15 7.1.4
binutils 2.34 2.46.1
glibc 2.31 2.39

All configs enable C++ support and build a static toolchain.

Repository Layout

  • build.sh: main build and packaging entrypoint.
  • docker_build_and_run.sh: recommended wrapper for local and CI builds.
  • Dockerfile: reproducible build environment for Crosstool-NG.
  • configs/: one Crosstool-NG defconfig per supported target/GCC combination.
  • additional_packages/: per-component overrides (checksums, version.desc, patches) copied into the container's Crosstool-NG package tree.
  • output/: generated source download cache, intermediate build trees, unpacked toolchains, final archives, and .sha256 files.

Recommended Build: Docker

Docker is the canonical way to build because the image pins the Crosstool-NG version and installs the tool dependencies expected by the configs.

Prerequisites

  • Docker installed locally
  • Permission to run docker build and docker run
  • Enough disk space for source downloads and full toolchain builds

Commands

Build the x86_64 GCC 12 toolchain:

./docker_build_and_run.sh x86_64 12

Build the x86_64 GCC 15 toolchain:

./docker_build_and_run.sh x86_64 15

Build the aarch64 GCC 15 toolchain:

./docker_build_and_run.sh aarch64 15

The wrapper script:

  • builds the local image ctng-image:1.28.0
  • mounts the repository into /workspace inside the container
  • runs GCC=<version> ARCH=<arch> ./build.sh
  • preserves file ownership on the host with --user "$(id -u):$(id -g)"

Manual Build

Manual builds are possible, but build.sh assumes ct-ng is already installed and compatible with the checked-in configs. In practice that means matching the container setup closely, especially Crosstool-NG 1.28.0 and the per-package checksum overrides in additional_packages/.

At minimum:

export GCC=15   # or 12
export ARCH=x86_64
./build.sh

Supported ARCH values are:

  • x86_64
  • arm64
  • aarch64

Any other value is rejected by build.sh.

Build Outputs

For a successful build, build.sh creates:

  • output/<target>_gcc<major>/: unpacked toolchain prefix generated by Crosstool-NG
  • output/<target>_gcc<major>.tar.gz: packaged toolchain archive
  • output/<target>_gcc<major>.tar.gz.sha256: checksum for the archive
  • output/downloads/: source tarball cache used by Crosstool-NG

For example, building ARCH=x86_64 and GCC=12 produces:

output/
├── downloads/
├── x86_64-unknown-linux-gnu_gcc12/
├── x86_64-unknown-linux-gnu_gcc12.tar.gz
└── x86_64-unknown-linux-gnu_gcc12.tar.gz.sha256

Inside the unpacked toolchain prefix you will find the target-rooted tree, including binaries such as:

output/x86_64-unknown-linux-gnu_gcc12/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc
output/x86_64-unknown-linux-gnu_gcc12/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-g++
output/x86_64-unknown-linux-gnu_gcc12/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ld

Packaging Notes

build.sh packages the final archive with stable tar ordering and normalized ownership, then writes a SHA-256 checksum next to the tarball for downstream verification.

Extending the Repository

To add another target or GCC major version, create a new Crosstool-NG config in configs/ that follows the existing naming convention:

configs/<target-triplet>_gcc<major>

The build scripts derive the target triplet and output paths from that naming scheme, so keeping it consistent avoids additional script changes.

Releases

Releases are published to GitHub Releases via the CI pipeline (.github/workflows/release.yml). Pushing a v* tag builds all four target/GCC combinations in parallel and attaches the resulting .tar.gz and .sha256 files to the release.

Each release archive contains the bundled license texts for all third-party components under <target-triplet>/share/licenses/. See NOTICE for the full list of components and their upstream source locations.

License

This repository is licensed under Apache License 2.0. See LICENSE and NOTICE for details.

About

Bazel toolchains for GNU GCC

Resources

Security policy

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages