Merge pull request #102766 from siraben/mmix

Initial implementation of cross-compilation to Knuth's MMIX
This commit is contained in:
John Ericson 2020-11-14 12:46:24 -05:00 committed by GitHub
commit 86fedc3a92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 16 deletions

View file

@ -36,6 +36,8 @@ let
"riscv64-none" "riscv32-none"
"vc4-none"
"mmix-mmixware"
"js-ghcjs"
"aarch64-genode" "i686-genode" "x86_64-genode"
@ -56,6 +58,7 @@ in {
i686 = filterDoubles predicates.isi686;
x86_64 = filterDoubles predicates.isx86_64;
mips = filterDoubles predicates.isMips;
mmix = filterDoubles predicates.isMmix;
riscv = filterDoubles predicates.isRiscV;
vc4 = filterDoubles predicates.isVc4;
js = filterDoubles predicates.isJavaScript;

View file

@ -109,6 +109,11 @@ rec {
platform = platforms.riscv-multiplatform "32";
};
mmix = {
config = "mmix-unknown-mmixware";
libc = "newlib";
};
msp430 = {
config = "msp430-elf";
libc = "newlib";

View file

@ -17,6 +17,7 @@ rec {
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
isMips = { cpu = { family = "mips"; }; };
isMmix = { cpu = { family = "mmix"; }; };
isRiscV = { cpu = { family = "riscv"; }; };
isSparc = { cpu = { family = "sparc"; }; };
isWasm = { cpu = { family = "wasm"; }; };

View file

@ -93,6 +93,8 @@ rec {
mips64 = { bits = 64; significantByte = bigEndian; family = "mips"; };
mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
mmix = { bits = 64; significantByte = bigEndian; family = "mmix"; };
powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
powerpc64 = { bits = 64; significantByte = bigEndian; family = "power"; };
powerpc64le = { bits = 64; significantByte = littleEndian; family = "power"; };
@ -268,19 +270,20 @@ rec {
kernels = with execFormats; with kernelFamilies; setTypes types.openKernel {
# TODO(@Ericson2314): Don't want to mass-rebuild yet to keeping 'darwin' as
# the nnormalized name for macOS.
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
ios = { execFormat = macho; families = { inherit darwin; }; };
freebsd = { execFormat = elf; families = { inherit bsd; }; };
linux = { execFormat = elf; families = { }; };
netbsd = { execFormat = elf; families = { inherit bsd; }; };
none = { execFormat = unknown; families = { }; };
openbsd = { execFormat = elf; families = { inherit bsd; }; };
solaris = { execFormat = elf; families = { }; };
wasi = { execFormat = wasm; families = { }; };
redox = { execFormat = elf; families = { }; };
windows = { execFormat = pe; families = { }; };
ghcjs = { execFormat = unknown; families = { }; };
genode = { execFormat = elf; families = { }; };
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
ios = { execFormat = macho; families = { inherit darwin; }; };
freebsd = { execFormat = elf; families = { inherit bsd; }; };
linux = { execFormat = elf; families = { }; };
netbsd = { execFormat = elf; families = { inherit bsd; }; };
none = { execFormat = unknown; families = { }; };
openbsd = { execFormat = elf; families = { inherit bsd; }; };
solaris = { execFormat = elf; families = { }; };
wasi = { execFormat = wasm; families = { }; };
redox = { execFormat = elf; families = { }; };
windows = { execFormat = pe; families = { }; };
ghcjs = { execFormat = unknown; families = { }; };
genode = { execFormat = elf; families = { }; };
mmixware = { execFormat = unknown; families = { }; };
} // { # aliases
# 'darwin' is the kernel for all of them. We choose macOS by default.
darwin = kernels.macos;
@ -382,7 +385,7 @@ rec {
else if (elemAt l 1) == "elf"
then { cpu = elemAt l 0; vendor = "unknown"; kernel = "none"; abi = elemAt l 1; }
else { cpu = elemAt l 0; kernel = elemAt l 1; };
"3" = # Awkwards hacks, beware!
"3" = # Awkward hacks, beware!
if elemAt l 1 == "apple"
then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; }
else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
@ -393,6 +396,8 @@ rec {
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; }
else if (elemAt l 2 == "redox")
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "redox"; }
else if (elemAt l 2 == "mmixware")
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "mmixware"; }
else if hasPrefix "netbsd" (elemAt l 2)
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"])

View file

@ -11,12 +11,14 @@ let
expr = lib.sort lib.lessThan x;
expected = lib.sort lib.lessThan y;
};
in with lib.systems.doubles; lib.runTests {
testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ js ++ genode ++ redox);
in
with lib.systems.doubles; lib.runTests {
testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ mmix ++ js ++ genode ++ redox);
testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv6l-none" "armv7a-linux" "armv7l-linux" "arm-none" "armv7a-darwin" ];
testi686 = mseteq i686 [ "i686-linux" "i686-freebsd" "i686-genode" "i686-netbsd" "i686-openbsd" "i686-cygwin" "i686-windows" "i686-none" "i686-darwin" ];
testmips = mseteq mips [ "mipsel-linux" ];
testmmix = mseteq mmix [ "mmix-mmixware" ];
testx86_64 = mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-genode" "x86_64-redox" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" "x86_64-windows" "x86_64-none" ];
testcygwin = mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ];

View file

@ -179,6 +179,7 @@ stdenv.mkDerivation {
mips64 = "btsmip";
mips64el = "ltsmip";
}.${targetPlatform.parsed.cpu.name}
else if targetPlatform.isMmix then "mmix"
else if targetPlatform.isPower then if targetPlatform.isBigEndian then "ppc" else "lppc"
else if targetPlatform.isSparc then "sparc"
else if targetPlatform.isMsp430 then "msp430"

View file

@ -0,0 +1,44 @@
{ stdenv, fetchFromGitLab, tetex }:
stdenv.mkDerivation {
pname = "mmixware";
version = "unstable-2019-02-19";
src = fetchFromGitLab {
domain = "gitlab.lrz.de";
owner = "mmix";
repo = "mmixware";
rev = "a330d68aafcfe739ecaaece888a669b8e7d9bcb8";
sha256 = "0bq0d19vqhfbpk4mcqzmd0hygbkhapl1mzlfkcr6afx0fhlhi087";
};
hardeningDisable = [ "format" ];
postPatch = ''
substituteInPlace Makefile --replace 'rm abstime.h' ""
'';
nativeBuildInputs = [ tetex ];
enableParallelBuilding = true;
makeFlags = [ "all" "doc" "CFLAGS=-O2" ];
installPhase = ''
runHook preInstall
mkdir -p $out/share/doc
cp *.ps $out/share/doc
install -Dm755 mmixal -t $out/bin
install -Dm755 mmix -t $out/bin
install -Dm755 mmotype -t $out/bin
install -Dm755 mmmix -t $out/bin
runHook postInstall
'';
meta = with stdenv.lib; {
description = "MMIX simulator and assembler";
homepage = "https://www-cs-faculty.stanford.edu/~knuth/mmix-news.html";
maintainers = with maintainers; [ siraben ];
platforms = platforms.unix;
license = licenses.publicDomain;
};
}

View file

@ -5691,6 +5691,8 @@ in
mmake = callPackage ../tools/misc/mmake { };
mmixware = callPackage ../development/tools/mmixware { };
modemmanager = callPackage ../tools/networking/modem-manager {};
modem-manager-gui = callPackage ../applications/networking/modem-manager-gui {};