Date: Sunday, February 26, 2023 @ 11:38:15
  Author: foutrelis
Revision: 469626

upgpkg: llvm14 14.0.6-3: drop most static libs (FS#77644)

We're building with LLVM_BUILD_LLVM_DYLIB=ON so there is little point to
shipping static libs. Let's see if anything breaks after we remove them.

Modified:
  llvm14/trunk/PKGBUILD

----------+
 PKGBUILD |   38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2023-02-26 11:24:24 UTC (rev 469625)
+++ PKGBUILD    2023-02-26 11:38:15 UTC (rev 469626)
@@ -3,7 +3,7 @@
 
 pkgname=('llvm14' 'llvm14-libs')
 pkgver=14.0.6
-pkgrel=2
+pkgrel=3
 arch=('x86_64')
 url="https://llvm.org/";
 license=('custom:Apache 2.0 with LLVM Exception')
@@ -19,6 +19,34 @@
             'ee9baf6df05474083857044d92f26f59d3ee709cdf82ba3bdb2792e6645f71d9')
 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard 
<[email protected]>
 
+# Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
+# installing static libraries; inspired by Gentoo
+_get_distribution_components() {
+  local target
+  ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r 
target; do
+    case $target in
+      llvm-libraries|distribution)
+        continue
+        ;;
+      # shared libraries
+      LLVM|LLVMgold)
+        ;;
+      # libraries needed for clang-tblgen
+      LLVMDemangle|LLVMSupport|LLVMTableGen)
+        ;;
+      # exclude static libraries
+      LLVM*)
+        continue
+        ;;
+      # exclude llvm-exegesis (doesn't seem useful without libpfm)
+      llvm-exegesis)
+        continue
+        ;;
+    esac
+    echo $target
+  done
+}
+
 prepare() {
   cd llvm-$pkgver.src
   mkdir build
@@ -51,7 +79,13 @@
     -DLLVM_LINK_LLVM_DYLIB=ON
     -DLLVM_USE_PERF=ON
   )
+
   cmake .. "${cmake_args[@]}"
+  local distribution_components=$(_get_distribution_components | paste -sd\;)
+  test -n "$distribution_components"
+  cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
+
+  cmake .. "${cmake_args[@]}"
   ninja
 }
 
@@ -66,7 +100,7 @@
 
   cd llvm-$pkgver.src/build
 
-  DESTDIR="$pkgdir" ninja install
+  DESTDIR="$pkgdir" ninja install-distribution
 
   # The runtime libraries go into llvm14-libs
   mv -f "$pkgdir"/usr/lib/llvm14/lib/libLLVM-{14,$pkgver}.so "$srcdir/"

Reply via email to