about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-02-11 19:40:07 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2019-02-11 19:40:07 +0100
commit223611dcb24a361d642244af8966a868ca952df3 (patch)
tree351b9192e73f0509f01a2e7487acde735c54966e
parentc68e76c33bf8b8e3fc0dabb3f7d9133328a7ea6d (diff)
downloadrust-223611dcb24a361d642244af8966a868ca952df3.tar.gz
rust-223611dcb24a361d642244af8966a868ca952df3.zip
Fix and enable libstd building
-rw-r--r--build_sysroot/Cargo.toml1
-rw-r--r--example/std_example.rs9
-rw-r--r--patches/0011-Workaround-for-libstd-crash.patch25
-rwxr-xr-xtest.sh9
4 files changed, 42 insertions, 2 deletions
diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml
index 725c0b40d89..3ba06fcb0f6 100644
--- a/build_sysroot/Cargo.toml
+++ b/build_sysroot/Cargo.toml
@@ -7,6 +7,7 @@ version = "0.0.0"
 core = { path = "./sysroot_src/src/libcore" }
 compiler_builtins = "0.1"
 alloc = { path = "./sysroot_src/src/liballoc" }
+std = { path = "./sysroot_src/src/libstd" }
 
 alloc_system = { path = "./alloc_system" }
 
diff --git a/example/std_example.rs b/example/std_example.rs
new file mode 100644
index 00000000000..dceb68bcdf4
--- /dev/null
+++ b/example/std_example.rs
@@ -0,0 +1,9 @@
+use std::io::Write;
+
+fn main() {
+    let _ = ::std::iter::repeat('a' as u8).take(10).collect::<Vec<_>>();
+    let stderr = ::std::io::stderr();
+    let mut stderr = stderr.lock();
+
+    writeln!(stderr, "some {} text", "<unknown>").unwrap();
+}
diff --git a/patches/0011-Workaround-for-libstd-crash.patch b/patches/0011-Workaround-for-libstd-crash.patch
new file mode 100644
index 00000000000..46712718dec
--- /dev/null
+++ b/patches/0011-Workaround-for-libstd-crash.patch
@@ -0,0 +1,25 @@
+From 2bc2ef06e118c6fba0626c0e9bf24fed873405b2 Mon Sep 17 00:00:00 2001
+From: bjorn3 <bjorn3@users.noreply.github.com>
+Date: Sat, 29 Dec 2018 12:37:34 +0100
+Subject: [PATCH] Workaround for libstd crash
+
+I think this is related to the use of TLS inside those functions
+---
+ src/libstd/rt.rs | 2 +-
+ 1 file changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs
+index 5ddb66b..6a0d0b5 100644
+--- a/src/libstd/rt.rs
++++ b/src/libstd/rt.rs
+@@ -51,7 +51,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
+         #[cfg(not(feature = "backtrace"))]
+         let exit_code = panic::catch_unwind(move || main());
+
+-        sys_common::cleanup();
++        //sys_common::cleanup();
+         exit_code.unwrap_or(101) as isize
+     }
+ }
+--
+2.17.2 (Apple Git-113)
diff --git a/test.sh b/test.sh
index 8cc4b0ff817..8cc5b2d186e 100755
--- a/test.sh
+++ b/test.sh
@@ -24,11 +24,16 @@ echo "[BUILD+RUN] alloc_example"
 $RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin
 ./target/out/alloc_example
 
+echo "[BUILD+RUN] std_example"
+$RUSTC --sysroot ./build_sysroot/sysroot example/std_example.rs --crate-type bin
+./target/out/std_example
+
 echo "[BUILD] mod_bench"
 $RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin
 
-echo "[BUILD] sysroot in release mode"
-./build_sysroot/build_sysroot.sh --release
+# FIXME linker gives multiple definitions error on Linux
+#echo "[BUILD] sysroot in release mode"
+#./build_sysroot/build_sysroot.sh --release
 
 COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
 COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort"