Skip to content

Commit e3b2084

Browse files
committed
[WIP] Tls support
1 parent f0bb30f commit e3b2084

12 files changed

+248
-139
lines changed

Cargo.lock

+30-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-8
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ default-features = false
4040
features = ["compression", "read", "std"] # We don't need WASM support
4141

4242
# Uncomment to use local checkout of cranelift
43-
#[patch."https://github.com/bytecodealliance/cranelift/"]
44-
#cranelift = { path = "../cranelift/cranelift-umbrella", default-features = false, features = ["std"] }
45-
#cranelift-module = { path = "../cranelift/cranelift-module" }
46-
#cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" }
47-
#cranelift-faerie = { path = "../cranelift/cranelift-faerie" }
48-
#cranelift-object = { path = "../cranelift/cranelift-object" }
49-
50-
#[patch.crates-io]
43+
[patch."https://github.com/bytecodealliance/cranelift/"]
44+
cranelift = { path = "../cranelift/cranelift-umbrella", default-features = false, features = ["std"] }
45+
cranelift-module = { path = "../cranelift/cranelift-module" }
46+
cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" }
47+
cranelift-faerie = { path = "../cranelift/cranelift-faerie" }
48+
cranelift-object = { path = "../cranelift/cranelift-object" }
49+
50+
[patch.crates-io]
5151
#gimli = { path = "../" }
52+
object = { path = "./object" }
5253

5354
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
5455
cranelift-simplejit = { git = "https://github.com/bytecodealliance/cranelift/" }

crate_patches/regex.patch

-34
This file was deleted.

example/mini_core.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(
22
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
3-
untagged_unions, decl_macro, rustc_attrs, transparent_unions
3+
untagged_unions, decl_macro, rustc_attrs, transparent_unions, thread_local,
44
)]
55
#![no_core]
66
#![allow(dead_code)]
@@ -538,3 +538,11 @@ pub macro line() { /* compiler built-in */ }
538538
pub macro cfg() { /* compiler built-in */ }
539539

540540
pub static A_STATIC: u8 = 42;
541+
542+
#[no_mangle]
543+
pub fn get_tls() -> u8 {
544+
#[thread_local]
545+
static A: u8 = 42;
546+
547+
A
548+
}

example/std_example.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ fn main() {
1212
let stderr = ::std::io::stderr();
1313
let mut stderr = stderr.lock();
1414

15+
std::thread::spawn(move || {
16+
println!("Hello from another thread!");
17+
});
18+
1519
writeln!(stderr, "some {} text", "<unknown>").unwrap();
1620

1721
let _ = std::process::Command::new("true").env("c", "d").spawn();

patches/0015-Remove-usage-of-unsized-locals.patch

+5-42
Original file line numberDiff line numberDiff line change
@@ -44,53 +44,16 @@ index f6dee7c..0c6a8c0 100644
4444
#[unstable(feature = "coerce_unsized", issue = "27732")]
4545
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
4646

47-
diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs
48-
index 1181b86..20f9251 100644
49-
--- a/src/libstd/sys_common/at_exit_imp.rs
50-
+++ b/src/libstd/sys_common/at_exit_imp.rs
51-
@@ -38,6 +38,7 @@ unsafe fn init() -> bool {
52-
true
53-
}
54-
55-
+/*
56-
pub fn cleanup() {
57-
for i in 1..=ITERS {
58-
unsafe {
59-
@@ -60,6 +61,7 @@ pub fn cleanup() {
60-
}
61-
}
62-
}
63-
+*/
64-
65-
pub fn push(f: Box<dyn FnOnce()>) -> bool {
66-
unsafe {
67-
diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs
68-
index 6260c3b..611ed7e 100644
69-
--- a/src/libstd/sys_common/mod.rs
70-
+++ b/src/libstd/sys_common/mod.rs
71-
@@ -127,7 +127,6 @@ pub fn cleanup() {
72-
CLEANUP.call_once(|| unsafe {
73-
sys::args::cleanup();
74-
sys::stack_overflow::cleanup();
75-
- at_exit_imp::cleanup();
76-
});
77-
}
78-
7947
diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs
8048
index b2142e7..718bb1c 100644
8149
--- a/src/libstd/sys_common/thread.rs
8250
+++ b/src/libstd/sys_common/thread.rs
83-
@@ -6,12 +6,7 @@ use crate::sys::thread as imp;
51+
@@ -6,7 +6,7 @@ pub unsafe fn start_thread(main: *mut u8) {
52+
let _handler = stack_overflow::Handler::new();
8453

85-
#[allow(dead_code)]
86-
pub unsafe fn start_thread(main: *mut u8) {
87-
- // Next, set up our stack overflow handler which may get triggered if we run
88-
- // out of stack.
89-
- let _handler = stack_overflow::Handler::new();
90-
-
91-
- // Finally, let's run some code.
54+
// Finally, let's run some code.
9255
- Box::from_raw(main as *mut Box<dyn FnOnce()>)()
93-
+ panic!("Threads are not yet supported, because cranelift doesn't support atomics.");
56+
+ Box::from_raw(main as *mut Box<dyn FnBox()>)()
9457
}
9558

9659
pub fn min_stack() -> usize {
@@ -102,7 +65,7 @@ index f4a1783..362b537 100644
10265
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
10366
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>)
10467
-> io::Result<Thread> {
105-
+ panic!("Threads are not yet supported, because cranelift doesn't support atomics.");
68+
+ panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics.");
10669
+
10770
let p = box p;
10871
let mut native: libc::pthread_t = mem::zeroed();

0 commit comments

Comments
 (0)