Skip to content

Commit 5089105

Browse files
keithmarcalfflalitbThomsonTan
authored
[bazel] Bump version and deps (#2679)
--------- Co-authored-by: Marc Alff <[email protected]> Co-authored-by: Lalit Kumar Bhasin <[email protected]> Co-authored-by: Tom Tan <[email protected]>
1 parent 3efd3ce commit 5089105

File tree

9 files changed

+82
-128
lines changed

9 files changed

+82
-128
lines changed

.bazelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
# bazel configurations for running tests under sanitizers.
55
# Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc
66

7+
# TODO: Remove once support is added, avoid MODULE.bazel creation for now
8+
common --enable_bzlmod=false
9+
710
# Enable automatic configs based on platform
811
common --enable_platform_specific_config
912

1013
# Needed by gRPC to build on some platforms.
1114
build --copt -DGRPC_BAZEL_BUILD
1215

16+
# Workaround abseil libraries missing symbols
17+
build:windows --dynamic_mode=off
18+
1319
# Set minimum supported C++ version
1420
build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14
1521
build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.4.1
1+
7.1.1

.github/workflows/ci.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -558,27 +558,6 @@ jobs:
558558
- name: run tests
559559
run: ./ci/do_ci.sh bazel.with_async_export.test
560560

561-
bazel_with_abseil:
562-
name: Bazel with external abseil
563-
runs-on: ubuntu-latest
564-
steps:
565-
- uses: actions/checkout@v4
566-
with:
567-
submodules: 'recursive'
568-
- name: Mount Bazel Cache
569-
uses: actions/cache@v4
570-
env:
571-
cache-name: bazel_cache
572-
with:
573-
path: /home/runner/.cache/bazel
574-
key: bazel_test
575-
- name: setup
576-
run: |
577-
sudo ./ci/setup_ci_environment.sh
578-
sudo ./ci/install_bazelisk.sh
579-
- name: run tests
580-
run: ./ci/do_ci.sh bazel.with_abseil
581-
582561
bazel_valgrind:
583562
name: Bazel valgrind
584563
runs-on: ubuntu-latest

api/BUILD

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
4+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
55

66
package(default_visibility = ["//visibility:public"])
77

8-
bool_flag(
9-
name = "with_abseil",
10-
build_setting_default = False,
11-
)
12-
138
CPP_STDLIBS = [
149
"none",
1510
"best",
@@ -28,10 +23,7 @@ string_flag(
2823
cc_library(
2924
name = "api",
3025
hdrs = glob(["include/**/*.h"]),
31-
defines = select({
32-
":with_external_abseil": ["HAVE_ABSEIL"],
33-
"//conditions:default": [],
34-
}) + select({
26+
defines = ["HAVE_ABSEIL"] + select({
3527
":set_cxx_stdlib_none": [],
3628
### automatic selection
3729
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
@@ -46,19 +38,11 @@ cc_library(
4638
}),
4739
strip_include_prefix = "include",
4840
tags = ["api"],
49-
deps = select({
50-
":with_external_abseil": [
51-
"@com_google_absl//absl/base",
52-
"@com_google_absl//absl/strings",
53-
"@com_google_absl//absl/types:variant",
54-
],
55-
"//conditions:default": [],
56-
}),
57-
)
58-
59-
config_setting(
60-
name = "with_external_abseil",
61-
flag_values = {":with_abseil": "true"},
41+
deps = [
42+
"@com_google_absl//absl/base",
43+
"@com_google_absl//absl/strings",
44+
"@com_google_absl//absl/types:variant",
45+
],
6246
)
6347

6448
[config_setting(

api/test/singleton/BUILD

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
DEFAULT_WIN_COPTS = [
5-
]
6-
74
# gcc and clang, assumed to be used on this platform
85
DEFAULT_NOWIN_COPTS = [
96
"-fvisibility=default",
107
]
118

12-
HIDDEN_WIN_COPTS = [
13-
]
14-
159
# gcc and clang, assumed to be used on this platform
1610
HIDDEN_NOWIN_COPTS = [
1711
"-fvisibility=hidden",
@@ -26,6 +20,10 @@ cc_library(
2620
"component_a.h",
2721
],
2822
linkstatic = True,
23+
target_compatible_with = select({
24+
"//bazel:windows": ["@platforms//:incompatible"],
25+
"//conditions:default": [],
26+
}),
2927
deps = [
3028
"//api",
3129
],
@@ -40,6 +38,10 @@ cc_library(
4038
"component_b.h",
4139
],
4240
linkstatic = True,
41+
target_compatible_with = select({
42+
"//bazel:windows": ["@platforms//:incompatible"],
43+
"//conditions:default": [],
44+
}),
4345
deps = [
4446
"//api",
4547
],
@@ -53,11 +55,12 @@ cc_library(
5355
hdrs = [
5456
"component_c.h",
5557
],
56-
copts = select({
57-
"//bazel:windows": DEFAULT_WIN_COPTS,
58-
"//conditions:default": DEFAULT_NOWIN_COPTS,
59-
}),
58+
copts = DEFAULT_NOWIN_COPTS,
6059
linkstatic = False,
60+
target_compatible_with = select({
61+
"//bazel:windows": ["@platforms//:incompatible"],
62+
"//conditions:default": [],
63+
}),
6164
deps = [
6265
"//api",
6366
],
@@ -71,11 +74,12 @@ cc_library(
7174
hdrs = [
7275
"component_d.h",
7376
],
74-
copts = select({
75-
"//bazel:windows": HIDDEN_WIN_COPTS,
76-
"//conditions:default": HIDDEN_NOWIN_COPTS,
77-
}),
77+
copts = HIDDEN_NOWIN_COPTS,
7878
linkstatic = False,
79+
target_compatible_with = select({
80+
"//bazel:windows": ["@platforms//:incompatible"],
81+
"//conditions:default": [],
82+
}),
7983
deps = [
8084
"//api",
8185
],
@@ -89,11 +93,12 @@ cc_library(
8993
hdrs = [
9094
"component_e.h",
9195
],
92-
copts = select({
93-
"//bazel:windows": DEFAULT_WIN_COPTS,
94-
"//conditions:default": DEFAULT_NOWIN_COPTS,
95-
}),
96+
copts = DEFAULT_NOWIN_COPTS,
9697
linkstatic = False,
98+
target_compatible_with = select({
99+
"//bazel:windows": ["@platforms//:incompatible"],
100+
"//conditions:default": [],
101+
}),
97102
deps = [
98103
"//api",
99104
],
@@ -107,11 +112,12 @@ cc_library(
107112
hdrs = [
108113
"component_f.h",
109114
],
110-
copts = select({
111-
"//bazel:windows": HIDDEN_WIN_COPTS,
112-
"//conditions:default": HIDDEN_NOWIN_COPTS,
113-
}),
115+
copts = HIDDEN_NOWIN_COPTS,
114116
linkstatic = False,
117+
target_compatible_with = select({
118+
"//bazel:windows": ["@platforms//:incompatible"],
119+
"//conditions:default": [],
120+
}),
115121
deps = [
116122
"//api",
117123
],
@@ -123,11 +129,12 @@ cc_binary(
123129
srcs = [
124130
"component_g.cc",
125131
],
126-
copts = select({
127-
"//bazel:windows": DEFAULT_WIN_COPTS,
128-
"//conditions:default": DEFAULT_NOWIN_COPTS,
129-
}),
132+
copts = DEFAULT_NOWIN_COPTS,
130133
linkshared = True,
134+
target_compatible_with = select({
135+
"//bazel:windows": ["@platforms//:incompatible"],
136+
"//conditions:default": [],
137+
}),
131138
deps = [
132139
"//api",
133140
],
@@ -139,11 +146,12 @@ cc_binary(
139146
srcs = [
140147
"component_h.cc",
141148
],
142-
copts = select({
143-
"//bazel:windows": HIDDEN_WIN_COPTS,
144-
"//conditions:default": HIDDEN_NOWIN_COPTS,
145-
}),
149+
copts = HIDDEN_NOWIN_COPTS,
146150
linkshared = True,
151+
target_compatible_with = select({
152+
"//bazel:windows": ["@platforms//:incompatible"],
153+
"//conditions:default": [],
154+
}),
147155
deps = [
148156
"//api",
149157
],
@@ -176,6 +184,10 @@ cc_test(
176184
"api",
177185
"test",
178186
],
187+
target_compatible_with = select({
188+
"//bazel:windows": ["@platforms//:incompatible"],
189+
"//conditions:default": [],
190+
}),
179191
deps = [
180192
"component_a",
181193
"component_b",

bazel/repository.bzl

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
54
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
6-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
7-
8-
_ALL_CONTENT = """
9-
filegroup(
10-
name = "all_srcs",
11-
srcs = glob(["**"]),
12-
visibility = ["//visibility:public"],
13-
)
14-
"""
5+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
156

167
#
178
# MAINTAINER
@@ -55,54 +46,40 @@ def opentelemetry_cpp_deps():
5546

5647
# Load abseil dependency(optional)
5748
maybe(
58-
#
59-
# Important note:
60-
#
61-
# The bazel build uses abseil-cpp-20230802.2 here,
62-
# while CMake uses more recent versions.
63-
#
64-
# bazel with abseil-cpp-20240116.2 : build failures in CI
65-
# bazel with abseil-cpp-20240116.1 : build failures in CI
66-
#
67-
# TODO: Fix issue #2619
68-
#
6949
http_archive,
7050
name = "com_google_absl",
71-
sha256 = "7c11539617af1f332f0854a6fb21e296a1b29c27d03f23c7b49d4adefcd102cc",
72-
strip_prefix = "abseil-cpp-20230802.2",
51+
sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc",
52+
strip_prefix = "abseil-cpp-20240116.2",
7353
urls = [
74-
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.2.tar.gz",
54+
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.2.tar.gz",
7555
],
7656
)
7757

78-
# Load gRPC dependency
58+
# gRPC transitively depends on apple_support and rules_apple at older
59+
# versions. Bazel 7.x requires newer versions of these rules. By loading
60+
# them before grpc, these newer versions are preferrred.
7961
maybe(
8062
http_archive,
81-
name = "com_github_grpc_grpc_legacy",
82-
sha256 = "024118069912358e60722a2b7e507e9c3b51eeaeee06e2dd9d95d9c16f6639ec",
83-
strip_prefix = "grpc-1.39.1",
84-
urls = [
85-
"https://github.com/grpc/grpc/archive/v1.39.1.tar.gz",
86-
],
63+
name = "build_bazel_apple_support",
64+
sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80",
65+
url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
8766
)
8867

8968
maybe(
9069
http_archive,
91-
name = "com_github_grpc_grpc_latest11",
92-
sha256 = "e266aa0d9d9cddb876484a370b94f468248594a96ca0b6f87c21f969db2b8c5b",
93-
strip_prefix = "grpc-1.46.4",
94-
urls = [
95-
"https://github.com/grpc/grpc/archive/v1.46.4.tar.gz",
96-
],
70+
name = "build_bazel_rules_apple",
71+
sha256 = "b4df908ec14868369021182ab191dbd1f40830c9b300650d5dc389e0b9266c8d",
72+
url = "https://github.com/bazelbuild/rules_apple/releases/download/3.5.1/rules_apple.3.5.1.tar.gz",
9773
)
9874

75+
# Load gRPC dependency
9976
maybe(
10077
http_archive,
10178
name = "com_github_grpc_grpc",
102-
sha256 = "cdeb805385fba23242bf87073e68d590c446751e09089f26e5e0b3f655b0f089",
103-
strip_prefix = "grpc-1.49.2",
79+
sha256 = "f40bde4ce2f31760f65dc49a2f50876f59077026494e67dccf23992548b1b04f",
80+
strip_prefix = "grpc-1.62.0",
10481
urls = [
105-
"https://github.com/grpc/grpc/archive/v1.49.2.tar.gz",
82+
"https://github.com/grpc/grpc/archive/refs/tags/v1.62.0.tar.gz",
10683
],
10784
)
10885

@@ -144,10 +121,10 @@ def opentelemetry_cpp_deps():
144121
maybe(
145122
http_archive,
146123
name = "platforms",
147-
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
124+
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
148125
urls = [
149-
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
150-
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
126+
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
127+
"https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
151128
],
152129
)
153130

ci/do_ci.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ $nproc = (Get-ComputerInfo).CsNumberOfLogicalProcessors
1010

1111
$SRC_DIR = (Get-Item -Path ".\").FullName
1212

13+
# Workaround https://github.com/bazelbuild/bazel/issues/18683
14+
$BAZEL_STARTUP_OPTIONS = "--output_base=C:\Out"
1315
$BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT"
1416
$BAZEL_TEST_OPTIONS = "$BAZEL_OPTIONS --test_output=errors"
1517

@@ -27,7 +29,7 @@ $VCPKG_DIR = Join-Path "$SRC_DIR" "tools" "vcpkg"
2729

2830
switch ($action) {
2931
"bazel.build" {
30-
bazel build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //...
32+
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //...
3133
$exit = $LASTEXITCODE
3234
if ($exit -ne 0) {
3335
exit $exit

ci/do_ci.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,6 @@ elif [[ "$1" == "cmake.install.test" ]]; then
425425
make -j $(nproc)
426426
sudo make install
427427
exit 0
428-
elif [[ "$1" == "bazel.with_abseil" ]]; then
429-
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC --//api:with_abseil=true //...
430-
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS_ASYNC --//api:with_abseil=true //...
431-
exit 0
432428
elif [[ "$1" == "cmake.test_example_plugin" ]]; then
433429
# Build the plugin
434430
cd "${BUILD_DIR}"
@@ -507,7 +503,7 @@ elif [[ "$1" == "bazel.tsan" ]]; then
507503
exit 0
508504
elif [[ "$1" == "bazel.valgrind" ]]; then
509505
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC //...
510-
bazel $BAZEL_STARTUP_OPTIONS test --run_under="/usr/bin/valgrind --leak-check=full --error-exitcode=1 --suppressions=\"${SRC_DIR}/ci/valgrind-suppressions\"" $BAZEL_TEST_OPTIONS_ASYNC //...
506+
bazel $BAZEL_STARTUP_OPTIONS test --run_under="/usr/bin/valgrind --leak-check=full --error-exitcode=1 --errors-for-leak-kinds=definite --suppressions=\"${SRC_DIR}/ci/valgrind-suppressions\"" $BAZEL_TEST_OPTIONS_ASYNC //...
511507
exit 0
512508
elif [[ "$1" == "bazel.e2e" ]]; then
513509
cd examples/e2e

0 commit comments

Comments
 (0)