Skip to content

Enable no_legacy_features on the Linux and QNX toolchains#95

Merged
nradakovic merged 5 commits into
mainfrom
nira_no_legacy_ft
Jul 15, 2026
Merged

Enable no_legacy_features on the Linux and QNX toolchains#95
nradakovic merged 5 commits into
mainfrom
nira_no_legacy_ft

Conversation

@nradakovic

@nradakovic nradakovic commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Moves both the Linux (GCC) and QNX (QCC) cc_toolchain configs to an explicit, no_legacy_features-based configuration. With legacy feature injection disabled, every compile, link, and archive flag is now supplied by a feature defined in the templates. Adds test coverage for the newly explicit features and refreshes the documentation.

Toolchain changes

  • Enable no_legacy_features on both templates and explicitly implement every compile, link, and archive feature previously provided by Bazel's legacy machinery.
  • Add guarded legacy features that are safe to enable by default (no-ops until the relevant build mode is active): per_object_debug_info, fission_support, linkstamps, includes, force_pic_flags, strip_debug_symbols, static_libgcc. fully_static_link stays opt-in since it emits -static unconditionally.
  • Fix include_paths to use the correct build variables (quote_include_paths / include_paths / system_include_paths); the previous *_include_directories names were never populated, so no -iquote/-I/-isystem flags were emitted.

Tests

  • New feature-verification tests that genuinely exercise the explicit features: preprocessor_defines_test (local_defines), include_dir_test (the includes attribute), user_link_flags_test (linkopts/--defsym), random_seed_test, and fully_static_link_test (verifies no shared objects are mapped; marked incompatible with toolchains lacking static archives, e.g. AutoSD).
  • New opt_in_features/ package with manual tests for the disabled-by-default / build-mode-gated features, plus a genuine force-PIC check run in a dedicated --force_pic CI step.
  • Wire the new tests into //:feature_verification_tests and update the x86_64-linux workflow.

Documentation

  • Rewrite docs/features.md to reflect the explicit feature set, with per-feature platform tags and default-enabled/opt-in status.
  • Remove the now-complete planning docs (linux_toolchain_feature_set.md, qnx_toolchain_feature_set.md), migrating their sysroot and tool-wiring notes into a new "Toolchain Feature Wiring" section in docs/maintenance.md; update the README accordingly.
  • Refresh docs/test_suite.md and docs/tests_and_validation.md for the new tests and layout.

Resolves #76 #77 #78 #79 #80

@nradakovic nradakovic self-assigned this Jul 8, 2026
@nradakovic nradakovic force-pushed the nira_no_legacy_ft branch 5 times, most recently from bea6bfa to 640636a Compare July 14, 2026 15:28
@nradakovic nradakovic changed the title Add no_legacy feature Enable no_legacy_features on the Linux and QNX toolchains Jul 14, 2026
@nradakovic nradakovic marked this pull request as ready for review July 14, 2026 15:30
Copilot AI review requested due to automatic review settings July 14, 2026 15:30
@nradakovic nradakovic added repo config Improvements or additions to repository configuration action config New action config request unit test Add or update unit tests example Add or update examples template Add or update template toolchain configurations p3 Medium/Low - handle it within normal process module dependency update Add or update MODULE.bazel file with new dependency version deprecated cleanup Remove deprecated targets labels Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Linux (GCC) and QNX (QCC) Bazel cc_toolchain templates to a fully explicit feature configuration by enabling no_legacy_features, ensuring that compile/link/archive behavior is driven by features declared in the templates rather than Bazel’s legacy feature injection.

Changes:

  • Enable no_legacy_features in both Linux and QNX toolchain templates and explicitly add the core compile/link/archive features that were previously implicitly provided.
  • Add new feature-verification tests (plus a new opt_in_features/ package for manual/build-mode-gated checks) and wire them into the feature verification suite.
  • Refresh and restructure documentation to reflect the explicit feature set and updated validation/test layout, and update the Linux CI workflow to exercise --force_pic.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/feature_verification/user_link_flags_test.cpp Adds runtime/link-failure-based verification for forwarding linkopts via user link flags feature.
tests/feature_verification/random_seed_test.cpp Adds a build-and-run smoke test exercising code patterns affected by -frandom-seed.
tests/feature_verification/preprocessor_defines_test.cpp Adds a compile-time check verifying local_defines are routed via preprocessor_defines.
tests/feature_verification/opt_in_features/opt_in_smoke.cpp Shared smoke-test main for manual opt-in feature targets.
tests/feature_verification/opt_in_features/force_pic_test.cpp Adds a --force_pic verification by asserting PIE (ET_DYN) via ELF header inspection.
tests/feature_verification/opt_in_features/BUILD Introduces manual tests for opt-in/build-mode-gated features.
tests/feature_verification/include_dir/custom_math.h Adds a header used to verify include search paths emitted for includes-exposed directories.
tests/feature_verification/include_dir_test.cpp Adds test verifying includes attribute -> include_paths feature behavior.
tests/feature_verification/fully_static_link_test.cpp Adds runtime verification of fully static linking by scanning /proc/self/maps for .so mappings.
tests/feature_verification/BUILD Wires new feature tests into the feature verification package.
tests/BUILD Adds new feature verification tests into the top-level tests suite.
templates/qnx/cc_toolchain_config.bzl.template Enables no_legacy_features and adds explicit core compile/link/archive features for QNX.
templates/linux/cc_toolchain_config.bzl.template Enables no_legacy_features and adds explicit core + guarded legacy-equivalent features for Linux.
README.md Updates repository documentation links to reflect the new consolidated features documentation.
docs/tests_and_validation.md Updates the description of feature verification coverage and the new opt-in tests package.
docs/test_suite.md Documents the newly added feature verification tests and the opt-in/manual test package.
docs/qnx_toolchain_feature_set.md Removes planning doc now superseded by explicit feature wiring + consolidated features doc.
docs/maintenance.md Adds “Toolchain Feature Wiring” section explaining how non-feature wiring complements no_legacy_features.
docs/linux_toolchain_feature_set.md Removes planning doc now superseded by explicit feature wiring + consolidated features doc.
docs/features.md Adds consolidated documentation for toolchain features across Linux and QNX.
.github/workflows/x86_64-linux.yml Adds a dedicated CI step to exercise the force-PIE behavior under --force_pic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/qnx/cc_toolchain_config.bzl.template
Comment thread docs/features.md Outdated
Enable no_legacy_features on the Linux and QNX cc_toolchain configs
and explicitly implement every compile, link, and archive feature
previously provided by Bazel's legacy machinery, plus guarded
legacy features enabled by default (fully_static_link stays
opt-in). Also fix include_paths to use the correct build variables
(quote_include_paths/include_paths/system_include_paths), which
were never populated before and so emitted no -iquote/-I/-isystem
flags.

resolves #76 #77
Rewrite docs/features.md to reflect the explicit, no_legacy_features-based
feature set of both the Linux and QNX toolchains, with per-feature platform
tags and default-enabled/opt-in status.

Remove the two development/planning documents (linux_toolchain_feature_set.md,
qnx_toolchain_feature_set.md) now that the migration they tracked is complete,
migrating their still-relevant sysroot and tool-wiring notes into a new
"Toolchain Feature Wiring" section in docs/maintenance.md. Update the README to
link to features.md instead of the removed documents.

resolves #80
Add tests that genuinely exercise the features implemented under
no_legacy_features:
- preprocessor_defines_test: defines via the local_defines attribute
  (distinct from copts/user_compile_flags)
- include_dir_test: include_paths via a library's `includes` attribute
- user_link_flags_test: linkopts forwarded through user_link_flags (--defsym)
- random_seed_test: reproducible-build random seed smoke test
- fully_static_link_test: verifies a fully static binary maps no shared
  objects; marked incompatible with toolchains lacking static archives (AutoSD)

Add an opt_in_features/ package with manual tests for the disabled-by-default
or build-mode-gated features (per_object_debug_info, fission_support,
linkstamps, includes, force_pic_flags, strip_debug_symbols, static_libgcc), and
a genuine force_pic PIE check run via a dedicated --force_pic CI step.

Wire the new tests into //:feature_verification_tests and update the
x86_64-linux workflow. Refresh docs/test_suite.md and docs/tests_and_validation.md
to list the new tests, the opt_in_features package, and the directory layout.

resolves #78
antonkri
antonkri previously approved these changes Jul 15, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Nikola Radakovic <radaknikolans@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Nikola Radakovic <radaknikolans@gmail.com>
@antonkri antonkri self-requested a review July 15, 2026 09:09
@nradakovic nradakovic merged commit e5b059c into main Jul 15, 2026
12 checks passed
@nradakovic nradakovic deleted the nira_no_legacy_ft branch July 15, 2026 09:34
@github-project-automation github-project-automation Bot moved this from In Progress to Done in INF - Infrastructure Community Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action config New action config request deprecated cleanup Remove deprecated targets example Add or update examples module dependency update Add or update MODULE.bazel file with new dependency version p3 Medium/Low - handle it within normal process repo config Improvements or additions to repository configuration template Add or update template toolchain configurations unit test Add or update unit tests

Projects

3 participants