Skip to content

Fix zstd install rules breaking clr.runtime clean build#125063

Merged
rzikm merged 2 commits intodotnet:mainfrom
rzikm:Zstd-build-errors-291f
Mar 6, 2026
Merged

Fix zstd install rules breaking clr.runtime clean build#125063
rzikm merged 2 commits intodotnet:mainfrom
rzikm:Zstd-build-errors-291f

Conversation

@rzikm
Copy link
Member

@rzikm rzikm commented Mar 2, 2026

Summary

Fix CMake build failure when building clr.runtime from a clean build (instead of clr.native).

Problem

When building clr.runtime from clean, the install step fails with:

CMake Error at _deps/zstd-build/lib/cmake_install.cmake:53 (file):
    file INSTALL cannot find
    ".../_deps/zstd-build/lib/zstd_static.lib"

This happens because zstd's own install() rules are included in the build's install step. When the runtime component install runs, it tries to install zstd_static.lib — but that file was never built because libzstd_static is only built as a dependency of System.IO.Compression.Native, which is not part of the runtime build target.

Fix

Replace FetchContent with a direct add_subdirectory() call using EXCLUDE_FROM_ALL, which reliably prevents zstd's own install() rules from being included in the component install. The EXCLUDE_FROM_ALL parameter on add_subdirectory() has properly suppressed install rules since CMake 3.14, making it compatible with the project's CMake 3.26 minimum.

The explicit install() calls in System.IO.Compression.Native/CMakeLists.txt that install libzstd_static to the correct destinations continue to work as before since they target the libzstd_static target directly (not via zstd's own install rules).

Fixes #124234

Use add_subdirectory with EXCLUDE_FROM_ALL instead of FetchContent to
prevent zstd's own install() rules from being included in the build's
install step. Without this, building clr.runtime from a clean build
fails because the install step tries to install zstd_static.lib which
was not built as part of the runtime target.

Fixes dotnet#124234

Co-authored-by: Copilot <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the vendored zstd CMake integration to avoid zstd’s upstream install() rules being pulled into the clr.runtime component install, which can fail in clean subset builds when zstd’s static library was never built.

Changes:

  • Replaces FetchContent usage in src/native/external/zstd.cmake with a direct add_subdirectory(... EXCLUDE_FROM_ALL) call.
  • Adds rationale comments explaining the clr.runtime clean-build install failure and why EXCLUDE_FROM_ALL is used.

Copilot AI review requested due to automatic review settings March 2, 2026 17:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@rzikm
Copy link
Member Author

rzikm commented Mar 6, 2026

/ba-g Test failures are unrelated

@rzikm rzikm merged commit 7db8a8c into dotnet:main Mar 6, 2026
155 of 163 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Building the clr.runtime subset from a clean build fails with zstd build error

3 participants