Skip to content

Commit 3ef6e9f

Browse files
authored
Bump bindgen to 0.71.1 (#530)
* Remove unused import Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Bump bindgen to 0.71.1 - Use the bindgen opaque struct where appropriate. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Bump mozjs-sys to 128.3-7 Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Specify the rust target for jsglue Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * blocklist js::ProfilingStackFrame We don't use the typ and on i686-linux-android bindgen generates a wrong struct with failing layout tests. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
1 parent 06a83db commit 3ef6e9f

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010
[workspace.dependencies]
1111
cc = "1"
1212
libc = "0.2"
13-
bindgen = { version = "0.69", default-features = false, features = [
13+
bindgen = { version = "0.71.1", default-features = false, features = [
1414
"runtime",
1515
"which-rustfmt",
1616
] }

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.128.3-6"
5+
version = "0.128.3-7"
66
authors = ["Mozilla"]
77
links = "mozjs"
88
build = "build.rs"

mozjs-sys/build.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ fn should_build_from_source() -> bool {
142142
}
143143
}
144144

145+
/// Returns the Rust version bindgen should target
146+
pub(crate) fn minimum_rust_target() -> bindgen::RustTarget {
147+
let Ok(rust_target) = bindgen::RustTarget::stable(80, 0) else {
148+
// `InvalidRustTarget` does not implement Debug, so we manually panic.
149+
panic!("Unsupported Rust target")
150+
};
151+
rust_target
152+
}
153+
145154
#[cfg(not(windows))]
146155
fn find_make() -> OsString {
147156
if let Some(make) = env::var_os("MAKE") {
@@ -412,7 +421,7 @@ fn build_jsapi_bindings(build_dir: &Path) {
412421
config &= !bindgen::CodegenConfig::METHODS;
413422

414423
let mut builder = bindgen::builder()
415-
.rust_target(bindgen::RustTarget::Stable_1_59)
424+
.rust_target(minimum_rust_target())
416425
.header("./src/jsapi.cpp")
417426
// Translate every enum with the "rustified enum" strategy. We should
418427
// investigate switching to the "constified module" strategy, which has
@@ -621,6 +630,7 @@ const BLACKLIST_TYPES: &'static [&'static str] = &[
621630
"JS::MutableHandleVector",
622631
"JS::Rooted.*Vector",
623632
"JS::RootedValueArray",
633+
"js::ProfilingStackFrame.*",
624634
// Classes we don't use and we cannot generate their
625635
// types properly from bindgen so we'll skip them for now.
626636
"JS::dbg::Builder",
@@ -760,6 +770,7 @@ mod jsglue {
760770
println!("cargo:rerun-if-changed=src/jsglue.cpp");
761771
let mut builder = bindgen::Builder::default()
762772
.header("./src/jsglue.cpp")
773+
.rust_target(super::minimum_rust_target())
763774
.parse_callbacks(Box::new(CustomCargoCallbacks::new()))
764775
.size_t_is_usize(true)
765776
.formatter(bindgen::Formatter::Rustfmt)

mozjs-sys/src/jsimpls.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use crate::jsval::{JSVal, UndefinedValue};
2727
use std::marker::PhantomData;
2828
use std::ops::Deref;
2929
use std::ops::DerefMut;
30-
use std::os::raw::c_void;
3130
use std::ptr;
3231

3332
impl<T> Deref for JS::Handle<T> {
@@ -200,7 +199,7 @@ impl JS::AutoGCRooter {
200199
#[allow(non_snake_case)]
201200
let autoGCRooters: *mut _ = {
202201
let rooting_cx = cx as *mut JS::RootingContext;
203-
&mut (*rooting_cx).autoGCRooters_[self.kind_ as usize]
202+
&mut (*rooting_cx).autoGCRooters_.0[self.kind_ as usize]
204203
};
205204
self.stackTop = autoGCRooters as *mut *mut _;
206205
self.down = *autoGCRooters as *mut _;
@@ -420,7 +419,7 @@ impl RootedBase {
420419
unsafe fn get_root_stack(cx: *mut JSContext, kind: JS::RootKind) -> *mut *mut RootedBase {
421420
let kind = kind as usize;
422421
let rooting_cx = Self::get_rooting_context(cx);
423-
&mut (*rooting_cx).stackRoots_[kind] as *mut _ as *mut _
422+
&mut (*rooting_cx).stackRoots_.0[kind] as *mut _ as *mut _
424423
}
425424

426425
unsafe fn get_rooting_context(cx: *mut JSContext) -> *mut JS::RootingContext {

mozjs/src/rust.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,11 @@ impl Runtime {
369369
});
370370

371371
#[cfg(target_pointer_width = "64")]
372-
InitSelfHostedCode(js_context, [0u64; 2], None);
372+
let cache = crate::jsapi::__BindgenOpaqueArray::<u64, 2>::default();
373373
#[cfg(target_pointer_width = "32")]
374-
InitSelfHostedCode(js_context, [0u32; 2], None);
374+
let cache = crate::jsapi::__BindgenOpaqueArray::<u32, 2>::default();
375+
376+
InitSelfHostedCode(js_context, cache, None);
375377

376378
SetWarningReporter(js_context, Some(report_warning));
377379

0 commit comments

Comments
 (0)