Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/x86_64-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ jobs:
- name: Bazel Test
run: |
bazel test --config=x86_64-linux -- //:language_and_standards_tests //:feature_verification_tests
- name: Bazel Test (force_pic)
run: |
bazel test --config=x86_64-linux --force_pic -- //feature_verification/opt_in_features:force_pic_flags_test
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ validates the setup, and how QNX-specific authentication and licensing fit in.
- [Repository layout](docs/repository_layout.md)
- [Extension API](docs/extension_api.md)
- [Generation flow](docs/generation_flow.md)
- [Linux toolchain feature set](docs/linux_toolchain_feature_set.md)
- [QNX toolchain feature set](docs/qnx_toolchain_feature_set.md)
- [Toolchain features](docs/features.md)
- [Tests and validation](docs/tests_and_validation.md)
- [QNX integration](docs/qnx_integration.md)
- [Test Suite](docs/test_suite.md)
Expand Down
113 changes: 113 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Toolchain Features

These are the `cc_toolchain` features defined by the toolchain configs in
[`templates/linux/cc_toolchain_config.bzl.template`](../templates/linux/cc_toolchain_config.bzl.template)
and
[`templates/qnx/cc_toolchain_config.bzl.template`](../templates/qnx/cc_toolchain_config.bzl.template).

Both toolchains enable **`no_legacy_features`**, which turns off the features
Bazel would otherwise add implicitly. As a result every flag the toolchain emits
comes from a feature defined explicitly below.

Each entry is tagged with the platform(s) it applies to: **(both)**, **(Linux)**,
or **(QNX)**. Unless noted as *opt-in (disabled by default)*, a feature is
enabled by default.

> **Note:** The order of features in the `features` list is significant — flags
> from a later feature appear after those from an earlier feature on the command
> line.

## Capability markers
- **`no_legacy_features`** (both) — Disables Bazel's implicit legacy features.
- **`supports_pic`** (both) — Declares position-independent-code support.
- **`supports_dynamic_linker`** (both) — Declares dynamic-linking support.
- **`supports_fission`** (Linux) — Declares Fission (split DWARF) support.
- **`supports_header_path_normalization`** (Linux) — Suppresses absolute-path
warnings for system headers.
- **`dbg`** / **`opt`** (both) — Well-known build-mode markers used to select flags.

## Compilation
- **`unfiltered_compile_flags`** (both) — Redacts `__DATE__`/`__TIME__`/`__TIMESTAMP__`
for reproducible builds.
- **`default_compile_flags`** (both) — Core compile flags plus `dbg`/`opt`
build-mode variants (exact flags differ per target).
- **`pic`** (Linux) — Emits `-fPIC` when the `pic` build variable is available.
(On QNX `-fPIC` is part of the default compile flags.)
- **`random_seed`** (both) — Emits `-frandom-seed=<output_file>` for
deterministic output.
- **`include_paths`** (both) — Emits `-iquote` / `-I` / `-isystem` from the
`quote_include_paths`, `include_paths`, and `system_include_paths` variables.
- **`preprocessor_defines`** (both) — Emits `-D` defines (from `defines` /
`local_defines`).
- **`includes`** (Linux) — Emits `-include <hdr>` for force-included headers.
- **`user_compile_flags`** (both) — Passes through user-supplied compile flags
(`copts`).
- **`compiler_input_flags`** (both) — `-c` and the source file.
- **`compiler_output_flags`** (both) — `-S` / `-E` / `-o` output flags.
- **`compiler_library_search_paths`** (Linux) — Sets `LD_LIBRARY_PATH` so the
compiler binary finds its shared libraries.
- **`dependency_file`** (both) — Generates `.d` dependency files. On QNX,
**`dependency_file_named_implicitly`** toggles between explicit and implicit
naming.
- **`per_object_debug_info`** (Linux) — Emits `-gsplit-dwarf -g` under
`--fission` (guarded; no-op otherwise).

## Linking / archiving
- **`archiver_flags`** (both) — `ar` flags (`rcsD`) and the object-file list for
static archives.
- **`user_link_flags`** (both) — Passes
through user-supplied link flags (`linkopts`).
- **`linker_param_file`** (both) — Uses `@param_file` for linker/archiver args.
- **`default_link_flags`** (both) — Default/hardening link flags (exact flags
differ per target and build mode).
- **`library_search_directories`** (both) — Emits `-L` search paths.
- **`runtime_library_search_directories`** (both) — Emits `-Wl,-rpath` entries
(`$ORIGIN` for `cc_test`, `$EXEC_ORIGIN` otherwise).
- **`shared_flag`** (both) — `-shared` for dynamic libraries.
- **`output_execpath_flags`** (both) — `-o` for the link output.
- **`libraries_to_link`** (both) — Handles whole-archive, static, object-file,
dynamic, and versioned-dynamic library linking.
- **`sysroot_link_flags`** (Linux) — Adds `--sysroot` / `-Wl,--sysroot` at link.

### Opt-in link features (Linux)
These mirror Bazel's legacy features and are guarded, so they are no-ops until
the relevant build mode is active. All are enabled by default except where noted.
- **`fission_support`** — `-Wl,--gdb-index` under `--fission`.
- **`linkstamps`** — Passes `%{linkstamp_paths}` to the linker (`--stamp`).
- **`force_pic_flags`** — `-pie` for executables under `--force_pic`.
- **`strip_debug_symbols`** — `-Wl,-S` when the link output is stripped
(e.g. `fastbuild`/`opt`, not `dbg`).
- **`static_libgcc`** — `-static-libgcc` when `static_link_cpp_runtimes` is on.
- **`fully_static_link`** — `-static` for fully static executables. **Opt-in
(disabled by default)**, since it forces static linking for every target and
requires static system archives (unavailable on some toolchains, e.g. AutoSD).

## Warnings (all opt-in / disabled by default)
- **`minimal_warnings`** (both) — Baseline warning set.
- **`strict_warnings`** (both) — Stricter warnings; implies `minimal_warnings`.
- **`all_wall_warnings`** (Linux) — Broadest warning set; implies `strict_warnings`.
- **`warnings_as_errors`** (both) — Adds `-Werror`.

## Sanitizers (Linux, opt-in)
- **`sanitizer`** — Base sanitizer feature.
- **`asan`** / **`lsan`** / **`tsan`** / **`ubsan`** — Address / Leak / Thread /
Undefined-Behavior sanitizers; each implies `sanitizer`.

## Threading
- **`use_pthread`** (Linux) — Links with `-pthread`.

## Extra flag hooks (template-substituted)
- **`extra_compile_flags`** (both) — Extra flags for all compile actions.
- **`extra_c_compile_flags`** / **`extra_cxx_compile_flags`** (Linux) — Extra C /
C++ compile flags.
- **`extra_link_flags`** (both) — Extra link flags.

## Coverage
- **`coverage`** (both) — Base coverage feature.
- **`gcc_coverage_map_format`** (both) — `-fprofile-arcs -ftest-coverage` at
compile and `-lgcov` / `--coverage` at link.

## QNX environment
- **`sdp_env`** (QNX) — Injects QNX SDP environment variables (`QNX_HOST`,
`QNX_TARGET`, license path, ...) into compile/link actions.
- **`qnx_license_env_info`** (QNX) — Adds an optional license environment entry.
179 changes: 0 additions & 179 deletions docs/linux_toolchain_feature_set.md

This file was deleted.

36 changes: 36 additions & 0 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,42 @@ centralizes special sysroot flags in one place.
Use explicit `gcc.sdp(...)` declarations when package metadata is local,
experimental, or intentionally not part of the default support matrix.

## Toolchain Feature Wiring

Both the Linux and QNX toolchain configs enable **`no_legacy_features`**, so
Bazel injects nothing implicitly — every compile/link/archive flag must come
from a feature (or wiring) declared in the template. See
[docs/features.md](features.md) for the full feature list. Not everything is a
feature, though; some behavior is provided by other toolchain wiring:

- **Compiler / archiver / strip tools** are bound through `action_config`
entries (`assemble`, `c_compile`, `cpp_compile`, the link actions, and
`cpp_link_static_library`), not `tool_paths`. The static-library action
`implies = ["archiver_flags"]`, so the `archiver_flags` feature only supplies
the flags while the `action_config` supplies the `ar` binary.
- **`gcov`** is provided via `tool_paths` (`gcov_wrapper`).
- **Sysroot (Linux)** — the sysroot path is passed as `builtin_sysroot` to
`create_cc_toolchain_config_info`; compile-time header resolution relies on
`cxx_builtin_include_directories`, so no `--sysroot` is needed at compile.
Link-time `--sysroot` / `-Wl,--sysroot` is emitted by the custom
`sysroot_link_flags` feature. There is intentionally no legacy `sysroot`
compile feature.
- **Sysroot / system includes (QNX)** — QNX does not use `builtin_sysroot`;
system include roots come from `cxx_builtin_include_directories` (SDP paths),
and the SDP environment is injected by the `sdp_env` feature.

When adding or auditing a feature, classify how each required behavior is
provided: an **explicit feature** in the `features` list, **tool/sysroot wiring**
as above, or **flags baked into another feature** (e.g. `-fPIC` is an explicit
`pic` feature on Linux but part of `default_compile_flags` on QNX). Under
`no_legacy_features` nothing is supplied automatically, so a missing behavior
means a broken build rather than a silent fallback.

> **Static archives:** `fully_static_link` (`-static`) requires static system
> libraries (`libc.a`, `libstdc++.a`, ...). Toolchains that ship only shared
> libraries (e.g. AutoSD) cannot link fully static binaries, so that feature is
> opt-in and its test is marked incompatible with such platforms.

## Common Gotchas

- runtime-specific toolchains may need extra include and link flags that do not
Expand Down
Loading
Loading