Skip to content

forward the crc target feature on aarch64#270

Merged
Byron merged 4 commits into
rust-lang:mainfrom
folkertdev:forward-crc-feature
Jun 18, 2026
Merged

forward the crc target feature on aarch64#270
Byron merged 4 commits into
rust-lang:mainfrom
folkertdev:forward-crc-feature

Conversation

@folkertdev

Copy link
Copy Markdown
Contributor

When statically linking zlib (i.e. when building it from source), forward the crc target feature. zlib does not dynamically detect it, and apparently it is not part of the baseline feature set in C.

@Byron Byron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot! This PR seems like something I should have merged before making a new release, but here we are 😅.

As now there is no rush, maybe you can take a look at this Codex-generated comment. It looks like CI wouldn't detect the issue. Maybe this is also something this PR could add, maybe even first, to reproduce the issue (please see the second block).

I am setting the PR to changes requested, just because I don't have other means of labeling it. All it needs is your feedback/investigation.


[P2] Guard CRC march flag for MSVC compilers — /Users/byron/dev/github.com/rust-lang/libz-sys/build.rs:146-147
When stock zlib is built for an AArch64 MSVC target with -C target-feature=+crc, this raw GCC/Clang -march=armv8-a+crc flag is passed to the C compiler. cl.exe does not accept that option, so aarch64-pc-windows-msvc builds that enable CRC will fail in the build script; gate this on the compiler family or use a supported/probed flag path.


No, this issue should not show up in the current CI configuration.

The review comment looks valid as a latent bug: MSVC targets always build bundled zlib via build.rs, and the CRC path unconditionally passes GCC/Clang syntax at build.rs.

But CI does not cover the failing combination:

  • Windows CI only tests x86_64/i686 MSVC/GNU targets, not aarch64-pc-windows-msvc: .github/workflows/ci.yml
  • Linux CI tests AArch64, but only Linux targets: .github/workflows/ci.yml
  • I found no workflow/config setting RUSTFLAGS=-Ctarget-feature=+crc or similar.
  • rustc --print cfg --target aarch64-pc-windows-msvc reports target_feature="neon" by default, not crc.

So CI would only catch this if it added an aarch64-pc-windows-msvc build with CRC enabled, for example via RUSTFLAGS="-Ctarget-feature=+crc".

@folkertdev folkertdev force-pushed the forward-crc-feature branch 5 times, most recently from 708e6ed to 0c09327 Compare May 31, 2026 10:57
@folkertdev folkertdev force-pushed the forward-crc-feature branch from 0c09327 to bb7eaeb Compare May 31, 2026 13:20
@folkertdev folkertdev requested a review from Byron May 31, 2026 13:20
@folkertdev

Copy link
Copy Markdown
Contributor Author

Later commits

  • add a test for --features=static
  • suppress a warning in systest on msvc (from what I understand it verifies the rust bindings against the C signatures)
  • run the test suite on MSVC aarch64 windows

@folkertdev

Copy link
Copy Markdown
Contributor Author

ping @Byron

@Byron Byron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the hiatus, that was just bad timing, and I'm now catching up on everything I have missed.

With that said, I took a look at every commit and am thankful for the added test coverage. With that I think everything is addressed.

Also, there now is an aarch64 run on Windows, which is great for peace of mind.

With that, I think we should be good to go, also assuming that you could validate locally that the CRC feature forwarding does give an observable speedup.

@Byron Byron merged commit db6e8c3 into rust-lang:main Jun 18, 2026
51 checks passed
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.

2 participants