Skip to content

chore(dependencies): only depend on the windows crate when targeting windows#2020

Closed
pkubaj wants to merge 1 commit into
DataDog:mainfrom
pkubaj:no_windows_include
Closed

chore(dependencies): only depend on the windows crate when targeting windows#2020
pkubaj wants to merge 1 commit into
DataDog:mainfrom
pkubaj:no_windows_include

Conversation

@pkubaj
Copy link
Copy Markdown
Contributor

@pkubaj pkubaj commented May 21, 2026

What does this PR do?

spawn_worker and datadog-sidecar both declare windows as an
unconditional dependency:

[dependencies.windows]
...

Cargo builds dependencies for every target, so the windows crate is
compiled on non-Windows platforms even though it is only ever used from
modules gated behind #[cfg(target_os = "windows")]
(spawn_worker::win32 and datadog_sidecar::windows).

The windows crate carries architecture-specific definitions and does
not compile on every Rust target. On a target it does not support
(e.g. FreeBSD/powerpc64) the build fails with errors such as:

error[E0425]: cannot find type `CONTEXT` in this scope
error[E0425]: cannot find type `SLIST_HEADER` in this scope

This goes unnoticed on x86_64/aarch64 because the crate happens to
compile there.

Move the dependency under [target.'cfg(windows)'.dependencies] so
cargo only builds it on Windows, matching how it is actually used. The
workspace's other windows-crate users (libdd-crashtracker,
libdd-crashtracker-ffi, libdd-telemetry) already gate it this way.

Motivation

Building on FreeBSD/powerpc64le.

How to test the change?

Build outside of x86_64/aarch64.

`spawn_worker` and `datadog-sidecar` both declare `windows` as an
unconditional dependency:

    [dependencies.windows]
    ...

Cargo builds dependencies for every target, so the `windows` crate is
compiled on non-Windows platforms even though it is only ever used from
modules gated behind `#[cfg(target_os = "windows")]`
(`spawn_worker::win32` and `datadog_sidecar::windows`).

The `windows` crate carries architecture-specific definitions and does
not compile on every Rust target. On a target it does not support
(e.g. FreeBSD/powerpc64) the build fails with errors such as:

    error[E0425]: cannot find type `CONTEXT` in this scope
    error[E0425]: cannot find type `SLIST_HEADER` in this scope

This goes unnoticed on x86_64/aarch64 because the crate happens to
compile there.

Move the dependency under `[target.'cfg(windows)'.dependencies]` so
cargo only builds it on Windows, matching how it is actually used. The
workspace's other `windows`-crate users (`libdd-crashtracker`,
`libdd-crashtracker-ffi`, `libdd-telemetry`) already gate it this way.
@pkubaj pkubaj requested review from a team as code owners May 21, 2026 09:41
@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented May 21, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 9 Pipeline jobs failed

Metadata, docs and deps | dependency-check   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Resource not accessible by integration while posting comment due to 403 error.

Metadata, docs and deps | missing-docs   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Resource not accessible by integration when attempting to post a comment on the GitHub issue.

Pull Request Labeler | triage   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Missing required workflow permissions for adding labels to pull requests. Error: Resource not accessible by integration.

View all 9 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 71cf089 | Docs | Datadog PR Page | Give us feedback!

@bantonsson bantonsson changed the title Only depend on the windows crate when targeting Windows chore(dependencies): only depend on the windows crate when targeting windows May 21, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.86%. Comparing base (0f83957) to head (71cf089).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2020      +/-   ##
==========================================
- Coverage   72.90%   72.86%   -0.04%     
==========================================
  Files         457      457              
  Lines       75769    75769              
==========================================
- Hits        55240    55211      -29     
- Misses      20529    20558      +29     
Components Coverage Δ
libdd-crashtracker 65.22% <ø> (-0.02%) ⬇️
libdd-crashtracker-ffi 36.82% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.69% <ø> (ø)
libdd-data-pipeline-ffi 78.63% <ø> (ø)
libdd-common 79.81% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (-0.06%) ⬇️
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.22% <ø> (ø)
libdd-profiling 81.70% <ø> (+0.01%) ⬆️
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.46% <ø> (ø)
datadog-sidecar 29.09% <ø> (-0.29%) ⬇️
datdog-sidecar-ffi 9.67% <ø> (-1.26%) ⬇️
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 88.86% <ø> (-0.11%) ⬇️
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bantonsson
Copy link
Copy Markdown
Contributor

Hey @pkubaj thank you for the contribution. In order for our CI to run I needed to cherry pick your changes into #2024

@bantonsson bantonsson closed this May 21, 2026
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request May 22, 2026
…windows (#2024)

# External Contribution
PR #2020

# What does this PR do?

`spawn_worker` and `datadog-sidecar` both declare `windows` as an
unconditional dependency:

    [dependencies.windows]
    ...

Cargo builds dependencies for every target, so the `windows` crate is
compiled on non-Windows platforms even though it is only ever used from
modules gated behind `#[cfg(target_os = "windows")]`
(`spawn_worker::win32` and `datadog_sidecar::windows`).

The `windows` crate carries architecture-specific definitions and does
not compile on every Rust target. On a target it does not support
(e.g. FreeBSD/powerpc64) the build fails with errors such as:

    error[E0425]: cannot find type `CONTEXT` in this scope
    error[E0425]: cannot find type `SLIST_HEADER` in this scope

This goes unnoticed on x86_64/aarch64 because the crate happens to
compile there.

Move the dependency under `[target.'cfg(windows)'.dependencies]` so
cargo only builds it on Windows, matching how it is actually used. The
workspace's other `windows`-crate users (`libdd-crashtracker`,
`libdd-crashtracker-ffi`, `libdd-telemetry`) already gate it this way.


# Motivation

Building on FreeBSD/powerpc64le.

# How to test the change?

Build outside of x86_64/aarch64.


Co-authored-by: pkubaj <pkubaj@anongoth.pl>
Co-authored-by: bjorn.antonsson <bjorn.antonsson@datadoghq.com>
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.

4 participants