chore(dependencies): only depend on the windows crate when targeting windows#2020
Closed
pkubaj wants to merge 1 commit into
Closed
chore(dependencies): only depend on the windows crate when targeting windows#2020pkubaj wants to merge 1 commit into
windows crate when targeting windows#2020pkubaj wants to merge 1 commit into
Conversation
`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.
yannham
approved these changes
May 21, 2026
bantonsson
approved these changes
May 21, 2026
|
windows crate when targeting Windowswindows crate when targeting windows
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
This was referenced May 21, 2026
Contributor
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
spawn_workeranddatadog-sidecarboth declarewindowsas anunconditional dependency:
Cargo builds dependencies for every target, so the
windowscrate iscompiled on non-Windows platforms even though it is only ever used from
modules gated behind
#[cfg(target_os = "windows")](
spawn_worker::win32anddatadog_sidecar::windows).The
windowscrate carries architecture-specific definitions and doesnot compile on every Rust target. On a target it does not support
(e.g. FreeBSD/powerpc64) the build fails with errors such as:
This goes unnoticed on x86_64/aarch64 because the crate happens to
compile there.
Move the dependency under
[target.'cfg(windows)'.dependencies]socargo 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.