From 2d524a19112c06aa2af50fc0ee032e80c1ac7043 Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 3 Nov 2026 16:37:56 +0100 Subject: [PATCH 1/3] fix(build): link libm, and run system-tests on pull requests dd-trace-cpp 2.4.1 uses std::round, which is in libm: Apache doesn't load it, so mod_datadog.so fails to load with "undefined symbol: round". Co-Authored-By: Claude Opus 5.5 --- .github/workflows/system-tests.yml | 2 +- mod_datadog/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index a1e36568..54d09327 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -1,7 +1,7 @@ name: System Tests on: - # pull_request: + pull_request: push: branches: [main] workflow_dispatch: diff --git a/mod_datadog/CMakeLists.txt b/mod_datadog/CMakeLists.txt index 7703647d..460d4e1b 100644 --- a/mod_datadog/CMakeLists.txt +++ b/mod_datadog/CMakeLists.txt @@ -88,6 +88,8 @@ target_link_libraries(mod_datadog dd-trace-cpp-static httpd fmt + # dd-trace-cpp uses std::round, and Apache doesn't always load libm + m ) if(HTTPD_DATADOG_ENABLE_COVERAGE) From 2efcb293ece3fb2a650084d0129f4545f96ce14e Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 3 Nov 2026 16:40:15 +0100 Subject: [PATCH 2/3] ci(system-tests): always run DEFAULT, and tracer-release only on main The excluded scenarios don't require credentials anymore. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/system-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 54d09327..d51ca7fd 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -50,8 +50,9 @@ jobs: library: cpp_httpd binaries_artifact: system_tests_binaries desired_execution_time: 300 # 5 minutes - scenarios_groups: tracer-release - excluded_scenarios: APM_TRACING_E2E_OTEL,APM_TRACING_E2E_SINGLE_SPAN # require AWS and datadog credentials + scenarios: DEFAULT + # the whole tracer-release group only on main, pull requests run DEFAULT + scenarios_groups: ${{ github.ref == 'refs/heads/main' && 'tracer-release' || '' }} parametric_job_count: 8 skip_empty_scenarios: false push_to_test_optimization: ${{ github.actor != 'dependabot[bot]' }} From ddba4b8a099c54884ced28d9a888a1c2435e65ad Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 3 Nov 2026 16:55:42 +0100 Subject: [PATCH 3/3] fix(build): define round in the module, instead of linking libm The module is built against musl, where libm is part of libc: linking it adds nothing. Like ceil/ceilf in glibc_compat.c, round is defined in the module, for glibc hosts. Co-Authored-By: Claude Opus 5.5 --- mod_datadog/CMakeLists.txt | 3 +-- mod_datadog/src/libm_compat.cpp | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 mod_datadog/src/libm_compat.cpp diff --git a/mod_datadog/CMakeLists.txt b/mod_datadog/CMakeLists.txt index 460d4e1b..ff8752f2 100644 --- a/mod_datadog/CMakeLists.txt +++ b/mod_datadog/CMakeLists.txt @@ -24,6 +24,7 @@ add_library( src/common_conf.cpp src/tracing/conf.cpp src/tracing/hooks.cpp + src/libm_compat.cpp ) set_property(TARGET mod_datadog PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -88,8 +89,6 @@ target_link_libraries(mod_datadog dd-trace-cpp-static httpd fmt - # dd-trace-cpp uses std::round, and Apache doesn't always load libm - m ) if(HTTPD_DATADOG_ENABLE_COVERAGE) diff --git a/mod_datadog/src/libm_compat.cpp b/mod_datadog/src/libm_compat.cpp new file mode 100644 index 00000000..9dcba173 --- /dev/null +++ b/mod_datadog/src/libm_compat.cpp @@ -0,0 +1,35 @@ +// The module is built against musl, where libm is part of libc, and its libc +// dependency is removed (patch_away_libc): the host process provides libc. On +// glibc hosts, Apache doesn't load libm, so libm functions used by dependencies +// must be defined here, like ceil/ceilf in +// deps/nginx-datadog/build_env/glibc_compat.c. + +#if defined(__linux__) && !defined(__GLIBC__) + +// used by dd-trace-cpp (OpenTelemetry tracestate sampling) +extern "C" double round(double x) { + double result; +#if defined(__x86_64__) + // truncate, then round half away from zero. x - result is exact: same sign + // and |result| <= |x|. + // NOLINTNEXTLINE(hicpp-no-assembler) + __asm__("roundsd $0x0B, %[x], %[result]" + : [result] "=x"(result) + : [x] "x"(x)); + const double fraction = x - result; + if (fraction >= 0.5) { + result += 1.0; + } else if (fraction <= -0.5) { + result -= 1.0; + } +#elif defined(__aarch64__) + // round to nearest, ties away from zero + // NOLINTNEXTLINE(hicpp-no-assembler) + __asm__("frinta %d0, %d1\n" : "=w"(result) : "w"(x)); +#else +#error "round is not implemented for this architecture" +#endif + return result; +} + +#endif