From 58d730fd648e1fdd0e64edaae40e14ae92ba6294 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Mon, 5 Aug 2019 15:20:18 +0000 Subject: [PATCH 1/6] Reuse Xargo This is the preparing steps for starting our own libstd. --- Makefile.toml | 106 +++++++++++++++++++++++++------------------------- Xargo.toml | 10 +++++ 2 files changed, 63 insertions(+), 53 deletions(-) create mode 100644 Xargo.toml diff --git a/Makefile.toml b/Makefile.toml index 580f8d858..72ed59656 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -40,105 +40,105 @@ install_crate = { rustup_component_name = "rust-src" } [tasks.install-mkisofs-rs] install_crate = { crate_name = "mkisofs-rs", binary = "mkisofs-rs", test_arg = "--help", min_version = "0.1.1" } -[tasks.install-cargo-xbuild] +[tasks.install-xargo] dependencies = ["install-rust-src"] -install_crate = { crate_name = "cargo-xbuild", binary = "cargo", test_arg = ["xbuild", "--help"], min_version = "0.5.14" } +install_crate = { crate_name = "xargo", binary = "xargo", test_arg = "--help" } [tasks.bootstrap] description = "Compiles the i386 bootstrap for debug" -dependencies = ["bootstrap-linker", "install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none", "--package=sunrise-bootstrap" ] +dependencies = ["bootstrap-linker", "install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none", "--package=sunrise-bootstrap" ] [tasks.bootstrap-release] description = "Compiles the i386 bootstrap for release" -dependencies = ["bootstrap-linker", "install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none", "--package=sunrise-bootstrap", "--release" ] +dependencies = ["bootstrap-linker", "install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none", "--package=sunrise-bootstrap", "--release" ] [tasks.kernel] description = "Compiles the kernel for debug" -dependencies = ["kernel-linker", "install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none", "--package=sunrise-kernel", "-Z", "package-features", "--features=panic-on-exception"] +dependencies = ["kernel-linker", "install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none", "--package=sunrise-kernel", "-Z", "package-features", "--features=panic-on-exception"] [tasks.kernel-release] description = "Compiles the kernel for release" -dependencies = ["kernel-linker", "install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none", "--package=sunrise-kernel", "--release" ] +dependencies = ["kernel-linker", "install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none", "--package=sunrise-kernel", "--release" ] [tasks.vi] description = "Compiles sunrise-vi" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-vi"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-vi"] [tasks.vi-release] description = "Compiles sunrise-vi" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-vi", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-vi", "--release"] [tasks.sm] description = "Compiles sunrise-sm" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-sm"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-sm"] [tasks.sm-release] description = "Compiles sunrise-sm" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-sm", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-sm", "--release"] [tasks.shell] description = "Compiles sunrise-shell" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-shell"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-shell"] [tasks.shell-release] description = "Compiles sunrise-shell" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-shell", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-shell", "--release"] [tasks.wall-clock] description = "Compiles sunrise-wall-clock" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-wall-clock"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-wall-clock"] [tasks.wall-clock-release] description = "Compiles sunrise-wall-clock" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-wall-clock", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-wall-clock", "--release"] [tasks.ahci] description = "Compiles sunrise-ahci" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-ahci"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-ahci"] [tasks.ahci-release] description = "Compiles sunrise-ahci" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-ahci", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-ahci", "--release"] [tasks.time] description = "Compiles sunrise-time" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xrustc", "--target=i386-unknown-none-user", "--package=sunrise-time", "--", "-Zexternal-macro-backtrace"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-time"] [tasks.time-release] description = "Compiles sunrise-time" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-time", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-time", "--release"] [tasks.fs] description = "Compiles sunrise-fs" @@ -290,10 +290,10 @@ args = ["-c", "kernel/src/main.rs", "bootstrap/src/main.rs", [tasks.clippy-sunrise-target] description = "Run clippy on sunrise components" -dependencies = ["install-cargo-xbuild", "refresh-crates"] +dependencies = ["install-xargo", "refresh-crates"] install_crate = { rustup_component_name = "clippy" } -command = "cargo" -args = ["xclippy", "--target=i386-unknown-none", +command = "xargo" +args = ["clippy", "--target=i386-unknown-none", "--all", "--exclude", "swipc-gen", "--exclude", "swipc-parser", "--exclude", "disk-initializer", "--exclude", "docs", diff --git a/Xargo.toml b/Xargo.toml new file mode 100644 index 000000000..ba61da83f --- /dev/null +++ b/Xargo.toml @@ -0,0 +1,10 @@ +[dependencies.core] +stage = 0 + +[dependencies.compiler_builtins] +version = "*" +stage = 0 +features = ["core", "mem"] + +[dependencies.alloc] +stage = 0 From 84c25290beeed633eda82040596bd5864c2fefa2 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Wed, 28 Aug 2019 16:53:36 +0000 Subject: [PATCH 2/6] Enforce last release of xargo + update doc --- Makefile.toml | 14 +++++++------- bootstrap/Cargo.toml | 4 ---- docs/BUILDING.md | 2 +- docs/UPDATE_RUST.md | 2 +- kernel/Cargo.toml | 5 ----- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 72ed59656..59b010806 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -42,7 +42,7 @@ install_crate = { crate_name = "mkisofs-rs", binary = "mkisofs-rs", test_arg = " [tasks.install-xargo] dependencies = ["install-rust-src"] -install_crate = { crate_name = "xargo", binary = "xargo", test_arg = "--help" } +install_crate = { crate_name = "xargo", binary = "xargo", test_arg = "--version", min_version = "0.3.16" } [tasks.bootstrap] description = "Compiles the i386 bootstrap for debug" @@ -142,15 +142,15 @@ args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-time", "- [tasks.fs] description = "Compiles sunrise-fs" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-fs"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-fs"] [tasks.fs-release] description = "Compiles sunrise-fs" -dependencies = ["install-cargo-xbuild"] -command = "cargo" -args = ["xbuild", "--target=i386-unknown-none-user", "--package=sunrise-fs", "--release"] +dependencies = ["install-xargo"] +command = "xargo" +args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-fs", "--release"] [tasks.userspace] description = "Compiles userspace apps" diff --git a/bootstrap/Cargo.toml b/bootstrap/Cargo.toml index 401de6fc6..4f2c298dd 100644 --- a/bootstrap/Cargo.toml +++ b/bootstrap/Cargo.toml @@ -5,10 +5,6 @@ version = "0.1.0" license = "Apache-2.0 OR MIT" edition = "2018" -[package.metadata.cargo-xbuild] -memcpy = true -sysroot_path = "target/sysroot" - [dependencies] sunrise-libutils = { path = "../libutils" } bit_field = "0.10.0" diff --git a/docs/BUILDING.md b/docs/BUILDING.md index f25bdf8e7..c84ad0f16 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -48,7 +48,7 @@ the user can interact. Logs going over serial port will be printed on stdout. - clippy - rust-src - cargo-make: `0.22.0` -- cargo-xbuild: `0.5.14` +- xargo: `0.3.16` - mkisofs-rs: `0.1.1` - qemu-system-i386: `4.0.50` - cargo-travis: `https://github.com/roblabla/cargo-travis` branch `doc-upload-target` diff --git a/docs/UPDATE_RUST.md b/docs/UPDATE_RUST.md index 09876fb6c..5c02e892a 100644 --- a/docs/UPDATE_RUST.md +++ b/docs/UPDATE_RUST.md @@ -15,7 +15,7 @@ We will occasionally want to update the version of the Rust Compiler we use in o - rust-std - rustc 2. Set the `rust-toolchain` file at the root of the repo to `nightly-$LATEST_VER`. For instance, if the latest version to support all the requirements is 2019-07-15, then set the rust-toolchain file to `nightly-2019-07-15`. -3. Update `cargo-xbuild` to the latest version. It likely contains fixes for latest rust changes (there are breaking changes to `no_std` builds from time to time). +3. Update `xargo` to the latest version. It likely contains fixes for latest rust changes (there are breaking changes to `no_std` builds from time to time). 4. Compile the whole project, and fix all the errors. 5. Update the `BUILDING.md` with the new minimum versions. diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 4f18ee215..373200d98 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -5,11 +5,6 @@ version = "0.1.0" license = "Apache-2.0 OR MIT" edition = "2018" -[package.metadata.cargo-xbuild] -memcpy = true -sysroot_path = "target/sysroot" - - [features] #Will make the kernel panic if an exception is encountered. Useful for debugging. panic-on-exception = [] From cc5bf900a293500c91339713e36ec24eb40362ef Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Wed, 28 Aug 2019 17:09:00 +0000 Subject: [PATCH 3/6] Change user target_os to sunrise --- Makefile.toml | 56 +++++++++---------- ...ser.json => i386-unknown-sunrise-user.json | 2 +- libuser/src/crt0/mod.rs | 4 +- libuser/src/crt0/relocation.rs | 2 +- libuser/src/lib.rs | 16 +++--- libuser/src/syscalls.rs | 4 +- 6 files changed, 42 insertions(+), 42 deletions(-) rename i386-unknown-none-user.json => i386-unknown-sunrise-user.json (97%) diff --git a/Makefile.toml b/Makefile.toml index 59b010806..1d6efdc80 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -72,85 +72,85 @@ args = ["build", "--target=i386-unknown-none", "--package=sunrise-kernel", "--re description = "Compiles sunrise-vi" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-vi"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-vi"] [tasks.vi-release] description = "Compiles sunrise-vi" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-vi", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-vi", "--release"] [tasks.sm] description = "Compiles sunrise-sm" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-sm"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-sm"] [tasks.sm-release] description = "Compiles sunrise-sm" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-sm", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-sm", "--release"] [tasks.shell] description = "Compiles sunrise-shell" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-shell"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-shell"] [tasks.shell-release] description = "Compiles sunrise-shell" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-shell", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-shell", "--release"] [tasks.wall-clock] description = "Compiles sunrise-wall-clock" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-wall-clock"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-wall-clock"] [tasks.wall-clock-release] description = "Compiles sunrise-wall-clock" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-wall-clock", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-wall-clock", "--release"] [tasks.ahci] description = "Compiles sunrise-ahci" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-ahci"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-ahci"] [tasks.ahci-release] description = "Compiles sunrise-ahci" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-ahci", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-ahci", "--release"] [tasks.time] description = "Compiles sunrise-time" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-time"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-time"] [tasks.time-release] description = "Compiles sunrise-time" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-time", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-time", "--release"] [tasks.fs] description = "Compiles sunrise-fs" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-fs"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-fs"] [tasks.fs-release] description = "Compiles sunrise-fs" dependencies = ["install-xargo"] command = "xargo" -args = ["build", "--target=i386-unknown-none-user", "--package=sunrise-fs", "--release"] +args = ["build", "--target=i386-unknown-sunrise-user", "--package=sunrise-fs", "--release"] [tasks.userspace] description = "Compiles userspace apps" @@ -168,13 +168,13 @@ script = [ ''' cp target/i386-unknown-none/debug/sunrise-bootstrap isofiles/boot/ cp target/i386-unknown-none/debug/sunrise-kernel isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-shell isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-time isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-wall-clock isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-sm isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-vi isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-ahci isofiles/boot/ -cp target/i386-unknown-none-user/debug/sunrise-fs isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-shell isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-time isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-wall-clock isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-sm isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-vi isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-ahci isofiles/boot/ +cp target/i386-unknown-sunrise-user/debug/sunrise-fs isofiles/boot/ mkisofs-rs external/grub/isofiles isofiles -o os.iso -b boot/grub/i386-pc/eltorito.img --no-emul-boot --boot-info-table --embedded-boot external/grub/embedded.img ''' ] @@ -187,13 +187,13 @@ script = [ ''' cp target/i386-unknown-none/release/sunrise-bootstrap isofiles/boot/ cp target/i386-unknown-none/release/sunrise-kernel isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-shell isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-time isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-wall-clock isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-sm isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-vi isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-ahci isofiles/boot/ -cp target/i386-unknown-none-user/release/sunrise-fs isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-shell isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-time isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-wall-clock isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-sm isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-vi isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-ahci isofiles/boot/ +cp target/i386-unknown-sunrise-user/release/sunrise-fs isofiles/boot/ mkisofs-rs external/grub/isofiles isofiles -o os.iso -b boot/grub/i386-pc/eltorito.img --no-emul-boot --boot-info-table --embedded-boot external/grub/embedded.img ''' ] diff --git a/i386-unknown-none-user.json b/i386-unknown-sunrise-user.json similarity index 97% rename from i386-unknown-none-user.json rename to i386-unknown-sunrise-user.json index 7f9b6f109..cfe37c0a1 100644 --- a/i386-unknown-none-user.json +++ b/i386-unknown-sunrise-user.json @@ -5,7 +5,7 @@ "target-endian": "little", "target-pointer-width": "32", "target-c-int-width": "32", - "os": "none", + "os": "sunrise", "linker": "rust-lld", "linker-flavor": "ld.lld", "linker-is-gnu": true, diff --git a/libuser/src/crt0/mod.rs b/libuser/src/crt0/mod.rs index a835f9182..3ee3a345e 100644 --- a/libuser/src/crt0/mod.rs +++ b/libuser/src/crt0/mod.rs @@ -5,7 +5,7 @@ pub mod relocation; /// Executable entrypoint. Handle relocations and calls real_start. -#[cfg(target_os = "none")] +#[cfg(target_os = "sunrise")] #[naked] #[no_mangle] #[link_section = ".text.crt0"] @@ -54,7 +54,7 @@ pub unsafe extern fn start() { /// Clean module bss. /// NOTE: Even if the bss should be cleared before calling anything in Rust, all functions used here are guaranteed to not use the bss. -#[cfg(target_os = "none")] +#[cfg(target_os = "sunrise")] #[no_mangle] #[link_section = ".text.crt0"] pub unsafe extern fn clean_bss(module_header: *const relocation::ModuleHeader) { diff --git a/libuser/src/crt0/relocation.rs b/libuser/src/crt0/relocation.rs index bf13240b0..a56df8aa3 100644 --- a/libuser/src/crt0/relocation.rs +++ b/libuser/src/crt0/relocation.rs @@ -127,7 +127,7 @@ struct ElfRela { const R_386_RELATIVE: usize = 8; /// Handle basic relocation. Return a non zero value if failed. -#[cfg(target_os = "none")] +#[cfg(target_os = "sunrise")] #[no_mangle] #[allow(clippy::cast_ptr_alignment)] pub unsafe extern fn relocate_self(aslr_base: *mut u8, module_headr: *const ModuleHeader) -> u32 { diff --git a/libuser/src/lib.rs b/libuser/src/lib.rs index dc5f46dbf..b66789762 100644 --- a/libuser/src/lib.rs +++ b/libuser/src/lib.rs @@ -75,7 +75,7 @@ use sunrise_libutils as utils; /// Global allocator. Every implicit allocation in the rust liballoc library (for /// instance for Vecs, Arcs, etc...) are allocated with this allocator. -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[global_allocator] static ALLOCATOR: allocator::Allocator = allocator::Allocator::new(); @@ -88,12 +88,12 @@ static ALLOCATOR: allocator::Allocator = allocator::Allocator::new(); /// The exception handling personality function for use in the bootstrap. /// /// We currently have no userspace exception handling, so make it do nothing. -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[lang = "eh_personality"] #[no_mangle] pub extern fn eh_personality() {} /// Function called on `panic!` invocation. Prints the panic information to the /// kernel debug logger, and exits the process. -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[panic_handler] #[no_mangle] pub extern fn panic_fmt(p: &core::panic::PanicInfo<'_>) -> ! { let _ = syscalls::output_debug_string(&format!("{}", p), 10, "sunrise_libuser::panic_fmt"); @@ -106,7 +106,7 @@ use core::alloc::Layout; // BODY: Panicking may allocate, so calling panic in the OOM handler is a // BODY: terrible idea. /// OOM handler. Causes a panic. -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[lang = "oom"] #[no_mangle] pub fn rust_oom(_: Layout) -> ! { @@ -115,7 +115,7 @@ pub fn rust_oom(_: Layout) -> ! { /// calls logger initialization, main, and finally exits the /// process. -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[no_mangle] pub unsafe extern fn real_start() -> ! { extern { @@ -135,7 +135,7 @@ pub unsafe extern fn real_start() -> ! { /// /// The default implementations are returning 0 to indicate a successful /// execution. In case of a failure, 1 is returned. -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[lang = "termination"] trait Termination { /// Is called to get the representation of the value as status code. @@ -143,13 +143,13 @@ trait Termination { fn report(self) -> i32; } -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] impl Termination for () { #[inline] fn report(self) -> i32 { 0 } } -#[cfg(any(all(target_os = "none", not(test)), rustdoc))] +#[cfg(any(all(target_os = "sunrise", not(test)), rustdoc))] #[lang = "start"] #[allow(clippy::unit_arg)] fn main(main: fn(), _argc: isize, _argv: *const *const u8) -> isize { diff --git a/libuser/src/syscalls.rs b/libuser/src/syscalls.rs index ab8070232..497285acd 100644 --- a/libuser/src/syscalls.rs +++ b/libuser/src/syscalls.rs @@ -9,7 +9,7 @@ use crate::error::KernelError; // Assembly blob can't get documented, but clippy requires it. #[allow(clippy::missing_docs_in_private_items)] mod syscall_inner { - #[cfg(all(target_arch = "x86", target_os = "none", not(test)))] + #[cfg(all(target_arch = "x86", target_os = "sunrise", not(test)))] global_asm!(" .intel_syntax noprefix .global syscall_inner @@ -55,7 +55,7 @@ syscall_inner: "); // Should only be used for rustdocs!!! - #[cfg(not(target_os = "none"))] + #[cfg(not(target_os = "sunrise"))] #[no_mangle] extern fn syscall_inner(regs: &mut super::Registers) { regs.eax = crate::error::KernelError::NotImplemented.make_ret() as usize; From f0c2cb9f6b99534b145d5d71550494a85b3bf700 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Thu, 29 Aug 2019 11:24:17 +0000 Subject: [PATCH 4/6] Separate userspace clippy task from kernelspace --- Makefile.toml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 1d6efdc80..6e5d34590 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -288,15 +288,30 @@ args = ["-c", "kernel/src/main.rs", "bootstrap/src/main.rs", "swipc-parser/src/lib.rs", "time/src/main.rs", "libtimezone/src/lib.rs" ] -[tasks.clippy-sunrise-target] -description = "Run clippy on sunrise components" +[tasks.clippy-sunrise-kernel-target] +description = "Run clippy on sunrise kernel and bootstrap" dependencies = ["install-xargo", "refresh-crates"] install_crate = { rustup_component_name = "clippy" } command = "xargo" args = ["clippy", "--target=i386-unknown-none", + "-p", "sunrise-kernel", + "-p", "sunrise-bootstrap", + "--", + "@@split(CLIPPY_RULES, )", + "${@}", + ] + +[tasks.clippy-sunrise-userspace-target] +description = "Run clippy on sunrise userspace" +dependencies = ["install-xargo", "refresh-crates"] +install_crate = { rustup_component_name = "clippy" } +command = "xargo" +args = ["clippy", "--target=i386-unknown-sunrise-user", "--all", "--exclude", "swipc-gen", "--exclude", "swipc-parser", "--exclude", "disk-initializer", "--exclude", "docs", + "--exclude", "sunrise-kernel", + "--exclude", "sunrise-bootstrap", "--", "@@split(CLIPPY_RULES, )", "${@}", @@ -315,7 +330,7 @@ args = ["clippy", ] [tasks.clippy] -dependencies = ["clippy-host-target", "clippy-sunrise-target"] +dependencies = ["clippy-host-target", "clippy-sunrise-kernel-target", "clippy-sunrise-userspace-target"] [tasks.swipc-gen] description = "Get the output of running gen_ipc on an ipcdef file" From 3f49b4e1471898ad074ad4713a71b4fd1540f231 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Fri, 30 Aug 2019 12:13:04 +0000 Subject: [PATCH 5/6] Fix compiler_builtins version --- Xargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xargo.toml b/Xargo.toml index ba61da83f..68de98463 100644 --- a/Xargo.toml +++ b/Xargo.toml @@ -2,7 +2,7 @@ stage = 0 [dependencies.compiler_builtins] -version = "*" +version = "=0.1.6" stage = 0 features = ["core", "mem"] From d0d2873d115bb166a29b37987baef84f7d9b7d5e Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Tue, 10 Sep 2019 17:10:34 +0200 Subject: [PATCH 6/6] Update Xargo.toml --- Xargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xargo.toml b/Xargo.toml index 68de98463..9a09826f6 100644 --- a/Xargo.toml +++ b/Xargo.toml @@ -2,7 +2,7 @@ stage = 0 [dependencies.compiler_builtins] -version = "=0.1.6" +version = "=0.1.16" stage = 0 features = ["core", "mem"]