Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bazel] Bump version and deps #2679

Merged
merged 26 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5571ef8
[bazel] Bump version and deps
keith Apr 22, 2024
42b8234
Remove old CI job
keith May 23, 2024
b42da16
Test windows fix
keith May 23, 2024
3878b14
grpc downgrade https://github.com/grpc/grpc/issues/36264
keith May 23, 2024
97286d9
try exporting
keith May 23, 2024
e20fa7a
disable possibly lost
keith May 23, 2024
fb47112
format
keith May 23, 2024
c589f4a
Attempt another CI fix
keith May 23, 2024
34121fc
Discard changes to api/test/singleton/component_c.cc
keith May 23, 2024
82fbbf0
Show doesn't matter, have to disable errors for possible
keith May 23, 2024
58dec69
try with dynamic_mode again
keith May 23, 2024
9fedbc2
another try
keith May 23, 2024
c2d07b2
syntax
keith May 23, 2024
373bdea
doc
keith May 23, 2024
dcd2493
Merge branch 'main' into ks/update-bazel-deps
marcalff May 27, 2024
07acca6
Disable api singleton test on windows
keith May 28, 2024
d1de2e9
swap flag
keith May 28, 2024
e6a12fc
Merge branch 'main' into ks/update-bazel-deps
lalitb May 29, 2024
9d8fab9
Merge branch 'main' into ks/update-bazel-deps
marcalff May 30, 2024
c0fd06b
Merge branch 'main' into ks/update-bazel-deps
marcalff May 30, 2024
052bad6
Merge branch 'main' into ks/update-bazel-deps
lalitb Jun 5, 2024
9823c5f
Merge branch 'main' into ks/update-bazel-deps
ThomsonTan Jun 5, 2024
de4fa6a
Merge branch 'main' into ks/update-bazel-deps
ThomsonTan Jun 6, 2024
b52eb89
Clarify rules loading order
keith Jun 7, 2024
072e66b
Merge branch 'main' into ks/update-bazel-deps
marcalff Jun 7, 2024
f2b60b4
Merge branch 'main' into ks/update-bazel-deps
marcalff Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
# bazel configurations for running tests under sanitizers.
# Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc

# TODO: Remove once support is added, avoid MODULE.bazel creation for now
common --enable_bzlmod=false

# Enable automatic configs based on platform
common --enable_platform_specific_config

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

# Workaround abseil libraries missing symbols
build:windows --dynamic_mode=off

# Set minimum supported C++ version
build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14
build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.1
7.1.1
21 changes: 0 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -558,27 +558,6 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.with_async_export.test

bazel_with_abseil:
name: Bazel with external abseil
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v4
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_test
- name: setup
run: |
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
run: ./ci/do_ci.sh bazel.with_abseil

bazel_valgrind:
name: Bazel valgrind
runs-on: ubuntu-latest
Expand Down
30 changes: 7 additions & 23 deletions api/BUILD
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")

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

bool_flag(
name = "with_abseil",
build_setting_default = False,
)

CPP_STDLIBS = [
"none",
"best",
Expand All @@ -28,10 +23,7 @@ string_flag(
cc_library(
name = "api",
hdrs = glob(["include/**/*.h"]),
defines = select({
":with_external_abseil": ["HAVE_ABSEIL"],
"//conditions:default": [],
}) + select({
defines = ["HAVE_ABSEIL"] + select({
marcalff marked this conversation as resolved.
Show resolved Hide resolved
":set_cxx_stdlib_none": [],
### automatic selection
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
Expand All @@ -46,19 +38,11 @@ cc_library(
}),
strip_include_prefix = "include",
tags = ["api"],
deps = select({
":with_external_abseil": [
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:variant",
],
"//conditions:default": [],
}),
)

config_setting(
name = "with_external_abseil",
flag_values = {":with_abseil": "true"},
deps = [
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:variant",
],
)

[config_setting(
Expand Down
72 changes: 42 additions & 30 deletions api/test/singleton/BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

DEFAULT_WIN_COPTS = [
]

# gcc and clang, assumed to be used on this platform
DEFAULT_NOWIN_COPTS = [
"-fvisibility=default",
]

HIDDEN_WIN_COPTS = [
]

# gcc and clang, assumed to be used on this platform
HIDDEN_NOWIN_COPTS = [
"-fvisibility=hidden",
Expand All @@ -26,6 +20,10 @@ cc_library(
"component_a.h",
],
linkstatic = True,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -40,6 +38,10 @@ cc_library(
"component_b.h",
],
linkstatic = True,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -53,11 +55,12 @@ cc_library(
hdrs = [
"component_c.h",
],
copts = select({
"//bazel:windows": DEFAULT_WIN_COPTS,
"//conditions:default": DEFAULT_NOWIN_COPTS,
}),
copts = DEFAULT_NOWIN_COPTS,
linkstatic = False,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -71,11 +74,12 @@ cc_library(
hdrs = [
"component_d.h",
],
copts = select({
"//bazel:windows": HIDDEN_WIN_COPTS,
"//conditions:default": HIDDEN_NOWIN_COPTS,
}),
copts = HIDDEN_NOWIN_COPTS,
linkstatic = False,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -89,11 +93,12 @@ cc_library(
hdrs = [
"component_e.h",
],
copts = select({
"//bazel:windows": DEFAULT_WIN_COPTS,
"//conditions:default": DEFAULT_NOWIN_COPTS,
}),
copts = DEFAULT_NOWIN_COPTS,
linkstatic = False,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -107,11 +112,12 @@ cc_library(
hdrs = [
"component_f.h",
],
copts = select({
"//bazel:windows": HIDDEN_WIN_COPTS,
"//conditions:default": HIDDEN_NOWIN_COPTS,
}),
copts = HIDDEN_NOWIN_COPTS,
linkstatic = False,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -123,11 +129,12 @@ cc_binary(
srcs = [
"component_g.cc",
],
copts = select({
"//bazel:windows": DEFAULT_WIN_COPTS,
"//conditions:default": DEFAULT_NOWIN_COPTS,
}),
copts = DEFAULT_NOWIN_COPTS,
linkshared = True,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand All @@ -139,11 +146,12 @@ cc_binary(
srcs = [
"component_h.cc",
],
copts = select({
"//bazel:windows": HIDDEN_WIN_COPTS,
"//conditions:default": HIDDEN_NOWIN_COPTS,
}),
copts = HIDDEN_NOWIN_COPTS,
linkshared = True,
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"//api",
],
Expand Down Expand Up @@ -176,6 +184,10 @@ cc_test(
"api",
"test",
],
target_compatible_with = select({
"//bazel:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
deps = [
"component_a",
"component_b",
Expand Down
61 changes: 18 additions & 43 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

_ALL_CONTENT = """
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
"""
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

#
# MAINTAINER
Expand Down Expand Up @@ -55,54 +46,38 @@ def opentelemetry_cpp_deps():

# Load abseil dependency(optional)
maybe(
#
# Important note:
#
# The bazel build uses abseil-cpp-20230802.2 here,
# while CMake uses more recent versions.
#
# bazel with abseil-cpp-20240116.2 : build failures in CI
# bazel with abseil-cpp-20240116.1 : build failures in CI
#
# TODO: Fix issue #2619
#
http_archive,
name = "com_google_absl",
sha256 = "7c11539617af1f332f0854a6fb21e296a1b29c27d03f23c7b49d4adefcd102cc",
strip_prefix = "abseil-cpp-20230802.2",
sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc",
strip_prefix = "abseil-cpp-20240116.2",
urls = [
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.2.tar.gz",
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.2.tar.gz",
],
)

# Load gRPC dependency
# Load this before grpc to pull a newer version
maybe(
http_archive,
name = "com_github_grpc_grpc_legacy",
sha256 = "024118069912358e60722a2b7e507e9c3b51eeaeee06e2dd9d95d9c16f6639ec",
strip_prefix = "grpc-1.39.1",
urls = [
"https://github.com/grpc/grpc/archive/v1.39.1.tar.gz",
],
name = "build_bazel_apple_support",
sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
marcalff marked this conversation as resolved.
Show resolved Hide resolved
)

maybe(
http_archive,
name = "com_github_grpc_grpc_latest11",
sha256 = "e266aa0d9d9cddb876484a370b94f468248594a96ca0b6f87c21f969db2b8c5b",
strip_prefix = "grpc-1.46.4",
urls = [
"https://github.com/grpc/grpc/archive/v1.46.4.tar.gz",
],
name = "build_bazel_rules_apple",
sha256 = "b4df908ec14868369021182ab191dbd1f40830c9b300650d5dc389e0b9266c8d",
url = "https://github.com/bazelbuild/rules_apple/releases/download/3.5.1/rules_apple.3.5.1.tar.gz",
)

# Load gRPC dependency
maybe(
http_archive,
name = "com_github_grpc_grpc",
sha256 = "cdeb805385fba23242bf87073e68d590c446751e09089f26e5e0b3f655b0f089",
strip_prefix = "grpc-1.49.2",
sha256 = "f40bde4ce2f31760f65dc49a2f50876f59077026494e67dccf23992548b1b04f",
strip_prefix = "grpc-1.62.0",
urls = [
"https://github.com/grpc/grpc/archive/v1.49.2.tar.gz",
"https://github.com/grpc/grpc/archive/refs/tags/v1.62.0.tar.gz",
],
)

Expand Down Expand Up @@ -144,10 +119,10 @@ def opentelemetry_cpp_deps():
maybe(
http_archive,
name = "platforms",
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
],
)

Expand Down
4 changes: 3 additions & 1 deletion ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ $nproc = (Get-ComputerInfo).CsNumberOfLogicalProcessors

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

# Workaround https://github.com/bazelbuild/bazel/issues/18683
$BAZEL_STARTUP_OPTIONS = "--output_base=C:\Out"
marcalff marked this conversation as resolved.
Show resolved Hide resolved
$BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT"
$BAZEL_TEST_OPTIONS = "$BAZEL_OPTIONS --test_output=errors"

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

switch ($action) {
"bazel.build" {
bazel build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //...
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //...
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
Expand Down
6 changes: 1 addition & 5 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,6 @@ elif [[ "$1" == "cmake.install.test" ]]; then
make -j $(nproc)
sudo make install
exit 0
elif [[ "$1" == "bazel.with_abseil" ]]; then
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC --//api:with_abseil=true //...
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS_ASYNC --//api:with_abseil=true //...
exit 0
elif [[ "$1" == "cmake.test_example_plugin" ]]; then
# Build the plugin
cd "${BUILD_DIR}"
Expand Down Expand Up @@ -503,7 +499,7 @@ elif [[ "$1" == "bazel.tsan" ]]; then
exit 0
elif [[ "$1" == "bazel.valgrind" ]]; then
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC //...
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 //...
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 //...
exit 0
elif [[ "$1" == "bazel.e2e" ]]; then
cd examples/e2e
Expand Down
Loading