Skip to content

Fix rust build on arm64 Linux, where C char is unsigned - #4245

Merged
kddnewton merged 1 commit into
ruby:mainfrom
sax:arm64-linux
Oct 8, 2026
Merged

kddnewton merged 1 commit into
ruby:mainfrom
sax:arm64-linux

Conversation

@sax

@sax sax commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Options#build_options cast each scope local's pointer to *const i8 before passing it to pm_string_constant_init. bindgen generates the parameter as *const c_char, which is i8 on x86 Linux, macOS and Windows but u8 on Linux ARM, so the crate failed to compile there:

error[E0308]: mismatched types
  --> ruby-prism/src/lib.rs:306:64
   expected `*const u8`, found `*const i8`

Use .cast() and let the type be inferred from the bindings instead. CI only builds on platforms where char is signed, which is why this went unnoticed.

Options#build_options cast each scope local's pointer to `*const i8`
before passing it to pm_string_constant_init.  bindgen generates the
parameter as `*const c_char`, which is `i8` on x86 Linux, macOS and
Windows but `u8` on Linux ARM, so the crate failed to compile there:

    error[E0308]: mismatched types
      --> ruby-prism/src/lib.rs:306:64
       expected `*const u8`, found `*const i8`

Use `.cast()` and let the type be inferred from the bindings instead.
CI only builds on platforms where char is signed, which is why this
went unnoticed.
@kddnewton
kddnewton merged commit 2a29deb into ruby:main Oct 8, 2026
107 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