Skip to content

[PROF-7056] Remove dependency on pkg-config system tool for native extension builds#5469

Merged
ivoanjo merged 2 commits into
masterfrom
ivoanjo/prof-7056-pkg-config
Mar 18, 2026
Merged

[PROF-7056] Remove dependency on pkg-config system tool for native extension builds#5469
ivoanjo merged 2 commits into
masterfrom
ivoanjo/prof-7056-pkg-config

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Mar 18, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR removes the dependency on the pkg-config system tool when building the native extensions that link to libdatadog.

Previously, we used mkmf's pkg_config("datadog_profiling_with_rpath") which shells out to the pkg-config binary to discover include paths, library paths, and linker flags from libdatadog's .pc file.

Now, we directly set the mkmf global variables ($INCFLAGS, $LDFLAGS, $libs) with the paths computed from Libdatadog.pkgconfig_folder, which we already have access to via the libdatadog gem.

Motivation:

The pkg-config tool has been a recurring source of support issues (see JIRA tickets). Customers on minimal Docker images, certain CI environments, or systems where pkg-config is misconfigured would hit cryptic build failures during gem installation.

Since we control both dd-trace-rb and libdatadog, we know the exact directory structure and don't need pkg-config's generic discovery mechanism. This is one less external dependency we don't have control over.

Change log entry

Yes. Core: Remove dependency on pkg-config system tool for native extension builds.

Additional Notes:

The generated Makefile is identical to the previous pkg-config approach.

How to test the change?

Green CI is good, as usual.

…extension builds

**What does this PR do?**

This PR removes the dependency on the `pkg-config` system tool when
building the native extensions that link to libdatadog.

Previously, we used mkmf's `pkg_config("datadog_profiling_with_rpath")`
which shells out to the `pkg-config` binary to discover include paths,
library paths, and linker flags from libdatadog's `.pc` file.

Now, we directly set the mkmf global variables (`$INCFLAGS`, `$LDFLAGS`,
`$libs`) with the paths computed from `Libdatadog.pkgconfig_folder`,
which we already have access to via the libdatadog gem.

**Motivation:**

The `pkg-config` tool has been a recurring source of support issues
(see JIRA tickets). Customers on minimal Docker images, certain CI
environments, or systems where pkg-config is misconfigured would hit
cryptic build failures during gem installation.

Since we control both dd-trace-rb and libdatadog, we know the exact
directory structure and don't need pkg-config's generic discovery
mechanism. This is one less external dependency we don't have control
over.

**Change log entry**

Yes. Core: Remove dependency on `pkg-config` system tool for native extension builds.

**Additional Notes:**

The generated Makefile is identical to the previous pkg-config approach.

**How to test the change?**

Green CI is good, as usual.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ivoanjo
ivoanjo requested review from a team as code owners March 18, 2026 10:22
@github-actions github-actions Bot added the profiling Involves Datadog profiling label Mar 18, 2026
@ivoanjo
ivoanjo requested a review from lloeki March 18, 2026 10:23
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Mar 18, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 40.00%
Overall Coverage: 95.13% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2d3f84a | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

…g helper

This consolidates all libdatadog linkage configuration into the
`configure_libdatadog` helper method, reducing code duplication
between the two extconf.rb files.

Also renames `current_folder:` parameter to `extconf_folder:` for
clarity, and adds `gem_dir:` parameter for testability.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@pr-commenter

pr-commenter Bot commented Mar 18, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-18 11:34:34

Comparing candidate commit 2d3f84a in PR branch ivoanjo/prof-7056-pkg-config with baseline commit b42addf in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@ivoanjo

ivoanjo commented Mar 18, 2026

Copy link
Copy Markdown
Member Author

I forgot to add in the PR description that this is a bit fiddly, but in practice, if it's wrong, we should see it fail loudly (from e.g. the extension not building) so if tests are passing we should be good to go + we have existing support to gracefully handle failures in compilation so worst case we have a backstop here to not impact customers.

@ivoanjo
ivoanjo merged commit 0ed964e into master Mar 18, 2026
631 checks passed
@ivoanjo
ivoanjo deleted the ivoanjo/prof-7056-pkg-config branch March 18, 2026 13:01
@github-actions github-actions Bot added this to the 2.30.0 milestone Mar 18, 2026
@lloeki

lloeki commented Mar 18, 2026

Copy link
Copy Markdown
Member

this is a bit fiddly

I don't think it's that fiddly, I've been using plain paths in libv8-node (and libv8 before it) and it's been perfectly fine for what, over half a decade?

https://github.com/rubyjs/libv8-node/blob/0d3c1477bd3a89f6d84a86cb41fae84ea1b9514e/ext/libv8-node/location.rb#L39-L40

@Strech Strech mentioned this pull request Mar 19, 2026
ivoanjo added a commit to DataDog/documentation that referenced this pull request Mar 23, 2026
jeff-morgan-dd added a commit to DataDog/documentation that referenced this pull request Mar 23, 2026
genesor pushed a commit to DataDog/documentation that referenced this pull request Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants