Skip to content

fix(build): link libm, and run system-tests on pull requests - #128

Closed
cbeauchesne wants to merge 3 commits into
mainfrom
cbeauchesne/link-libm-and-system-tests-on-pr
Closed

cbeauchesne wants to merge 3 commits into
mainfrom
cbeauchesne/link-libm-and-system-tests-on-pr

Conversation

@cbeauchesne

@cbeauchesne cbeauchesne commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Overview

  • Define round in the module (mod_datadog/src/libm_compat.cpp)
  • Run system-tests on pull requests: DEFAULT only. The whole tracer-release group (with DEFAULT) still runs on main
  • Remove excluded_scenarios: APM_TRACING_E2E_OTEL and APM_TRACING_E2E_SINGLE_SPAN don't require credentials anymore

Motivation

Since #126 (dd-trace-cpp 2.1.0 → 2.4.1), Apache can't load the module:

Cannot load /usr/lib/apache2/modules/mod_datadog.so into server: /usr/lib/apache2/modules/mod_datadog.so: undefined symbol: round

The module has no NEEDED entry: it relies on the Apache process for every libc function. dd-trace-cpp 2.4.1 added a call to std::round (OpenTelemetry tracestate sampling, src/datadog/trace_segment.cpp), which is in libm, and Apache doesn't load libm. It's the only libm symbol among the module's undefined symbols.

The module is built against musl, where libm is part of libc, so linking libm adds nothing. Like ceil/ceilf in deps/nginx-datadog/build_env/glibc_compat.c, round is now defined in the module: roundsd (truncate) then half away from zero on x86_64, frinta on aarch64. It stays local to the module (symbols.ld). Its proper home would be glibc_compat.c in nginx-datadog, but httpd-datadog gets it through the devcontainer image.

It breaks the cpp_httpd, dev jobs of every system-tests PR (e.g. https://github.com/DataDog/system-tests/actions/runs/41662355703/job/126014462409). It wasn't caught here because the system-tests workflow only ran on main: this PR enables it on pull requests too, and this PR's run validates the fix.

Additional Notes

Checked against std::round, bit for bit, on edge cases (±0, halves, 0.49999999999999994, large values, infinities, NaN, subnormals) and 5M generated values, on amd64 and arm64. The module wasn't built locally: this PR's system-tests run is the check, and nm -D mod_datadog.so should no longer list U round.

References

Jira ticket:

Contributor Checklist

  • I am the author of this pull request and I own it.
  • I reviewed every line of this pull request.
  • This pull request follows the Contributing Guidelines.

🤖 Generated with Claude Code

cbeauchesne and others added 2 commits November 3, 2026 16:37
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 <noreply@anthropic.com>
The excluded scenarios don't require credentials anymore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 66.67%
• Overall Coverage: 45.59% (+0.43%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ddba4b8 | Docs | Give us feedback!

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 <noreply@anthropic.com>
@cbeauchesne
cbeauchesne marked this pull request as ready for review November 3, 2026 16:05
@cbeauchesne
cbeauchesne requested a review from a team as a code owner November 3, 2026 16:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T16:09:35.570320Z ddba4b8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddba4b8a09

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +16 to +18
__asm__("roundsd $0x0B, %[x], %[result]"
: [result] "=x"(result)
: [x] "x"(x));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the rounding code within the x86-64 ISA baseline

On an x86_64 host without SSE4.1, every call to this replacement executes the SSE4.1-only roundsd instruction and kills the Apache worker with SIGILL. The project publishes generic x86_64 artifacts without declaring a newer CPU baseline, so an otherwise supported older server or VM can load the module and then crash when dd-trace-cpp rounds a sampling value. Use a baseline-safe implementation or dispatch only after checking the CPU feature.

Useful? React with 👍 / 👎.

@xlamorlette-datadog xlamorlette-datadog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most adequate way to fix this is #127.

@cbeauchesne

Copy link
Copy Markdown
Contributor Author

Replaced by #127

@cbeauchesne cbeauchesne closed this Nov 3, 2026
@cbeauchesne
cbeauchesne deleted the cbeauchesne/link-libm-and-system-tests-on-pr branch November 3, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants