commit bf93e7d6c50d71a77d32a6afdd26474d90d5ce00
parent 6110995cfbd5f7c182613bfcf34b1b363ecdd234
Author: cowmonk <cowmonk@based.pt>
Date: Wed, 12 Nov 2025 11:22:44 -0700
Sources + Header Build
Added Source pulling via curl.
Diffstat:
7 files changed, 94 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,2 @@
+./sources
+./build
diff --git a/Makefile b/Makefile
@@ -1,5 +1,33 @@
include config.mk
+SOURCES_FILE=./sources.list
+ARCH=$(shell uname -m)
+FROOT="${ARCH}-musllvm"
+
all:
-.PHONY:
+pull:
+ @if [ ! -d ./sources ]; then \
+ echo "Sources Directory Not Found!"; \
+ mkdir -p ./sources; \
+ echo "Pulling Sources..."; \
+ xargs -a ${SOURCES_FILE} -n1 -P4 -- curl -L -S -O --output-dir ./sources || { echo "curl failed"; exit 1; }; \
+ echo "done"; \
+ else \
+ ./scripts/check.sh; \
+ fi
+
+build: init
+ ./scripts/headers.sh
+
+init:
+ @if [ ! -d ./build/${FROOT} ]; then \
+ echo "Making toolchain directory..."; \
+ mkdir -p ./build/${FROOT}; \
+ fi
+
+clean:
+ rm -rf ./sources
+ rm -rf ./build
+
+.PHONY: all pull build clean init
diff --git a/README.md b/README.md
@@ -3,5 +3,12 @@
A simple make build system to make a pure musl clang/llvm toolchain.
Targeting x86_64.
+# Dependencies
+Here are some dependencies required to build this toolchain:
+- a C compiler (preferably clang)
+- curl
+- make
+- POSIX Unix utilities (GNU utilities are acceptable)
+
# Credits
* [Chimera linux](https://chimera-linux.org) - Majority of patches are sourced from chimera linux.
diff --git a/config.mk b/config.mk
@@ -0,0 +1,6 @@
+# musllvm default flags
+
+CC = cc
+CFLAGS = -O2 -pipe
+
+
diff --git a/scripts/check.sh b/scripts/check.sh
@@ -0,0 +1,12 @@
+#/bin/sh
+
+while IFS= read -r url; do \
+[ -z "$url" ] && continue; \
+fname="$(printf '%s' "$url" | sed -E 's/[?#].*$//' | sed -E 's!.*/!!')"; \
+if [ -e "$(OUTDIR)/$fname" ]; then \
+ printf "SKIP: %s (already exists)\n" "$fname"; \
+else \
+ printf "GET: %s -> %s\n" "$url" "$fname"; \
+ curl -o "./sources/$fname" "$url" || { printf "ERROR: failed to download %s\n" "$url"; exit 1; }; \
+fi; \
+done < ${SOURCES_FILE}; \
diff --git a/scripts/headers.sh b/scripts/headers.sh
@@ -0,0 +1,27 @@
+#/bin/sh
+
+ARCH=$(uname -m)
+FROOT="${ARCH}-musllvm"
+LINUX_TAR=$(printf '%s' "$url" | sed -E 's/[?#].*$//' | sed -E 's!.*/!!' | grep -i linux)
+LINUX_SOURCE="${LINUX_TAR%%.tar*}"
+
+if command -v "clang" >/dev/null 2>&1 && command -v "lld" >/dev/null 2>&1; then
+ export LLVM=1
+ export LLVM=IAS
+fi
+
+tar -xpf ./sources/${LINUX_TAR} ./build
+
+mkdir -pv ./build/${FROOT}/include
+
+echo "Building Headers"
+pushd ./build/${LINUX_SOURCE}
+
+make mrproper
+make headers
+find usr/include \( -name .install -o -name ..install.cmd \) -exec rm -vf {} \;
+cp -rv usr/include/* ../${FROOT}/include/
+rm -v ../${FROOT}/include/Makefile
+
+popd
+
diff --git a/sources.list b/sources.list
@@ -1,2 +1,11 @@
-https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/llvm-project-20.1.8.src.tar.xz
-
+https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.17.7.tar.xz
+https://musl.libc.org/releases/musl-1.2.5.tar.gz
+https://pub.sortix.org/libz/libz-1.2.8.2025.03.07.tar.gz
+https://github.com/chimera-linux/libatomic-chimera/archive/refs/tags/v0.90.0.tar.gz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/llvm-21.1.2.src.tar.xz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/cmake-21.1.2.src.tar.xz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/third-party-21.1.2.src.tar.xz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/clang-21.1.2.src.tar.xz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/compiler-rt-21.1.2.src.tar.xz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.5/lld-21.1.5.src.tar.xz
+https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.5/libunwind-21.1.5.src.tar.xz