Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit 59a69a0

Browse files
author
bors-servo
authored
Auto merge of #440 - servo:macfix, r=Manishearth
Work around inconsistent padding from different LLVM versions. This allows building with LLVM 4 or 6 and unbreaks my mac cross-compilation. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/440) <!-- Reviewable:end -->
2 parents d15b976 + 8f50cb1 commit 59a69a0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs"
33
description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine."
44
repository = "https://github.com/servo/rust-mozjs"
5-
version = "0.9.1"
5+
version = "0.9.2"
66
authors = ["The Servo Project Developers"]
77
build = "build.rs"
88
license = "MPL-2.0"

src/conversions.rs

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use rust::maybe_wrap_value;
4444
use libc;
4545
use num_traits::{Bounded, Zero};
4646
use std::borrow::Cow;
47+
use std::mem;
4748
use std::rc::Rc;
4849
use std::{ptr, slice};
4950

@@ -601,11 +602,18 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T
601602
return Ok(ConversionResult::Failure("Value is not an object".into()));
602603
}
603604

605+
// Depending on the version of LLVM in use, bindgen can end up including
606+
// a padding field in the ForOfIterator. To support multiple versions of
607+
// LLVM that may not have the same fields as a result, we create an empty
608+
// iterator instance and initialize a non-empty instance using the empty
609+
// instance as a base value.
610+
let zero = mem::zeroed();
604611
let mut iterator = ForOfIterator {
605612
cx_: cx,
606613
iterator: RootedObject::new_unrooted(),
607614
nextMethod: RootedValue::new_unrooted(),
608615
index: ::std::u32::MAX, // NOT_ARRAY
616+
..zero
609617
};
610618
let iterator = ForOfIteratorGuard::new(cx, &mut iterator);
611619
let iterator = &mut *iterator.root;

0 commit comments

Comments
 (0)