From f0959ba2f4452a3d19bd33f3f7c6864e13685f81 Mon Sep 17 00:00:00 2001 From: fosslinux Date: Thu, 17 Dec 2020 10:19:25 +1100 Subject: [PATCH] Initial commit As of right now, rootfs.sh creates an initramfs that: - boots linux - builds mescc-tools-seed - compiles blynn-compiler (from oriansj's fork) --- .gitignore | 2 + .gitmodules | 9 +++ blynn-compiler-extras/go.kaem | 102 +++++++++++++++++++++++++++++++ blynn-compiler-extras/kaem.patch | 12 ++++ blynn-compiler-oriansj | 1 + bootstrap-seeds | 1 + mescc-tools-seed | 1 + rootfs.sh | 35 +++++++++++ 8 files changed, 163 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100755 blynn-compiler-extras/go.kaem create mode 100644 blynn-compiler-extras/kaem.patch create mode 160000 blynn-compiler-oriansj create mode 160000 bootstrap-seeds create mode 160000 mescc-tools-seed create mode 100755 rootfs.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..385f871 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tmp/ +kernel diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8ac31f4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "mescc-tools-seed"] + path = mescc-tools-seed + url = https://github.com/oriansj/mescc-tools-seed/ +[submodule "bootstrap-seeds"] + path = bootstrap-seeds + url = https://github.com/oriansj/bootstrap-seeds +[submodule "blynn-compiler-oriansj"] + path = blynn-compiler-oriansj + url = https://github.com/oriansj/blynn-compiler diff --git a/blynn-compiler-extras/go.kaem b/blynn-compiler-extras/go.kaem new file mode 100755 index 0000000..f43507f --- /dev/null +++ b/blynn-compiler-extras/go.kaem @@ -0,0 +1,102 @@ +set -ex + +PATH=/bin + +cd blynn-compiler + +# compile pack_blobs.c +M2-Planet --architecture x86 \ + -f functions/file.c \ + -f functions/exit.c \ + -f functions/malloc.c \ + -f functions/calloc.c \ + -f functions/file_print.c \ + -f functions/match.c \ + -f functions/require.c \ + -f pack_blobs.c \ + --debug \ + -o bin/pack_blobs.M1 + +# Create dwarf stubs for pack_blobs +blood-elf -f bin/pack_blobs.M1 --entry _start -o bin/pack_blobs-footer.M1 + +# Convert to hex2 linker format +M1 -f test/common_x86/x86_defs.M1 \ + -f test/common_x86/libc-core.M1 \ + -f bin/pack_blobs.M1 \ + -f bin/pack_blobs-footer.M1 \ + --LittleEndian \ + --architecture x86 \ + -o bin/pack_blobs.hex2 + +# Link into final static binary +hex2 -f test/common_x86/ELF-i386-debug.hex2 \ + -f bin/pack_blobs.hex2 \ + --LittleEndian \ + --architecture x86 \ + --BaseAddress 0x8048000 \ + -o bin/pack_blobs --exec_enable + +# Build blobs +./bin/pack_blobs -f blob/parenthetically.source -o generated/parenthetically +./bin/pack_blobs -f blob/exponentially.source -o generated/exponentially +./bin/pack_blobs -f blob/practically.source -o generated/practically +./bin/pack_blobs -f blob/singularity.source -o generated/singularity_blob + +# Compile to assembly vm.c +M2-Planet --architecture x86 \ + -f functions/file.c \ + -f functions/exit.c \ + -f functions/malloc.c \ + -f functions/calloc.c \ + -f functions/file_print.c \ + -f functions/in_set.c \ + -f functions/numerate_number.c \ + -f functions/match.c \ + -f functions/require.c \ + -f vm.c \ + --debug \ + -o bin/vm.M1 + +# Create dwarf stubs for vm +blood-elf -f bin/vm.M1 --entry _start -o bin/vm-footer.M1 + +# Convert to hex2 linker format +M1 -f test/common_x86/x86_defs.M1 \ + -f test/common_x86/libc-core.M1 \ + -f bin/vm.M1 \ + -f bin/vm-footer.M1 \ + --LittleEndian \ + --architecture x86 \ + -o bin/vm.hex2 + +# Link into final static binary +hex2 -f test/common_x86/ELF-i386-debug.hex2 \ + -f bin/vm.hex2 \ + --LittleEndian \ + --architecture x86 \ + --BaseAddress 0x8048000 \ + -o bin/vm --exec_enable + +# Generate raw file needed +./bin/vm --bootstrap \ + -lf generated/parenthetically \ + -lf generated/exponentially \ + -lf generated/practically \ + -lf generated/singularity_blob \ + -lf singularity \ + -lf semantically \ + -lf stringy \ + -lf binary \ + -lf algebraically \ + -lf parity.hs \ + -lf fixity.hs \ + -lf typically.hs \ + -lf classy.hs \ + -lf barely.hs \ + -lf barely.hs \ + -lfr barely.hs \ + -o bin/raw + +# Make lonely +./bin/vm -f lonely.hs -l bin/raw run effectively.hs -o generated/lonely.c diff --git a/blynn-compiler-extras/kaem.patch b/blynn-compiler-extras/kaem.patch new file mode 100644 index 0000000..0d475df --- /dev/null +++ b/blynn-compiler-extras/kaem.patch @@ -0,0 +1,12 @@ +--- kaem.run 2020-12-14 17:54:49.590792093 +1100 ++++ kaem.run 2020-12-14 17:55:34.293053332 +1100 +@@ -36,3 +36,9 @@ + ############################################ + + ../bin/kaem --verbose --strict --file mes-m2.kaem ++ ++############################################ ++# Phase-14 Build blynn-compiler # ++############################################ ++ ++../bin/kaem --verbose --strict --file blynn-compiler/go.kaem diff --git a/blynn-compiler-oriansj b/blynn-compiler-oriansj new file mode 160000 index 0000000..aa5b62d --- /dev/null +++ b/blynn-compiler-oriansj @@ -0,0 +1 @@ +Subproject commit aa5b62d7358fa0a1b45730c190a15ca3a8408c2c diff --git a/bootstrap-seeds b/bootstrap-seeds new file mode 160000 index 0000000..cfa1083 --- /dev/null +++ b/bootstrap-seeds @@ -0,0 +1 @@ +Subproject commit cfa108377c15382f58b20394150840e1099b6767 diff --git a/mescc-tools-seed b/mescc-tools-seed new file mode 160000 index 0000000..8a87a76 --- /dev/null +++ b/mescc-tools-seed @@ -0,0 +1 @@ +Subproject commit 8a87a7689b9f92c218c2d6d519a3e61867a717db diff --git a/rootfs.sh b/rootfs.sh new file mode 100755 index 0000000..208f387 --- /dev/null +++ b/rootfs.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -ex + +# Setup tmp +mkdir -p tmp/ +sudo mount -t tmpfs -o size=8G tmpfs tmp + +# Now copy everything over + +# base: mescc-tools-seed +cp -r mescc-tools-seed/x86/* tmp +cp -r mescc-tools-seed/{M2-Planet,mes-m2,mescc-tools} tmp/ +cp bootstrap-seeds/POSIX/x86/kaem-optional-seed tmp/init +cp bootstrap-seeds/POSIX/x86/kaem-optional-seed tmp/ +cp -r bootstrap-seeds tmp/ +mkdir tmp/bin + +# blynn-compiler +pushd tmp +git clone ../blynn-compiler-oriansj blynn-compiler +cp ../blynn-compiler-extras/go.kaem blynn-compiler/ +patch -Np0 -i ../blynn-compiler-extras/kaem.patch +mkdir blynn-compiler/{bin,generated} +popd + +# General cleanup +find tmp -name .git -exec rm -rf \; + +# initramfs +cd tmp +find . | cpio -H newc -o | gzip > initramfs.igz +qemu-system-x86_64 -enable-kvm -kernel ../kernel -initrd initramfs.igz -append console=ttyS0 -nographic -m 16G + +# Cleanup +sudo umount tmp