-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add SGX target to std and dependencies #56066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
030b1ed
22c4368
6c03640
c559216
4a35056
39f9751
1e44e2d
8d6edc9
1a894f1
59b79f7
6650f43
7bea6a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+30 −0 | .travis.yml | |
+27 −2 | Cargo.toml | |
+42 −0 | README.md | |
+2 −4 | src/dlmalloc.rs | |
+51 −101 | src/global.rs | |
+80 −47 | src/lib.rs | |
+3 −0 | src/linux.rs | |
+3 −0 | src/macos.rs | |
+68 −0 | src/sgx.rs | |
+2 −0 | src/wasm.rs | |
+1 −0 | tests/global.rs | |
+23 −30 | tests/smoke.rs |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ const fn done<T>() -> *mut Arc<T> { 1_usize as *mut _ } | |
unsafe impl<T> Sync for Lazy<T> {} | ||
|
||
impl<T> Lazy<T> { | ||
#[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed this cropping up in a few places for a few APIs, but how come this was necessary? (should be fine in any case, just curious) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ultimately comes down to the various There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm ok, that seems suspicious but it seems fine anyway There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe someone with more experience with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't call an unstable const fn from a stable one. You might be able to make all of the functions called from this one stable and then you won't need the unstable anymore. note that as of right now, you cannot call unsafe const fns from any const fn. If you want, just merge the PR as is and open an issue about it and assign it to me |
||
pub const fn new() -> Lazy<T> { | ||
Lazy { | ||
lock: Mutex::new(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ use intrinsics; | |
use mem; | ||
use ptr; | ||
use raw; | ||
use sys::stdio::{Stderr, stderr_prints_nothing}; | ||
use sys::stdio::panic_output; | ||
use sys_common::rwlock::RWLock; | ||
use sys_common::thread_info; | ||
use sys_common::util; | ||
|
@@ -193,7 +193,6 @@ fn default_hook(info: &PanicInfo) { | |
None => "Box<Any>", | ||
} | ||
}; | ||
let mut err = Stderr::new().ok(); | ||
let thread = thread_info::current_thread(); | ||
let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>"); | ||
|
||
|
@@ -215,17 +214,14 @@ fn default_hook(info: &PanicInfo) { | |
} | ||
}; | ||
|
||
let prev = LOCAL_STDERR.with(|s| s.borrow_mut().take()); | ||
match (prev, err.as_mut()) { | ||
(Some(mut stderr), _) => { | ||
write(&mut *stderr); | ||
let mut s = Some(stderr); | ||
LOCAL_STDERR.with(|slot| { | ||
*slot.borrow_mut() = s.take(); | ||
}); | ||
} | ||
(None, Some(ref mut err)) => { write(err) } | ||
_ => {} | ||
if let Some(mut local) = LOCAL_STDERR.with(|s| s.borrow_mut().take()) { | ||
write(&mut *local); | ||
let mut s = Some(local); | ||
LOCAL_STDERR.with(|slot| { | ||
*slot.borrow_mut() = s.take(); | ||
}); | ||
} else if let Some(mut out) = panic_output() { | ||
write(&mut out); | ||
} | ||
} | ||
|
||
|
@@ -485,7 +481,7 @@ fn rust_panic_with_hook(payload: &mut dyn BoxMeUp, | |
// Some platforms know that printing to stderr won't ever actually | ||
// print anything, and if that's the case we can skip the default | ||
// hook. | ||
Hook::Default if stderr_prints_nothing() => {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe at the time this was added this was an optimization for wasm specifically in LTO mode to ensure that lots of panicking infrastructure csan be removed because in this case the payload is never actually used. I haven't finished reading this patch yet, but it may be worthwhile running the wasm tests as they should in theory catch this if it's still a problem! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made sure the changes should have the same functionality, and I also checked that The crux is that currently in this target, checking whether there is a panic output mechanism prevents future use of the same (it's an atomic “take”). I can think if there's another way to restructure all this tomorrow, but this was the best I could come up with a few months ago :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, with regards to this and #56066 (comment), I conflated two things a little bit. In the SGX target, whether panicking can ever output anything at all is determined post-link time by setting/unsetting the The second requirement that leads to the "writer factory" in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I refactored this a bunch to use types instead of bare functions. I think it should be LTOable. Please take a look. |
||
Hook::Default if panic_output().is_none() => {} | ||
Hook::Default => { | ||
info.set_payload(payload.get()); | ||
default_hook(&info); | ||
|
@@ -494,7 +490,7 @@ fn rust_panic_with_hook(payload: &mut dyn BoxMeUp, | |
info.set_payload(payload.get()); | ||
(*ptr)(&info); | ||
} | ||
} | ||
}; | ||
HOOK_LOCK.read_unlock(); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.