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

Various Nix improvements #153

Merged
merged 13 commits into from
Jun 21, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ dummies! {
SmallPage
LargePage
HugePage
PageGlobalDirectory
PageUpperDirectory
PageDirectory
PageTable
PT
VSpace
IrqControl
IrqHandler
AsidControl
Expand Down
2 changes: 1 addition & 1 deletion crates/private/support/sel4-simple-task/rpc/src/easy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use core::mem;

use serde::{Deserialize, Serialize};

use sel4::{Badge, Endpoint, IpcBuffer, MessageInfo, MessageInfoBuilder, Word};
use sel4::{cap::Endpoint, Badge, IpcBuffer, MessageInfo, MessageInfoBuilder, Word};

const BYTES_PER_WORD: usize = mem::size_of::<Word>() / mem::size_of::<u8>();

Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-capdl-initializer/core/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl CopyAddrs {
let outer_span = 1u64 << sel4::vspace_levels::span_bits(level);
let inner_span = 1usize << sel4::vspace_levels::step_bits(level);
let addr_space_footprint = coarsen_footprint(
&(user_image_bounds.start..(user_image_bounds.start + bootinfo.footprint_size())),
&(user_image_bounds.start..(user_image_bounds.end + bootinfo.footprint_size())),
inner_span,
);
match (
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-kernel-loader/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mk {
};
target."cfg(target_arch = \"aarch64\")".dependencies = {
smccc = "0.1.1";
aarch64-cpu = "9.0.0";
aarch64-cpu = "9.4.0";
};
build-dependencies = {
inherit (versions)
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-kernel-loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ riscv = "0.10.0"
sbi = "0.2.0"

[target."cfg(target_arch = \"aarch64\")".dependencies]
aarch64-cpu = "9.0.0"
aarch64-cpu = "9.4.0"
smccc = "0.1.1"
4 changes: 3 additions & 1 deletion hacking/cargo-manifest-management/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ rec {
inherit lib;
};

manualManifests = import ./manual-manifests.nix;
manualManifests = import ./manual-manifests.nix {
inherit lib;
};

workspace = makeBlueprint {
inherit manifestScope manualManifests;
Expand Down
2 changes: 2 additions & 0 deletions hacking/cargo-manifest-management/manual-manifests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# SPDX-License-Identifier: BSD-2-Clause
#

{ lib }:

let

relativeToWorkspaceRoot = relativePath: "${toString ../..}/${relativePath}";
Expand Down
3 changes: 0 additions & 3 deletions hacking/cargo-manifest-management/tool/make-blueprint.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ in

let
cargoNixPaths =
let
dirFilter = relativePathSegments: lib.head relativePathSegments == "crates";
in
scanDirForFilesWithName workspaceDirFilter "Cargo.nix" workspaceRoot;

generateManifest = cargoNixAbsolutePath:
Expand Down
4 changes: 2 additions & 2 deletions hacking/nix/rust-utils/build-crates-in-layers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ in
, commonModifications ? {}
, lastLayerModifications ? {}

, release ? false
, profile ? if release then "release" else null
, release ? true
, profile ? if release then "release" else (if test then "test" else "dev")

, features ? []
, noDefaultFeatures ? false
Expand Down
5 changes: 4 additions & 1 deletion hacking/nix/rust-utils/build-sysroot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
{ rustEnvironment ? defaultRustEnvironment
, targetTriple ? defaultRustTargetTriple
, release ? true
, profile ? if release then "release" else null
, profile ? if release then "release" else "dev"
, alloc ? true
, std ? false
, compilerBuiltinsMem ? true
, compilerBuiltinsC ? rustEnvironment.compilerRTSource != null
, extraManifest ? {}
Expand Down Expand Up @@ -68,6 +69,8 @@ let
"compiler_builtins"
] ++ lib.optionals alloc [
"alloc"
] ++ lib.optionals std [
"std"
]);

features = lib.concatStringsSep "," (lib.flatten [
Expand Down
21 changes: 14 additions & 7 deletions hacking/nix/rust-utils/crate-utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#

{ lib, buildPlatform, hostPlatform
, stdenv, buildPackages
, writeText, linkFarm, runCommand
, toTOMLFile
, mkBuiltinRustTargetTriple
Expand Down Expand Up @@ -97,21 +98,27 @@ rec {
# TODO improve this mechanism
linkerConfig = { rustEnvironment, targetTriple }@args:
let
f = { targetTriple, platform }:
f = { targetTriple, platform, cc }:
let
linker = rustEnvironment.chooseLinker {
inherit targetTriple platform;
inherit targetTriple platform cc;
};
in
lib.optionalAttrs (linker != null) {
target = {
"${targetTriple.name}".linker = linker;
};
target."${targetTriple.name}".linker = linker;
};
in
clobber [
(f { targetTriple = mkBuiltinRustTargetTriple buildPlatform.config; platform = buildPlatform; })
(f { inherit targetTriple; platform = hostPlatform; })
(f {
targetTriple = mkBuiltinRustTargetTriple buildPlatform.config;
platform = buildPlatform;
inherit (buildPackages.stdenv) cc;
})
(f {
inherit targetTriple;
platform = hostPlatform;
inherit (stdenv) cc;
})
];

baseConfig = { rustEnvironment, targetTriple }@args: clobber [
Expand Down
5 changes: 3 additions & 2 deletions hacking/nix/rust-utils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ in
isBuiltin = false;
};

elaborateRustEnvironment =
elaborateRustEnvironment = lib.makeOverridable (
{ rustToolchain
, channel ? null
, isNightly ?
Expand All @@ -79,5 +79,6 @@ in
inherit rustToolchain;
lockfile = symlinkToRegularFile "Cargo.lock" "${rustToolchain}/lib/rustlib/src/rust/Cargo.lock";
};
};
}
);
}
12 changes: 8 additions & 4 deletions hacking/nix/scope/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ superCallPackage ../rust-utils {} self //
mkDefaultElaborateRustEnvironmentArgs = { rustToolchain }: rec {
inherit rustToolchain;

chooseLinker = { targetTriple, platform }:
if platform.isNone
then "${rustToolchain}/lib/rustlib/${buildPlatform.config}/bin/rust-lld"
else null;
chooseLinker = { targetTriple, platform, cc }:
if platform.config == buildPlatform.config
then null
else (
if platform.isNone
then "${rustToolchain}/lib/rustlib/${buildPlatform.config}/bin/rust-lld"
else "${cc.targetPrefix}cc"
);

vendoredSuperLockfile = vendoredTopLevelLockfile;
};
Expand Down
2 changes: 1 addition & 1 deletion hacking/nix/scope/world/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ self: with self;
inherit (worldConfig) kernelLoaderConfig;
};

mkSeL4KernelLoaderWithPayload = { appELF } : callPackage ./mk-sel4-kernel-loader-with-payload.nix {} {
mkSeL4KernelLoaderWithPayload = { appELF }: callPackage ./mk-sel4-kernel-loader-with-payload.nix {} {
app = appELF;
};

Expand Down
6 changes: 4 additions & 2 deletions hacking/nix/scope/world/mk-task.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ in
, replaceSysroot ? null
, getELF ? if test then getELFDefaultForTest else getELFDefault

, test ? false
, release ? false
, release ? true
, profile ? if release then "release" else (if test then "test" else "dev")

, test ? false

, ...
} @ args:

Expand Down
5 changes: 3 additions & 2 deletions hacking/nix/scope/world/sel4-kernel-loader.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ let

rootCrate = crates.sel4-kernel-loader;

profile = "release";
# profile = "dev";
release = true;

profile = if release then "release" else "dev";

profiles = crateUtils.clobber [
{
Expand Down
Loading