Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmozjs_sys + target=android-i686: Rust compilation error #21093
Comments
|
Message appeared after 2544db1 |
|
@asajeffrey @jdm is away. Maybe you can help. |
|
I think there may be a rustc bug causing the error message to show the wrong span of source, and a bindgen bug causing an invalid cast to be emitted. It would help to look at the generated |
|
Not sure where this is failing. Can't find an obvious culprit: https://gist.github.com/paulrouget/1700b9da726208d4022f1fe2e4ecb610 |
|
Does mach build --android work? |
|
Also, you may be picking up an old jsapi.rs, try removing it and see if that helps. |
impl < AllocPolicy > HashTable < AllocPolicy > {
# [ inline ] pub fn gen ( & self ) -> u64 {
unsafe { :: std :: mem :: transmute (
self . _bitfield_1 . get ( 0usize , 56u8 ) as [ u32 ; 2usize ] ) } } |
|
Which in my copy of jsapi.rs (generated on and for linux) is: pub fn gen(&self) -> u64 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 56u8) as u64) }
}@emilio any ideas what's going on here? |
|
Yeah, this is because uint64_t is 4-byte aligned in that arch. This is a bindgen bug since it's not supposed to care about alignment in this case, but I couldn't repro with: struct Table
{
unsigned long long foo: 56;
unsigned long long bar: 8;
};Which generates the following for
So a test-case for this would be extremely helpful. |
blob() does care about alignment, so we can get into an architecture where there are integers where size != align. This is a tentative fix for servo/servo#21093, though as mentioned there I couldn't find a repro on my machine.
|
https://searchfox.org/mozilla-central/rev/39b790b29543a4718d876d8ca3fd179d82fc24f7/js/public/HashTable.h#1224 is the relevant data structure if I'm not wrong... rust-lang/rust-bindgen#1339 is a potential fix for this, though a repro would be nice. |
|
@emilio Hmm, running test.h through bindgen without the #[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Table {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize], u64>,
pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_Table() {
assert_eq!(
::std::mem::size_of::<Table>(),
8usize,
concat!("Size of: ", stringify!(Table))
);
assert_eq!(
::std::mem::align_of::<Table>(),
8usize,
concat!("Alignment of ", stringify!(Table))
);
}
impl Table {
#[inline]
pub fn foo(&self) -> ::std::os::raw::c_ulonglong {
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 56u8) as u64) }
}
#[inline]
pub fn set_foo(&mut self, val: ::std::os::raw::c_ulonglong) {
unsafe {
let val: u64 = ::std::mem::transmute(val);
self._bitfield_1.set(0usize, 56u8, val as u64)
}
}
#[inline]
pub fn bar(&self) -> ::std::os::raw::c_ulonglong {
unsafe { ::std::mem::transmute(self._bitfield_1.get(56usize, 8u8) as u64) }
}
#[inline]
pub fn set_bar(&mut self, val: ::std::os::raw::c_ulonglong) {
unsafe {
let val: u64 = ::std::mem::transmute(val);
self._bitfield_1.set(56usize, 8u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(
foo: ::std::os::raw::c_ulonglong,
bar: ::std::os::raw::c_ulonglong,
) -> __BindgenBitfieldUnit<[u8; 8usize], u64> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize], u64> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 56u8, {
let foo: u64 = unsafe { ::std::mem::transmute(foo) };
foo as u64
});
__bindgen_bitfield_unit.set(56usize, 8u8, {
let bar: u64 = unsafe { ::std::mem::transmute(bar) };
bar as u64
});
__bindgen_bitfield_unit
}
}which includes the Also, the opaque type generated is |
|
Looks like we can work round this, by declaring |
|
I have a branch with the workaround: https://github.com/asajeffrey/mozjs/tree/opaque-hashtable @paul: can you check to see if using this fixes your problem? |
|
Submitted workaround PR servo/mozjs#141 |
Make Make js::detail::HashTable.* opaque This is a workaround for servo/servo#21093. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/mozjs/141) <!-- Reviewable:end -->
|
@asajeffrey this fixes it! Thank you. |
Updated mozjs_sys to v0.51.3 <!-- Please describe your changes on the following line: --> Allows building servo for target `i686-linux-android`. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #21093 - [X] These changes do not require tests because deperndency update <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21102) <!-- Reviewable:end -->
Updated mozjs_sys to v0.51.3 <!-- Please describe your changes on the following line: --> Allows building servo for target `i686-linux-android`. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #21093 - [X] These changes do not require tests because deperndency update <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21102) <!-- Reviewable:end -->
Updated mozjs_sys to v0.51.3 <!-- Please describe your changes on the following line: --> Allows building servo for target `i686-linux-android`. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #21093 - [X] These changes do not require tests because deperndency update <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21102) <!-- Reviewable:end -->
blob() does care about alignment, so we can get into an architecture where there are integers where size != align. This is a tentative fix for servo/servo#21093, though as mentioned there I couldn't find a repro on my machine.
Fix integer_type to actually return integers all the time. blob() does care about alignment, so we can get into an architecture where there are integers where size != align. This is a tentative fix for servo/servo#21093, though as mentioned there I couldn't find a repro on my machine.
./mach build --target=i686-linux-android -d