From da3f9558d9781edce20c0aae46324d9bb6b2d43a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 10 Nov 2016 19:59:59 -0700 Subject: [PATCH] Fixes for building libstd (real) --- libstd_real/Cargo.toml | 3 ++- libstd_real/libc/Cargo.toml | 1 + libstd_real/libc/build.rs | 18 ++++++++++++++++++ libstd_real/libc/src/lib.rs | 8 ++++++++ libstd_real/panic_abort/Cargo.toml | 10 ++++++++++ libstd_real/panic_unwind/Cargo.toml | 5 +++++ libstd_real/panic_unwind/src/lib.rs | 27 --------------------------- libstd_real/unwind/Cargo.toml | 6 ++++++ libstd_real/unwind/src/lib.rs | 1 - rust | 2 +- 10 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 libstd_real/libc/build.rs create mode 100644 libstd_real/panic_abort/Cargo.toml delete mode 100644 libstd_real/panic_unwind/src/lib.rs delete mode 100644 libstd_real/unwind/src/lib.rs diff --git a/libstd_real/Cargo.toml b/libstd_real/Cargo.toml index 7ee35a3..471f2b4 100644 --- a/libstd_real/Cargo.toml +++ b/libstd_real/Cargo.toml @@ -10,7 +10,8 @@ path = "../rust/src/libstd/lib.rs" [dependencies] alloc_system = { path = "alloc_system" } compiler_builtins = { path = "compiler_builtins" } -panic_unwind = { path = "panic_unwind" } +panic_abort = { path = "panic_abort" } +#panic_unwind = { path = "panic_unwind" } libc = { path = "libc" } unwind = { path = "unwind" } diff --git a/libstd_real/libc/Cargo.toml b/libstd_real/libc/Cargo.toml index f26d702..7137b05 100644 --- a/libstd_real/libc/Cargo.toml +++ b/libstd_real/libc/Cargo.toml @@ -2,6 +2,7 @@ name = "libc" version = "0.1.0" authors = ["Jeremy Soller "] +build = "build.rs" [dependencies] redox_syscall = { path = "../../syscall/" } diff --git a/libstd_real/libc/build.rs b/libstd_real/libc/build.rs new file mode 100644 index 0000000..546f604 --- /dev/null +++ b/libstd_real/libc/build.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(warnings)] + +// See comments in Cargo.toml for why this exists + +fn main() { + println!("cargo:rustc-cfg=stdbuild"); + println!("cargo:rerun-if-changed=build.rs"); +} diff --git a/libstd_real/libc/src/lib.rs b/libstd_real/libc/src/lib.rs index c7142ef..a8f72bf 100644 --- a/libstd_real/libc/src/lib.rs +++ b/libstd_real/libc/src/lib.rs @@ -3,6 +3,14 @@ #![feature(asm)] #![feature(naked_functions)] +#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute, cfg_target_vendor))] +#![cfg_attr(stdbuild, no_std)] +#![cfg_attr(stdbuild, staged_api)] +#![cfg_attr(stdbuild, allow(warnings))] +#![cfg_attr(stdbuild, unstable(feature = "libc", + reason = "use `libc` from crates.io", + issue = "27783"))] + pub use types::*; pub use funcs::*; pub use start::*; diff --git a/libstd_real/panic_abort/Cargo.toml b/libstd_real/panic_abort/Cargo.toml new file mode 100644 index 0000000..4e8e492 --- /dev/null +++ b/libstd_real/panic_abort/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "panic_abort" +version = "0.0.0" +authors = ["Jeremy Soller "] + +[lib] +path = "../../rust/src/libpanic_abort/lib.rs" + +[dependencies] +redox_syscall = { path = "../../syscall/" } diff --git a/libstd_real/panic_unwind/Cargo.toml b/libstd_real/panic_unwind/Cargo.toml index b9b4fa5..746be81 100644 --- a/libstd_real/panic_unwind/Cargo.toml +++ b/libstd_real/panic_unwind/Cargo.toml @@ -3,5 +3,10 @@ name = "panic_unwind" version = "0.0.0" authors = ["Jeremy Soller "] +[lib] +path = "../../rust/src/libpanic_unwind/lib.rs" + [dependencies] +libc = { path = "../libc/" } redox_syscall = { path = "../../syscall/" } +unwind = { path = "../unwind/" } diff --git a/libstd_real/panic_unwind/src/lib.rs b/libstd_real/panic_unwind/src/lib.rs deleted file mode 100644 index bae8220..0000000 --- a/libstd_real/panic_unwind/src/lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![no_std] -#![feature(core_intrinsics)] -#![feature(lang_items)] -#![feature(panic_runtime)] -#![panic_runtime] - -#[no_mangle] -pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), data: *mut u8, - _data_ptr: *mut usize, _vtable_ptr: *mut usize) -> u32 { - f(data); - 0 -} - -#[no_mangle] -pub unsafe extern fn __rust_start_panic(_data: usize, _vtable: usize) -> u32 { - core::intrinsics::abort(); -} - -#[lang = "eh_personality"] -pub extern fn eh_personality() {} - -#[allow(non_snake_case)] -#[no_mangle] -/// Required to handle panics -pub unsafe extern "C" fn _Unwind_Resume() -> ! { - core::intrinsics::abort(); -} diff --git a/libstd_real/unwind/Cargo.toml b/libstd_real/unwind/Cargo.toml index 41c966d..a43c8c3 100644 --- a/libstd_real/unwind/Cargo.toml +++ b/libstd_real/unwind/Cargo.toml @@ -2,3 +2,9 @@ name = "unwind" version = "0.0.0" authors = ["Jeremy Soller "] + +[lib] +path = "../../rust/src/libunwind/lib.rs" + +[dependencies] +libc = { path = "../libc/" } diff --git a/libstd_real/unwind/src/lib.rs b/libstd_real/unwind/src/lib.rs deleted file mode 100644 index 0c9ac1a..0000000 --- a/libstd_real/unwind/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -#![no_std] diff --git a/rust b/rust index ced32a0..79a8c27 160000 --- a/rust +++ b/rust @@ -1 +1 @@ -Subproject commit ced32a08f3bf7325bf3fe6488e21b108f996abc5 +Subproject commit 79a8c272fb8ad09600ef58ff223c73eb44343040