Skip to content

forward the crc target feature on aarch64#270

Open
folkertdev wants to merge 4 commits into
rust-lang:mainfrom
folkertdev:forward-crc-feature
Open

forward the crc target feature on aarch64#270
folkertdev wants to merge 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.

Copy link
Copy Markdown
Member

@Byron Byron left a comment

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

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