eip1962 icon indicating copy to clipboard operation
eip1962 copied to clipboard

Use libc c_char strings to unblock builds for Arm64

Open garyschulte opened this issue 4 years ago • 2 comments

Use libc c_char references to defer to the platform char implementation rather than using signed char (i8).

This allows us to build on Arm64 platforms where char is unsigned.

ref:

https://stackoverflow.com/questions/47684111/make-string-type-compatible-with-arm/47684200 https://users.rust-lang.org/t/expected-const-i8-found-const-u8-for-c-function-pointer-waiting-for-a-const-char/2441 https://github.com/remacs/remacs/issues/1393 etc.

Otherwise arm64 gets build errors such as:

...
error[E0308]: mismatched types
  --> src/public_interface/eip196/c_api.rs:58:73
   |
58 |     let err_out_i8: &mut [i8] = unsafe { std::slice::from_raw_parts_mut(err, EIP196_PREALLOCATE_FOR_ERROR_BYTES) };
   |                                                                         ^^^ expected `i8`, found `u8`
   |
   = note: expected raw pointer `*mut i8`
              found raw pointer `*mut u8`

              ...

Built and tested on Arm64 linux and x86_64 linux

garyschulte avatar Oct 26 '21 22:10 garyschulte

@shamatar when you have time would you 👀 ? TIA

garyschulte avatar Nov 16 '21 19:11 garyschulte

Oh, that slipped off from my radar. Can you hide libc under feature flag, as it's not required unless there are EIP related features?

shamatar avatar Nov 16 '21 21:11 shamatar