aports/main/llvm-runtimes/APKBUILD
2025-05-08 07:06:52 +00:00

160 lines
4.7 KiB
Text

# Contributor: Eric Molitor <eric@molitor.org>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=llvm-runtimes
# Note: Update together with llvm.
pkgver=20.1.4
_llvmver=${pkgver%%.*}
pkgrel=0
pkgdesc="LLVM Runtimes"
url="https://llvm.org/"
arch="all"
license="Apache-2.0"
makedepends="
clang
cmake
linux-headers
llvm$_llvmver-dev
llvm$_llvmver-static
python3
samurai
"
subpackages="
libc++:libcxx
libc++-static:libcxx_static
libc++-dev:libcxx_dev
compiler-rt:rt
llvm-libunwind:libunwind
llvm-libunwind-static:libunwind_static
llvm-libunwind-dev:libunwind_dev
"
source="https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver//_/-}/llvm-project-${pkgver//_/}.src.tar.xz
armv6-arch.patch.noauto
compiler-rt-lsan-dtp-offset.patch
compiler-rt-ppc-fixes.patch
compiler-rt-sanitizer-supported-arch.patch
libunwind-link-libssp.patch
fix-msan-with-musl.patch
"
builddir="$srcdir/llvm-project-${pkgver//_/}.src"
options="!check"
case "$CARCH" in
# Sanitizers are broken on other arches.
# Keep in sync with compiler-rt-sanitizer-supported-arch.patch.
aarch64|ppc64le|x86_64|riscv64|loongarch64)
_build_sanitizers='ON'
;;
*)
_build_sanitizers='OFF'
;;
esac
prepare() {
default_prepare
case "$CARCH" in
armhf)
patch -Np1 < "$srcdir"/armv6-arch.patch.noauto
;;
esac
}
build() {
if [ "$CBUILD" != "$CHOST" ]; then
local crossopts="
-DCMAKE_SYSTEM_NAME=Linux
-DCMAKE_HOST_SYSTEM_NAME=Linux
-DLIBUNWIND_SYSROOT=$CBUILDROOT
"
fi
CC=clang \
CXX=clang++ \
CFLAGS="$CFLAGS -DNDEBUG -DSANITIZER_CAN_USE_PREINIT_ARRAY=0" \
CXXFLAGS="$CXXFLAGS -DNDEBUG -DSANITIZER_CAN_USE_PREINIT_ARRAY=0" \
cmake -B build -G Ninja -Wno-dev -S runtimes \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIBCXX_HAS_MUSL_LIBC=ON \
-DLIBUNWIND_HAS_NODEFAULTLIBS_FLAG=OFF \
-DCOMPILER_RT_INCLUDE_TESTS="$(want_check && echo ON || echo OFF)" \
-DCOMPILER_RT_BUILD_SANITIZERS=$_build_sanitizers \
-DCOMPILER_RT_INSTALL_PATH="/usr/lib/llvm$_llvmver/lib/clang/$_llvmver" \
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
-DCMAKE_VERBOSE_MAKEFILE=ON \
$crossopts
cmake --build build
}
package() {
# create target triple dir and a relative symlink to it
local clangruntimedir="$(clang -print-runtime-dir)"
install -dm0755 "$pkgdir"/"$clangruntimedir"
ln -s "${clangruntimedir##*/}" "$pkgdir"/"${clangruntimedir%/*}"/linux
DESTDIR="$pkgdir" cmake --install build
install -dm0755 "$pkgdir"/usr/include/mach-o
cp libunwind/include/*.h "$pkgdir"/usr/include/
cp libunwind/include/mach-o/*.h "$pkgdir"/usr/include/mach-o/
}
libunwind() {
pkgdesc="LLVM libunwind library"
depends="!libunwind-dev"
amove usr/lib/libunwind.so.*
}
libunwind_static() {
pkgdesc="LLVM libunwind library (static)"
amove usr/lib/libunwind.a
}
libunwind_dev() {
pkgdesc="LLVM libunwind library (development files)"
amove usr/lib/libunwind.so
amove usr/include
}
rt() {
pkgdesc="LLVM compiler-rt runtime libraries"
# prefix with 0.0 for easy migration to clang-rtlib when this ver no longer tracks default Clang
provides="clang$_llvmver-rtlib=0.0.$pkgver-r$pkgrel"
amove usr/lib/llvm$_llvmver/lib/clang/$_llvmver
}
libcxx() {
pkgdesc="LLVM libc++ library"
amove usr/lib/libc++*.so.*
}
libcxx_static() {
pkgdesc="LLVM libc++ library (static libs)"
amove usr/lib/libc++*.a
}
libcxx_dev() {
pkgdesc="LLVM libc++ library (development files)"
amove usr/lib/libc++*.so
amove usr/include/c++
}
sha512sums="
acace8175a5468c7e84a89d1564e147e81fe92b6d910f22b058edf72094b27176677c06dbe141fccfbabdad77165f957bbf1ec8aff7bffc85f0757c0103f7e59 llvm-project-20.1.4.src.tar.xz
ed30960bc5dea6d611a691e12949ddff1346fb5ba0ff36741496bf36442468f3724bb98526d230a97e58848bef703d6b793db27e254d927004f1903e3f2816ed armv6-arch.patch.noauto
e3831613d807695ff5fb3d0903954bf4ccf8907852a488959fb4b002b6ec0e8b8d0beea76aa99621ccaec4d30fe61311d5cb067023ff486826c42d3084f134be compiler-rt-lsan-dtp-offset.patch
80929e113a1ba879a09ec664d2bd0f2e8a1c69b34159266b92cc17540959fd79ad8a55ad0bc26196974427a47803f0cb25c20269125458f91422f2d1c758e186 compiler-rt-ppc-fixes.patch
7754a0b6d5d65bc7bcc35d8d16d43c21e202a068ae729508d2d00a3e32b88483763666a9ec3130f8be4cefd59aee30f2bd46f07e6bef0519084c05a96342fdcc compiler-rt-sanitizer-supported-arch.patch
98eeabdeb08d6c9ed767cfd8a9ed29dc6732cd87235395b51245081299c7367194fb533e1c064249a32a98da68ae396f64e304a97a2d2b7dbdb874f77da160df libunwind-link-libssp.patch
0a4f0b5ae82f93387e8880c6e293eef9234f0cb4dadf7c52846f1a45612b931d2b460579d08d48548de9a7e6372b75f95e05e32683a60911a3d48f567cd4808b fix-msan-with-musl.patch
"