Repository navigation
Open
Labels
refinement neededThe issue or PR needs refinement
Description
Epic: Rule-based C++ toolchains (PoC)
Background
The toolchains in this repository are generated per platform from templates/BUILD.template and templates/cc_toolchain_config.bzl.template. They are a hybrid of two approaches:
- Features under
features/already use the rule-based API (cc_args,cc_feature). - The toolchain itself is still declared the legacy way:
- a custom
cc_toolchain_configrule hand-buildsaction_configs andtool_paths; - it is wired into the native
cc_toolchainthroughtoolchain_config; gcovneeds a wrapper script as a workaround for rules_cc#351.
- a custom
The rule-based toolchain API in rules_cc replaces this with declarative targets (cc_tool, cc_tool_map, cc_args, cc_feature, cc_toolchain). Its API is documented here: https://github.com/bazelbuild/rules_cc/blob/main/docs/toolchain_api.md
Goal
Build a proof of concept that declares at least one toolchain per OS family fully with the rule-based API. The PoC should show whether we can drop the legacy cc_toolchain_config template. It should also record the gaps, so we can decide whether and how to migrate everything.
Scope
- Linux GCC, QNX 8.0 SDP and EBcLfSA are the target toolchain families. The PoC may start with one family (for example Linux x86_64 GCC), but the findings must cover all three.
- Use
rules_cc0.2.25 (the version we already depend on). Record any API features that need a newer version. - Keep the existing generated-repository model (
gccmodule extension,gcc_toolchainrepository rule). Only the generated toolchain content changes. - The PoC runs alongside the existing toolchains. It is not a replacement, and the legacy path stays the default until a decision is made.
Out of scope
- Removing the legacy toolchain path.
- Changing supported SDP, GCC or SDK versions.
- Changes to the public module extension API, unless the PoC shows they are unavoidable.
Work items
- Analysis
- Map every legacy
action_config,tool_pathand feature to its rule-based equivalent. - List what the API cannot express yet:
gcovhandling, per-toolchainenvwith resolved paths (QNX_HOST/QNX_TARGET),cxx_builtin_include_directories, sysroot,stripandarflags.
- Map every legacy
- Tool declarations
- Declare
cc_toolandcc_tool_mapfor compile, link, archive, strip, objcopy and coverage. - Replace the
gcov_wrapperworkaround if the API allows it. - Fix the package BUILD files so each CPU-specific tool target maps to the matching binary (for example
packages/qnx/sdp/8.0/sdp.BUILD).
- Declare
- Args and features
- Check that the existing
features/targets work unchanged with the rule-basedcc_toolchain. - Port anything that depends on legacy
featureorflag_setconstructs.
- Check that the existing
- Toolchain declaration
- Add a template variant that emits the rule-based
cc_toolchain, withknown_features,enabled_featuresand the tool map. - Pass runfiles and
all_filesthrough the API's data attributes in place of the current filegroups.
- Add a template variant that emits the rule-based
- Validation
- Build and run the existing tests under
tests/and the examples with the PoC toolchain. - Compare compile and link command lines (
--subcommands) between the legacy and rule-based toolchains, and explain any differences. - Check sandboxed and remote execution (missing inputs,
/proc/self/cwdpaths).
- Build and run the existing tests under
- Findings and decision
- Write up the gaps, workarounds and open issues, with upstream
rules_ccissues for any blockers. - Recommend one of: migrate fully, migrate partially, or wait for upstream.
- Write up the gaps, workarounds and open issues, with upstream
Acceptance criteria
- At least one toolchain builds and passes the existing tests using only the rule-based API, with no
cc_toolchain_configrule. - The legacy and PoC command lines are compared, and every difference is justified.
- A findings document lists the blockers per toolchain family and the effort to migrate the rest.
- The CI runs the PoC toolchain without affecting the default toolchains.
Risks and open questions
- Rule-based toolchains are still evolving upstream, so API changes between
rules_ccreleases may break the PoC. - Which
rules_ccminimum version will we require? - QNX needs a
QNX_HOST/QNX_TARGETenvironment with resolved paths (rules/gcc.bzlalready has a TODO for this). Label resolution incc_argsenvis not supported yet. gcovsupport: can rules_cc#351 be avoided in the new model?- Can the same BUILD content serve both the legacy and the new templates during the transition?
Child issues (to create)
- Analyse the legacy-to-rule-based mapping and list the gaps
- PoC: Linux x86_64 GCC with the rule-based toolchain
- PoC: QNX 8.0 (SDP env, sysroot, include directories)
- PoC: EBcLfSA
- Remove or replace the
gcovwrapper - CI job for PoC toolchains
- Findings and migration recommendation
Metadata
Metadata
Assignees
Labels
refinement neededThe issue or PR needs refinement
Type
Projects
- StatusShow more project fieldsrefinement needed
- StatusShow more project fieldsBacklog
Activity
[-]PoC - Ruled Based Toolchains[/-][+]Ruled Based Toolchains (PoC)[/+]