From eb830570b4c9fe849f34d670d8feac1c6e865adb Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Sun, 30 Jan 2022 20:12:38 +0000 Subject: [PATCH] clang: split in two - clang and clang-libs Follow the llvm approach and split the package in two - clang and clang-libs. This packages which depend solely on the library can use that instead of clang itself. For example: people can use opencl-mesa + clang-libs, without the need of pulling the gcc, compiler-rt and their respective dependencies. The total of which weighting at 300+ MiB - reducing both bandwidth and local storage. Signed-off-by: Emil Velikov --- repos/extra-x86_64/PKGBUILD | 55 +++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/repos/extra-x86_64/PKGBUILD b/repos/extra-x86_64/PKGBUILD index 1e32af17..a76f64c3 100644 --- a/repos/extra-x86_64/PKGBUILD +++ b/repos/extra-x86_64/PKGBUILD @@ -1,23 +1,17 @@ # Maintainer: Evangelos Foutras # Contributor: Jan "heftig" Steffens -pkgname=clang +pkgbase=clang +pkgname=(clang clang-libs) pkgver=13.0.0 pkgrel=4 pkgdesc="C language family frontend for LLVM" arch=('x86_64') url="https://clang.llvm.org/" license=('custom:Apache 2.0 with LLVM Exception') -depends=('llvm-libs' 'gcc' 'compiler-rt') makedepends=('llvm' 'cmake' 'ninja' 'python-sphinx') -optdepends=('openmp: OpenMP support in clang with -fopenmp' - 'python: for scan-view and git-clang-format' - 'llvm: referenced by some clang headers') -provides=("clang-analyzer=$pkgver" "clang-tools-extra=$pkgver") -conflicts=('clang-analyzer' 'clang-tools-extra') -replaces=('clang-analyzer' 'clang-tools-extra') _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver -source=($_source_base/$pkgname-$pkgver.src.tar.xz{,.sig} +source=($_source_base/$pkgbase-$pkgver.src.tar.xz{,.sig} $_source_base/clang-tools-extra-$pkgver.src.tar.xz{,.sig} $_source_base/llvm-$pkgver.src.tar.xz{,.sig} fix-scan-build-py-executable-lookup-path.patch @@ -56,7 +50,7 @@ _get_distribution_components() { } prepare() { - cd "$srcdir/$pkgname-$pkgver.src" + cd "$srcdir/$pkgbase-$pkgver.src" mkdir build mv "$srcdir/clang-tools-extra-$pkgver.src" tools/extra patch -Np2 -i ../enable-SSP-and-PIE-by-default.patch @@ -69,7 +63,7 @@ prepare() { } build() { - cd "$srcdir/$pkgname-$pkgver.src/build" + cd "$srcdir/$pkgbase-$pkgver.src/build" local cmake_args=( -G Ninja @@ -97,7 +91,7 @@ build() { } check() { - cd "$srcdir/$pkgname-$pkgver.src/build" + cd "$srcdir/$pkgbase-$pkgver.src/build" ninja check-clang{,-tools} } @@ -107,8 +101,16 @@ _python_optimize() { python -OO -m compileall "$@" } -package() { - cd "$srcdir/$pkgname-$pkgver.src/build" +package_clang() { + depends=('clang-libs' 'gcc' 'compiler-rt') + optdepends=('openmp: OpenMP support in clang with -fopenmp' + 'python: for scan-view and git-clang-format' + 'llvm: referenced by some clang headers') + provides=("clang-analyzer=$pkgver" "clang-tools-extra=$pkgver") + conflicts=('clang-analyzer' 'clang-tools-extra') + replaces=('clang-analyzer' 'clang-tools-extra') + + cd "$srcdir/$pkgbase-$pkgver.src/build" DESTDIR="$pkgdir" ninja install-distribution install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE" @@ -116,6 +118,29 @@ package() { # Remove documentation sources rm -r "$pkgdir"/usr/share/doc/clang{,-tools}/html/{_sources,.buildinfo} + # The python and runtime libraries go into clang-libs + mv -f "$pkgdir"/usr/lib/libclang{,-cpp}.so* "$srcdir" + mv -f "$pkgdir"/usr/lib/{libear,libscanbuild} "$srcdir" + mv -f "$pkgdir"/usr/libexec "$srcdir" + mv -f "$pkgdir"/usr/bin/scan-build "$srcdir" +} + +package_clang-libs() { + depends=('llvm-libs') + optdepends=('python: for the python bindings') + + cd "$srcdir/$pkgbase-$pkgver.src/build" + + # Move in libraries ejected at end of package_clang + install -d "$pkgdir/usr/lib" + install -d "$pkgdir/usr/lib/clang" + install -d "$pkgdir/usr/bin" + cp -a "$srcdir"/libclang{,-cpp}.so* "$pkgdir/usr/lib" + # These three moved again below, but keeping those blocks untouched for cleaner merges with upstream monopackage. + cp -a "$srcdir"/{libear,libscanbuild} "$pkgdir/usr/lib" + cp -av "$srcdir"/libexec "$pkgdir"/usr/ + cp -av "$srcdir"/scan-build "$pkgdir"/usr/bin/ + # Move scanbuild-py into site-packages and install Python bindings local site_packages=$(python -c "import site; print(site.getsitepackages()[0])") install -d "$pkgdir/$site_packages" @@ -131,6 +156,8 @@ package() { # Compile Python scripts _python_optimize "$pkgdir/usr/share" "$pkgdir/$site_packages" + + install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE" } # vim:set ts=2 sw=2 et: -- 2.34.1