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
4 changes: 3 additions & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ enabled by default.
- **`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.
- **`sysroot_link_flags`** (Linux) — Adds `--sysroot` / `-Wl,--sysroot` at link,
and `--sysroot` for assemble/preprocess-assemble actions (preprocessed `.S`
sources need it to resolve sysroot headers).
Comment thread
nradakovic marked this conversation as resolved.

### Opt-in link features (Linux)
These mirror Bazel's legacy features and are guarded, so they are no-ops until
Expand Down
10 changes: 6 additions & 4 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ feature, though; some behavior is provided by other toolchain wiring:
- **`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.
`cxx_builtin_include_directories`, so no `--sysroot` is needed for c/cxx
compiles. Link-time `--sysroot` / `-Wl,--sysroot` and assembly-time
`--sysroot` (assemble / preprocess-assemble; needed for `.S` sources since
the extra_*_compile_flags include paths do not apply there) are emitted by
Comment thread
nradakovic marked this conversation as resolved.
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.
Expand Down
2 changes: 1 addition & 1 deletion docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ toolchain, are summarized below.
| Default / hardening link flags | **Supported, explicit** | `default_link_flags` feature |
| `-L` library search paths, `-Wl,-rpath` | **Supported, explicit** | `library_search_directories`, `runtime_library_search_directories` |
| Static archive creation (`ar`) | **Supported, explicit** | `archiver_flags` feature + `cpp_link_static_library` action |
| `--sysroot` handling | **Supported, explicit (Linux)** | `sysroot_link_flags` at link; compile relies on `cxx_builtin_include_directories` |
| `--sysroot` handling | **Supported, explicit (Linux)** | `sysroot_link_flags` at link and assemble/preprocess-assemble; C/C++ compile-time header resolution relies on `cxx_builtin_include_directories` |
| Compiler / archiver / strip tool binding | **Supported, wiring** | `action_config` entries, not legacy `tool_paths` |
| `gcov` | **Supported, wiring** | `tool_paths` (`gcov_wrapper`) |
| Warnings (e.g. `-Wall`) added by default | **Not part of this toolchain — injected** | `minimal_warnings` / `strict_warnings` / `all_wall_warnings` are defined by `score_cpp_policies`, not this toolchain, and only become available once brought in via `extra_known_features` / `extra_enabled_features`. |
Expand Down
15 changes: 14 additions & 1 deletion features/native/sysroot_link_flags/features.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Feature definition for sysroot link flags.
"""

load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature")
load("@rules_cc//cc/toolchains/args:sysroot.bzl", "cc_sysroot")

Expand All @@ -21,6 +24,7 @@ def make_sysroot_link_flags(target_os, sysroot):
"-Wl,--sysroot={sysroot}" needs to be listed here.

Args:
target_os: the target operating system for this toolchain (e.g., "linux").
sysroot: label of the directory rule for this toolchain's sysroot.
"""
if target_os == "linux":
Expand All @@ -31,8 +35,17 @@ def make_sysroot_link_flags(target_os, sysroot):
sysroot = sysroot,
)

cc_sysroot(
name = "sysroot_assembly_flags_args",
actions = ["@rules_cc//cc/toolchains/actions:assembly_actions"],
sysroot = sysroot,
)

cc_feature(
name = "sysroot_link_flags",
args = [":sysroot_link_flags_args"],
args = [
":sysroot_link_flags_args",
":sysroot_assembly_flags_args",
],
feature_name = "sysroot_link_flags",
)
Loading