From 40276a06c2c76e6838691e3fb5beb1ff12978dda Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 31 Jan 2021 14:27:57 +0100 Subject: [PATCH 01/11] add examples to instrument RustyHermit applications --- examples/demo/Cargo.toml | 8 ++++++-- examples/demo/src/main.rs | 13 +++++++++++++ examples/demo/src/matrix_multiplication.rs | 13 +++++++++++++ examples/demo/src/pi_sequential.rs | 13 +++++++++++++ examples/hello_world/Cargo.toml | 6 +++++- examples/hello_world/src/main.rs | 11 +++++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) diff --git a/examples/demo/Cargo.toml b/examples/demo/Cargo.toml index 19ab1dadd..c39f01d92 100644 --- a/examples/demo/Cargo.toml +++ b/examples/demo/Cargo.toml @@ -33,6 +33,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,13 +44,13 @@ 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.dev] 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..fb86109d2 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -10,6 +10,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 +21,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 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"); } From 997735fb641a6ca65ba240ccbae015f86e0e95c5 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 31 Jan 2021 14:32:35 +0100 Subject: [PATCH 02/11] integrate rftrace into hermit-sys - make sure that RUSTFLAGS is set correctly --- hermit-sys/Cargo.toml | 3 +-- hermit-sys/build.rs | 3 +++ hermit-sys/src/lib.rs | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hermit-sys/Cargo.toml b/hermit-sys/Cargo.toml index f4b38e497..48b83a1a8 100644 --- a/hermit-sys/Cargo.toml +++ b/hermit-sys/Cargo.toml @@ -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..f823e56fe 100644 --- a/hermit-sys/build.rs +++ b/hermit-sys/build.rs @@ -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")] From c47678462743e4e589486ba3044e34ff26bd5858 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 31 Jan 2021 14:37:41 +0100 Subject: [PATCH 03/11] remove lto support because it isn't compatible to rftrace - remove obsolete "instrument" feature in applications, which aren't used as instrumentation examples --- .github/workflows/test.yml | 2 -- .gitlab-ci.yml | 4 ++-- Cargo.lock | 11 +++++++++++ Cargo.toml | 2 +- benches/micro/Cargo.toml | 3 +-- benches/netbench/Cargo.toml | 1 - examples/httpd/Cargo.toml | 1 - 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ebc7db97..7ca04d371 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,8 +75,6 @@ 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 - env: - RUSTFLAGS: -Clinker-plugin-lto - name: Build loader (unix) working-directory: loader run: make diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5bbc5e92..eb4528b04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,7 @@ build:demo: 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 artifacts: paths: - target/x86_64-unknown-hermit/debug/rusty_demo @@ -48,7 +48,7 @@ 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 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..7937eeacf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["target", "loader", "libhermit-rs"] opt-level = 3 debug = false rpath = false -lto = "thin" +lto = false debug-assertions = false [profile.dev] diff --git a/benches/micro/Cargo.toml b/benches/micro/Cargo.toml index 24f63dd62..2c7363b40 100644 --- a/benches/micro/Cargo.toml +++ b/benches/micro/Cargo.toml @@ -27,13 +27,12 @@ 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.dev] diff --git a/benches/netbench/Cargo.toml b/benches/netbench/Cargo.toml index 27ed16e1b..e15587a87 100644 --- a/benches/netbench/Cargo.toml +++ b/benches/netbench/Cargo.toml @@ -27,7 +27,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" diff --git a/examples/httpd/Cargo.toml b/examples/httpd/Cargo.toml index bae1b4240..a9bfb42dd 100644 --- a/examples/httpd/Cargo.toml +++ b/examples/httpd/Cargo.toml @@ -23,7 +23,6 @@ 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 From 257443a7c40b74c28b9cea0364c65479b75bd3ff Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 21:26:19 +0100 Subject: [PATCH 04/11] remove obsolete toolchain description --- benches/micro/rust-toolchain | 1 - 1 file changed, 1 deletion(-) delete mode 100644 benches/micro/rust-toolchain 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 From e84020c49a3fb9ce4911d1940b2aeb826ef3daa4 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 21:46:41 +0100 Subject: [PATCH 05/11] Using of a more unique notation for the license --- hermit-abi/Cargo.toml | 2 +- hermit-sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 48b83a1a8..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" From fb867fb5c9de592b2e0a8809e21bfee0e5e9f1c7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 21:48:54 +0100 Subject: [PATCH 06/11] introduce the profile release-lto to enable LTO optimization --- Cargo.toml | 5 +++++ benches/micro/Cargo.toml | 5 +++++ benches/netbench/Cargo.toml | 9 ++++++--- examples/demo/Cargo.toml | 5 +++++ examples/hello_world/Cargo.toml | 5 +++++ examples/httpd/Cargo.toml | 7 ++++++- 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7937eeacf..c3ec98f94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ +cargo-features = ["named-profiles"] [workspace] members = [ "hermit-abi", @@ -17,6 +18,10 @@ rpath = false 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 2c7363b40..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" @@ -35,6 +36,10 @@ rpath = false 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/netbench/Cargo.toml b/benches/netbench/Cargo.toml index e15587a87..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] @@ -48,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 c39f01d92..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" @@ -53,6 +54,10 @@ rpath = false 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/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index fb86109d2..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" @@ -30,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/httpd/Cargo.toml b/examples/httpd/Cargo.toml index a9bfb42dd..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 "] @@ -28,9 +29,13 @@ smoltcp = ["hermit-sys/smoltcp"] 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` From 4cab5de7bf5d4152b74eee91eb05fd098fc60e1d Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 22:09:58 +0100 Subject: [PATCH 07/11] add tests for LTO optimized version of rusty_demo --- .github/workflows/test.yml | 7 +++++++ .gitlab-ci.yml | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ca04d371..9a7c10830 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,6 +75,10 @@ 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) + cargo build -p rusty_demo --profile release-lto -Z unstable-options + env: + RUSTFLAGS: -Clinker-plugin-lto - name: Build loader (unix) working-directory: loader run: make @@ -96,6 +100,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 eb4528b04..89c9fe501 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,10 +39,12 @@ build:demo: script: - cargo build -p rusty_demo - 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 @@ -66,6 +68,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 @@ -85,6 +89,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 From 86801bed386e54b79e0904eda98f559902dd4e80 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 22:23:04 +0100 Subject: [PATCH 08/11] define unstable feature "build-std" to build the tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a7c10830..ba7345e77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,7 +76,7 @@ jobs: 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) - cargo build -p rusty_demo --profile release-lto -Z unstable-options + 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) From 14911dc62e6909f0285655629a5b347eae42c4e4 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 22:25:07 +0100 Subject: [PATCH 09/11] add missing label "run" --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba7345e77..01a677279 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,6 +76,7 @@ jobs: 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 From 0d6414a1138cf1887f18b0d2828202e5b871a573 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 1 Feb 2021 22:44:50 +0100 Subject: [PATCH 10/11] add also check for profile "release-lto" Also the profile "release-lto" depends on the release version of libhermit and build this version. --- hermit-sys/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermit-sys/build.rs b/hermit-sys/build.rs index f823e56fe..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"); } From ed114a5d71314c753a85b6942f04e842c9c13ada Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Feb 2021 22:15:26 +0100 Subject: [PATCH 11/11] add test to create a trace file --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 89c9fe501..98bc3698a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,6 +33,15 @@ 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} @@ -55,6 +64,19 @@ build:httpd: 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: