Initial commit

This commit is contained in:
2026-03-21 12:43:00 -05:00
commit 83bf16823c
438 changed files with 33617 additions and 0 deletions
@@ -0,0 +1,37 @@
From 9779b878973501138a7ac60671ea791dde0ea029 Mon Sep 17 00:00:00 2001
From: q66 <q66@chimera-linux.org>
Date: Sat, 4 Nov 2023 08:44:01 +0100
Subject: [PATCH 01/29] llvm: always set a larger stack size explicitly
---
llvm/lib/Support/Threading.cpp | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 693de0e64..dd3e76fb8 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -75,21 +75,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
// keyword.
#include "llvm/Support/thread.h"
-#if defined(__APPLE__)
- // Darwin's default stack size for threads except the main one is only 512KB,
- // which is not enough for some/many normal LLVM compilations. This implements
- // the same interface as std::thread but requests the same stack size as the
- // main thread (8MB) before creation.
const std::optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024;
-#elif defined(_AIX)
- // On AIX, the default pthread stack size limit is ~192k for 64-bit programs.
- // This limit is easily reached when doing link-time thinLTO. AIX library
- // developers have used 4MB, so we'll do the same.
-const std::optional<unsigned> llvm::thread::DefaultStackSize = 4 * 1024 * 1024;
-#else
-const std::optional<unsigned> llvm::thread::DefaultStackSize;
-#endif
-
#endif
--
2.51.1
+230
View File
@@ -0,0 +1,230 @@
#!/bin/sh
set -eu
jobs() {
if command -v nproc >/dev/null 2>&1; then
nproc
else
getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1
fi
}
target_triple() {
printf '%s\n' "${CHOST:-x86_64-sfg-linux-gnu}"
}
assert_destdir() {
[ "${DESTDIR:-}" != "" ] || {
echo "build.sh: DESTDIR is not set" >&2
exit 1
}
}
haul_from_primary() {
pkg=$1
shift
old_destdir=$DESTDIR
DESTDIR=$DEPOT_PRIMARY_DESTDIR
export DESTDIR
haul "$pkg" "$@"
DESTDIR=$old_destdir
export DESTDIR
}
depot_build() {
j=$(jobs)
triple=$(target_triple)
cmake -G Ninja llvm \
-B build-clang-llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_SKIP_INSTALL_RPATH=ON \
-DLLVM_ENABLE_PROJECTS=clang\;lld\;flang \
-DLLVM_ENABLE_RUNTIMES=compiler-rt \
-DLLVM_USE_LINKER=lld \
-DLLVM_DEFAULT_TARGET_TRIPLE="$triple" \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DCLANG_LINK_CLANG_DYLIB=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_FFI=ON \
-DCLANG_DEFAULT_PIE_ON_LINUX=ON \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DCLANG_DEFAULT_CXX_STDLIB=libc++ \
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
-DLLVM_INCLUDE_UTILS=ON \
-DLLVM_BUILD_UTILS=ON \
-DSANITIZER_CXX_ABI=libcxxabi \
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=OFF \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DLLVM_INSTALL_UTILS=ON \
-DCLANG_DEFAULT_UNWINDLIB="none" \
-DCOMPILER_RT_BUILD_SANITIZERS=ON \
-DCOMPILER_RT_BUILD_XRAY=ON \
-DCOMPILER_RT_BUILD_LIBFUZZER=ON \
-DCOMPILER_RT_BUILD_PROFILE=ON \
-DCOMPILER_RT_BUILD_MEMPROF=ON \
-DCOMPILER_RT_BUILD_ORC=ON \
-DCOMPILER_RT_BUILD_CRT=ON \
-DLLVM_BUILD_DOCS=ON \
-DCMAKE_INSTALL_DOCDIR=share/doc \
-DSPHINX_WARNINGS_AS_ERRORS=OFF \
-DLLVM_ENABLE_SPHINX=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ARCH="i686;x86_64" \
-DCLANG_DEFAULT_RTLIB=compiler-rt \
-DLLVM_INCLUDE_TESTS=ON
ninja -C build-clang-llvm -j"$j"
cmake -G Ninja runtimes/ \
-B build-libcxx \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLLVM_ENABLE_RUNTIMES=libcxx\;libcxxabi\;libunwind \
-DCMAKE_C_COMPILER_TARGET="$triple" \
-DCMAKE_CXX_COMPILER_TARGET="$triple" \
-DLLVM_DEFAULT_TARGET_TRIPLE="$triple" \
-DLLVM_ENABLE_LTO=Thin \
-DLLVM_ENABLE_SPHINX=ON \
-DLIBCXX_INCLUDE_DOCS=ON \
-DCMAKE_INSTALL_DOCDIR=share/doc \
-DSPHINX_WARNINGS_AS_ERRORS=OFF \
-DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -unwindlib=libunwind -rtlib=compiler-rt" \
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -unwindlib=libunwind -rtlib=compiler-rt"
ninja -C build-libcxx -j"$j"
cmake -G Ninja llvm-libgcc \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-B build-llvm-libgcc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_BUILD_LIBUNWIND=ON \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_PROFILE=OFF \
-DLLVM_LIBGCC_EXPLICIT_OPT_IN=Yes \
-DCMAKE_C_COMPILER_TARGET="$triple" \
-DCMAKE_CXX_COMPILER_TARGET="$triple" \
-DLLVM_DEFAULT_TARGET_TRIPLE="$triple" \
-DCOMPILER_RT_BUILD_CRT=ON \
-DCOMPILER_RT_BUILD_ORC=OFF \
-DCOMPILER_RT_BAREMETAL_BUILD=OFF \
-DCOMPILER_RT_USE_LLVM_UNWINDER=ON \
-DCOMPILER_RT_ENABLE_STATIC_UNWINDER=ON \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF \
-DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -unwindlib=libunwind -rtlib=compiler-rt" \
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -unwindlib=libunwind -rtlib=compiler-rt"
ninja -C build-llvm-libgcc -j"$j"
}
depot_install() {
# Primary package: install the big LLVM/Clang/Flang tree once, then split from it.
assert_destdir
DESTDIR="$DESTDIR" cmake --install build-clang-llvm
ln -snf clang "$DESTDIR/usr/bin/cc"
ln -snf clang++ "$DESTDIR/usr/bin/c++"
ln -snf flang "$DESTDIR/usr/bin/f95"
ln -snf ld.lld "$DESTDIR/usr/bin/ld"
ln -snf linux/clang_rt.crtbegin-x86_64.o "$DESTDIR/usr/lib/crtbeginS.o"
ln -snf linux/clang_rt.crtend-x86_64.o "$DESTDIR/usr/lib/crtendS.o"
ln -snf linux/clang_rt.crtbegin-x86_64.o "$DESTDIR/usr/lib/crtbeginT.o"
ln -snf linux/clang_rt.crtend-x86_64.o "$DESTDIR/usr/lib/crtendT.o"
ln -snf linux/clang_rt.crtbegin-x86_64.o "$DESTDIR/usr/lib/crtbegin.o"
ln -snf linux/clang_rt.crtend-x86_64.o "$DESTDIR/usr/lib/crtend.o"
if [ -f "$DESTDIR/usr/share/clang/bash-autocomplete.sh" ]; then
mkdir -p "$DESTDIR/usr/share/bash-completion/completions"
mv "$DESTDIR/usr/share/clang/bash-autocomplete.sh" \
"$DESTDIR/usr/share/bash-completion/completions/clang"
fi
}
depot_install_llvm_libs() {
# Split shared LLVM libraries out of the primary LLVM install tree.
haul_from_primary llvm-libs 'usr/lib/libLLVM*.so*'
haul_from_primary llvm-libs 'usr/lib/libLTO.so*'
haul_from_primary llvm-libs 'usr/lib/libRemarks.so*'
}
depot_install_clang() {
haul_from_primary clang 'usr/bin/analyze-build'
haul_from_primary clang 'usr/bin/amdgpu-arch'
haul_from_primary clang 'usr/bin/c-index-test'
haul_from_primary clang 'usr/bin/clang*'
haul_from_primary clang 'usr/bin/diagtool'
haul_from_primary clang 'usr/bin/git-clang-format'
haul_from_primary clang 'usr/bin/hmaptool'
haul_from_primary clang 'usr/bin/intercept-build'
haul_from_primary clang 'usr/bin/nvptx-arch'
haul_from_primary clang 'usr/bin/scan-build*'
haul_from_primary clang 'usr/bin/scan-view'
haul_from_primary clang 'usr/bin/cc'
haul_from_primary clang 'usr/bin/c++'
haul_from_primary clang 'usr/include/clang*'
haul_from_primary clang 'usr/lib/clang'
haul_from_primary clang 'usr/lib/cmake/clang'
haul_from_primary clang 'usr/lib/libclang*.so*'
haul_from_primary clang 'usr/share/clang*'
haul_from_primary clang 'usr/share/scan-build'
haul_from_primary clang 'usr/share/scan-view'
haul_from_primary clang 'usr/share/bash-completion/completions/clang'
haul_from_primary clang 'usr/lib/crt*'
haul_from_primary clang 'usr/share/doc/clang*'
haul_from_primary clang 'usr/share/man/man1/clang*'
}
depot_install_libcxx() {
assert_destdir
DESTDIR="$DESTDIR" cmake --install build-libcxx
# Keep libcxx package focused (libunwind belongs to llvm-libgcc in this split).
rm -f "$DESTDIR/usr/include/__libunwind_config.h" \
"$DESTDIR/usr/include/libunwind.h" \
"$DESTDIR/usr/include/libunwind.modulemap" \
"$DESTDIR/usr/include/unwind.h" \
"$DESTDIR/usr/include/unwind_itanium.h" \
"$DESTDIR/usr/include/unwind_arm_ehabi.h" \
"$DESTDIR/usr/include/mach-o/compact_unwind_encoding.h"
rm -f "$DESTDIR/usr/lib/libunwind.so" \
"$DESTDIR/usr/lib/libunwind.so.1" \
"$DESTDIR/usr/lib/libunwind.so.1.0" \
"$DESTDIR/usr/lib/libunwind.a"
rm -rf "$DESTDIR/usr/lib/cmake/libunwind"
rmdir "$DESTDIR/usr/include/mach-o" 2>/dev/null || true
}
depot_install_llvm_libgcc() {
assert_destdir
DESTDIR="$DESTDIR" cmake --install build-llvm-libgcc
}
depot_install_flang() {
haul_from_primary flang 'usr/bin/flang*'
haul_from_primary flang 'usr/bin/tco'
haul_from_primary flang 'usr/bin/fir-*'
haul_from_primary flang 'usr/bin/f95'
haul_from_primary flang 'usr/include/flang*'
haul_from_primary flang 'usr/lib/cmake/flang*'
haul_from_primary flang 'usr/lib/libFIR*'
haul_from_primary flang 'usr/lib/libFortran*'
haul_from_primary flang 'usr/lib/libFlang*'
haul_from_primary flang 'usr/lib/libflang*'
haul_from_primary flang 'usr/lib/libCUFAttrs.a'
haul_from_primary flang 'usr/lib/libCUFDialect.a'
haul_from_primary flang 'usr/share/man/man1/flang*'
}
@@ -0,0 +1,63 @@
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -362,6 +362,7 @@
set(i386_SOURCES
${GENERIC_SOURCES}
+ ${GENERIC_TF_SOURCES}
${x86_ARCH_SOURCES}
i386/ashldi3.S
i386/ashrdi3.S
@@ -1012,9 +1013,9 @@
list(APPEND BUILTIN_CFLAGS_${arch} -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
endif()
- # For RISCV32 and 32-bit SPARC, we must force enable int128 for compiling long
- # double routines.
- if (COMPILER_RT_ENABLE_SOFTWARE_INT128 OR ("${arch}" MATCHES "riscv32|sparc$"
+ # For i386, RISCV32 and 32-bit SPARC, we must force enable int128 for
+ # compiling long double routines.
+ if (COMPILER_RT_ENABLE_SOFTWARE_INT128 OR ("${arch}" MATCHES "i386|riscv32|sparc$"
AND NOT CMAKE_COMPILER_IS_GNUCC))
list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
endif()
--- a/compiler-rt/lib/builtins/extendxftf2.c
+++ b/compiler-rt/lib/builtins/extendxftf2.c
@@ -12,7 +12,8 @@
#define QUAD_PRECISION
#include "fp_lib.h"
-#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && \
+ (defined(__x86_64__) || defined(__i386__))
#define SRC_80
#define DST_QUAD
#include "fp_extend_impl.inc"
--- a/compiler-rt/lib/builtins/trunctfxf2.c
+++ b/compiler-rt/lib/builtins/trunctfxf2.c
@@ -12,7 +12,8 @@
#define QUAD_PRECISION
#include "fp_lib.h"
-#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && \
+ (defined(__x86_64__) || defined(__i386__))
#define SRC_QUAD
#define DST_80
--- a/compiler-rt/lib/builtins/truncxfbf2.c
+++ b/compiler-rt/lib/builtins/truncxfbf2.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && \
+ (defined(__x86_64__) || defined(__i386__))
#define SRC_80
#define DST_BFLOAT
#include "fp_trunc_impl.inc"
+119
View File
@@ -0,0 +1,119 @@
[package]
name = "llvm"
version = "22.1.1"
revision = 2
description = "Collection of modular and reusable compiler and toolchain technologies"
homepage = "https://llvm.org/"
license = ["Apache-2.0 WITH LLVM-exception"]
[[packages]]
name = "clang"
version = "22.1.1"
revision = 2
description = "Modern C, C++, and Objective-C frontend built on LLVM"
homepage = "https://llvm.org/"
license = ["Apache-2.0 WITH LLVM-exception"]
[[packages]]
name = "llvm-libs"
version = "22.1.1"
revision = 2
description = "Essential shared runtime libraries for LLVM/Clang users"
homepage = "https://llvm.org/"
license = ["Apache-2.0 WITH LLVM-exception"]
[[packages]]
name = "libcxx"
version = "22.1.1"
revision = 2
description = "LLVM libc++, libc++abi, and related runtime components"
homepage = "https://llvm.org/"
license = ["Apache-2.0 WITH LLVM-exception"]
[[packages]]
name = "llvm-libgcc"
version = "22.1.1"
revision = 2
description = "LLVM low-level runtime support (compiler-rt/libunwind style)"
homepage = "https://llvm.org/"
license = ["Apache-2.0 WITH LLVM-exception"]
[[packages]]
name = "flang"
version = "22.1.1"
revision = 2
description = "Fortran frontend for LLVM"
homepage = "https://llvm.org/"
license = ["Apache-2.0 WITH LLVM-exception"]
[source]
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/llvm-project-$version.src.tar.xz"
sha256 = "sha256:9c6f37f6f5f68d38f435d25f770fc48c62d92b2412205767a16dac2c942f0c95"
extract_dir = "llvm-project-$version.src"
patches = [ "0001-llvm-always-set-a-larger-stack-size-explicitly.patch", "llvm-project-22.1.1-compiler-rt-i386-tf-builtins.patch" ]
[[manual_sources]]
files = [ "llvm-project-22.1.1-compiler-rt-i386-tf-builtins.patch", "0001-llvm-always-set-a-larger-stack-size-explicitly.patch" ]
[build]
type = "custom"
[build.flags]
skip_tests = true
no_delete_static = true
use_lto = false
split_docs = true
[dependencies]
build = [
"cmake",
"ninja",
"libffi",
"python-setuptools",
"zstd",
"libxml215",
"curl",
"python-sphinx",
"python-wheel",
"python-setuptools",
"python-myst-parser",
"python-psutil",
"git",
"lib32-glibc"
]
runtime = [
"libcxx",
"libffi",
"libxml215",
"zlib-ng",
"zstd",
"glibc",
"llvm-libgcc",
]
[package_dependencies.llvm-libs]
runtime = ["llvm-libgcc", "libffi", "libxml215", "zlib-ng", "zstd", "libedit"]
[package_dependencies.libcxx]
runtime = ["libunwind", "glibc"]
[package_dependencies.llvm-libgcc]
runtime = ["glibc"]
[package_dependencies.clang]
runtime = ["llvm-libs", "llvm-libgcc"]
[package_dependencies.flang]
runtime = ["libffi", "llvm-libs", "zstd", "zlib-ng", "llvm", "compiler-rt"]
[package_alternatives.llvm]
provides = ["binutils"]
[package_alternatives.clang]
provides = ["cc", "c++", "gcc"]
[package_alternatives.libcxx]
provides = ["libstdc++", "libc++"]
[package_alternatives.llvm-libgcc]
provides = ["libgcc", "compiler-rt", "libunwind"]