Skip to content

Commit 245d728

Browse files
authored
Upgrade to bazel 7 (#2297)
1 parent d42bc14 commit 245d728

File tree

7 files changed

+95
-42
lines changed

7 files changed

+95
-42
lines changed

.bazelrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Global bazelrc file, see https://docs.bazel.build/versions/master/guide.html#bazelrc.
22

3+
common --noenable_bzlmod --enable_workspace
4+
35
# Use strict action env to prevent leaks of env vars.
46
build --incompatible_strict_action_env
57

@@ -97,7 +99,7 @@ test:aarch64_sysroot --test_tag_filters=-no_libcpp,-requires_root,-requires_bpf,
9799
# Build for Clang using Libc++.
98100
build:clang --config=clang-base
99101
build:clang --//bazel:enable_libcpp
100-
build:clang --features=libc++ --features=-libstdc++
102+
build:clang --features=libc++ --features=-libstdc++ --host_features=libc++ --host_features=-libstdc++
101103
build:clang --build_tag_filters=-no_libcpp
102104
build:clang --test_tag_filters=-no_libcpp,-requires_root,-requires_bpf,-disabled
103105
test:clang --config=tmp-sandbox
@@ -110,7 +112,7 @@ test:clang-libstdc++ --config=tmp-sandbox
110112

111113
build:qemu-bpf --config=clang-base
112114
build:qemu-bpf --//bazel:enable_libcpp
113-
build:qemu-bpf --features=libc++ --features=-libstdc++
115+
build:qemu-bpf --features=libc++ --features=-libstdc++ --host_features=libc++ --host_features=-libstdc++
114116
build:qemu-bpf --build_tag_filters=requires_bpf,requires_root,-no_qemu,-no_libcpp
115117
build:qemu-bpf --test_tag_filters=requires_bpf,requires_root,-no_qemu,-no_libcpp,-disabled
116118
build:qemu-bpf --sandbox_fake_username

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.5.0
1+
7.7.1
Lines changed: 76 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
2-
--- a/cc_toolchain_config.bzl 2023-01-06 15:34:50.000000000 -0800
3-
+++ b/cc_toolchain_config.bzl 2023-01-22 15:33:16.794758043 -0800
4-
@@ -27,6 +27,7 @@
5-
"with_feature_set",
6-
)
1+
diff --git a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
2+
index 1dd0e7a6e7..29b59c6325 100644
3+
--- a/cc_toolchain_config.bzl
4+
+++ b/cc_toolchain_config.bzl
5+
@@ -15,6 +15,7 @@
6+
"""A Starlark cc_toolchain configuration rule"""
7+
78
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
89
+load(":toolchain_features.bzl", "pl_toolchain_pre_features", "PL_EXTRA_CC_CONFIG_ATTRS", "pl_toolchain_post_features", "pl_action_configs")
9-
10-
def layering_check_features(compiler):
11-
if compiler != "clang":
12-
@@ -147,7 +148,7 @@
10+
load(
11+
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
12+
"action_config",
13+
@@ -228,7 +229,7 @@ def _impl(ctx):
1314
tool_path(name = name, path = path)
1415
for name, path in ctx.attr.tool_paths.items()
1516
]
@@ -18,7 +19,7 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
1819

1920
llvm_cov_action = action_config(
2021
action_name = ACTION_NAMES.llvm_cov,
21-
@@ -168,6 +169,10 @@
22+
@@ -278,6 +279,10 @@ def _impl(ctx):
2223
name = "supports_start_end_lib",
2324
enabled = True,
2425
)
@@ -27,9 +28,9 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
2728
+ enabled = True,
2829
+ )
2930

30-
default_compile_flags_feature = feature(
31-
name = "default_compile_flags",
32-
@@ -203,7 +208,7 @@
31+
gcc_quoting_for_param_files_feature = feature(
32+
name = "gcc_quoting_for_param_files",
33+
@@ -323,7 +328,7 @@ def _impl(ctx):
3334
flags = ctx.attr.dbg_compile_flags,
3435
),
3536
] if ctx.attr.dbg_compile_flags else []),
@@ -38,49 +39,89 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
3839
),
3940
flag_set(
4041
actions = all_compile_actions,
41-
@@ -212,7 +217,7 @@
42+
@@ -332,7 +337,7 @@ def _impl(ctx):
4243
flags = ctx.attr.opt_compile_flags,
4344
),
4445
] if ctx.attr.opt_compile_flags else []),
4546
- with_features = [with_feature_set(features = ["opt"])],
4647
+ with_features = [with_feature_set(features = ["opt", "default_opt_level_flags"])],
4748
),
4849
flag_set(
49-
actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend],
50-
@@ -244,7 +249,7 @@
50+
actions = [ACTION_NAMES.c_compile],
51+
@@ -372,7 +377,7 @@ def _impl(ctx):
5152
flags = ctx.attr.opt_link_flags,
5253
),
5354
] if ctx.attr.opt_link_flags else []),
5455
- with_features = [with_feature_set(features = ["opt"])],
5556
+ with_features = [with_feature_set(features = ["opt", "default_opt_level_flags"])],
5657
),
5758
],
59+
env_sets = [
60+
@@ -1473,27 +1478,6 @@ def _impl(ctx):
61+
enabled = True,
5862
)
59-
@@ -1255,6 +1260,7 @@
63+
64+
- asan_feature = _sanitizer_feature(
65+
- name = "asan",
66+
- specific_compile_flags = [
67+
- "-fsanitize=address",
68+
- "-fno-common",
69+
- ],
70+
- specific_link_flags = [
71+
- "-fsanitize=address",
72+
- ],
73+
- )
74+
-
75+
- tsan_feature = _sanitizer_feature(
76+
- name = "tsan",
77+
- specific_compile_flags = [
78+
- "-fsanitize=thread",
79+
- ],
80+
- specific_link_flags = [
81+
- "-fsanitize=thread",
82+
- ],
83+
- )
84+
-
85+
ubsan_feature = _sanitizer_feature(
86+
name = "ubsan",
87+
specific_compile_flags = [
88+
@@ -1569,11 +1553,10 @@ def _impl(ctx):
6089
strip_debug_symbols_feature,
6190
coverage_feature,
6291
supports_pic_feature,
92+
- asan_feature,
93+
- tsan_feature,
94+
ubsan_feature,
95+
gcc_quoting_for_param_files_feature,
96+
static_link_cpp_runtimes_feature,
6397
+ default_opt_level_flags_feature,
6498
] + (
6599
[
66100
supports_start_end_lib_feature,
67-
@@ -1276,6 +1282,7 @@
68-
else:
69-
features = [
70-
supports_pic_feature,
101+
@@ -1613,11 +1596,10 @@ def _impl(ctx):
102+
set_install_name_feature,
103+
libtool_feature,
104+
archiver_flags_feature,
105+
- asan_feature,
106+
- tsan_feature,
107+
ubsan_feature,
108+
gcc_quoting_for_param_files_feature,
109+
static_link_cpp_runtimes_feature,
71110
+ default_opt_level_flags_feature,
72111
] + (
73112
[
74113
supports_start_end_lib_feature,
75-
@@ -1294,6 +1301,7 @@
76-
unfiltered_compile_flags_feature,
77-
] + layering_check_features(ctx.attr.compiler)
114+
@@ -1643,8 +1625,8 @@ def _impl(ctx):
115+
parse_headers_action_configs, parse_headers_features = parse_headers_support(
116+
parse_headers_tool_path = ctx.attr.tool_paths.get("parse_headers"),
117+
)
118+
+ features = pl_toolchain_pre_features(ctx) + features + parse_headers_features + pl_toolchain_post_features(ctx)
119+
action_configs += parse_headers_action_configs
120+
- features += parse_headers_features
78121

79-
+ features = pl_toolchain_pre_features(ctx) + features + pl_toolchain_post_features(ctx)
80-
return cc_common.create_cc_toolchain_config_info(
81-
ctx = ctx,
82-
features = features,
83-
@@ -1313,7 +1321,7 @@
122+
if symbol_check:
123+
features.append(symbol_check)
124+
@@ -1669,7 +1651,7 @@ def _impl(ctx):
84125

85126
cc_toolchain_config = rule(
86127
implementation = _impl,
@@ -89,11 +130,12 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
89130
"cpu": attr.string(mandatory = True),
90131
"compiler": attr.string(mandatory = True),
91132
"toolchain_identifier": attr.string(mandatory = True),
92-
@@ -1336,6 +1344,6 @@
93-
"coverage_link_flags": attr.string_list(),
94-
"supports_start_end_lib": attr.bool(),
95-
"builtin_sysroot": attr.string(),
133+
@@ -1699,7 +1681,7 @@ cc_toolchain_config = rule(
134+
fragment = "apple",
135+
name = "xcode_config_label",
136+
)),
96137
- },
97138
+ }, **PL_EXTRA_CC_CONFIG_ATTRS),
139+
fragments = ["apple", "cpp"],
98140
provides = [CcToolchainConfigInfo],
99141
)

bazel/pl_build_system.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def pl_common_linkopts():
9595
"-lunwind",
9696
],
9797
# The OSX system library transitively links common libraries (e.g., pthread).
98-
"@bazel_tools//tools/osx:darwin": [],
98+
"@bazel_tools//tools/osx:darwin_arm64": [],
99+
"@bazel_tools//tools/osx:darwin_x86_64": [],
99100
"//conditions:default": [
100101
"-pthread",
101102
"-lunwind",

bazel/repository_locations.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ REPOSITORY_LOCATIONS = dict(
488488
],
489489
),
490490
unix_cc_toolchain_config = dict(
491-
sha256 = "2c1d60ef4d586909f138c28409780e102e2ebd619e7d462ded26dce43a8f9ffb",
491+
sha256 = "dfee9d4e56421497002c1bb932a1cf9323eca9273374419ca436e7d4b1421134",
492492
urls = [
493-
"https://raw.githubusercontent.com/bazelbuild/bazel/5.3.1/tools/cpp/unix_cc_toolchain_config.bzl",
493+
"https://raw.githubusercontent.com/bazelbuild/bazel/7.7.1/tools/cpp/unix_cc_toolchain_config.bzl",
494494
],
495495
),
496496
# GRPC and Protobuf pick different versions. Pick the newer one.

bazel/test_runners/qemu_with_kernel/launcher.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ RUN_QEMU_SCRIPT=%runqemuscript%
2525
# Create a tmp directory that serves as the /test_fs sanbox dir inside qemu.
2626
tmpdir_for_sandbox=$(mktemp -d)
2727

28+
# This file must be modified to signal to bazel that the qemu runner supports sharding.
29+
# Since this runner leverages bazel's test runner and only runs supported binaries
30+
# (googletest tests), we fulfill the requirement by touching this file.
31+
if [ -n "${TEST_SHARD_STATUS_FILE}" ]; then
32+
touch "${TEST_SHARD_STATUS_FILE}"
33+
fi
34+
2835
# shellcheck disable=SC2317
2936
function cleanup {
3037
retval=$?

ci/cquery_ignore_non_target_and_incompatible.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
def format(target):
1818
build_opts = build_options(target)
1919

20-
# We only want to get targets that are in the target configuration. So we ignore exec and host targets.
21-
if build_opts["//command_line_option:is exec configuration"] or build_opts["//command_line_option:is host configuration"]:
20+
# We only want to get targets that are in the target configuration. So we ignore exec targets.
21+
# Note: "is host configuration" was removed in Bazel 7 as host configuration was fully replaced by exec configuration.
22+
if build_opts["//command_line_option:is exec configuration"]:
2223
return None
2324

2425
# Ignore targets that are incompatible with the target configuration.

0 commit comments

Comments
 (0)