From 9abb264c2e60b0b38d618984ff7f6e47a89ec461 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Wed, 26 Jun 2024 10:28:09 +0000 Subject: [PATCH 1/3] nix: Fix buildSysroot for native targets Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/build-sysroot.nix | 2 +- hacking/nix/rust-utils/crate-utils.nix | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hacking/nix/rust-utils/build-sysroot.nix b/hacking/nix/rust-utils/build-sysroot.nix index b90c00092..194b7d241 100644 --- a/hacking/nix/rust-utils/build-sysroot.nix +++ b/hacking/nix/rust-utils/build-sysroot.nix @@ -36,7 +36,7 @@ let manifest = crateUtils.toTOMLFile "Cargo.toml" (crateUtils.clobber [ { inherit package; - lib.path = crateUtils.dummyLibInSrc; + lib.path = crateUtils.dummyLibWithoutStdInSrc; } extraManifest ]); diff --git a/hacking/nix/rust-utils/crate-utils.nix b/hacking/nix/rust-utils/crate-utils.nix index ca59429a2..c590d9f9c 100644 --- a/hacking/nix/rust-utils/crate-utils.nix +++ b/hacking/nix/rust-utils/crate-utils.nix @@ -26,6 +26,7 @@ rec { ### dummyLibInSrc = dummyInSrc "lib.rs" dummyLib; + dummyLibWithoutStdInSrc = dummyInSrc "lib.rs" dummyLibWithoutStd; dummyMainWithStdInSrc = dummyInSrc "main.rs" dummyMainWithStd; dummyMainWithOrWithoutStdInSrc = dummyInSrc "main.rs" dummyMainWithOrWithoutStd; @@ -39,14 +40,14 @@ rec { in "${src}/${name}"; + dummyLibWithoutStd = writeText "lib.rs" '' + #![no_std] + ''; + dummyMainWithStd = writeText "main.rs" '' fn main() {} ''; - # dummyLib = writeText "lib.rs" '' - # #![no_std] - # ''; - # HACK for cargo test (required by harness = "false") dummyLib = dummyMainOrLibWithOrWithoutStd; From 2293bdb464aabb59df9d3dbd00b58c1ee4dd0c71 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Wed, 26 Jun 2024 12:04:19 +0000 Subject: [PATCH 2/3] nix: Enable specifying sysroot source for buildSysroot Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/build-sysroot.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hacking/nix/rust-utils/build-sysroot.nix b/hacking/nix/rust-utils/build-sysroot.nix index 194b7d241..8f7d1e589 100644 --- a/hacking/nix/rust-utils/build-sysroot.nix +++ b/hacking/nix/rust-utils/build-sysroot.nix @@ -18,6 +18,7 @@ , std ? false , compilerBuiltinsMem ? true , compilerBuiltinsC ? rustEnvironment.compilerRTSource != null +, src ? null , extraManifest ? {} , extraConfig ? {} }: @@ -89,6 +90,9 @@ in } // lib.optionalAttrs compilerBuiltinsC { "CC_${targetTriple.name}" = "${stdenv.cc.targetPrefix}gcc"; RUST_COMPILER_RT_ROOT = rustEnvironment.compilerRTSource; +} // lib.optionalAttrs (src != null) { + # HACK + __CARGO_TESTS_ONLY_SRC_ROOT = src; }) '' cargo build \ -Z unstable-options \ From ff6478e299620842e8e2cc28e8672e799f9f7873 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Wed, 26 Jun 2024 12:32:43 +0000 Subject: [PATCH 3/3] nix: Add more shell aliases Signed-off-by: Nick Spinale --- hacking/nix/scope/world/shell.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hacking/nix/scope/world/shell.nix b/hacking/nix/scope/world/shell.nix index 91c5b8909..f5f1601a4 100644 --- a/hacking/nix/scope/world/shell.nix +++ b/hacking/nix/scope/world/shell.nix @@ -83,7 +83,8 @@ mkShell (seL4RustEnvVars // kernelLoaderConfigEnvVars // capdlEnvVars // bindgen ]; shellHook = '' - # abbreviation export h=$HOST_CARGO_FLAGS + export t="--target $RUST_SEL4_TARGET" + export bt="--target $RUST_BARE_METAL_TARGET" ''; })