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

[pull] main from open-telemetry:main #305

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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({
":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
63 changes: 20 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,40 @@ 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
# gRPC transitively depends on apple_support and rules_apple at older
# versions. Bazel 7.x requires newer versions of these rules. By loading
# them before grpc, these newer versions are preferrred.
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",
)

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 +121,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"
$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 @@ -425,10 +425,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 @@ -507,7 +503,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
Loading