Merge pull request #105294 from Ericson2314/platform-config-improvements

Platform config improvements
This commit is contained in:
John Ericson 2020-12-02 11:17:41 -05:00 committed by GitHub
commit 8e21ce5fae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 20 deletions

View File

@ -25,7 +25,7 @@ rec {
system = parse.doubleFromSystem final.parsed; system = parse.doubleFromSystem final.parsed;
config = parse.tripleFromSystem final.parsed; config = parse.tripleFromSystem final.parsed;
# Just a guess, based on `system` # Just a guess, based on `system`
platform = platforms.selectBySystem final.system; platform = platforms.select final;
# Determine whether we are compatible with the provided CPU # Determine whether we are compatible with the provided CPU
isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu; isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu;
# Derived meta-data # Derived meta-data

View File

@ -7,7 +7,7 @@ let
riscv = bits: { riscv = bits: {
config = "riscv${bits}-unknown-linux-gnu"; config = "riscv${bits}-unknown-linux-gnu";
platform = platforms.riscv-multiplatform bits; platform = platforms.riscv-multiplatform;
}; };
in in
@ -110,13 +110,13 @@ rec {
riscv64-embedded = { riscv64-embedded = {
config = "riscv64-none-elf"; config = "riscv64-none-elf";
libc = "newlib"; libc = "newlib";
platform = platforms.riscv-multiplatform "64"; platform = platforms.riscv-multiplatform;
}; };
riscv32-embedded = { riscv32-embedded = {
config = "riscv32-none-elf"; config = "riscv32-none-elf";
libc = "newlib"; libc = "newlib";
platform = platforms.riscv-multiplatform "32"; platform = platforms.riscv-multiplatform;
}; };
mmix = { mmix = {

View File

@ -471,10 +471,9 @@ rec {
## Other ## Other
## ##
riscv-multiplatform = bits: { riscv-multiplatform = {
name = "riscv-multiplatform"; name = "riscv-multiplatform";
kernelArch = "riscv"; kernelArch = "riscv";
bfdEmulation = "elf${bits}lriscv";
kernelTarget = "vmlinux"; kernelTarget = "vmlinux";
kernelAutoModules = true; kernelAutoModules = true;
kernelBaseConfig = "defconfig"; kernelBaseConfig = "defconfig";
@ -484,17 +483,22 @@ rec {
''; '';
}; };
selectBySystem = system: { select = platform:
i486-linux = pc32; # x86
i586-linux = pc32; /**/ if platform.isx86_32 then pc32
i686-linux = pc32; else if platform.isx86_64 then pc64
x86_64-linux = pc64;
armv5tel-linux = sheevaplug; # ARM
armv6l-linux = raspberrypi; else if platform.isAarch32 then let
armv7a-linux = armv7l-hf-multiplatform; version = platform.parsed.cpu.version or "";
armv7l-linux = armv7l-hf-multiplatform; in if lib.versionOlder version "6" then sheevaplug
aarch64-linux = aarch64-multiplatform; else if lib.versionOlder version "7" then raspberrypi
mipsel-linux = fuloong2f_n32; else armv7l-hf-multiplatform
powerpc64le-linux = powernv; else if platform.isAarch64 then aarch64-multiplatform
}.${system} or pcBase;
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;
} }

View File

@ -167,7 +167,7 @@ stdenv.mkDerivation {
else if targetPlatform.isWindows then "pe" else if targetPlatform.isWindows then "pe"
else "elf" + toString targetPlatform.parsed.cpu.bits; else "elf" + toString targetPlatform.parsed.cpu.bits;
endianPrefix = if targetPlatform.isBigEndian then "big" else "little"; endianPrefix = if targetPlatform.isBigEndian then "big" else "little";
sep = optionalString (!targetPlatform.isMips && !targetPlatform.isPower) "-"; sep = optionalString (!targetPlatform.isMips && !targetPlatform.isPower && !targetPlatform.isRiscV) "-";
arch = arch =
/**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64" /**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64"
else if targetPlatform.isAarch32 then endianPrefix + "arm" else if targetPlatform.isAarch32 then endianPrefix + "arm"
@ -187,6 +187,7 @@ stdenv.mkDerivation {
else if targetPlatform.isAlpha then "alpha" else if targetPlatform.isAlpha then "alpha"
else if targetPlatform.isVc4 then "vc4" else if targetPlatform.isVc4 then "vc4"
else if targetPlatform.isOr1k then "or1k" else if targetPlatform.isOr1k then "or1k"
else if targetPlatform.isRiscV then "lriscv"
else throw "unknown emulation for platform: ${targetPlatform.config}"; else throw "unknown emulation for platform: ${targetPlatform.config}";
in if targetPlatform.useLLVM or false then "" in if targetPlatform.useLLVM or false then ""
else targetPlatform.platform.bfdEmulation or (fmt + sep + arch); else targetPlatform.platform.bfdEmulation or (fmt + sep + arch);