Skip to content

Conversation

filipw
Copy link

@filipw filipw commented Sep 1, 2025

libc::c_char in Rust differs by target architecture:

  • On most platforms (x86-64 Windows, Linux, macOS) it is i8.
  • On Windows ARM64 (AArch64) it is u8.

This change unconditionally casts pointers with as *const _:

  • On Windows ARM64, this converts *const i8 to *const u8 (or vice versa), resolving the type mismatch that caused compilation to fail.
  • On other platforms, the cast is effectively a no-op but ensures the code compiles everywhere.

CStr::from_ptr only requires a pointer to a null-terminated byte sequence. The underlying representation of i8 and u8 is identical, so the cast is sound.

This change allows building and running on Windows ARM (yes, under OQS_PERMIT_UNSUPPORTED_ARCHITECTURE)

By the way - Windows on arm Github Agents are available for free now, so it might be nice to extend the CI setup with that https://github.com/orgs/community/discussions/155713.

`libc::c_char` in Rust differs by target architecture:
- On most platforms (x86-64 Windows, Linux, macOS) it is `i8`.
- On Windows ARM64 (AArch64) it is `u8`.

This change unconditionally casts pointers with `as *const _`:
- On Windows ARM64, this converts `*const i8` to `*const u8` (or vice versa), resolving the type mismatch that caused compilation to fail.
- On other platforms, the cast is effectively a no-op but ensures the code compiles everywhere.

`CStr::from_ptr` only requires a pointer to a null-terminated byte sequence.
The underlying representation of `i8` and `u8` is identical, so the cast is
sound.

Signed-off-by: filipw <[email protected]>
@dstebila dstebila added this pull request to the merge queue Sep 11, 2025
@dstebila dstebila mentioned this pull request Sep 11, 2025
@dstebila
Copy link
Member

Thanks very much! I've created #300 to add builds on Windows ARM.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 11, 2025
@dstebila
Copy link
Member

It looks like it is failing on some CI tests now, e.g. https://github.com/open-quantum-safe/liboqs-rust/actions/runs/17648174011/job/50151644796. I'm not sure what's going on here -- do any of those errors mean anything to you?

@filipw
Copy link
Author

filipw commented Sep 11, 2025

I don't think this is related to this PR (after all the original checks passed fine).
This looks like an OpenSSL linking issue caused by windows-latest.

Most likely cause is this actions/runner-images#12677
windows-latest is being gradually moved from Windows Server 2022 to 2025 this month and the preinstalled stuff is changing (e.g. from OpenSSL 1.1.1 to 3.4.0)

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