Refactor features implementation - #132
Open
nradakovic wants to merge 11 commits into
Open
Conversation
nradakovic
force-pushed
the
nira_add_cc_features
branch
from
August 31, 2026 11:30
45e2770 to
47a0092
Compare
Introduce standalone cc_feature/cc_args/cc_feature_set targets under features/, replacing the monolithic per-OS cc_toolchain_flags.bzl.template logic with composable, individually buildable feature targets from @rules_cc//cc/toolchains. - features/native/: one target per legacy toolchain feature (default_compile_flags, include_paths, pic, sysroot_link_flags, etc.), including capability markers (dbg, opt, supports_pic, ...). - features/custom/linux/ and features/custom/qnx/: project-specific features not covered by the native set (e.g. QNX gcc_version_flags, sdp_env). - features/BUILD and features/make_cc_features.bzl: cc_feature_set aggregation and helpers for assembling known/enabled feature lists per target_os. No existing targets are wired to these features yet; that follows in a subsequent commit.
Update Bazel version to be aligned with project requirements.
The current supported version of S-CORE project is 8.6.
Switch gcc_toolchain's generated BUILD/config files from the old per-OS cc_toolchain_flags.bzl.template + hand-rolled feature() calls to known_features/enabled_features built from the features/ targets introduced previously. - templates/BUILD.template: instantiate per-instance features (extra_compile_flags, extra_link_flags, compiler_library_search_paths, sysroot_link_flags, and OS-specific custom features) and resolve _KNOWN_FEATURES/_ENABLED_FEATURES via get_feature_lists(). - templates/cc_toolchain_config.bzl.template: replaces the separate templates/linux and templates/qnx variants with a single shared template driven by known_features/enabled_features and cxx_builtin_include_directories. - rules/gcc.bzl: drop the now-unused cc_toolchain_flags plumbing, add get_custom_cc_features_qnx() (sdp_env) and get_custom_cc_features_linux(), and pass extra flag/search-path values into the BUILD template instead of the config template. - rules/common.bzl: add get_flag_strings() to render flag lists as Starlark string literals for the new template. - extensions/gcc.bzl: point toolchains at the single shared cc_toolchain_config.bzl.template and drop cc_toolchain_flags. - packages/**/gcc.BUILD: add cxx_builtin_include_directories filegroup consumed by the new config template.
In order to built AutoSD binaries, we need to disable default link options. The AutoSD options are supplied via external flags.
Reflect the collapse of Linux/QNX cc_toolchain_config templates into a single shared template, and record the in-progress features/ catalog migration. - docs/generation_flow.md: describe the single shared cc_toolchain_config.bzl.template + BUILD.template + cc_gcov_wrapper.template used by both OSes instead of separate templates/linux and templates/qnx families. - docs/features.md, docs/migration_guide.md: update links/references from templates/linux|qnx/cc_toolchain_config.bzl.template to the single templates/cc_toolchain_config.bzl.template. - docs/maintenance.md: document the new features/ declarative catalog (cc_feature/cc_args/cc_feature_set) as a parallel, not-yet-consumed representation of the legacy template's features, including the linux_features/qnx_features ordering rules and the still-open question of how to fit the extra_*_flags hooks into that model.
Update bazel deps in test directory.
- repository_layout.md: add missing features/ entry, describe single shared template pair instead of removed templates/linux|qnx split - generation_flow.md: fix flow steps still pointing at templates/linux/ and templates/qnx/ (now empty stubs) - maintenance.md: replace "In-Progress" features/ section — the legacy feature() template is gone, cc_toolchain_config now consumes known_features/enabled_features straight from features/ - migration_guide.md: fix warning-feature claims that contradicted features.md, and the outdated no_legacy_features feature() snippet - guardrails/*: point "how to fix" guidance at features/custom/linux|qnx/make_cc_features.bzl
Fix format errors detected by workflow guard.
nradakovic
force-pushed
the
nira_add_cc_features
branch
from
August 31, 2026 11:42
43fb9b5 to
1d61cc4
Compare
Update Bazel module deps in test directory.
nradakovic
marked this pull request as ready for review
August 31, 2026 11:44
nradakovic
requested review from
AlexanderLanin,
antonkri and
dcalavrezo-qorix
as code owners
August 31, 2026 11:44
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Bazel C/C++ toolchain configuration to move most feature logic out of per-OS cc_toolchain_config.bzl.template files into a declarative features/ catalog (using @rules_cc//cc/toolchains), and consolidates Linux/QNX templates into shared templates. It also updates the test workspace’s Bazel/tooling versions and refreshes documentation to match the new layout.
Changes:
- Replace per-OS toolchain config/flags templates with shared
templates/cc_toolchain_config.bzl.templateplus OS-specific ordered feature lists underfeatures/custom/*. - Introduce a large set of reusable
cc_feature/cc_argstargets underfeatures/native/*and wire per-toolchain instance features viatemplates/BUILD.template. - Update test workspace Bazel version and lockfile, and refresh docs and CI workflow flags to reflect the new feature model.
Reviewed changes
Copilot reviewed 66 out of 73 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/MODULE.bazel.lock | Updates Bazel module lockfile (version bump and regenerated digests/facts). |
| tests/guardrails/README.md | Updates guardrail remediation guidance to point at the new feature list sources. |
| tests/guardrails/legacy_feature_guard.bzl | Updates guardrail failure message to reference new feature list locations. |
| tests/.bazelversion | Bumps Bazel version used by the test workspace. |
| templates/qnx/cc_toolchain_flags.bzl.template | Removes QNX-specific legacy flags template (now replaced by features/). |
| templates/qnx/cc_toolchain_config.bzl.template | Removes QNX-specific legacy toolchain config template (now shared). |
| templates/linux/cc_toolchain_flags.bzl.template | Removes Linux-specific legacy flags template (now replaced by features/). |
| templates/linux/cc_toolchain_config.bzl.template | Removes Linux-specific legacy toolchain config template (now shared). |
| templates/cc_toolchain_config.bzl.template | Adds shared cc_toolchain_config template that consumes known/enabled feature labels. |
| templates/cc_gcov_wrapper.template | Adds shared gcov wrapper template for coverage integration. |
| templates/BUILD.template | Wires feature catalogs + per-instance features into generated toolchain repos. |
| rules/gcc.bzl | Updates toolchain repo generation to use shared templates and feature list plumbing. |
| rules/common.bzl | Adds helper for rendering string-list literals into generated BUILD templates. |
| packages/linux/x86_64/gcc/15.3.0/gcc.BUILD | Adds/updates toolchain package metadata needed by new toolchain wiring. |
| packages/linux/x86_64/gcc/12.2.0/gcc.BUILD | Adds/updates toolchain package metadata needed by new toolchain wiring. |
| packages/linux/aarch64/gcc/15.3.0/gcc.BUILD | Adds/updates toolchain package metadata needed by new toolchain wiring. |
| packages/linux/aarch64/gcc/12.2.0/gcc.BUILD | Adds/updates toolchain package metadata needed by new toolchain wiring. |
| packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD | Adds/updates toolchain package metadata needed by new toolchain wiring. |
| packages/linux/aarch64/autosd/10.0/autosd.BUILD | Adds/updates toolchain package metadata needed by new toolchain wiring. |
| features/native/user_link_flags/BUILD | Adds declarative feature for user-provided link flags. |
| features/native/user_compile_flags/BUILD | Adds declarative feature for user-provided compile flags. |
| features/native/use_pthread/BUILD | Adds declarative feature for -pthread linking. |
| features/native/unfiltered_compile_flags/BUILD | Adds always-on deterministic macro redaction flags. |
| features/native/sysroot_link_flags/features.bzl | Adds generator for per-toolchain sysroot link feature. |
| features/native/sysroot_link_flags/BUILD | Build package placeholder for per-toolchain sysroot feature generation. |
| features/native/strip_debug_symbols/BUILD | Adds declarative feature for strip-at-link behavior. |
| features/native/static_libgcc/BUILD | Adds declarative feature for static libgcc under a constraint marker. |
| features/native/shared_flag/BUILD | Adds declarative -shared feature for dynamic library link actions. |
| features/native/runtime_library_search_directories/BUILD | Adds declarative rpath emission behavior split by OS/test mode. |
| features/native/random_seed/BUILD | Adds deterministic -frandom-seed= feature. |
| features/native/preprocessor_defines/BUILD | Adds declarative preprocessor define emission feature. |
| features/native/pic/BUILD | Adds declarative PIC compile feature. |
| features/native/per_object_debug_info/BUILD | Adds declarative split DWARF compile feature. |
| features/native/output_execpath_flags/BUILD | Adds declarative -o {output_execpath} link feature. |
| features/native/markers/BUILD | Adds marker features (dbg/opt/etc.) used for constraints and ordering. |
| features/native/linkstamps/BUILD | Adds declarative linkstamp propagation feature. |
| features/native/linker_param_file/BUILD | Adds declarative linker param file feature. |
| features/native/library_search_directories/BUILD | Adds declarative -L search directory feature. |
| features/native/libraries_to_link/BUILD | Adds declarative library-to-link iteration feature for link actions. |
| features/native/includes/BUILD | Adds declarative forced -include feature. |
| features/native/include_paths/BUILD | Adds declarative include path emission feature. |
| features/native/gcc_coverage_map_format/BUILD | Adds declarative coverage flags feature gated by coverage marker. |
| features/native/fully_static_link/BUILD | Adds declarative fully-static linking feature (opt-in). |
| features/native/force_pic_flags/BUILD | Adds declarative -pie emission under force_pic. |
| features/native/fission_support/BUILD | Adds declarative fission linker feature. |
| features/native/extra_link_flags/features.bzl | Adds generator for per-toolchain extra link flags feature. |
| features/native/extra_link_flags/BUILD | Build package placeholder for per-toolchain extra link feature generation. |
| features/native/extra_compile_flags/features.bzl | Adds generator for per-toolchain extra compile flags features. |
| features/native/extra_compile_flags/BUILD | Build package placeholder for per-toolchain extra compile feature generation. |
| features/native/dependency_file/BUILD | Adds declarative dependency file emission behavior (Linux/QNX variants). |
| features/native/default_link_flags/BUILD | Adds declarative default link flags for Linux/QNX. |
| features/native/default_compile_flags/BUILD | Adds declarative default compile flags (OS/CPU/mode conditioned). |
| features/native/compiler_output_flags/BUILD | Adds declarative compiler output flag emission feature. |
| features/native/compiler_library_search_paths/features.bzl | Adds generator for per-toolchain LD_LIBRARY_PATH environment feature. |
| features/native/compiler_library_search_paths/BUILD | Build package placeholder for per-toolchain search-path feature generation. |
| features/native/compiler_input_flags/BUILD | Adds declarative -c {source_file} emission feature. |
| features/native/archiver_flags/BUILD | Adds declarative archiver flags feature for ar actions. |
| features/make_cc_features.bzl | Adds shared helper for computing known/enabled feature lists by OS. |
| features/custom/qnx/sdp_env/feature.bzl | Adds QNX SDP environment feature generator. |
| features/custom/qnx/sdp_env/BUILD | Build package placeholder for QNX SDP env feature. |
| features/custom/qnx/make_cc_features.bzl | Defines ordered QNX feature list and default-enabled subset. |
| features/custom/qnx/gcc_version_flags/BUILD | Adds QNX-specific gcc version routing feature. |
| features/custom/qnx/BUILD | Build package placeholder for QNX custom features. |
| features/custom/linux/make_cc_features.bzl | Defines ordered Linux feature list and default-enabled subset. |
| features/custom/linux/BUILD | Build package placeholder for Linux custom features. |
| features/BUILD | Adds grouped feature sets (linux/qnx) for constraints (currently not referenced). |
| extensions/gcc.bzl | Updates extension wiring to point at the shared template. |
| docs/repository_layout.md | Documents the new features/ subsystem and shared templates. |
| docs/migration_guide.md | Updates migration guidance for the new feature injection model. |
| docs/maintenance.md | Adds a catalog overview and maintenance notes for the new feature model. |
| docs/generation_flow.md | Updates generation flow docs to reflect shared templates + feature lists. |
| docs/features.md | Updates feature documentation to reference shared template location. |
| .github/workflows/autosd.yml | Adjusts CI invocation flags for the updated toolchain feature model. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1
to
+25
| # ******************************************************************************* | ||
| # Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| # ******************************************************************************* | ||
| # Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* |
Fix issues reported by copilot.
antonkri
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR moves all toolchain features from defining features within toolchain rule implementation, to the rule based defined features.