The repository turns a small MODULE.bazel declaration into a generated
toolchain repository through these steps:
extensions/gcc.bzlcollectsgcc.toolchainandgcc.sdptags.- Package metadata is resolved from
packages/version_matrix.bzlor from an explicitgcc.sdpdeclaration. rules/gcc.bzlrenders a BUILD file and configuration files into a new repository.- Platform-specific templates from
templates/linux/ortemplates/qnx/are populated with CPU, version, licensing, and flag information. - The consuming workspace enables the generated toolchain with
--extra_toolchainsand compatible platform constraints.
packages/version_matrix.bzl
Defines the supported package matrix. Each entry maps a logical toolchain key to download metadata and, when needed, extra compiler or linker flags.
rules/common.bzl
Provides small helpers that convert lists of flags into the Bazel flag_group
representation needed by the templates and repository rules.
rules/gcc.bzl
Generates the toolchain repository. It decides whether Linux or QNX template
content is required, performs placeholder substitution, and emits the final
BUILD, cc_toolchain_config.bzl, flags.bzl, and Linux gcov wrapper
files.
Linux templates:
templates/linux/cc_toolchain_config.bzl.templatetemplates/linux/cc_toolchain_flags.bzl.templatetemplates/linux/cc_gcov_wrapper.template
QNX templates:
templates/qnx/cc_toolchain_config.bzl.templatetemplates/qnx/cc_toolchain_flags.bzl.template
Shared template:
templates/BUILD.template
- Some package definitions rely on the
%{toolchain_pkg}%placeholder, which is rewritten to the canonical Bzlmod repository name during repository-rule generation. This is handled by the_get_canonical_pkg_name()helper inrules/gcc.bzl. - QNX
aarch64is mapped internally toaarch64lewhere required by the underlying SDK layout. This normalization is a QNX-specific convention, centralized in the_normalize_cpu()helper. Linux toolchain binaries use the CPU name unchanged (e.g.,aarch64-unknown-linux-gnu-gcov). - SDP version mapping is handled through the
_SDP_VERSION_MAPPINGconfiguration inrules/gcc.bzl. Currently, SDP version8.0.4is mapped to8.0.0because platform constraint support uses the older identifier. This mapping is configurable for future extensibility. - Linux toolchains generate an extra
gcov_wrapperscript to work around the currentrules_cccoverage integration behavior. The gcov path uses the{cpu}-unknown-linux-gnu-gcovnaming convention.
The version matrix is more than a list of URLs. It is also the place where the repository centralizes:
- package build-file selection,
- archive extraction prefixes,
- sysroot-specific compiler flags,
- extra link flags,
- compiler library search paths,
- runtime-ecosystem variants such as AutoSD or EB corbos Linux for Safety Applications.