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 the sharedtemplates/BUILD.templateandtemplates/cc_toolchain_config.bzl.templateinto a new repository, substituting CPU, version, licensing, and flag placeholders.- The rendered
BUILDfile wires in the toolchain's feature set: per-instance features created at generation time (extra compile/link flags, sysroot link flags, compiler library search paths) plus the orderedknown_features/enabled_featureslists fromfeatures/custom/linux/orfeatures/custom/qnx/, which reference the reusablecc_featuretargets underfeatures/native/. - 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 and archive patches.
rules/common.bzl
Provides small helpers that convert lists of flags into the Bazel flag_group
representation needed by the templates and repository rules. It also defines
the SDP version mappings used to map package releases to platform constraints.
rules/gcc.bzl
Generates the toolchain repository. It performs placeholder substitution and
emits the final BUILD, cc_toolchain_config.bzl, and gcov wrapper files,
substituting OS-specific values (e.g. compiler, abi_version,
toolchain_identifier) into the shared templates below.
features/
Defines the toolchain's cc_feature / cc_args targets with
@rules_cc//cc/toolchains. features/native/ holds one reusable target per
toolchain feature; features/custom/linux/ and features/custom/qnx/ hold
OS-specific features plus the ordered known_features/enabled_features
lists that templates/BUILD.template passes to cc_toolchain_config.
Shared templates (used by both Linux and QNX):
templates/cc_toolchain_config.bzl.templatetemplates/BUILD.templatetemplates/cc_gcov_wrapper.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
SDP_VERSION_MAPPINGinrules/common.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.