Skip to content

Commit bea8321

Browse files
authored
Rollup merge of rust-lang#57803 - jethrogb:jb/sgx-unwind-version, r=alexcrichton
Several changes to libunwind for SGX target Two fixes: * rust-lang#34978 bites again! * __rust_alloc are actually private symbols. Add new public versions. Also, these ones are `extern "C"`. Upstream changes (fortanix/llvm-project#2, fortanix/llvm-project#3): * b7357de Avoid too new relocation types being emitted * 0feefe5 Use new symbol names to call Rust allocator Fixes fortanix/rust-sgx#65
2 parents 8348f83 + 6abba95 commit bea8321

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc
3232
COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
3333
# We pass the commit id of the port of LLVM's libunwind to the build script.
3434
# Any update to the commit id here, should cause the container image to be re-built from this point on.
35-
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "bbe23902411be88d7388f381becefadd6e3ef819"
35+
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "13fad13f8ea83a8da58d04a5faa45943151b3398"
3636

3737
COPY scripts/sccache.sh /scripts/
3838
RUN sh /scripts/sccache.sh

src/libstd/sys/sgx/rwlock.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::{self, Layout};
12
use num::NonZeroUsize;
23
use slice;
34
use str;
@@ -147,6 +148,7 @@ impl RWLock {
147148
self.__write_unlock(rguard, wguard);
148149
}
149150

151+
// only used by __rust_rwlock_unlock below
150152
#[inline]
151153
unsafe fn unlock(&self) {
152154
let rguard = self.readers.lock();
@@ -164,6 +166,7 @@ impl RWLock {
164166

165167
const EINVAL: i32 = 22;
166168

169+
// used by libunwind port
167170
#[no_mangle]
168171
pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RWLock) -> i32 {
169172
if p.is_null() {
@@ -190,6 +193,8 @@ pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RWLock) -> i32 {
190193
return 0;
191194
}
192195

196+
// the following functions are also used by the libunwind port. They're
197+
// included here to make sure parallel codegen and LTO don't mess things up.
193198
#[no_mangle]
194199
pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) {
195200
if s < 0 {
@@ -206,6 +211,16 @@ pub unsafe extern "C" fn __rust_abort() {
206211
::sys::abort_internal();
207212
}
208213

214+
#[no_mangle]
215+
pub unsafe extern "C" fn __rust_c_alloc(size: usize, align: usize) -> *mut u8 {
216+
alloc::alloc(Layout::from_size_align_unchecked(size, align))
217+
}
218+
219+
#[no_mangle]
220+
pub unsafe extern "C" fn __rust_c_dealloc(ptr: *mut u8, size: usize, align: usize) {
221+
alloc::dealloc(ptr, Layout::from_size_align_unchecked(size, align))
222+
}
223+
209224
#[cfg(test)]
210225
mod tests {
211226

0 commit comments

Comments
 (0)