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

Platform config improvements #105294

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rec {
system = parse.doubleFromSystem final.parsed;
config = parse.tripleFromSystem final.parsed;
# Just a guess, based on `system`
platform = platforms.selectBySystem final.system;
platform = platforms.select final;
# Determine whether we are compatible with the provided CPU
isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu;
# Derived meta-data
Expand Down
6 changes: 3 additions & 3 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let

riscv = bits: {
config = "riscv${bits}-unknown-linux-gnu";
platform = platforms.riscv-multiplatform bits;
platform = platforms.riscv-multiplatform;
};
in

Expand Down Expand Up @@ -105,13 +105,13 @@ rec {
riscv64-embedded = {
config = "riscv64-none-elf";
libc = "newlib";
platform = platforms.riscv-multiplatform "64";
platform = platforms.riscv-multiplatform;
};

riscv32-embedded = {
config = "riscv32-none-elf";
libc = "newlib";
platform = platforms.riscv-multiplatform "32";
platform = platforms.riscv-multiplatform;
};

mmix = {
Expand Down
34 changes: 19 additions & 15 deletions lib/systems/platforms.nix
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,9 @@ rec {
## Other
##

riscv-multiplatform = bits: {
riscv-multiplatform = {
name = "riscv-multiplatform";
kernelArch = "riscv";
bfdEmulation = "elf${bits}lriscv";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnAZoidberg it's based off of this which has the "l", presumably for little endian.

kernelTarget = "vmlinux";
kernelAutoModules = true;
kernelBaseConfig = "defconfig";
Expand All @@ -469,17 +468,22 @@ rec {
'';
};

selectBySystem = system: {
i486-linux = pc32;
i586-linux = pc32;
i686-linux = pc32;
x86_64-linux = pc64;
armv5tel-linux = sheevaplug;
armv6l-linux = raspberrypi;
armv7a-linux = armv7l-hf-multiplatform;
armv7l-linux = armv7l-hf-multiplatform;
aarch64-linux = aarch64-multiplatform;
mipsel-linux = fuloong2f_n32;
powerpc64le-linux = powernv;
}.${system} or pcBase;
select = platform:
# x86
/**/ if platform.isx86_32 then pc32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should verify we are still looking at linux systems

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the original didn’t check that for pcBase so maybe it shouldn’t matter. I guess defaulting yo pcBase if non linux is reasonable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I would rather decide what to do with that later. If some non-linux platform has some linux config stuff, it should be harmless.

else if platform.isx86_64 then pc64

# ARM
else if platform.isAarch32 then let
version = platform.parsed.cpu.version or "";
in if lib.versionOlder version "6" then sheevaplug
else if lib.versionOlder version "7" then raspberrypi
else armv7l-hf-multiplatform
else if platform.isAarch64 then aarch64-multiplatform

else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then fuloong2f_n32

else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv

else pcBase;
}
3 changes: 2 additions & 1 deletion pkgs/build-support/bintools-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ stdenv.mkDerivation {
else if targetPlatform.isWindows then "pe"
else "elf" + toString targetPlatform.parsed.cpu.bits;
endianPrefix = if targetPlatform.isBigEndian then "big" else "little";
sep = optionalString (!targetPlatform.isMips && !targetPlatform.isPower) "-";
sep = optionalString (!targetPlatform.isMips && !targetPlatform.isPower && !targetPlatform.isRiscV) "-";
arch =
/**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64"
else if targetPlatform.isAarch32 then endianPrefix + "arm"
Expand All @@ -187,6 +187,7 @@ stdenv.mkDerivation {
else if targetPlatform.isAlpha then "alpha"
else if targetPlatform.isVc4 then "vc4"
else if targetPlatform.isOr1k then "or1k"
else if targetPlatform.isRiscV then "lriscv"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? I tried to build NixOS on RISC-V a few months ago and I added "riscv" which seemed to work.
I'm now rebasing my branch on top of master and I have a conflict here.

else throw "unknown emulation for platform: ${targetPlatform.config}";
in if targetPlatform.useLLVM or false then ""
else targetPlatform.platform.bfdEmulation or (fmt + sep + arch);
Expand Down