From fc1728da0c556ef64f29449c02d781799b70cc90 Mon Sep 17 00:00:00 2001 From: Alexander Hill Date: Mon, 19 Jan 2026 21:27:26 -0500 Subject: [PATCH] Successfully built LLVM! --- STATUS.md | 2 +- bootstrap.sh | 5 ++++ rootbuild.sh | 6 ++-- sources/llvm/llvm.spec | 51 +++++++++++++++++++++++++++++++++ sources/llvm/rtsan-127764.patch | 22 ++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 sources/llvm/rtsan-127764.patch diff --git a/STATUS.md b/STATUS.md index f15111a..0e72ad4 100644 --- a/STATUS.md +++ b/STATUS.md @@ -42,7 +42,7 @@ Definitions: | `libtool` | Yes | Yes | | `limine` | Yes | Yes | | `linux` | Yes | Yes | -| `llvm` | No | No | +| `llvm` | Yes | No | | `m4` | Yes | Yes | | `make` | Yes | Yes | | `mawk` | Yes | Yes | diff --git a/bootstrap.sh b/bootstrap.sh index 94e43d7..baf1267 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -245,11 +245,15 @@ SOURCES=( bzip2 cmake coreutils + curl dash diffutils + expat findutils flex fortune-mod + gettext + git grep groff gzip @@ -275,6 +279,7 @@ SOURCES=( patch perl pkgconf + python sed tar xz diff --git a/rootbuild.sh b/rootbuild.sh index fca3bdf..dbbee95 100755 --- a/rootbuild.sh +++ b/rootbuild.sh @@ -62,10 +62,12 @@ echo "Done!" # NOTE: curl requires LibreSSL and zlib to build. ~ahill # NOTE: gettext requires ncurses to build. ~ahill # NOTE: git requires curl, expat, and gettext to build. ~ahill +# NOTE: Python requires bzip2, expat, LibreSSL, ncurses, xz, and zlib to build. ~ahill +# NOTE: LLVM requires CMake and Python to build. ~ahill cd /maple LAYER0="bc byacc bzip2 coreutils diffutils expat findutils grep gzip initramfs-tools libressl m4 make mawk muon musl ncurses patch perl pkgconf sed tar xz zlib zsh" -LAYER1="autoconf automake curl flex gettext groff libarchive libcap2 libelf libtool nano openrc" -LAYER2="cmake dash fortune-mod kmod nasm" +LAYER1="autoconf automake curl flex gettext groff libarchive libcap2 libelf libtool nano openrc python" +LAYER2="cmake dash fortune-mod git kmod llvm nasm" LAYER3="limine linux" PACKAGES="$LAYER0 $LAYER1 $LAYER2 $LAYER3" for pkg in $PACKAGES; do diff --git a/sources/llvm/llvm.spec b/sources/llvm/llvm.spec index f8f7c11..267297f 100755 --- a/sources/llvm/llvm.spec +++ b/sources/llvm/llvm.spec @@ -1,5 +1,56 @@ # Maintainer: Alexander Hill SRC_HASH="4633a23617fa31a3ea51242586ea7fb1da7140e426bd62fc164261fe036aa142" SRC_NAME="llvm" +SRC_PATCHES=" +1e52d86c422498ed5d926ad90e0787e79b8a02cb33cc916b1897c2a6ebfef9fc rtsan-127764.patch +" SRC_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/llvm-project-21.1.8.src.tar.xz" SRC_VERSION="21.1.8" + +build() { + tar xf ../$SRC_FILENAME + cd llvm-project-$SRC_VERSION.src/ + # NOTE: This version of LLVM has an issue where compiler-rt attempts to use + # a header before it is has been built. This patch fixes it. ~ahill + # See also: https://github.com/llvm/llvm-project/issues/127764 + patch -p1 < ../rtsan-127764.patch + # NOTE: compiler-rt fails to build on musl because execinfo.h is missing. + # Disabling COMPILER_RT_BUILD_GWP_ASAN works. ~ahill + # NOTE: LLVM_ENABLE_ZSTD is disabled because we don't have zstd in the + # sysroot, and because I don't believe that a library created by + # Facebook should be required for an operating system to function. + # ~ahill + # NOTE: Many build scripts still rely on the old Unix names for tools such + # as cc and ld to function. Because of this, we enable + # LLVM_INSTALL_BINUTILS_SYMLINKS and LLVM_INSTALL_CCTOOLS_SYMLINKS for + # compatibility's sake. ~ahill + cmake -B build -S llvm \ + -DCLANG_DEFAULT_CXX_STDLIB=libc++ \ + -DCLANG_DEFAULT_LINKER=lld \ + -DCLANG_DEFAULT_RTLIB=compiler-rt \ + -DCLANG_DEFAULT_UNWINDLIB=libunwind \ + -DCLANG_VENDOR=Maple \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$TT_INSTALLDIR \ + -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \ + -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ + -DLIBCXX_CXX_ABI=libcxxabi \ + -DLIBCXX_HAS_MUSL_LIBC=ON \ + -DLIBCXX_USE_COMPILER_RT=ON \ + -DLIBCXXABI_USE_COMPILER_RT=ON \ + -DLIBCXXABI_USE_LLVM_UNWINDER=ON \ + -DLIBUNWIND_USE_COMPILER_RT=ON \ + -DLLVM_ENABLE_PROJECTS="clang;lld;llvm" \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libclc;libcxx;libcxxabi;libunwind" \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_HOST_TRIPLE=$TT_TARGET \ + -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON \ + -DLLVM_INSTALL_CCTOOLS_SYMLINKS=ON + cmake --build build --parallel $TT_PROCS + cmake --install build --parallel $TT_PROCS + # NOTE: LLVM doesn't add symlinks for clang or ld.lld, so I'll make them + # myself. ~ahill + ln -sf clang $TT_INSTALLDIR/bin/cc + ln -sf clang++ $TT_INSTALLDIR/bin/c++ + ln -sf ld.lld $TT_INSTALLDIR/bin/ld +} \ No newline at end of file diff --git a/sources/llvm/rtsan-127764.patch b/sources/llvm/rtsan-127764.patch new file mode 100644 index 0000000..7ea316e --- /dev/null +++ b/sources/llvm/rtsan-127764.patch @@ -0,0 +1,22 @@ +--- + compiler-rt/lib/rtsan/CMakeLists.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/compiler-rt/lib/rtsan/CMakeLists.txt b/compiler-rt/lib/rtsan/CMakeLists.txt +index a4413d9992b6..40bcf7facad7 100644 +--- a/compiler-rt/lib/rtsan/CMakeLists.txt ++++ b/compiler-rt/lib/rtsan/CMakeLists.txt +@@ -37,6 +37,11 @@ set(RTSAN_DYNAMIC_LIBS + ${SANITIZER_CXX_ABI_LIBRARIES} + ${SANITIZER_COMMON_LINK_LIBS}) + ++if(TARGET cxx-headers OR HAVE_LIBCXX) ++ # Rtsan uses C++ standard library headers. ++ set(RTSAN_DEPS cxx-headers) ++endif() ++ + append_rtti_flag(OFF RTSAN_CFLAGS) + + if(APPLE) +-- +2.43.0