Skip to content
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

Ground work for libstd (reuse Xargo) #402

Merged
merged 6 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 91 additions & 76 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,117 +40,117 @@ 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 = "--version", min_version = "0.3.16" }

[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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-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-sunrise-user", "--package=sunrise-time", "--release"]

[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-sunrise-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-sunrise-user", "--package=sunrise-fs", "--release"]

[tasks.userspace]
description = "Compiles userspace apps"
Expand All @@ -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
'''
]
Expand All @@ -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
'''
]
Expand Down Expand Up @@ -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"
dependencies = ["install-cargo-xbuild", "refresh-crates"]
[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 = "cargo"
args = ["xclippy", "--target=i386-unknown-none",
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, )",
"${@}",
Expand All @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[dependencies.core]
stage = 0

[dependencies.compiler_builtins]
version = "=0.1.16"
stage = 0
features = ["core", "mem"]

[dependencies.alloc]
stage = 0
4 changes: 0 additions & 4 deletions bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 1 addition & 1 deletion docs/UPDATE_RUST.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions libuser/src/crt0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion libuser/src/crt0/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading