summaryrefslogtreecommitdiff
path: root/bootstrap.sh
diff options
context:
space:
mode:
authorAlexander Hill <ahill@breadpudding.dev>2025-11-14 18:27:49 -0500
committerAlexander Hill <ahill@breadpudding.dev>2025-11-14 18:27:49 -0500
commitf8787a89115503dcd1b4ad05d6309e75d4727fa7 (patch)
tree3c8f7d99749b83b6d529c8a5f8f49585d5e5931c /bootstrap.sh
parent6f8194193d95d43dc0ff8bd896d3c636a23a259a (diff)
Fixed the bootstrap and updated treetap
Bootstrap build survived overnight. TGIF
Diffstat (limited to 'bootstrap.sh')
-rwxr-xr-xbootstrap.sh18
1 files changed, 12 insertions, 6 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index 5db4386..532da62 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -8,6 +8,7 @@ ARCH=$(echo $TARGET | cut -d"-" -f1)
BOOTSTRAP=$(pwd)/.bootstrap
PROCS=$(nproc)
SOURCES=$(pwd)/.treetap/sources
+SPEC=$(pwd)/sources
export AR=llvm-ar
export CC=clang
export CFLAGS="-fuse-ld=lld -O3 -march=$MICROARCH -pipe --sysroot=$BOOTSTRAP/root -Wno-unused-command-line-argument"
@@ -15,8 +16,9 @@ export CXX=clang++
export CXXFLAGS=$CFLAGS
export RANLIB=llvm-ranlib
export LD=ld.lld
-export TREETAP_SYSROOT=$BOOTSTRAP/root
-export TREETAP_TARGET=$TARGET
+export LDFLAGS="--sysroot=$BOOTSTRAP/root"
+export TT_SYSROOT=$BOOTSTRAP/root
+export TT_TARGET=$TARGET
# Fetch sources required for a bootstrap
./treetap fetch sources/busybox.spec
@@ -57,7 +59,8 @@ set(CMAKE_SYSTEM_NAME Linux)
EOF
# Install headers for Linux
-tar xf $SOURCES/linux/*/linux-*.tar*
+LINUX_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/linux.spec)
+tar xf $SOURCES/linux/$LINUX_VERSION/linux-*.tar*
cd linux-*/
# NOTE: LLVM=1 is required here because GCC and other GNU tools are required in
# some places still. This allows us to use LLVM and bypass the parts that
@@ -71,7 +74,8 @@ cp -r usr/include $BOOTSTRAP/root/usr
cd ..
# Install headers for musl
-tar xf $SOURCES/musl/*/musl-*.tar*
+MUSL_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/musl.spec)
+tar xf $SOURCES/musl/$MUSL_VERSION/musl-*.tar*
cd musl-*/
# NOTE: We are intentionally not passing --target here because musl follows the
# GNU approach when it comes to cross-compiling. This means the build
@@ -90,7 +94,8 @@ make -O -j $PROCS install-headers DESTDIR=$BOOTSTRAP/root
cd ..
# Build and install compiler-rt builtins
-tar xf $SOURCES/llvm/*/llvm-project-*.tar*
+LLVM_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/llvm.spec)
+tar xf $SOURCES/llvm/$LLVM_VERSION/llvm-project-*.tar*
cd llvm-project-*/
cmake -S compiler-rt/lib/builtins -B build-builtins \
-DCMAKE_BUILD_TYPE=Release \
@@ -187,7 +192,8 @@ cmake --install build-llvm --parallel $PROCS
cd ..
# Build Busybox
-tar xf $SOURCES/busybox/*/busybox-*.tar*
+BUSYBOX_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/busybox.spec)
+tar xf $SOURCES/busybox/$BUSYBOX_VERSION/busybox-*.tar*
cd busybox-*/
# NOTE: Like we did with musl before, we don't set CROSS_COMPILE because LLVM is
# smart and doesn't need a compiler to cross-compile code. With that said,