From 7edb312f2321791d72b5fd8a65fa264cb546cbde Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 24 Mar 2026 23:44:28 -0400 Subject: [PATCH] initial commit Signed-off-by: Ian Moffett --- .gitignore | 5 +++++ host/bootstrap.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++ host/build.sh | 8 +++++++ host/toolchain.sh | 39 +++++++++++++++++++++++++++++++++ src/mk/default.mk | 37 +++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 .gitignore create mode 100755 host/bootstrap.sh create mode 100644 host/build.sh create mode 100755 host/toolchain.sh create mode 100644 src/mk/default.mk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aab2932 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/var +*.o +*.d +*.sys +*.iso diff --git a/host/bootstrap.sh b/host/bootstrap.sh new file mode 100755 index 0000000..a940959 --- /dev/null +++ b/host/bootstrap.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# +# Copyright (c) 2026, Mirocom Laboratories +# Provided under the BSD-3 clause +# + +# +# Check if a list of programs are installed on the system +# +# <@>: List of programs to check +# +check_deps() { + for dep in $@; do + printf "Checking if $dep is installed... " + which $dep &>/dev/null + if [ $? -ne 0 ]; then + echo "no" + echo "Please install $dep!" + exit 1 + fi + + echo "yes" + done +} + +# +# Obtain the Mirocom gcc toolchain +# +get_toolchain() { + if [ ! -d var/cc/toolchain ]; then + git clone https://git.mirocom.org/Mirocom/mirocom-toolchain --depth=1 var/cc/toolchain + cd var/cc/toolchain + tar -xzvf toolchain.tar.gz + mv public/* .; rm -rf public/ + cd ../../../ + fi +} + +# +# Obtain all deps +# +get_deps() { + get_toolchain +} + +# Make sure everything is installed +check_deps \ + git \ + make \ + gcc \ + xorriso + +# Obtain all the deps we need +get_deps diff --git a/host/build.sh b/host/build.sh new file mode 100644 index 0000000..d87ca85 --- /dev/null +++ b/host/build.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# +# Copyright (c) 2026, Mirocom Laboratories +# Provided under the BSD-3 clause +# + + diff --git a/host/toolchain.sh b/host/toolchain.sh new file mode 100755 index 0000000..a9a54ad --- /dev/null +++ b/host/toolchain.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# +# Copyright (c) 2026, Mirocom Laboratories +# Provided under the BSD-3 clause +# + +TARGET=x86_64-pc-mirocom +MAKE=make + +mkdir -p var/ +mkdir -p var/cc/root/usr/include/ +mkdir -p var/cc/root/usr/bin/ + +# Don't build again if the lock exists +if [ -f var/cc/.lock ]; then + echo "var/cc/.lock exists, skipping toolchain build" + exit 1 +fi + +pushd var/cc/toolchain +bash build.sh + +mkdir -p gcc +pushd gcc + +# Configure gcc +../gcc-patched/configure --target=$TARGET \ + --prefix=$(pwd) --with-sysroot=$(pwd)/../../root/ \ + --disable-nls --enable-languages=c --disable-multilib + +# Build gcc +$MAKE all-gcc +$MAKE install-gcc + +# Lock the directory +popd +popd +touch var/cc/.lock diff --git a/src/mk/default.mk b/src/mk/default.mk new file mode 100644 index 0000000..57ddf9b --- /dev/null +++ b/src/mk/default.mk @@ -0,0 +1,37 @@ +ARCH_TARGET = x86_64 + +CC = \ + ../var/cc/toolchain/gcc/bin/$(ARCH_TARGET)-pc-mirocom-gcc +LD = \ + ../var/cc/toolchain/build-binutils/bin/$(ARCH_TARGET)-pc-mirocom-ld +AR = \ + ../var/cc/toolchain/build-binutils/bin/$(ARCH_TARGET)-pc-mirocom-ar + +SYS_CFLAGS = \ + -nostdlib \ + -nostdinc \ + -ffreestanding \ + -fexceptions \ + --std=gnu11 \ + -mcmodel=kernel \ + -Wno-attributes \ + -fno-stack-protector\ + -D_M1X_MULTICORE + +ifeq ($(ARCH_TARGET),x86_64) + SYS_CFLAGS += \ + -mno-sse \ + -mno-sse2 \ + -mno-sse3 \ + -mno-avx \ + -mno-avx2 \ + -mno-80387 \ + -mno-3dnow \ + -mno-mmx +endif + +PASSDOWN_ARGS = \ + ARCH=$(ARCH_TARGET) \ + SYS_CC=$(CC) \ + SYS_LD=$(LD) \ + SYS_CFLAGS="$(SYS_CFLAGS)"