Skip to content

Commit 1b12232

Browse files
Jethro Beekmanpnkfelix
Jethro Beekman
authored andcommitted
Fix SGX RWLock representation for UnsafeCell niche fix
1 parent 3e04722 commit 1b12232

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/ci/docker/dist-various-2/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc
4848
COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
4949
# We pass the commit id of the port of LLVM's libunwind to the build script.
5050
# Any update to the commit id here, should cause the container image to be re-built from this point on.
51-
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "53b586346f2c7870e20b170decdc30729d97c42b"
51+
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "5125c169b30837208a842f85f7ae44a83533bd0e"
5252

5353
COPY dist-various-2/build-wasi-toolchain.sh /tmp/
5454
RUN /tmp/build-wasi-toolchain.sh

src/libstd/sys/sgx/rwlock.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ pub struct RWLock {
1010
writer: SpinMutex<WaitVariable<bool>>,
1111
}
1212

13-
// Below is to check at compile time, that RWLock has size of 128 bytes.
13+
// Check at compile time that RWLock size matches C definition (see test_c_rwlock_initializer below)
1414
#[allow(dead_code)]
1515
unsafe fn rw_lock_size_assert(r: RWLock) {
16-
mem::transmute::<RWLock, [u8; 128]>(r);
16+
mem::transmute::<RWLock, [u8; 144]>(r);
1717
}
1818

1919
impl RWLock {
@@ -210,15 +210,17 @@ mod tests {
210210
// be changed too.
211211
#[test]
212212
fn test_c_rwlock_initializer() {
213+
#[rustfmt::skip]
213214
const RWLOCK_INIT: &[u8] = &[
214-
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
215-
0x0, 0x0, 0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0,
220+
/* 0x50 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
221+
/* 0x60 */ 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
222+
/* 0x70 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
223+
/* 0x80 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
222224
];
223225

224226
#[inline(never)]
@@ -239,7 +241,7 @@ mod tests {
239241
zero_stack();
240242
let mut init = MaybeUninit::<RWLock>::zeroed();
241243
rwlock_new(&mut init);
242-
assert_eq!(mem::transmute::<_, [u8; 128]>(init.assume_init()).as_slice(), RWLOCK_INIT)
244+
assert_eq!(mem::transmute::<_, [u8; 144]>(init.assume_init()).as_slice(), RWLOCK_INIT)
243245
};
244246
}
245247
}

0 commit comments

Comments
 (0)