Skip to content

Commit c50a004

Browse files
committed
osx fixes and merge from upstream
2 parents 7f989b0 + 5fc4707 commit c50a004

File tree

13 files changed

+387
-82
lines changed

13 files changed

+387
-82
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ common:windows --repo_env=BAZEL_SH="c:\\program files\\git\\usr\\bin\\bash.exe"
2626
#build --features=parse_headers
2727
#build --features=layering_check
2828

29+
# Disable these two on OSX
30+
build:macos --features=-header_modules
31+
build:macos --features=-layering_check
32+
2933
# Don't try to build .so and .dylib shared libs (instead of static) libs on Linux/OSX
3034
# For some reason, with clang-cl, it also tried to do on Windows, where dynamic linking just does not support it.
3135
build --dynamic_mode=off

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.5.0rc4
1+
8.5.0

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ Checks: >
3838
-cppcoreguidelines-macro-usage,
3939
-cppcoreguidelines-non-private-member-variables-in-classes,
4040
-cppcoreguidelines-avoid-non-const-global-variables,
41-
-cppcoreguidelines-pro-*
41+
-cppcoreguidelines-pro-*

.devcontainer/Dockerfile.dev

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM otel/cpp_format_tools
5+
6+
ARG USER_UID=1000
7+
ARG USER_GID=1000
8+
ARG INSTALL_PACKAGES=
9+
10+
ARG CXX_STANDARD=17
11+
12+
ENV CXX_STANDARD=${CXX_STANDARD}
13+
14+
COPY ci /opt/ci
15+
16+
RUN apt update && apt install -y wget \
17+
ninja-build \
18+
llvm-20-dev \
19+
libclang-20-dev \
20+
clang-tidy-20 \
21+
shellcheck \
22+
sudo \
23+
cmake
24+
25+
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200 && \
26+
update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-20 200 && \
27+
update-alternatives --config clang-tidy && \
28+
update-alternatives --config llvm-config
29+
30+
RUN cd /opt/ci && bash setup_ci_environment.sh
31+
RUN cd /opt/ci && bash install_iwyu.sh
32+
33+
ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-amd64 /usr/local/bin
34+
35+
RUN git config --global core.autocrlf input \
36+
&& chmod +x /usr/local/bin/bazelisk-linux-amd64
37+
38+
ENV INSTALL_PACKAGES=${INSTALL_PACKAGES}
39+
ENV USER_NAME=devuser
40+
ENV USER_UID=${USER_UID}
41+
ENV USER_GID=${USER_GID}
42+
ENV IS_CONTAINER_BUILD=true
43+
44+
COPY install /opt/install
45+
COPY ./.devcontainer/customize_container.sh /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
46+
RUN /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
47+
RUN apt install -y npm && npm install -g markdownlint-cli@0.44.0
48+
49+
USER devuser
50+
51+
WORKDIR /workspaces/opentelemetry-cpp
52+
RUN cd /opt && bash ci/install_thirdparty.sh --install-dir /home/devuser/third-party/install-stable --tags-file install/cmake/third_party_stable
53+
ENV CMAKE_PREFIX_PATH=/home/devuser/third-party/install-stable
54+
55+
ENTRYPOINT []
56+
57+
CMD ["/bin/bash"]

.github/workflows/clang-tidy.yaml

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ jobs:
1717
matrix:
1818
include:
1919
- cmake_options: all-options-abiv1-preview
20-
warning_limit: 63
20+
warning_limit: 595
2121
- cmake_options: all-options-abiv2-preview
22-
warning_limit: 63
22+
warning_limit: 597
23+
env:
24+
CC: /usr/bin/clang-18
25+
CXX: /usr/bin/clang++-18
26+
CXX_STANDARD: '14' # Run clang-tidy on the minimum supported c++ standard
2327
steps:
2428
- name: Harden the runner (Audit all outbound calls)
2529
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
@@ -53,52 +57,64 @@ jobs:
5357
run: |
5458
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml"
5559
56-
- name: Check clang-tidy
60+
- name: Install clang-tidy-20
5761
run: |
58-
if ! command -v clang-tidy &> /dev/null; then
59-
echo "clang-tidy could not be found"
60-
exit 1
61-
fi
62+
sudo apt install -y clang-tidy-20
63+
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200
64+
sudo update-alternatives --config clang-tidy
6265
echo "Using clang-tidy version: $(clang-tidy --version)"
6366
echo "clang-tidy installed at: $(which clang-tidy)"
6467
65-
- name: Prepare CMake
68+
- name: Build and run clang-tidy
69+
id: build
6670
env:
67-
CC: clang
68-
CXX: clang++
71+
OTELCPP_CMAKE_CACHE_FILE: ${{ matrix.cmake_options }}.cmake
72+
BUILD_DIR: build-${{ matrix.cmake_options }}
6973
run: |
70-
echo "Running cmake..."
71-
cmake -B build-${{ matrix.cmake_options }} \
72-
-C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \
73-
-DCMAKE_CXX_STANDARD=14 \
74-
-DWITH_STL=CXX14 \
75-
-DWITH_OPENTRACING=OFF \
76-
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
77-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
78-
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--quiet;-p;build-${{ matrix.cmake_options }}"
74+
./ci/do_ci.sh cmake.clang_tidy.test
75+
echo "build_log=${BUILD_DIR}/opentelemetry-cpp-clang-tidy.log" >> "$GITHUB_OUTPUT"
7976
80-
- name: Run clang-tidy
77+
- name: Analyze clang-tidy output
78+
id: analyze
8179
run: |
82-
cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) 2>&1 | tee clang-tidy-${{ matrix.cmake_options }}.log
80+
SCRIPT_OUTPUT=$(python3 ./ci/create_clang_tidy_report.py \
81+
--build_log ${{ steps.build.outputs.build_log }} \
82+
--output ./clang_tidy_report-${{ matrix.cmake_options }}.md)
83+
export $SCRIPT_OUTPUT
84+
echo "Found $TOTAL_WARNINGS unique warnings"
85+
echo "clang-tidy report generated at $REPORT_PATH"
86+
echo "warning_count=$TOTAL_WARNINGS" >> "$GITHUB_OUTPUT"
87+
echo "report_path=$REPORT_PATH" >> "$GITHUB_OUTPUT"
88+
cat $REPORT_PATH >> $GITHUB_STEP_SUMMARY
8389
90+
<<<<<<< HEAD
8491
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
92+
=======
93+
- name: Upload build log
94+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
95+
>>>>>>> 5fc4707a8b7820f6bdbc782ccdffac7ccafbe80d
8596
with:
8697
name: Logs-clang-tidy-${{ matrix.cmake_options }}
87-
path: ./clang-tidy-${{ matrix.cmake_options }}.log
98+
path: ${{ steps.build.outputs.build_log }}
99+
100+
- name: Upload warning report
101+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
102+
with:
103+
name: Report-clang-tidy-${{ matrix.cmake_options }}
104+
path: ${{ steps.analyze.outputs.report_path }}
88105

89-
- name: Count warnings
106+
- name: Check Warning Limits
90107
run: |
91-
COUNT=$(grep -c "warning:" clang-tidy-${{ matrix.cmake_options }}.log)
92-
echo "clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
108+
readonly COUNT="${{ steps.analyze.outputs.warning_count }}"
109+
readonly LIMIT="${{ matrix.warning_limit }}"
93110
94-
readonly WARNING_LIMIT=${{ matrix.warning_limit }}
111+
echo "clang-tidy reported ${COUNT} unique warning(s) with preset '${{ matrix.cmake_options }}'"
112+
echo "Limit is ${LIMIT}"
95113
96-
# FAIL the build if COUNT > WARNING_LIMIT
97-
if [ $COUNT -gt $WARNING_LIMIT ] ; then
98-
echo "clang-tidy reported ${COUNT} warning(s) exceeding the existing warning limit of ${WARNING_LIMIT} with cmake options preset '${{ matrix.cmake_options }}'"
114+
if [ "$COUNT" -gt "$LIMIT" ]; then
115+
echo "::error::clang-tidy reported ${COUNT} warning(s) exceeding the limit of ${LIMIT}"
99116
exit 1
100-
# WARN in annotations if COUNT > 0
101-
elif [ $COUNT -gt 0 ] ; then
102-
echo "::warning::clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
117+
elif [ "$COUNT" -gt 0 ]; then
118+
echo "::warning::clang-tidy reported ${COUNT} warning(s) within the limit of ${LIMIT}"
103119
fi
104120

BUILD

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# NOTE: This below code is Windows specific
22

3-
#load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
4-
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
3+
#load("@bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
4+
load("@bazel_lib//lib:write_source_files.bzl", "write_source_file")
55
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
66

77
#load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
@@ -73,7 +73,7 @@ otel_cc_library(
7373
visibility = ["//visibility:private"],
7474
deps = [
7575
"@otel_sdk//exporters/elasticsearch:es_log_record_exporter",
76-
# "@otel_sdk//exporters/etw:etw_exporter",
76+
#"@otel_sdk//exporters/etw:etw_exporter",
7777
"@otel_sdk//exporters/memory:in_memory_data",
7878
"@otel_sdk//exporters/memory:in_memory_metric_data",
7979
"@otel_sdk//exporters/memory:in_memory_metric_exporter_factory",
@@ -173,7 +173,11 @@ otel_cc_library(
173173
"api_sdk_includes",
174174
"otel_sdk_deps",
175175
],
176-
) for otel_sdk_binary in ["otel_sdk_r", "otel_sdk_d", "otel_sdk_rd"]]
176+
) for otel_sdk_binary in [
177+
"otel_sdk_r",
178+
"otel_sdk_d",
179+
"otel_sdk_rd",
180+
]]
177181

178182
# Convenient alias that selects the appropriate otel_sdk from above
179183
alias(
@@ -241,8 +245,8 @@ alias(
241245
"//exporters/prometheus:headers",
242246
"//exporters/zipkin:headers",
243247
"//ext:headers",
244-
"//sdk:headers",
245248
"//resource_detectors:headers",
249+
"//sdk:headers",
246250
] + select({
247251
"@platforms//os:windows": [
248252
"//exporters/etw:headers",
@@ -365,12 +369,14 @@ pkg_files(
365369
args = [
366370
"debug-files",
367371
"bundle-sources",
372+
"--log-level=trace",
368373
] + select({
369374
"@platforms//os:macos": ["$(execpath " + otel_sdk_binary + "_dsym_file" + ")"],
370375
"//conditions:default": ["$(execpath " + otel_sdk_binary + ")"],
371376
}),
372377
tags = ["no-sandbox"],
373378
target_compatible_with = select({
379+
"@platforms//os:macos": ["@platforms//:incompatible"],
374380
"@platforms//os:windows": ["@platforms//:incompatible"],
375381
"//conditions:default": None,
376382
}),
@@ -395,7 +401,7 @@ pkg_files(
395401

396402
[pkg_files(
397403
name = otel_sdk_binary + "_src_bundle",
398-
srcs = [otel_sdk_binary + "_src_bundle_force"],
404+
srcs = [otel_sdk_binary], # + "_src_bundle_force"],
399405
prefix = otel_sdk_prefix,
400406
strip_prefix = pkg_strip_prefix.from_pkg(),
401407
) for otel_sdk_binary in [
@@ -432,14 +438,18 @@ pkg_files(
432438
pkg_filegroup(
433439
name = "otel_sdk_files",
434440
srcs = [
435-
"otel_sdk_d_lib_files",
436-
"otel_sdk_d_src_bundle",
437441
"otel_sdk_header_files",
442+
"otel_sdk_d_lib_files",
438443
"otel_sdk_r_lib_files",
439-
"otel_sdk_r_src_bundle",
440444
"otel_sdk_rd_lib_files",
441-
"otel_sdk_rd_src_bundle",
442-
],
445+
] + select({
446+
"@platforms//os:macos": [],
447+
"//conditions:default": [
448+
"otel_sdk_d_src_bundle",
449+
"otel_sdk_r_src_bundle",
450+
"otel_sdk_rd_src_bundle",
451+
],
452+
}),
443453
)
444454

445455
# On windows we have .dll files in bin/, and import .lib files in lib/

MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module(
55
)
66

77
bazel_dep(name = "abseil-cpp", version = "20250814.1")
8-
bazel_dep(name = "aspect_bazel_lib", version = "2.22.0")
8+
bazel_dep(name = "bazel_lib", version = "3.0.0")
99
bazel_dep(name = "bazel_skylib", version = "1.8.2")
1010
bazel_dep(name = "boringssl", version = "0.20251124.0")
1111
single_version_override(
@@ -29,7 +29,7 @@ single_version_override(
2929
bazel_dep(name = "depend_on_what_you_use", version = "0.11.0")
3030
bazel_dep(name = "google_benchmark", version = "1.9.4")
3131
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
32-
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
32+
bazel_dep(name = "re2", version = "2025-11-05.bcr.1")
3333
bazel_dep(name = "rules_go", version = "0.59.0")
3434
bazel_dep(name = "gazelle", version = "0.47.0")
3535
bazel_dep(name = "stardoc", version = "0.8.0")
@@ -44,7 +44,7 @@ bazel_dep(name = "zlib", version = "1.3.1.bcr.8")
4444
bazel_dep(name = "opentracing-cpp", version = "1.6.0")
4545
bazel_dep(name = "rules_multitool", version = "1.11.1")
4646
bazel_dep(name = "protoc-gen-validate", version = "1.3.0")
47-
bazel_dep(name = "c-ares", version = "1.34.5")
47+
bazel_dep(name = "c-ares", version = "1.34.5.bcr.3")
4848
archive_override(
4949
module_name = "c-ares",
5050
integrity = "sha256-QItVHP1adgblywbel9M7cgFSehKhzHO6CrVe8/ynEls=",

api/test/singleton/singleton_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void do_something()
5656
# ifdef _WIN32
5757
HMODULE component_g = LoadLibraryA("component_g.dll");
5858
# elif defined(__APPLE__)
59-
void *component_g = dlopen("libcomponent_g.dylib", RTLD_NOW);
59+
void *component_g = dlopen("api/test/singleton/libcomponent_g.dylib", RTLD_NOW);
6060
# else
6161
void *component_g = dlopen("api/test/singleton/libcomponent_g.so", RTLD_NOW);
6262
# endif
@@ -84,7 +84,7 @@ void do_something()
8484
# ifdef _WIN32
8585
HMODULE component_h = LoadLibraryA("component_h.dll");
8686
# elif defined(__APPLE__)
87-
void *component_h = dlopen("libcomponent_h.dylib", RTLD_NOW);
87+
void *component_h = dlopen("api/test/singleton/libcomponent_h.dylib", RTLD_NOW);
8888
# else
8989
void *component_h = dlopen("api/test/singleton/libcomponent_h.so", RTLD_NOW);
9090
# endif

0 commit comments

Comments
 (0)