From 2d2aa463ddfa74f12e8982e9febcdb1972b7a99c Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 8 Feb 2023 23:40:38 +0100 Subject: [PATCH 1/4] build-rust-package: call sysroot/src with the expected lib parameter --- .../build-support/rust/build-rust-package/sysroot/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/rust/build-rust-package/sysroot/default.nix b/pkgs/build-support/rust/build-rust-package/sysroot/default.nix index 1e0b901105cd..e6f03cb47f68 100644 --- a/pkgs/build-support/rust/build-rust-package/sysroot/default.nix +++ b/pkgs/build-support/rust/build-rust-package/sysroot/default.nix @@ -1,10 +1,10 @@ -{ stdenv, rust, rustPlatform, buildPackages }: +{ lib, stdenv, rust, rustPlatform, buildPackages }: { shortTarget, originalCargoToml, target, RUSTFLAGS }: let cargoSrc = import ../../sysroot/src.nix { - inherit stdenv rustPlatform buildPackages originalCargoToml; + inherit lib stdenv rustPlatform buildPackages originalCargoToml; }; in rustPlatform.buildRustPackage { inherit target RUSTFLAGS; From 87837a5fcf7dd9c58bb80f15a8f046a2abc8a4c8 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 9 Feb 2023 01:13:21 +0100 Subject: [PATCH 2/4] build-support/rust/sysroot: update Cargo.lock --- .../rust/build-rust-package/sysroot/default.nix | 2 +- pkgs/build-support/rust/sysroot/Cargo.lock | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/rust/build-rust-package/sysroot/default.nix b/pkgs/build-support/rust/build-rust-package/sysroot/default.nix index e6f03cb47f68..dc0f3e792cad 100644 --- a/pkgs/build-support/rust/build-rust-package/sysroot/default.nix +++ b/pkgs/build-support/rust/build-rust-package/sysroot/default.nix @@ -14,7 +14,7 @@ in rustPlatform.buildRustPackage { RUSTC_BOOTSTRAP = 1; __internal_dontAddSysroot = true; - cargoSha256 = "0y6dqfhsgk00y3fv5bnjzk0s7i30nwqc1rp0xlrk83hkh80x81mw"; + cargoSha256 = "sha256-zgkwevitxsu1C4OgGTsqNSc0gDxaNXYK1WPbfER48d0="; doCheck = false; diff --git a/pkgs/build-support/rust/sysroot/Cargo.lock b/pkgs/build-support/rust/sysroot/Cargo.lock index 6ec6da6ae6e2..d9b0c25d02f2 100644 --- a/pkgs/build-support/rust/sysroot/Cargo.lock +++ b/pkgs/build-support/rust/sysroot/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "alloc" version = "0.0.0" @@ -10,9 +12,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.52" +version = "0.1.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6591c2442ee984e2b264638a8b5e7ae44fd47b32d28e3a08e2e9c3cdb0c2fb0" +checksum = "f867ce54c09855ccd135ad4a50c777182a0c7af5ff20a8f537617bd648b10d50" dependencies = [ "rustc-std-workspace-core", ] From 63c8961f8b144ca40314909330f7759d1fa7e530 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 9 Feb 2023 01:15:07 +0100 Subject: [PATCH 3/4] build-support/rust/sysroot: let cargo-src crate become no_std --- pkgs/build-support/rust/sysroot/src.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/sysroot/src.nix b/pkgs/build-support/rust/sysroot/src.nix index 3d11b62dd315..664702e82c31 100644 --- a/pkgs/build-support/rust/sysroot/src.nix +++ b/pkgs/build-support/rust/sysroot/src.nix @@ -19,7 +19,7 @@ stdenv.mkDerivation { + '' ${buildPackages.python3.withPackages (ps: with ps; [ toml ])}/bin/python3 ${./cargo.py} mkdir -p $out/src - touch $out/src/lib.rs + echo '#![no_std]' > $out/src/lib.rs cp Cargo.toml $out/Cargo.toml cp ${./Cargo.lock} $out/Cargo.lock ''; From 9d1aafcdeb074c5ad8b6780f9474f9cced901388 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 24 Feb 2023 21:53:45 +0100 Subject: [PATCH 4/4] build-support/rust: allow cross-compiling the sysroot --- pkgs/build-support/rust/build-rust-package/sysroot/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/build-support/rust/build-rust-package/sysroot/default.nix b/pkgs/build-support/rust/build-rust-package/sysroot/default.nix index dc0f3e792cad..a6d53056d9c7 100644 --- a/pkgs/build-support/rust/build-rust-package/sysroot/default.nix +++ b/pkgs/build-support/rust/build-rust-package/sysroot/default.nix @@ -29,4 +29,7 @@ in rustPlatform.buildRustPackage { host=${rust.toRustTarget stdenv.buildPlatform} cp -r $RUST_SYSROOT/lib/rustlib/$host $out ''; + + # allows support for cross-compilation + meta.platforms = lib.platforms.all; }