Skip to content

Commit 559b7a6

Browse files
authored
Merge pull request #4634 from nia-e/new-libffi
native-lib: bump libffi
2 parents e3787bd + 9d14f4d commit 559b7a6

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

src/tools/miri/Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,19 +794,19 @@ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
794794

795795
[[package]]
796796
name = "libffi"
797-
version = "4.1.1"
797+
version = "5.0.0"
798798
source = "registry+https://github.com/rust-lang/crates.io-index"
799-
checksum = "e7681c6fab541f799a829e44a445a0666cf8d8a6cfebf89419e6aed52c604e87"
799+
checksum = "0444124f3ffd67e1b0b0c661a7f81a278a135eb54aaad4078e79fbc8be50c8a5"
800800
dependencies = [
801801
"libc",
802802
"libffi-sys",
803803
]
804804

805805
[[package]]
806806
name = "libffi-sys"
807-
version = "3.3.2"
807+
version = "4.0.0"
808808
source = "registry+https://github.com/rust-lang/crates.io-index"
809-
checksum = "7b0d828d367b4450ed08e7d510dc46636cd660055f50d67ac943bfe788767c29"
809+
checksum = "3d722da8817ea580d0669da6babe2262d7b86a1af1103da24102b8bb9c101ce7"
810810
dependencies = [
811811
"cc",
812812
]

src/tools/miri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ features = ['unprefixed_malloc_on_supported_platforms']
3939
[target.'cfg(unix)'.dependencies]
4040
libc = "0.2"
4141
# native-lib dependencies
42-
libffi = { version = "4.1.1", optional = true }
42+
libffi = { version = "5.0.0", optional = true }
4343
libloading = { version = "0.8", optional = true }
4444
serde = { version = "1.0.219", features = ["derive"], optional = true }
4545

src/tools/miri/src/shims/native_lib/ffi.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ use libffi::middle::{Arg as ArgPtr, Cif, Type as FfiType};
99
///
1010
/// The safety invariants of the foreign function being called must be upheld (if any).
1111
pub unsafe fn call<R: libffi::high::CType>(fun: CodePtr, args: &mut [OwnedArg]) -> R {
12-
let arg_ptrs: Vec<_> = args.iter().map(|arg| arg.ptr()).collect();
1312
let cif = Cif::new(args.iter_mut().map(|arg| arg.ty.take().unwrap()), R::reify().into_middle());
14-
// SAFETY: Caller upholds that the function is safe to call, and since we
15-
// were passed a slice reference we know the `OwnedArg`s won't have been
16-
// dropped by this point.
13+
let arg_ptrs: Vec<_> = args.iter().map(|arg| ArgPtr::new(&*arg.bytes)).collect();
14+
// SAFETY: Caller upholds that the function is safe to call.
1715
unsafe { cif.call(fun, &arg_ptrs) }
1816
}
1917

@@ -31,16 +29,4 @@ impl OwnedArg {
3129
pub fn new(ty: FfiType, bytes: Box<[u8]>) -> Self {
3230
Self { ty: Some(ty), bytes }
3331
}
34-
35-
/// Creates a libffi argument pointer pointing to this argument's bytes.
36-
/// NB: Since `libffi::middle::Arg` ignores the lifetime of the reference
37-
/// it's derived from, it is up to the caller to ensure the `OwnedArg` is
38-
/// not dropped before unsafely calling `libffi::middle::Cif::call()`!
39-
fn ptr(&self) -> ArgPtr {
40-
// FIXME: Using `&self.bytes[0]` to reference the whole array is
41-
// definitely unsound under SB, but we're waiting on
42-
// https://github.com/libffi-rs/libffi-rs/commit/112a37b3b6ffb35bd75241fbcc580de40ba74a73
43-
// to land in a release so that we don't need to do this.
44-
ArgPtr::new(&self.bytes[0])
45-
}
4632
}

0 commit comments

Comments
 (0)