diff --git a/.bazelversion b/.bazelversion index acd405b..df5119e 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -8.6.0 +8.7.0 diff --git a/.github/workflows/autosd.yml b/.github/workflows/autosd.yml index 89260af..ff90bfc 100644 --- a/.github/workflows/autosd.yml +++ b/.github/workflows/autosd.yml @@ -41,7 +41,7 @@ jobs: cache-save: ${{ github.event_name == 'push' }} - name: Bazel Build (basic) run: | - bazel build --lockfile_mode=error --config=x86_64-linux-autosd10 -- //:language_and_standards_tests //:feature_verification_tests + bazel build --lockfile_mode=error --config=x86_64-linux-autosd10 --features=-default_link_flags -- //:language_and_standards_tests //:feature_verification_tests - name: Guardrail (no legacy features) run: | - bazel test --lockfile_mode=error --config=x86_64-linux-autosd10 -- //:guardrail_tests + bazel test --lockfile_mode=error --config=x86_64-linux-autosd10 --features=-default_link_flags -- //:guardrail_tests diff --git a/docs/features.md b/docs/features.md index 486880e..bb20348 100644 --- a/docs/features.md +++ b/docs/features.md @@ -1,9 +1,7 @@ # 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). +These are the `cc_toolchain` features defined by the shared toolchain config in +[`templates/cc_toolchain_config.bzl.template`](../templates/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 diff --git a/docs/generation_flow.md b/docs/generation_flow.md index 2c6820e..d4ac19e 100644 --- a/docs/generation_flow.md +++ b/docs/generation_flow.md @@ -44,27 +44,18 @@ representation needed by the templates and repository rules. `rules/gcc.bzl` -Generates the toolchain repository. It decides whether Linux or QNX template -content is required, performs placeholder substitution, and emits the final -`BUILD`, `cc_toolchain_config.bzl`, `flags.bzl`, and Linux `gcov` wrapper -files. +Generates the toolchain repository. It performs placeholder substitution and +emits the final `BUILD`, `cc_toolchain_config.bzl`, and `gcov` wrapper files, +substituting OS-specific values (e.g. `compiler`, `abi_version`, +`toolchain_identifier`) into the shared templates below. ## Template Families -Linux templates: - -- `templates/linux/cc_toolchain_config.bzl.template` -- `templates/linux/cc_toolchain_flags.bzl.template` -- `templates/linux/cc_gcov_wrapper.template` - -QNX templates: - -- `templates/qnx/cc_toolchain_config.bzl.template` -- `templates/qnx/cc_toolchain_flags.bzl.template` - -Shared template: +Shared templates (used by both Linux and QNX): +- `templates/cc_toolchain_config.bzl.template` - `templates/BUILD.template` +- `templates/cc_gcov_wrapper.template` ## Important Implementation Details diff --git a/docs/maintenance.md b/docs/maintenance.md index 2a91f65..8cb4a9b 100644 --- a/docs/maintenance.md +++ b/docs/maintenance.md @@ -73,6 +73,66 @@ means a broken build rather than a silent fallback. > libraries (e.g. AutoSD) cannot link fully static binaries, so that feature is > opt-in and its test is marked incompatible with such platforms. +## In-Progress: Declarative `features/` Catalog + +`features/` defines the same toolchain features declaratively with +`@rules_cc//cc/toolchains` (`cc_feature` / `cc_args` / `cc_feature_set`), as a +parallel catalog alongside the legacy `feature()` Starlark in +`templates/cc_toolchain_config.bzl.template`. The **real** toolchain +generation still goes exclusively through the legacy template, rendered by +`rules/gcc.bzl`; nothing in the repository currently consumes +`//features:linux_features` or `//features:qnx_features`. + +`features/BUILD` defines two ordered `cc_feature_set` targets, `linux_features` +and `qnx_features`, whose `all_of` order intentionally mirrors the exact +feature order in the corresponding template's `features = [...]` list (order is +significant there — see the "order of the features is relevant" comment in both +templates). Platform membership (Linux-only vs. QNX-only vs. both) is expressed +purely by which set a feature is listed in; individual `cc_feature` targets no +longer carry `requires_any_of = ["//features/linux_platform"]` / +`["//features/qnx_platform"]` gates. `all_wall_warnings`, `minimal_warnings`, +`strict_warnings`, and `warnings_as_errors` were removed from `features/` +entirely — they are superseded by `score_cpp_policies` and injected via +`extra_known_features` / `extra_enabled_features` instead. + +### Open problem: the `extra_*_flags` hooks + +`extra_compile_flags`, `extra_c_compile_flags`, `extra_cxx_compile_flags`, and +`extra_link_flags` are intentionally **not** part of `linux_features` / +`qnx_features` yet. They don't fit the static-label model the rest of +`features/` uses: + +- **Content is dynamic per toolchain instance.** The flag lists come from + `gcc.toolchain(extra_compile_flags = [...])` (see `extensions/gcc.bzl`) and + are substituted via `%{...}` placeholders directly into the generated + `cc_toolchain_config.bzl` by `rules/gcc.bzl` (`_impl`, `get_flag_groups()`) — + not a fixed BUILD label a `cc_feature_set` could reference. +- **Position is order-sensitive.** `extra_compile_flags` / + `extra_c_compile_flags` / `extra_cxx_compile_flags` must land after + `preprocessor_defines` / `default_compile_flags` and before + `user_compile_flags`; `extra_link_flags` must land near the end, after + `user_link_flags`. The existing `extra_known_features` / + `extra_enabled_features` injection mechanism (used for `score_cpp_policies` + sanitizers/warnings) always appends via `features.extend(...)` at the very + end of the list — safe for position-independent features, unsafe for these. + +Options considered, decision still pending: + +1. **Leave as-is.** Keep the raw `%{...}` template-substitution mechanism + exactly as today; a static label structurally can't hold per-invocation + dynamic content, so these 4 simply stay outside the `features/` catalog. + Zero risk, matches current shipped behavior. +2. **Label-typed "slots".** Add label attributes (e.g. + `extra_compile_flags_target = attr.label(providers = [CcArgsInfo])`) to the + toolchain config rule. The caller defines their own small `cc_args`/ + `cc_feature` target with whatever flags they want and passes its label in; + the rule splices that label into the fixed position within the ordered + feature list — same trick as `extra_known_features`, but inserted at an + index instead of appended at the end. Preserves both order (repo controls + position) and dynamism (caller controls content). This is a real API change + touching `extensions/gcc.bzl` attrs, `rules/gcc.bzl` codegen, and + `docs/extension_api.md`. + ## Common Gotchas - runtime-specific toolchains may need extra include and link flags that do not diff --git a/docs/migration_guide.md b/docs/migration_guide.md index 17e40ef..d2d1ec1 100644 --- a/docs/migration_guide.md +++ b/docs/migration_guide.md @@ -65,9 +65,7 @@ no_legacy_features_feature = feature(name = "no_legacy_features", enabled = True With this enabled, Bazel injects **nothing** implicitly. Every compile, link, and archive flag must come from a feature (or other toolchain wiring) declared explicitly in -[`templates/linux/cc_toolchain_config.bzl.template`](../templates/linux/cc_toolchain_config.bzl.template) -or -[`templates/qnx/cc_toolchain_config.bzl.template`](../templates/qnx/cc_toolchain_config.bzl.template). +[`templates/cc_toolchain_config.bzl.template`](../templates/cc_toolchain_config.bzl.template). The practical consequence: the command line is now fully described by this repository's feature set. What you see documented in diff --git a/extensions/gcc.bzl b/extensions/gcc.bzl index ae8b330..06e64b9 100644 --- a/extensions/gcc.bzl +++ b/extensions/gcc.bzl @@ -203,8 +203,7 @@ def _get_toolchains(tags): toolchains = [] for tag in tags: toolchain = { - "cc_toolchain_config": "@score_bazel_cpp_toolchains//templates/{}:cc_toolchain_config.bzl.template".format(tag.target_os), - "cc_toolchain_flags": "@score_bazel_cpp_toolchains//templates/{}:cc_toolchain_flags.bzl.template".format(tag.target_os), + "cc_toolchain_config": "@score_bazel_cpp_toolchains//templates:cc_toolchain_config.bzl.template", "gcc_version": tag.version, "name": tag.name, "use_base_constraints_only": tag.use_base_constraints_only, @@ -416,7 +415,6 @@ def _impl(mctx): tc_runtime_ecosystem = toolchain_info["tc_runtime_ecosystem"], gcc_version = toolchain_info["gcc_version"], cc_toolchain_config = toolchain_info["cc_toolchain_config"], - cc_toolchain_flags = toolchain_info["cc_toolchain_flags"], use_base_constraints_only = toolchain_info["use_base_constraints_only"], ) diff --git a/features/BUILD b/features/BUILD new file mode 100644 index 0000000..7863c58 --- /dev/null +++ b/features/BUILD @@ -0,0 +1,99 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature_set.bzl", "cc_feature_set") + +# Order mirrors templates/cc_toolchain_config.bzl.template's `features = [...]` list, +# since feature order determines command-line flag order. +cc_feature_set( + name = "linux", + all_of = [ + "//features/native/markers:no_legacy_features", + "//features/native/compiler_library_search_paths", + "//features/native/markers:dbg", + "//features/native/unfiltered_compile_flags", + "//features/native/markers:gnu11", + "//features/native/default_compile_flags", + "//features/native/random_seed", + "//features/native/include_paths", + "//features/native/preprocessor_defines", + "//features/native/user_compile_flags", + "//features/native/compiler_input_flags", + "//features/native/compiler_output_flags", + "//features/native/dependency_file", + "//features/native/per_object_debug_info", + "//features/native/includes", + "//features/native/default_link_flags", + "//features/native/archiver_flags", + "//features/native/linker_param_file", + "//features/native/library_search_directories", + "//features/native/shared_flag", + "//features/native/output_execpath_flags", + "//features/native/runtime_library_search_directories", + "//features/native/libraries_to_link", + "//features/native/user_link_flags", + "//features/native/linkstamps", + "//features/native/fission_support", + "//features/native/force_pic_flags", + "//features/native/strip_debug_symbols", + "//features/native/static_libgcc", + "//features/native/fully_static_link", + "//features/native/sysroot_link_flags", + "//features/native/use_pthread", + "//features/native/markers:opt", + "//features/native/markers:supports_dynamic_linker", + "//features/native/markers:supports_pic", + "//features/native/pic", + "//features/native/markers:supports_header_path_normalization", + "//features/native/markers:supports_fission", + "//features/native/markers:coverage", + "//features/native/gcc_coverage_map_format", + ], + visibility = ["//visibility:public"], +) + +# Order mirrors templates/cc_toolchain_config.bzl.template's `features = [...]` list, +# since feature order determines command-line flag order. +cc_feature_set( + name = "qnx", + all_of = [ + "//features/native/markers:dbg", + "//features/native/markers:no_legacy_features", + "//features/native/unfiltered_compile_flags", + "//features/native/default_compile_flags", + "//features/native/random_seed", + "//features/native/include_paths", + "//features/native/preprocessor_defines", + "//features/native/user_compile_flags", + "//features/native/compiler_input_flags", + "//features/native/compiler_output_flags", + "//features/native/markers:dependency_file_named_implicitly", + "//features/native/dependency_file", + "//features/native/default_link_flags", + "//features/native/archiver_flags", + "//features/native/linker_param_file", + "//features/native/library_search_directories", + "//features/native/shared_flag", + "//features/native/output_execpath_flags", + "//features/native/libraries_to_link", + "//features/native/user_link_flags", + "//features/native/markers:coverage", + "//features/native/markers:opt", + "//features/native/markers:supports_dynamic_linker", + "//features/native/markers:supports_pic", + "//features/native/pic", + "//features/native/runtime_library_search_directories", + "//features/native/gcc_coverage_map_format", + ], + visibility = ["//visibility:public"], +) diff --git a/features/custom/linux/BUILD b/features/custom/linux/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/features/custom/linux/make_cc_features.bzl b/features/custom/linux/make_cc_features.bzl new file mode 100644 index 0000000..6e64324 --- /dev/null +++ b/features/custom/linux/make_cc_features.bzl @@ -0,0 +1,75 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +_LINUX_FEATURES = [ + ("@score_bazel_cpp_toolchains//features/native/markers:no_legacy_features", True), + (":compiler_library_search_paths", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/markers:dbg", False), # Bazel auto-toggles via -c dbg + ("@score_bazel_cpp_toolchains//features/native/unfiltered_compile_flags", True), + ("@score_bazel_cpp_toolchains//features/native/markers:gnu11", False), # opt-in + ("@score_bazel_cpp_toolchains//features/native/default_compile_flags", True), + ("@score_bazel_cpp_toolchains//features/native/random_seed", True), + ("@score_bazel_cpp_toolchains//features/native/include_paths", True), + ("@score_bazel_cpp_toolchains//features/native/preprocessor_defines", True), + (":extra_compile_flags", True), # per-instance, see templates/BUILD.template + (":extra_c_compile_flags", True), # per-instance, see templates/BUILD.template + (":extra_cxx_compile_flags", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/user_compile_flags", True), + ("@score_bazel_cpp_toolchains//features/native/compiler_input_flags", True), + ("@score_bazel_cpp_toolchains//features/native/compiler_output_flags", True), + ("@score_bazel_cpp_toolchains//features/native/dependency_file", True), + ("@score_bazel_cpp_toolchains//features/native/per_object_debug_info", True), + ("@score_bazel_cpp_toolchains//features/native/includes", True), + ("@score_bazel_cpp_toolchains//features/native/default_link_flags", True), + ("@score_bazel_cpp_toolchains//features/native/archiver_flags", True), + ("@score_bazel_cpp_toolchains//features/native/linker_param_file", True), + ("@score_bazel_cpp_toolchains//features/native/library_search_directories", True), + ("@score_bazel_cpp_toolchains//features/native/shared_flag", True), + ("@score_bazel_cpp_toolchains//features/native/output_execpath_flags", True), + ("@score_bazel_cpp_toolchains//features/native/runtime_library_search_directories", True), + ("@score_bazel_cpp_toolchains//features/native/libraries_to_link", True), + ("@score_bazel_cpp_toolchains//features/native/user_link_flags", True), + (":extra_link_flags", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/linkstamps", True), + ("@score_bazel_cpp_toolchains//features/native/fission_support", True), + ("@score_bazel_cpp_toolchains//features/native/force_pic_flags", True), + ("@score_bazel_cpp_toolchains//features/native/strip_debug_symbols", True), + ("@score_bazel_cpp_toolchains//features/native/static_libgcc", True), + ("@score_bazel_cpp_toolchains//features/native/fully_static_link", False), # opt-in + (":sysroot_link_flags", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/use_pthread", True), + ("@score_bazel_cpp_toolchains//features/native/markers:opt", False), # Bazel auto-toggles via -c opt + ("@score_bazel_cpp_toolchains//features/native/markers:supports_dynamic_linker", True), + ("@score_bazel_cpp_toolchains//features/native/markers:supports_pic", True), + ("@score_bazel_cpp_toolchains//features/native/pic", True), + ("@score_bazel_cpp_toolchains//features/native/markers:supports_header_path_normalization", True), + ("@score_bazel_cpp_toolchains//features/native/markers:supports_fission", True), + ("@score_bazel_cpp_toolchains//features/native/markers:coverage", False), # opt-in + ("@score_bazel_cpp_toolchains//features/native/gcc_coverage_map_format", False), # opt-in (+ requires "coverage") +] + +def linux_known_features(): + """Full ordered list of Linux feature labels — order drives flag order.""" + return [label for label, _enabled in _LINUX_FEATURES] + +def linux_enabled_features(): + """Subset of Linux feature labels that start enabled — order is irrelevant here.""" + return [label for label, enabled in _LINUX_FEATURES if enabled] + +def get_feature_lists(): + """Returns the flat known/enabled feature label lists for Linux. + + Returns: + (known_features, enabled_features) tuple of flat label lists. + """ + return linux_known_features(), linux_enabled_features() diff --git a/features/custom/qnx/BUILD b/features/custom/qnx/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/features/custom/qnx/gcc_version_flags/BUILD b/features/custom/qnx/gcc_version_flags/BUILD new file mode 100644 index 0000000..6e049e2 --- /dev/null +++ b/features/custom/qnx/gcc_version_flags/BUILD @@ -0,0 +1,43 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "qnx_gcc_version_compile_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = select({ + "@score_bazel_platforms//settings:aarch64-qnx8": ["-V12.2.0,gcc_ntoaarch64le"], + "@score_bazel_platforms//settings:x86_64-qnx8": ["-V12.2.0,gcc_ntox86_64"], + }), +) + +cc_args( + name = "qnx_gcc_version_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = select({ + "@score_bazel_platforms//settings:aarch64-qnx8": ["-V12.2.0,gcc_ntoaarch64le_cxx"], + "@score_bazel_platforms//settings:x86_64-qnx8": ["-V12.2.0,gcc_ntox86_64_cxx"], + }), +) + +cc_feature( + name = "gcc_version_flags", + args = [ + ":qnx_gcc_version_compile_args", + ":qnx_gcc_version_link_args", + ], + feature_name = "gcc_version_flags", + visibility = ["//visibility:public"], +) diff --git a/features/custom/qnx/make_cc_features.bzl b/features/custom/qnx/make_cc_features.bzl new file mode 100644 index 0000000..3f5196f --- /dev/null +++ b/features/custom/qnx/make_cc_features.bzl @@ -0,0 +1,86 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +def compute_feature_lists(target_os): + """Returns the flat known/enabled feature label lists for target_os. + + Unlike cc_feature_set (which groups features for requires_any_of/requires_all_of + constraints and does not itself provide FeatureInfo), cc_toolchain_config's + known_features/enabled_features attrs require every entry to individually + provide FeatureInfo — so this returns plain lists of cc_feature labels rather + than a single grouping target. + + Per-instance features (extra_compile_flags, extra_c_compile_flags, + extra_cxx_compile_flags, extra_link_flags, sysroot_link_flags, + compiler_library_search_paths) are baked into _LINUX_FEATURES/_QNX_FEATURES + directly since their target names never change across toolchain instances — + see templates/BUILD.template for where those targets get created. + + Args: + target_os: "linux" or "qnx". + + Returns: + (known_features, enabled_features) tuple of flat label lists. + """ + +_QNX_FEATURES = [ + ("@score_bazel_cpp_toolchains//features/native/markers:dbg", False), # Bazel auto-toggles via -c dbg + ("@score_bazel_cpp_toolchains//features/native/markers:no_legacy_features", True), + ("@score_bazel_cpp_toolchains//features/native/unfiltered_compile_flags", True), + ("@score_bazel_cpp_toolchains//features/custom/qnx/gcc_version_flags", True), + ("@score_bazel_cpp_toolchains//features/native/default_compile_flags", True), + ("@score_bazel_cpp_toolchains//features/native/random_seed", True), + ("@score_bazel_cpp_toolchains//features/native/include_paths", True), + ("@score_bazel_cpp_toolchains//features/native/preprocessor_defines", True), + (":extra_compile_flags", True), # per-instance, see templates/BUILD.template + (":extra_c_compile_flags", True), # per-instance, see templates/BUILD.template + (":extra_cxx_compile_flags", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/user_compile_flags", True), + ("@score_bazel_cpp_toolchains//features/native/compiler_input_flags", True), + ("@score_bazel_cpp_toolchains//features/native/compiler_output_flags", True), + ("@score_bazel_cpp_toolchains//features/native/markers:dependency_file_named_implicitly", False), + ("@score_bazel_cpp_toolchains//features/native/dependency_file", True), + ("@score_bazel_cpp_toolchains//features/native/default_link_flags", True), + ("@score_bazel_cpp_toolchains//features/native/archiver_flags", True), + ("@score_bazel_cpp_toolchains//features/native/linker_param_file", True), + ("@score_bazel_cpp_toolchains//features/native/library_search_directories", True), + ("@score_bazel_cpp_toolchains//features/native/shared_flag", True), + ("@score_bazel_cpp_toolchains//features/native/output_execpath_flags", True), + ("@score_bazel_cpp_toolchains//features/native/libraries_to_link", True), + ("@score_bazel_cpp_toolchains//features/native/user_link_flags", True), + (":extra_link_flags", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/markers:coverage", False), # opt-in + ("@score_bazel_cpp_toolchains//features/native/markers:opt", False), # Bazel auto-toggles via -c opt + (":sdp_env", True), # per-instance, see templates/BUILD.template + ("@score_bazel_cpp_toolchains//features/native/markers:supports_dynamic_linker", True), + ("@score_bazel_cpp_toolchains//features/native/markers:supports_pic", True), + ("@score_bazel_cpp_toolchains//features/native/pic", True), + ("@score_bazel_cpp_toolchains//features/native/runtime_library_search_directories", True), + ("@score_bazel_cpp_toolchains//features/native/gcc_coverage_map_format", False), # opt-in +] + +def qnx_known_features(): + """Full ordered list of QNX feature labels — order drives flag order.""" + return [label for label, _enabled in _QNX_FEATURES] + +def qnx_enabled_features(): + """Subset of QNX feature labels that start enabled — order is irrelevant here.""" + return [label for label, enabled in _QNX_FEATURES if enabled] + +def get_feature_lists(): + """Returns the flat known/enabled feature label lists for QNX. + + Returns: + (known_features, enabled_features) tuple of flat label lists. + """ + return qnx_known_features(), qnx_enabled_features() diff --git a/features/custom/qnx/sdp_env/BUILD b/features/custom/qnx/sdp_env/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/features/custom/qnx/sdp_env/feature.bzl b/features/custom/qnx/sdp_env/feature.bzl new file mode 100644 index 0000000..dcdd34b --- /dev/null +++ b/features/custom/qnx/sdp_env/feature.bzl @@ -0,0 +1,63 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +_ACTIONS = [ + "@rules_cc//cc/toolchains/actions:compile_actions", + "@rules_cc//cc/toolchains/actions:link_actions", +] + +def make_sdp_env_feature( + host_dir, + target_dir, + license_path, + license_info_variable, + license_info_value): + """Creates a feature for the sdp_env toolchain. + + Args: + host_dir: str, resolved path to the SDP host directory. + target_dir: str, resolved path to the SDP target directory. + license_path: str, path to the license file. + license_info_variable: str, name of an extra license env var, "" if none. + license_info_value: str, value of that extra license env var, "" if none. + + Returns: + A feature definition for the sdp_env toolchain. + """ + + # cc_args' `env` has no mechanism to resolve labels/format custom + # placeholders (see validate_env_variables in rules_cc) -- host_dir/ + # target_dir must already be plain resolved path strings. + env = { + "QNX_HOST": host_dir, + "QNX_TARGET": target_dir, + "QNX_CONFIGURATION_EXCLUSIVE": "/var/tmp/.qnx", + "QNX_SHARED_LICENSE_FILE": license_path, + } + if license_info_value: + env[license_info_variable] = license_info_value + + cc_args( + name = "sdp_env_args", + actions = _ACTIONS, + env = env, + ) + + cc_feature( + name = "sdp_env", + feature_name = "sdp_env", + args = [":sdp_env_args"], + ) diff --git a/features/make_cc_features.bzl b/features/make_cc_features.bzl new file mode 100644 index 0000000..2fabe32 --- /dev/null +++ b/features/make_cc_features.bzl @@ -0,0 +1,27 @@ +def compute_feature_lists(target_os): + """Returns the flat known/enabled feature label lists for target_os. + + Unlike cc_feature_set (which groups features for requires_any_of/requires_all_of + constraints and does not itself provide FeatureInfo), cc_toolchain_config's + known_features/enabled_features attrs require every entry to individually + provide FeatureInfo — so this returns plain lists of cc_feature labels rather + than a single grouping target. + + Per-instance features (extra_compile_flags, extra_c_compile_flags, + extra_cxx_compile_flags, extra_link_flags, sysroot_link_flags, + compiler_library_search_paths) are baked into _LINUX_FEATURES/_QNX_FEATURES + directly since their target names never change across toolchain instances — + see templates/BUILD.template for where those targets get created. + + Args: + target_os: "linux" or "qnx". + + Returns: + (known_features, enabled_features) tuple of flat label lists. + """ + if target_os == "linux": + return linux_known_features(), linux_enabled_features() + elif target_os == "qnx": + return qnx_known_features(), qnx_enabled_features() + else: + fail("Unsupported target_os '{}', expected 'linux' or 'qnx'".format(target_os)) diff --git a/features/native/archiver_flags/BUILD b/features/native/archiver_flags/BUILD new file mode 100644 index 0000000..030860d --- /dev/null +++ b/features/native/archiver_flags/BUILD @@ -0,0 +1,77 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:nested_args.bzl", "cc_nested_args") + +cc_args( + name = "archiver_static_flag_args", + actions = ["@rules_cc//cc/toolchains/actions:ar_actions"], + args = ["rcsD"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "archiver_output_execpath_args", + actions = ["@rules_cc//cc/toolchains/actions:ar_actions"], + args = ["{output_execpath}"], + format = {"output_execpath": "@rules_cc//cc/toolchains/variables:output_execpath"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_execpath", + visibility = ["//visibility:public"], +) + +cc_nested_args( + name = "archiver_object_file_entry", + args = ["{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file", +) + +cc_nested_args( + name = "archiver_object_file_group_entry", + args = ["{object_file}"], + format = {"object_file": "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files"}, + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files", + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file_group", +) + +cc_nested_args( + name = "archiver_iterate_libraries", + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link", + nested = [ + ":archiver_object_file_entry", + ":archiver_object_file_group_entry", + ], +) + +cc_args( + name = "archiver_libraries_args", + actions = ["@rules_cc//cc/toolchains/actions:ar_actions"], + nested = [":archiver_iterate_libraries"], + requires_not_none = "@rules_cc//cc/toolchains/variables:libraries_to_link", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "archiver_flags", + args = [ + ":archiver_static_flag_args", + ":archiver_output_execpath_args", + ":archiver_libraries_args", + ], + feature_name = "archiver_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/compiler_input_flags/BUILD b/features/native/compiler_input_flags/BUILD new file mode 100644 index 0000000..01612f2 --- /dev/null +++ b/features/native/compiler_input_flags/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "compiler_input_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-c", + "{source_file}", + ], + format = {"source_file": "@rules_cc//cc/toolchains/variables:source_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:source_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "compiler_input_flags", + args = [":compiler_input_flags_args"], + feature_name = "compiler_input_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/compiler_library_search_paths/BUILD b/features/native/compiler_library_search_paths/BUILD new file mode 100644 index 0000000..269fe76 --- /dev/null +++ b/features/native/compiler_library_search_paths/BUILD @@ -0,0 +1,29 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +# Instantiated per-toolchain via make_compiler_library_search_paths() in +# features.bzl, since each toolchain has different search paths — see +# templates/BUILD.template. diff --git a/features/native/compiler_library_search_paths/features.bzl b/features/native/compiler_library_search_paths/features.bzl new file mode 100644 index 0000000..3cfb0aa --- /dev/null +++ b/features/native/compiler_library_search_paths/features.bzl @@ -0,0 +1,45 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +_ALL_ACTIONS = [ + "@rules_cc//cc/toolchains/actions:compile_actions", + "@rules_cc//cc/toolchains/actions:link_actions", + "@rules_cc//cc/toolchains/actions:strip", + "@rules_cc//cc/toolchains/actions:ar_actions", +] + +def make_compiler_library_search_paths(compiler_library_search_paths): + """Creates the compiler_library_search_paths feature. + + Sets LD_LIBRARY_PATH for every toolchain action (compile, link, archive, + strip) so the compiler/linker/ar/strip binaries themselves can find their + own runtime shared libraries. This is unrelated to the artifacts being + built, so it's an env var applied to all actions, not a linker flag. + + Args: + compiler_library_search_paths: colon-joined path string, "" if none. + """ + cc_args( + name = "compiler_library_search_paths_args", + actions = _ALL_ACTIONS, + env = {"LD_LIBRARY_PATH": compiler_library_search_paths} if compiler_library_search_paths else {}, + ) + + cc_feature( + name = "compiler_library_search_paths", + args = [":compiler_library_search_paths_args"], + feature_name = "compiler_library_search_paths", + ) diff --git a/features/native/compiler_output_flags/BUILD b/features/native/compiler_output_flags/BUILD new file mode 100644 index 0000000..3adc126 --- /dev/null +++ b/features/native/compiler_output_flags/BUILD @@ -0,0 +1,54 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "output_assembly_file_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = ["-S"], + requires_not_none = "@rules_cc//cc/toolchains/variables:output_assembly_file", + visibility = ["//visibility:public"], +) + +cc_args( + name = "output_preprocess_file_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = ["-E"], + requires_not_none = "@rules_cc//cc/toolchains/variables:output_preprocess_file", + visibility = ["//visibility:public"], +) + +cc_args( + name = "output_file_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-o", + "{output_file}", + ], + format = {"output_file": "@rules_cc//cc/toolchains/variables:output_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "compiler_output_flags", + args = [ + ":output_assembly_file_args", + ":output_preprocess_file_args", + ":output_file_args", + ], + feature_name = "compiler_output_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/default_compile_flags/BUILD b/features/native/default_compile_flags/BUILD new file mode 100644 index 0000000..45c0eb2 --- /dev/null +++ b/features/native/default_compile_flags/BUILD @@ -0,0 +1,161 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +cc_args( + name = "default_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = select( + { + "@platforms//os:linux": [ + "-U_FORTIFY_SOURCE", + "-D_XOPEN_SOURCE=700", + "-fstack-protector", + "-fdiagnostics-color=always", + "-fno-omit-frame-pointer", + "-ffunction-sections", + "-fdata-sections", + "-fno-canonical-system-headers", + "-no-canonical-prefixes", + "-z noexecstack", + ], + "@platforms//os:qnx": [ + "-fno-canonical-system-headers", + ], + "//conditions:default": [], + }, + ), +) + +# x86_64 requires -m64; other architectures need no CPU flags here +cc_args( + name = "target_cpu_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = select({ + "@platforms//cpu:x86_64": ["-m64"], + "//conditions:default": [], + }), + visibility = ["//visibility:public"], +) + +cc_feature_constraint( + name = "not_gnu11", + none_of = ["//features/native/markers:gnu11"], +) + +cc_feature_constraint( + name = "is_gnu11", + all_of = ["//features/native/markers:gnu11"], +) + +cc_args( + name = "c_std_c11_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = ["-std=c11"], + requires_any_of = [":not_gnu11"], +) + +cc_args( + name = "c_std_gnu11_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = ["-std=gnu11"], + requires_any_of = [":is_gnu11"], +) + +cc_args( + name = "default_cxx_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"], + args = ["-std=c++17"] + + select({ + "@platforms//os:qnx": [ + "-D_QNX_SOURCE", + ], + "//conditions:default": [], + }), +) + +cc_feature_constraint( + name = "is_dbg", + all_of = ["//features/native/markers:dbg"], +) + +cc_args( + name = "dbg_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-Og", + "-g3", + ], + requires_any_of = [":is_dbg"], +) + +cc_feature_constraint( + name = "is_opt", + all_of = ["//features/native/markers:opt"], +) + +cc_feature_constraint( + name = "is_fastbuild", + all_of = ["//features/native/markers:fastbuild"], +) + +cc_args( + name = "opt_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-O2", + "-DNDEBUG", + ], + requires_any_of = [ + ":is_opt", + ":is_fastbuild", + ], +) + +cc_args( + name = "gcc_compile_flag_version_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = select({ + "@score_bazel_platform//settings:aarch64-qnx8": [ + "-V{version},gcc_nto{cpu}".format( + cpu = "aarch64le", + version = "12.2.0", + ), + ], + "@score_bazel_platform//settings:x86_64-qnx8": [ + "-V{version},gcc_nto{cpu}".format( + cpu = "x86_64", + version = "12.2.0", + ), + ], + "//conditions:default": [], + }), +) + +cc_feature( + name = "default_compile_flags", + args = [ + ":default_compile_flags_args", + ":target_cpu_flags_args", + ":c_std_c11_args", + ":c_std_gnu11_args", + ":default_cxx_compile_flags_args", + ":dbg_compile_flags_args", + ":opt_compile_flags_args", + ], + feature_name = "default_compile_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/default_link_flags/BUILD b/features/native/default_link_flags/BUILD new file mode 100644 index 0000000..f586f61 --- /dev/null +++ b/features/native/default_link_flags/BUILD @@ -0,0 +1,90 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +cc_feature_constraint( + name = "is_opt", + all_of = ["//features/native/markers:opt"], +) + +# compress-debug only when neither opt nor fastbuild +cc_feature_constraint( + name = "not_opt_not_fastbuild", + none_of = [ + "//features/native/markers:opt", + "//features/native/markers:fastbuild", + ], +) + +# Linux base link flags +cc_args( + name = "linux_base_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = [ + "-lm", + "-ldl", + "-lrt", + "-static-libstdc++", + "-static-libgcc", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_opt_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--gc-sections"], + requires_any_of = [":is_opt"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_debug_compress_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--compress-debug-sections=zlib"], + requires_any_of = [":not_opt_not_fastbuild"], + visibility = ["//visibility:public"], +) + +# QNX static link flags (the -V routing flag stays in toolchain config template) +cc_args( + name = "qnx_base_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = [ + "-Wl,-z,relro", + "-Wl,-z,now", + "-Wl,--push-state", + "-Wl,--as-needed", + "-lc++", + "-lm", + "-Wl,--pop-state", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "default_link_flags", + args = select({ + "@platforms//os:linux": [ + ":linux_base_link_args", + ":linux_opt_link_args", + ":linux_debug_compress_link_args", + ], + "@platforms//os:qnx": [":qnx_base_link_args"], + }), + feature_name = "default_link_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/dependency_file/BUILD b/features/native/dependency_file/BUILD new file mode 100644 index 0000000..5abf755 --- /dev/null +++ b/features/native/dependency_file/BUILD @@ -0,0 +1,88 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +_COMPILE_ACTIONS = [ + "@rules_cc//cc/toolchains/actions:assemble", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + "@rules_cc//cc/toolchains/actions:cpp_header_parsing", +] + +# Linux: standard -MD -MF flags +cc_args( + name = "dependency_file_linux_args", + actions = _COMPILE_ACTIONS, + args = [ + "-MD", + "-MF", + "{dependency_file}", + ], + format = {"dependency_file": "@rules_cc//cc/toolchains/variables:dependency_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:dependency_file", + visibility = ["//visibility:public"], +) + +# QNX: QCC-wrapped flags — explicit filename (dependency_file_named_implicitly is NOT active) +cc_feature_constraint( + name = "not_dep_named_implicitly", + none_of = ["//features/native/markers:dependency_file_named_implicitly"], +) + +cc_args( + name = "dependency_file_qnx_explicit_args", + actions = _COMPILE_ACTIONS, + args = [ + "-Wc,-MD,{dependency_file}", + "-Wp,-MD,{dependency_file}", + ], + format = {"dependency_file": "@rules_cc//cc/toolchains/variables:dependency_file"}, + requires_any_of = [":not_dep_named_implicitly"], + requires_not_none = "@rules_cc//cc/toolchains/variables:dependency_file", + visibility = ["//visibility:public"], +) + +# QNX: QCC-wrapped flags — implicit filename (dependency_file_named_implicitly IS active) +cc_feature_constraint( + name = "is_dep_named_implicitly", + all_of = ["//features/native/markers:dependency_file_named_implicitly"], +) + +cc_args( + name = "dependency_file_qnx_implicit_args", + actions = _COMPILE_ACTIONS, + args = [ + "-Wc,-MD", + "-Wp,-MD", + ], + requires_any_of = [":is_dep_named_implicitly"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "dependency_file", + args = select({ + "@platforms//os:linux": [":dependency_file_linux_args"], + "@platforms//os:qnx": [ + ":dependency_file_qnx_explicit_args", + ":dependency_file_qnx_implicit_args", + ], + }), + feature_name = "dependency_file", + visibility = ["//visibility:public"], +) diff --git a/features/native/extra_compile_flags/BUILD b/features/native/extra_compile_flags/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/features/native/extra_compile_flags/features.bzl b/features/native/extra_compile_flags/features.bzl new file mode 100644 index 0000000..6458017 --- /dev/null +++ b/features/native/extra_compile_flags/features.bzl @@ -0,0 +1,60 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +def make_extra_compile_features( + extra_compile_flags = None, + extra_c_compile_flags = None, + extra_cxx_compile_flags = None, +): + + cc_args( + name = "extra_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = extra_compile_flags, + ) + + cc_feature( + name = "extra_compile_flags", + args = [":extra_compile_flags_args"], + feature_name = "extra_compile_flags", + implies = ["@score_bazel_cpp_toolchains//features/native/default_compile_flags"], + ) + + cc_args( + name = "extra_c_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = extra_c_compile_flags, + ) + + cc_feature( + name = "extra_c_compile_flags", + args = [":extra_c_compile_flags_args"], + feature_name = "extra_c_compile_flags", + implies = ["@score_bazel_cpp_toolchains//features/native/default_compile_flags"], + ) + + cc_args( + name = "extra_cxx_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"], + args = extra_cxx_compile_flags, + ) + + cc_feature( + name = "extra_cxx_compile_flags", + args = [":extra_cxx_compile_flags_args"], + feature_name = "extra_cxx_compile_flags", + implies = ["@score_bazel_cpp_toolchains//features/native/default_compile_flags"], + ) \ No newline at end of file diff --git a/features/native/extra_link_flags/BUILD b/features/native/extra_link_flags/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/features/native/extra_link_flags/features.bzl b/features/native/extra_link_flags/features.bzl new file mode 100644 index 0000000..5e3e231 --- /dev/null +++ b/features/native/extra_link_flags/features.bzl @@ -0,0 +1,30 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +def make_extra_link_features( + extra_link_flags = None, +): + cc_args( + name = "extra_link_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = extra_link_flags, + ) + + cc_feature( + name = "extra_link_flags", + args = [":extra_link_flags_args"], + feature_name = "extra_link_flags", + ) \ No newline at end of file diff --git a/features/native/fission_support/BUILD b/features/native/fission_support/BUILD new file mode 100644 index 0000000..7e749dc --- /dev/null +++ b/features/native/fission_support/BUILD @@ -0,0 +1,30 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "fission_support_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--gdb-index"], + requires_not_none = "@rules_cc//cc/toolchains/variables:is_using_fission", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "fission_support", + args = [":fission_support_args"], + feature_name = "fission_support", + visibility = ["//visibility:public"], +) diff --git a/features/native/force_pic_flags/BUILD b/features/native/force_pic_flags/BUILD new file mode 100644 index 0000000..22c9f0d --- /dev/null +++ b/features/native/force_pic_flags/BUILD @@ -0,0 +1,30 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "force_pic_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_link_executable"], + args = ["-pie"], + requires_not_none = "@rules_cc//cc/toolchains/variables:force_pic", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "force_pic_flags", + args = [":force_pic_flags_args"], + feature_name = "force_pic_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/fully_static_link/BUILD b/features/native/fully_static_link/BUILD new file mode 100644 index 0000000..f128a0e --- /dev/null +++ b/features/native/fully_static_link/BUILD @@ -0,0 +1,33 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "fully_static_link_args", + actions = [ + "@rules_cc//cc/toolchains/actions:cpp_link_executable", + "@rules_cc//cc/toolchains/actions:cpp_link_dynamic_library", + "@rules_cc//cc/toolchains/actions:cpp_link_nodeps_dynamic_library", + ], + args = ["-static"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "fully_static_link", + args = [":fully_static_link_args"], + feature_name = "fully_static_link", + visibility = ["//visibility:public"], +) diff --git a/features/native/gcc_coverage_map_format/BUILD b/features/native/gcc_coverage_map_format/BUILD new file mode 100644 index 0000000..71816a7 --- /dev/null +++ b/features/native/gcc_coverage_map_format/BUILD @@ -0,0 +1,62 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_set.bzl", "cc_feature_set") + +cc_feature_set( + name = "requires_coverage", + all_of = ["//features/native/markers:coverage"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "coverage_compile_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + ], + args = [ + "-fprofile-arcs", + "-ftest-coverage", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_coverage_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["--coverage"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "qnx_coverage_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-lgcov"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "gcc_coverage_map_format", + args = [":coverage_compile_args"] + select({ + "@platforms//os:linux": [":linux_coverage_link_args"], + "@platforms//os:qnx": [":qnx_coverage_link_args"], + }), + feature_name = "gcc_coverage_map_format", + requires_any_of = [":requires_coverage"], + visibility = ["//visibility:public"], +) diff --git a/features/native/include_paths/BUILD b/features/native/include_paths/BUILD new file mode 100644 index 0000000..676bab8 --- /dev/null +++ b/features/native/include_paths/BUILD @@ -0,0 +1,59 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "quote_include_paths_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = [ + "-iquote", + "{quote_include_paths}", + ], + format = {"quote_include_paths": "@rules_cc//cc/toolchains/variables:quote_include_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:quote_include_paths", + visibility = ["//visibility:public"], +) + +cc_args( + name = "include_paths_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = ["-I{include_paths}"], + format = {"include_paths": "@rules_cc//cc/toolchains/variables:include_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:include_paths", + visibility = ["//visibility:public"], +) + +cc_args( + name = "system_include_paths_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = [ + "-isystem", + "{system_include_paths}", + ], + format = {"system_include_paths": "@rules_cc//cc/toolchains/variables:system_include_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:system_include_paths", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "include_paths", + args = [ + ":quote_include_paths_args", + ":include_paths_args", + ":system_include_paths_args", + ], + feature_name = "include_paths", + visibility = ["//visibility:public"], +) diff --git a/features/native/includes/BUILD b/features/native/includes/BUILD new file mode 100644 index 0000000..f0dc8dd --- /dev/null +++ b/features/native/includes/BUILD @@ -0,0 +1,35 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "includes_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = [ + "-include", + "{includes}", + ], + format = {"includes": "@rules_cc//cc/toolchains/variables:includes"}, + iterate_over = "@rules_cc//cc/toolchains/variables:includes", + requires_not_none = "@rules_cc//cc/toolchains/variables:includes", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "includes", + args = [":includes_args"], + feature_name = "includes", + visibility = ["//visibility:public"], +) diff --git a/features/native/libraries_to_link/BUILD b/features/native/libraries_to_link/BUILD new file mode 100644 index 0000000..09e96a5 --- /dev/null +++ b/features/native/libraries_to_link/BUILD @@ -0,0 +1,105 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:nested_args.bzl", "cc_nested_args") + +# static_library: dispatch on is_whole_archive +cc_nested_args( + name = "whole_archive_static_library", + args = [ + "-Wl,--whole-archive", + "{lib_name}", + "-Wl,--no-whole-archive", + ], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_true = "@rules_cc//cc/toolchains/variables:libraries_to_link.is_whole_archive", +) + +cc_nested_args( + name = "non_whole_archive_static_library", + args = ["{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_false = "@rules_cc//cc/toolchains/variables:libraries_to_link.is_whole_archive", +) + +cc_nested_args( + name = "static_library_dispatch", + nested = [ + ":whole_archive_static_library", + ":non_whole_archive_static_library", + ], + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "static_library", +) + +cc_nested_args( + name = "object_file_entry", + args = ["{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file", +) + +cc_nested_args( + name = "object_file_group_entry", + args = ["{object_file}"], + format = {"object_file": "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files"}, + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files", + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file_group", +) + +cc_nested_args( + name = "dynamic_library_entry", + args = ["-l{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "dynamic_library", +) + +cc_nested_args( + name = "versioned_dynamic_library_entry", + args = ["-l:{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "versioned_dynamic_library", +) + +cc_nested_args( + name = "iterate_libraries", + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link", + nested = [ + ":static_library_dispatch", + ":object_file_entry", + ":object_file_group_entry", + ":dynamic_library_entry", + ":versioned_dynamic_library_entry", + ], +) + +cc_args( + name = "libraries_to_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + nested = [":iterate_libraries"], + requires_not_none = "@rules_cc//cc/toolchains/variables:libraries_to_link", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "libraries_to_link", + args = [":libraries_to_link_args"], + feature_name = "libraries_to_link", + visibility = ["//visibility:public"], +) diff --git a/features/native/library_search_directories/BUILD b/features/native/library_search_directories/BUILD new file mode 100644 index 0000000..1f65428 --- /dev/null +++ b/features/native/library_search_directories/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "library_search_directories_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-L{library_search_directories}"], + format = {"library_search_directories": "@rules_cc//cc/toolchains/variables:library_search_directories"}, + iterate_over = "@rules_cc//cc/toolchains/variables:library_search_directories", + requires_not_none = "@rules_cc//cc/toolchains/variables:library_search_directories", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "library_search_directories", + args = [":library_search_directories_args"], + feature_name = "library_search_directories", + visibility = ["//visibility:public"], +) diff --git a/features/native/linker_param_file/BUILD b/features/native/linker_param_file/BUILD new file mode 100644 index 0000000..cc097bb --- /dev/null +++ b/features/native/linker_param_file/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linker_param_file_args", + actions = [ + "@rules_cc//cc/toolchains/actions:link_actions", + "@rules_cc//cc/toolchains/actions:ar_actions", + ], + args = ["@{linker_param_file}"], + format = {"linker_param_file": "@rules_cc//cc/toolchains/variables:linker_param_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:linker_param_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "linker_param_file", + args = [":linker_param_file_args"], + feature_name = "linker_param_file", + visibility = ["//visibility:public"], +) diff --git a/features/native/linkstamps/BUILD b/features/native/linkstamps/BUILD new file mode 100644 index 0000000..4dd5b32 --- /dev/null +++ b/features/native/linkstamps/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linkstamps_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["{linkstamp_paths}"], + format = {"linkstamp_paths": "@rules_cc//cc/toolchains/variables:linkstamp_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:linkstamp_paths", + requires_not_none = "@rules_cc//cc/toolchains/variables:linkstamp_paths", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "linkstamps", + args = [":linkstamps_args"], + feature_name = "linkstamps", + visibility = ["//visibility:public"], +) diff --git a/features/native/markers/BUILD b/features/native/markers/BUILD new file mode 100644 index 0000000..3f3f131 --- /dev/null +++ b/features/native/markers/BUILD @@ -0,0 +1,90 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +# Capability markers — enabled state is set at toolchain assembly, not here. +cc_feature( + name = "no_legacy_features", + feature_name = "no_legacy_features", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "supports_pic", + feature_name = "supports_pic", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "supports_dynamic_linker", + feature_name = "supports_dynamic_linker", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "dbg", + feature_name = "dbg", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "opt", + feature_name = "opt", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "fastbuild", + feature_name = "fastbuild", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "coverage", + feature_name = "coverage", + visibility = ["//visibility:public"], +) + +## Linux specficic +cc_feature( + name = "supports_fission", + feature_name = "supports_fission", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "supports_header_path_normalization", + feature_name = "supports_header_path_normalization", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "gnu11", + feature_name = "gnu11", + visibility = ["//visibility:public"], +) + +## QNX only +cc_feature( + name = "dependency_file_named_implicitly", + feature_name = "dependency_file_named_implicitly", + visibility = ["//visibility:public"], +) + +# Linked runtime control +cc_feature( + name = "static_link_cpp_runtimes", + feature_name = "static_link_cpp_runtimes", + visibility = ["//visibility:public"], +) diff --git a/features/native/output_execpath_flags/BUILD b/features/native/output_execpath_flags/BUILD new file mode 100644 index 0000000..e9cbcdb --- /dev/null +++ b/features/native/output_execpath_flags/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "output_execpath_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = [ + "-o", + "{output_execpath}", + ], + format = {"output_execpath": "@rules_cc//cc/toolchains/variables:output_execpath"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_execpath", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "output_execpath_flags", + args = [":output_execpath_flags_args"], + feature_name = "output_execpath_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/per_object_debug_info/BUILD b/features/native/per_object_debug_info/BUILD new file mode 100644 index 0000000..6e284d8 --- /dev/null +++ b/features/native/per_object_debug_info/BUILD @@ -0,0 +1,39 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "per_object_debug_info_args", + actions = [ + "@rules_cc//cc/toolchains/actions:assemble", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_codegen", + ], + args = [ + "-gsplit-dwarf", + "-g", + ], + requires_not_none = "@rules_cc//cc/toolchains/variables:per_object_debug_info_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "per_object_debug_info", + args = [":per_object_debug_info_args"], + feature_name = "per_object_debug_info", + visibility = ["//visibility:public"], +) diff --git a/features/native/pic/BUILD b/features/native/pic/BUILD new file mode 100644 index 0000000..5d0c864 --- /dev/null +++ b/features/native/pic/BUILD @@ -0,0 +1,37 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "pic_args", + actions = [ + "@rules_cc//cc/toolchains/actions:assemble", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_codegen", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + ], + args = ["-fPIC"], + requires_not_none = "@rules_cc//cc/toolchains/variables:pic", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "pic", + args = [":pic_args"], + feature_name = "pic", + visibility = ["//visibility:public"], +) diff --git a/features/native/preprocessor_defines/BUILD b/features/native/preprocessor_defines/BUILD new file mode 100644 index 0000000..b7bf963 --- /dev/null +++ b/features/native/preprocessor_defines/BUILD @@ -0,0 +1,31 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "preprocessor_defines_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = ["-D{preprocessor_defines}"], + format = {"preprocessor_defines": "@rules_cc//cc/toolchains/variables:preprocessor_defines"}, + iterate_over = "@rules_cc//cc/toolchains/variables:preprocessor_defines", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "preprocessor_defines", + args = [":preprocessor_defines_args"], + feature_name = "preprocessor_defines", + visibility = ["//visibility:public"], +) diff --git a/features/native/random_seed/BUILD b/features/native/random_seed/BUILD new file mode 100644 index 0000000..d0c33d1 --- /dev/null +++ b/features/native/random_seed/BUILD @@ -0,0 +1,36 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "random_seed_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_codegen", + ], + args = ["-frandom-seed={output_file}"], + format = {"output_file": "@rules_cc//cc/toolchains/variables:output_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "random_seed", + args = [":random_seed_args"], + feature_name = "random_seed", + visibility = ["//visibility:public"], +) diff --git a/features/native/runtime_library_search_directories/BUILD b/features/native/runtime_library_search_directories/BUILD new file mode 100644 index 0000000..5c248fd --- /dev/null +++ b/features/native/runtime_library_search_directories/BUILD @@ -0,0 +1,74 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:nested_args.bzl", "cc_nested_args") + +# Linux: fork rpath on is_cc_test +cc_nested_args( + name = "linux_rpath_test", + args = ["-Wl,-rpath,$ORIGIN/{dir}"], + format = {"dir": "@rules_cc//cc/toolchains/variables:runtime_library_search_directories"}, + requires_true = "@rules_cc//cc/toolchains/variables:is_cc_test", +) + +cc_nested_args( + name = "linux_rpath_exec", + args = ["-Wl,-rpath,$EXEC_ORIGIN/{dir}"], + format = {"dir": "@rules_cc//cc/toolchains/variables:runtime_library_search_directories"}, + requires_false = "@rules_cc//cc/toolchains/variables:is_cc_test", +) + +cc_nested_args( + name = "linux_rpath_iterate", + iterate_over = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", + nested = [ + ":linux_rpath_test", + ":linux_rpath_exec", + ], +) + +cc_args( + name = "runtime_dirs_linux_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + nested = [":linux_rpath_iterate"], + requires_not_none = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", + visibility = ["//visibility:public"], +) + +# QNX: always $EXEC_ORIGIN, QCC uses -Wl,-rpath +cc_nested_args( + name = "qnx_rpath_iterate", + args = ["-Wl,-rpath,$EXEC_ORIGIN/{dir}"], + format = {"dir": "@rules_cc//cc/toolchains/variables:runtime_library_search_directories"}, + iterate_over = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", +) + +cc_args( + name = "runtime_dirs_qnx_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + nested = [":qnx_rpath_iterate"], + requires_not_none = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "runtime_library_search_directories", + args = select({ + "@platforms//os:linux": [":runtime_dirs_linux_args"], + "@platforms//os:qnx": [":runtime_dirs_qnx_args"], + }), + feature_name = "runtime_library_search_directories", + visibility = ["//visibility:public"], +) diff --git a/features/native/shared_flag/BUILD b/features/native/shared_flag/BUILD new file mode 100644 index 0000000..8b5d30d --- /dev/null +++ b/features/native/shared_flag/BUILD @@ -0,0 +1,29 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "shared_flag_args", + actions = ["@rules_cc//cc/toolchains/actions:dynamic_library_link_actions"], + args = ["-shared"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "shared_flag", + args = [":shared_flag_args"], + feature_name = "shared_flag", + visibility = ["//visibility:public"], +) diff --git a/features/native/static_libgcc/BUILD b/features/native/static_libgcc/BUILD new file mode 100644 index 0000000..af35773 --- /dev/null +++ b/features/native/static_libgcc/BUILD @@ -0,0 +1,39 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +cc_feature_constraint( + name = "is_static_link_cpp_runtimes", + all_of = ["//features/native/markers:static_link_cpp_runtimes"], +) + +cc_args( + name = "static_libgcc_args", + actions = [ + "@rules_cc//cc/toolchains/actions:cpp_link_executable", + "@rules_cc//cc/toolchains/actions:cpp_link_dynamic_library", + ], + args = ["-static-libgcc"], + requires_any_of = [":is_static_link_cpp_runtimes"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "static_libgcc", + args = [":static_libgcc_args"], + feature_name = "static_libgcc", + visibility = ["//visibility:public"], +) diff --git a/features/native/strip_debug_symbols/BUILD b/features/native/strip_debug_symbols/BUILD new file mode 100644 index 0000000..6d5626f --- /dev/null +++ b/features/native/strip_debug_symbols/BUILD @@ -0,0 +1,30 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "strip_debug_symbols_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,-S"], + requires_not_none = "@rules_cc//cc/toolchains/variables:strip_debug_symbols", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "strip_debug_symbols", + args = [":strip_debug_symbols_args"], + feature_name = "strip_debug_symbols", + visibility = ["//visibility:public"], +) diff --git a/features/native/sysroot_link_flags/BUILD b/features/native/sysroot_link_flags/BUILD new file mode 100644 index 0000000..73b762d --- /dev/null +++ b/features/native/sysroot_link_flags/BUILD @@ -0,0 +1,15 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +# Instantiated per-toolchain via make_sysroot_link_flags() in features.bzl, since +# each toolchain has a different sysroot directory — see templates/BUILD.template. diff --git a/features/native/sysroot_link_flags/features.bzl b/features/native/sysroot_link_flags/features.bzl new file mode 100644 index 0000000..90fa0cf --- /dev/null +++ b/features/native/sysroot_link_flags/features.bzl @@ -0,0 +1,38 @@ +# ******************************************************************************* +# Copyright (c) 2026 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains/args:sysroot.bzl", "cc_sysroot") + +def make_sysroot_link_flags(target_os, sysroot): + """Creates the sysroot_link_flags feature for this toolchain's sysroot directory. + + cc_sysroot already emits "--sysroot={sysroot}" on its own; only the extra + "-Wl,--sysroot={sysroot}" needs to be listed here. + + Args: + sysroot: label of the directory rule for this toolchain's sysroot. + """ + if target_os == "linux": + cc_sysroot( + name = "sysroot_link_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--sysroot={sysroot}"], + sysroot = sysroot, + ) + + cc_feature( + name = "sysroot_link_flags", + args = [":sysroot_link_flags_args"], + feature_name = "sysroot_link_flags", + ) diff --git a/features/native/unfiltered_compile_flags/BUILD b/features/native/unfiltered_compile_flags/BUILD new file mode 100644 index 0000000..8ea2d00 --- /dev/null +++ b/features/native/unfiltered_compile_flags/BUILD @@ -0,0 +1,37 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "unfiltered_compile_flags_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + "-Wno-builtin-macro-redefined", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "unfiltered_compile_flags", + args = [":unfiltered_compile_flags_args"], + feature_name = "unfiltered_compile_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/use_pthread/BUILD b/features/native/use_pthread/BUILD new file mode 100644 index 0000000..85922fc --- /dev/null +++ b/features/native/use_pthread/BUILD @@ -0,0 +1,29 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "use_pthread_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-pthread"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "use_pthread", + args = [":use_pthread_args"], + feature_name = "use_pthread", + visibility = ["//visibility:public"], +) diff --git a/features/native/user_compile_flags/BUILD b/features/native/user_compile_flags/BUILD new file mode 100644 index 0000000..f5a6702 --- /dev/null +++ b/features/native/user_compile_flags/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "user_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = ["{user_compile_flags}"], + format = {"user_compile_flags": "@rules_cc//cc/toolchains/variables:user_compile_flags"}, + iterate_over = "@rules_cc//cc/toolchains/variables:user_compile_flags", + requires_not_none = "@rules_cc//cc/toolchains/variables:user_compile_flags", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "user_compile_flags", + args = [":user_compile_flags_args"], + feature_name = "user_compile_flags", + visibility = ["//visibility:public"], +) diff --git a/features/native/user_link_flags/BUILD b/features/native/user_link_flags/BUILD new file mode 100644 index 0000000..d4e30f2 --- /dev/null +++ b/features/native/user_link_flags/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "user_link_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["{user_link_flags}"], + format = {"user_link_flags": "@rules_cc//cc/toolchains/variables:user_link_flags"}, + iterate_over = "@rules_cc//cc/toolchains/variables:user_link_flags", + requires_not_none = "@rules_cc//cc/toolchains/variables:user_link_flags", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "user_link_flags", + args = [":user_link_flags_args"], + feature_name = "user_link_flags", + visibility = ["//visibility:public"], +) diff --git a/packages/linux/aarch64/autosd/10.0/autosd.BUILD b/packages/linux/aarch64/autosd/10.0/autosd.BUILD index daedfc5..44b2e8f 100644 --- a/packages/linux/aarch64/autosd/10.0/autosd.BUILD +++ b/packages/linux/aarch64/autosd/10.0/autosd.BUILD @@ -59,3 +59,7 @@ filegroup( "lib64/**", ]), ) + +filegroup( + name = "cxx_builtin_include_directories", +) diff --git a/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD b/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD index d909382..44a2303 100644 --- a/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD +++ b/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD @@ -71,3 +71,7 @@ filegroup( name = "sysroot_dir", srcs = ["."], ) + +filegroup( + name = "cxx_builtin_include_directories", +) diff --git a/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD b/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD index 4725a73..170a138 100644 --- a/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD +++ b/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD @@ -54,3 +54,7 @@ filegroup( name = "sysroot_dir", srcs = ["aarch64-unknown-linux-gnu/sysroot"], ) + +filegroup( + name = "cxx_builtin_include_directories", +) diff --git a/packages/linux/aarch64/gcc/15.3.0/gcc.BUILD b/packages/linux/aarch64/gcc/15.3.0/gcc.BUILD index 4725a73..170a138 100644 --- a/packages/linux/aarch64/gcc/15.3.0/gcc.BUILD +++ b/packages/linux/aarch64/gcc/15.3.0/gcc.BUILD @@ -54,3 +54,7 @@ filegroup( name = "sysroot_dir", srcs = ["aarch64-unknown-linux-gnu/sysroot"], ) + +filegroup( + name = "cxx_builtin_include_directories", +) diff --git a/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD b/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD index dc6fbb1..088dab4 100644 --- a/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD +++ b/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD @@ -54,3 +54,7 @@ filegroup( name = "sysroot_dir", srcs = ["x86_64-unknown-linux-gnu/sysroot"], ) + +filegroup( + name = "cxx_builtin_include_directories", +) diff --git a/packages/linux/x86_64/gcc/15.3.0/gcc.BUILD b/packages/linux/x86_64/gcc/15.3.0/gcc.BUILD index dc6fbb1..088dab4 100644 --- a/packages/linux/x86_64/gcc/15.3.0/gcc.BUILD +++ b/packages/linux/x86_64/gcc/15.3.0/gcc.BUILD @@ -54,3 +54,7 @@ filegroup( name = "sysroot_dir", srcs = ["x86_64-unknown-linux-gnu/sysroot"], ) + +filegroup( + name = "cxx_builtin_include_directories", +) diff --git a/rules/common.bzl b/rules/common.bzl index ad756d6..b61011c 100644 --- a/rules/common.bzl +++ b/rules/common.bzl @@ -22,6 +22,19 @@ load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "flag_group") # uses the older identifier. SDP_VERSION_MAPPING = {"8.0.4": "8.0.0"} +def get_flag_strings(flags): + """Converts a list of warning flags into a Bazel flag group representation. + + Args: + flags (list[str]): A list of compiler warning flags. + + Returns: + str: A formatted string representing the flag group in Bazel syntax. + """ + if len(flags): + return "[" + ", ".join(['"%s"' % f for f in flags]) + "]" + return "None" + def get_flag_groups(flags): """Converts a list of warning flags into a Bazel flag group representation. diff --git a/rules/gcc.bzl b/rules/gcc.bzl index 1a9504b..7acf67d 100644 --- a/rules/gcc.bzl +++ b/rules/gcc.bzl @@ -14,7 +14,7 @@ """ Module rule for defining GCC toolchains in Bazel. """ -load("@score_bazel_cpp_toolchains//rules:common.bzl", "SDP_VERSION_MAPPING", "get_flag_groups", "label_list_to_string") +load("@score_bazel_cpp_toolchains//rules:common.bzl", "SDP_VERSION_MAPPING", "get_flag_groups", "get_flag_strings", "label_list_to_string") # Constants _OS_QNX = "qnx" @@ -52,8 +52,7 @@ def _get_cc_config_linux(rctx): Returns: str: BUILD file content defining filegroup and cc_toolchain_config for Linux. """ - return """ -filegroup( + return """filegroup( name = "all_files", srcs = [ "@{tc_pkg_repo}//:all_files", @@ -71,6 +70,9 @@ cc_toolchain_config( sysroot = "@{tc_pkg_repo}//:sysroot_dir", target_cpu = "{tc_cpu}", target_os = "{tc_os}", + known_features = _KNOWN_FEATURES, + enabled_features = _ENABLED_FEATURES, + cxx_builtin_include_directories = ["@{tc_pkg_repo}//:cxx_builtin_include_directories"], extra_known_features = {tc_extra_known_features}, extra_enabled_features = {tc_extra_enabled_features}, visibility = ["//visibility:public"], @@ -108,11 +110,11 @@ cc_toolchain_config( cxx_binary = "@{tc_pkg_repo}//:cxx", gcov_binary = "@{tc_pkg_repo}//:gcov", strip_binary = "@{tc_pkg_repo}//:strip", - host_dir = "@{tc_pkg_repo}//:host_dir", - target_dir = "@{tc_pkg_repo}//:target_dir", - cxx_builtin_include_directories = "@{tc_pkg_repo}//:cxx_builtin_include_directories", + cxx_builtin_include_directories = ["@{tc_pkg_repo}//:cxx_builtin_include_directories"], target_cpu = "{tc_cpu}", target_os = "{tc_os}", + known_features = _KNOWN_FEATURES, + enabled_features = _ENABLED_FEATURES, extra_known_features = {tc_extra_known_features}, extra_enabled_features = {tc_extra_enabled_features}, visibility = ["//visibility:public"], @@ -125,6 +127,34 @@ cc_toolchain_config( tc_extra_enabled_features = label_list_to_string(rctx.attr.extra_enabled_features), ) +def get_custom_cc_features_linux(rctx): + return "" + +def get_custom_cc_features_qnx(rctx, canonical_pkg_name): + # host_dir/target_dir must be plain resolved paths, not labels: cc_args' + # `env` rejects format() variables that aren't builtin cc_toolchain + # variables ("The variable host_dir does not exist"). + + # TODO: Once Bazel enables label resolution in cc_args' env, we can use labels instead of resolved paths. + + custom_load = """load("@score_bazel_cpp_toolchains//features/custom/qnx/sdp_env:feature.bzl", "make_sdp_env_feature")""" + custom_features = """ +make_sdp_env_feature( + host_dir = "{host_dir}", + target_dir = "{target_dir}", + license_path = "{license_path}", + license_info_variable = "{license_info_variable}", + license_info_value = "{license_info_value}", +) +""".format( + host_dir = "/proc/self/cwd/external/{canonical_pkg}/host/linux/x86_64".format(canonical_pkg = canonical_pkg_name), + target_dir = "/proc/self/cwd/external/{canonical_pkg}/target/qnx".format(canonical_pkg = canonical_pkg_name), + license_path = rctx.attr.license_path, + license_info_variable = rctx.attr.license_info_variable, + license_info_value = rctx.attr.license_info_value, + ) + return custom_load, custom_features + def _normalize_cpu(cpu): """Converts CPU name to its normalized form for toolchain paths. @@ -210,10 +240,22 @@ def _impl(rctx): tc_identifier_short_2 = "-{}".format(rctx.attr.tc_runtime_ecosystem) tc_identifier_long_2 = "[\"@score_bazel_platforms//runtime_es:{}\"]".format(rctx.attr.tc_runtime_ecosystem) + # Get canonical repository name for the toolchain package + canonical_pkg_name = _get_canonical_pkg_name(rctx) + + # Replace %{toolchain_pkg}% placeholder in extra flags with canonical name + def replace_placeholder(flags): + return [flag.replace(_PLACEHOLDER_TOOLCHAIN_PKG, canonical_pkg_name) for flag in flags] + + compiler_library_search_paths = replace_placeholder(rctx.attr.tc_compiler_library_search_paths) + compiler_library_search_paths_str = ":".join(["/proc/self/cwd/" + entry for entry in compiler_library_search_paths]) + rctx.template( "BUILD", rctx.attr._cc_toolchain_build, { + "%{tc_custom_feature_load}": get_custom_cc_features_qnx(rctx, canonical_pkg_name)[0] if rctx.attr.tc_os == _OS_QNX else "", + "%{tc_custom_features}": get_custom_cc_features_qnx(rctx, canonical_pkg_name)[1] if rctx.attr.tc_os == _OS_QNX else "", "%{cc_toolchain_config}": cc_toolchain_config, "%{tc_cpu}": rctx.attr.tc_cpu, "%{tc_identifier}": tc_identifier, @@ -221,6 +263,12 @@ def _impl(rctx): "%{tc_pkg_repo}": rctx.attr.tc_pkg_repo, "%{tc_runtime_es}": rctx.attr.tc_runtime_ecosystem, "%{tc_version}": rctx.attr.gcc_version, + "%{tc_sysroot}": "@{tc_pkg_repo}//:sysroot_dir".format(tc_pkg_repo = rctx.attr.tc_pkg_repo), + "%{tc_extra_compile_flags}": get_flag_strings(replace_placeholder(rctx.attr.extra_compile_flags)), + "%{tc_extra_c_compile_flags}": get_flag_strings(replace_placeholder(rctx.attr.extra_c_compile_flags)), + "%{tc_extra_cxx_compile_flags}": get_flag_strings(replace_placeholder(rctx.attr.extra_cxx_compile_flags)), + "%{tc_extra_link_flags}": get_flag_strings(replace_placeholder(rctx.attr.extra_link_flags)), + "%{tc_compiler_library_search_paths}": compiler_library_search_paths_str, "%{tc_identifier_short_1}": tc_identifier_short_1, "%{tc_identifier_short_2}": tc_identifier_short_2, "%{tc_identifier_long_1}": tc_identifier_long_1, @@ -228,22 +276,14 @@ def _impl(rctx): }, ) - # Get canonical repository name for the toolchain package - canonical_pkg_name = _get_canonical_pkg_name(rctx) - - # Replace %{toolchain_pkg}% placeholder in extra flags with canonical name - def replace_placeholder(flags): - return [flag.replace(_PLACEHOLDER_TOOLCHAIN_PKG, canonical_pkg_name) for flag in flags] - extra_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_compile_flags)) extra_c_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_c_compile_flags)) extra_cxx_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_cxx_compile_flags)) extra_link_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_link_flags)) - compiler_library_search_paths = replace_placeholder(rctx.attr.tc_compiler_library_search_paths) template_dict = { "%{compiler_library_search_paths_switch}": "True" if len(rctx.attr.tc_compiler_library_search_paths) else "False", - "%{compiler_library_search_paths}": ":".join(["/proc/self/cwd/" + entry for entry in compiler_library_search_paths]), + "%{compiler_library_search_paths}": compiler_library_search_paths_str, "%{extra_c_compile_flags_switch}": "True" if len(rctx.attr.extra_c_compile_flags) else "False", "%{extra_c_compile_flags}": extra_c_compile_flags, "%{extra_compile_flags_switch}": "True" if len(rctx.attr.extra_compile_flags) else "False", @@ -252,6 +292,7 @@ def _impl(rctx): "%{extra_cxx_compile_flags}": extra_cxx_compile_flags, "%{extra_link_flags_switch}": "True" if len(rctx.attr.extra_link_flags) else "False", "%{extra_link_flags}": extra_link_flags, + "%{tc_compiler}": "gcc", "%{tc_cpu}": _normalize_cpu(rctx.attr.tc_cpu), "%{tc_identifier}": "gcc", "%{tc_runtime_es}": rctx.attr.tc_runtime_ecosystem, @@ -260,12 +301,16 @@ def _impl(rctx): if rctx.attr.tc_os == _OS_QNX: mapped_sdp_version = _apply_sdp_version_mapping(rctx.attr.sdp_version) + qnx_identifier = "{cpu}-qnx{sdp}".format(cpu = _normalize_cpu(rctx.attr.tc_cpu), sdp = mapped_sdp_version) extra_template_dict = { "%{license_info_value}": rctx.attr.license_info_value, "%{license_info_variable}": rctx.attr.license_info_variable, "%{license_path}": rctx.attr.license_path, "%{sdp_version}": mapped_sdp_version, + "%{tc_abi_version}": qnx_identifier, + "%{tc_compiler}": "qcc", "%{tc_cpu_cxx}": _normalize_cpu(rctx.attr.tc_cpu), + "%{tc_identifier}": qnx_identifier, "%{use_license_info}": "False" if rctx.attr.license_info_value == "" else "True", } template_dict = dict_union(template_dict, extra_template_dict) @@ -276,12 +321,6 @@ def _impl(rctx): template_dict, ) - rctx.template( - "flags.bzl", - rctx.attr.cc_toolchain_flags, - {}, - ) - if rctx.attr.tc_os == _OS_LINUX: # There is an issue with gcov and cc_toolchain config. # See: https://github.com/bazelbuild/rules_cc/issues/351 @@ -320,9 +359,6 @@ gcc_toolchain = repository_rule( "cc_toolchain_config": attr.label( doc = "Path to the cc_config.bzl template file.", ), - "cc_toolchain_flags": attr.label( - doc = "Path to the Bazel BUILD file template for the toolchain.", - ), "extra_c_compile_flags": attr.string_list(doc = "Extra/Additional C-specific compile flags."), "extra_compile_flags": attr.string_list(doc = "Extra/Additional compile flags."), "extra_cxx_compile_flags": attr.string_list(doc = "Extra/Additional C++-specific compile flags."), @@ -344,7 +380,7 @@ gcc_toolchain = repository_rule( "tc_runtime_ecosystem": attr.string(doc = "Runtime ecosystem."), "tc_system_toolchain": attr.bool(doc = "Boolean flag to state if this is a system toolchain"), "_cc_gcov_wrapper_script": attr.label( - default = "@score_bazel_cpp_toolchains//templates/linux:cc_gcov_wrapper.template", + default = "@score_bazel_cpp_toolchains//templates:cc_gcov_wrapper.template", ), "_cc_toolchain_build": attr.label( default = "@score_bazel_cpp_toolchains//templates:BUILD.template", diff --git a/templates/BUILD.template b/templates/BUILD.template index b7548da..55520bb 100644 --- a/templates/BUILD.template +++ b/templates/BUILD.template @@ -15,8 +15,37 @@ """ load("@rules_cc//cc:defs.bzl", "cc_toolchain") +load("@score_bazel_cpp_toolchains//features/custom/%{tc_os}:make_cc_features.bzl", "get_feature_lists") +load("@score_bazel_cpp_toolchains//features/native/extra_compile_flags:features.bzl", "make_extra_compile_features") +load("@score_bazel_cpp_toolchains//features/native/extra_link_flags:features.bzl", "make_extra_link_features") +load("@score_bazel_cpp_toolchains//features/native/compiler_library_search_paths:features.bzl", "make_compiler_library_search_paths") +load("@score_bazel_cpp_toolchains//features/native/sysroot_link_flags:features.bzl", "make_sysroot_link_flags") +%{tc_custom_feature_load} load(":cc_toolchain_config.bzl", "cc_toolchain_config") +make_extra_compile_features( + extra_compile_flags = %{tc_extra_compile_flags}, + extra_c_compile_flags = %{tc_extra_c_compile_flags}, + extra_cxx_compile_flags = %{tc_extra_cxx_compile_flags}, +) + +make_extra_link_features( + extra_link_flags = %{tc_extra_link_flags} +) + +make_compiler_library_search_paths( + compiler_library_search_paths = "%{tc_compiler_library_search_paths}", +) + +make_sysroot_link_flags( + target_os = "%{tc_os}", + sysroot = "%{tc_sysroot}", +) +%{tc_custom_features} +# known_features must list every feature (enabled or opt-in); enabled_features is +# the order-irrelevant subset that should start on. See compute_feature_lists(). +_KNOWN_FEATURES, _ENABLED_FEATURES = get_feature_lists() + filegroup( name = "empty", ) diff --git a/templates/linux/cc_gcov_wrapper.template b/templates/cc_gcov_wrapper.template similarity index 100% rename from templates/linux/cc_gcov_wrapper.template rename to templates/cc_gcov_wrapper.template diff --git a/templates/cc_toolchain_config.bzl.template b/templates/cc_toolchain_config.bzl.template new file mode 100644 index 0000000..5b9a426 --- /dev/null +++ b/templates/cc_toolchain_config.bzl.template @@ -0,0 +1,178 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +"""C/C++ toolchain definition""" + +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") +load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "flag_group", + "flag_set", + "tool", + "tool_path", +) +load("@rules_cc//cc:defs.bzl", "cc_common", "CcToolchainConfigInfo") +load("@rules_cc//cc/toolchains:feature_injection.bzl", "convert_feature", "FeatureInfo") + +def _impl(ctx): + assemble_action = action_config( + action_name = ACTION_NAMES.assemble, + tools = [tool(tool = ctx.executable.cc_binary)], + ) + preprocess_assemble_action = action_config( + action_name = ACTION_NAMES.preprocess_assemble, + tools = [tool(tool = ctx.executable.cc_binary)], + ) + c_compile_action = action_config( + action_name = ACTION_NAMES.c_compile, + tools = [tool(tool = ctx.executable.cc_binary)], + ) + cpp_compile_action = action_config( + action_name = ACTION_NAMES.cpp_compile, + tools = [tool(tool = ctx.executable.cxx_binary)], + ) + cpp_link_executable_action = action_config( + action_name = ACTION_NAMES.cpp_link_executable, + tools = [tool(tool = ctx.executable.cxx_binary)], + ) + cpp_link_dynamic_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_dynamic_library, + tools = [tool(tool = ctx.executable.cxx_binary)], + ) + cpp_link_nodeps_dynamic_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, + tools = [tool(tool = ctx.executable.cxx_binary)], + ) + cpp_link_static_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_static_library, + tools = [tool(tool = ctx.executable.ar_binary)], + implies = ["archiver_flags"], + ) + strip_action = action_config( + action_name = ACTION_NAMES.strip, + tools = [tool(tool = ctx.executable.strip_binary)], + flag_sets = [ + flag_set( + flag_groups = [ + flag_group( + flags = [ + "-g", + "-p", + ], + ), + flag_group( + iterate_over = "stripopts", + flags = ["%{stripopts}"], + ), + flag_group( + flags = [ + "%{input_file}", + "%{output_file}", + ], + ), + ], + ), + ], + ) + + action_configs = [ + assemble_action, + c_compile_action, + cpp_compile_action, + cpp_link_dynamic_library_action, + cpp_link_executable_action, + cpp_link_nodeps_dynamic_library_action, + cpp_link_static_library_action, + preprocess_assemble_action, + strip_action, + ] + + features = [ + convert_feature(known_feature[FeatureInfo], enabled = known_feature in ctx.attr.enabled_features) + for known_feature in ctx.attr.known_features + ] + + extra_rules_based_features = depset(ctx.attr.extra_enabled_features + ctx.attr.extra_known_features) + features.extend([convert_feature(extra_feature[FeatureInfo], enabled = extra_feature in ctx.attr.extra_enabled_features) for extra_feature in extra_rules_based_features.to_list()]) + + # Get builtin include directories from attribute if provided + cxx_builtin_include_directories = [ + "/proc/self/cwd/{}".format(include_directory.path) + for include_directory in ctx.files.cxx_builtin_include_directories + ] + + sysroot = None + if ctx.attr.sysroot != None: + sysroot = ctx.attr.sysroot[DefaultInfo].files.to_list()[0].path + + # TODO: Once https://github.com/bazelbuild/rules_cc/issues/351 is fixed remove this. + tool_paths = [tool_path(name = "gcov", path = "gcov_wrapper")] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + abi_version = "%{tc_abi_version}", + abi_libc_version = "unknown", + builtin_sysroot = sysroot, + compiler = "%{tc_compiler}", + cxx_builtin_include_directories = cxx_builtin_include_directories, + features = features, + action_configs = action_configs, + host_system_name = "local", + target_system_name = "%{tc_cpu}-%{tc_os}", + target_cpu = ctx.attr.target_cpu, + target_libc = "unknown", + toolchain_identifier = "%{tc_identifier}", + tool_paths = tool_paths, + ) + +cc_toolchain_config = rule( + implementation = _impl, + provides = [CcToolchainConfigInfo], + attrs = { + "ar_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), + "cc_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), + "cxx_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), + "gcov_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), + "strip_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), + "target_cpu": attr.string(mandatory = True), + "target_os": attr.string(mandatory = True), + "sysroot": attr.label(default = None), + "cxx_builtin_include_directories": attr.label_list(allow_files = True, default = []), + "known_features": attr.label_list( + providers = [FeatureInfo], + mandatory = True, + ), + "enabled_features": attr.label_list( + providers = [FeatureInfo], + mandatory = True, + ), + "extra_enabled_features": attr.label_list( + providers = [FeatureInfo], + default = [], + doc = """ +Extra `cc_feature` features to add to this toolchain in an initially enabled state. +This attribute has limited integration with `cc_feature`, and does not run additional correctness checks or handle things like `data` files. +This is only offered as a migration bridge for projects transitioning to rule-based toolchain configurations, or sharing of simple argument sets with older toolchains. +""", + ), + "extra_known_features": attr.label_list( + providers = [FeatureInfo], + default = [], + doc = """ +Extra `cc_feature` features to add to this toolchain in an initially disabled state. +This attribute has limited integration with `cc_feature`, and does not run additional correctness checks or handle things like `data` files. +This is only offered as a migration bridge for projects transitioning to rule-based toolchain configurations, or sharing of simple argument sets with older toolchains. +""", + ), + }, +) diff --git a/templates/linux/cc_toolchain_config.bzl.template b/templates/linux/cc_toolchain_config.bzl.template deleted file mode 100644 index c5480ff..0000000 --- a/templates/linux/cc_toolchain_config.bzl.template +++ /dev/null @@ -1,1050 +0,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 -# ******************************************************************************* - -"""C/C++ toolchain definition""" - -load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") -load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "action_config", - "env_entry", - "env_set", - "feature", - "feature_set", - "flag_group", - "flag_set", - "tool", - "tool_path", - "variable_with_value", - "with_feature_set", -) -load("@rules_cc//cc:defs.bzl", "cc_common", "CcToolchainConfigInfo") -load("@rules_cc//cc/toolchains:feature_injection.bzl", "convert_feature", "FeatureInfo") -load(":flags.bzl", - "UNFILTERED_COMPILE_FLAGS", - "DEFAULT_COMPILE_FLAGS", - "DEFAULT_x86_64_COMPILE_FLAGS", - "DEFAULT_ARM64_COMPILE_FLAGS", - "DEFAULT_C_COMPILE_FLAGS", - "DEFAULT_CXX_COMPILE_FLAGS", - "DEFAULT_LINK_FLAGS", - "DBG_COMPILE_FLAGS", - "OPT_COMPILE_FLAGS", -) - -all_cpp_compile_actions = [ - ACTION_NAMES.cpp_compile, - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.clif_match, - ACTION_NAMES.lto_backend, -] - -all_c_compile_actions = [ - ACTION_NAMES.c_compile, -] - -all_assemble_actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, -] - -all_compile_actions = all_c_compile_actions + all_cpp_compile_actions + all_assemble_actions - -all_link_actions = [ - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, -] - -all_actions = all_compile_actions + all_link_actions + [ - ACTION_NAMES.strip, - ACTION_NAMES.cpp_link_static_library, -] - -def _impl(ctx): - dbg_feature = feature(name = "dbg") - opt_feature = feature(name = "opt") - - no_legacy_features_feature = feature(name = "no_legacy_features", enabled = True) - - # Temp solution until we do not add feature injection - gnu11_feature = feature(name = "gnu11") - - supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) - supports_fission_feature = feature(name = "supports_fission", enabled = True) - - assemble_action = action_config( - action_name = ACTION_NAMES.assemble, - tools = [tool(tool = ctx.executable.cc_binary)], - ) - preprocess_assemble_action = action_config( - action_name = ACTION_NAMES.preprocess_assemble, - tools = [tool(tool = ctx.executable.cc_binary)], - ) - c_compile_action = action_config( - action_name = ACTION_NAMES.c_compile, - tools = [tool(tool = ctx.executable.cc_binary)], - ) - cpp_compile_action = action_config( - action_name = ACTION_NAMES.cpp_compile, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_executable_action = action_config( - action_name = ACTION_NAMES.cpp_link_executable, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_dynamic_library_action = action_config( - action_name = ACTION_NAMES.cpp_link_dynamic_library, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_nodeps_dynamic_library_action = action_config( - action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_static_library_action = action_config( - action_name = ACTION_NAMES.cpp_link_static_library, - tools = [tool(tool = ctx.executable.ar_binary)], - implies = ["archiver_flags"], - ) - strip_action = action_config( - action_name = ACTION_NAMES.strip, - tools = [tool(tool = ctx.executable.strip_binary)], - flag_sets = [ - flag_set( - flag_groups = [ - flag_group( - flags = [ - "-g", - "-p", - ], - ), - flag_group( - iterate_over = "stripopts", - flags = ["%{stripopts}"], - ), - flag_group( - flags = [ - "%{input_file}", - "%{output_file}", - ], - ), - ], - ), - ], - ) - - action_configs = [ - assemble_action, - c_compile_action, - cpp_compile_action, - cpp_link_dynamic_library_action, - cpp_link_executable_action, - cpp_link_nodeps_dynamic_library_action, - cpp_link_static_library_action, - preprocess_assemble_action, - strip_action, - ] - - # Set LD_LIBRARY_PATH environment variable for all actions - # This is needed by some toolchains since these libraries are not in `rpath` of compiler binary - # which are needed to run it. - compiler_library_search_paths = "%{compiler_library_search_paths}" - compiler_library_search_paths_feature = feature( - name = "compiler_library_search_paths", - enabled = %{compiler_library_search_paths_switch}, - env_sets = [ - env_set( - actions = all_actions, - env_entries = [env_entry(key = "LD_LIBRARY_PATH", value = compiler_library_search_paths)] if compiler_library_search_paths != "" else [], - ), - ], - ) - - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_c_compile_actions + all_cpp_compile_actions, - flag_groups = UNFILTERED_COMPILE_FLAGS - ), - ], - ) - - target_cpu_flags = [] - if ctx.attr.target_cpu == "x86_64": - target_cpu_flags = DEFAULT_x86_64_COMPILE_FLAGS - else: - target_cpu_flags = DEFAULT_ARM64_COMPILE_FLAGS - - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = DEFAULT_COMPILE_FLAGS, - ), - flag_set( - actions = all_compile_actions, - flag_groups = target_cpu_flags, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = [flag_group(flags = ["-std=c11"])], - with_features = [with_feature_set(not_features = ["gnu11"])], - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = [flag_group(flags = ["-std=gnu11"])], - with_features = [with_feature_set(features = ["gnu11"])], - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = DEFAULT_CXX_COMPILE_FLAGS, - ), - flag_set( - actions = all_compile_actions, - flag_groups = DBG_COMPILE_FLAGS, - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = all_compile_actions, - flag_groups = OPT_COMPILE_FLAGS, - with_features = [ - with_feature_set(features = ["opt"]), - with_feature_set(features = ["fastbuild"]), - ], - ), - ], - ) - - # Add sysroot linker flags as a separate feature (always enabled) - sysroot_link_flags_feature_flag_sets = [] - if ctx.attr.sysroot != None: - sysroot_files = ctx.attr.sysroot[DefaultInfo].files.to_list() - if sysroot_files: - sysroot_path = sysroot_files[0].path - sysroot_link_flags_feature_flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = [ - "--sysroot=" + sysroot_path, - "-Wl,--sysroot=" + sysroot_path, - ])], - ), - ] - - sysroot_link_flags_feature = feature( - name = "sysroot_link_flags", - enabled = True, - flag_sets = sysroot_link_flags_feature_flag_sets, - ) - - # Only enable default link flags if extra link flags are not provided - default_link_flags_enabled = not %{extra_link_flags_switch} - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = default_link_flags_enabled, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = DEFAULT_LINK_FLAGS, - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = [ - "-Wl,--compress-debug-sections=zlib", - ], - ), - ], - with_features = [with_feature_set(not_features = ["opt"])], - ), - ], - ) - - extra_compile_flags = %{extra_compile_flags} - extra_compile_flags_feature = feature( - name = "extra_compile_flags", - enabled = %{extra_compile_flags_switch}, - implies = ["default_compile_flags"], - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = extra_compile_flags, - ), - ], - ) - - extra_c_compile_flags = %{extra_c_compile_flags} - extra_c_compile_flags_feature = feature( - name = "extra_c_compile_flags", - enabled = %{extra_c_compile_flags_switch}, - implies = ["default_compile_flags"], - flag_sets = [ - flag_set( - actions = all_c_compile_actions, - flag_groups = extra_c_compile_flags, - ), - ], - ) - - extra_cxx_compile_flags = %{extra_cxx_compile_flags} - extra_cxx_compile_flags_feature = feature( - name = "extra_cxx_compile_flags", - enabled = %{extra_cxx_compile_flags_switch}, - implies = ["default_compile_flags"], - flag_sets = [ - flag_set( - actions = all_cpp_compile_actions, - flag_groups = extra_cxx_compile_flags, - ), - ], - ) - - extra_link_flags = %{extra_link_flags} - extra_link_flags_feature = feature( - name = "extra_link_flags", - enabled = %{extra_link_flags_switch}, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = extra_link_flags, - ), - ], - ) - - pthread_feature = feature( - name = "use_pthread", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group(flags = ["-pthread"]), - ], - ), - ], - ) - - supports_pic_feature = feature(name = "supports_pic", enabled = True) - - pic_feature = feature( - name = "pic", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.cpp_module_compile, - ], - flag_groups = [ - flag_group(flags = ["-fPIC"], expand_if_available = "pic"), - ], - ), - ], - ) - - user_compile_flags_feature = feature( - name = "user_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "user_compile_flags", - flags = ["%{user_compile_flags}"], - expand_if_available = "user_compile_flags", - ), - ], - ), - ], - ) - - random_seed_feature = feature( - name = "random_seed", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ], - flag_groups = [ - flag_group( - expand_if_available = "output_file", - flags = ["-frandom-seed=%{output_file}"], - ), - ], - ), - ], - ) - - include_paths_feature = feature( - name = "include_paths", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "quote_include_paths", - flags = ["-iquote", "%{quote_include_paths}"], - expand_if_available = "quote_include_paths", - ), - ], - ), - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "include_paths", - flags = ["-I%{include_paths}"], - expand_if_available = "include_paths", - ), - ], - ), - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "system_include_paths", - flags = ["-isystem", "%{system_include_paths}"], - expand_if_available = "system_include_paths", - ), - ], - ), - ], - ) - - preprocessor_defines_feature = feature( - name = "preprocessor_defines", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "preprocessor_defines", - flags = ["-D%{preprocessor_defines}"], - expand_if_available = "preprocessor_defines", - ), - ], - ), - ], - ) - - compiler_input_flags_feature = feature( - name = "compiler_input_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - flags = ["-c", "%{source_file}"], - expand_if_available = "source_file", - ), - ], - ), - ], - ) - - dependency_file_feature = feature( - name = "dependency_file", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.objc_compile, - ACTION_NAMES.objcpp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.clif_match, - ], - flag_groups = [ - flag_group( - flags = ["-MD", "-MF", "%{dependency_file}"], - expand_if_available = "dependency_file", - ), - ], - ), - ], - ) - - compiler_output_flags_feature = feature( - name = "compiler_output_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - flags = ["-S"], - expand_if_available = "output_assembly_file", - ), - flag_group( - flags = ["-E"], - expand_if_available = "output_preprocess_file", - ), - flag_group( - flags = ["-o", "%{output_file}"], - expand_if_available = "output_file", - ), - ], - ), - ], - ) - - archiver_flags_feature = feature( - name = "archiver_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.cpp_link_static_library], - flag_groups = [ - flag_group( - flags = ["rcsD", "%{output_execpath}"], - expand_if_available = "output_execpath", - ), - flag_group( - iterate_over = "libraries_to_link", - flag_groups = [ - flag_group( - flags = ["%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file", - ), - ), - flag_group( - flags = ["%{libraries_to_link.object_files}"], - iterate_over = "libraries_to_link.object_files", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file_group", - ), - ), - ], - expand_if_available = "libraries_to_link", - ), - flag_group( - iterate_over = "user_archiver_flags", - flags = ["%{user_archiver_flags}"], - expand_if_available = "user_archiver_flags", - ), - ], - ), - ], - ) - - linker_param_file_feature = feature( - name = "linker_param_file", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions + [ACTION_NAMES.cpp_link_static_library], - flag_groups = [ - flag_group( - flags = ["@%{linker_param_file}"], - expand_if_available = "linker_param_file", - ), - ], - ), - ], - ) - - library_search_directories_feature = feature( - name = "library_search_directories", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "library_search_directories", - flag_groups = [ - flag_group( - flags = ["-L%{library_search_directories}"], - ), - ], - expand_if_available = "library_search_directories", - ), - ], - ), - ], - ) - - shared_flag_feature = feature( - name = "shared_flag", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ], - flag_groups = [flag_group(flags = ["-shared"])], - ), - ], - ) - - output_execpath_flags_feature = feature( - name = "output_execpath_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = ["-o", "%{output_execpath}"], - expand_if_available = "output_execpath", - ), - ], - ), - ], - ) - - runtime_library_search_directories_feature = feature( - name = "runtime_library_search_directories", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "runtime_library_search_directories", - flag_groups = [ - flag_group( - flags = ["-Wl,-rpath,$ORIGIN/%{runtime_library_search_directories}"], - expand_if_true = "is_cc_test", - ), - flag_group( - flags = ["-Wl,-rpath,$EXEC_ORIGIN/%{runtime_library_search_directories}"], - expand_if_false = "is_cc_test", - ), - ], - expand_if_available = "runtime_library_search_directories", - ), - ], - ), - ], - ) - - libraries_to_link_feature = feature( - name = "libraries_to_link", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "libraries_to_link", - flag_groups = [ - flag_group( - flags = ["-Wl,--whole-archive", "%{libraries_to_link.name}", "-Wl,--no-whole-archive"], - expand_if_true = "libraries_to_link.is_whole_archive", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "static_library", - ), - ), - flag_group( - flags = ["%{libraries_to_link.name}"], - expand_if_false = "libraries_to_link.is_whole_archive", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "static_library", - ), - ), - flag_group( - flags = ["%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file", - ), - ), - flag_group( - flags = ["%{libraries_to_link.object_files}"], - iterate_over = "libraries_to_link.object_files", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file_group", - ), - ), - flag_group( - flags = ["-l%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "dynamic_library", - ), - ), - flag_group( - flags = ["-l:%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "versioned_dynamic_library", - ), - ), - ], - expand_if_available = "libraries_to_link", - ), - ], - ), - ], - ) - - user_link_flags_feature = feature( - name = "user_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "user_link_flags", - flags = ["%{user_link_flags}"], - expand_if_available = "user_link_flags", - ), - ], - ), - ], - ) - - # ------------------------------------------------------------------------ - # Additional legacy features. - # - # These mirror features that Bazel's legacy toolchain machinery would add - # automatically. All except fully_static_link are guarded (via - # expand_if_available or with_features) so they are no-ops for normal builds - # and only emit flags when the relevant build mode is active (e.g. --fission, - # --force_pic, --stamp). They are therefore enabled by default. - # - # fully_static_link is left DISABLED by default because it emits -static - # unconditionally, which would force fully static linking for every target. - # Users who want it must opt in explicitly, e.g. via `--features=`. - # ------------------------------------------------------------------------ - - # Fission: emit split DWARF debug info into separate .dwo files at compile. - per_object_debug_info_feature = feature( - name = "per_object_debug_info", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_codegen, - ], - flag_groups = [ - flag_group( - flags = ["-gsplit-dwarf", "-g"], - expand_if_available = "per_object_debug_info_file", - ), - ], - ), - ], - ) - - # Fission: emit a .gdb_index section at link when fission is in use. - fission_support_feature = feature( - name = "fission_support", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = ["-Wl,--gdb-index"], - expand_if_available = "is_using_fission", - ), - ], - ), - ], - ) - - # Pass linkstamp object files to the linker (used with --stamp). - linkstamps_feature = feature( - name = "linkstamps", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "linkstamp_paths", - flags = ["%{linkstamp_paths}"], - expand_if_available = "linkstamp_paths", - ), - ], - ), - ], - ) - - # Force-include headers via -include (the `includes` build variable). - includes_feature = feature( - name = "includes", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "includes", - flags = ["-include", "%{includes}"], - expand_if_available = "includes", - ), - ], - ), - ], - ) - - # Build position-independent executables under --force_pic. - force_pic_flags_feature = feature( - name = "force_pic_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.cpp_link_executable], - flag_groups = [ - flag_group( - flags = ["-pie"], - expand_if_available = "force_pic", - ), - ], - ), - ], - ) - - # Strip debug symbols at link time. - strip_debug_symbols_feature = feature( - name = "strip_debug_symbols", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = ["-Wl,-S"], - expand_if_available = "strip_debug_symbols", - ), - ], - ), - ], - ) - - # Statically link libgcc (paired with static_link_cpp_runtimes). - static_libgcc_feature = feature( - name = "static_libgcc", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ], - flag_groups = [flag_group(flags = ["-static-libgcc"])], - with_features = [ - with_feature_set(features = ["static_link_cpp_runtimes"]), - ], - ), - ], - ) - - # Fully static link (-static) under --dynamic_mode=fully. - fully_static_link_feature = feature( - name = "fully_static_link", - enabled = False, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ], - flag_groups = [flag_group(flags = ["-static"])], - ), - ], - ) - - # Feature to disable absolute path warnings for system headers - supports_header_path_normalization = feature( - name = "supports_header_path_normalization", - enabled = True, - ) - - coverage_feature = feature(name = "coverage") - gcc_coverage_map_format_feature = feature( - name = "gcc_coverage_map_format", - provides = ["profile"], - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.preprocess_assemble, - ], - flag_groups = [flag_group( - expand_if_available = "gcov_gcno_file", - flags = ["-fprofile-arcs", "-ftest-coverage"], - )], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["--coverage"])], - ), - ], - requires = [feature_set(features = ["coverage"])], - ) - - # The order of the features is relevant, they are applied in this specific order. - # A command line parameter from a feature at the end of the list will appear - # after a command line parameter from a feature at the beginning of the list. - - features = [ - no_legacy_features_feature, - compiler_library_search_paths_feature, - dbg_feature, - unfiltered_compile_flags_feature, - gnu11_feature, - default_compile_flags_feature, - random_seed_feature, - include_paths_feature, - preprocessor_defines_feature, - extra_compile_flags_feature, - extra_c_compile_flags_feature, - extra_cxx_compile_flags_feature, - user_compile_flags_feature, - compiler_input_flags_feature, - compiler_output_flags_feature, - dependency_file_feature, - per_object_debug_info_feature, - includes_feature, - default_link_flags_feature, - archiver_flags_feature, - linker_param_file_feature, - library_search_directories_feature, - shared_flag_feature, - output_execpath_flags_feature, - runtime_library_search_directories_feature, - libraries_to_link_feature, - user_link_flags_feature, - linkstamps_feature, - fission_support_feature, - force_pic_flags_feature, - strip_debug_symbols_feature, - static_libgcc_feature, - fully_static_link_feature, - sysroot_link_flags_feature, - pthread_feature, - extra_link_flags_feature, - opt_feature, - supports_dynamic_linker_feature, - supports_pic_feature, - pic_feature, - supports_header_path_normalization, - supports_fission_feature, - coverage_feature, - gcc_coverage_map_format_feature, - ] - - extra_rules_based_features = depset(ctx.attr.extra_enabled_features + ctx.attr.extra_known_features) - features.extend([convert_feature(extra_feature[FeatureInfo], enabled = extra_feature in ctx.attr.extra_enabled_features) for extra_feature in extra_rules_based_features.to_list()]) - - # Get builtin include directories from attribute if provided - cxx_builtin_include_directories = [] - if hasattr(ctx.attr, "builtin_include_directories") and ctx.attr.builtin_include_directories: - cxx_builtin_include_directories = ctx.attr.builtin_include_directories - - # TODO: Once https://github.com/bazelbuild/rules_cc/issues/351 is fixed remove this. - tool_paths = [tool_path(name = "gcov", path = "gcov_wrapper")] - - sysroot = None - if ctx.attr.sysroot != None: - sysroot = ctx.attr.sysroot[DefaultInfo].files.to_list()[0].path - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - abi_version = "%{tc_abi_version}", - abi_libc_version = "unknown", - builtin_sysroot = sysroot, - compiler = "gcc", - cxx_builtin_include_directories = cxx_builtin_include_directories, - features = features, - action_configs = action_configs, - host_system_name = "local", - target_system_name = "%{tc_cpu}-%{tc_os}", - target_cpu = ctx.attr.target_cpu, - target_libc = "unknown", - toolchain_identifier = "%{tc_identifier}", - tool_paths = tool_paths, - ) - -cc_toolchain_config = rule( - implementation = _impl, - provides = [CcToolchainConfigInfo], - attrs = { - "ar_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "cc_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "cxx_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "gcov_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "target_cpu": attr.string(mandatory = True), - "target_os": attr.string(mandatory = True), - "strip_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "sysroot": attr.label(default = None), - "host_dir": attr.label(default = None), - "target_dir": attr.label(default = None), - "cxx_builtin_include_directories": attr.label(allow_files = True, default = None), - "extra_enabled_features": attr.label_list( - providers = [FeatureInfo], - default = [], - doc = """ -Extra `cc_feature` features to add to this toolchain in an initially enabled state. -This attribute has limited integration with `cc_feature`, and does not run additional correctness checks or handle things like `data` files. -This is only offered as a migration bridge for projects transitioning to rule-based toolchain configurations, or sharing of simple argument sets with older toolchains. -""", - ), - "extra_known_features": attr.label_list( - providers = [FeatureInfo], - default = [], - doc = """ -Extra `cc_feature` features to add to this toolchain in an initially disabled state. -This attribute has limited integration with `cc_feature`, and does not run additional correctness checks or handle things like `data` files. -This is only offered as a migration bridge for projects transitioning to rule-based toolchain configurations, or sharing of simple argument sets with older toolchains. -""", - ), - }, -) \ No newline at end of file diff --git a/templates/linux/cc_toolchain_flags.bzl.template b/templates/linux/cc_toolchain_flags.bzl.template deleted file mode 100644 index 416275e..0000000 --- a/templates/linux/cc_toolchain_flags.bzl.template +++ /dev/null @@ -1,95 +0,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 -# ******************************************************************************* - -""" Common compile and link flags for GCC toolchains. -""" - -load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "flag_group") - -def get_flag_group(flags): - """Helper function to create a flag_group. - - Args: - flags (list[str]): A list of compiler or linker flags. - - Returns: - flag_group: A Bazel flag_group object containing the provided flags. - """ - if len(flags): - return [ - flag_group( - flags = flags, - ) - ] - return [] - -# Flags that should always be applied, without filtering. -UNFILTERED_COMPILE_FLAGS = get_flag_group([ - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - "-Wno-builtin-macro-redefined", -]) - -# Default compile flags when no specific build type is selected. -DEFAULT_COMPILE_FLAGS = get_flag_group([ - "-U_FORTIFY_SOURCE", - "-D_XOPEN_SOURCE=700", - "-fstack-protector", - "-fdiagnostics-color=always", - "-fno-omit-frame-pointer", - "-ffunction-sections", - "-fdata-sections", - "-fno-canonical-system-headers", - "-no-canonical-prefixes", - "-z noexecstack", -]) - -# TODO: Check if we need this. -DEFAULT_x86_64_COMPILE_FLAGS = get_flag_group([ - "-m64", -]) - -DEFAULT_ARM64_COMPILE_FLAGS = get_flag_group([ -]) - -# Default compile flags for C language when no specific build type is selected. -DEFAULT_C_COMPILE_FLAGS = get_flag_group([ -]) - -# Default compile flags for C++ language when no specific build type is selected. -DEFAULT_CXX_COMPILE_FLAGS = get_flag_group([ - "-std=c++17", -]) - -# Debug compile flags. -DBG_COMPILE_FLAGS = get_flag_group([ - "-Og", - "-g3", -]) - -# Optimization compile flags. -OPT_COMPILE_FLAGS = get_flag_group([ - "-O2", - "-DNDEBUG", -]) - -# Default link flags when no specific build type is selected. -DEFAULT_LINK_FLAGS = get_flag_group([ - "-lm", - "-ldl", - "-lrt", - "-static-libstdc++", - "-static-libgcc", -]) - diff --git a/templates/qnx/cc_toolchain_config.bzl.template b/templates/qnx/cc_toolchain_config.bzl.template deleted file mode 100644 index 4c8f06a..0000000 --- a/templates/qnx/cc_toolchain_config.bzl.template +++ /dev/null @@ -1,817 +0,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 -# ******************************************************************************* - -"""C/C++ toolchain definition""" - -load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") -load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "action_config", - "env_entry", - "env_set", - "feature", - "feature_set", - "flag_group", - "flag_set", - "tool", - "tool_path", - "variable_with_value", - "with_feature_set", -) -load("@rules_cc//cc:defs.bzl", "cc_common", "CcToolchainConfigInfo") -load("@rules_cc//cc/toolchains:feature_injection.bzl", "convert_feature", "FeatureInfo") -load(":flags.bzl", - "UNFILTERED_COMPILE_FLAGS", - "DEFAULT_COMPILE_FLAGS", - "DEFAULT_C_COMPILE_FLAGS", - "DEFAULT_CXX_COMPILE_FLAGS", - "DEFAULT_LINK_FLAGS", - "DBG_COMPILE_FLAGS", - "OPT_COMPILE_FLAGS", -) - -all_cpp_compile_actions = [ - ACTION_NAMES.cpp_compile, - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.clif_match, - ACTION_NAMES.lto_backend, -] - -all_c_compile_actions = [ - ACTION_NAMES.c_compile, -] - -all_assemble_actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, -] - -all_compile_actions = all_c_compile_actions + all_cpp_compile_actions + all_assemble_actions - -all_link_actions = [ - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, -] - -all_actions = all_compile_actions + all_link_actions + [ - ACTION_NAMES.strip, - ACTION_NAMES.cpp_link_static_library, -] - -def _impl(ctx): - """ Implementation function of GCC toolchains. - """ - - dbg_feature = feature(name = "dbg") - opt_feature = feature(name = "opt") - - no_legacy_features_feature = feature(name = "no_legacy_features", enabled = True) - - supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) - - assemble_action = action_config( - action_name = ACTION_NAMES.assemble, - tools = [tool(tool = ctx.executable.cc_binary)], - ) - preprocess_assemble_action = action_config( - action_name = ACTION_NAMES.preprocess_assemble, - tools = [tool(tool = ctx.executable.cc_binary)], - ) - c_compile_action = action_config( - action_name = ACTION_NAMES.c_compile, - tools = [tool(tool = ctx.executable.cc_binary)], - ) - cpp_compile_action = action_config( - action_name = ACTION_NAMES.cpp_compile, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_executable_action = action_config( - action_name = ACTION_NAMES.cpp_link_executable, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_dynamic_library_action = action_config( - action_name = ACTION_NAMES.cpp_link_dynamic_library, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_nodeps_dynamic_library_action = action_config( - action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, - tools = [tool(tool = ctx.executable.cxx_binary)], - ) - cpp_link_static_library_action = action_config( - action_name = ACTION_NAMES.cpp_link_static_library, - tools = [tool(tool = ctx.executable.ar_binary)], - implies = ["archiver_flags"], - ) - strip_action = action_config( - action_name = ACTION_NAMES.strip, - tools = [tool(tool = ctx.executable.strip_binary)], - flag_sets = [ - flag_set( - flag_groups = [ - flag_group( - flags = [ - "-g", - "-p", - ], - ), - flag_group( - iterate_over = "stripopts", - flags = ["%{stripopts}"], - ), - flag_group( - flags = [ - "%{input_file}", - "%{output_file}", - ], - ), - ], - ), - ], - ) - - action_configs = [ - assemble_action, - c_compile_action, - cpp_compile_action, - cpp_link_dynamic_library_action, - cpp_link_executable_action, - cpp_link_nodeps_dynamic_library_action, - cpp_link_static_library_action, - preprocess_assemble_action, - strip_action, - ] - - # Core compilation features - random_seed_feature = feature( - name = "random_seed", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ], - flag_groups = [ - flag_group( - expand_if_available = "output_file", - flags = ["-frandom-seed=%{output_file}"], - ), - ], - ), - ], - ) - - include_paths_feature = feature( - name = "include_paths", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "quote_include_paths", - flags = ["-iquote", "%{quote_include_paths}"], - expand_if_available = "quote_include_paths", - ), - ], - ), - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "include_paths", - flags = ["-I%{include_paths}"], - expand_if_available = "include_paths", - ), - ], - ), - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "system_include_paths", - flags = ["-isystem", "%{system_include_paths}"], - expand_if_available = "system_include_paths", - ), - ], - ), - ], - ) - - preprocessor_defines_feature = feature( - name = "preprocessor_defines", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "preprocessor_defines", - flags = ["-D%{preprocessor_defines}"], - expand_if_available = "preprocessor_defines", - ), - ], - ), - ], - ) - - user_compile_flags_feature = feature( - name = "user_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - iterate_over = "user_compile_flags", - flags = ["%{user_compile_flags}"], - expand_if_available = "user_compile_flags", - ), - ], - ), - ], - ) - - compiler_input_flags_feature = feature( - name = "compiler_input_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - flags = ["-c", "%{source_file}"], - expand_if_available = "source_file", - ), - ], - ), - ], - ) - - compiler_output_flags_feature = feature( - name = "compiler_output_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [ - flag_group( - flags = ["-S"], - expand_if_available = "output_assembly_file", - ), - flag_group( - flags = ["-E"], - expand_if_available = "output_preprocess_file", - ), - flag_group( - flags = ["-o", "%{output_file}"], - expand_if_available = "output_file", - ), - ], - ), - ], - ) - - archiver_flags_feature = feature( - name = "archiver_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.cpp_link_static_library], - flag_groups = [ - flag_group( - flags = ["rcsD", "%{output_execpath}"], - expand_if_available = "output_execpath", - ), - flag_group( - iterate_over = "libraries_to_link", - flag_groups = [ - flag_group( - flags = ["%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file", - ), - ), - flag_group( - flags = ["%{libraries_to_link.object_files}"], - iterate_over = "libraries_to_link.object_files", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file_group", - ), - ), - ], - expand_if_available = "libraries_to_link", - ), - flag_group( - iterate_over = "user_archiver_flags", - flags = ["%{user_archiver_flags}"], - expand_if_available = "user_archiver_flags", - ), - ], - ), - ], - ) - - # Core linking features - user_link_flags_feature = feature( - name = "user_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "user_link_flags", - flags = ["%{user_link_flags}"], - expand_if_available = "user_link_flags", - ), - ], - ), - ], - ) - - linker_param_file_feature = feature( - name = "linker_param_file", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions + [ACTION_NAMES.cpp_link_static_library], - flag_groups = [ - flag_group( - flags = ["@%{linker_param_file}"], - expand_if_available = "linker_param_file", - ), - ], - ), - ], - ) - - library_search_directories_feature = feature( - name = "library_search_directories", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "library_search_directories", - flag_groups = [ - flag_group( - flags = ["-L%{library_search_directories}"], - ), - ], - expand_if_available = "library_search_directories", - ), - ], - ), - ], - ) - - shared_flag_feature = feature( - name = "shared_flag", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ], - flag_groups = [flag_group(flags = ["-shared"])], - ), - ], - ) - - output_execpath_flags_feature = feature( - name = "output_execpath_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = ["-o", "%{output_execpath}"], - expand_if_available = "output_execpath", - ), - ], - ), - ], - ) - - libraries_to_link_feature = feature( - name = "libraries_to_link", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "libraries_to_link", - flag_groups = [ - flag_group( - flags = ["-Wl,--whole-archive", "%{libraries_to_link.name}", "-Wl,--no-whole-archive"], - expand_if_true = "libraries_to_link.is_whole_archive", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "static_library", - ), - ), - flag_group( - flags = ["%{libraries_to_link.name}"], - expand_if_false = "libraries_to_link.is_whole_archive", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "static_library", - ), - ), - flag_group( - flags = ["%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file", - ), - ), - flag_group( - flags = ["%{libraries_to_link.object_files}"], - iterate_over = "libraries_to_link.object_files", - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "object_file_group", - ), - ), - flag_group( - flags = ["-l%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "dynamic_library", - ), - ), - flag_group( - flags = ["-l:%{libraries_to_link.name}"], - expand_if_equal = variable_with_value( - name = "libraries_to_link.type", - value = "versioned_dynamic_library", - ), - ), - ], - expand_if_available = "libraries_to_link", - ), - ], - ), - ], - ) - - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_c_compile_actions + all_cpp_compile_actions, - flag_groups = UNFILTERED_COMPILE_FLAGS, - ), - ], - ) - - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = DEFAULT_COMPILE_FLAGS, - ), - flag_set( - actions = all_compile_actions, - flag_groups = [flag_group(flags = ["-V%{tc_version},gcc_nto%{tc_cpu}"])], - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = DEFAULT_C_COMPILE_FLAGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = DEFAULT_CXX_COMPILE_FLAGS, - ), - flag_set( - actions = all_compile_actions, - flag_groups = DBG_COMPILE_FLAGS, - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = all_compile_actions, - flag_groups = OPT_COMPILE_FLAGS, - with_features = [ - with_feature_set(features = ["opt"]), - with_feature_set(features = ["fastbuild"]), - ], - ), - ], - ) - - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-V%{tc_version},gcc_nto%{tc_cpu}_cxx"])], - ), - flag_set( - actions = all_link_actions, - flag_groups = DEFAULT_LINK_FLAGS, - ), - ], - ) - - extra_compile_flags = %{extra_compile_flags} - extra_compile_flags_feature = feature( - name = "extra_compile_flags", - enabled = %{extra_compile_flags_switch}, - implies = ["default_compile_flags"], - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = extra_compile_flags, - ), - ], - ) - - extra_link_flags = %{extra_link_flags} - extra_link_flags_feature = feature( - name = "extra_link_flags", - enabled = %{extra_link_flags_switch}, - implies = ["default_link_flags"], - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = extra_link_flags, - ), - ], - ) - supports_pic_feature = feature(name = "supports_pic", enabled = True) - - pic_feature = feature( - name = "pic", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.cpp_module_compile, - ], - flag_groups = [ - flag_group(flags = ["-fPIC"], expand_if_available = "pic"), - ], - ), - ], - ) - - dependency_file_named_implicitly_feature = feature( - name = "dependency_file_named_implicitly", - enabled = False, - ) - - use_license_env_info_feautre = feature( - name = "qnx_license_env_info", - enabled = %{use_license_info}, - ) - - license_variable = "%{license_info_variable}" - license_value = "%{license_info_value}" - - sdp_env_feature = feature( - name = "sdp_env", - enabled = True, - env_sets = [ - env_set( - actions = all_compile_actions + all_link_actions, - env_entries = [ - env_entry(key = "QNX_HOST", value = "/proc/self/cwd/" + ctx.file.host_dir.path), - env_entry(key = "QNX_TARGET", value = "/proc/self/cwd/" + ctx.file.target_dir.path), - env_entry(key = "QNX_CONFIGURATION_EXCLUSIVE", value = "/var/tmp/.qnx"), - env_entry(key = "QNX_SHARED_LICENSE_FILE", value = "%{license_path}"), - ], - ), - env_set( - actions = all_compile_actions + all_link_actions, - env_entries = [env_entry(key = license_variable, value = license_value)] if license_value != "" else [], - with_features = [with_feature_set(features = ["qnx_license_env_info"])], - ) - ], - ) - - dependency_file_feature = feature( - name = "dependency_file", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.objc_compile, - ACTION_NAMES.objcpp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.clif_match, - ], - flag_groups = [flag_group( - flags = [ - "-Wc,-MD,%{dependency_file}", - "-Wp,-MD,%{dependency_file}", - ], - expand_if_available = "dependency_file", - )], - with_features = [ - with_feature_set(not_features = ["dependency_file_named_implicitly"]), - ], - ), - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.objc_compile, - ACTION_NAMES.objcpp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.clif_match, - ], - flag_groups = [flag_group(flags = [ - "-Wc,-MD", - "-Wp,-MD", - ])], - with_features = [ - with_feature_set(features = ["dependency_file_named_implicitly"]), - ], - ), - ], - ) - - # QNX uses -Wl,-rpath instead of -rpath - runtime_library_search_directories_feature = feature( - name = "runtime_library_search_directories", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - iterate_over = "runtime_library_search_directories", - flag_groups = [ - flag_group( - flags = ["-Wl,-rpath,$EXEC_ORIGIN/%{runtime_library_search_directories}"], - ), - ], - expand_if_available = "runtime_library_search_directories", - ), - ], - ), - ], - ) - - coverage_feature = feature(name = "coverage") - gcc_coverage_map_format_feature = feature( - name = "gcc_coverage_map_format", - provides = ["profile"], - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.preprocess_assemble, - ], - flag_groups = [flag_group( - expand_if_available = "gcov_gcno_file", - flags = ["-fprofile-arcs", "-ftest-coverage"], - )], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-lgcov"])], - ), - ], - ) - - # The order of the features is relevant, they are applied in this specific order. - # A command line parameter from a feature at the end of the list will appear - # after a command line parameter from a feature at the beginning of the list. - - features = [ - dbg_feature, - no_legacy_features_feature, - unfiltered_compile_flags_feature, - default_compile_flags_feature, - random_seed_feature, - include_paths_feature, - preprocessor_defines_feature, - extra_compile_flags_feature, - user_compile_flags_feature, - compiler_input_flags_feature, - compiler_output_flags_feature, - dependency_file_named_implicitly_feature, - dependency_file_feature, - default_link_flags_feature, - archiver_flags_feature, - linker_param_file_feature, - library_search_directories_feature, - shared_flag_feature, - output_execpath_flags_feature, - libraries_to_link_feature, - user_link_flags_feature, - coverage_feature, - extra_link_flags_feature, - opt_feature, - use_license_env_info_feautre, - sdp_env_feature, - supports_dynamic_linker_feature, - supports_pic_feature, - pic_feature, - runtime_library_search_directories_feature, - gcc_coverage_map_format_feature, - ] - - extra_rules_based_features = depset(ctx.attr.extra_enabled_features + ctx.attr.extra_known_features) - features.extend([convert_feature(extra_feature[FeatureInfo], enabled = extra_feature in ctx.attr.extra_enabled_features) for extra_feature in extra_rules_based_features.to_list()]) - - cxx_builtin_include_directories = [ - "/proc/self/cwd/{}".format(include_directory.path) - for include_directory in ctx.files.cxx_builtin_include_directories - ] - - # TODO: Once https://github.com/bazelbuild/rules_cc/issues/351 is fixed remove this. - tool_paths = [tool_path(name = "gcov", path = "gcov_wrapper")] - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - abi_version = "%{tc_cpu}-qnx%{sdp_version}", - abi_libc_version = "unknown", - compiler = "qcc", - cxx_builtin_include_directories = cxx_builtin_include_directories, - features = features, - action_configs = action_configs, - host_system_name = "local", - target_system_name = "%{tc_cpu}-qnx", - target_cpu = "%{tc_cpu}", - target_libc = "unknown", - toolchain_identifier = "%{tc_cpu}-qnx%{sdp_version}", - tool_paths = tool_paths, - ) - -cc_toolchain_config = rule( - implementation = _impl, - provides = [CcToolchainConfigInfo], - attrs = { - "ar_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "cc_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "cxx_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "gcov_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "strip_binary": attr.label(allow_single_file = True, executable = True, cfg = "exec", mandatory = True), - "host_dir": attr.label(allow_single_file = True, mandatory = True), - "target_dir": attr.label(allow_single_file = True, mandatory = True), - "target_cpu": attr.string(mandatory = True), - "target_os": attr.string(mandatory = True), - "cxx_builtin_include_directories": attr.label(allow_files = True, mandatory = True), - "extra_enabled_features": attr.label_list( - providers = [FeatureInfo], - default = [], - doc = """ -Extra `cc_feature` features to add to this toolchain in an initially enabled state. -This attribute has limited integration with `cc_feature`, and does not run additional correctness checks or handle things like `data` files. -This is only offered as a migration bridge for projects transitioning to rule-based toolchain configurations, or sharing of simple argument sets with older toolchains. -""", - ), - "extra_known_features": attr.label_list( - providers = [FeatureInfo], - default = [], - doc = """ -Extra `cc_feature` features to add to this toolchain in an initially disabled state. -This attribute has limited integration with `cc_feature`, and does not run additional correctness checks or handle things like `data` files. -This is only offered as a migration bridge for projects transitioning to rule-based toolchain configurations, or sharing of simple argument sets with older toolchains. -""", - ), - }, -) diff --git a/templates/qnx/cc_toolchain_flags.bzl.template b/templates/qnx/cc_toolchain_flags.bzl.template deleted file mode 100644 index 52c2bf3..0000000 --- a/templates/qnx/cc_toolchain_flags.bzl.template +++ /dev/null @@ -1,81 +0,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 -# ******************************************************************************* - -""" Common compile and link flags for GCC toolchains. -""" - -load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "flag_group") - -def get_flag_group(flags): - """Helper function to create a flag_group. - - Args: - flags (list[str]): A list of compiler or linker flags. - - Returns: - flag_group: A Bazel flag_group object containing the provided flags. - """ - if len(flags): - return [ - flag_group( - flags = flags, - ) - ] - return [] - -# Flags that should always be applied, without filtering. -UNFILTERED_COMPILE_FLAGS = get_flag_group([ - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - "-Wno-builtin-macro-redefined", -]) - -# Default compile flags when no specific build type is selected. -DEFAULT_COMPILE_FLAGS = get_flag_group([ - "-fno-canonical-system-headers", -]) - -# Default compile flags for C language when no specific build type is selected. -DEFAULT_C_COMPILE_FLAGS = get_flag_group([ - "-std=c11", -]) - -# Default compile flags for C++ language when no specific build type is selected. -DEFAULT_CXX_COMPILE_FLAGS = get_flag_group([ - "-D_QNX_SOURCE", - "-std=c++17", -]) - -# Debug compile flags. -DBG_COMPILE_FLAGS = get_flag_group([ - "-Og", - "-g3", -]) - -# Optimization compile flags. -OPT_COMPILE_FLAGS = get_flag_group([ - "-O2", - "-DNDEBUG", -]) - -# Default link flags when no specific build type is selected. -DEFAULT_LINK_FLAGS = get_flag_group([ - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--push-state", - "-Wl,--as-needed", - "-lc++", - "-lm", - "-Wl,--pop-state", -]) diff --git a/tests/.bazelversion b/tests/.bazelversion index e7fdef7..df5119e 100644 --- a/tests/.bazelversion +++ b/tests/.bazelversion @@ -1 +1 @@ -8.4.2 +8.7.0 diff --git a/tests/MODULE.bazel.lock b/tests/MODULE.bazel.lock index 15a6923..aa211b8 100644 --- a/tests/MODULE.bazel.lock +++ b/tests/MODULE.bazel.lock @@ -1,5 +1,5 @@ { - "lockFileVersion": 18, + "lockFileVersion": 24, "registryFileHashes": { "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", @@ -603,107 +603,9 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { - "@@aspect_rules_js+//npm:extensions.bzl%pnpm": { - "general": { - "bzlTransitiveDigest": "c+aduAtzWJ+Sfmy4J0UmLN9iqbGkiP1HPlR9NZBfOdU=", - "usagesDigest": "ZYGEy1FrDUNPBzAzD+ujlHkMEsVPMYOvpHm9RhUexUE=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "pnpm": { - "repoRuleId": "@@aspect_rules_js+//npm/private:npm_import.bzl%npm_import_rule", - "attributes": { - "package": "pnpm", - "version": "8.6.7", - "root_package": "", - "link_workspace": "", - "link_packages": {}, - "integrity": "sha512-vRIWpD/L4phf9Bk2o/O2TDR8fFoJnpYrp2TKqTIZF/qZ2/rgL3qKXzHofHgbXsinwMoSEigz28sqk3pQ+yMEQQ==", - "url": "", - "commit": "", - "patch_args": [ - "-p0" - ], - "patches": [], - "custom_postinstall": "", - "npm_auth": "", - "npm_auth_basic": "", - "npm_auth_username": "", - "npm_auth_password": "", - "lifecycle_hooks": [], - "extra_build_content": "load(\"@aspect_rules_js//js:defs.bzl\", \"js_binary\")\njs_binary(name = \"pnpm\", data = glob([\"package/**\"]), entry_point = \"package/dist/pnpm.cjs\", visibility = [\"//visibility:public\"])", - "generate_bzl_library_targets": false, - "extract_full_archive": true - } - }, - "pnpm__links": { - "repoRuleId": "@@aspect_rules_js+//npm/private:npm_import.bzl%npm_import_links", - "attributes": { - "package": "pnpm", - "version": "8.6.7", - "dev": false, - "root_package": "", - "link_packages": {}, - "deps": {}, - "transitive_closure": {}, - "lifecycle_build_target": false, - "lifecycle_hooks_env": [], - "lifecycle_hooks_execution_requirements": [ - "no-sandbox" - ], - "lifecycle_hooks_use_default_shell_env": false, - "bins": {}, - "npm_translate_lock_repo": "", - "package_visibility": [ - "//visibility:public" - ], - "replace_package": "" - } - } - }, - "recordedRepoMappingEntries": [ - [ - "aspect_bazel_lib+", - "bazel_skylib", - "bazel_skylib+" - ], - [ - "aspect_bazel_lib+", - "bazel_tools", - "bazel_tools" - ], - [ - "aspect_rules_js+", - "aspect_bazel_lib", - "aspect_bazel_lib+" - ], - [ - "aspect_rules_js+", - "bazel_features", - "bazel_features+" - ], - [ - "aspect_rules_js+", - "bazel_skylib", - "bazel_skylib+" - ], - [ - "aspect_rules_js+", - "bazel_tools", - "bazel_tools" - ], - [ - "bazel_features+", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@aspect_rules_py+//py:extensions.bzl%py_tools": { "general": { - "bzlTransitiveDigest": "dAWBz6nfg2GIP7kchPavcBdWoHNQ67aXhXo4MPJJqNk=", + "bzlTransitiveDigest": "13DN9p/N8uOU1SMHBh9nZIlptJtS3qP63UkXe+NH8SQ=", "usagesDigest": "NC1b49l5tenTBVWEUGzzC0j5Kg1GH+l5lBw5JRCldIU=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -843,39 +745,9 @@ ] } }, - "@@pybind11_bazel+//:internal_configure.bzl%internal_configure_extension": { - "general": { - "bzlTransitiveDigest": "G7xCmtNWXRuBtChRgB5OK5+gmM8Uoy8Mec/B7j3fhqs=", - "usagesDigest": "D1r3lfzMuUBFxgG8V6o0bQTLMk3GkaGOaPzw53wrwyw=", - "recordedFileInputs": { - "@@pybind11_bazel+//MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34" - }, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "pybind11": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "build_file": "@@pybind11_bazel+//:pybind11-BUILD.bazel", - "strip_prefix": "pybind11-2.12.0", - "urls": [ - "https://github.com/pybind/pybind11/archive/v2.12.0.zip" - ] - } - } - }, - "recordedRepoMappingEntries": [ - [ - "pybind11_bazel+", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@rules_buf+//buf:extensions.bzl%buf": { "general": { - "bzlTransitiveDigest": "nziVPz62Pjv2JecWM9NXmhpU/OjKhPz1MT9++4ObLUw=", + "bzlTransitiveDigest": "dSWqckK2ILN7aDIDHfv+Qrl1fb1hF7o7MDXY6T8C41s=", "usagesDigest": "vxN6C2h72rUERbAmd1476FWpxdxo1NhYoY5JSFXJT3g=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -898,92 +770,9 @@ ] } }, - "@@rules_fuzzing+//fuzzing/private:extensions.bzl%non_module_dependencies": { - "general": { - "bzlTransitiveDigest": "v2H25KPHEkN56IHR41S67Kzp5Xjxd75GBiazhON8jzc=", - "usagesDigest": "wy6ISK6UOcBEjj/mvJ/S3WeXoO67X+1llb9yPyFtPgc=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "platforms": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "urls": [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz" - ], - "sha256": "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74" - } - }, - "rules_python": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "sha256": "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8", - "strip_prefix": "rules_python-0.28.0", - "url": "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.0.tar.gz" - } - }, - "bazel_skylib": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "sha256": "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", - "urls": [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz" - ] - } - }, - "com_google_absl": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "urls": [ - "https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.1.zip" - ], - "strip_prefix": "abseil-cpp-20240116.1", - "integrity": "sha256-7capMWOvWyoYbUaHF/b+I2U6XLMaHmky8KugWvfXYuk=" - } - }, - "rules_fuzzing_oss_fuzz": { - "repoRuleId": "@@rules_fuzzing+//fuzzing/private/oss_fuzz:repository.bzl%oss_fuzz_repository", - "attributes": {} - }, - "honggfuzz": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "build_file": "@@rules_fuzzing+//:honggfuzz.BUILD", - "sha256": "6b18ba13bc1f36b7b950c72d80f19ea67fbadc0ac0bb297ec89ad91f2eaa423e", - "url": "https://github.com/google/honggfuzz/archive/2.5.zip", - "strip_prefix": "honggfuzz-2.5" - } - }, - "rules_fuzzing_jazzer": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_jar", - "attributes": { - "sha256": "ee6feb569d88962d59cb59e8a31eb9d007c82683f3ebc64955fd5b96f277eec2", - "url": "https://repo1.maven.org/maven2/com/code-intelligence/jazzer/0.20.1/jazzer-0.20.1.jar" - } - }, - "rules_fuzzing_jazzer_api": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_jar", - "attributes": { - "sha256": "f5a60242bc408f7fa20fccf10d6c5c5ea1fcb3c6f44642fec5af88373ae7aa1b", - "url": "https://repo1.maven.org/maven2/com/code-intelligence/jazzer-api/0.20.1/jazzer-api-0.20.1.jar" - } - } - }, - "recordedRepoMappingEntries": [ - [ - "rules_fuzzing+", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { - "bzlTransitiveDigest": "OlvsB0HsvxbR8ZN+J9Vf00X/+WVz/Y/5Xrq2LgcVfdo=", + "bzlTransitiveDigest": "03Qju4tW0vE+0RBuZGuV2A4Hx6AiSkdNahYvworx2aM=", "usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -1215,161 +1004,9 @@ ] } }, - "@@rules_rust+//crate_universe/private:internal_extensions.bzl%cu_nr": { - "general": { - "bzlTransitiveDigest": "oRwNDJU+OUmkvm5VgB12Uzf5d82zFgjjyx2akug8OTs=", - "usagesDigest": "dQ7SQZ7uSSL3vVKSMBKRxKJUm9OVrZZA+S1/QQfT570=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "cargo_bazel_bootstrap": { - "repoRuleId": "@@rules_rust+//cargo/private:cargo_bootstrap.bzl%cargo_bootstrap_repository", - "attributes": { - "srcs": [ - "@@rules_rust+//crate_universe:src/api.rs", - "@@rules_rust+//crate_universe:src/api/lockfile.rs", - "@@rules_rust+//crate_universe:src/cli.rs", - "@@rules_rust+//crate_universe:src/cli/generate.rs", - "@@rules_rust+//crate_universe:src/cli/query.rs", - "@@rules_rust+//crate_universe:src/cli/render.rs", - "@@rules_rust+//crate_universe:src/cli/splice.rs", - "@@rules_rust+//crate_universe:src/cli/vendor.rs", - "@@rules_rust+//crate_universe:src/config.rs", - "@@rules_rust+//crate_universe:src/context.rs", - "@@rules_rust+//crate_universe:src/context/crate_context.rs", - "@@rules_rust+//crate_universe:src/context/platforms.rs", - "@@rules_rust+//crate_universe:src/lib.rs", - "@@rules_rust+//crate_universe:src/lockfile.rs", - "@@rules_rust+//crate_universe:src/main.rs", - "@@rules_rust+//crate_universe:src/metadata.rs", - "@@rules_rust+//crate_universe:src/metadata/cargo_bin.rs", - "@@rules_rust+//crate_universe:src/metadata/cargo_tree_resolver.rs", - "@@rules_rust+//crate_universe:src/metadata/cargo_tree_rustc_wrapper.bat", - "@@rules_rust+//crate_universe:src/metadata/cargo_tree_rustc_wrapper.sh", - "@@rules_rust+//crate_universe:src/metadata/dependency.rs", - "@@rules_rust+//crate_universe:src/metadata/metadata_annotation.rs", - "@@rules_rust+//crate_universe:src/rendering.rs", - "@@rules_rust+//crate_universe:src/rendering/template_engine.rs", - "@@rules_rust+//crate_universe:src/rendering/templates/module_bzl.j2", - "@@rules_rust+//crate_universe:src/rendering/templates/partials/header.j2", - "@@rules_rust+//crate_universe:src/rendering/templates/partials/module/aliases_map.j2", - "@@rules_rust+//crate_universe:src/rendering/templates/partials/module/deps_map.j2", - "@@rules_rust+//crate_universe:src/rendering/templates/partials/module/repo_git.j2", - "@@rules_rust+//crate_universe:src/rendering/templates/partials/module/repo_http.j2", - "@@rules_rust+//crate_universe:src/rendering/templates/vendor_module.j2", - "@@rules_rust+//crate_universe:src/rendering/verbatim/alias_rules.bzl", - "@@rules_rust+//crate_universe:src/select.rs", - "@@rules_rust+//crate_universe:src/splicing.rs", - "@@rules_rust+//crate_universe:src/splicing/cargo_config.rs", - "@@rules_rust+//crate_universe:src/splicing/crate_index_lookup.rs", - "@@rules_rust+//crate_universe:src/splicing/splicer.rs", - "@@rules_rust+//crate_universe:src/test.rs", - "@@rules_rust+//crate_universe:src/utils.rs", - "@@rules_rust+//crate_universe:src/utils/starlark.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/glob.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/label.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/select.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/select_dict.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/select_list.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/select_scalar.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/select_set.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/serialize.rs", - "@@rules_rust+//crate_universe:src/utils/starlark/target_compatible_with.rs", - "@@rules_rust+//crate_universe:src/utils/symlink.rs", - "@@rules_rust+//crate_universe:src/utils/target_triple.rs" - ], - "binary": "cargo-bazel", - "cargo_lockfile": "@@rules_rust+//crate_universe:Cargo.lock", - "cargo_toml": "@@rules_rust+//crate_universe:Cargo.toml", - "version": "1.86.0", - "timeout": 900, - "rust_toolchain_cargo_template": "@rust_host_tools//:bin/{tool}", - "rust_toolchain_rustc_template": "@rust_host_tools//:bin/{tool}", - "compressed_windows_toolchain_names": false - } - } - }, - "moduleExtensionMetadata": { - "explicitRootModuleDirectDeps": [ - "cargo_bazel_bootstrap" - ], - "explicitRootModuleDirectDevDeps": [], - "useAllRepos": "NO", - "reproducible": false - }, - "recordedRepoMappingEntries": [ - [ - "bazel_features+", - "bazel_features_globals", - "bazel_features++version_extension+bazel_features_globals" - ], - [ - "bazel_features+", - "bazel_features_version", - "bazel_features++version_extension+bazel_features_version" - ], - [ - "rules_cc+", - "bazel_tools", - "bazel_tools" - ], - [ - "rules_cc+", - "cc_compatibility_proxy", - "rules_cc++compatibility_proxy+cc_compatibility_proxy" - ], - [ - "rules_cc+", - "rules_cc", - "rules_cc+" - ], - [ - "rules_cc++compatibility_proxy+cc_compatibility_proxy", - "rules_cc", - "rules_cc+" - ], - [ - "rules_rust+", - "bazel_features", - "bazel_features+" - ], - [ - "rules_rust+", - "bazel_skylib", - "bazel_skylib+" - ], - [ - "rules_rust+", - "bazel_tools", - "bazel_tools" - ], - [ - "rules_rust+", - "cui", - "rules_rust++cu+cui" - ], - [ - "rules_rust+", - "rrc", - "rules_rust++i2+rrc" - ], - [ - "rules_rust+", - "rules_cc", - "rules_cc+" - ], - [ - "rules_rust+", - "rules_rust", - "rules_rust+" - ] - ] - } - }, "@@score_bazel_cpp_toolchains+//extensions:gcc.bzl%gcc": { "general": { - "bzlTransitiveDigest": "uUsNFSfSSybb9eE3vhujRJ3STO1XYw/Su0MpWT8DZJI=", + "bzlTransitiveDigest": "9jkyV0giRrzeBMZmMRCNvE6Eij63D9zhSVHxzptk9Iw=", "usagesDigest": "dWr2zFjJ8fBvweFk2KWoZzQqJ+aKnb9A8QACQhKlUfw=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -1507,8 +1144,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "12.2.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": true } }, @@ -1534,8 +1170,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "12.2.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1561,8 +1196,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "15.3.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1588,8 +1222,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "12.2.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1615,8 +1248,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "15.3.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1644,8 +1276,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "12.2.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1671,8 +1302,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "12.2.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/qnx:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/qnx:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1698,8 +1328,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "", "gcc_version": "12.2.0", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/qnx:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/qnx:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1761,8 +1390,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "autosd10", "gcc_version": "", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } }, @@ -1840,8 +1468,7 @@ "tc_system_toolchain": false, "tc_runtime_ecosystem": "ebclfsa", "gcc_version": "", - "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_config.bzl.template", - "cc_toolchain_flags": "@@score_bazel_cpp_toolchains+//templates/linux:cc_toolchain_flags.bzl.template", + "cc_toolchain_config": "@@score_bazel_cpp_toolchains+//templates:cc_toolchain_config.bzl.template", "use_base_constraints_only": false } } @@ -1872,7 +1499,7 @@ }, "@@score_rules_imagefs+//extensions:imagefs.bzl%imagefs": { "general": { - "bzlTransitiveDigest": "x/MeLfkCFKL5zGGdqxO8ikFOoWzlkB1VBe5tts2t0NI=", + "bzlTransitiveDigest": "4qMGnB7+T2rXYxW5iSvXX6nlCv/jNBvR6B0r5AHvEQQ=", "usagesDigest": "4LvOoMbWgpZh1KrPMaxsrJ/9n3DRlU6JijkThVx2Cw0=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -1923,5 +1550,171 @@ ] } } + }, + "facts": { + "@@rules_go+//go:extensions.bzl%go_sdk": { + "1.25.0": { + "aix_ppc64": [ + "go1.25.0.aix-ppc64.tar.gz", + "e5234a7dac67bc86c528fe9752fc9d63557918627707a733ab4cac1a6faed2d4" + ], + "darwin_amd64": [ + "go1.25.0.darwin-amd64.tar.gz", + "5bd60e823037062c2307c71e8111809865116714d6f6b410597cf5075dfd80ef" + ], + "darwin_arm64": [ + "go1.25.0.darwin-arm64.tar.gz", + "544932844156d8172f7a28f77f2ac9c15a23046698b6243f633b0a0b00c0749c" + ], + "dragonfly_amd64": [ + "go1.25.0.dragonfly-amd64.tar.gz", + "5ed3cf9a810a1483822538674f1336c06b51aa1b94d6d545a1a0319a48177120" + ], + "freebsd_386": [ + "go1.25.0.freebsd-386.tar.gz", + "abea5d5c6697e6b5c224731f2158fe87c602996a2a233ac0c4730cd57bf8374e" + ], + "freebsd_amd64": [ + "go1.25.0.freebsd-amd64.tar.gz", + "86e6fe0a29698d7601c4442052dac48bd58d532c51cccb8f1917df648138730b" + ], + "freebsd_arm": [ + "go1.25.0.freebsd-arm.tar.gz", + "d90b78e41921f72f30e8bbc81d9dec2cff7ff384a33d8d8debb24053e4336bfe" + ], + "freebsd_arm64": [ + "go1.25.0.freebsd-arm64.tar.gz", + "451d0da1affd886bfb291b7c63a6018527b269505db21ce6e14724f22ab0662e" + ], + "freebsd_riscv64": [ + "go1.25.0.freebsd-riscv64.tar.gz", + "7b565f76bd8bda46549eeaaefe0e53b251e644c230577290c0f66b1ecdb3cdbe" + ], + "illumos_amd64": [ + "go1.25.0.illumos-amd64.tar.gz", + "b1e1fdaab1ad25aa1c08d7a36c97d45d74b98b89c3f78c6d2145f77face54a2c" + ], + "linux_386": [ + "go1.25.0.linux-386.tar.gz", + "8c602dd9d99bc9453b3995d20ce4baf382cc50855900a0ece5de9929df4a993a" + ], + "linux_amd64": [ + "go1.25.0.linux-amd64.tar.gz", + "2852af0cb20a13139b3448992e69b868e50ed0f8a1e5940ee1de9e19a123b613" + ], + "linux_arm64": [ + "go1.25.0.linux-arm64.tar.gz", + "05de75d6994a2783699815ee553bd5a9327d8b79991de36e38b66862782f54ae" + ], + "linux_armv6l": [ + "go1.25.0.linux-armv6l.tar.gz", + "a5a8f8198fcf00e1e485b8ecef9ee020778bf32a408a4e8873371bfce458cd09" + ], + "linux_loong64": [ + "go1.25.0.linux-loong64.tar.gz", + "cab86b1cf761b1cb3bac86a8877cfc92e7b036fc0d3084123d77013d61432afc" + ], + "linux_mips": [ + "go1.25.0.linux-mips.tar.gz", + "d66b6fb74c3d91b9829dc95ec10ca1f047ef5e89332152f92e136cf0e2da5be1" + ], + "linux_mips64": [ + "go1.25.0.linux-mips64.tar.gz", + "4082e4381a8661bc2a839ff94ba3daf4f6cde20f8fb771b5b3d4762dc84198a2" + ], + "linux_mips64le": [ + "go1.25.0.linux-mips64le.tar.gz", + "70002c299ec7f7175ac2ef673b1b347eecfa54ae11f34416a6053c17f855afcc" + ], + "linux_mipsle": [ + "go1.25.0.linux-mipsle.tar.gz", + "b00a3a39eff099f6df9f1c7355bf28e4589d0586f42d7d4a394efb763d145a73" + ], + "linux_ppc64": [ + "go1.25.0.linux-ppc64.tar.gz", + "df166f33bd98160662560a72ff0b4ba731f969a80f088922bddcf566a88c1ec1" + ], + "linux_ppc64le": [ + "go1.25.0.linux-ppc64le.tar.gz", + "0f18a89e7576cf2c5fa0b487a1635d9bcbf843df5f110e9982c64df52a983ad0" + ], + "linux_riscv64": [ + "go1.25.0.linux-riscv64.tar.gz", + "c018ff74a2c48d55c8ca9b07c8e24163558ffec8bea08b326d6336905d956b67" + ], + "linux_s390x": [ + "go1.25.0.linux-s390x.tar.gz", + "34e5a2e19f2292fbaf8783e3a241e6e49689276aef6510a8060ea5ef54eee408" + ], + "netbsd_386": [ + "go1.25.0.netbsd-386.tar.gz", + "f8586cdb7aa855657609a5c5f6dbf523efa00c2bbd7c76d3936bec80aa6c0aba" + ], + "netbsd_amd64": [ + "go1.25.0.netbsd-amd64.tar.gz", + "ae8dc1469385b86a157a423bb56304ba45730de8a897615874f57dd096db2c2a" + ], + "netbsd_arm": [ + "go1.25.0.netbsd-arm.tar.gz", + "1ff7e4cc764425fc9dd6825eaee79d02b3c7cafffbb3691687c8d672ade76cb7" + ], + "netbsd_arm64": [ + "go1.25.0.netbsd-arm64.tar.gz", + "e1b310739f26724216aa6d7d7208c4031f9ff54c9b5b9a796ddc8bebcb4a5f16" + ], + "openbsd_386": [ + "go1.25.0.openbsd-386.tar.gz", + "4802a9b20e533da91adb84aab42e94aa56cfe3e5475d0550bed3385b182e69d8" + ], + "openbsd_amd64": [ + "go1.25.0.openbsd-amd64.tar.gz", + "c016cd984bebe317b19a4f297c4f50def120dc9788490540c89f28e42f1dabe1" + ], + "openbsd_arm": [ + "go1.25.0.openbsd-arm.tar.gz", + "a1e31d0bf22172ddde42edf5ec811ef81be43433df0948ece52fecb247ccfd8d" + ], + "openbsd_arm64": [ + "go1.25.0.openbsd-arm64.tar.gz", + "343ea8edd8c218196e15a859c6072d0dd3246fbbb168481ab665eb4c4140458d" + ], + "openbsd_ppc64": [ + "go1.25.0.openbsd-ppc64.tar.gz", + "694c14da1bcaeb5e3332d49bdc2b6d155067648f8fe1540c5de8f3cf8e157154" + ], + "openbsd_riscv64": [ + "go1.25.0.openbsd-riscv64.tar.gz", + "aa510ad25cf54c06cd9c70b6d80ded69cb20188ac6e1735655eef29ff7e7885f" + ], + "plan9_386": [ + "go1.25.0.plan9-386.tar.gz", + "46f8cef02086cf04bf186c5912776b56535178d4cb319cd19c9fdbdd29231986" + ], + "plan9_amd64": [ + "go1.25.0.plan9-amd64.tar.gz", + "29b34391d84095e44608a228f63f2f88113a37b74a79781353ec043dfbcb427b" + ], + "plan9_arm": [ + "go1.25.0.plan9-arm.tar.gz", + "0a047107d13ebe7943aaa6d54b1d7bbd2e45e68ce449b52915a818da715799c2" + ], + "solaris_amd64": [ + "go1.25.0.solaris-amd64.tar.gz", + "9977f9e4351984364a3b2b78f8b88bfd1d339812356d5237678514594b7d3611" + ], + "windows_386": [ + "go1.25.0.windows-386.zip", + "df9f39db82a803af0db639e3613a36681ab7a42866b1384b3f3a1045663961a7" + ], + "windows_amd64": [ + "go1.25.0.windows-amd64.zip", + "89efb4f9b30812eee083cc1770fdd2913c14d301064f6454851428f9707d190b" + ], + "windows_arm64": [ + "go1.25.0.windows-arm64.zip", + "27bab004c72b3d7bd05a69b6ec0fc54a309b4b78cc569dd963d8b3ec28bfdb8c" + ] + } + } } }