diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ebc7db97..01a677279 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,6 +75,9 @@ jobs: - name: Building release version run: cargo build -p rusty_demo -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit --release + - name: Building release version (LTO) + run: + cargo build -p rusty_demo --profile release-lto -Z unstable-options -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit env: RUSTFLAGS: -Clinker-plugin-lto - name: Build loader (unix) @@ -98,6 +101,9 @@ jobs: - name: Test release version run: qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand + - name: Test release version (LTO) + run: + qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/release-lto/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand - name: Build httpd with DHCP support run: cargo build --manifest-path examples/httpd/Cargo.toml --features dhcpv4 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bee0f1e0a..1f5812096 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,26 +34,50 @@ variables: prepare:docker: <<: *prepare_docker +build:instrument: + stage: build + image: ${CI_REGISTRY_IMAGE} + script: + - RUSTFLAGS="-Z instrument-mcount" cargo build -p rusty_demo --release --features=instrument + artifacts: + paths: + - target/x86_64-unknown-hermit/release/matrix_multiplcation + build:demo: stage: build image: ${CI_REGISTRY_IMAGE} script: - cargo build -p rusty_demo - - RUSTFLAGS="-Clinker-plugin-lto" cargo build -p rusty_demo --release + - cargo build -p rusty_demo --release + - RUSTFLAGS="-Clinker-plugin-lto" cargo build -p rusty_demo --profile release-lto -Z unstable-options artifacts: paths: - target/x86_64-unknown-hermit/debug/rusty_demo - target/x86_64-unknown-hermit/release/rusty_demo + - target/x86_64-unknown-hermit/release-lto/rusty_demo build:httpd: stage: build image: ${CI_REGISTRY_IMAGE} script: - - RUSTFLAGS="-Clinker-plugin-lto" cargo build --manifest-path examples/httpd/Cargo.toml --no-default-features --features pci,acpi,smoltcp,vga,dhcpv4 --release + - cargo build --manifest-path examples/httpd/Cargo.toml --no-default-features --features pci,acpi,smoltcp,vga,dhcpv4 --release artifacts: paths: - target/x86_64-unknown-hermit/release/httpd +test:instrument: + stage: test + dependencies: + - build:instrument + image: ${CI_REGISTRY_IMAGE} + script: + - lscpu + - kvm-ok + - cargo install uhyve + - uhyve -v -c 1 target/x86_64-unknown-hermit/release/matrix_multiplcation + tags: + - privileged + test:uhyve: stage: test dependencies: @@ -67,6 +91,8 @@ test:uhyve: - uhyve -v -c 2 target/x86_64-unknown-hermit/debug/rusty_demo - uhyve -v -c 1 target/x86_64-unknown-hermit/release/rusty_demo - uhyve -v -c 2 target/x86_64-unknown-hermit/release/rusty_demo + - uhyve -v -c 1 target/x86_64-unknown-hermit/release-lto/rusty_demo + - uhyve -v -c 2 target/x86_64-unknown-hermit/release-lto/rusty_demo tags: - privileged @@ -86,6 +112,8 @@ test:qemu: - qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/debug/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm - qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm - qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm + - qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release-lto/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm + - qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release-lto/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm tags: - privileged diff --git a/Cargo.lock b/Cargo.lock index b777e7a9c..51ad58e02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,6 +250,7 @@ name = "hello_world" version = "0.1.0" dependencies = [ "hermit-sys", + "rftrace-frontend", ] [[package]] @@ -655,6 +656,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa2ee2d77e97cb948eb4576a5b7908aac75c02afa337c99aa34b9cef0346bedd" +[[package]] +name = "rftrace-frontend" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419a5a276d688261074e7356d4061628dca7b0987f9422eeed4c66ecc128639a" +dependencies = [ + "byteorder", +] + [[package]] name = "rust-tcp-io-perf" version = "0.0.0" @@ -689,6 +699,7 @@ dependencies = [ "hermit-sys", "num_cpus", "rayon", + "rftrace-frontend", "syscalls", ] diff --git a/Cargo.toml b/Cargo.toml index e5121bea3..c3ec98f94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ +cargo-features = ["named-profiles"] [workspace] members = [ "hermit-abi", @@ -14,9 +15,13 @@ exclude = ["target", "loader", "libhermit-rs"] opt-level = 3 debug = false rpath = false -lto = "thin" +lto = false debug-assertions = false +[profile.release-lto] +inherits = "release" +lto = "thin" + [profile.dev] opt-level = 1 # controls the `--opt-level` the compiler builds with debug = true # controls whether the compiler passes `-C debuginfo` diff --git a/benches/micro/Cargo.toml b/benches/micro/Cargo.toml index 24f63dd62..7256c74e3 100644 --- a/benches/micro/Cargo.toml +++ b/benches/micro/Cargo.toml @@ -1,3 +1,4 @@ +cargo-features = ["named-profiles"] [package] name = "micro_benchmarks" version = "0.1.0" @@ -27,15 +28,18 @@ pci = ["hermit-sys/pci"] acpi = ["hermit-sys/acpi"] fsgsbase = ["hermit-sys/fsgsbase"] smp = ["hermit-sys/smp"] -instrument = ["hermit-sys/instrument"] [profile.release] opt-level = 3 debug = false rpath = false -lto = true +lto = false debug-assertions = false +[profile.release-lto] +inherits = "release" +lto = "thin" + [profile.dev] opt-level = 1 # controls the `--opt-level` the compiler builds with debug = true # controls whether the compiler passes `-C debuginfo` diff --git a/benches/micro/rust-toolchain b/benches/micro/rust-toolchain deleted file mode 100644 index bf867e0ae..000000000 --- a/benches/micro/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly diff --git a/benches/netbench/Cargo.toml b/benches/netbench/Cargo.toml index 27ed16e1b..b71dd6402 100644 --- a/benches/netbench/Cargo.toml +++ b/benches/netbench/Cargo.toml @@ -1,10 +1,9 @@ +cargo-features = ["named-profiles"] [package] - name = "rust-tcp-io-perf" version = "0.0.0" authors = ["Lorenzo Martini "] readme = "README.md" - description = "A Rust program to measure bandwidth or latency over a Rust TCP connection" [dependencies] @@ -27,7 +26,6 @@ acpi = ["hermit-sys/acpi"] fsgsbase = ["hermit-sys/fsgsbase"] smp = ["hermit-sys/smp"] smoltcp = ["hermit-sys/smoltcp"] -instrument = ["hermit-sys/instrument"] [[bin]] name = "server-bw" @@ -49,9 +47,13 @@ path = "src/rust-tcp-latency/client.rs" opt-level = 3 debug = false rpath = false -lto = true +lto = false debug-assertions = false +[profile.release-lto] +inherits = "release" +lto = "thin" + [profile.dev] opt-level = 1 # controls the `--opt-level` the compiler builds with debug = true # controls whether the compiler passes `-C debuginfo` diff --git a/examples/demo/Cargo.toml b/examples/demo/Cargo.toml index 19ab1dadd..6521dc765 100644 --- a/examples/demo/Cargo.toml +++ b/examples/demo/Cargo.toml @@ -1,3 +1,4 @@ +cargo-features = ["named-profiles"] [package] name = "rusty_demo" version = "0.1.0" @@ -33,6 +34,10 @@ default-features = false [target.'cfg(target_os = "linux")'.dependencies] syscalls = { version = "0.2", default-features = false } +[dependencies.rftrace-frontend] +version = "0.1.0" +optional = true + [features] default = ["pci", "acpi", "smp"] vga = ["hermit-sys/vga"] @@ -40,15 +45,19 @@ pci = ["hermit-sys/pci"] acpi = ["hermit-sys/acpi"] fsgsbase = ["hermit-sys/fsgsbase"] smp = ["hermit-sys/smp"] -instrument = ["hermit-sys/instrument"] +instrument = ["hermit-sys/instrument", "rftrace-frontend"] [profile.release] opt-level = 3 debug = false rpath = false -lto = true +lto = false debug-assertions = false +[profile.release-lto] +inherits = "release" +lto = "thin" + [profile.dev] opt-level = 1 # controls the `--opt-level` the compiler builds with debug = true # controls whether the compiler passes `-C debuginfo` diff --git a/examples/demo/src/main.rs b/examples/demo/src/main.rs index c4fae982a..ca5c15696 100644 --- a/examples/demo/src/main.rs +++ b/examples/demo/src/main.rs @@ -13,12 +13,16 @@ extern crate hermit_sys; extern crate num_cpus; extern crate rayon; +#[cfg(feature = "instrument")] +extern crate rftrace_frontend; #[cfg(target_os = "linux")] #[macro_use] extern crate syscalls; mod tests; +#[cfg(feature = "instrument")] +use rftrace_frontend::Events; use tests::*; fn test_result(result: Result<(), T>) -> &'static str { @@ -29,6 +33,11 @@ fn test_result(result: Result<(), T>) -> &'static str { } fn main() { + #[cfg(feature = "instrument")] + let events = rftrace_frontend::init(1000000, true); + #[cfg(feature = "instrument")] + rftrace_frontend::enable(); + println!("Test {} ... {}", stringify!(hello), test_result(hello())); println!( "Test {} ... {}", @@ -85,4 +94,8 @@ fn main() { stringify!(thread_creation), test_result(thread_creation()) ); + + #[cfg(feature = "instrument")] + rftrace_frontend::dump_full_uftrace(events, "trace", "rusty_demo", false) + .expect("Saving trace failed"); } diff --git a/examples/demo/src/matrix_multiplication.rs b/examples/demo/src/matrix_multiplication.rs index b72c54c50..ad67da507 100644 --- a/examples/demo/src/matrix_multiplication.rs +++ b/examples/demo/src/matrix_multiplication.rs @@ -13,12 +13,16 @@ extern crate hermit_sys; extern crate num_cpus; extern crate rayon; +#[cfg(feature = "instrument")] +extern crate rftrace_frontend; #[cfg(target_os = "linux")] #[macro_use] extern crate syscalls; mod tests; +#[cfg(feature = "instrument")] +use rftrace_frontend::Events; use tests::*; fn test_result(result: Result<(), T>) -> &'static str { @@ -29,9 +33,18 @@ fn test_result(result: Result<(), T>) -> &'static str { } fn main() { + #[cfg(feature = "instrument")] + let events = rftrace_frontend::init(1000000, true); + #[cfg(feature = "instrument")] + rftrace_frontend::enable(); + println!( "Test {} ... {}", stringify!(test_matmul_strassen), test_result(test_matmul_strassen()) ); + + #[cfg(feature = "instrument")] + rftrace_frontend::dump_full_uftrace(events, "trace", "matrix_multiplcation", false) + .expect("Saving trace failed"); } diff --git a/examples/demo/src/pi_sequential.rs b/examples/demo/src/pi_sequential.rs index 2fe660a1b..1d28251e9 100644 --- a/examples/demo/src/pi_sequential.rs +++ b/examples/demo/src/pi_sequential.rs @@ -11,12 +11,16 @@ #[cfg(target_os = "hermit")] extern crate hermit_sys; +#[cfg(feature = "instrument")] +extern crate rftrace_frontend; #[cfg(target_os = "linux")] #[macro_use] extern crate syscalls; mod tests; +#[cfg(feature = "instrument")] +use rftrace_frontend::Events; use tests::*; fn test_result(result: Result<(), T>) -> &'static str { @@ -27,9 +31,18 @@ fn test_result(result: Result<(), T>) -> &'static str { } fn main() { + #[cfg(feature = "instrument")] + let events = rftrace_frontend::init(1000000, true); + #[cfg(feature = "instrument")] + rftrace_frontend::enable(); + println!( "Test {} ... {}", stringify!(pi_sequential), test_result(pi_sequential(5000000)) ); + + #[cfg(feature = "instrument")] + rftrace_frontend::dump_full_uftrace(events, "trace", "pi_sequential", false) + .expect("Saving trace failed"); } diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 67fbb1281..83d57c838 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -1,3 +1,4 @@ +cargo-features = ["named-profiles"] [package] name = "hello_world" version = "0.1.0" @@ -10,6 +11,10 @@ path = "../../hermit-sys" default-features = false features = ["with_submodule"] +[dependencies.rftrace-frontend] +version = "0.1.0" +optional = true + [features] default = ["pci", "acpi"] vga = ["hermit-sys/vga"] @@ -17,7 +22,7 @@ pci = ["hermit-sys/pci"] acpi = ["hermit-sys/acpi"] fsgsbase = ["hermit-sys/fsgsbase"] smp = ["hermit-sys/smp"] -instrument = ["hermit-sys/instrument"] +instrument = ["hermit-sys/instrument", "rftrace-frontend"] [profile.release] opt-level = 3 @@ -26,6 +31,10 @@ rpath = false lto = true debug-assertions = false +[profile.release-lto] +inherits = "release" +lto = "thin" + [profile.dev] opt-level = 1 # controls the `--opt-level` the compiler builds with debug = true # controls whether the compiler passes `-C debuginfo` diff --git a/examples/hello_world/src/main.rs b/examples/hello_world/src/main.rs index 5af957900..8e4a87936 100644 --- a/examples/hello_world/src/main.rs +++ b/examples/hello_world/src/main.rs @@ -3,7 +3,18 @@ #[cfg(target_os = "hermit")] extern crate hermit_sys; +#[cfg(feature = "instrument")] +extern crate rftrace_frontend; fn main() { + #[cfg(feature = "instrument")] + let events = rftrace_frontend::init(1000000, true); + #[cfg(feature = "instrument")] + rftrace_frontend::enable(); + println!("Hello World!"); + + #[cfg(feature = "instrument")] + rftrace_frontend::dump_full_uftrace(events, "trace", "hello_world", true) + .expect("Saving trace failed"); } diff --git a/examples/httpd/Cargo.toml b/examples/httpd/Cargo.toml index bae1b4240..530fca402 100644 --- a/examples/httpd/Cargo.toml +++ b/examples/httpd/Cargo.toml @@ -1,3 +1,4 @@ +cargo-features = ["named-profiles"] [package] name = "httpd" authors = ["Stefan Lankes "] @@ -23,15 +24,18 @@ acpi = ["hermit-sys/acpi"] fsgsbase = ["hermit-sys/fsgsbase"] smp = ["hermit-sys/smp"] smoltcp = ["hermit-sys/smoltcp"] -instrument = ["hermit-sys/instrument"] [profile.release] opt-level = 3 debug = false rpath = false -lto = true +lto = false debug-assertions = false +[profile.release-lto] +inherits = "release" +lto = "thin" + [profile.dev] opt-level = 1 # controls the `--opt-level` the compiler builds with debug = true # controls whether the compiler passes `-C debuginfo` diff --git a/hermit-abi/Cargo.toml b/hermit-abi/Cargo.toml index e520847ee..00a906ae6 100644 --- a/hermit-abi/Cargo.toml +++ b/hermit-abi/Cargo.toml @@ -2,7 +2,7 @@ name = "hermit-abi" version = "0.1.18" authors = ["Stefan Lankes"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" readme = "README.md" edition = "2018" description = """ diff --git a/hermit-sys/Cargo.toml b/hermit-sys/Cargo.toml index f4b38e497..8df795b86 100644 --- a/hermit-sys/Cargo.toml +++ b/hermit-sys/Cargo.toml @@ -2,7 +2,7 @@ name = "hermit-sys" version = "0.1.20" authors = ["Stefan Lankes"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" description = "FFI bindings to HermitCore" repository = "https://github.com/hermitcore/rusty-hermit" readme = "README.md" @@ -56,5 +56,4 @@ features = ["std", "ethernet", "socket-udp", "socket-tcp", "proto-ipv4", "proto- [dependencies.rftrace] version = "0.1.0" optional = true -features = ["autokernel", "buildcore", "interruptsafe"] - +features = ["autokernel", "buildcore", "interruptsafe"] \ No newline at end of file diff --git a/hermit-sys/build.rs b/hermit-sys/build.rs index c68817d9f..57937d46c 100644 --- a/hermit-sys/build.rs +++ b/hermit-sys/build.rs @@ -43,7 +43,7 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) { None => src_dir.join("target"), }; - if profile == "release" { + if profile == "release" || profile == "release-lto" { cmd.arg("--release"); } @@ -88,6 +88,9 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) { #[cfg(feature = "instrument")] { cmd.env("RUSTFLAGS", "-Z instrument-mcount"); + } + #[cfg(not(feature = "instrument"))] + { // if instrument is not set, ensure that instrument is not in environment variables! cmd.env( "RUSTFLAGS", diff --git a/hermit-sys/src/lib.rs b/hermit-sys/src/lib.rs index 7390ca317..87d84335e 100644 --- a/hermit-sys/src/lib.rs +++ b/hermit-sys/src/lib.rs @@ -2,6 +2,8 @@ extern crate aarch64; #[macro_use] extern crate log; +#[cfg(feature = "instrument")] +extern crate rftrace; #[cfg(feature = "smoltcp")] extern crate smoltcp; #[cfg(target_arch = "x86_64")]