Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jets FFI fails on MacOS #257

Open
sanket1729 opened this issue Dec 21, 2024 · 6 comments
Open

Jets FFI fails on MacOS #257

sanket1729 opened this issue Dec 21, 2024 · 6 comments

Comments

@sanket1729
Copy link
Member

Running cargo test on fbe88d6f703c2f3b74f52eb3eebf60411606ed42 . This need not be prioritized, but mainly an informational issue.

failures:
    bit_machine::tests::crash_regression1
    human_encoding::parse::tests::bip340_program
    human_encoding::parse::tests::simple_program
    human_encoding::tests::filled_witness
    jet::elements::tests::test_ffi_env
    jet::tests::test_ffi_jet
    node::commit::tests::shared_witnesses
    policy::satisfy::tests::satisfy_after
    policy::satisfy::tests::satisfy_and
    policy::satisfy::tests::satisfy_asm
    policy::satisfy::tests::satisfy_older
    policy::satisfy::tests::satisfy_or
    policy::satisfy::tests::satisfy_pk
    policy::satisfy::tests::satisfy_sha256
    policy::satisfy::tests::satisfy_thresh
    policy::serialize::tests::execute_after
    policy::serialize::tests::execute_and
    policy::serialize::tests::execute_and_true
    policy::serialize::tests::execute_older
    policy::serialize::tests::execute_or
    policy::serialize::tests::execute_pk
    policy::serialize::tests::execute_sha256
    policy::serialize::tests::execute_threshold
@apoelstra
Copy link
Collaborator

Could this be an endianness issue?

@sanket1729
Copy link
Member Author

My system is little endian. Which I think is the most common and the one rust-simplicity expects?

@sanket1729
Copy link
Member Author

Okay, I am failing the sanity_checks for FFI. Maybe, we can somehow make this a compile time check.

std::mem::size_of::<crate::ffi::UWORD>() != crate::ffi::c_sizeof_UWORD

@sanket1729
Copy link
Member Author

I am not familiar with MacOS, but it looks like, UWORD uint_fast16_t typically expands to 2 byte. In contrast, on Linux, it often expands to 8 bytes (64 bits), where 64-bit operations are considered faster or more efficient given the architecture.

When we wrote the bindings, we assume UWORD which is uint_fast16_t maps to usize

@sanket1729
Copy link
Member Author

fast_* types which don't really define particular sizes are really hard to work with FFI across systems :( .

@sanket1729
Copy link
Member Author

sanket1729 commented Dec 21, 2024

And as expected changing

- pub type c_uint_fast16_t = usize;
+ pub type c_uint_fast16_t = u16;

fixes the issue. Figuring out a programmatic way to do this might be annoying. Maybe the new std::ffi has things that can help with fast* type

@sanket1729 sanket1729 changed the title Jets FFI fails on MacOS Jets FFI fails on MacOS/AMD Dec 21, 2024
@sanket1729 sanket1729 changed the title Jets FFI fails on MacOS/AMD Jets FFI fails on MacOS Dec 21, 2024
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

No branches or pull requests

2 participants