fix: work around problems with /Zi argument on windows.#1483
Merged
Conversation
/Zi is not multiprocess-safe; it depends on spinning up an mspdbsrv.exe and interacting with it in unsafe ways. CMake's default debug flags can include /Zi, which uses a shared PDB file via mspdbsrv.exe. When multiple CMake targets build in parallel on Windows, this causes "PDB API call failed" (C1090) errors. Bazel's MSVC toolchain already passes /Z7 (embed debug info in .obj), but CMake's /Zi overrides it. CMake added a better way to interact with this configuration in 3.25 with [CMP0141](https://cmake.org/cmake/help/latest/policy/CMP0141.html). So, my change does two things: 1. Sets the default `CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` to `Embedded`, which is the equivalent of /Z7. 2. Replaces /Zi (if found) in cmake's default flags for `Debug` and `RelWithDebInfo`. (/Zi should only be present here if a project overrides the DEBUG_INFORMATION_FORMAT or if they're on an older cmake). This makes it extremely likely /Zi will not be used unless it is the explicit intention of the rules_foreign_cc user.
rdesgroppes
added a commit
to DataDog/datadog-agent
that referenced
this pull request
Mar 19, 2026
Moving the unreleased tip of main allows to address Bazel 9 related issues instead of patching locally: - bazel-contrib/rules_foreign_cc#1493 - bazel-contrib/rules_foreign_cc#1492 Other notable commits since: - bazel-contrib/rules_foreign_cc#1483 - bazel-contrib/rules_foreign_cc#1490 - bazel-contrib/rules_foreign_cc#1496 Patches 0002 (DY/LD_LIBRARY_PATH) and 0003 (-j on make command line) are still carried locally as neither has landed upstream yet (but we're working on it).
rdesgroppes
added a commit
to DataDog/datadog-agent
that referenced
this pull request
Mar 21, 2026
Moving the unreleased tip of main allows to address Bazel 9 related issues instead of patching locally: - bazel-contrib/rules_foreign_cc#1493 - bazel-contrib/rules_foreign_cc#1492 Other notable commits since: - bazel-contrib/rules_foreign_cc#1483 - bazel-contrib/rules_foreign_cc#1490 - bazel-contrib/rules_foreign_cc#1496 Patches 0002 (DY/LD_LIBRARY_PATH) and 0003 (-j on make command line) are still carried locally as neither has landed upstream yet (but we're working on it).
gh-worker-dd-mergequeue-cf854d bot
pushed a commit
to DataDog/datadog-agent
that referenced
this pull request
Mar 21, 2026
Depends on #48082. ### Motivation Moving the unreleased tip of main allows to address Bazel 9 related issues instead of patching locally: - bazel-contrib/rules_foreign_cc#1493 - bazel-contrib/rules_foreign_cc#1492 (`CcInfo` and other `Cc*` symbols) Other notable commits since: - bazel-contrib/rules_foreign_cc#1483 - bazel-contrib/rules_foreign_cc#1490 - bazel-contrib/rules_foreign_cc#1496 ### Additional Notes Patches 0002 (bazel-contrib/rules_foreign_cc#1452) and 0003 (bazel-contrib/rules_foreign_cc#1491) are still carried locally as neither has landed upstream yet (but we're working on it). Co-authored-by: regis.desgroppes <regis.desgroppes@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.
/Zi is not multiprocess-safe; it depends on spinning up an mspdbsrv.exe and interacting with it in unsafe ways. When multiple CMake targets build in parallel on Windows, this causes "PDB API call failed" (C1090) errors.
CMake's default debug flags can include /Zi. Bazel's MSVC toolchain already passes /Z7 (embed debug info in .obj), but CMake's /Zi overrides it. CMake added a better way to interact with this configuration in 3.25 with CMP0141.
So, my change does two things:
CMAKE_MSVC_DEBUG_INFORMATION_FORMATtoEmbedded, which is the equivalent of /Z7.DebugandRelWithDebInfo. (/Zi should only be present here if a project overrides the DEBUG_INFORMATION_FORMAT or if they're on an older cmake).