tov / libffi-rs

Rust bindings for libffi
Apache License 2.0
104 stars 36 forks source link

Add support for the loongarch64 architecture #75

Closed heiher closed 1 year ago

yorickpeterse commented 1 year ago

@heiher Does qemu support this architecture? If so, please add this to the test matrix similar to https://github.com/tov/libffi-rs/pull/72/files.

heiher commented 1 year ago

@yorickpeterse Yes, QEMU does support this architecture. However, the latest version of Docker Ubuntu does not yet support it. Therefore, I conducted tests natively, and the results are as follows:

cargo test --no-default-features
   Compiling cc v1.0.79
   Compiling libc v0.2.141
   Compiling libffi-sys v2.2.1 (/home/hev/rust/libffi-rs/libffi-sys-rs)
   Compiling libffi v3.2.0 (/home/hev/rust/libffi-rs/libffi-rs)
    Finished test [unoptimized + debuginfo] target(s) in 13.30s
     Running unittests src/lib.rs (target/debug/deps/libffi-17240bee0f0172ee)

running 12 tests
test middle::test::call ... ok
test middle::test::clone_cif ... ok
test middle::types::test::clone_struct ... ok
test middle::types::test::clone_u64 ... ok
test middle::types::test::create_struct ... ok
test high::test::new ... ok
test high::test::new_mut ... ok
test high::test::new_with_cif_mut ... ok
test high::test::new_with_cif ... ok
test middle::test::rust_lambda ... ok
test middle::test::closure ... ok
test middle::types::test::create_u64 ... ok

test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/libffi_sys-5bdfbe382a0b5751)

running 1 test
test test::test_function_with_two_arguments ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests libffi

running 17 tests
test src/low.rs - low::type_tag (line 178) ... ok
test src/low.rs - low::closure_free (line 389) ... ok
test src/low.rs - low::closure_alloc (line 365) ... ok
test src/low.rs - low::prep_cif (line 235) ... ok
test src/low.rs - low::prep_closure (line 464) ... ok
test src/low.rs - low::prep_closure_mut (line 556) ... ok
test src/middle/builder.rs - middle::builder::Builder (line 23) ... ok
test src/low.rs - low::call (line 321) ... ok
test src/lib.rs - (line 72) ... ok
test src/high/mod.rs - high (line 35) ... ok
test src/middle/mod.rs - middle::Cif (line 65) ... ok
test src/middle/mod.rs - middle::Closure (line 194) ... ok
test src/high/mod.rs - high (line 55) ... ok
test src/high/call.rs - high::call (line 8) ... ok
test src/high/call.rs - high::call::ffi_call (line 99) ... ok
test src/high/call.rs - high::call::call (line 64) ... ok
test src/middle/types.rs - middle::types::Type (line 45) ... ok

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.73s

   Doc-tests libffi-sys

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
cargo test --features system
   Compiling cc v1.0.79
   Compiling libc v0.2.141
   Compiling libffi-sys v2.2.1 (/home/hev/rust/libffi-rs/libffi-sys-rs)
   Compiling libffi v3.2.0 (/home/hev/rust/libffi-rs/libffi-rs)
    Finished test [unoptimized + debuginfo] target(s) in 6.66s
     Running unittests src/lib.rs (target/debug/deps/libffi-e9d2cf5f3b99046a)

running 12 tests
test high::test::new_with_cif ... ok
test high::test::new ... ok
test middle::test::call ... ok
test high::test::new_mut ... ok
test high::test::new_with_cif_mut ... ok
test middle::test::clone_cif ... ok
test middle::test::rust_lambda ... ok
test middle::test::closure ... ok
test middle::types::test::clone_struct ... ok
test middle::types::test::clone_u64 ... ok
test middle::types::test::create_struct ... ok
test middle::types::test::create_u64 ... ok

test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/libffi_sys-2363ea291f277eba)

running 1 test
test test::test_function_with_two_arguments ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests libffi

running 17 tests
test src/low.rs - low::type_tag (line 178) ... ok
test src/low.rs - low::closure_alloc (line 365) ... ok
test src/low.rs - low::prep_cif (line 235) ... ok
test src/low.rs - low::prep_closure_mut (line 556) ... ok
test src/low.rs - low::prep_closure (line 464) ... ok
test src/low.rs - low::closure_free (line 389) ... ok
test src/middle/builder.rs - middle::builder::Builder (line 23) ... ok
test src/low.rs - low::call (line 321) ... ok
test src/lib.rs - (line 72) ... ok
test src/middle/mod.rs - middle::Cif (line 65) ... ok
test src/middle/mod.rs - middle::Closure (line 194) ... ok
test src/high/mod.rs - high (line 55) ... ok
test src/high/call.rs - high::call (line 8) ... ok
test src/high/mod.rs - high (line 35) ... ok
test src/high/call.rs - high::call::call (line 64) ... ok
test src/high/call.rs - high::call::ffi_call (line 99) ... ok
test src/middle/types.rs - middle::types::Type (line 45) ... ok

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.74s

   Doc-tests libffi-sys

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
heiher commented 1 year ago

https://github.com/rust-lang/rust/pull/96971 merged. Maybe we are ready to go? :)

yorickpeterse commented 1 year ago

@heiher Is there any indication as to when QEMU on the GitHub actions image would support this architecture? Or is there perhaps a way to use a newer version of QEMU (without compiling it from source every build)? I'm hesitant to add/claim support of architectures we can't test for, unless there's simply no reasonable option available.

heiher commented 1 year ago

@yorickpeterse It appears that QEMU is not an issue, but since the stable and beta channels currently do not support loongarch64, we would like to request that CI support only be added after the loongarch64-unknown-linux-gnu target is promoted to Tier 2. What is your opinion on this? Thank you.

yorickpeterse commented 1 year ago

@heiher Ah I see. I'm guessing it will take a while for Rust to support this architecture, so in that case we'll just merge this in the mean time. Thanks!