# Maintainer: pkgname=scudo-malloc # tied to llvm version pkgver=16.0.6 pkgrel=1 pkgdesc="Standalone scudo malloc from compiler-rt" url="https://llvm.org" arch="all" license="Apache-2.0 WITH LLVM-exception" depends_dev="$pkgname=$pkgver-r$pkgrel" makedepends="linux-headers" checkdepends="gtest-dev" subpackages="$pkgname-static $pkgname-dev" source="https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver//_/-}/compiler-rt-${pkgver//_/}.src.tar.xz va_args.patch " builddir="$srcdir/compiler-rt-${pkgver//_/}.src/lib/scudo/standalone" prepare() { default_prepare # these can't build against musl because of mallopt/malloc_info rm -fv tests/wrappers_*_test.cpp # mallocs into oom(?) rm -fv tests/combined_test.cpp } build() { export CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-mismatched-new-delete -std=c++17 -fvisibility=hidden -fno-exceptions -fno-rtti -pthread -fPIC -O3 -Iinclude -I. -DNDEBUG -DSCUDO_CAN_USE_PRIMARY64=0" case "$CARCH" in aarch64) # this has broken emulation in aarch64 qemu (incl qemu-user), # which causes it to abort instantly export CXXFLAGS="$CXXFLAGS -DSCUDO_DISABLE_TBI" ;; esac msg "building libscudo" ${CXX:-c++} ./*.cpp $CXXFLAGS -ffreestanding -nostdinc++ -c # on arches with hardware crc32, the code can runtime detect it, # so rebuild the crc32 object case "$CARCH" in aarch64) rm -fv crc32_hw.o msg "rebuilding crc32_hw.cpp" ${CXX:-c++} ./crc32_hw.cpp $CXXFLAGS -ffreestanding -nostdinc++ -c -march=armv8-a+crc ;; x86|x86_64) rm -fv crc32_hw.o msg "rebuilding crc32_hw.cpp" ${CXX:-c++} ./crc32_hw.cpp $CXXFLAGS -ffreestanding -nostdinc++ -c -mcrc32 ;; esac msg "linking libscudo" # this is just a standard malloc interface, so we don't need an soname or versioning for it ${CXX:-c++} ./*.o $CXXFLAGS $LDFLAGS -shared -o libscudo.so ${AR:-ar} rcs libscudo.a ./*.o if want_check; then msg "building tests" ${CXX:-c++} ./tests/*_test.cpp ./*.cpp tests/scudo_unit_test_main.cpp -o scudo_test $CXXFLAGS -g $LDFLAGS -L. -lgtest fi } check() { ./scudo_test } package() { install -Dm755 libscudo.so -t "$pkgdir"/usr/lib/ install -Dm644 libscudo.a -t "$pkgdir"/usr/lib/ install -Dm644 include/scudo/interface.h -t "$pkgdir"/usr/include/scudo/ } sha512sums=" 852e2105facb12ea0943aa24e0c220f76671ad76dfe7d07b8164c3a1d8360670ca565a2b6dd590722b974e16a2adf3c466fdabdfd3bb3ebbd005162c8ac4406c compiler-rt-16.0.6.src.tar.xz 353efde0a155e9d07c06ed778ade5c3434520e7c90b70947357f199ffe31883ae6924b9dfce0f61e655479f93b9b6699f89d8a5f9a8950f12e47244781c44748 va_args.patch "