Skip to content

Latest commit

 

History

History
91 lines (58 loc) · 11.8 KB

File metadata and controls

91 lines (58 loc) · 11.8 KB

This module provides the definitions for registering a GCC toolchain for C and C++.

gcc_toolchain

gcc_toolchain(name, binary_prefix, enable_fortran, extra_asmflags, extra_cflags, extra_cxxflags,
              extra_fflags, extra_ldflags, fincludes, gcc_toolchain_workspace_name, gcc_version,
              gcc_versions, includes, repo_mapping, supports_param_files, target_arch)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this repository. Name required
binary_prefix An explicit prefix used by each binary in bin/. Defaults to detecting the prefix from the extracted toolchain. String optional "auto"
enable_fortran Enable Fortran support in the toolchain (the default). Boolean optional True
extra_asmflags Extra flags for the assembly preprocessor. List of strings optional []
extra_cflags Extra flags for compiling C. List of strings optional []
extra_cxxflags Extra flags for compiling C++. List of strings optional []
extra_fflags Extra flags for compiling Fortran, if enabled. List of strings optional []
extra_ldflags Extra flags for linking. %workspace% is rendered to the toolchain root path. See https://github.com/bazelbuild/bazel/blob/a48e246e/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java#L234-L254. List of strings optional []
fincludes Extra includes for compiling Fortran, if enabled. %workspace% is rendered to the toolchain root path. List of strings optional []
gcc_toolchain_workspace_name The name given to the gcc-toolchain repository, if the default was not used. String optional "gcc_toolchain"
gcc_version The version of GCC. String optional "16.2.0"
gcc_versions A JSON dictionary of GCC versions to their download URLs and SHA256 hashes. The structure is {<gcc_version>: {<target_arch>: {url: <url>, sha256: <sha256>}}}. String optional "{"12.5.0":{"aarch64":{"sha256":"7b0e25133a98d44b648a925ba11f64a3adc470e87668af80ce2c3af389ebe9be","url":"https://github.com/f0rmiga/gcc-builds/releases/download/18082025/gcc-toolchain-12.5.0-aarch64.tar.xz"},"armv7":{"sha256":"a0ef76c8cc517b3d76dd2f09b1a371975b2ff1082e2f9372ed79af01b9292934","url":"https://github.com/f0rmiga/gcc-builds/releases/download/18082025/gcc-toolchain-12.5.0-armv7.tar.xz"},"x86_64":{"sha256":"51076e175839b434bb2dc0006c0096916df585e8c44666d35b0e3ce821d535db","url":"https://github.com/f0rmiga/gcc-builds/releases/download/18082025/gcc-toolchain-12.5.0-x86_64.tar.xz"}},"13.4.0":{"aarch64":{"sha256":"770cf6bf62bdf78763de526d3a9f5cae4c19f1a3aca0ef8f18b05f1a46d1ffaf","url":"https://github.com/f0rmiga/gcc-builds/releases/download/18082025/gcc-toolchain-13.4.0-aarch64.tar.xz"},"armv7":{"sha256":"1b2739b5003c5a3f0ab7c4cc7fb95cc99c0e933982512de7255c2bd9ced757ad","url":"https://github.com/f0rmiga/gcc-builds/releases/download/18082025/gcc-toolchain-13.4.0-armv7.tar.xz"},"x86_64":{"sha256":"d96071c1b98499afd7b7b56ebd69ad414020edf66e982004acffe7df8aaf7e02","url":"https://github.com/f0rmiga/gcc-builds/releases/download/18082025/gcc-toolchain-13.4.0-x86_64.tar.xz"}},"14.3.0":{"aarch64":{"sha256":"b5a73bc840938c8dbb49e2f15b8b8d63e5c33beae0be2aa9a7c52b593522cdcd","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-14.3.0-aarch64.tar.xz"},"armv7":{"sha256":"376684c062a23e84b619a717fa4c7bba336211c8b48169f76eb5aa6ed4da6bb8","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-14.3.0-armv7.tar.xz"},"x86_64":{"sha256":"d155a38e4acff9588df466f0edc98c1a2c54d09bc0162805ba38908cfd7a1d28","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-14.3.0-x86_64.tar.xz"}},"15.2.0":{"aarch64":{"sha256":"f38696590786e7c99d3bb5b8ce9ed66be6224d505fa45dcae0b2a6ec07eb0570","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-15.2.0-aarch64.tar.xz"},"armv7":{"sha256":"8ecb5b35aa25efe78772701c70ed27eda727264303d03cffc372a6f24f18be90","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-15.2.0-armv7.tar.xz"},"x86_64":{"sha256":"f31edf791877935258dcc864afbfb7c9f9238be9f7d9da0ee57f5bc121074457","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-15.2.0-x86_64.tar.xz"}},"16.1.0":{"aarch64":{"sha256":"4331e513156a699c1015fb94021497306f0a896520efbad8b3e16418eb683468","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-16.1.0-aarch64.tar.xz"},"armv7":{"sha256":"8d42c1fd130ccb170fe8d5d17148ae2d3f97134ac0009fdcac87550fec6a6289","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-16.1.0-armv7.tar.xz"},"x86_64":{"sha256":"cfd8ca5bc365c1c838825ed6e44c7b2c309aada25791f76ef73b1aec819e362e","url":"https://github.com/f0rmiga/gcc-builds/releases/download/08072026/gcc-toolchain-16.1.0-x86_64.tar.xz"}},"16.2.0":{"aarch64":{"sha256":"6407b35116f21c59e98ab5ad68ddd8ff5f3e0469723a5d465ec08ed615b11a55","url":"https://github.com/f0rmiga/gcc-builds/releases/download/10082026/gcc-toolchain-16.2.0-aarch64.tar.xz"},"armv7":{"sha256":"515da8a22fa560002d3d149ad701acb725502c70f7bf8d4905f90b0830d38238","url":"https://github.com/f0rmiga/gcc-builds/releases/download/10082026/gcc-toolchain-16.2.0-armv7.tar.xz"},"x86_64":{"sha256":"54af34c821e59b03ded8f82d3a1104426ec4baaf3b226233e1fd76ad5dcb78cf","url":"https://github.com/f0rmiga/gcc-builds/releases/download/10082026/gcc-toolchain-16.2.0-x86_64.tar.xz"}}}"
includes Extra includes for compiling C and C++. %workspace% is rendered to the toolchain root path. See https://github.com/bazelbuild/bazel/blob/a48e246e/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java#L234-L254. List of strings optional []
repo_mapping A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). Dictionary: String -> String required
supports_param_files Set supports_param_files = 1 on the generated cc_toolchain, which lets Bazel pass linker arguments via an @params file. Enable this when link command lines for large targets overflow ARG_MAX (e.g. collect2: posix_spawn: Argument list too long). Off by default to preserve historical behavior. Boolean optional False
target_arch The target architecture this toolchain produces. E.g. x86_64. String required

gcc_declare_toolchain

gcc_declare_toolchain(name, target_arch, kwargs)

Declares a gcc_toolchain for every available GCC version.

name is the hub repository holding the toolchain declarations. Each GCC version gets its own repository holding the cc_toolchain, fetched only when that version is selected through the @gcc_toolchain//toolchain:gcc_version flag.

You should use gcc_register_toolchain unless you need to register toolchains manually, e.g. if you are consuming this repository as a Bzlmod dependency.

PARAMETERS

Name Description Default Value
name The name of the hub repository holding the toolchain declarations. none
target_arch The target architecture of the toolchain. none
kwargs The extra arguments passed to gcc_toolchain. See gcc_toolchain for more info. The attributes of the toolchain declarations themselves are also accepted here, since they apply to the hub rather than to gcc_toolchain:

target_compatible_with: constraint_values passed to target_compatible_with of the toolchain. {target_arch} is rendered to the target_arch argument value. Defaults to ["@platforms//os:linux", "@platforms//cpu:{target_arch}"].

extra_target_compatible_with: Additional constraint_values appended to target_compatible_with of the toolchain, on top of the values from the target_compatible_with argument (including its defaults). Unlike target_compatible_with, {target_arch} is not rendered.

target_settings: Additional config_settings passed to target_settings of the toolchain, on top of the GCC version selection. {target_arch} is rendered to the target_arch argument value.
none

gcc_register_toolchain

gcc_register_toolchain(name, target_arch, kwargs)

Declares a gcc_toolchain for every available GCC version and registers all of them.

Which one resolves is selected by the @gcc_toolchain//toolchain:gcc_version flag.

PARAMETERS

Name Description Default Value
name The name of the hub repository holding the toolchain declarations. none
target_arch The target architecture of the toolchain. none
kwargs The extra arguments passed to gcc_declare_toolchain. See gcc_declare_toolchain for more info. none