Skip to content

Commit afddadc

Browse files
committed
Add feature injection
Add feature injection to toolchain gcc extension. This option will allow users to add external defined features.
1 parent 332c9c9 commit afddadc

16 files changed

Lines changed: 145 additions & 373 deletions

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bazel_dep(name = "score_bazel_platforms", version = "0.1.2")
2727
# *******************************************************************************
2828
# C++ Rules for Bazel
2929
# *******************************************************************************
30-
bazel_dep(name = "rules_cc", version = "0.2.14")
30+
bazel_dep(name = "rules_cc", version = "0.2.17")
3131

3232
# *******************************************************************************
3333
# Needed by S-CORE CI Automatic checks

MODULE.bazel.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/examples_and_validation.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ platforms.
4545
`examples/BUILD`
4646

4747
Contains small C++ targets used to verify compilation, linking, pthread
48-
support, and sanitizer integration.
48+
support, and optional sanitizer integration when sanitizer features are
49+
registered explicitly.
4950

5051
`examples/test.sh`
5152

@@ -85,4 +86,12 @@ In practice this means checking among other things:
8586
- correct toolchain registration and platform matching,
8687
- basic linking behavior,
8788
- feature coverage such as pthread-enabled builds,
88-
- optional sanitizer feature wiring for the local Linux toolchain path.
89+
- optional sanitizer feature wiring for the local Linux toolchain path.
90+
91+
## Sanitizer Note
92+
93+
Sanitizer features are not included by default by the generated toolchains.
94+
If a workspace wants to use targets such as `asan_test`, it must first
95+
register the sanitizer `cc_feature` definitions explicitly, for example via
96+
`extra_known_features` or `extra_enabled_features` when declaring the
97+
toolchain and by providing the feature definitions from `score_cpp_policies`.

docs/extension_api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Flag and runtime attributes:
7272
- `extra_c_compile_flags`
7373
- `extra_cxx_compile_flags`
7474
- `extra_link_flags`
75+
- `extra_known_features`
76+
- `extra_enabled_features`
7577
- `ld_library_paths`
7678
- `runtime_ecosystem`
7779
- `use_base_constraints_only`
@@ -112,5 +114,9 @@ configurations for this activation step.
112114
- The extension is intended for the root module.
113115
- When `use_default_package` is enabled, the version matrix can inject extra
114116
include and link flags required by non-standard sysroot layouts.
117+
- Sanitizer features are not registered automatically. Workspaces that want
118+
sanitizer support must provide the relevant rule-based `cc_feature`
119+
definitions explicitly, typically from `score_cpp_policies`, through
120+
`extra_known_features` or `extra_enabled_features`.
115121
- QNX toolchains use additional licensing and include-path parameters that do
116122
not apply to Linux toolchains.

examples/BUILD

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,57 +51,3 @@ cc_test(
5151
linkstatic = False,
5252
deps = [":math_lib"],
5353
)
54-
55-
cc_test(
56-
name = "asan_test",
57-
srcs = ["asan_test.cpp"],
58-
features = ["asan"],
59-
deps = [
60-
"@googletest//:gtest",
61-
"@googletest//:gtest_main",
62-
],
63-
)
64-
65-
# for some reason this test is very flaky.
66-
# cc_test(
67-
# name = "tsan_test",
68-
# srcs = ["tsan_test.cpp"],
69-
# features = ["tsan"],
70-
# env = {
71-
# "TSAN_OPTIONS": "halt_on_error=1",
72-
# },
73-
# deps = [
74-
# "@googletest//:gtest",
75-
# "@googletest//:gtest_main",
76-
# ],
77-
# )
78-
79-
cc_test(
80-
name = "ubsan_test",
81-
srcs = ["ubsan_test.cpp"],
82-
env = {
83-
"UBSAN_OPTIONS": "halt_on_error=1",
84-
},
85-
features = ["ubsan"],
86-
deps = [
87-
"@googletest//:gtest",
88-
"@googletest//:gtest_main",
89-
],
90-
)
91-
92-
cc_test(
93-
name = "lsan_test",
94-
srcs = ["lsan_test.cpp"],
95-
env = {
96-
"ASAN_OPTIONS": "detect_leaks=1",
97-
"LSAN_OPTIONS": "exitcode=23",
98-
},
99-
features = [
100-
"lsan",
101-
"asan",
102-
],
103-
deps = [
104-
"@googletest//:gtest",
105-
"@googletest//:gtest_main",
106-
],
107-
)

examples/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bazel_dep(name = "score_bazel_platforms", version = "0.1.2")
3030
# *******************************************************************************
3131
# C++ Rules for Bazel
3232
# *******************************************************************************
33-
bazel_dep(name = "rules_cc", version = "0.2.14")
33+
bazel_dep(name = "rules_cc", version = "0.2.17")
3434
bazel_dep(name = "googletest", version = "1.17.0")
3535

3636
# *******************************************************************************

examples/MODULE.bazel.lock

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ The toolchain configurations are defined in:
1010

1111
## Building Targets
1212

13+
## Sanitizer Feature Registration
14+
15+
Sanitizer features are no longer included by default by the example toolchain
16+
declarations. Targets that request features such as `score_asan` require the
17+
workspace to register those feature definitions explicitly, for example from
18+
`score_cpp_policies` via `extra_known_features` or `extra_enabled_features` on
19+
the corresponding `gcc.toolchain(...)` declaration.
20+
21+
Without that explicit registration, sanitizer-specific example targets are not
22+
expected to build.
23+
1324
### Default Toolchain
1425

1526
Build a specific target with the default toolchain:

examples/asan_test.cpp

Lines changed: 0 additions & 36 deletions
This file was deleted.

examples/lsan_test.cpp

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)