Github messages for voidlinux
 help / color / mirror / Atom feed
From: Calandracas606 <Calandracas606@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [WIP] New package: llvm19-19.1.0
Date: Tue, 06 Aug 2024 19:40:58 +0200	[thread overview]
Message-ID: <20240806174058.CCEBE28585@inbox.vuxu.org> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-51527@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1492 bytes --]

There is an updated pull request by Calandracas606 against master on the void-packages repository

https://github.com/Calandracas606/void-packages llvm19
https://github.com/void-linux/void-packages/pull/51527

[WIP] New package: llvm19-19.1.0
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **NO**


#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**


<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for my native architecture, x86_64-glibc
- I built this PR locally for these architectures (if supported. mark crossbuilds):

  - [x] x86_64 
  - [x] x86_64-musl
  - [x] i686
  - [x] aarch64 (cross)
  - [ ] aarch64-musl (cross)
  - [x] armv7l (cross)
  - [ ] armv7l-musl (cross)
  - [x] armv6l (cross)
  - [ ] armv6l-musl (cross)

TODO:
- [ ] build libomptarget properly
- [ ] libclc spirv-mesa3d-

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/51527.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-llvm19-51527.patch --]
[-- Type: text/x-diff, Size: 201667 bytes --]

From ff71baa55d9f7f23860cb1bb7bdbcf01b0dcfe66 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Mon, 29 Jul 2024 08:58:45 -0400
Subject: [PATCH 01/19] New package: llvm19-19.1.0

---
 common/shlibs                                 |   4 +
 srcpkgs/clang-analyzer19                      |   1 +
 srcpkgs/clang-tools-extra19                   |   1 +
 srcpkgs/clang19                               |   1 +
 srcpkgs/clang19-devel                         |   1 +
 srcpkgs/clang19-headers                       |   1 +
 srcpkgs/compiler-rt19                         |   1 +
 srcpkgs/flang19                               |   1 +
 srcpkgs/flang19-devel                         |   1 +
 srcpkgs/libclang-cpp19                        |   1 +
 srcpkgs/libclang19                            |   1 +
 srcpkgs/libclc                                |   1 +
 srcpkgs/libclc/template                       |  30 -
 srcpkgs/liblldb19                             |   1 +
 srcpkgs/libllvm19                             |   1 +
 srcpkgs/libomp19                              |   1 +
 srcpkgs/libomp19-devel                        |   1 +
 srcpkgs/lld18-devel                           |   1 -
 srcpkgs/lld19                                 |   1 +
 srcpkgs/lld19-devel                           |   1 +
 srcpkgs/lldb-devel18                          |   1 -
 srcpkgs/lldb19                                |   1 +
 srcpkgs/lldb19-devel                          |   1 +
 srcpkgs/llvm-bolt19                           |   1 +
 srcpkgs/llvm-libunwind                        |   2 +-
 srcpkgs/llvm-libunwind-devel                  |   2 +-
 srcpkgs/llvm-libunwind-devel18                |   1 -
 srcpkgs/llvm-libunwind18                      |   1 -
 srcpkgs/llvm19-cross-tools                    |   1 +
 srcpkgs/llvm19-devel                          |   1 +
 srcpkgs/llvm19-doc                            |   1 +
 .../llvm19/files/llvm-Config-llvm-config.h    |   9 +
 srcpkgs/llvm19/patches/SmallVector.patch      |  13 +
 ...s-set-a-larger-stack-size-explicitly.patch |  37 +
 ...clang-001-fix-unwind-chain-inclusion.patch |  44 +
 .../patches/clang-002-add-musl-triples.patch  | 115 +++
 .../clang-003-ppc64-dynamic-linker-path.patch |  13 +
 .../compiler-rt-sanitizer-ppc64-musl.patch    |  37 +
 ...compiler-rt-sanitizer-supported-arch.patch |  22 +
 srcpkgs/llvm19/patches/libcxx-armv67.patch    |  35 +
 srcpkgs/llvm19/patches/libcxx-musl.patch      |  26 +
 .../llvm19/patches/libcxx-ssp-nonshared.patch |  11 +
 srcpkgs/llvm19/patches/libcxxabi-dl.patch     |  25 +
 srcpkgs/llvm19/patches/libomp-soname.patch    |  12 +
 srcpkgs/llvm19/patches/llvm-001-musl.patch    |  32 +
 .../patches/llvm-004-override-opt.patch       |  18 +
 .../llvm19/patches/llvm-005-ppc-bigpic.patch  |  36 +
 .../patches/llvm-006-aarch64-mf_exec.patch    |  24 +
 srcpkgs/llvm19/patches/mallopt-musl.patch     |  22 +
 srcpkgs/llvm19/patches/openmp-stdint.patch    |  12 +
 srcpkgs/llvm19/template                       | 789 ++++++++++++++++++
 srcpkgs/llvm19/update                         |   3 +
 srcpkgs/mlir19                                |   1 +
 srcpkgs/mlir19-devel                          |   1 +
 54 files changed, 1366 insertions(+), 36 deletions(-)
 create mode 120000 srcpkgs/clang-analyzer19
 create mode 120000 srcpkgs/clang-tools-extra19
 create mode 120000 srcpkgs/clang19
 create mode 120000 srcpkgs/clang19-devel
 create mode 120000 srcpkgs/clang19-headers
 create mode 120000 srcpkgs/compiler-rt19
 create mode 120000 srcpkgs/flang19
 create mode 120000 srcpkgs/flang19-devel
 create mode 120000 srcpkgs/libclang-cpp19
 create mode 120000 srcpkgs/libclang19
 create mode 120000 srcpkgs/libclc
 delete mode 100644 srcpkgs/libclc/template
 create mode 120000 srcpkgs/liblldb19
 create mode 120000 srcpkgs/libllvm19
 create mode 120000 srcpkgs/libomp19
 create mode 120000 srcpkgs/libomp19-devel
 delete mode 120000 srcpkgs/lld18-devel
 create mode 120000 srcpkgs/lld19
 create mode 120000 srcpkgs/lld19-devel
 delete mode 120000 srcpkgs/lldb-devel18
 create mode 120000 srcpkgs/lldb19
 create mode 120000 srcpkgs/lldb19-devel
 create mode 120000 srcpkgs/llvm-bolt19
 delete mode 120000 srcpkgs/llvm-libunwind-devel18
 delete mode 120000 srcpkgs/llvm-libunwind18
 create mode 120000 srcpkgs/llvm19-cross-tools
 create mode 120000 srcpkgs/llvm19-devel
 create mode 120000 srcpkgs/llvm19-doc
 create mode 100644 srcpkgs/llvm19/files/llvm-Config-llvm-config.h
 create mode 100644 srcpkgs/llvm19/patches/SmallVector.patch
 create mode 100644 srcpkgs/llvm19/patches/always-set-a-larger-stack-size-explicitly.patch
 create mode 100644 srcpkgs/llvm19/patches/clang-001-fix-unwind-chain-inclusion.patch
 create mode 100644 srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch
 create mode 100644 srcpkgs/llvm19/patches/clang-003-ppc64-dynamic-linker-path.patch
 create mode 100644 srcpkgs/llvm19/patches/compiler-rt-sanitizer-ppc64-musl.patch
 create mode 100644 srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch
 create mode 100644 srcpkgs/llvm19/patches/libcxx-armv67.patch
 create mode 100644 srcpkgs/llvm19/patches/libcxx-musl.patch
 create mode 100644 srcpkgs/llvm19/patches/libcxx-ssp-nonshared.patch
 create mode 100644 srcpkgs/llvm19/patches/libcxxabi-dl.patch
 create mode 100644 srcpkgs/llvm19/patches/libomp-soname.patch
 create mode 100644 srcpkgs/llvm19/patches/llvm-001-musl.patch
 create mode 100644 srcpkgs/llvm19/patches/llvm-004-override-opt.patch
 create mode 100644 srcpkgs/llvm19/patches/llvm-005-ppc-bigpic.patch
 create mode 100644 srcpkgs/llvm19/patches/llvm-006-aarch64-mf_exec.patch
 create mode 100644 srcpkgs/llvm19/patches/mallopt-musl.patch
 create mode 100644 srcpkgs/llvm19/patches/openmp-stdint.patch
 create mode 100644 srcpkgs/llvm19/template
 create mode 100644 srcpkgs/llvm19/update
 create mode 120000 srcpkgs/mlir19
 create mode 120000 srcpkgs/mlir19-devel

diff --git a/common/shlibs b/common/shlibs
index a5314955498e24..fcc4654a5df84c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -988,14 +988,18 @@ libuchardet.so.0 uchardet-0.0.6_1
 libgtksourceviewmm-3.0.so.0 gtksourceviewmm-3.2.0_1
 libyajl.so.2 yajl-2.0.1_1
 libconfuse.so.2 confuse-3.2.1_1
+liblldb.so.19.1-rc1 liblldb19-19.1.0_1
 liblldb.so.18.1 liblldb18-18.1.8_1
 liblldb.so.17 liblldb17-17.0.6_3
+libclang.so.19.1-rc1 libclang19-19.1.0_1
 libclang.so.18.1 libclang18-18.1.8_1
 libclang.so.17 libclang17-17.0.6_1
+libclang-cpp.so.19.1-rc1 libclang-cpp19-19.1.0_1
 libclang-cpp.so.18.1 libclang-cpp18-18.1.8_1
 libclang-cpp.so.17 libclang-cpp17-17.0.6_1
 libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
+libLLVM.so.19.1-rc1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
diff --git a/srcpkgs/clang-analyzer19 b/srcpkgs/clang-analyzer19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/clang-analyzer19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/clang-tools-extra19 b/srcpkgs/clang-tools-extra19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/clang-tools-extra19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/clang19 b/srcpkgs/clang19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/clang19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/clang19-devel b/srcpkgs/clang19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/clang19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/clang19-headers b/srcpkgs/clang19-headers
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/clang19-headers
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/compiler-rt19 b/srcpkgs/compiler-rt19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/compiler-rt19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/flang19 b/srcpkgs/flang19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/flang19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/flang19-devel b/srcpkgs/flang19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/flang19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libclang-cpp19 b/srcpkgs/libclang-cpp19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libclang-cpp19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libclang19 b/srcpkgs/libclang19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libclang19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libclc b/srcpkgs/libclc
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libclc
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libclc/template b/srcpkgs/libclc/template
deleted file mode 100644
index da85a23c785549..00000000000000
--- a/srcpkgs/libclc/template
+++ /dev/null
@@ -1,30 +0,0 @@
-# Template file for 'libclc'
-pkgname=libclc
-version=18.1.8
-revision=1
-build_style=cmake
-# disable clspv (failing tests, we don't ship it)
-configure_args="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
- -DLIBCLC_TARGETS_TO_BUILD=amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl;spirv-mesa3d-;spirv64-mesa3d-"
-hostmakedepends="llvm18-devel python3 libedit-devel libffi-devel
- ncurses-devel zlib-devel SPIRV-LLVM-Translator"
-short_desc="Open implementation of the OpenCL C programming language"
-maintainer="Daniel Martinez <danielmartinez@cock.li>"
-license="BSD-3-Clause, MIT"
-homepage="https://libclc.llvm.org"
-distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/libclc-${version}.src.tar.xz"
-checksum=905bd59e9f810d6bd0ae6874725a8f8a3c91cb416199c03f2b98b57437cfb32e
-replaces="libclc-git>=0"
-
-do_configure() {
-	# We really do a native build.
-	# The outcome is just header files.
-	unset CC CXX LD CFLAGS CXXFLAGS LDFLAGS
-	mkdir -p build
-	cd build
-	cmake -GNinja ${configure_args} ..
-}
-
-post_install() {
-	vlicense LICENSE.TXT
-}
diff --git a/srcpkgs/liblldb19 b/srcpkgs/liblldb19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/liblldb19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libllvm19 b/srcpkgs/libllvm19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libllvm19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libomp19 b/srcpkgs/libomp19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libomp19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libomp19-devel b/srcpkgs/libomp19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libomp19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/lld18-devel b/srcpkgs/lld18-devel
deleted file mode 120000
index 1f418dc969a832..00000000000000
--- a/srcpkgs/lld18-devel
+++ /dev/null
@@ -1 +0,0 @@
-llvm18
\ No newline at end of file
diff --git a/srcpkgs/lld19 b/srcpkgs/lld19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/lld19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/lld19-devel b/srcpkgs/lld19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/lld19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/lldb-devel18 b/srcpkgs/lldb-devel18
deleted file mode 120000
index 1f418dc969a832..00000000000000
--- a/srcpkgs/lldb-devel18
+++ /dev/null
@@ -1 +0,0 @@
-llvm18
\ No newline at end of file
diff --git a/srcpkgs/lldb19 b/srcpkgs/lldb19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/lldb19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/lldb19-devel b/srcpkgs/lldb19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/lldb19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm-bolt19 b/srcpkgs/llvm-bolt19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/llvm-bolt19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind b/srcpkgs/llvm-libunwind
index 1f418dc969a832..985027fe0a5c8d 120000
--- a/srcpkgs/llvm-libunwind
+++ b/srcpkgs/llvm-libunwind
@@ -1 +1 @@
-llvm18
\ No newline at end of file
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind-devel b/srcpkgs/llvm-libunwind-devel
index 1f418dc969a832..985027fe0a5c8d 120000
--- a/srcpkgs/llvm-libunwind-devel
+++ b/srcpkgs/llvm-libunwind-devel
@@ -1 +1 @@
-llvm18
\ No newline at end of file
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind-devel18 b/srcpkgs/llvm-libunwind-devel18
deleted file mode 120000
index 1f418dc969a832..00000000000000
--- a/srcpkgs/llvm-libunwind-devel18
+++ /dev/null
@@ -1 +0,0 @@
-llvm18
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind18 b/srcpkgs/llvm-libunwind18
deleted file mode 120000
index 1f418dc969a832..00000000000000
--- a/srcpkgs/llvm-libunwind18
+++ /dev/null
@@ -1 +0,0 @@
-llvm18
\ No newline at end of file
diff --git a/srcpkgs/llvm19-cross-tools b/srcpkgs/llvm19-cross-tools
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/llvm19-cross-tools
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm19-devel b/srcpkgs/llvm19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/llvm19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm19-doc b/srcpkgs/llvm19-doc
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/llvm19-doc
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm19/files/llvm-Config-llvm-config.h b/srcpkgs/llvm19/files/llvm-Config-llvm-config.h
new file mode 100644
index 00000000000000..2fa08c9be69621
--- /dev/null
+++ b/srcpkgs/llvm19/files/llvm-Config-llvm-config.h
@@ -0,0 +1,9 @@
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+#include "llvm-config-32.h"
+#elif __WORDSIZE == 64
+#include "llvm-config-64.h"
+#else
+#error "Unknown word size"
+#endif
diff --git a/srcpkgs/llvm19/patches/SmallVector.patch b/srcpkgs/llvm19/patches/SmallVector.patch
new file mode 100644
index 00000000000000..ac10d306c4346d
--- /dev/null
+++ b/srcpkgs/llvm19/patches/SmallVector.patch
@@ -0,0 +1,13 @@
+diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
+index 2e6d2dc6ce90..be2cf6cc1fee 100644
+--- a/llvm/include/llvm/ADT/SmallVector.h
++++ b/llvm/include/llvm/ADT/SmallVector.h
+@@ -1163,7 +1163,7 @@ template <typename T> struct CalculateSmallVectorDefaultInlinedElements {
+   // happens on a 32-bit host and then fails due to sizeof(T) *increasing* on a
+   // 64-bit host, is expected to be very rare.
+   static_assert(
+-      sizeof(T) <= 256,
++      sizeof(T) <= 288,
+       "You are trying to use a default number of inlined elements for "
+       "`SmallVector<T>` but `sizeof(T)` is really big! Please use an "
+       "explicit number of inlined elements with `SmallVector<T, N>` to make "
diff --git a/srcpkgs/llvm19/patches/always-set-a-larger-stack-size-explicitly.patch b/srcpkgs/llvm19/patches/always-set-a-larger-stack-size-explicitly.patch
new file mode 100644
index 00000000000000..cb17121dea2021
--- /dev/null
+++ b/srcpkgs/llvm19/patches/always-set-a-larger-stack-size-explicitly.patch
@@ -0,0 +1,37 @@
+From 2354350bcc890c13016d67f4c060b32cb1cd693c 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/25] 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 7cc7ba44c..b91b8f4bb 100644
+--- a/llvm/lib/Support/Threading.cpp
++++ b/llvm/lib/Support/Threading.cpp
+@@ -77,21 +77,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.42.0
diff --git a/srcpkgs/llvm19/patches/clang-001-fix-unwind-chain-inclusion.patch b/srcpkgs/llvm19/patches/clang-001-fix-unwind-chain-inclusion.patch
new file mode 100644
index 00000000000000..e4eaa7783e7a6c
--- /dev/null
+++ b/srcpkgs/llvm19/patches/clang-001-fix-unwind-chain-inclusion.patch
@@ -0,0 +1,44 @@
+From 352974169f0d2b5da3d5321f588f5e3b5941330e Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe@gmail.com>
+Date: Tue, 8 Sep 2015 22:14:57 +0200
+Subject: [PATCH 2/7] fix unwind chain inclusion
+
+---
+ lib/Headers/unwind.h | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/lib/Headers/unwind.h b/lib/Headers/unwind.h
+index 303d792..44e10cc 100644
+--- a/clang/lib/Headers/unwind.h
++++ b/clang/lib/Headers/unwind.h
+@@ -9,9 +9,6 @@
+ 
+ /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
+ 
+-#ifndef __CLANG_UNWIND_H
+-#define __CLANG_UNWIND_H
+-
+ #if defined(__APPLE__) && __has_include_next(<unwind.h>)
+ /* Darwin (from 11.x on) provide an unwind.h. If that's available,
+  * use it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
+@@ -39,6 +36,9 @@
+ # endif
+ #else
+ 
++#ifndef __CLANG_UNWIND_H
++#define __CLANG_UNWIND_H
++
+ #include <stdint.h>
+ 
+ #ifdef __cplusplus
+@@ -322,6 +322,7 @@ _Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *);
+ }
+ #endif
+ 
++#endif /* __CLANG_UNWIND_H */
++
+ #endif
+ 
+-#endif /* __CLANG_UNWIND_H */
+-- 
+2.5.1
diff --git a/srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch b/srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch
new file mode 100644
index 00000000000000..0ef4c7e75d6b58
--- /dev/null
+++ b/srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch
@@ -0,0 +1,115 @@
+--- a/clang/lib/Driver/ToolChains/Gnu.cpp
++++ b/clang/lib/Driver/ToolChains/Gnu.cpp
+@@ -2086,7 +2086,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
+   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
+                                              "armv7hl-redhat-linux-gnueabi",
+                                              "armv6hl-suse-linux-gnueabi",
+-                                             "armv7hl-suse-linux-gnueabi"};
++                                             "armv7hl-suse-linux-gnueabi",
++                                             "armv7l-linux-gnueabihf"};
+   static const char *const ARMebLibDirs[] = {"/lib"};
+   static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
+                                              "armeb-linux-androideabi"};
+@@ -2153,8 +2154,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
+       "powerpc64-suse-linux", "powerpc-montavista-linuxspe"};
+   static const char *const PPCLELibDirs[] = {"/lib32", "/lib"};
+   static const char *const PPCLETriples[] = {"powerpcle-linux-gnu",
+-                                             "powerpcle-unknown-linux-gnu",
+-                                             "powerpcle-linux-musl"};
++                                             "powerpcle-unknown-linux-gnu"};
+ 
+   static const char *const PPC64LibDirs[] = {"/lib64", "/lib"};
+   static const char *const PPC64Triples[] = {
+@@ -2235,6 +2235,92 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
+     return;
+   }
+ 
++  if (TargetTriple.isMusl()) {
++    static const char *const AArch64MuslTriples[] = {"aarch64-linux-musl"};
++    static const char *const ARMHFMuslTriples[] = {
++        "arm-linux-musleabihf", "armv7l-linux-musleabihf"
++    };
++    static const char *const ARMMuslTriples[] = {"arm-linux-musleabi"};
++    static const char *const X86_64MuslTriples[] = {"x86_64-linux-musl"};
++    static const char *const X86MuslTriples[] = {"i686-linux-musl"};
++    static const char *const MIPSMuslTriples[] = {
++        "mips-linux-musl", "mipsel-linux-musl",
++        "mipsel-linux-muslhf", "mips-linux-muslhf"
++    };
++    static const char *const PPCMuslTriples[] = {"powerpc-linux-musl"};
++    static const char *const PPCLEMuslTriples[] = {"powerpcle-linux-musl"};
++    static const char *const PPC64MuslTriples[] = {"powerpc64-linux-musl"};
++    static const char *const PPC64LEMuslTriples[] = {"powerpc64le-linux-musl"};
++    static const char *const RISCV64MuslTriples[] = {"riscv64-linux-musl"};
++
++    switch (TargetTriple.getArch()) {
++    case llvm::Triple::aarch64:
++      LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
++      TripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
++      BiarchLibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
++      BiarchTripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
++      break;
++    case llvm::Triple::arm:
++      LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
++      if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
++        TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples));
++      } else {
++        TripleAliases.append(begin(ARMMuslTriples), end(ARMMuslTriples));
++      }
++      break;
++    case llvm::Triple::x86_64:
++      LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
++      TripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
++      BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
++      BiarchTripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
++      break;
++    case llvm::Triple::x86:
++      LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
++      TripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
++      BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
++      BiarchTripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
++      break;
++    case llvm::Triple::mips:
++      LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
++      TripleAliases.append(begin(MIPSMuslTriples), end(MIPSMuslTriples));
++      break;
++    case llvm::Triple::ppc:
++      LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
++      TripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
++      BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
++      BiarchTripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
++      break;
++    case llvm::Triple::ppcle:
++      LibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs));
++      TripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples));
++      BiarchLibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
++      BiarchTripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples));
++      break;
++    case llvm::Triple::ppc64:
++      LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
++      TripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
++      BiarchLibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
++      BiarchTripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
++      break;
++    case llvm::Triple::ppc64le:
++      LibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
++      TripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples));
++      BiarchLibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs));
++      BiarchTripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples));
++      break;
++    case llvm::Triple::riscv64:
++      LibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
++      TripleAliases.append(begin(RISCV64MuslTriples), end(RISCV64MuslTriples));
++      break;
++    default:
++      break;
++    }
++    TripleAliases.push_back(TargetTriple.str());
++    if (TargetTriple.str() != BiarchTriple.str())
++      BiarchTripleAliases.push_back(BiarchTriple.str());
++    return;
++  }
++
+   // Android targets should not use GNU/Linux tools or libraries.
+   if (TargetTriple.isAndroid()) {
+     static const char *const AArch64AndroidTriples[] = {
diff --git a/srcpkgs/llvm19/patches/clang-003-ppc64-dynamic-linker-path.patch b/srcpkgs/llvm19/patches/clang-003-ppc64-dynamic-linker-path.patch
new file mode 100644
index 00000000000000..4ad6412d1e6c63
--- /dev/null
+++ b/srcpkgs/llvm19/patches/clang-003-ppc64-dynamic-linker-path.patch
@@ -0,0 +1,13 @@
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -504,10 +504,6 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+     Loader = "ld.so.1";
+     break;
+   case llvm::Triple::ppc64:
+-    LibDir = "lib64";
+-    Loader =
+-        (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1";
+-    break;
+   case llvm::Triple::ppc64le:
+     LibDir = "lib64";
+     Loader =
diff --git a/srcpkgs/llvm19/patches/compiler-rt-sanitizer-ppc64-musl.patch b/srcpkgs/llvm19/patches/compiler-rt-sanitizer-ppc64-musl.patch
new file mode 100644
index 00000000000000..3aed07b8569404
--- /dev/null
+++ b/srcpkgs/llvm19/patches/compiler-rt-sanitizer-ppc64-musl.patch
@@ -0,0 +1,37 @@
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+@@ -74,6 +74,10 @@
+ #    include <sys/utsname.h>
+ #  endif
+ 
++#if SANITIZER_LINUX && defined(__powerpc__)
++#include <asm/ptrace.h>
++#endif
++
+ #  if SANITIZER_LINUX && !SANITIZER_ANDROID
+ #    include <sys/personality.h>
+ #  endif
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -94,7 +94,7 @@
+ # include <utime.h>
+ # include <sys/ptrace.h>
+ #    if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
+-        defined(__hexagon__) || defined(__loongarch__) ||SANITIZER_RISCV64
++        defined(__hexagon__) || defined(__powerpc__) || defined(__loongarch__) ||SANITIZER_RISCV64
+ #      include <asm/ptrace.h>
+ #      ifdef __arm__
+ typedef struct user_fpregs elf_fpregset_t;
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+@@ -31,7 +31,7 @@
+ #include <sys/types.h> // for pid_t
+ #include <sys/uio.h> // for iovec
+ #include <elf.h> // for NT_PRSTATUS
+-#if (defined(__aarch64__) || SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
+-     !SANITIZER_ANDROID
++#if (defined(__aarch64__) || defined(__powerpc__) ||SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
++     !SANITIZER_ANDROID
+ // GLIBC 2.20+ sys/user does not include asm/ptrace.h
+ # include <asm/ptrace.h>
+ #endif
diff --git a/srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch b/srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch
new file mode 100644
index 00000000000000..c9b9286ac37b31
--- /dev/null
+++ b/srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch
@@ -0,0 +1,22 @@
+Based on patch from Alpine:
+https://gitlab.alpinelinux.org/alpine/aports/-/blob/693203c42aa1cde88cb547173ef67a98824973fd/main/llvm-runtimes/compiler-rt-sanitizer-supported-arch.patch
+
+Sanitizer code is broken on armhf, armv7, s390x, x86, and probably riscv64 on musl,
+i.e. enable it only on x86_64, aarch64, and ppc64le.
+
+--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
++++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+@@ -23,9 +23,13 @@ if(APPLE)
+   set(X86_64 x86_64 x86_64h)
+ endif()
+ 
++if (LIBCXX_HAS_MUSL_LIBC)
++set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86_64} ${ARM64} ${PPC64})
++else()
+ set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64}
+     ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9}
+     ${HEXAGON} ${LOONGARCH64})
++endif()
+ set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
+     ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
+     ${LOONGARCH64})
diff --git a/srcpkgs/llvm19/patches/libcxx-armv67.patch b/srcpkgs/llvm19/patches/libcxx-armv67.patch
new file mode 100644
index 00000000000000..700ab134790452
--- /dev/null
+++ b/srcpkgs/llvm19/patches/libcxx-armv67.patch
@@ -0,0 +1,35 @@
+See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109180
+Avoid the following undefined reference:
+
+/usr/lib/gcc/armv7l-linux-gnueabihf/12.2.0/../../../../armv7l-linux-gnueabihf/bin/ld: projects/libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o: in function `std::__1::__time_get_c_storage<char>::__x() const [clone .localalias]':
+locale.cpp:(.text._ZNKSt3__120__time_get_c_storageIcE3__xEv+0xb4): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()'
+/usr/lib/gcc/armv7l-linux-gnueabihf/12.2.0/../../../../armv7l-linux-gnueabihf/bin/ld: projects/libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o: in function `std::__1::__time_get_c_storage<char>::__X() const [clone .localalias]':
+
+diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
+index b8ac536588d3..65e5a1365634 100644
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -308,6 +308,8 @@ endif()
+ option(LIBCXX_HERMETIC_STATIC_LIBRARY
+   "Do not export any symbols from the static library." ${LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT})
+ 
++option(LIBCXX_VOID_GCC_BUG_109180_WORKAROUND OFF)
++
+ #===============================================================================
+ # Check option configurations
+ #===============================================================================
+diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
+index 35b466527096..5b0efa171616 100644
+--- a/libcxx/src/CMakeLists.txt
++++ b/libcxx/src/CMakeLists.txt
+@@ -155,6 +155,10 @@ if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
+ endif()
+ add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
+ 
++if (LIBCXX_VOID_GCC_BUG_109180_WORKAROUND)
++  set_source_files_properties(string.cpp PROPERTIES COMPILE_FLAGS -fno-inline)
++endif()
++
+ if (APPLE AND LLVM_USE_SANITIZER)
+   if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
+       ("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
diff --git a/srcpkgs/llvm19/patches/libcxx-musl.patch b/srcpkgs/llvm19/patches/libcxx-musl.patch
new file mode 100644
index 00000000000000..0dd5f0e7eb8a8b
--- /dev/null
+++ b/srcpkgs/llvm19/patches/libcxx-musl.patch
@@ -0,0 +1,26 @@
+--- a/libcxx/include/locale
++++ b/libcxx/include/locale
+@@ -742,7 +742,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
+     __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
+     errno                                                     = 0;
+     char* __p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++    long long __ll = strtoll(__a, &__p2, __base);
++#else
+     long long __ll                                               = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+     __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
+     if (__current_errno == 0)
+       errno = __save_errno;
+@@ -782,7 +786,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
+     __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
+     errno                                                     = 0;
+     char* __p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++        unsigned long long __ll = strtoull(__a, &__p2, __base);
++#else
+     unsigned long long __ll                                      = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+     __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
+     if (__current_errno == 0)
+       errno = __save_errno;
diff --git a/srcpkgs/llvm19/patches/libcxx-ssp-nonshared.patch b/srcpkgs/llvm19/patches/libcxx-ssp-nonshared.patch
new file mode 100644
index 00000000000000..70292beb2fcdbd
--- /dev/null
+++ b/srcpkgs/llvm19/patches/libcxx-ssp-nonshared.patch
@@ -0,0 +1,11 @@
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -769,6 +769,8 @@ function(cxx_link_system_libraries target)
+     target_link_libraries(${target} PRIVATE atomic)
+   endif()
+ 
++#ssp  target_link_libraries(${target} PRIVATE ssp_nonshared)
++
+   if (MINGW)
+     target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}")
+   endif()
diff --git a/srcpkgs/llvm19/patches/libcxxabi-dl.patch b/srcpkgs/llvm19/patches/libcxxabi-dl.patch
new file mode 100644
index 00000000000000..e872d263de30f5
--- /dev/null
+++ b/srcpkgs/llvm19/patches/libcxxabi-dl.patch
@@ -0,0 +1,25 @@
+Also link to -ldl to prevent undefined references.
+
+--- a/libcxxabi/src/CMakeLists.txt
++++ b/libcxxabi/src/CMakeLists.txt
+@@ -73,6 +73,7 @@
+   endif()
+ 
+   add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
++  add_library_flags_if(LIBCXXABI_HAS_C_LIB dl)
+ endif()
+ 
+ if (LIBCXXABI_USE_LLVM_UNWINDER)
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -745,6 +745,10 @@
+     if (LIBCXX_HAS_PTHREAD_LIB)
+       target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB)
+     endif()
++    if (LIBCXX_HAS_C_LIB)
++      target_link_libraries(${target} PRIVATE dl)
++    endif()
++
+     if (LIBCXX_HAS_RT_LIB)
+       target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB)
+     endif()
diff --git a/srcpkgs/llvm19/patches/libomp-soname.patch b/srcpkgs/llvm19/patches/libomp-soname.patch
new file mode 100644
index 00000000000000..9a622cd9254c2e
--- /dev/null
+++ b/srcpkgs/llvm19/patches/libomp-soname.patch
@@ -0,0 +1,12 @@
+diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
+index df1ca9d90..9d2c3b7b9 100644
+--- a/openmp/runtime/src/CMakeLists.txt
++++ b/openmp/runtime/src/CMakeLists.txt
+@@ -150,6 +150,7 @@ libomp_get_libflags(LIBOMP_CONFIGURED_LIBFLAGS)
+ # Build libomp library. Add LLVMSupport dependency if building in-tree with libomptarget profiling enabled.
+ if(OPENMP_STANDALONE_BUILD OR (NOT OPENMP_ENABLE_LIBOMP_PROFILING))
+   add_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES})
++  set_target_properties(omp PROPERTIES VERSION ${LIBOMP_VERSION_MAJOR} SOVERSION ${LIBOMP_VERSION_MAJOR})
+   # Linking command will include libraries in LIBOMP_CONFIGURED_LIBFLAGS
+   target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${LIBOMP_DL_LIBS})
+ else()
diff --git a/srcpkgs/llvm19/patches/llvm-001-musl.patch b/srcpkgs/llvm19/patches/llvm-001-musl.patch
new file mode 100644
index 00000000000000..8652e4af69f7c2
--- /dev/null
+++ b/srcpkgs/llvm19/patches/llvm-001-musl.patch
@@ -0,0 +1,32 @@
+From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe@gmail.com>
+Date: Tue, 8 Sep 2015 22:03:02 +0200
+Subject: [PATCH 3/3] musl
+
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ lib/Support/DynamicLibrary.cpp            | 2 +-
+ lib/Support/Unix/Signals.inc              | 6 +++---
+ utils/unittest/googletest/src/gtest.cc    | 1 +
+ 5 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 34a8a1e3..1214ece5 100644
+--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/PassManager.h"
+ #include "llvm/Pass.h"
+ 
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ template <typename T> class ArrayRef;
+ class Triple;
diff --git a/srcpkgs/llvm19/patches/llvm-004-override-opt.patch b/srcpkgs/llvm19/patches/llvm-004-override-opt.patch
new file mode 100644
index 00000000000000..51d0e4b31b32c3
--- /dev/null
+++ b/srcpkgs/llvm19/patches/llvm-004-override-opt.patch
@@ -0,0 +1,18 @@
+This allows us to override the optimization level as not all platforms can
+deal with -O3.
+
+--- a/llvm/CMakeLists.txt
++++ b/llvm/CMakeLists.txt
+@@ -918,6 +918,12 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+   llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+ endif()
+ 
++set(VOID_CXX_OPT_FLAGS "" CACHE STRING "Optimization level to use")
++
++if (NOT VOID_CXX_OPT_FLAGS STREQUAL "")
++    llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "${VOID_CXX_OPT_FLAGS}")
++endif()
++
+ # Put this before tblgen. Else we have a circular dependence.
+ add_subdirectory(lib/Demangle)
+ add_subdirectory(lib/Support)
diff --git a/srcpkgs/llvm19/patches/llvm-005-ppc-bigpic.patch b/srcpkgs/llvm19/patches/llvm-005-ppc-bigpic.patch
new file mode 100644
index 00000000000000..d332687b9d9295
--- /dev/null
+++ b/srcpkgs/llvm19/patches/llvm-005-ppc-bigpic.patch
@@ -0,0 +1,36 @@
+From f3dbdd49c06bfafc1d6138094cf42889c14d38b6 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 3 Nov 2019 10:57:27 -0600
+Subject: [PATCH] [LLVM][PowerPC] Assume BigPIC if no PIC level is specified
+
+---
+ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp  | 2 +-
+ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
+index cce21f32..87ca5f9b 100644
+--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
++++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+@@ -520,7 +520,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
+ 
+   // Add 32768 offset to the symbol so we follow up the latest GOT/PLT ABI.
+   if (Kind == MCSymbolRefExpr::VK_PLT && Subtarget->isSecurePlt() &&
+-      M->getPICLevel() == PICLevel::BigPIC)
++      M->getPICLevel() != PICLevel::SmallPIC)
+     TlsRef = MCBinaryExpr::createAdd(
+         TlsRef, MCConstantExpr::create(32768, OutContext), OutContext);
+   const MachineOperand &MO = MI->getOperand(2);
+diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp
+index 5cc180d7..a5b02565 100644
+--- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
++++ b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
+@@ -117,7 +117,7 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
+   const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, RefKind, Ctx);
+   // If -msecure-plt -fPIC, add 32768 to symbol.
+   if (Subtarget->isSecurePlt() && TM.isPositionIndependent() &&
+-      M->getPICLevel() == PICLevel::BigPIC &&
++      M->getPICLevel() != PICLevel::SmallPIC &&
+       MO.getTargetFlags() == PPCII::MO_PLT)
+     Expr =
+         MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(32768, Ctx), Ctx);
diff --git a/srcpkgs/llvm19/patches/llvm-006-aarch64-mf_exec.patch b/srcpkgs/llvm19/patches/llvm-006-aarch64-mf_exec.patch
new file mode 100644
index 00000000000000..192b4824b8695c
--- /dev/null
+++ b/srcpkgs/llvm19/patches/llvm-006-aarch64-mf_exec.patch
@@ -0,0 +1,24 @@
+Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
+
+    Failing Tests (8):
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
+        LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
+
+Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
+
+--- a/llvm/lib/Support/Unix/Memory.inc
++++ b/llvm/lib/Support/Unix/Memory.inc
+@@ -58,7 +58,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
+     return PROT_READ | PROT_WRITE | PROT_EXEC;
+   case llvm::sys::Memory::MF_EXEC:
+-#if defined(__FreeBSD__) || defined(__powerpc__)
++#if defined(__FreeBSD__) || defined(__powerpc__) || (defined(__linux__) && defined(__aarch64__))
+     // On PowerPC, having an executable page that has no read permission
+     // can have unintended consequences.  The function InvalidateInstruction-
+     // Cache uses instructions dcbf and icbi, both of which are treated by
diff --git a/srcpkgs/llvm19/patches/mallopt-musl.patch b/srcpkgs/llvm19/patches/mallopt-musl.patch
new file mode 100644
index 00000000000000..6234f22562c756
--- /dev/null
+++ b/srcpkgs/llvm19/patches/mallopt-musl.patch
@@ -0,0 +1,22 @@
+diff --git a/compiler-rt/lib/nsan/nsan_interceptors.cpp b/compiler-rt/lib/nsan/nsan_interceptors.cpp
+index 544b44f53cc4..baa818599411 100644
+--- a/compiler-rt/lib/nsan/nsan_interceptors.cpp
++++ b/compiler-rt/lib/nsan/nsan_interceptors.cpp
+@@ -21,7 +21,7 @@
+ 
+ #include <wchar.h>
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && defined(__GLIBC__)
+ extern "C" int mallopt(int param, int value);
+ #endif
+ 
+@@ -210,7 +210,7 @@ void __nsan::InitializeInterceptors() {
+   CHECK(!initialized);
+ 
+   // Instruct libc malloc to consume less memory.
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && defined(__GLIBC__)
+   mallopt(1, 0);          // M_MXFAST
+   mallopt(-3, 32 * 1024); // M_MMAP_THRESHOLD
+ #endif
diff --git a/srcpkgs/llvm19/patches/openmp-stdint.patch b/srcpkgs/llvm19/patches/openmp-stdint.patch
new file mode 100644
index 00000000000000..57e73521df8690
--- /dev/null
+++ b/srcpkgs/llvm19/patches/openmp-stdint.patch
@@ -0,0 +1,12 @@
+diff --git a/openmp/libomptarget/include/Shared/SourceInfo.h b/openmp/libomptarget/include/Shared/SourceInfo.h
+index 7ce5fd43efc0..c9ff20c59b43 100644
+--- a/openmp/libomptarget/include/Shared/SourceInfo.h
++++ b/openmp/libomptarget/include/Shared/SourceInfo.h
+@@ -14,6 +14,7 @@
+ #define OMPTARGET_SHARED_SOURCE_INFO_H
+ 
+ #include <string>
++#include <stdint.h>
+ 
+ #ifdef _WIN32
+ constexpr bool OSWindows = true;
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
new file mode 100644
index 00000000000000..57b851c8a308c2
--- /dev/null
+++ b/srcpkgs/llvm19/template
@@ -0,0 +1,789 @@
+# Template file for 'llvm19'
+pkgname=llvm19
+version=19.1.0
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+# build_helper=qemu
+_ext_suffix=".cpython-${py3_ver/./}-linux-${XBPS_TARGET_LIBC/glibc/gnu}.so"
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLDB_USE_SYSTEM_SIX=YES
+ -DLIBCXX_CXX_ABI=libcxxabi
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES
+ -DLIBCXXABI_USE_LLVM_UNWINDER=YES
+ -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBOMP_ENABLE_SHARED=YES
+ -DLIBOMP_INSTALL_ALIASES=NO
+ -DLLVM_INCLUDE_DOCS=YES
+ -DLLVM_BUILD_DOCS=YES
+ -DLLVM_ENABLE_SPHINX=YES
+ -DLLVM_ENABLE_Z3_SOLVER=YES
+ -DSPHINX_WARNINGS_AS_ERRORS=NO
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BUILD_LLVM_DYLIB=YES
+ -DLLVM_LINK_LLVM_DYLIB=YES
+ -DCLANG_LINK_CLANG_DYLIB=YES
+ -DCLANG_CONFIG_FILE_SYSTEM_DIR=/etc/clang19
+ -DLLVM_ENABLE_RTTI=YES
+ -DLLVM_ENABLE_FFI=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLDB_PYTHON_RELATIVE_PATH=lib/python${py3_ver}/site-packages
+ -DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver}
+ -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix "
+hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
+ python3-recommonmark python3-sphinx-automodapi git python3-sphinx-markdown-tables python3-yaml pkg-config
+ python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it $(vopt_if graphviz graphviz)"
+makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
+ libxml2-devel binutils-devel z3"
+short_desc="LLVM Compiler Infrastructure Project - Version 19"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0"
+homepage="https://www.llvm.org"
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}-rc1.tar.gz"
+checksum=cd3b42caf8e78c497712a661303672c1a6279eb1a5ff8735488087319ab95214
+conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+
+build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
+ openmp libcxx libunwind lto graphviz"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp libunwind"
+
+if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
+	build_options_default+=" flang bolt"
+fi
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+# build fails because compiler_rt generates armv7 instructions when target is armv6
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) ;;
+	*) configure_args+=" -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+if [ "$build_option_lto" ]; then
+	configure_args+=" -DLLVM_ENABLE_LTO=On"
+fi
+
+subpackages="libllvm19 llvm19-doc llvm19-devel"
+
+# use $(:) to silence xlint
+_enabled_runtimes=$(:)
+
+if [ "$build_option_clang" ]; then
+	_enabled_projects+="clang;"
+	subpackages+=" clang19 clang19-headers clang19-devel libclang19 libclang-cpp19 clang-analyzer19 "
+fi
+if [ "$build_option_clang_tools_extra" ]; then
+	_enabled_projects+="clang-tools-extra;"
+	subpackages+=" clang-tools-extra19 "
+fi
+if [ "$build_option_bolt" ]; then
+	_enabled_projects+="bolt;"
+	subpackages+=" llvm-bolt19 "
+fi
+if [ "$build_option_polly" ]; then
+	_enabled_projects+="polly;"
+fi
+if [ "$build_option_lldb" ]; then
+	_enabled_projects+="lldb;"
+	subpackages+=" lldb19 lldb19-devel liblldb19"
+fi
+if [ "$build_option_lld" ]; then
+	_enabled_projects+="lld;"
+	subpackages+=" lld19 lld19-devel "
+fi
+if [ "$build_option_libclc" ]; then
+	_enabled_projects+="libclc;"
+	subpackages+=" libclc"
+fi
+if [ "$build_option_mlir" ]; then
+	_enabled_projects+="mlir;"
+	subpackages+=" mlir19 mlir19-devel "
+fi
+if [ "$build_option_flang" ]; then
+	_enabled_projects+="flang;"
+	subpackages+=" flang19 flang19-devel "
+fi
+
+subpackages+=" compiler-rt19 "
+_enabled_runtimes="compiler-rt"
+
+if [ "$build_option_openmp" ]; then
+	# openmp fails when built as runtime if cross-compiled
+	if [ "$CROSS_BUILD" ]; then
+		_enabled_projects+="openmp;"
+	else
+		_enabled_runtimes+=";openmp"
+		configure_args+=" OPENMP_ENABLE_LIBOMPTARGET=YES"
+	fi
+	subpackages+=" libomp19 libomp19-devel "
+fi
+
+if [ "$build_option_libunwind" ]; then
+	subpackages+=" llvm-libunwind llvm-libunwind-devel "
+	_enabled_runtimes+=";libunwind"
+fi
+
+if [ "$build_option_libcxx" ]; then
+	subpackages+=" libcxx libcxx-devel libcxxabi libcxxabi-devel "
+	_enabled_runtimes+=";libcxxabi;libcxx"
+fi
+
+
+configure_args+=" -DLLVM_ENABLE_RUNTIMES=${_enabled_runtimes}"
+configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" llvm19-cross-tools"
+fi
+
+# For OCaml bindings and lldb lua scripting
+if [ -z "$CROSS_BUILD" ]; then
+	if [ "$build_option_clang_tools_extra" ] && [ "$build_option_lldb" ] && [ "$build_option_mlir" ]; then
+		subpackages+=" llvm19-cross-tools"
+	fi
+	# OCaml cross build is broken
+	hostmakedepends+=" ocaml ocaml-findlib "
+	# lldb cross build fails with lua
+	makedepends+=" lua53-devel "
+fi
+
+post_patch() {
+	if [ "$build_option_lldb" ]; then
+		if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+			vsed -i 's|__ptrace_request|int|g' \
+				${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+		fi
+		# disable docs for lldb as they fail to generate
+		vsed -i '/add_subdirectory(docs)/d' \
+			${wrksrc}/lldb/CMakeLists.txt
+	fi
+
+	# update config.guess for better platform detection
+	cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
+		${wrksrc}/llvm/cmake
+
+	# fix linker failures on some archs
+	vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
+		${wrksrc}/libcxxabi/cmake/config-ix.cmake
+	vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
+		${wrksrc}/libcxxabi/cmake/config-ix.cmake
+
+	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*) ;;
+		ppc*-musl|i686-musl|mips*-musl)
+			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+				${wrksrc}/libunwind/src/CMakeLists.txt
+			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+				${wrksrc}/libcxxabi/src/CMakeLists.txt
+			vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+			;;
+	esac
+}
+
+pre_configure() {
+	local triplet
+
+	# Vastly reduce size of debugging symbols:
+	CFLAGS=${CFLAGS/ -g/ -g1}
+	CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+
+	# since gcc9, the build likes to blow up for ppc32 apparently because
+	# of clang being too large for a 24-bit relative call to the PLT, so
+	# optimize for size instead
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*) ;;
+		mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
+		armv*) configure_args+=" -DLIBCXX_VOID_GCC_BUG_109180_WORKAROUND=ON ";;
+	esac
+
+	if [ "$CROSS_BUILD" ]; then
+		configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/usr/bin"
+		configure_args+=" -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen"
+		configure_args+=" -DCLANG_TABLEGEN=/usr/bin/clang-tblgen"
+		configure_args+=" -DMLIR_TABLEGEN=/usr/bin/mlir-tblgen"
+		configure_args+=" -DMLIR_PDLL_TABLEGEN=/usr/bin/mlir-pdll"
+		configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/usr/bin/mlir-linalg-ods-yaml-gen"
+		configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/usr/bin/mlir-src-sharder"
+		configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/usr/bin/clang-tidy-confusable-chars-gen"
+		configure_args+=" -DCLANG_PSEUDO_GEN=/usr/bin/clang-pseudo-gen"
+		configure_args+=" -DLLVM_CONFIG_PATH=/usr/bin/llvm-config"
+		configure_args+=" -DLLDB_TABLEGEN_EXE=/usr/bin/lldb-tblgen"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+	arm*-musl|i686-musl)
+		# sanitizer code is broken since it duplicates some libc bits
+		configure_args+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+		;;
+	esac
+
+	case "$XBPS_TARGET_MACHINE" in
+		i686*) _arch="X86";;
+		x86_64*) _arch="X86";;
+		armv5*) _arch="Armv5te";;
+		armv6*) _arch="Armv6";;
+		armv7*) _arch="Armv7";;
+		aarch64*) _arch="AArch64";;
+		mips*) _arch="Mips";;
+		ppc*) _arch="PowerPC";;
+		riscv64*) _arch="RISCV64";;
+	esac
+
+	triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
+
+	configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+	configure_args+=" -DLLVM_HOST_TRIPLE=${triplet}"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${triplet}"
+}
+
+post_build() {
+
+	mkdir -p ${wrksrc}/${build_wrksrc}/runtimes-doc
+	cmake -G Ninja ${wrksrc}/runtimes -B ${wrksrc}/${build_wrksrc}/runtimes-doc \
+		-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+		-DLLVM_ENABLE_SPHINX=ON \
+		-DSPHINX_WARNINGS_AS_ERRORS=OFF
+
+	ninja ${makejobs} -C ${wrksrc}/${build_wrksrc}/runtimes-doc docs-libcxx-html docs-libunwind-html
+
+}
+
+post_install() {
+
+	# Required for multilib.
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+		for _header in llvm-config; do
+			mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
+			vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
+				usr/include/llvm/Config ${_header}.h
+		done
+	fi
+
+	# Remove llvm-config-host in cross builds.
+	if [ "$CROSS_BUILD" ]; then
+		rm -f ${DESTDIR}/usr/bin/llvm-config-host
+	fi
+
+	rm -rf ${DESTDIR}/usr/share/gdb
+
+	if [ "$build_option_libcxx" ]; then
+		# Install libcxxabi headers
+		vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
+		vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
+
+		cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr \
+			-P ${wrksrc}/${build_wrksrc}/runtimes-doc/libcxx/docs/cmake_install.cmake
+
+		LIBCXX_DOCS=usr/share/doc/LLVM/libcxx
+		vmkdir ${LIBCXX_DOCS}
+		vcopy ${wrksrc}/${build_wrksrc}/runtimes-doc/libcxx/docs/html ${LIBCXX_DOCS}
+	fi
+
+	if [ "$build_option_libunwind" ]; then
+		# Install libunwind headers
+		vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
+		vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
+		vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
+		vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
+			644 usr/include/mach-o
+
+		cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr \
+			-P ${wrksrc}/${build_wrksrc}/runtimes-doc/libunwind/docs/cmake_install.cmake
+
+		LIBUNWIND_DOCS=usr/share/doc/LLVM/libunwind
+		vmkdir ${LIBUNWIND_DOCS}
+		vcopy ${wrksrc}/${build_wrksrc}/runtimes-doc/libunwind/docs/html ${LIBUNWIND_DOCS}
+	fi
+
+	# Can this be disabled some other way?
+	rm -f ${DESTDIR}/usr/lib64
+}
+
+clang19_package() {
+	lib32disabled=yes
+	depends="libstdc++-devel libgcc-devel  binutils ${XBPS_TARGET_LIBC}-devel
+	 compiler-rt19"
+	conflicts="clang18>=0 clang17>=0 clang15>=0"
+	short_desc+=" - C language family frontend"
+	homepage="https://clang.llvm.org/"
+	pkg_install() {
+		vmove usr/bin/clang-19
+		vmove usr/bin/clang
+		vmove usr/bin/clang++
+		vmove usr/bin/clang-cl
+		vmove usr/bin/clang-cpp
+		vmove usr/bin/clang-check
+		vmove usr/bin/clang-extdef-mapping
+		vmove usr/bin/clang-format
+		vmove usr/bin/git-clang-format
+		vmove usr/bin/clang-linker-wrapper
+		vmove usr/bin/clang-offload-bundler
+		vmove usr/bin/clang-offload-packager
+		vmove usr/bin/clang-refactor
+		vmove usr/bin/clang-rename
+		vmove usr/bin/clang-repl
+		vmove usr/bin/clang-scan-deps
+		vmove usr/bin/clang-tblgen
+		vmove usr/bin/c-index-test
+		vmove usr/bin/diagtool
+		vmove usr/bin/amdgpu-arch
+		vmove usr/bin/nvptx-arch
+		vmove usr/bin/hmaptool
+
+		vmove usr/share/man/man1/clang.1
+		vmove usr/share/man/man1/diagtool.1
+		if [ "$build_option_polly" ]; then
+			vmove usr/lib/LLVMPolly.so
+			vmove usr/share/man/man1/polly.1
+		fi
+	}
+}
+
+clang19-headers_package() {
+	lib32disabled=yes
+	short_desc+=" - C language family frontend - Headers"
+	homepage="https://clang.llvm.org/"
+	pkg_install() {
+		vmove usr/lib/clang/19/include
+	}
+}
+
+clang19-devel_package() {
+	lib32disabled=yes
+	depends="libstdc++-devel libgcc-devel  binutils ${XBPS_TARGET_LIBC}-devel
+	 clang19>=${version}_${revision} clang-analyzer19>=${version}_${revision}
+	 llvm19>=${version}_${revision}"
+	conflicts="clang18-devel clang17-devel clang15-devel"
+	if [ "$build_option_clang_tools_extra" ]; then
+		depends+=" clang-tools-extra19>=${version}_${revision}"
+	fi
+	short_desc+=" - C language family frontend - development Files"
+	homepage="https://clang.llvm.org/"
+	pkg_install() {
+		vmove usr/include/clang
+		vmove usr/include/clang-c
+		vmove usr/lib/libear
+		vmove usr/lib/cmake/clang
+		vmove "usr/lib/libclang*.a"
+		vmove "usr/lib/libclang*.so"
+		vmove usr/share/clang
+		if [ "$build_option_clang_tools_extra" ]; then
+			vmove usr/include/clang-tidy
+			vmove usr/lib/libfindAllSymbols.a
+		fi
+		if [ "$build_option_polly" ]; then
+			vmove usr/include/polly
+			vmove usr/lib/cmake/polly
+			vmove "usr/lib/libPolly*.a"
+		fi
+	}
+}
+
+libclang19_package() {
+	depends="clang19-headers>=${version}_${revision}"
+	short_desc+=" - C frontend library"
+	#TODO remove shlib_provides
+	shlib_provides="libclang.so.19.1-rc1"
+	pkg_install() {
+		vmove "usr/lib/libclang.so.*"
+	}
+}
+
+libclang-cpp19_package() {
+	depends="clang19-headers>=${version}_${revision}"
+	short_desc+=" - C frontend library (C++ interface)"
+	pkg_install() {
+		vmove "usr/lib/libclang-cpp.so.*"
+	}
+}
+
+clang-analyzer19_package() {
+	depends="clang19>=${version}_${revision} python3 perl"
+	conflicts="clang-analyzer18>=0 clang-analyzer17>=0 clang-analyzer15>=0"
+	short_desc+=" - A source code analysis framework"
+	homepage="https://clang-analyzer.llvm.org/"
+	pycompile_dirs="usr/share/scan-view"
+	pkg_install() {
+		vmove usr/share/scan-view
+		vmove usr/share/scan-build
+		vmove usr/lib/libscanbuild
+		vmove usr/libexec/analyze-c++
+		vmove usr/libexec/analyze-cc
+		vmove usr/libexec/intercept-c++
+		vmove usr/libexec/intercept-cc
+		vmove usr/libexec/c++-analyzer
+		vmove usr/libexec/ccc-analyzer
+		vmove usr/share/man/man1/scan-build.1
+		vmove usr/bin/analyze-build
+		vmove usr/bin/scan-build
+		vmove usr/bin/scan-build-py
+		vmove usr/bin/scan-view
+	}
+}
+
+clang-tools-extra19_package() {
+	lib32disabled=yes
+	depends="clang19>=${version}_${revision} python3"
+	conflicts="clang-tools-extra18>=0 clang-tools-extra17>=0 clang-tools-extra15>=0"
+	short_desc+=" - Extra Clang tools"
+	homepage="https://clang.llvm.org/extra/"
+	pkg_install() {
+		vmove usr/bin/clang-apply-replacements
+		vmove usr/bin/clang-change-namespace
+		vmove usr/bin/clang-doc
+		vmove usr/bin/clang-include-cleaner
+		vmove usr/bin/clang-include-fixer
+		vmove usr/bin/clang-move
+		vmove usr/bin/clang-pseudo
+		vmove usr/bin/clang-query
+		vmove usr/bin/clang-reorder-fields
+		vmove usr/bin/clang-tidy
+		vmove usr/bin/clangd
+		vmove usr/bin/find-all-symbols
+		vmove usr/bin/modularize
+		vmove usr/bin/pp-trace
+		vmove usr/bin/run-clang-tidy
+		vmove usr/share/man/man1/extraclangtools.1
+	}
+}
+
+# "bolt" package name is already used
+llvm-bolt19_package() {
+	lib32disabled=yes
+	depends="clang19>=${version}_${revision}"
+	conflicts="llvm-bolt18>=0 llvm-bolt17>=0"
+	short_desc+=" - post-link optimizer"
+	homepage="https://github.com/llvm/llvm-project/tree/main/bolt"
+	pkg_install() {
+		vmove usr/bin/llvm-bolt
+		vmove usr/bin/perf2bolt
+		vmove usr/bin/llvm-boltdiff
+		vmove usr/bin/merge-fdata
+		vmove usr/bin/llvm-bolt-heatmap
+		if [ -z "$CROSS_BUILD" ]; then
+			case "$XBPS_TARGET_MACHINE" in
+				x86_64*|aarch64*)
+					vmove usr/lib/libbolt_rt_instr.a
+					vmove usr/lib/libbolt_rt_hugify.a
+				;;
+			esac
+		fi
+	}
+}
+
+lldb19_package() {
+	lib32disabled=yes
+	depends+=" python3-six"
+	conflicts="lldb18>=0 lldb17>=0 lldb15>=0"
+	short_desc+=" - LLDB debugger"
+	homepage="https://lldb.llvm.org/"
+	pkg_install() {
+		vmove usr/bin/lldb
+		vmove usr/bin/lldb-argdumper
+		vmove usr/bin/lldb-instr
+		vmove usr/bin/lldb-server
+		vmove usr/bin/lldb-dap
+		vmove "usr/lib/python${py3_ver}/site-packages/lldb"
+		if [ -z "$CROSS_BUILD" ]; then
+			vmove /usr/lib/lua/5.3/lldb.so
+		fi
+	}
+}
+
+lldb19-devel_package() {
+	lib32disabled=yes
+	depends="lldb19>=${version}_${revision}"
+	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
+	short_desc+=" - LLDB debugger - development files"
+	pkg_install() {
+		vmove usr/include/lldb
+		vmove "usr/lib/liblldb*.so"
+	}
+}
+
+liblldb19_package() {
+	lib32disabled=yes
+	short_desc+=" - LLDB debugger - runtime library"
+	#TODO remove shlib_provides
+	shlib_provides="liblldb.so.19.1-rc1"
+	pkg_install() {
+		vmove "usr/lib/liblldb*.so.*"
+	}
+}
+
+lld19_package() {
+	lib32disabled=yes
+	conflicts="lld18>=0 lld17>=0 lld15>=0"
+	short_desc+=" - linker"
+	homepage="https://lld.llvm.org"
+	pkg_install() {
+		vmove usr/bin/lld
+		vmove usr/bin/lld-link
+		vmove usr/bin/ld.lld
+		vmove usr/bin/ld64.lld
+		vmove usr/bin/wasm-ld
+	}
+}
+
+lld19-devel_package() {
+	lib32disabled=yes
+	depends="lld19>=${version}_${revision} llvm19>=${version}_${revision}"
+	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
+	short_desc+=" - linker - development files"
+	homepage="https://lld.llvm.org"
+	pkg_install() {
+		vmove usr/include/lld
+		vmove usr/lib/cmake/lld
+		vmove "usr/lib/liblld*.a"
+	}
+}
+
+mlir19_package() {
+	lib32disabled=yes
+	short_desc+=" - multi-level IR compiler framework"
+	homepage="https://mlir.llvm.org/"
+	pkg_install() {
+		vmove "usr/lib/libMLIR*.so.*"
+		vmove "usr/lib/libmlir*.so.*"
+	}
+}
+
+mlir19-devel_package() {
+	lib32disabled=yes
+	depends="mlir19>=${version}_${revision} llvm19>=${version}_${revision}"
+	conflicts="mlir18-devel>=0 mlir17-devel>=0"
+	short_desc+=" - multi-level IR compiler framework - development files"
+	homepage="https://mlir.llvm.org/"
+	pkg_install() {
+		vmove "usr/bin/mlir*"
+		vmove usr/bin/tblgen-lsp-server
+		vmove usr/include/mlir
+		vmove usr/include/mlir-c
+		vmove usr/lib/cmake/mlir
+		vmove "usr/lib/libMLIR*"
+		vmove "usr/lib/objects-Release/obj.MLIR*"
+		vmove "usr/lib/libmlir*"
+		vmove usr/share/man/man1/mlir-tblgen.1
+	}
+}
+
+flang19_package() {
+	lib32disabled=yes
+	depends="mlir19>=${version}_${revision}"
+	conflicts="flang18>=0 flang17>=0"
+	short_desc+=" - Fortran language frontend"
+	homepage="https://flang.llvm.org/"
+	pkg_install() {
+		vmove usr/bin/flang-new
+	}
+}
+
+flang19-devel_package() {
+	lib32disabled=yes
+	depends="flang19>=${version}_${revision} llvm19>=${version}_${revision}"
+	conflicts="flang18-devel>=0 flang17-devel>=0"
+	short_desc+=" - Fortran language frontend - development files"
+	homepage="https://flang.llvm.org/"
+	pkg_install() {
+		vmove usr/bin/bbc
+		vmove usr/bin/f18-parse-demo
+		vmove usr/bin/fir-opt
+		vmove usr/bin/tco
+		vmove usr/include/flang
+		vmove usr/lib/cmake/flang
+		vmove "usr/lib/libflang*.a"
+		vmove "usr/lib/libFIR*.a"
+		vmove "usr/lib/libHLFIR*.a"
+		vmove "usr/lib/libFortran*.a"
+		vmove "usr/lib/libCUF*.a"
+	}
+}
+
+libomp19_package() {
+	short_desc+=" - Clang OpenMP support library"
+	conflicts="libomp18>=0 libomp17>=0"
+	pkg_install() {
+		vmove "usr/lib/libomp*.so"
+	}
+}
+
+libomp19-devel_package() {
+	short_desc+=" - Clang OpenMP support library - development files"
+	depends="libomp19>=${version}_${revision}"
+	conflicts="libomp18-devel>=0 libomp17-devel>=0"
+	pkg_install() {
+		if [ -f "${DESTDIR}/usr/bin/llvm-omp-device-info" ]; then
+			vmove usr/bin/llvm-omp-device-info
+		fi
+		if [ -f "${DESTDIR}/usr/bin/llvm-omp-kernel-replay" ]; then
+			vmove usr/bin/llvm-omp-kernel-replay
+		fi
+		if [ -f "${DESTDIR}/usr/lib/libarcher.so" ]; then
+			vmove "usr/lib/libarcher*.so"
+		fi
+		if [ -f "${DESTDIR}/usr/lib/libarcher_static.a" ]; then
+			vmove "usr/lib/libarcher*.a"
+		fi
+
+		vmove usr/lib/cmake/openmp
+		if [ -f "${DESTDIR}/usr/share/man/man1/llvmopenmp.1" ]; then
+			vmove usr/share/man/man1/llvmopenmp.1
+		fi
+
+		if [ -z "$CROSS_BUILD" ]; then
+			case "$XBPS_TARGET_MACHINE" in
+				x86_64*|aarch64*)
+					# TODO: Fix libomp
+					# vmove "usr/lib/libomptarget*.bc"
+					# vmove "usr/lib/libomp*.a"
+				;;
+			esac
+		fi
+	}
+}
+
+llvm-libunwind_package() {
+	short_desc+=" - libunwind"
+	pkg_install() {
+		vmove "usr/lib/libunwind.so.*"
+	}
+}
+
+llvm-libunwind-devel_package() {
+	short_desc+=" - libunwind - development files"
+	depends="llvm-libunwind>=${version}_${revision}"
+	conflicts="libunwind-devel>=0"
+	pkg_install() {
+		vmove usr/include/mach-o
+		vmove "usr/include/*unwind*"
+		vmove "usr/lib/libunwind.a"
+		vmove "usr/lib/libunwind.so"
+	}
+}
+
+libcxxabi_package() {
+	short_desc+=" - low level support for libc++"
+	pkg_install() {
+		vmove "usr/lib/libc++abi.so.*"
+	}
+}
+
+libcxxabi-devel_package() {
+	short_desc+=" - low level support for libc++ - development files"
+	depends="libcxxabi>=${version}_${revision}"
+	pkg_install() {
+		vmove "usr/include/*cxxabi*"
+		vmove "usr/lib/libc++abi.so"
+		vmove "usr/lib/libc++abi.a"
+	}
+}
+
+libcxx_package() {
+	short_desc+=" - C++ standard library"
+	pkg_install() {
+		vmove "usr/lib/libc++.so.*"
+	}
+}
+
+libcxx-devel_package() {
+	short_desc+=" - C++ standard library - development files"
+	depends="libcxx>=${version}_${revision}"
+	pkg_install() {
+		vmove usr/include/c++
+		vmove usr/share/libc++
+		vmove "usr/lib/libc++.so"
+		vmove "usr/lib/libc++.a"
+		vmove "usr/lib/libc++experimental.a"
+	}
+}
+
+compiler-rt19_package() {
+	short_desc+=" - runtime libraries"
+	homepage="https://compiler-rt.llvm.org/"
+	pkg_install() {
+		vmove usr/lib/clang/19/lib
+		if [ -d "${DESTDIR}/usr/lib/clang/19/bin" ]; then
+			vmove usr/lib/clang/19/bin
+		fi
+		if [ -d "${DESTDIR}/usr/lib/clang/19/share" ]; then
+			vmove usr/lib/clang/19/share
+		fi
+	}
+}
+
+libllvm19_package() {
+	short_desc+=" - library"
+	pkg_install() {
+		vmove "usr/lib/libLLVM-*.so"
+		vmove "usr/lib/libLLVM.so.*"
+	}
+}
+
+llvm19-doc_package() {
+	short_desc+=" - documentation"
+	pkg_install() {
+		vmove usr/share/doc
+	}
+}
+
+llvm19-devel_package() {
+	depends="llvm19>=${version}_${revision}"
+	conflicts="llvm18-devel>=0 llvm17-devel>=0 llvm15-devel>=0"
+	short_desc+=" - development files"
+	if [ "$build_option_openmp" ]; then
+		depends+=" libomp19-devel>=${version}_${revision} "
+	fi
+	if [ "$build_option_mlir" ]; then
+		depends+=" mlir19-devel>=${version}_${revision} "
+	fi
+	if [ "$build_option_clang" ]; then
+		depends+=" clang19-devel>=${version}_${revision} "
+	fi
+	pkg_install() {
+		vmove usr/lib/libLLVM.so
+		vmove usr/lib/libLTO.so
+		vmove usr/lib/libRemarks.so
+		vmove usr/include/llvm
+		vmove usr/include/llvm-c
+		vmove "usr/lib/libLLVM*.a"
+		vmove usr/lib/cmake/llvm
+	}
+}
+
+# These binaries are ONLY used when building llvm, they aren't normally installed
+llvm19-cross-tools_package() {
+	conflicts="llvm18-cross-tools>=0 llvm17-cross-tools>=0"
+	short_desc+=" - build tools for cross compiling LLVM"
+	depends="lldb19-devel>=${version}_${revision} llvm19-devel>=${version}_${revision}"
+	pkg_install() {
+		# Binaries ONLY used during the process of building llvm, and aren't usually installed
+		vbin build/bin/lldb-tblgen
+		vbin build/bin/clang-tidy-confusable-chars-gen
+		vbin build/bin/clang-pseudo-gen
+		vbin build/bin/mlir-src-sharder
+	}
+}
+
+libclc_package() {
+	short_desc+=" - Open implementation of the OpenCL C programming language"
+	replaces="libclc-git>=0"
+	pkg_install() {
+		vmove usr/share/clc
+		vmove usr/include/clc
+		vmove usr/share/pkgconfig/libclc.pc
+	}
+}
diff --git a/srcpkgs/llvm19/update b/srcpkgs/llvm19/update
new file mode 100644
index 00000000000000..46844c65620f4c
--- /dev/null
+++ b/srcpkgs/llvm19/update
@@ -0,0 +1,3 @@
+site="https://github.com/llvm/llvm-project/releases"
+pattern="llvmorg-\K(18)\.(\d+)\.+\d+(-rc\d+)?"
+ignore="*-rc*"
diff --git a/srcpkgs/mlir19 b/srcpkgs/mlir19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/mlir19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/mlir19-devel b/srcpkgs/mlir19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/mlir19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file

From 0711917adfae35a9527502e48e7473a4cdc37518 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Mon, 29 Jul 2024 09:18:45 -0400
Subject: [PATCH 02/19] llvm19: fixup remove PPC Musl patches

---
 .../patches/clang-002-add-musl-triples.patch  | 115 ------------------
 1 file changed, 115 deletions(-)
 delete mode 100644 srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch

diff --git a/srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch b/srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch
deleted file mode 100644
index 0ef4c7e75d6b58..00000000000000
--- a/srcpkgs/llvm19/patches/clang-002-add-musl-triples.patch
+++ /dev/null
@@ -1,115 +0,0 @@
---- a/clang/lib/Driver/ToolChains/Gnu.cpp
-+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
-@@ -2086,7 +2086,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
-   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
-                                              "armv7hl-redhat-linux-gnueabi",
-                                              "armv6hl-suse-linux-gnueabi",
--                                             "armv7hl-suse-linux-gnueabi"};
-+                                             "armv7hl-suse-linux-gnueabi",
-+                                             "armv7l-linux-gnueabihf"};
-   static const char *const ARMebLibDirs[] = {"/lib"};
-   static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
-                                              "armeb-linux-androideabi"};
-@@ -2153,8 +2154,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
-       "powerpc64-suse-linux", "powerpc-montavista-linuxspe"};
-   static const char *const PPCLELibDirs[] = {"/lib32", "/lib"};
-   static const char *const PPCLETriples[] = {"powerpcle-linux-gnu",
--                                             "powerpcle-unknown-linux-gnu",
--                                             "powerpcle-linux-musl"};
-+                                             "powerpcle-unknown-linux-gnu"};
- 
-   static const char *const PPC64LibDirs[] = {"/lib64", "/lib"};
-   static const char *const PPC64Triples[] = {
-@@ -2235,6 +2235,92 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
-     return;
-   }
- 
-+  if (TargetTriple.isMusl()) {
-+    static const char *const AArch64MuslTriples[] = {"aarch64-linux-musl"};
-+    static const char *const ARMHFMuslTriples[] = {
-+        "arm-linux-musleabihf", "armv7l-linux-musleabihf"
-+    };
-+    static const char *const ARMMuslTriples[] = {"arm-linux-musleabi"};
-+    static const char *const X86_64MuslTriples[] = {"x86_64-linux-musl"};
-+    static const char *const X86MuslTriples[] = {"i686-linux-musl"};
-+    static const char *const MIPSMuslTriples[] = {
-+        "mips-linux-musl", "mipsel-linux-musl",
-+        "mipsel-linux-muslhf", "mips-linux-muslhf"
-+    };
-+    static const char *const PPCMuslTriples[] = {"powerpc-linux-musl"};
-+    static const char *const PPCLEMuslTriples[] = {"powerpcle-linux-musl"};
-+    static const char *const PPC64MuslTriples[] = {"powerpc64-linux-musl"};
-+    static const char *const PPC64LEMuslTriples[] = {"powerpc64le-linux-musl"};
-+    static const char *const RISCV64MuslTriples[] = {"riscv64-linux-musl"};
-+
-+    switch (TargetTriple.getArch()) {
-+    case llvm::Triple::aarch64:
-+      LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
-+      TripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
-+      BiarchLibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
-+      BiarchTripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
-+      break;
-+    case llvm::Triple::arm:
-+      LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
-+      if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
-+        TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples));
-+      } else {
-+        TripleAliases.append(begin(ARMMuslTriples), end(ARMMuslTriples));
-+      }
-+      break;
-+    case llvm::Triple::x86_64:
-+      LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
-+      TripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
-+      BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
-+      BiarchTripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
-+      break;
-+    case llvm::Triple::x86:
-+      LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
-+      TripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
-+      BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
-+      BiarchTripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
-+      break;
-+    case llvm::Triple::mips:
-+      LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
-+      TripleAliases.append(begin(MIPSMuslTriples), end(MIPSMuslTriples));
-+      break;
-+    case llvm::Triple::ppc:
-+      LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
-+      TripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
-+      BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
-+      BiarchTripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
-+      break;
-+    case llvm::Triple::ppcle:
-+      LibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs));
-+      TripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples));
-+      BiarchLibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
-+      BiarchTripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples));
-+      break;
-+    case llvm::Triple::ppc64:
-+      LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
-+      TripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
-+      BiarchLibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
-+      BiarchTripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
-+      break;
-+    case llvm::Triple::ppc64le:
-+      LibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
-+      TripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples));
-+      BiarchLibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs));
-+      BiarchTripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples));
-+      break;
-+    case llvm::Triple::riscv64:
-+      LibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
-+      TripleAliases.append(begin(RISCV64MuslTriples), end(RISCV64MuslTriples));
-+      break;
-+    default:
-+      break;
-+    }
-+    TripleAliases.push_back(TargetTriple.str());
-+    if (TargetTriple.str() != BiarchTriple.str())
-+      BiarchTripleAliases.push_back(BiarchTriple.str());
-+    return;
-+  }
-+
-   // Android targets should not use GNU/Linux tools or libraries.
-   if (TargetTriple.isAndroid()) {
-     static const char *const AArch64AndroidTriples[] = {

From 5107d3d0f27cb4631cb2fc18d367af40e523f1d7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Mon, 29 Jul 2024 09:20:59 -0400
Subject: [PATCH 03/19] llvm19: fixup remove libomp-soname.patch

---
 srcpkgs/llvm19/patches/libomp-soname.patch | 12 ------------
 1 file changed, 12 deletions(-)
 delete mode 100644 srcpkgs/llvm19/patches/libomp-soname.patch

diff --git a/srcpkgs/llvm19/patches/libomp-soname.patch b/srcpkgs/llvm19/patches/libomp-soname.patch
deleted file mode 100644
index 9a622cd9254c2e..00000000000000
--- a/srcpkgs/llvm19/patches/libomp-soname.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
-index df1ca9d90..9d2c3b7b9 100644
---- a/openmp/runtime/src/CMakeLists.txt
-+++ b/openmp/runtime/src/CMakeLists.txt
-@@ -150,6 +150,7 @@ libomp_get_libflags(LIBOMP_CONFIGURED_LIBFLAGS)
- # Build libomp library. Add LLVMSupport dependency if building in-tree with libomptarget profiling enabled.
- if(OPENMP_STANDALONE_BUILD OR (NOT OPENMP_ENABLE_LIBOMP_PROFILING))
-   add_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES})
-+  set_target_properties(omp PROPERTIES VERSION ${LIBOMP_VERSION_MAJOR} SOVERSION ${LIBOMP_VERSION_MAJOR})
-   # Linking command will include libraries in LIBOMP_CONFIGURED_LIBFLAGS
-   target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${LIBOMP_DL_LIBS})
- else()

From 0139147e062da65e932263cd1d6a1cc35cd1f85d Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Mon, 29 Jul 2024 09:23:52 -0400
Subject: [PATCH 04/19] llvm19: fixup remove openmp-stdint.patch

---
 srcpkgs/llvm19/patches/openmp-stdint.patch | 12 ------------
 1 file changed, 12 deletions(-)
 delete mode 100644 srcpkgs/llvm19/patches/openmp-stdint.patch

diff --git a/srcpkgs/llvm19/patches/openmp-stdint.patch b/srcpkgs/llvm19/patches/openmp-stdint.patch
deleted file mode 100644
index 57e73521df8690..00000000000000
--- a/srcpkgs/llvm19/patches/openmp-stdint.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/openmp/libomptarget/include/Shared/SourceInfo.h b/openmp/libomptarget/include/Shared/SourceInfo.h
-index 7ce5fd43efc0..c9ff20c59b43 100644
---- a/openmp/libomptarget/include/Shared/SourceInfo.h
-+++ b/openmp/libomptarget/include/Shared/SourceInfo.h
-@@ -14,6 +14,7 @@
- #define OMPTARGET_SHARED_SOURCE_INFO_H
- 
- #include <string>
-+#include <stdint.h>
- 
- #ifdef _WIN32
- constexpr bool OSWindows = true;

From 706301e94556c3d2d842c5e8c9ad33121ec8dbcd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Tue, 30 Jul 2024 09:18:53 -0400
Subject: [PATCH 05/19] llvm18: use for libcxx and libcxxabi

---
 srcpkgs/llvm18/template | 57 ++++++++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index 1311ecf6fc60b9..c72b16151ae53a 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -47,8 +47,9 @@ conflicts="llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt openmp lto graphviz"
-build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
+build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
+ openmp libcxx libunwind lto graphviz"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp libcxx"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"
@@ -128,13 +129,14 @@ if [ "$build_option_openmp" ]; then
 fi
 
 # enable if runtime subpackages link to this version of llvm
-if true; then
+if [ "$build_option_libunwind" ]; then
 	subpackages+=" llvm-libunwind llvm-libunwind-devel "
 	_enabled_runtimes+=";libunwind"
+fi
 
+if [ "$build_option_libcxx" ]; then
 	subpackages+=" libcxx libcxx-devel libcxxabi libcxxabi-devel "
 	_enabled_runtimes+=";libcxxabi;libcxx"
-
 fi
 
 configure_args+=" -DLLVM_ENABLE_RUNTIMES=${_enabled_runtimes}"
@@ -281,31 +283,38 @@ post_install() {
 
 	rm -rf ${DESTDIR}/usr/share/gdb
 
-	# Install libcxxabi headers
-	vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
-	vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
+	if [ "$build_option_libcxx" ]; then
+		# Install libcxxabi headers
+		vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
+		vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
 
-	# Install libunwind headers
-	vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
-	vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
-	vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
-	vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
-		644 usr/include/mach-o
+		cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr \
+			-P ${wrksrc}/${build_wrksrc}/runtimes-doc/libcxx/docs/cmake_install.cmake
 
-	# Install libcxx and libunwind docs
-	cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P ${wrksrc}/${build_wrksrc}/runtimes-doc/libcxx/docs/cmake_install.cmake
-	cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P ${wrksrc}/${build_wrksrc}/runtimes-doc/libunwind/docs/cmake_install.cmake
+		LIBCXX_DOCS=usr/share/doc/LLVM/libcxx
+		vmkdir ${LIBCXX_DOCS}
+		vcopy ${wrksrc}/${build_wrksrc}/runtimes-doc/libcxx/docs/html ${LIBCXX_DOCS}
+	fi
 
-	# Can this be disabled some other way?
-	rm -rf ${DESTDIR}/usr/lib64
 
-	LIBCXX_DOCS=usr/share/doc/LLVM/libcxx
-	vmkdir ${LIBCXX_DOCS}
-	vcopy ${wrksrc}/${build_wrksrc}/runtimes-doc/libcxx/docs/html ${LIBCXX_DOCS}
+	if [ "$build_option_libunwind" ]; then
+		# Install libunwind headers
+		vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
+		vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
+		vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
+		vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
+			644 usr/include/mach-o
 
-	LIBUNWIND_DOCS=usr/share/doc/LLVM/libunwind
-	vmkdir ${LIBUNWIND_DOCS}
-	vcopy ${wrksrc}/${build_wrksrc}/runtimes-doc/libunwind/docs/html ${LIBUNWIND_DOCS}
+		cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr \
+			-P ${wrksrc}/${build_wrksrc}/runtimes-doc/libunwind/docs/cmake_install.cmake
+
+		LIBUNWIND_DOCS=usr/share/doc/LLVM/libunwind
+		vmkdir ${LIBUNWIND_DOCS}
+		vcopy ${wrksrc}/${build_wrksrc}/runtimes-doc/libunwind/docs/html ${LIBUNWIND_DOCS}
+	fi
+
+	# Can this be disabled some other way?
+	rm -rf ${DESTDIR}/usr/lib64
 }
 
 clang18_package() {

From 6b97eb1137f03bed9be046e7a7168767a672ca6e Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Tue, 30 Jul 2024 23:42:10 -0400
Subject: [PATCH 06/19] llvm19: fixup

---
 srcpkgs/llvm19/template | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 57b851c8a308c2..29b2cc23027dff 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -124,6 +124,7 @@ if [ "$build_option_openmp" ]; then
 	# openmp fails when built as runtime if cross-compiled
 	if [ "$CROSS_BUILD" ]; then
 		_enabled_projects+="openmp;"
+		#TODO? _enabled_runtimes+=";openmp"
 	else
 		_enabled_runtimes+=";openmp"
 		configure_args+=" OPENMP_ENABLE_LIBOMPTARGET=YES"
@@ -147,6 +148,17 @@ configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" llvm19-cross-tools"
+
+	#TODO?
+	# CC="clang"
+	# CXX="clang++"
+	# LD="lld"
+	# CFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
+	# CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
+	# LDFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
+	# configure_args+=" -DLLVM_USE_LINKER=lld"
+	# configure_args+=" -DCMAKE_C_COMPILER=clang"
+	# configure_args+=" -DCMAKE_CXX_COMPILER=clang++"
 fi
 
 # For OCaml bindings and lldb lua scripting
@@ -768,7 +780,8 @@ llvm19-devel_package() {
 llvm19-cross-tools_package() {
 	conflicts="llvm18-cross-tools>=0 llvm17-cross-tools>=0"
 	short_desc+=" - build tools for cross compiling LLVM"
-	depends="lldb19-devel>=${version}_${revision} llvm19-devel>=${version}_${revision}"
+	depends="lldb19-devel>=${version}_${revision} llvm19-devel>=${version}_${revision}
+	 lld19-devel>=${version}_${revision}"
 	pkg_install() {
 		# Binaries ONLY used during the process of building llvm, and aren't usually installed
 		vbin build/bin/lldb-tblgen

From 15892bc27a67dd8b7c39f0c51d12cbbabf268ff1 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Wed, 31 Jul 2024 07:54:44 -0400
Subject: [PATCH 07/19] llvm19: fixup version suffix

---
 common/shlibs                               |  8 ++++----
 srcpkgs/llvm19/patches/version-suffix.patch | 12 ++++++++++++
 srcpkgs/llvm19/template                     |  4 ++--
 3 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/llvm19/patches/version-suffix.patch

diff --git a/common/shlibs b/common/shlibs
index fcc4654a5df84c..cd1743292aa8f8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -988,18 +988,18 @@ libuchardet.so.0 uchardet-0.0.6_1
 libgtksourceviewmm-3.0.so.0 gtksourceviewmm-3.2.0_1
 libyajl.so.2 yajl-2.0.1_1
 libconfuse.so.2 confuse-3.2.1_1
-liblldb.so.19.1-rc1 liblldb19-19.1.0_1
+liblldb.so.19.1 liblldb19-19.1.0_1
 liblldb.so.18.1 liblldb18-18.1.8_1
 liblldb.so.17 liblldb17-17.0.6_3
-libclang.so.19.1-rc1 libclang19-19.1.0_1
+libclang.so.19.1 libclang19-19.1.0_1
 libclang.so.18.1 libclang18-18.1.8_1
 libclang.so.17 libclang17-17.0.6_1
-libclang-cpp.so.19.1-rc1 libclang-cpp19-19.1.0_1
+libclang-cpp.so.19.1 libclang-cpp19-19.1.0_1
 libclang-cpp.so.18.1 libclang-cpp18-18.1.8_1
 libclang-cpp.so.17 libclang-cpp17-17.0.6_1
 libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
-libLLVM.so.19.1-rc1 libllvm19-19.1.0_1
+libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
diff --git a/srcpkgs/llvm19/patches/version-suffix.patch b/srcpkgs/llvm19/patches/version-suffix.patch
new file mode 100644
index 00000000000000..8600b2a19151aa
--- /dev/null
+++ b/srcpkgs/llvm19/patches/version-suffix.patch
@@ -0,0 +1,12 @@
+diff --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake
+index 897dd963bd9a..fe053cc99ff2 100644
+--- a/cmake/Modules/LLVMVersion.cmake
++++ b/cmake/Modules/LLVMVersion.cmake
+@@ -10,6 +10,6 @@ if(NOT DEFINED LLVM_VERSION_PATCH)
+   set(LLVM_VERSION_PATCH 0)
+ endif()
+ if(NOT DEFINED LLVM_VERSION_SUFFIX)
+-  set(LLVM_VERSION_SUFFIX -rc1)
++  set(LLVM_VERSION_SUFFIX)
+ endif()
+ 
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29b2cc23027dff..a3b00872f8da1f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -409,7 +409,7 @@ libclang19_package() {
 	depends="clang19-headers>=${version}_${revision}"
 	short_desc+=" - C frontend library"
 	#TODO remove shlib_provides
-	shlib_provides="libclang.so.19.1-rc1"
+	# shlib_provides="libclang.so.19.1-rc1"
 	pkg_install() {
 		vmove "usr/lib/libclang.so.*"
 	}
@@ -531,7 +531,7 @@ liblldb19_package() {
 	lib32disabled=yes
 	short_desc+=" - LLDB debugger - runtime library"
 	#TODO remove shlib_provides
-	shlib_provides="liblldb.so.19.1-rc1"
+	# shlib_provides="liblldb.so.19.1-rc1"
 	pkg_install() {
 		vmove "usr/lib/liblldb*.so.*"
 	}

From d392324a747322104549db65d4d8073dfd112c79 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Wed, 31 Jul 2024 13:35:58 -0400
Subject: [PATCH 08/19] llvm19: fixup cross compiling

---
 .../llvm19/patches/flang-musl-bessel.patch    | 41 ++++++++++
 srcpkgs/llvm19/template                       | 79 ++++++++++++++++---
 2 files changed, 107 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/llvm19/patches/flang-musl-bessel.patch

diff --git a/srcpkgs/llvm19/patches/flang-musl-bessel.patch b/srcpkgs/llvm19/patches/flang-musl-bessel.patch
new file mode 100644
index 00000000000000..2d36fbaff7022f
--- /dev/null
+++ b/srcpkgs/llvm19/patches/flang-musl-bessel.patch
@@ -0,0 +1,41 @@
+diff --git a/flang/runtime/Float128Math/math-entries.h b/flang/runtime/Float128Math/math-entries.h
+index 13fdab264700..0e8e630fd644 100644
+--- a/flang/runtime/Float128Math/math-entries.h
++++ b/flang/runtime/Float128Math/math-entries.h
+@@ -185,9 +185,11 @@ DEFINE_SIMPLE_ALIAS(Hypot, std::hypot)
+ DEFINE_SIMPLE_ALIAS(Ilogb, std::ilogb)
+ DEFINE_SIMPLE_ALIAS(Isinf, std::isinf)
+ DEFINE_SIMPLE_ALIAS(Isnan, std::isnan)
++#ifdef __GLIBC__
+ DEFINE_SIMPLE_ALIAS(J0, j0l)
+ DEFINE_SIMPLE_ALIAS(J1, j1l)
+ DEFINE_SIMPLE_ALIAS(Jn, jnl)
++#endif
+ DEFINE_SIMPLE_ALIAS(Ldexp, std::ldexp)
+ DEFINE_SIMPLE_ALIAS(Lgamma, std::lgamma)
+ DEFINE_SIMPLE_ALIAS(Llround, std::llround)
+@@ -204,9 +206,11 @@ DEFINE_SIMPLE_ALIAS(Tan, std::tan)
+ DEFINE_SIMPLE_ALIAS(Tanh, std::tanh)
+ DEFINE_SIMPLE_ALIAS(Tgamma, std::tgamma)
+ DEFINE_SIMPLE_ALIAS(Trunc, std::trunc)
++#ifdef __GLIBC__
+ DEFINE_SIMPLE_ALIAS(Y0, y0l)
+ DEFINE_SIMPLE_ALIAS(Y1, y1l)
+ DEFINE_SIMPLE_ALIAS(Yn, ynl)
++#endif
+ 
+ // Use numeric_limits to produce infinity of the right type.
+ #define F128_RT_INFINITY \
+diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
+index 42b1b86ebaad..13b6c9388f0c 100644
+--- a/llvm/runtimes/CMakeLists.txt
++++ b/llvm/runtimes/CMakeLists.txt
+@@ -498,7 +498,7 @@ if(build_runtimes)
+   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+     if (${LLVM_TOOL_FLANG_BUILD})
+       message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
+-      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
++      set(LIBOMP_FORTRAN_MODULES_COMPILER "${LIBOMP_FORTRAN_MODULES_COMPILER_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
+       set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+       # TODO: This is a workaround until flang becomes a first-class project
+       # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index a3b00872f8da1f..4674c64ccc0a69 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -32,33 +32,52 @@ configure_args="
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
  -DLLDB_PYTHON_RELATIVE_PATH=lib/python${py3_ver}/site-packages
  -DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver}
- -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix "
+ -DFLANG_INCLUDE_TESTS=NO
+ -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr "
 hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
  python3-recommonmark python3-sphinx-automodapi git python3-sphinx-markdown-tables python3-yaml pkg-config
- python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it $(vopt_if graphviz graphviz)"
+ python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it SPIRV-Headers SPIRV-Tools-devel
+ $(vopt_if graphviz graphviz)"
 makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
- libxml2-devel binutils-devel z3"
+ libxml2-devel binutils-devel z3 SPIRV-Headers SPIRV-Tools-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0"
 homepage="https://www.llvm.org"
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}-rc1.tar.gz"
-checksum=cd3b42caf8e78c497712a661303672c1a6279eb1a5ff8735488087319ab95214
+_spirv_commit=9508565848694d1a9bebd8a00f13749d7cc293d9
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}-rc1.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/${_spirv_commit}.tar.gz"
+checksum="cd3b42caf8e78c497712a661303672c1a6279eb1a5ff8735488087319ab95214
+ b0fe774cad6539cf6ed63100656374fbe37dc332d87aac7dd707dfdd1d4376bd"
+skip_extraction=${_spirv_commit}.tar.gz
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libcxx libunwind lto graphviz"
-build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp libunwind"
+ openmp libcxx libunwind llvm_spirv lto graphviz"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp
+ libunwind llvm_spirv"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"
+	# if [ "$XBPS_TARGET_LIBC" = "musl" ] ; then
+	# 	if [ -z "$CROSS_BUILD" ]; then
+	# 		build_options_default+=" flang"
+	# 	fi
+	# else
+	# 	build_options_default+=" flang"
+	# fi
+	# x86_64|i686) makedepends+=" libquadmath-devel" ;;
 fi
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
 	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+	# x86_64*|i686*|aarch64*)
+	# 	makedepends+=" libquadmath-devel"
+	# 	hostmakedepends+=" libquadmath-devel" ;;
 esac
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -104,6 +123,7 @@ if [ "$build_option_lld" ]; then
 	_enabled_projects+="lld;"
 	subpackages+=" lld19 lld19-devel "
 fi
+
 if [ "$build_option_libclc" ]; then
 	_enabled_projects+="libclc;"
 	subpackages+=" libclc"
@@ -123,11 +143,12 @@ _enabled_runtimes="compiler-rt"
 if [ "$build_option_openmp" ]; then
 	# openmp fails when built as runtime if cross-compiled
 	if [ "$CROSS_BUILD" ]; then
-		_enabled_projects+="openmp;"
-		#TODO? _enabled_runtimes+=";openmp"
+		# _enabled_projects+="openmp;"
+		#TODO?
+		_enabled_runtimes+=";openmp"
 	else
 		_enabled_runtimes+=";openmp"
-		configure_args+=" OPENMP_ENABLE_LIBOMPTARGET=YES"
+		configure_args+=" -DOPENMP_ENABLE_LIBOMPTARGET=YES"
 	fi
 	subpackages+=" libomp19 libomp19-devel "
 fi
@@ -147,7 +168,7 @@ configure_args+=" -DLLVM_ENABLE_RUNTIMES=${_enabled_runtimes}"
 configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" llvm19-cross-tools"
+	hostmakedepends+=" llvm19-cross-tools flang19-devel"
 
 	#TODO?
 	# CC="clang"
@@ -163,7 +184,7 @@ fi
 
 # For OCaml bindings and lldb lua scripting
 if [ -z "$CROSS_BUILD" ]; then
-	if [ "$build_option_clang_tools_extra" ] && [ "$build_option_lldb" ] && [ "$build_option_mlir" ]; then
+	if [ "$build_option_clang_tools_extra" ] && [ "$build_option_lldb" ] && [ "$build_option_flang" ] && [ "$build_option_mlir" ]; then
 		subpackages+=" llvm19-cross-tools"
 	fi
 	# OCaml cross build is broken
@@ -172,6 +193,13 @@ if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" lua53-devel "
 fi
 
+post_extract() {
+	if [ "$build_option_llvm_spirv" ]; then
+		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_commit}.tar.gz
+		# vsrcextract -C ${wrksrc}/llvm/tools ${_spirv_commit}.tar.gz
+	fi
+}
+
 post_patch() {
 	if [ "$build_option_lldb" ]; then
 		if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -207,6 +235,30 @@ post_patch() {
 }
 
 pre_configure() {
+
+	if [ "$build_option_llvm_spirv" ]; then
+		if [ "$CROSS_BUILD" ]; then
+			configure_args+=" -DLLVM_SPIRV=/usr/bin/llvm-spirv"
+		else
+			configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
+		fi
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		# hostmakedepends+=" llvm19-cross-tools"
+
+		#TODO?
+		CC="clang"
+		CXX="clang++"
+		# LD="lld"
+		CFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
+		CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
+		# LDFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
+		configure_args+=" -DLLVM_USE_LINKER=lld"
+		configure_args+=" -DCMAKE_C_COMPILER=clang"
+		configure_args+=" -DCMAKE_CXX_COMPILER=clang++"
+	fi
+
 	local triplet
 
 	# Vastly reduce size of debugging symbols:
@@ -230,6 +282,7 @@ pre_configure() {
 		configure_args+=" -DMLIR_PDLL_TABLEGEN=/usr/bin/mlir-pdll"
 		configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/usr/bin/mlir-linalg-ods-yaml-gen"
 		configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/usr/bin/mlir-src-sharder"
+		configure_args+=" -DLIBOMP_FORTRAN_MODULES_COMPILER_EXE=/usr/bin/flang-new"
 		configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/usr/bin/clang-tidy-confusable-chars-gen"
 		configure_args+=" -DCLANG_PSEUDO_GEN=/usr/bin/clang-pseudo-gen"
 		configure_args+=" -DLLVM_CONFIG_PATH=/usr/bin/llvm-config"
@@ -781,7 +834,7 @@ llvm19-cross-tools_package() {
 	conflicts="llvm18-cross-tools>=0 llvm17-cross-tools>=0"
 	short_desc+=" - build tools for cross compiling LLVM"
 	depends="lldb19-devel>=${version}_${revision} llvm19-devel>=${version}_${revision}
-	 lld19-devel>=${version}_${revision}"
+	 lld19-devel>=${version}_${revision} flang19-devel>=${version}_${revision}"
 	pkg_install() {
 		# Binaries ONLY used during the process of building llvm, and aren't usually installed
 		vbin build/bin/lldb-tblgen

From f4ab0e9ea9e124e1d22279378f2cc066bcfded84 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Wed, 31 Jul 2024 13:42:18 -0400
Subject: [PATCH 09/19] llvm19: fixup cleanup

---
 srcpkgs/llvm19/template | 34 ++++++++--------------------------
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 4674c64ccc0a69..a824c60f1e487d 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -56,9 +56,9 @@ lib32disabled=yes
 python_version=3
 
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libcxx libunwind llvm_spirv lto graphviz"
+ openmp libcxx libunwind llvm_spirv lto graphviz smaller_debug"
 build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp
- libunwind llvm_spirv"
+ libunwind llvm_spirv smaller_debug"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"
@@ -168,18 +168,7 @@ configure_args+=" -DLLVM_ENABLE_RUNTIMES=${_enabled_runtimes}"
 configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" llvm19-cross-tools flang19-devel"
-
-	#TODO?
-	# CC="clang"
-	# CXX="clang++"
-	# LD="lld"
-	# CFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
-	# CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
-	# LDFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
-	# configure_args+=" -DLLVM_USE_LINKER=lld"
-	# configure_args+=" -DCMAKE_C_COMPILER=clang"
-	# configure_args+=" -DCMAKE_CXX_COMPILER=clang++"
+	hostmakedepends+=" llvm19-cross-tools "
 fi
 
 # For OCaml bindings and lldb lua scripting
@@ -245,15 +234,10 @@ pre_configure() {
 	fi
 
 	if [ "$CROSS_BUILD" ]; then
-		# hostmakedepends+=" llvm19-cross-tools"
-
-		#TODO?
 		CC="clang"
 		CXX="clang++"
-		# LD="lld"
 		CFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
 		CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
-		# LDFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
 		configure_args+=" -DLLVM_USE_LINKER=lld"
 		configure_args+=" -DCMAKE_C_COMPILER=clang"
 		configure_args+=" -DCMAKE_CXX_COMPILER=clang++"
@@ -261,9 +245,11 @@ pre_configure() {
 
 	local triplet
 
-	# Vastly reduce size of debugging symbols:
-	CFLAGS=${CFLAGS/ -g/ -g1}
-	CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+	if [ "$build_option_smaller_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -g1}
+		CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+	fi
 
 	# since gcc9, the build likes to blow up for ppc32 apparently because
 	# of clang being too large for a 24-bit relative call to the PLT, so
@@ -461,8 +447,6 @@ clang19-devel_package() {
 libclang19_package() {
 	depends="clang19-headers>=${version}_${revision}"
 	short_desc+=" - C frontend library"
-	#TODO remove shlib_provides
-	# shlib_provides="libclang.so.19.1-rc1"
 	pkg_install() {
 		vmove "usr/lib/libclang.so.*"
 	}
@@ -583,8 +567,6 @@ lldb19-devel_package() {
 liblldb19_package() {
 	lib32disabled=yes
 	short_desc+=" - LLDB debugger - runtime library"
-	#TODO remove shlib_provides
-	# shlib_provides="liblldb.so.19.1-rc1"
 	pkg_install() {
 		vmove "usr/lib/liblldb*.so.*"
 	}

From 3b724b824eae88e7c3bf0bd3004dde8515822ece Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Thu, 1 Aug 2024 08:56:38 -0400
Subject: [PATCH 10/19] llvm19: fixup armv*

---
 srcpkgs/llvm19/patches/flang-cross.patch      | 13 ++++
 .../llvm19/patches/flang-musl-bessel.patch    | 60 ++++++++++++++-----
 srcpkgs/llvm19/template                       | 43 ++++++++++---
 3 files changed, 92 insertions(+), 24 deletions(-)
 create mode 100644 srcpkgs/llvm19/patches/flang-cross.patch

diff --git a/srcpkgs/llvm19/patches/flang-cross.patch b/srcpkgs/llvm19/patches/flang-cross.patch
new file mode 100644
index 00000000000000..855a2d126df1eb
--- /dev/null
+++ b/srcpkgs/llvm19/patches/flang-cross.patch
@@ -0,0 +1,13 @@
+diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
+index 42b1b86ebaad..13b6c9388f0c 100644
+--- a/llvm/runtimes/CMakeLists.txt
++++ b/llvm/runtimes/CMakeLists.txt
+@@ -498,7 +498,7 @@ if(build_runtimes)
+   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+     if (${LLVM_TOOL_FLANG_BUILD})
+       message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
+-      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
++      set(LIBOMP_FORTRAN_MODULES_COMPILER "${LIBOMP_FORTRAN_MODULES_COMPILER_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
+       set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+       # TODO: This is a workaround until flang becomes a first-class project
+       # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
diff --git a/srcpkgs/llvm19/patches/flang-musl-bessel.patch b/srcpkgs/llvm19/patches/flang-musl-bessel.patch
index 2d36fbaff7022f..59f4e3e2d4be93 100644
--- a/srcpkgs/llvm19/patches/flang-musl-bessel.patch
+++ b/srcpkgs/llvm19/patches/flang-musl-bessel.patch
@@ -1,12 +1,53 @@
+commit 8a0c2301664e7178b2c48a8cfb2a10151bdde462
+Author: Daniel Martinez <danielmartinez@cock.li>
+Date:   Wed Jul 31 14:28:29 2024 -0400
+
+    [flang][runtime] Use fallback bessel functions on musl
+    
+    Fixes compilation on linux when using musl as the libc.
+    
+    musl does not provide long double variants of the bessel functions.
+
+diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
+index a5f5bec1e7e4..b7d890df1f4a 100644
+--- a/flang/runtime/Float128Math/CMakeLists.txt
++++ b/flang/runtime/Float128Math/CMakeLists.txt
+@@ -108,6 +108,26 @@ elseif (HAVE_LDBL_MANT_DIG_113)
+   # We can use 'long double' versions from libc.
+   check_library_exists(m sinl "" FOUND_LIBM)
+   if (FOUND_LIBM)
++    check_cxx_source_compiles(
++      "#include <cmath>
++       int main() {
++         int n = 0;
++         long double x = 1;
++         long double Y0 = y0l(x);
++         long double Y1 = y1l(x);
++         long double Yn = ynl(n,x);
++         long double J0 = j0l(x);
++         long double J1 = j1l(x);
++         long double Jn = jnl(n,x);
++         return 0;
++       }
++      "
++    FOUND_LIBM_BESSEL)
++    if (FOUND_LIBM_BESSEL)
++     target_compile_definitions(FortranFloat128MathILib INTERFACE
++       HAS_LIBM_BESSEL
++       )
++    endif()
+     target_compile_definitions(FortranFloat128MathILib INTERFACE
+       HAS_LIBM
+       )
 diff --git a/flang/runtime/Float128Math/math-entries.h b/flang/runtime/Float128Math/math-entries.h
-index 13fdab264700..0e8e630fd644 100644
+index 13fdab264700..45ae40fdafa0 100644
 --- a/flang/runtime/Float128Math/math-entries.h
 +++ b/flang/runtime/Float128Math/math-entries.h
 @@ -185,9 +185,11 @@ DEFINE_SIMPLE_ALIAS(Hypot, std::hypot)
  DEFINE_SIMPLE_ALIAS(Ilogb, std::ilogb)
  DEFINE_SIMPLE_ALIAS(Isinf, std::isinf)
  DEFINE_SIMPLE_ALIAS(Isnan, std::isnan)
-+#ifdef __GLIBC__
++#ifdef HAS_LIBM_BESSEL
  DEFINE_SIMPLE_ALIAS(J0, j0l)
  DEFINE_SIMPLE_ALIAS(J1, j1l)
  DEFINE_SIMPLE_ALIAS(Jn, jnl)
@@ -18,7 +59,7 @@ index 13fdab264700..0e8e630fd644 100644
  DEFINE_SIMPLE_ALIAS(Tanh, std::tanh)
  DEFINE_SIMPLE_ALIAS(Tgamma, std::tgamma)
  DEFINE_SIMPLE_ALIAS(Trunc, std::trunc)
-+#ifdef __GLIBC__
++#ifdef HAS_LIBM_BESSEL
  DEFINE_SIMPLE_ALIAS(Y0, y0l)
  DEFINE_SIMPLE_ALIAS(Y1, y1l)
  DEFINE_SIMPLE_ALIAS(Yn, ynl)
@@ -26,16 +67,3 @@ index 13fdab264700..0e8e630fd644 100644
  
  // Use numeric_limits to produce infinity of the right type.
  #define F128_RT_INFINITY \
-diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
-index 42b1b86ebaad..13b6c9388f0c 100644
---- a/llvm/runtimes/CMakeLists.txt
-+++ b/llvm/runtimes/CMakeLists.txt
-@@ -498,7 +498,7 @@ if(build_runtimes)
-   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
-     if (${LLVM_TOOL_FLANG_BUILD})
-       message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
--      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
-+      set(LIBOMP_FORTRAN_MODULES_COMPILER "${LIBOMP_FORTRAN_MODULES_COMPILER_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
-       set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
-       # TODO: This is a workaround until flang becomes a first-class project
-       # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index a824c60f1e487d..d9ba6283beb2ea 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -40,7 +40,7 @@ hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
  python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it SPIRV-Headers SPIRV-Tools-devel
  $(vopt_if graphviz graphviz)"
 makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
- libxml2-devel binutils-devel z3 SPIRV-Headers SPIRV-Tools-devel"
+ libxml2-devel binutils-devel z3-devel SPIRV-Headers SPIRV-Tools-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0"
@@ -56,10 +56,12 @@ lib32disabled=yes
 python_version=3
 
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libcxx libunwind llvm_spirv lto graphviz smaller_debug"
+ openmp libcxx libunwind llvm_spirv lto graphviz smaller_debug full_debug"
 build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp
  libunwind llvm_spirv smaller_debug"
 
+vopt_conflict smaller_debug full_debug
+
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"
 	# if [ "$XBPS_TARGET_LIBC" = "musl" ] ; then
@@ -80,6 +82,14 @@ case "$XBPS_TARGET_MACHINE" in
 	# 	hostmakedepends+=" libquadmath-devel" ;;
 esac
 
+case "$XBPS_TARGET_MACHINE" in
+	armv*)
+		nopie=yes
+		configure_args+=" -DLLVM_ENABLE_PIE=NO"
+		configure_args+=" -DLLDB_INCLUDE_TESTS=NO"
+	;;
+esac
+
 # build fails because compiler_rt generates armv7 instructions when target is armv6
 case "$XBPS_TARGET_MACHINE" in
 	armv6*) ;;
@@ -236,14 +246,23 @@ pre_configure() {
 	if [ "$CROSS_BUILD" ]; then
 		CC="clang"
 		CXX="clang++"
-		CFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
-		CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET}"
-		configure_args+=" -DLLVM_USE_LINKER=lld"
-		configure_args+=" -DCMAKE_C_COMPILER=clang"
-		configure_args+=" -DCMAKE_CXX_COMPILER=clang++"
+
+		local gcc_version=$(gcc -dumpversion)
+
+		CFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+		CFLAGS+=" --gcc-toolchain=/usr"
+		CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
+		CFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
+
+		CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+		CXXFLAGS+=" --gcc-toolchain=/usr"
+		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}"
+		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/${XBPS_CROSS_TRIPLET}"
+		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward"
+		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
+		CXXFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
 	fi
 
-	local triplet
 
 	if [ "$build_option_smaller_debug" ]; then
 		# Vastly reduce size of debugging symbols:
@@ -251,6 +270,12 @@ pre_configure() {
 		CXXFLAGS=${CXXFLAGS/ -g/ -g1}
 	fi
 
+	if [ "$build_option_full_debug" ]; then
+		# Vastly increase size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -g3}
+		CXXFLAGS=${CXXFLAGS/ -g/ -g3}
+	fi
+
 	# since gcc9, the build likes to blow up for ppc32 apparently because
 	# of clang being too large for a 24-bit relative call to the PLT, so
 	# optimize for size instead
@@ -294,6 +319,8 @@ pre_configure() {
 		riscv64*) _arch="RISCV64";;
 	esac
 
+	local triplet
+
 	triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
 
 	configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"

From 24bb95be8e6c63699dcd8e0c0b7157a0ee26b1f8 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Thu, 1 Aug 2024 20:13:31 -0400
Subject: [PATCH 11/19] libclc: fixup

---
 srcpkgs/libclc          |  1 -
 srcpkgs/libclc/template | 30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 delete mode 120000 srcpkgs/libclc
 create mode 100644 srcpkgs/libclc/template

diff --git a/srcpkgs/libclc b/srcpkgs/libclc
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/libclc
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/libclc/template b/srcpkgs/libclc/template
new file mode 100644
index 00000000000000..da85a23c785549
--- /dev/null
+++ b/srcpkgs/libclc/template
@@ -0,0 +1,30 @@
+# Template file for 'libclc'
+pkgname=libclc
+version=18.1.8
+revision=1
+build_style=cmake
+# disable clspv (failing tests, we don't ship it)
+configure_args="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
+ -DLIBCLC_TARGETS_TO_BUILD=amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl;spirv-mesa3d-;spirv64-mesa3d-"
+hostmakedepends="llvm18-devel python3 libedit-devel libffi-devel
+ ncurses-devel zlib-devel SPIRV-LLVM-Translator"
+short_desc="Open implementation of the OpenCL C programming language"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="BSD-3-Clause, MIT"
+homepage="https://libclc.llvm.org"
+distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/libclc-${version}.src.tar.xz"
+checksum=905bd59e9f810d6bd0ae6874725a8f8a3c91cb416199c03f2b98b57437cfb32e
+replaces="libclc-git>=0"
+
+do_configure() {
+	# We really do a native build.
+	# The outcome is just header files.
+	unset CC CXX LD CFLAGS CXXFLAGS LDFLAGS
+	mkdir -p build
+	cd build
+	cmake -GNinja ${configure_args} ..
+}
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 45f2f7c8381fc44a5bf409684b411f3051e9b184 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Thu, 1 Aug 2024 21:23:03 -0400
Subject: [PATCH 12/19] llvm19: fixup cross

---
 srcpkgs/libclc19                              |  1 +
 srcpkgs/libcxx                                |  2 +-
 srcpkgs/libcxx-devel                          |  2 +-
 srcpkgs/libcxxabi                             |  2 +-
 srcpkgs/libcxxabi-devel                       |  2 +-
 ...compiler-rt-sanitizer-supported-arch.patch | 22 ------
 srcpkgs/llvm19/patches/flang-cross.patch      | 19 ++++-
 srcpkgs/llvm19/template                       | 70 +++++++++----------
 8 files changed, 55 insertions(+), 65 deletions(-)
 create mode 120000 srcpkgs/libclc19
 delete mode 100644 srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch

diff --git a/srcpkgs/libclc19 b/srcpkgs/libclc19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/libclc19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libcxx b/srcpkgs/libcxx
index 1f418dc969a832..985027fe0a5c8d 120000
--- a/srcpkgs/libcxx
+++ b/srcpkgs/libcxx
@@ -1 +1 @@
-llvm18
\ No newline at end of file
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libcxx-devel b/srcpkgs/libcxx-devel
index 1f418dc969a832..985027fe0a5c8d 120000
--- a/srcpkgs/libcxx-devel
+++ b/srcpkgs/libcxx-devel
@@ -1 +1 @@
-llvm18
\ No newline at end of file
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi b/srcpkgs/libcxxabi
index 1f418dc969a832..985027fe0a5c8d 120000
--- a/srcpkgs/libcxxabi
+++ b/srcpkgs/libcxxabi
@@ -1 +1 @@
-llvm18
\ No newline at end of file
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi-devel b/srcpkgs/libcxxabi-devel
index 1f418dc969a832..985027fe0a5c8d 120000
--- a/srcpkgs/libcxxabi-devel
+++ b/srcpkgs/libcxxabi-devel
@@ -1 +1 @@
-llvm18
\ No newline at end of file
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch b/srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch
deleted file mode 100644
index c9b9286ac37b31..00000000000000
--- a/srcpkgs/llvm19/patches/compiler-rt-sanitizer-supported-arch.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Based on patch from Alpine:
-https://gitlab.alpinelinux.org/alpine/aports/-/blob/693203c42aa1cde88cb547173ef67a98824973fd/main/llvm-runtimes/compiler-rt-sanitizer-supported-arch.patch
-
-Sanitizer code is broken on armhf, armv7, s390x, x86, and probably riscv64 on musl,
-i.e. enable it only on x86_64, aarch64, and ppc64le.
-
---- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
-+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
-@@ -23,9 +23,13 @@ if(APPLE)
-   set(X86_64 x86_64 x86_64h)
- endif()
- 
-+if (LIBCXX_HAS_MUSL_LIBC)
-+set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86_64} ${ARM64} ${PPC64})
-+else()
- set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64}
-     ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9}
-     ${HEXAGON} ${LOONGARCH64})
-+endif()
- set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
-     ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-     ${LOONGARCH64})
diff --git a/srcpkgs/llvm19/patches/flang-cross.patch b/srcpkgs/llvm19/patches/flang-cross.patch
index 855a2d126df1eb..3daf5a81a40d7b 100644
--- a/srcpkgs/llvm19/patches/flang-cross.patch
+++ b/srcpkgs/llvm19/patches/flang-cross.patch
@@ -1,5 +1,20 @@
+commit 61215cf73fcbcf81545e6702fb7c9e32ae614c56
+Author: Daniel Martinez <danielmartinez@cock.li>
+Date:   Wed Jul 31 21:14:52 2024 -0400
+
+    Allow flang-new binary to be specified for omp modules
+    
+    This allows the path of the flang-new binary to be specified as a
+    cmake configuration.
+    
+    This is useful when cross compiling, as flang-new may exist
+    on the build machine, which should be used instead of the host.
+    
+    For example, by passing "-DFLANG_NEW_EXE=/usr/bin/flang-new", that
+    binary will be used instead of just built host compiler.
+
 diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
-index 42b1b86ebaad..13b6c9388f0c 100644
+index 42b1b86ebaad..22999827d4a8 100644
 --- a/llvm/runtimes/CMakeLists.txt
 +++ b/llvm/runtimes/CMakeLists.txt
 @@ -498,7 +498,7 @@ if(build_runtimes)
@@ -7,7 +22,7 @@ index 42b1b86ebaad..13b6c9388f0c 100644
      if (${LLVM_TOOL_FLANG_BUILD})
        message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
 -      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
-+      set(LIBOMP_FORTRAN_MODULES_COMPILER "${LIBOMP_FORTRAN_MODULES_COMPILER_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
++      set(LIBOMP_FORTRAN_MODULES_COMPILER "${FLANG_NEW_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
        set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
        # TODO: This is a workaround until flang becomes a first-class project
        # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index d9ba6283beb2ea..487188925bf872 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -32,7 +32,6 @@ configure_args="
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
  -DLLDB_PYTHON_RELATIVE_PATH=lib/python${py3_ver}/site-packages
  -DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver}
- -DFLANG_INCLUDE_TESTS=NO
  -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr "
 hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
@@ -56,14 +55,12 @@ lib32disabled=yes
 python_version=3
 
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libcxx libunwind llvm_spirv lto graphviz smaller_debug full_debug"
+ openmp libcxx libunwind offload llvm_spirv lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp
- libunwind llvm_spirv smaller_debug"
-
-vopt_conflict smaller_debug full_debug
+ libcxx libunwind llvm_spirv"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
-	build_options_default+=" flang bolt"
+	build_options_default+=" flang bolt offload"
 	# if [ "$XBPS_TARGET_LIBC" = "musl" ] ; then
 	# 	if [ -z "$CROSS_BUILD" ]; then
 	# 		build_options_default+=" flang"
@@ -136,7 +133,7 @@ fi
 
 if [ "$build_option_libclc" ]; then
 	_enabled_projects+="libclc;"
-	subpackages+=" libclc"
+	subpackages+=" libclc19"
 fi
 if [ "$build_option_mlir" ]; then
 	_enabled_projects+="mlir;"
@@ -151,16 +148,13 @@ subpackages+=" compiler-rt19 "
 _enabled_runtimes="compiler-rt"
 
 if [ "$build_option_openmp" ]; then
-	# openmp fails when built as runtime if cross-compiled
-	if [ "$CROSS_BUILD" ]; then
-		# _enabled_projects+="openmp;"
-		#TODO?
-		_enabled_runtimes+=";openmp"
-	else
-		_enabled_runtimes+=";openmp"
+	_enabled_runtimes+=";openmp"
+	subpackages+=" libomp19 libomp19-devel "
+
+	if [ "$build_option_offload" ]; then
+		_enabled_runtimes+=";offload"
 		configure_args+=" -DOPENMP_ENABLE_LIBOMPTARGET=YES"
 	fi
-	subpackages+=" libomp19 libomp19-devel "
 fi
 
 if [ "$build_option_libunwind" ]; then
@@ -247,12 +241,16 @@ pre_configure() {
 		CC="clang"
 		CXX="clang++"
 
+		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+
 		local gcc_version=$(gcc -dumpversion)
 
 		CFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
 		CFLAGS+=" --gcc-toolchain=/usr"
 		CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
-		CFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
+		# CFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
+		CFLAGS+=" -isystem /usr/lib/gcc/${XBPS_CROSS_TRIPLET}/${gcc_version}/include"
 
 		CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
 		CXXFLAGS+=" --gcc-toolchain=/usr"
@@ -260,30 +258,26 @@ pre_configure() {
 		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/${XBPS_CROSS_TRIPLET}"
 		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward"
 		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
-		CXXFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
+		# CXXFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
+		CXXFLAGS+=" -isystem /usr/lib/gcc/${XBPS_CROSS_TRIPLET}/${gcc_version}/include"
 	fi
 
 
-	if [ "$build_option_smaller_debug" ]; then
+
+	if [ ! "$build_option_full_debug" ]; then
 		# Vastly reduce size of debugging symbols:
 		CFLAGS=${CFLAGS/ -g/ -g1}
 		CXXFLAGS=${CXXFLAGS/ -g/ -g1}
 	fi
 
-	if [ "$build_option_full_debug" ]; then
-		# Vastly increase size of debugging symbols:
-		CFLAGS=${CFLAGS/ -g/ -g3}
-		CXXFLAGS=${CXXFLAGS/ -g/ -g3}
-	fi
-
-	# since gcc9, the build likes to blow up for ppc32 apparently because
-	# of clang being too large for a 24-bit relative call to the PLT, so
-	# optimize for size instead
-	case "$XBPS_TARGET_MACHINE" in
-		ppc64*) ;;
-		mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
-		armv*) configure_args+=" -DLIBCXX_VOID_GCC_BUG_109180_WORKAROUND=ON ";;
-	esac
+	# # since gcc9, the build likes to blow up for ppc32 apparently because
+	# # of clang being too large for a 24-bit relative call to the PLT, so
+	# # optimize for size instead
+	# case "$XBPS_TARGET_MACHINE" in
+	# 	ppc64*) ;;
+	# 	mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
+	# 	armv*) configure_args+=" -DLIBCXX_VOID_GCC_BUG_109180_WORKAROUND=ON ";;
+	# esac
 
 	if [ "$CROSS_BUILD" ]; then
 		configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/usr/bin"
@@ -293,7 +287,7 @@ pre_configure() {
 		configure_args+=" -DMLIR_PDLL_TABLEGEN=/usr/bin/mlir-pdll"
 		configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/usr/bin/mlir-linalg-ods-yaml-gen"
 		configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/usr/bin/mlir-src-sharder"
-		configure_args+=" -DLIBOMP_FORTRAN_MODULES_COMPILER_EXE=/usr/bin/flang-new"
+		configure_args+=" -DFLANG_NEW_EXE=/usr/bin/flang-new"
 		configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/usr/bin/clang-tidy-confusable-chars-gen"
 		configure_args+=" -DCLANG_PSEUDO_GEN=/usr/bin/clang-pseudo-gen"
 		configure_args+=" -DLLVM_CONFIG_PATH=/usr/bin/llvm-config"
@@ -304,6 +298,9 @@ pre_configure() {
 	arm*-musl|i686-musl)
 		# sanitizer code is broken since it duplicates some libc bits
 		configure_args+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+		# configure_args+=" -DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
+		configure_args+=" -DCOMPILER_RT_BUILD_XRAY=OFF"
+		configure_args+=" -DCOMPILER_RT_BUILD_MEMPROF=OFF"
 		;;
 	esac
 
@@ -721,9 +718,8 @@ libomp19-devel_package() {
 		if [ -z "$CROSS_BUILD" ]; then
 			case "$XBPS_TARGET_MACHINE" in
 				x86_64*|aarch64*)
-					# TODO: Fix libomp
-					# vmove "usr/lib/libomptarget*.bc"
-					# vmove "usr/lib/libomp*.a"
+					vmove "usr/lib/libomptarget*.bc"
+					vmove "usr/lib/libomp*.a"
 				;;
 			esac
 		fi
@@ -853,7 +849,7 @@ llvm19-cross-tools_package() {
 	}
 }
 
-libclc_package() {
+libclc19_package() {
 	short_desc+=" - Open implementation of the OpenCL C programming language"
 	replaces="libclc-git>=0"
 	pkg_install() {

From 1231bf402cf73119e0edeeffefa90c80b9ae54bc Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Fri, 2 Aug 2024 09:57:08 -0400
Subject: [PATCH 13/19] llvm19: fixup cross

---
 srcpkgs/SPIRV-LLVM-Translator19       |   1 +
 srcpkgs/SPIRV-LLVM-Translator19-devel |   1 +
 srcpkgs/llvm19/template               | 199 ++++++++++++++------------
 3 files changed, 112 insertions(+), 89 deletions(-)
 create mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 120000 srcpkgs/SPIRV-LLVM-Translator19-devel

diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
new file mode 120000
index 00000000000000..985027fe0a5c8d
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -0,0 +1 @@
+llvm19
\ No newline at end of file
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 487188925bf872..c88fdf14d4be67 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -33,6 +33,7 @@ configure_args="
  -DLLDB_PYTHON_RELATIVE_PATH=lib/python${py3_ver}/site-packages
  -DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver}
  -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
+ -DLIBC_WNO_ERROR=YES
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr "
 hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
  python3-recommonmark python3-sphinx-automodapi git python3-sphinx-markdown-tables python3-yaml pkg-config
@@ -55,21 +56,21 @@ lib32disabled=yes
 python_version=3
 
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp
  libcxx libunwind llvm_spirv"
 
-if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
-	build_options_default+=" flang bolt offload"
+# hack to set correct order of subpackages after processing build options
+subpackages=$(:)
+
+# if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
+
 	# if [ "$XBPS_TARGET_LIBC" = "musl" ] ; then
-	# 	if [ -z "$CROSS_BUILD" ]; then
-	# 		build_options_default+=" flang"
-	# 	fi
 	# else
 	# 	build_options_default+=" flang"
 	# fi
 	# x86_64|i686) makedepends+=" libquadmath-devel" ;;
-fi
+# fi
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -80,6 +81,12 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 case "$XBPS_TARGET_MACHINE" in
+	x86_64*|aarch64*)
+		build_options_default+=" flang bolt"
+		if [ -z "$CROSS_BUILD" ]; then
+			build_options_default+=" offload"
+		fi
+	;;
 	armv*)
 		nopie=yes
 		configure_args+=" -DLLVM_ENABLE_PIE=NO"
@@ -102,7 +109,11 @@ if [ "$build_option_lto" ]; then
 	configure_args+=" -DLLVM_ENABLE_LTO=On"
 fi
 
-subpackages="libllvm19 llvm19-doc llvm19-devel"
+if [ "$build_option_llvm_spirv" ]; then
+	subpackages+=" SPIRV-LLVM-Translator19 SPIRV-LLVM-Translator19-devel "
+fi
+
+subpackages+=" libllvm19 llvm19-doc llvm19-devel "
 
 # use $(:) to silence xlint
 _enabled_runtimes=$(:)
@@ -144,6 +155,7 @@ if [ "$build_option_flang" ]; then
 	subpackages+=" flang19 flang19-devel "
 fi
 
+
 subpackages+=" compiler-rt19 "
 _enabled_runtimes="compiler-rt"
 
@@ -157,6 +169,10 @@ if [ "$build_option_openmp" ]; then
 	fi
 fi
 
+if [ "$build_option_libc" ]; then
+	_enabled_runtimes+=";libc"
+fi
+
 if [ "$build_option_libunwind" ]; then
 	subpackages+=" llvm-libunwind llvm-libunwind-devel "
 	_enabled_runtimes+=";libunwind"
@@ -173,6 +189,21 @@ configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" llvm19-cross-tools "
+
+	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/usr/bin"
+	configure_args+=" -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen"
+	configure_args+=" -DCLANG_TABLEGEN=/usr/bin/clang-tblgen"
+	configure_args+=" -DMLIR_TABLEGEN=/usr/bin/mlir-tblgen"
+	configure_args+=" -DMLIR_PDLL_TABLEGEN=/usr/bin/mlir-pdll"
+	configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/usr/bin/mlir-linalg-ods-yaml-gen"
+	configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/usr/bin/mlir-src-sharder"
+	configure_args+=" -DFLANG_NEW_EXE=/usr/bin/flang-new"
+	configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/usr/bin/clang-tidy-confusable-chars-gen"
+	configure_args+=" -DCLANG_PSEUDO_GEN=/usr/bin/clang-pseudo-gen"
+	configure_args+=" -DLLVM_CONFIG_PATH=/usr/bin/llvm-config"
+	configure_args+=" -DLLDB_TABLEGEN_EXE=/usr/bin/lldb-tblgen"
+
+	configure_args+=" -DLIBOMP_OMPD_GDB_SUPPORT=NO"
 fi
 
 # For OCaml bindings and lldb lua scripting
@@ -186,6 +217,41 @@ if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" lua53-devel "
 fi
 
+if [ ! "$build_option_full_debug" ]; then
+	# Vastly reduce size of debugging symbols:
+	CFLAGS=${CFLAGS/ -g/ -g1}
+	CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+arm*-musl|i686-musl)
+	# sanitizer code is broken since it duplicates some libc bits
+	configure_args+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+	# configure_args+=" -DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
+	configure_args+=" -DCOMPILER_RT_BUILD_XRAY=OFF"
+	configure_args+=" -DCOMPILER_RT_BUILD_MEMPROF=OFF"
+	;;
+esac
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*) _arch="X86";;
+	x86_64*) _arch="X86";;
+	armv5*) _arch="Armv5te";;
+	armv6*) _arch="Armv6";;
+	armv7*) _arch="Armv7";;
+	aarch64*) _arch="AArch64";;
+	mips*) _arch="Mips";;
+	ppc*) _arch="PowerPC";;
+	riscv64*) _arch="RISCV64";;
+esac
+
+
+_triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+configure_args+=" -DLLVM_HOST_TRIPLE=${_triplet}"
+configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${_triplet}"
+
 post_extract() {
 	if [ "$build_option_llvm_spirv" ]; then
 		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_commit}.tar.gz
@@ -228,15 +294,6 @@ post_patch() {
 }
 
 pre_configure() {
-
-	if [ "$build_option_llvm_spirv" ]; then
-		if [ "$CROSS_BUILD" ]; then
-			configure_args+=" -DLLVM_SPIRV=/usr/bin/llvm-spirv"
-		else
-			configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-		fi
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		CC="clang"
 		CXX="clang++"
@@ -249,8 +306,7 @@ pre_configure() {
 		CFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
 		CFLAGS+=" --gcc-toolchain=/usr"
 		CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
-		# CFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
-		CFLAGS+=" -isystem /usr/lib/gcc/${XBPS_CROSS_TRIPLET}/${gcc_version}/include"
+		# CFLAGS+=" -isystem /usr/lib/gcc/${XBPS_CROSS_TRIPLET}/${gcc_version}/include"
 
 		CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
 		CXXFLAGS+=" --gcc-toolchain=/usr"
@@ -258,71 +314,15 @@ pre_configure() {
 		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/${XBPS_CROSS_TRIPLET}"
 		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward"
 		CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
-		# CXXFLAGS+=" -isystem /usr/lib/gcc/${gcc_version}/include"
-		CXXFLAGS+=" -isystem /usr/lib/gcc/${XBPS_CROSS_TRIPLET}/${gcc_version}/include"
-	fi
-
-
-
-	if [ ! "$build_option_full_debug" ]; then
-		# Vastly reduce size of debugging symbols:
-		CFLAGS=${CFLAGS/ -g/ -g1}
-		CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+		# CXXFLAGS+=" -isystem /usr/lib/gcc/${XBPS_CROSS_TRIPLET}/${gcc_version}/include"
 	fi
-
-	# # since gcc9, the build likes to blow up for ppc32 apparently because
-	# # of clang being too large for a 24-bit relative call to the PLT, so
-	# # optimize for size instead
-	# case "$XBPS_TARGET_MACHINE" in
-	# 	ppc64*) ;;
-	# 	mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
-	# 	armv*) configure_args+=" -DLIBCXX_VOID_GCC_BUG_109180_WORKAROUND=ON ";;
-	# esac
-
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/usr/bin"
-		configure_args+=" -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen"
-		configure_args+=" -DCLANG_TABLEGEN=/usr/bin/clang-tblgen"
-		configure_args+=" -DMLIR_TABLEGEN=/usr/bin/mlir-tblgen"
-		configure_args+=" -DMLIR_PDLL_TABLEGEN=/usr/bin/mlir-pdll"
-		configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/usr/bin/mlir-linalg-ods-yaml-gen"
-		configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/usr/bin/mlir-src-sharder"
-		configure_args+=" -DFLANG_NEW_EXE=/usr/bin/flang-new"
-		configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/usr/bin/clang-tidy-confusable-chars-gen"
-		configure_args+=" -DCLANG_PSEUDO_GEN=/usr/bin/clang-pseudo-gen"
-		configure_args+=" -DLLVM_CONFIG_PATH=/usr/bin/llvm-config"
-		configure_args+=" -DLLDB_TABLEGEN_EXE=/usr/bin/lldb-tblgen"
+	if [ "$build_option_llvm_spirv" ]; then
+		if [ "$CROSS_BUILD" ]; then
+			configure_args+=" -DLLVM_SPIRV=/usr/bin/llvm-spirv"
+		else
+			configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
+		fi
 	fi
-
-	case "$XBPS_TARGET_MACHINE" in
-	arm*-musl|i686-musl)
-		# sanitizer code is broken since it duplicates some libc bits
-		configure_args+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF"
-		# configure_args+=" -DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
-		configure_args+=" -DCOMPILER_RT_BUILD_XRAY=OFF"
-		configure_args+=" -DCOMPILER_RT_BUILD_MEMPROF=OFF"
-		;;
-	esac
-
-	case "$XBPS_TARGET_MACHINE" in
-		i686*) _arch="X86";;
-		x86_64*) _arch="X86";;
-		armv5*) _arch="Armv5te";;
-		armv6*) _arch="Armv6";;
-		armv7*) _arch="Armv7";;
-		aarch64*) _arch="AArch64";;
-		mips*) _arch="Mips";;
-		ppc*) _arch="PowerPC";;
-		riscv64*) _arch="RISCV64";;
-	esac
-
-	local triplet
-
-	triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
-
-	configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
-	configure_args+=" -DLLVM_HOST_TRIPLE=${triplet}"
-	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${triplet}"
 }
 
 post_build() {
@@ -386,6 +386,10 @@ post_install() {
 
 	# Can this be disabled some other way?
 	rm -f ${DESTDIR}/usr/lib64
+
+	if [ "$build_option_llvm_spirv" ]; then
+		mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-19
+	fi
 }
 
 clang19_package() {
@@ -715,13 +719,9 @@ libomp19-devel_package() {
 			vmove usr/share/man/man1/llvmopenmp.1
 		fi
 
-		if [ -z "$CROSS_BUILD" ]; then
-			case "$XBPS_TARGET_MACHINE" in
-				x86_64*|aarch64*)
-					vmove "usr/lib/libomptarget*.bc"
-					vmove "usr/lib/libomp*.a"
-				;;
-			esac
+		if [ "$build_option_offload" ]; then
+			vmove "usr/lib/libomptarget*.bc"
+			vmove "usr/lib/libomp*.a"
 		fi
 	}
 }
@@ -823,6 +823,9 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
+	if [ "$build_option_llvm_spirv" ]; then
+		depends+=" SPIRV-LLVM-Translator19-devel>=${version}_${revision} "
+	fi
 	pkg_install() {
 		vmove usr/lib/libLLVM.so
 		vmove usr/lib/libLTO.so
@@ -858,3 +861,21 @@ libclc19_package() {
 		vmove usr/share/pkgconfig/libclc.pc
 	}
 }
+
+SPIRV-LLVM-Translator19_package() {
+	short_desc+=" - API and commands for processing SPIR-V modules"
+	alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-19"
+	pkg_install() {
+		vmove usr/bin/llvm-spirv-19
+	}
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator19>=${version}_${revision}"
+	short_desc+=" - API and commands for processing SPIR-V modules - development files"
+	pkg_install() {
+		vmove usr/include/LLVMSPIRVLib
+		vmove usr/lib/pkgconfig/LLVMSPIRVLib.pc
+		vmove "usr/lib/libLLVMSPIRV*.a"
+	}
+}

From 05095af3ce51b7a79a2bf51d4032889665bd4138 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Fri, 2 Aug 2024 12:17:23 -0400
Subject: [PATCH 14/19] libclc: alternatives

---
 srcpkgs/libclc/template | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libclc/template b/srcpkgs/libclc/template
index da85a23c785549..5bf88b564d9a89 100644
--- a/srcpkgs/libclc/template
+++ b/srcpkgs/libclc/template
@@ -1,10 +1,10 @@
 # Template file for 'libclc'
 pkgname=libclc
 version=18.1.8
-revision=1
+revision=2
 build_style=cmake
 # disable clspv (failing tests, we don't ship it)
-configure_args="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
+configure_args="-DCMAKE_INSTALL_PREFIX=/usr/lib/llvm/18/ -DCMAKE_BUILD_TYPE=Release
  -DLIBCLC_TARGETS_TO_BUILD=amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl;spirv-mesa3d-;spirv64-mesa3d-"
 hostmakedepends="llvm18-devel python3 libedit-devel libffi-devel
  ncurses-devel zlib-devel SPIRV-LLVM-Translator"
@@ -16,6 +16,12 @@ distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${vers
 checksum=905bd59e9f810d6bd0ae6874725a8f8a3c91cb416199c03f2b98b57437cfb32e
 replaces="libclc-git>=0"
 
+alternatives="
+ clc:/usr/share/clc:/usr/lib/llvm/18/share/clc
+ clc:/usr/include/clc:/usr/lib/llvm/18/include/clc
+ clc:/usr/share/pkgconfig/libclc.pc:/usr/lib/llvm/18/share/pkgconfig/libclc.pc
+"
+
 do_configure() {
 	# We really do a native build.
 	# The outcome is just header files.

From 74baa083e1f9f82f963f04d633dd59482816bce6 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 3 Aug 2024 17:55:08 -0400
Subject: [PATCH 15/19] llvm19: fixup builds on all arches

---
 srcpkgs/llvm19/template | 730 ++++++++++++++++++++++++++++------------
 1 file changed, 507 insertions(+), 223 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index c88fdf14d4be67..3ed783e3dd6e9e 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -4,20 +4,41 @@ version=19.1.0
 revision=1
 build_wrksrc=llvm
 build_style=cmake
+_llvm_prefix=lib/llvm/19
+_llvm_mandir=usr/${_llvm_prefix}/share/man
+_llvm_bindir=usr/${_llvm_prefix}/bin
+_llvm_datadir=usr/${_llvm_prefix}/share
+_llvm_incdir=usr/${_llvm_prefix}/include
+_llvm_libdir=usr/${_llvm_prefix}/lib
+_llvm_libexecdir=usr/${_llvm_prefix}/libexec
+ # -DLLVM_UTILS_INSTALL_DIR=/usr/${_llvm_prefix}/utils/bin
+ # -DLLVM_TOOLS_INSTALL_DIR=/usr/${_llvm_prefix}/tools/bin
+ # -DCMAKE_INSTALL_MANDIR=${_llvm_prefix}/share/man
+ # -DCMAKE_INSTALL_BINDIR=${_llvm_prefix}/bin
+ # -DCMAKE_INSTALL_DATADIR=${_llvm_prefix}/share
 # build_helper=qemu
 _ext_suffix=".cpython-${py3_ver/./}-linux-${XBPS_TARGET_LIBC/glibc/gnu}.so"
 configure_args="
  -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DCMAKE_INSTALL_PREFIX=/usr/${_llvm_prefix}
  -DENABLE_LINKER_BUILD_ID=YES
  -DLLDB_USE_SYSTEM_SIX=YES
+ -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBCXXABI_USE_LLVM_UNWINDER=YES
  -DLIBCXX_CXX_ABI=libcxxabi
  -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES
- -DLIBCXXABI_USE_LLVM_UNWINDER=YES
- -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBCXX_INSTALL_INCLUDE_DIR=/usr/include/c++/v1
+ -DLIBCXX_INSTALL_LIBRARY_DIR=/usr/lib
+ -DLIBCXX_INSTALL_RUNTIME_DIR=/usr/bin
+ -DLIBCXX_INSTALL_MODULES_DIR=/usr/share/libc++/v1
+ -DLIBCXXABI_INSTALL_LIBRARY_DIR=/usr/lib
+ -DLIBUNWIND_INSTALL_INCLUDE_DIR=/usr/include
+ -DLIBUNWIND_INSTALL_LIBRARY_DIR=/usr/lib
+ -DLIBUNWIND_INSTALL_RUNTIME_DIR=/usr/bin
  -DLIBOMP_ENABLE_SHARED=YES
  -DLIBOMP_INSTALL_ALIASES=NO
- -DLLVM_INCLUDE_DOCS=YES
  -DLLVM_BUILD_DOCS=YES
+ -DLLVM_INCLUDE_DOCS=YES
  -DLLVM_ENABLE_SPHINX=YES
  -DLLVM_ENABLE_Z3_SOLVER=YES
  -DSPHINX_WARNINGS_AS_ERRORS=NO
@@ -34,11 +55,12 @@ configure_args="
  -DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver}
  -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
  -DLIBC_WNO_ERROR=YES
+ -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr "
 hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
  python3-recommonmark python3-sphinx-automodapi git python3-sphinx-markdown-tables python3-yaml pkg-config
  python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it SPIRV-Headers SPIRV-Tools-devel
- $(vopt_if graphviz graphviz)"
+ patchelf $(vopt_if graphviz graphviz)"
 makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
  libxml2-devel binutils-devel z3-devel SPIRV-Headers SPIRV-Tools-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
@@ -57,7 +79,7 @@ python_version=3
 
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
  openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
-build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb
  libcxx libunwind llvm_spirv"
 
 # hack to set correct order of subpackages after processing build options
@@ -75,13 +97,10 @@ subpackages=$(:)
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
 	x86_64|i686) makedepends+=" libquadmath-devel" ;;
-	# x86_64*|i686*|aarch64*)
-	# 	makedepends+=" libquadmath-devel"
-	# 	hostmakedepends+=" libquadmath-devel" ;;
 esac
 
 case "$XBPS_TARGET_MACHINE" in
-	x86_64*|aarch64*)
+	x86_64*|aarch64*|riscv64*)
 		build_options_default+=" flang bolt"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
@@ -96,8 +115,15 @@ esac
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
 case "$XBPS_TARGET_MACHINE" in
-	armv6*) ;;
-	*) configure_args+=" -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" ;;
+	armv6*)
+		# Don't enable openmp on armv6*
+		#/builddir/llvm19-19.1.0/openmp/runtime/src/kmp_platform.h:263:2:
+		#error Unknown or unsupported architecture
+		;;
+	*)
+		build_options_default+=" openmp "
+		configure_args+=" -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
+		;;
 esac
 
 if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -165,7 +191,8 @@ if [ "$build_option_openmp" ]; then
 
 	if [ "$build_option_offload" ]; then
 		_enabled_runtimes+=";offload"
-		configure_args+=" -DOPENMP_ENABLE_LIBOMPTARGET=YES"
+		configuje_args+=" -DOPENMP_ENABLE_LIBOMPTARGET=YES"
+		# configure_args+=" -DLLVM_RUNTIMES_GPU_BUILD=YES"
 	fi
 fi
 
@@ -190,18 +217,19 @@ configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" llvm19-cross-tools "
 
-	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/usr/bin"
-	configure_args+=" -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen"
-	configure_args+=" -DCLANG_TABLEGEN=/usr/bin/clang-tblgen"
-	configure_args+=" -DMLIR_TABLEGEN=/usr/bin/mlir-tblgen"
-	configure_args+=" -DMLIR_PDLL_TABLEGEN=/usr/bin/mlir-pdll"
-	configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/usr/bin/mlir-linalg-ods-yaml-gen"
-	configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/usr/bin/mlir-src-sharder"
-	configure_args+=" -DFLANG_NEW_EXE=/usr/bin/flang-new"
-	configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/usr/bin/clang-tidy-confusable-chars-gen"
-	configure_args+=" -DCLANG_PSEUDO_GEN=/usr/bin/clang-pseudo-gen"
-	configure_args+=" -DLLVM_CONFIG_PATH=/usr/bin/llvm-config"
-	configure_args+=" -DLLDB_TABLEGEN_EXE=/usr/bin/lldb-tblgen"
+	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
+	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
+	configure_args+=" -DLLVM_TABLEGEN=/${_llvm_bindir}/llvm-tblgen"
+	configure_args+=" -DCLANG_TABLEGEN=/${_llvm_bindir}/clang-tblgen"
+	configure_args+=" -DMLIR_TABLEGEN=/${_llvm_bindir}/mlir-tblgen"
+	configure_args+=" -DMLIR_PDLL_TABLEGEN=/${_llvm_bindir}/mlir-pdll"
+	configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/${_llvm_bindir}/mlir-linalg-ods-yaml-gen"
+	configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/${_llvm_bindir}/mlir-src-sharder"
+	configure_args+=" -DFLANG_NEW_EXE=/${_llvm_bindir}/flang-new"
+	configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/${_llvm_bindir}/clang-tidy-confusable-chars-gen"
+	configure_args+=" -DCLANG_PSEUDO_GEN=/${_llvm_bindir}/clang-pseudo-gen"
+	configure_args+=" -DLLVM_CONFIG_PATH=/${_llvm_bindir}/llvm-config"
+	configure_args+=" -DLLDB_TABLEGEN_EXE=/${_llvm_bindir}/lldb-tblgen"
 
 	configure_args+=" -DLIBOMP_OMPD_GDB_SUPPORT=NO"
 fi
@@ -255,42 +283,41 @@ configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${_triplet}"
 post_extract() {
 	if [ "$build_option_llvm_spirv" ]; then
 		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_commit}.tar.gz
-		# vsrcextract -C ${wrksrc}/llvm/tools ${_spirv_commit}.tar.gz
 	fi
 }
 
 post_patch() {
-	if [ "$build_option_lldb" ]; then
-		if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
-			vsed -i 's|__ptrace_request|int|g' \
-				${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
-		fi
+# 	if [ "$build_option_lldb" ]; then
+# 		if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+# 			vsed -i 's|__ptrace_request|int|g' \
+# 				${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+# 		fi
 		# disable docs for lldb as they fail to generate
 		vsed -i '/add_subdirectory(docs)/d' \
 			${wrksrc}/lldb/CMakeLists.txt
-	fi
-
-	# update config.guess for better platform detection
-	cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
-		${wrksrc}/llvm/cmake
-
-	# fix linker failures on some archs
-	vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
-		${wrksrc}/libcxxabi/cmake/config-ix.cmake
-	vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
-		${wrksrc}/libcxxabi/cmake/config-ix.cmake
-
-	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
-	case "$XBPS_TARGET_MACHINE" in
-		ppc64*) ;;
-		ppc*-musl|i686-musl|mips*-musl)
-			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
-				${wrksrc}/libunwind/src/CMakeLists.txt
-			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
-				${wrksrc}/libcxxabi/src/CMakeLists.txt
-			vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
-			;;
-	esac
+# 	fi
+
+# 	# update config.guess for better platform detection
+# 	cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
+# 		${wrksrc}/llvm/cmake
+
+# 	# fix linker failures on some archs
+# 	vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
+# 		${wrksrc}/libcxxabi/cmake/config-ix.cmake
+# 	vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
+# 		${wrksrc}/libcxxabi/cmake/config-ix.cmake
+
+# 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+# 	case "$XBPS_TARGET_MACHINE" in
+# 		ppc64*) ;;
+# 		ppc*-musl|i686-musl|mips*-musl)
+# 			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+# 				${wrksrc}/libunwind/src/CMakeLists.txt
+# 			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+# 				${wrksrc}/libcxxabi/src/CMakeLists.txt
+# 			vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+# 			;;
+# 	esac
 }
 
 pre_configure() {
@@ -334,7 +361,6 @@ post_build() {
 		-DSPHINX_WARNINGS_AS_ERRORS=OFF
 
 	ninja ${makejobs} -C ${wrksrc}/${build_wrksrc}/runtimes-doc docs-libcxx-html docs-libunwind-html
-
 }
 
 post_install() {
@@ -342,15 +368,15 @@ post_install() {
 	# Required for multilib.
 	if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
 		for _header in llvm-config; do
-			mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
+			mv ${DESTDIR}/${_llvm_incdir}/llvm/Config/${_header}{,-64}.h
 			vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
-				usr/include/llvm/Config ${_header}.h
+				${_llvm_incdir}/llvm/Config ${_header}.h
 		done
 	fi
 
 	# Remove llvm-config-host in cross builds.
 	if [ "$CROSS_BUILD" ]; then
-		rm -f ${DESTDIR}/usr/bin/llvm-config-host
+		rm -f ${DESTDIR}/${_llvm_bindir}/llvm-config-host
 	fi
 
 	rm -rf ${DESTDIR}/usr/share/gdb
@@ -387,9 +413,8 @@ post_install() {
 	# Can this be disabled some other way?
 	rm -f ${DESTDIR}/usr/lib64
 
-	if [ "$build_option_llvm_spirv" ]; then
-		mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-19
-	fi
+	vmkdir usr/lib/clang
+	ln -s ../llvm/19/lib/clang/19 ${DESTDIR}/usr/lib/clang/19
 }
 
 clang19_package() {
@@ -399,36 +424,76 @@ clang19_package() {
 	conflicts="clang18>=0 clang17>=0 clang15>=0"
 	short_desc+=" - C language family frontend"
 	homepage="https://clang.llvm.org/"
+	alternatives="
+	 clang:/usr/share/man/man1/clang.1:/${_llvm_mandir}/man1/clang.1
+	 clang:/usr/share/man/man1/diagtool.1:/${_llvm_mandir}/man1/diagtool.1
+	"
+	_clang19_files=( \
+		bin/clang-19 \
+		bin/clang \
+		bin/clang++ \
+		bin/clang-cl \
+		bin/clang-cpp \
+		bin/clang-check \
+		bin/clang-extdef-mapping \
+		bin/clang-format \
+		bin/git-clang-format \
+		bin/clang-linker-wrapper \
+		bin/clang-offload-bundler \
+		bin/clang-offload-packager \
+		bin/clang-refactor \
+		bin/clang-rename \
+		bin/clang-repl \
+		bin/clang-scan-deps \
+		bin/clang-tblgen \
+		bin/c-index-test \
+		bin/diagtool \
+		bin/amdgpu-arch \
+		bin/nvptx-arch \
+		bin/hmaptool \
+	)
+
+	for _alt in "${_clang19_files[@]}"; do
+		alternatives+=" clang:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
+
+	if [ "$build_option_polly" ]; then
+		alternatives+=" clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1"
+	fi
 	pkg_install() {
-		vmove usr/bin/clang-19
-		vmove usr/bin/clang
-		vmove usr/bin/clang++
-		vmove usr/bin/clang-cl
-		vmove usr/bin/clang-cpp
-		vmove usr/bin/clang-check
-		vmove usr/bin/clang-extdef-mapping
-		vmove usr/bin/clang-format
-		vmove usr/bin/git-clang-format
-		vmove usr/bin/clang-linker-wrapper
-		vmove usr/bin/clang-offload-bundler
-		vmove usr/bin/clang-offload-packager
-		vmove usr/bin/clang-refactor
-		vmove usr/bin/clang-rename
-		vmove usr/bin/clang-repl
-		vmove usr/bin/clang-scan-deps
-		vmove usr/bin/clang-tblgen
-		vmove usr/bin/c-index-test
-		vmove usr/bin/diagtool
-		vmove usr/bin/amdgpu-arch
-		vmove usr/bin/nvptx-arch
-		vmove usr/bin/hmaptool
-
-		vmove usr/share/man/man1/clang.1
-		vmove usr/share/man/man1/diagtool.1
+		for _bin in "${_clang19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_bin}
+		done
+		vmove ${_llvm_mandir}/man1/clang.1
+		vmove ${_llvm_mandir}/man1/diagtool.1
 		if [ "$build_option_polly" ]; then
-			vmove usr/lib/LLVMPolly.so
-			vmove usr/share/man/man1/polly.1
+			vmove ${_llvm_libdir}/LLVMPolly.so
+			vmove ${_llvm_mandir}/man1/polly.1
 		fi
+
+		# vmove ${_llvm_bindir}/clang-19
+		# vmove ${_llvm_bindir}/clang
+		# vmove ${_llvm_bindir}/clang++
+		# vmove ${_llvm_bindir}/clang-cl
+		# vmove ${_llvm_bindir}/clang-cpp
+		# vmove ${_llvm_bindir}/clang-check
+		# vmove ${_llvm_bindir}/clang-extdef-mapping
+		# vmove ${_llvm_bindir}/clang-format
+		# vmove ${_llvm_bindir}/git-clang-format
+		# vmove ${_llvm_bindir}/clang-linker-wrapper
+		# vmove ${_llvm_bindir}/clang-offload-bundler
+		# vmove ${_llvm_bindir}/clang-offload-packager
+		# vmove ${_llvm_bindir}/clang-refactor
+		# vmove ${_llvm_bindir}/clang-rename
+		# vmove ${_llvm_bindir}/clang-repl
+		# vmove ${_llvm_bindir}/clang-scan-deps
+		# vmove ${_llvm_bindir}/clang-tblgen
+		# vmove ${_llvm_bindir}/c-index-test
+		# vmove ${_llvm_bindir}/diagtool
+		# vmove ${_llvm_bindir}/amdgpu-arch
+		# vmove ${_llvm_bindir}/nvptx-arch
+		# vmove ${_llvm_bindir}/hmaptool
+
 	}
 }
 
@@ -437,7 +502,8 @@ clang19-headers_package() {
 	short_desc+=" - C language family frontend - Headers"
 	homepage="https://clang.llvm.org/"
 	pkg_install() {
-		vmove usr/lib/clang/19/include
+		vmove ${_llvm_libdir}/clang/19/include
+		vmove usr/lib/clang
 	}
 }
 
@@ -453,21 +519,21 @@ clang19-devel_package() {
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
 	pkg_install() {
-		vmove usr/include/clang
-		vmove usr/include/clang-c
-		vmove usr/lib/libear
-		vmove usr/lib/cmake/clang
-		vmove "usr/lib/libclang*.a"
-		vmove "usr/lib/libclang*.so"
-		vmove usr/share/clang
+		vmove ${_llvm_incdir}/clang
+		vmove ${_llvm_incdir}/clang-c
+		vmove ${_llvm_libdir}/libear
+		vmove ${_llvm_libdir}/cmake/clang
+		vmove "${_llvm_libdir}/libclang*.a"
+		vmove "${_llvm_libdir}/libclang*.so"
+		vmove ${_llvm_datadir}/clang
 		if [ "$build_option_clang_tools_extra" ]; then
-			vmove usr/include/clang-tidy
-			vmove usr/lib/libfindAllSymbols.a
+			vmove ${_llvm_incdir}/clang-tidy
+			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
-			vmove usr/include/polly
-			vmove usr/lib/cmake/polly
-			vmove "usr/lib/libPolly*.a"
+			vmove ${_llvm_incdir}/polly
+			vmove ${_llvm_libdir}/cmake/polly
+			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
 	}
 }
@@ -476,7 +542,7 @@ libclang19_package() {
 	depends="clang19-headers>=${version}_${revision}"
 	short_desc+=" - C frontend library"
 	pkg_install() {
-		vmove "usr/lib/libclang.so.*"
+		vmove "${_llvm_libdir}/libclang.so.*"
 	}
 }
 
@@ -484,7 +550,7 @@ libclang-cpp19_package() {
 	depends="clang19-headers>=${version}_${revision}"
 	short_desc+=" - C frontend library (C++ interface)"
 	pkg_install() {
-		vmove "usr/lib/libclang-cpp.so.*"
+		vmove "${_llvm_libdir}/libclang-cpp.so.*"
 	}
 }
 
@@ -493,22 +559,44 @@ clang-analyzer19_package() {
 	conflicts="clang-analyzer18>=0 clang-analyzer17>=0 clang-analyzer15>=0"
 	short_desc+=" - A source code analysis framework"
 	homepage="https://clang-analyzer.llvm.org/"
-	pycompile_dirs="usr/share/scan-view"
+	pycompile_dirs="${_llvm_datadir}/scan-view"
+	_clang_analyzer19_files=(  \
+		share/scan-view \
+		share/scan-build \
+		lib/libscanbuild \
+		libexec/analyze-c++ \
+		libexec/analyze-cc \
+		libexec/intercept-c++ \
+		libexec/intercept-cc \
+		libexec/c++-analyzer \
+		libexec/ccc-analyzer \
+		share/man/man1/scan-build.1 \
+		bin/analyze-build \
+		bin/scan-build \
+		bin/scan-build-py \
+		bin/scan-view \
+	)
+	for _alt in "${_clang_analyzer19_files[@]}"; do
+		alternatives+=" clang-analyzer:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove usr/share/scan-view
-		vmove usr/share/scan-build
-		vmove usr/lib/libscanbuild
-		vmove usr/libexec/analyze-c++
-		vmove usr/libexec/analyze-cc
-		vmove usr/libexec/intercept-c++
-		vmove usr/libexec/intercept-cc
-		vmove usr/libexec/c++-analyzer
-		vmove usr/libexec/ccc-analyzer
-		vmove usr/share/man/man1/scan-build.1
-		vmove usr/bin/analyze-build
-		vmove usr/bin/scan-build
-		vmove usr/bin/scan-build-py
-		vmove usr/bin/scan-view
+		for _f in "${_clang_analyzer19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+		# vmove ${_llvm_datadir}/scan-view
+		# vmove ${_llvm_datadir}/scan-build
+		# vmove ${_llvm_libdir}/libscanbuild
+		# vmove ${_llvm_libexecdir}/analyze-c++
+		# vmove ${_llvm_libexecdir}/analyze-cc
+		# vmove ${_llvm_libexecdir}/intercept-c++
+		# vmove ${_llvm_libexecdir}/intercept-cc
+		# vmove ${_llvm_libexecdir}/c++-analyzer
+		# vmove ${_llvm_libexecdir}/ccc-analyzer
+		# vmove ${_llvm_mandir}/man1/scan-build.1
+		# vmove ${_llvm_bindir}/analyze-build
+		# vmove ${_llvm_bindir}/scan-build
+		# vmove ${_llvm_bindir}/scan-build-py
+		# vmove ${_llvm_bindir}/scan-view
 	}
 }
 
@@ -518,23 +606,49 @@ clang-tools-extra19_package() {
 	conflicts="clang-tools-extra18>=0 clang-tools-extra17>=0 clang-tools-extra15>=0"
 	short_desc+=" - Extra Clang tools"
 	homepage="https://clang.llvm.org/extra/"
+	_clang_tools_extra19_files=( \
+		bin/clang-apply-replacements \
+		bin/clang-change-namespace \
+		bin/clang-doc \
+		bin/clang-include-cleaner \
+		bin/clang-include-fixer \
+		bin/clang-move \
+		bin/clang-pseudo \
+		bin/clang-query \
+		bin/clang-reorder-fields \
+		bin/clang-tidy \
+		bin/clangd \
+		bin/find-all-symbols \
+		bin/modularize \
+		bin/pp-trace \
+		bin/run-clang-tidy \
+		share/man/man1/extraclangtools.1 \
+	)
+
+	for _alt in "${_clang_tools_extra19_files[@]}"; do
+		alternatives+=" clang-tools-extra:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove usr/bin/clang-apply-replacements
-		vmove usr/bin/clang-change-namespace
-		vmove usr/bin/clang-doc
-		vmove usr/bin/clang-include-cleaner
-		vmove usr/bin/clang-include-fixer
-		vmove usr/bin/clang-move
-		vmove usr/bin/clang-pseudo
-		vmove usr/bin/clang-query
-		vmove usr/bin/clang-reorder-fields
-		vmove usr/bin/clang-tidy
-		vmove usr/bin/clangd
-		vmove usr/bin/find-all-symbols
-		vmove usr/bin/modularize
-		vmove usr/bin/pp-trace
-		vmove usr/bin/run-clang-tidy
-		vmove usr/share/man/man1/extraclangtools.1
+		for _f in "${_clang_tools_extra19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+		# vmove ${_llvm_bindir}/clang-apply-replacements
+		# vmove ${_llvm_bindir}/clang-change-namespace
+		# vmove ${_llvm_bindir}/clang-doc
+		# vmove ${_llvm_bindir}/clang-include-cleaner
+		# vmove ${_llvm_bindir}/clang-include-fixer
+		# vmove ${_llvm_bindir}/clang-move
+		# vmove ${_llvm_bindir}/clang-pseudo
+		# vmove ${_llvm_bindir}/clang-query
+		# vmove ${_llvm_bindir}/clang-reorder-fields
+		# vmove ${_llvm_bindir}/clang-tidy
+		# vmove ${_llvm_bindir}/clangd
+		# vmove ${_llvm_bindir}/find-all-symbols
+		# vmove ${_llvm_bindir}/modularize
+		# vmove ${_llvm_bindir}/pp-trace
+		# vmove ${_llvm_bindir}/run-clang-tidy
+
+		# vmove ${_llvm_mandir}/man1/extraclangtools.1
 	}
 }
 
@@ -546,16 +660,16 @@ llvm-bolt19_package() {
 	short_desc+=" - post-link optimizer"
 	homepage="https://github.com/llvm/llvm-project/tree/main/bolt"
 	pkg_install() {
-		vmove usr/bin/llvm-bolt
-		vmove usr/bin/perf2bolt
-		vmove usr/bin/llvm-boltdiff
-		vmove usr/bin/merge-fdata
-		vmove usr/bin/llvm-bolt-heatmap
+		vmove ${_llvm_bindir}/llvm-bolt
+		vmove ${_llvm_bindir}/perf2bolt
+		vmove ${_llvm_bindir}/llvm-boltdiff
+		vmove ${_llvm_bindir}/merge-fdata
+		vmove ${_llvm_bindir}/llvm-bolt-heatmap
 		if [ -z "$CROSS_BUILD" ]; then
 			case "$XBPS_TARGET_MACHINE" in
-				x86_64*|aarch64*)
-					vmove usr/lib/libbolt_rt_instr.a
-					vmove usr/lib/libbolt_rt_hugify.a
+				x86_64*|aarch64*|riscv64*)
+					vmove ${_llvm_libdir}/libbolt_rt_instr.a
+					vmove ${_llvm_libdir}/libbolt_rt_hugify.a
 				;;
 			esac
 		fi
@@ -569,14 +683,14 @@ lldb19_package() {
 	short_desc+=" - LLDB debugger"
 	homepage="https://lldb.llvm.org/"
 	pkg_install() {
-		vmove usr/bin/lldb
-		vmove usr/bin/lldb-argdumper
-		vmove usr/bin/lldb-instr
-		vmove usr/bin/lldb-server
-		vmove usr/bin/lldb-dap
-		vmove "usr/lib/python${py3_ver}/site-packages/lldb"
+		vmove ${_llvm_bindir}/lldb
+		vmove ${_llvm_bindir}/lldb-argdumper
+		vmove ${_llvm_bindir}/lldb-instr
+		vmove ${_llvm_bindir}/lldb-server
+		vmove ${_llvm_bindir}/lldb-dap
+		vmove "${_llvm_libdir}/python${py3_ver}/site-packages/lldb"
 		if [ -z "$CROSS_BUILD" ]; then
-			vmove /usr/lib/lua/5.3/lldb.so
+			vmove ${_llvm_libdir}/lua/5.3/lldb.so
 		fi
 	}
 }
@@ -587,8 +701,8 @@ lldb19-devel_package() {
 	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
 	short_desc+=" - LLDB debugger - development files"
 	pkg_install() {
-		vmove usr/include/lldb
-		vmove "usr/lib/liblldb*.so"
+		vmove ${_llvm_incdir}/lldb
+		vmove "${_llvm_libdir}/liblldb*.so"
 	}
 }
 
@@ -596,7 +710,7 @@ liblldb19_package() {
 	lib32disabled=yes
 	short_desc+=" - LLDB debugger - runtime library"
 	pkg_install() {
-		vmove "usr/lib/liblldb*.so.*"
+		vmove "${_llvm_libdir}/liblldb*.so.*"
 	}
 }
 
@@ -605,12 +719,25 @@ lld19_package() {
 	conflicts="lld18>=0 lld17>=0 lld15>=0"
 	short_desc+=" - linker"
 	homepage="https://lld.llvm.org"
+	_lld19_files=(  \
+		bin/lld \
+		bin/lld-link \
+		bin/ld.lld \
+		bin/ld64.lld \
+		bin/wasm-ld \
+	)
+	for _alt in "${_lld19_files[@]}"; do
+		alternatives+=" lld:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove usr/bin/lld
-		vmove usr/bin/lld-link
-		vmove usr/bin/ld.lld
-		vmove usr/bin/ld64.lld
-		vmove usr/bin/wasm-ld
+		for _f in "${_lld19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+		# vmove ${_llvm_bindir}/lld
+		# vmove ${_llvm_bindir}/lld-link
+		# vmove ${_llvm_bindir}/ld.lld
+		# vmove ${_llvm_bindir}/ld64.lld
+		# vmove ${_llvm_bindir}/wasm-ld
 	}
 }
 
@@ -621,9 +748,9 @@ lld19-devel_package() {
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
 	pkg_install() {
-		vmove usr/include/lld
-		vmove usr/lib/cmake/lld
-		vmove "usr/lib/liblld*.a"
+		vmove ${_llvm_incdir}/lld
+		vmove ${_llvm_libdir}/cmake/lld
+		vmove "${_llvm_libdir}/liblld*.a"
 	}
 }
 
@@ -632,8 +759,8 @@ mlir19_package() {
 	short_desc+=" - multi-level IR compiler framework"
 	homepage="https://mlir.llvm.org/"
 	pkg_install() {
-		vmove "usr/lib/libMLIR*.so.*"
-		vmove "usr/lib/libmlir*.so.*"
+		vmove "${_llvm_libdir}/libMLIR*.so.*"
+		vmove "${_llvm_libdir}/libmlir*.so.*"
 	}
 }
 
@@ -644,15 +771,15 @@ mlir19-devel_package() {
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
 	pkg_install() {
-		vmove "usr/bin/mlir*"
-		vmove usr/bin/tblgen-lsp-server
-		vmove usr/include/mlir
-		vmove usr/include/mlir-c
-		vmove usr/lib/cmake/mlir
-		vmove "usr/lib/libMLIR*"
-		vmove "usr/lib/objects-Release/obj.MLIR*"
-		vmove "usr/lib/libmlir*"
-		vmove usr/share/man/man1/mlir-tblgen.1
+		vmove "${_llvm_bindir}/mlir*"
+		vmove ${_llvm_bindir}/tblgen-lsp-server
+		vmove ${_llvm_incdir}/mlir
+		vmove ${_llvm_incdir}/mlir-c
+		vmove ${_llvm_libdir}/cmake/mlir
+		vmove "${_llvm_libdir}/libMLIR*"
+		vmove "${_llvm_libdir}/objects-Release/obj.MLIR*"
+		vmove "${_llvm_libdir}/libmlir*"
+		vmove ${_llvm_mandir}/man1/mlir-tblgen.1
 	}
 }
 
@@ -663,7 +790,7 @@ flang19_package() {
 	short_desc+=" - Fortran language frontend"
 	homepage="https://flang.llvm.org/"
 	pkg_install() {
-		vmove usr/bin/flang-new
+		vmove ${_llvm_bindir}/flang-new
 	}
 }
 
@@ -674,17 +801,17 @@ flang19-devel_package() {
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
 	pkg_install() {
-		vmove usr/bin/bbc
-		vmove usr/bin/f18-parse-demo
-		vmove usr/bin/fir-opt
-		vmove usr/bin/tco
-		vmove usr/include/flang
-		vmove usr/lib/cmake/flang
-		vmove "usr/lib/libflang*.a"
-		vmove "usr/lib/libFIR*.a"
-		vmove "usr/lib/libHLFIR*.a"
-		vmove "usr/lib/libFortran*.a"
-		vmove "usr/lib/libCUF*.a"
+		vmove ${_llvm_bindir}/bbc
+		vmove ${_llvm_bindir}/f18-parse-demo
+		vmove ${_llvm_bindir}/fir-opt
+		vmove ${_llvm_bindir}/tco
+		vmove ${_llvm_incdir}/flang
+		vmove ${_llvm_libdir}/cmake/flang
+		vmove "${_llvm_libdir}/libflang*.a"
+		vmove "${_llvm_libdir}/libFIR*.a"
+		vmove "${_llvm_libdir}/libHLFIR*.a"
+		vmove "${_llvm_libdir}/libFortran*.a"
+		vmove "${_llvm_libdir}/libCUF*.a"
 	}
 }
 
@@ -692,7 +819,7 @@ libomp19_package() {
 	short_desc+=" - Clang OpenMP support library"
 	conflicts="libomp18>=0 libomp17>=0"
 	pkg_install() {
-		vmove "usr/lib/libomp*.so"
+		vmove "${_llvm_libdir}/libomp*.so"
 	}
 }
 
@@ -701,27 +828,24 @@ libomp19-devel_package() {
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
 	pkg_install() {
-		if [ -f "${DESTDIR}/usr/bin/llvm-omp-device-info" ]; then
-			vmove usr/bin/llvm-omp-device-info
+		if [ -f "${DESTDIR}/${_llvm_bindir}/llvm-omp-device-info" ]; then
+			vmove ${_llvm_bindir}/llvm-omp-device-info
 		fi
-		if [ -f "${DESTDIR}/usr/bin/llvm-omp-kernel-replay" ]; then
-			vmove usr/bin/llvm-omp-kernel-replay
+		if [ -f "${DESTDIR}/${_llvm_bindir}/llvm-omp-kernel-replay" ]; then
+			vmove ${_llvm_bindir}/llvm-omp-kernel-replay
 		fi
-		if [ -f "${DESTDIR}/usr/lib/libarcher.so" ]; then
-			vmove "usr/lib/libarcher*.so"
+		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
+			vmove "${_llvm_libdir}/libarcher*.so"
 		fi
-		if [ -f "${DESTDIR}/usr/lib/libarcher_static.a" ]; then
-			vmove "usr/lib/libarcher*.a"
+		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher_static.a" ]; then
+			vmove "${_llvm_libdir}/libarcher*.a"
 		fi
 
-		vmove usr/lib/cmake/openmp
-		if [ -f "${DESTDIR}/usr/share/man/man1/llvmopenmp.1" ]; then
-			vmove usr/share/man/man1/llvmopenmp.1
-		fi
+		vmove ${_llvm_libdir}/cmake/openmp
 
 		if [ "$build_option_offload" ]; then
-			vmove "usr/lib/libomptarget*.bc"
-			vmove "usr/lib/libomp*.a"
+			vmove "${_llvm_libdir}/libomptarget*.bc"
+			vmove "${_llvm_libdir}/libomp*.a"
 		fi
 	}
 }
@@ -783,14 +907,15 @@ libcxx-devel_package() {
 
 compiler-rt19_package() {
 	short_desc+=" - runtime libraries"
+	depends="clang19-headers>=${version}_${revision}"
 	homepage="https://compiler-rt.llvm.org/"
 	pkg_install() {
-		vmove usr/lib/clang/19/lib
-		if [ -d "${DESTDIR}/usr/lib/clang/19/bin" ]; then
-			vmove usr/lib/clang/19/bin
+		vmove ${_llvm_libdir}/clang/19/lib
+		if [ -d "${DESTDIR}/${_llvm_libdir}/clang/19/bin" ]; then
+			vmove ${_llvm_libdir}/clang/19/bin
 		fi
-		if [ -d "${DESTDIR}/usr/lib/clang/19/share" ]; then
-			vmove usr/lib/clang/19/share
+		if [ -d "${DESTDIR}/${_llvm_libdir}/clang/19/share" ]; then
+			vmove ${_llvm_libdir}/clang/19/share
 		fi
 	}
 }
@@ -798,8 +923,8 @@ compiler-rt19_package() {
 libllvm19_package() {
 	short_desc+=" - library"
 	pkg_install() {
-		vmove "usr/lib/libLLVM-*.so"
-		vmove "usr/lib/libLLVM.so.*"
+		vmove "${_llvm_libdir}/libLLVM-*.so"
+		vmove "${_llvm_libdir}/libLLVM.so.*"
 	}
 }
 
@@ -807,6 +932,7 @@ llvm19-doc_package() {
 	short_desc+=" - documentation"
 	pkg_install() {
 		vmove usr/share/doc
+		vmove ${_llvm_datadir}/doc
 	}
 }
 
@@ -827,13 +953,13 @@ llvm19-devel_package() {
 		depends+=" SPIRV-LLVM-Translator19-devel>=${version}_${revision} "
 	fi
 	pkg_install() {
-		vmove usr/lib/libLLVM.so
-		vmove usr/lib/libLTO.so
-		vmove usr/lib/libRemarks.so
-		vmove usr/include/llvm
-		vmove usr/include/llvm-c
-		vmove "usr/lib/libLLVM*.a"
-		vmove usr/lib/cmake/llvm
+		vmove ${_llvm_libdir}/libLLVM.so
+		vmove ${_llvm_libdir}/libLTO.so
+		vmove ${_llvm_libdir}/libRemarks.so
+		vmove ${_llvm_incdir}/llvm
+		vmove ${_llvm_incdir}/llvm-c
+		vmove "${_llvm_libdir}/libLLVM*.a"
+		vmove ${_llvm_libdir}/cmake/llvm
 	}
 }
 
@@ -845,10 +971,11 @@ llvm19-cross-tools_package() {
 	 lld19-devel>=${version}_${revision} flang19-devel>=${version}_${revision}"
 	pkg_install() {
 		# Binaries ONLY used during the process of building llvm, and aren't usually installed
-		vbin build/bin/lldb-tblgen
-		vbin build/bin/clang-tidy-confusable-chars-gen
-		vbin build/bin/clang-pseudo-gen
-		vbin build/bin/mlir-src-sharder
+		vmkdir ${_llvm_bindir}
+		vcopy build/bin/lldb-tblgen ${_llvm_bindir}
+		vcopy build/bin/clang-tidy-confusable-chars-gen ${_llvm_bindir}
+		vcopy build/bin/clang-pseudo-gen ${_llvm_bindir}
+		vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 	}
 }
 
@@ -856,17 +983,18 @@ libclc19_package() {
 	short_desc+=" - Open implementation of the OpenCL C programming language"
 	replaces="libclc-git>=0"
 	pkg_install() {
-		vmove usr/share/clc
-		vmove usr/include/clc
-		vmove usr/share/pkgconfig/libclc.pc
+		vmove ${_llvm_datadir}/clc
+		vmove ${_llvm_incdir}/clc
+		vmove ${_llvm_datadir}/pkgconfig/libclc.pc
 	}
 }
 
 SPIRV-LLVM-Translator19_package() {
 	short_desc+=" - API and commands for processing SPIR-V modules"
-	alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-19"
+	alternatives="llvm-spirv:/usr/bin/llvm-spirv:/${_llvm_bindir}/llvm-spirv"
 	pkg_install() {
-		vmove usr/bin/llvm-spirv-19
+		patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
+		vmove ${_llvm_bindir}/llvm-spirv
 	}
 }
 
@@ -874,8 +1002,164 @@ SPIRV-LLVM-Translator19-devel_package() {
 	depends="SPIRV-LLVM-Translator19>=${version}_${revision}"
 	short_desc+=" - API and commands for processing SPIR-V modules - development files"
 	pkg_install() {
-		vmove usr/include/LLVMSPIRVLib
-		vmove usr/lib/pkgconfig/LLVMSPIRVLib.pc
-		vmove "usr/lib/libLLVMSPIRV*.a"
+		vmove ${_llvm_incdir}/LLVMSPIRVLib
+		vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
+		vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
 	}
 }
+
+_llvm_alts=( \
+	bin/FileCheck \
+	bin/UnicodeNameMappingGenerator \
+	bin/bugpoint \
+	bin/clang-installapi \
+	bin/clang-nvlink-wrapper \
+	bin/count \
+	bin/dsymutil \
+	bin/intercept-build \
+	bin/llc \
+	bin/lli \
+	bin/lli-child-target \
+	bin/llvm-PerfectShuffle \
+	bin/llvm-ar \
+	bin/llvm-as \
+	bin/llvm-bcanalyzer \
+	bin/llvm-c-test \
+	bin/llvm-cat \
+	bin/llvm-cfi-verify \
+	bin/llvm-cgdata \
+	bin/llvm-config \
+	bin/llvm-cov \
+	bin/llvm-cvtres \
+	bin/llvm-cxxdump \
+	bin/llvm-cxxfilt \
+	bin/llvm-cxxmap \
+	bin/llvm-debuginfo-analyzer \
+	bin/llvm-debuginfod \
+	bin/llvm-debuginfod-find \
+	bin/llvm-diff \
+	bin/llvm-dis \
+	bin/llvm-dwarfdump \
+	bin/llvm-dwarfutil \
+	bin/llvm-dwp \
+	bin/llvm-exegesis \
+	bin/llvm-extract \
+	bin/llvm-gsymutil \
+	bin/llvm-ifs \
+	bin/llvm-jitlink \
+	bin/llvm-jitlink-executor \
+	bin/llvm-libtool-darwin \
+	bin/llvm-link \
+	bin/llvm-lipo \
+	bin/llvm-lto \
+	bin/llvm-lto2 \
+	bin/llvm-mc \
+	bin/llvm-mca \
+	bin/llvm-ml \
+	bin/llvm-modextract \
+	bin/llvm-mt \
+	bin/llvm-nm \
+	bin/llvm-objcopy \
+	bin/llvm-objdump \
+	bin/llvm-opt-report \
+	bin/llvm-pdbutil \
+	bin/llvm-profdata \
+	bin/llvm-profgen \
+	bin/llvm-rc \
+	bin/llvm-readobj \
+	bin/llvm-readtapi \
+	bin/llvm-reduce \
+	bin/llvm-remarkutil \
+	bin/llvm-rtdyld \
+	bin/llvm-sim \
+	bin/llvm-size \
+	bin/llvm-split \
+	bin/llvm-stress \
+	bin/llvm-strings \
+	bin/llvm-symbolizer \
+	bin/llvm-tblgen \
+	bin/llvm-tli-checker \
+	bin/llvm-undname \
+	bin/llvm-xray \
+	bin/not \
+	bin/obj2yaml \
+	bin/opt \
+	bin/prepare_builtins \
+	bin/reduce-chunk-list \
+	bin/sancov \
+	bin/sanstats \
+	bin/split-file \
+	bin/tblgen-to-irdl \
+	bin/verify-uselistorder \
+	bin/yaml-bench \
+	bin/yaml2obj \
+	bin/llvm-addr2line \
+	bin/llvm-bitcode-strip \
+	bin/llvm-dlltool \
+	bin/llvm-install-name-tool \
+	bin/llvm-lib \
+	bin/llvm-otool \
+	bin/llvm-ranlib \
+	bin/llvm-readelf \
+	bin/llvm-strip \
+	bin/llvm-windres \
+)
+# /usr/lib/llvm/19/share/man/man1/FileCheck.1
+# /usr/lib/llvm/19/share/man/man1/bugpoint.1
+# /usr/lib/llvm/19/share/man/man1/clang-tblgen.1
+# /usr/lib/llvm/19/share/man/man1/dsymutil.1
+# /usr/lib/llvm/19/share/man/man1/lit.1
+# /usr/lib/llvm/19/share/man/man1/llc.1
+# /usr/lib/llvm/19/share/man/man1/lldb-tblgen.1
+# /usr/lib/llvm/19/share/man/man1/lli.1
+# /usr/lib/llvm/19/share/man/man1/llvm-addr2line.1
+# /usr/lib/llvm/19/share/man/man1/llvm-ar.1
+# /usr/lib/llvm/19/share/man/man1/llvm-as.1
+# /usr/lib/llvm/19/share/man/man1/llvm-bcanalyzer.1
+# /usr/lib/llvm/19/share/man/man1/llvm-config.1
+# /usr/lib/llvm/19/share/man/man1/llvm-cov.1
+# /usr/lib/llvm/19/share/man/man1/llvm-cxxfilt.1
+# /usr/lib/llvm/19/share/man/man1/llvm-cxxmap.1
+# /usr/lib/llvm/19/share/man/man1/llvm-debuginfo-analyzer.1
+# /usr/lib/llvm/19/share/man/man1/llvm-diff.1
+# /usr/lib/llvm/19/share/man/man1/llvm-dis.1
+# /usr/lib/llvm/19/share/man/man1/llvm-dwarfdump.1
+# /usr/lib/llvm/19/share/man/man1/llvm-dwarfutil.1
+# /usr/lib/llvm/19/share/man/man1/llvm-exegesis.1
+# /usr/lib/llvm/19/share/man/man1/llvm-extract.1
+# /usr/lib/llvm/19/share/man/man1/llvm-ifs.1
+# /usr/lib/llvm/19/share/man/man1/llvm-install-name-tool.1
+# /usr/lib/llvm/19/share/man/man1/llvm-lib.1
+# /usr/lib/llvm/19/share/man/man1/llvm-libtool-darwin.1
+# /usr/lib/llvm/19/share/man/man1/llvm-link.1
+# /usr/lib/llvm/19/share/man/man1/llvm-lipo.1
+# /usr/lib/llvm/19/share/man/man1/llvm-locstats.1
+# /usr/lib/llvm/19/share/man/man1/llvm-mc.1
+# /usr/lib/llvm/19/share/man/man1/llvm-mca.1
+# /usr/lib/llvm/19/share/man/man1/llvm-nm.1
+# /usr/lib/llvm/19/share/man/man1/llvm-objcopy.1
+# /usr/lib/llvm/19/share/man/man1/llvm-objdump.1
+# /usr/lib/llvm/19/share/man/man1/llvm-opt-report.1
+# /usr/lib/llvm/19/share/man/man1/llvm-otool.1
+# /usr/lib/llvm/19/share/man/man1/llvm-pdbutil.1
+# /usr/lib/llvm/19/share/man/man1/llvm-profdata.1
+# /usr/lib/llvm/19/share/man/man1/llvm-profgen.1
+# /usr/lib/llvm/19/share/man/man1/llvm-ranlib.1
+# /usr/lib/llvm/19/share/man/man1/llvm-readelf.1
+# /usr/lib/llvm/19/share/man/man1/llvm-readobj.1
+# /usr/lib/llvm/19/share/man/man1/llvm-reduce.1
+# /usr/lib/llvm/19/share/man/man1/llvm-remarkutil.1
+# /usr/lib/llvm/19/share/man/man1/llvm-size.1
+# /usr/lib/llvm/19/share/man/man1/llvm-stress.1
+# /usr/lib/llvm/19/share/man/man1/llvm-strings.1
+# /usr/lib/llvm/19/share/man/man1/llvm-strip.1
+# /usr/lib/llvm/19/share/man/man1/llvm-symbolizer.1
+# /usr/lib/llvm/19/share/man/man1/llvm-tblgen.1
+# /usr/lib/llvm/19/share/man/man1/llvm-tli-checker.1
+# /usr/lib/llvm/19/share/man/man1/opt.1
+# /usr/lib/llvm/19/share/man/man1/tblgen.1
+
+alternatives=$(:)
+for _alt in "${_llvm_alts[@]}"; do
+	alternatives+=" llvm:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+done

From 78e1a1383b59e9a2e0d9a1f528df3072bee3631f Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 4 Aug 2024 12:41:06 -0400
Subject: [PATCH 16/19] llvm19: fixup disbale lldb docs

---
 .../llvm19/patches/disable-lldb-docs.patch    |  18 ++
 srcpkgs/llvm19/template                       | 187 +++++++++---------
 2 files changed, 111 insertions(+), 94 deletions(-)
 create mode 100644 srcpkgs/llvm19/patches/disable-lldb-docs.patch

diff --git a/srcpkgs/llvm19/patches/disable-lldb-docs.patch b/srcpkgs/llvm19/patches/disable-lldb-docs.patch
new file mode 100644
index 00000000000000..6e7c774bea2f1b
--- /dev/null
+++ b/srcpkgs/llvm19/patches/disable-lldb-docs.patch
@@ -0,0 +1,18 @@
+commit 9af31d021e83dce4e98f06d8e732f4afb481cd08
+Author: Daniel Martinez <danielmartinez@cock.li>
+Date:   Sat Aug 3 18:04:04 2024 -0400
+
+    disable lldb docs as they depend on some sphinx packages we don't have
+
+diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
+index 59cdc4593463..e7c2c38b50a9 100644
+--- a/lldb/CMakeLists.txt
++++ b/lldb/CMakeLists.txt
+@@ -124,7 +124,6 @@ add_subdirectory(utils/TableGen)
+ 
+ add_subdirectory(source)
+ add_subdirectory(tools)
+-add_subdirectory(docs)
+ 
+ if (LLDB_ENABLE_PYTHON)
+   if(LLDB_BUILD_FRAMEWORK)
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 3ed783e3dd6e9e..fc88f85bc2c22c 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -255,7 +255,6 @@ case "$XBPS_TARGET_MACHINE" in
 arm*-musl|i686-musl)
 	# sanitizer code is broken since it duplicates some libc bits
 	configure_args+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF"
-	# configure_args+=" -DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
 	configure_args+=" -DCOMPILER_RT_BUILD_XRAY=OFF"
 	configure_args+=" -DCOMPILER_RT_BUILD_MEMPROF=OFF"
 	;;
@@ -286,15 +285,15 @@ post_extract() {
 	fi
 }
 
-post_patch() {
+# post_patch() {
 # 	if [ "$build_option_lldb" ]; then
 # 		if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 # 			vsed -i 's|__ptrace_request|int|g' \
 # 				${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
 # 		fi
 		# disable docs for lldb as they fail to generate
-		vsed -i '/add_subdirectory(docs)/d' \
-			${wrksrc}/lldb/CMakeLists.txt
+		# vsed -i '/add_subdirectory(docs)/d' \
+		# 	${wrksrc}/lldb/CMakeLists.txt
 # 	fi
 
 # 	# update config.guess for better platform detection
@@ -318,7 +317,7 @@ post_patch() {
 # 			vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
 # 			;;
 # 	esac
-}
+# }
 
 pre_configure() {
 	if [ "$CROSS_BUILD" ]; then
@@ -451,6 +450,10 @@ clang19_package() {
 		bin/amdgpu-arch \
 		bin/nvptx-arch \
 		bin/hmaptool \
+		lib/LLVMgold.so \
+		share/man/man1/clang.1 \
+		share/man/man1/diagtool.1 \
+		share/man/man1/clang-tblgen.1 \
 	)
 
 	for _alt in "${_clang19_files[@]}"; do
@@ -458,14 +461,16 @@ clang19_package() {
 	done
 
 	if [ "$build_option_polly" ]; then
-		alternatives+=" clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1"
+		alternatives+="
+			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		"
 	fi
 	pkg_install() {
 		for _bin in "${_clang19_files[@]}"; do
 			vmove usr/${_llvm_prefix}/${_bin}
 		done
-		vmove ${_llvm_mandir}/man1/clang.1
-		vmove ${_llvm_mandir}/man1/diagtool.1
+
 		if [ "$build_option_polly" ]; then
 			vmove ${_llvm_libdir}/LLVMPolly.so
 			vmove ${_llvm_mandir}/man1/polly.1
@@ -659,12 +664,25 @@ llvm-bolt19_package() {
 	conflicts="llvm-bolt18>=0 llvm-bolt17>=0"
 	short_desc+=" - post-link optimizer"
 	homepage="https://github.com/llvm/llvm-project/tree/main/bolt"
+	_llvm_bolt19_files=( \
+		bin/llvm-bolt
+		bin/perf2bolt
+		bin/llvm-boltdiff
+		bin/merge-fdata
+		bin/llvm-bolt-heatmap
+	)
+	for _alt in "${_llvm_bolt19_files[@]}"; do
+		alternatives+=" llvm-bolt:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_bindir}/llvm-bolt
-		vmove ${_llvm_bindir}/perf2bolt
-		vmove ${_llvm_bindir}/llvm-boltdiff
-		vmove ${_llvm_bindir}/merge-fdata
-		vmove ${_llvm_bindir}/llvm-bolt-heatmap
+		for _f in "${_llvm_bolt19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+		# vmove ${_llvm_bindir}/llvm-bolt
+		# vmove ${_llvm_bindir}/perf2bolt
+		# vmove ${_llvm_bindir}/llvm-boltdiff
+		# vmove ${_llvm_bindir}/merge-fdata
+		# vmove ${_llvm_bindir}/llvm-bolt-heatmap
 		if [ -z "$CROSS_BUILD" ]; then
 			case "$XBPS_TARGET_MACHINE" in
 				x86_64*|aarch64*|riscv64*)
@@ -819,7 +837,7 @@ libomp19_package() {
 	short_desc+=" - Clang OpenMP support library"
 	conflicts="libomp18>=0 libomp17>=0"
 	pkg_install() {
-		vmove "${_llvm_libdir}/libomp*.so"
+		vmove "${_llvm_libdir}/libomp*.so*"
 	}
 }
 
@@ -897,6 +915,7 @@ libcxx-devel_package() {
 	short_desc+=" - C++ standard library - development files"
 	depends="libcxx>=${version}_${revision}"
 	pkg_install() {
+		vmove usr/lib/libc++.modules.json
 		vmove usr/include/c++
 		vmove usr/share/libc++
 		vmove "usr/lib/libc++.so"
@@ -1009,21 +1028,23 @@ SPIRV-LLVM-Translator19-devel_package() {
 }
 
 _llvm_alts=( \
-	bin/FileCheck \
+	bin/FileCheck share/man/man1/FileCheck.1 \
 	bin/UnicodeNameMappingGenerator \
-	bin/bugpoint \
+	bin/bugpoint share/man/man1/bugpoint.1 \
 	bin/clang-installapi \
 	bin/clang-nvlink-wrapper \
 	bin/count \
-	bin/dsymutil \
+	bin/dsymutil share/man/man1/dsymutil.1 \
 	bin/intercept-build \
 	bin/llc \
 	bin/lli \
 	bin/lli-child-target \
 	bin/llvm-PerfectShuffle \
+	bin/llvm-addr2line \
 	bin/llvm-ar \
 	bin/llvm-as \
 	bin/llvm-bcanalyzer \
+	bin/llvm-bitcode-strip \
 	bin/llvm-c-test \
 	bin/llvm-cat \
 	bin/llvm-cfi-verify \
@@ -1039,6 +1060,7 @@ _llvm_alts=( \
 	bin/llvm-debuginfod-find \
 	bin/llvm-diff \
 	bin/llvm-dis \
+	bin/llvm-dlltool \
 	bin/llvm-dwarfdump \
 	bin/llvm-dwarfutil \
 	bin/llvm-dwp \
@@ -1046,8 +1068,10 @@ _llvm_alts=( \
 	bin/llvm-extract \
 	bin/llvm-gsymutil \
 	bin/llvm-ifs \
+	bin/llvm-install-name-tool \
 	bin/llvm-jitlink \
 	bin/llvm-jitlink-executor \
+	bin/llvm-lib \
 	bin/llvm-libtool-darwin \
 	bin/llvm-link \
 	bin/llvm-lipo \
@@ -1061,29 +1085,34 @@ _llvm_alts=( \
 	bin/llvm-nm \
 	bin/llvm-objcopy \
 	bin/llvm-objdump \
-	bin/llvm-opt-report \
+	bin/llvm-opt-report share/man/man1/llvm-opt-report.1 \
+	bin/llvm-otool \
 	bin/llvm-pdbutil \
-	bin/llvm-profdata \
-	bin/llvm-profgen \
+	bin/llvm-profdata   share/man/man1/llvm-profdata.1 \
+	bin/llvm-profgen    share/man/man1/llvm-profgen.1 \
+	bin/llvm-ranlib     share/man/man1/llvm-ranlib.1 \
 	bin/llvm-rc \
-	bin/llvm-readobj \
+	bin/llvm-readelf    share/man/man1/llvm-readelf.1 \
+	bin/llvm-readobj    share/man/man1/llvm-readobj.1 \
 	bin/llvm-readtapi \
-	bin/llvm-reduce \
-	bin/llvm-remarkutil \
+	bin/llvm-reduce     share/man/man1/llvm-reduce.1 \
+	bin/llvm-remarkutil share/man/man1/llvm-remarkutil.1 \
 	bin/llvm-rtdyld \
 	bin/llvm-sim \
-	bin/llvm-size \
+	bin/llvm-size        share/man/man1/llvm-size.1 \
 	bin/llvm-split \
-	bin/llvm-stress \
-	bin/llvm-strings \
-	bin/llvm-symbolizer \
-	bin/llvm-tblgen \
-	bin/llvm-tli-checker \
+	bin/llvm-stress      share/man/man1/llvm-stress.1 \
+	bin/llvm-strings     share/man/man1/llvm-strings.1 \
+	bin/llvm-strip       share/man/man1/llvm-strip.1 \
+	bin/llvm-symbolizer  share/man/man1/llvm-symbolizer.1 \
+	bin/llvm-tblgen      share/man/man1/llvm-tblgen.1 \
+	bin/llvm-tli-checker share/man/man1/llvm-tli-checker.1 \
 	bin/llvm-undname \
+	bin/llvm-windres \
 	bin/llvm-xray \
 	bin/not \
 	bin/obj2yaml \
-	bin/opt \
+	bin/opt share/man/man1/opt.1 \
 	bin/prepare_builtins \
 	bin/reduce-chunk-list \
 	bin/sancov \
@@ -1093,71 +1122,41 @@ _llvm_alts=( \
 	bin/verify-uselistorder \
 	bin/yaml-bench \
 	bin/yaml2obj \
-	bin/llvm-addr2line \
-	bin/llvm-bitcode-strip \
-	bin/llvm-dlltool \
-	bin/llvm-install-name-tool \
-	bin/llvm-lib \
-	bin/llvm-otool \
-	bin/llvm-ranlib \
-	bin/llvm-readelf \
-	bin/llvm-strip \
-	bin/llvm-windres \
+	share/man/man1/lit.1 \
+	share/man/man1/llc.1 \
+	share/man/man1/lldb-tblgen.1 \
+	share/man/man1/lli.1 \
+	share/man/man1/llvm-addr2line.1 \
+	share/man/man1/llvm-ar.1 \
+	share/man/man1/llvm-as.1 \
+	share/man/man1/llvm-bcanalyzer.1 \
+	share/man/man1/llvm-config.1 \
+	share/man/man1/llvm-cov.1 \
+	share/man/man1/llvm-cxxfilt.1 \
+	share/man/man1/llvm-cxxmap.1 \
+	share/man/man1/llvm-debuginfo-analyzer.1 \
+	share/man/man1/llvm-diff.1 \
+	share/man/man1/llvm-dis.1 \
+	share/man/man1/llvm-dwarfdump.1 \
+	share/man/man1/llvm-dwarfutil.1 \
+	share/man/man1/llvm-exegesis.1 \
+	share/man/man1/llvm-extract.1 \
+	share/man/man1/llvm-ifs.1 \
+	share/man/man1/llvm-install-name-tool.1 \
+	share/man/man1/llvm-lib.1 \
+	share/man/man1/llvm-libtool-darwin.1 \
+	share/man/man1/llvm-link.1 \
+	share/man/man1/llvm-lipo.1 \
+	share/man/man1/llvm-locstats.1 \
+	share/man/man1/llvm-mc.1 \
+	share/man/man1/llvm-mca.1 \
+	share/man/man1/llvm-nm.1 \
+	share/man/man1/llvm-objcopy.1 \
+	share/man/man1/llvm-objdump.1 \
+	share/man/man1/llvm-otool.1 \
+	share/man/man1/llvm-pdbutil.1 \
+	share/man/man1/tblgen.1 \
 )
-# /usr/lib/llvm/19/share/man/man1/FileCheck.1
-# /usr/lib/llvm/19/share/man/man1/bugpoint.1
-# /usr/lib/llvm/19/share/man/man1/clang-tblgen.1
-# /usr/lib/llvm/19/share/man/man1/dsymutil.1
-# /usr/lib/llvm/19/share/man/man1/lit.1
-# /usr/lib/llvm/19/share/man/man1/llc.1
-# /usr/lib/llvm/19/share/man/man1/lldb-tblgen.1
-# /usr/lib/llvm/19/share/man/man1/lli.1
-# /usr/lib/llvm/19/share/man/man1/llvm-addr2line.1
-# /usr/lib/llvm/19/share/man/man1/llvm-ar.1
-# /usr/lib/llvm/19/share/man/man1/llvm-as.1
-# /usr/lib/llvm/19/share/man/man1/llvm-bcanalyzer.1
-# /usr/lib/llvm/19/share/man/man1/llvm-config.1
-# /usr/lib/llvm/19/share/man/man1/llvm-cov.1
-# /usr/lib/llvm/19/share/man/man1/llvm-cxxfilt.1
-# /usr/lib/llvm/19/share/man/man1/llvm-cxxmap.1
-# /usr/lib/llvm/19/share/man/man1/llvm-debuginfo-analyzer.1
-# /usr/lib/llvm/19/share/man/man1/llvm-diff.1
-# /usr/lib/llvm/19/share/man/man1/llvm-dis.1
-# /usr/lib/llvm/19/share/man/man1/llvm-dwarfdump.1
-# /usr/lib/llvm/19/share/man/man1/llvm-dwarfutil.1
-# /usr/lib/llvm/19/share/man/man1/llvm-exegesis.1
-# /usr/lib/llvm/19/share/man/man1/llvm-extract.1
-# /usr/lib/llvm/19/share/man/man1/llvm-ifs.1
-# /usr/lib/llvm/19/share/man/man1/llvm-install-name-tool.1
-# /usr/lib/llvm/19/share/man/man1/llvm-lib.1
-# /usr/lib/llvm/19/share/man/man1/llvm-libtool-darwin.1
-# /usr/lib/llvm/19/share/man/man1/llvm-link.1
-# /usr/lib/llvm/19/share/man/man1/llvm-lipo.1
-# /usr/lib/llvm/19/share/man/man1/llvm-locstats.1
-# /usr/lib/llvm/19/share/man/man1/llvm-mc.1
-# /usr/lib/llvm/19/share/man/man1/llvm-mca.1
-# /usr/lib/llvm/19/share/man/man1/llvm-nm.1
-# /usr/lib/llvm/19/share/man/man1/llvm-objcopy.1
-# /usr/lib/llvm/19/share/man/man1/llvm-objdump.1
-# /usr/lib/llvm/19/share/man/man1/llvm-opt-report.1
-# /usr/lib/llvm/19/share/man/man1/llvm-otool.1
-# /usr/lib/llvm/19/share/man/man1/llvm-pdbutil.1
-# /usr/lib/llvm/19/share/man/man1/llvm-profdata.1
-# /usr/lib/llvm/19/share/man/man1/llvm-profgen.1
-# /usr/lib/llvm/19/share/man/man1/llvm-ranlib.1
-# /usr/lib/llvm/19/share/man/man1/llvm-readelf.1
-# /usr/lib/llvm/19/share/man/man1/llvm-readobj.1
-# /usr/lib/llvm/19/share/man/man1/llvm-reduce.1
-# /usr/lib/llvm/19/share/man/man1/llvm-remarkutil.1
-# /usr/lib/llvm/19/share/man/man1/llvm-size.1
-# /usr/lib/llvm/19/share/man/man1/llvm-stress.1
-# /usr/lib/llvm/19/share/man/man1/llvm-strings.1
-# /usr/lib/llvm/19/share/man/man1/llvm-strip.1
-# /usr/lib/llvm/19/share/man/man1/llvm-symbolizer.1
-# /usr/lib/llvm/19/share/man/man1/llvm-tblgen.1
-# /usr/lib/llvm/19/share/man/man1/llvm-tli-checker.1
-# /usr/lib/llvm/19/share/man/man1/opt.1
-# /usr/lib/llvm/19/share/man/man1/tblgen.1
 
 alternatives=$(:)
 for _alt in "${_llvm_alts[@]}"; do

From 5d9f10ca1708b8e7a24f138757ef54bb983d7d33 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Tue, 6 Aug 2024 07:24:05 -0400
Subject: [PATCH 17/19] llvm19: fixup update to rc2

---
 srcpkgs/llvm19/patches/flang-cross.patch    | 10 +--
 srcpkgs/llvm19/patches/mallopt-musl.patch   | 22 -------
 srcpkgs/llvm19/patches/version-suffix.patch |  2 +-
 srcpkgs/llvm19/template                     | 70 ++++++---------------
 4 files changed, 24 insertions(+), 80 deletions(-)
 delete mode 100644 srcpkgs/llvm19/patches/mallopt-musl.patch

diff --git a/srcpkgs/llvm19/patches/flang-cross.patch b/srcpkgs/llvm19/patches/flang-cross.patch
index 3daf5a81a40d7b..92fcb2f12fd1aa 100644
--- a/srcpkgs/llvm19/patches/flang-cross.patch
+++ b/srcpkgs/llvm19/patches/flang-cross.patch
@@ -1,4 +1,4 @@
-commit 61215cf73fcbcf81545e6702fb7c9e32ae614c56
+commit 178a6c7744713200455f97dd66bbb15d9c25bc00
 Author: Daniel Martinez <danielmartinez@cock.li>
 Date:   Wed Jul 31 21:14:52 2024 -0400
 
@@ -10,11 +10,11 @@ Date:   Wed Jul 31 21:14:52 2024 -0400
     This is useful when cross compiling, as flang-new may exist
     on the build machine, which should be used instead of the host.
     
-    For example, by passing "-DFLANG_NEW_EXE=/usr/bin/flang-new", that
-    binary will be used instead of just built host compiler.
+    For example, by passing "-DFLANG_NEW_NATIVE_EXE=/usr/bin/flang-new",
+    that binary will be used instead of just built host compiler.
 
 diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
-index 42b1b86ebaad..22999827d4a8 100644
+index 42b1b86ebaad..1591c855462b 100644
 --- a/llvm/runtimes/CMakeLists.txt
 +++ b/llvm/runtimes/CMakeLists.txt
 @@ -498,7 +498,7 @@ if(build_runtimes)
@@ -22,7 +22,7 @@ index 42b1b86ebaad..22999827d4a8 100644
      if (${LLVM_TOOL_FLANG_BUILD})
        message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
 -      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
-+      set(LIBOMP_FORTRAN_MODULES_COMPILER "${FLANG_NEW_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
++      set(LIBOMP_FORTRAN_MODULES_COMPILER "${FLANG_NEW_NATIVE_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
        set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
        # TODO: This is a workaround until flang becomes a first-class project
        # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
diff --git a/srcpkgs/llvm19/patches/mallopt-musl.patch b/srcpkgs/llvm19/patches/mallopt-musl.patch
deleted file mode 100644
index 6234f22562c756..00000000000000
--- a/srcpkgs/llvm19/patches/mallopt-musl.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/compiler-rt/lib/nsan/nsan_interceptors.cpp b/compiler-rt/lib/nsan/nsan_interceptors.cpp
-index 544b44f53cc4..baa818599411 100644
---- a/compiler-rt/lib/nsan/nsan_interceptors.cpp
-+++ b/compiler-rt/lib/nsan/nsan_interceptors.cpp
-@@ -21,7 +21,7 @@
- 
- #include <wchar.h>
- 
--#if SANITIZER_LINUX
-+#if SANITIZER_LINUX && defined(__GLIBC__)
- extern "C" int mallopt(int param, int value);
- #endif
- 
-@@ -210,7 +210,7 @@ void __nsan::InitializeInterceptors() {
-   CHECK(!initialized);
- 
-   // Instruct libc malloc to consume less memory.
--#if SANITIZER_LINUX
-+#if SANITIZER_LINUX && defined(__GLIBC__)
-   mallopt(1, 0);          // M_MXFAST
-   mallopt(-3, 32 * 1024); // M_MMAP_THRESHOLD
- #endif
diff --git a/srcpkgs/llvm19/patches/version-suffix.patch b/srcpkgs/llvm19/patches/version-suffix.patch
index 8600b2a19151aa..70f2299742fe2e 100644
--- a/srcpkgs/llvm19/patches/version-suffix.patch
+++ b/srcpkgs/llvm19/patches/version-suffix.patch
@@ -6,7 +6,7 @@ index 897dd963bd9a..fe053cc99ff2 100644
    set(LLVM_VERSION_PATCH 0)
  endif()
  if(NOT DEFINED LLVM_VERSION_SUFFIX)
--  set(LLVM_VERSION_SUFFIX -rc1)
+-  set(LLVM_VERSION_SUFFIX -rc2)
 +  set(LLVM_VERSION_SUFFIX)
  endif()
  
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index fc88f85bc2c22c..82abd352dc3bae 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -11,12 +11,6 @@ _llvm_datadir=usr/${_llvm_prefix}/share
 _llvm_incdir=usr/${_llvm_prefix}/include
 _llvm_libdir=usr/${_llvm_prefix}/lib
 _llvm_libexecdir=usr/${_llvm_prefix}/libexec
- # -DLLVM_UTILS_INSTALL_DIR=/usr/${_llvm_prefix}/utils/bin
- # -DLLVM_TOOLS_INSTALL_DIR=/usr/${_llvm_prefix}/tools/bin
- # -DCMAKE_INSTALL_MANDIR=${_llvm_prefix}/share/man
- # -DCMAKE_INSTALL_BINDIR=${_llvm_prefix}/bin
- # -DCMAKE_INSTALL_DATADIR=${_llvm_prefix}/share
-# build_helper=qemu
 _ext_suffix=".cpython-${py3_ver/./}-linux-${XBPS_TARGET_LIBC/glibc/gnu}.so"
 configure_args="
  -DCMAKE_BUILD_TYPE=Release -Wno-dev
@@ -56,7 +50,8 @@ configure_args="
  -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
  -DLIBC_WNO_ERROR=YES
  -DBASE_LLVM_VERSION=${version}
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr "
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+"
 hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
  python3-recommonmark python3-sphinx-automodapi git python3-sphinx-markdown-tables python3-yaml pkg-config
  python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it SPIRV-Headers SPIRV-Tools-devel
@@ -68,9 +63,9 @@ maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0"
 homepage="https://www.llvm.org"
 _spirv_commit=9508565848694d1a9bebd8a00f13749d7cc293d9
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}-rc1.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}-rc2.tar.gz
  https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/${_spirv_commit}.tar.gz"
-checksum="cd3b42caf8e78c497712a661303672c1a6279eb1a5ff8735488087319ab95214
+checksum="5332e77a658136c778fc32ec2a3687de4d63e0ff48010be205c4e7af6e76f1f1
  b0fe774cad6539cf6ed63100656374fbe37dc332d87aac7dd707dfdd1d4376bd"
 skip_extraction=${_spirv_commit}.tar.gz
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
@@ -85,15 +80,6 @@ build_options_default="clang clang_tools_extra lld mlir libclc polly lldb
 # hack to set correct order of subpackages after processing build options
 subpackages=$(:)
 
-# if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
-
-	# if [ "$XBPS_TARGET_LIBC" = "musl" ] ; then
-	# else
-	# 	build_options_default+=" flang"
-	# fi
-	# x86_64|i686) makedepends+=" libquadmath-devel" ;;
-# fi
-
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
 	x86_64|i686) makedepends+=" libquadmath-devel" ;;
@@ -225,7 +211,7 @@ if [ "$CROSS_BUILD" ]; then
 	configure_args+=" -DMLIR_PDLL_TABLEGEN=/${_llvm_bindir}/mlir-pdll"
 	configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/${_llvm_bindir}/mlir-linalg-ods-yaml-gen"
 	configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/${_llvm_bindir}/mlir-src-sharder"
-	configure_args+=" -DFLANG_NEW_EXE=/${_llvm_bindir}/flang-new"
+	configure_args+=" -DFLANG_NEW_NATIVE_EXE=/${_llvm_bindir}/flang-new"
 	configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/${_llvm_bindir}/clang-tidy-confusable-chars-gen"
 	configure_args+=" -DCLANG_PSEUDO_GEN=/${_llvm_bindir}/clang-pseudo-gen"
 	configure_args+=" -DLLVM_CONFIG_PATH=/${_llvm_bindir}/llvm-config"
@@ -285,39 +271,19 @@ post_extract() {
 	fi
 }
 
-# post_patch() {
-# 	if [ "$build_option_lldb" ]; then
-# 		if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
-# 			vsed -i 's|__ptrace_request|int|g' \
-# 				${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
-# 		fi
-		# disable docs for lldb as they fail to generate
-		# vsed -i '/add_subdirectory(docs)/d' \
-		# 	${wrksrc}/lldb/CMakeLists.txt
-# 	fi
-
-# 	# update config.guess for better platform detection
-# 	cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
-# 		${wrksrc}/llvm/cmake
-
-# 	# fix linker failures on some archs
-# 	vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
-# 		${wrksrc}/libcxxabi/cmake/config-ix.cmake
-# 	vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
-# 		${wrksrc}/libcxxabi/cmake/config-ix.cmake
-
-# 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
-# 	case "$XBPS_TARGET_MACHINE" in
-# 		ppc64*) ;;
-# 		ppc*-musl|i686-musl|mips*-musl)
-# 			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
-# 				${wrksrc}/libunwind/src/CMakeLists.txt
-# 			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
-# 				${wrksrc}/libcxxabi/src/CMakeLists.txt
-# 			vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
-# 			;;
-# 	esac
-# }
+post_patch() {
+	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*) ;;
+		ppc*-musl|i686-musl|mips*-musl)
+			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+				${wrksrc}/libunwind/src/CMakeLists.txt
+			vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+				${wrksrc}/libcxxabi/src/CMakeLists.txt
+			vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+			;;
+	esac
+}
 
 pre_configure() {
 	if [ "$CROSS_BUILD" ]; then

From d46e07496deacd4ca9289f5c9314aa01ba7a5423 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Tue, 6 Aug 2024 08:57:01 -0400
Subject: [PATCH 18/19] llvm19: flang

---
 srcpkgs/llvm19/template | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 82abd352dc3bae..0b22d0298528b7 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -773,8 +773,20 @@ flang19_package() {
 	conflicts="flang18>=0 flang17>=0"
 	short_desc+=" - Fortran language frontend"
 	homepage="https://flang.llvm.org/"
+	_flang19_files=(  \
+		bin/flang-new
+		bin/bbc
+		bin/f18-parse-demo
+		bin/fir-opt
+		bin/tco
+	)
+	for _alt in "${_flang19_files[@]}"; do
+		alternatives+=" flang:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_bindir}/flang-new
+		for _f in "${_flang19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -785,10 +797,10 @@ flang19-devel_package() {
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
 	pkg_install() {
-		vmove ${_llvm_bindir}/bbc
-		vmove ${_llvm_bindir}/f18-parse-demo
-		vmove ${_llvm_bindir}/fir-opt
-		vmove ${_llvm_bindir}/tco
+		# vmove ${_llvm_bindir}/bbc
+		# vmove ${_llvm_bindir}/f18-parse-demo
+		# vmove ${_llvm_bindir}/fir-opt
+		# vmove ${_llvm_bindir}/tco
 		vmove ${_llvm_incdir}/flang
 		vmove ${_llvm_libdir}/cmake/flang
 		vmove "${_llvm_libdir}/libflang*.a"

From 5dc0587e1a24af4ec4521f4874f8679503d18864 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Tue, 6 Aug 2024 13:40:35 -0400
Subject: [PATCH 19/19] llvm19: fixup link libs

---
 srcpkgs/llvm19/patches/flang-cross.patch |   6 +-
 srcpkgs/llvm19/template                  | 162 +++++++++++++++++++----
 2 files changed, 138 insertions(+), 30 deletions(-)

diff --git a/srcpkgs/llvm19/patches/flang-cross.patch b/srcpkgs/llvm19/patches/flang-cross.patch
index 92fcb2f12fd1aa..7f00e2a1df0571 100644
--- a/srcpkgs/llvm19/patches/flang-cross.patch
+++ b/srcpkgs/llvm19/patches/flang-cross.patch
@@ -1,4 +1,4 @@
-commit 178a6c7744713200455f97dd66bbb15d9c25bc00
+commit 92984acc52fb95566d9387948c2655507328438b
 Author: Daniel Martinez <danielmartinez@cock.li>
 Date:   Wed Jul 31 21:14:52 2024 -0400
 
@@ -14,7 +14,7 @@ Date:   Wed Jul 31 21:14:52 2024 -0400
     that binary will be used instead of just built host compiler.
 
 diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
-index 42b1b86ebaad..1591c855462b 100644
+index 42b1b86ebaad..41921aaeaeb2 100644
 --- a/llvm/runtimes/CMakeLists.txt
 +++ b/llvm/runtimes/CMakeLists.txt
 @@ -498,7 +498,7 @@ if(build_runtimes)
@@ -22,7 +22,7 @@ index 42b1b86ebaad..1591c855462b 100644
      if (${LLVM_TOOL_FLANG_BUILD})
        message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
 -      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
-+      set(LIBOMP_FORTRAN_MODULES_COMPILER "${FLANG_NEW_NATIVE_EXE}" CACHE INTERNAL "${CMAKE_BINARY_DIR}/bin/flang-new")
++      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new" CACHE INTERNAL "")
        set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
        # TODO: This is a workaround until flang becomes a first-class project
        # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 0b22d0298528b7..997cd061bbc59d 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -211,7 +211,7 @@ if [ "$CROSS_BUILD" ]; then
 	configure_args+=" -DMLIR_PDLL_TABLEGEN=/${_llvm_bindir}/mlir-pdll"
 	configure_args+=" -DMLIR_LINALG_ODS_YAML_GEN=/${_llvm_bindir}/mlir-linalg-ods-yaml-gen"
 	configure_args+=" -DMLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE=/${_llvm_bindir}/mlir-src-sharder"
-	configure_args+=" -DFLANG_NEW_NATIVE_EXE=/${_llvm_bindir}/flang-new"
+	configure_args+=" -DLIBOMP_FORTRAN_MODULES_COMPILER=/${_llvm_bindir}/flang-new"
 	configure_args+=" -DCLANG_TIDY_CONFUSABLE_CHARS_GEN=/${_llvm_bindir}/clang-tidy-confusable-chars-gen"
 	configure_args+=" -DCLANG_PSEUDO_GEN=/${_llvm_bindir}/clang-pseudo-gen"
 	configure_args+=" -DLLVM_CONFIG_PATH=/${_llvm_bindir}/llvm-config"
@@ -265,6 +265,35 @@ configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
 configure_args+=" -DLLVM_HOST_TRIPLE=${_triplet}"
 configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${_triplet}"
 
+_vlink_libs() {
+	local _files="$1"
+	local _f
+	for _f in $DESTDIR/$_files; do
+		local _base=$(basename "${_f}")
+		# echo "_base: ${_base}"
+		# echo "ln cmd: ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib"
+		ln -s ${_llvm_prefix}/lib/${_base} ${DESTDIR}/usr/lib
+		vmove ${_llvm_libdir}/${_base}
+		vmove usr/lib/${_base}
+	done
+}
+
+# _valt() {
+# 	local _f
+# 	local _bn
+# 	local _alt_group="$1"
+# 	local _subdir="$2"
+# 	local _files="$3"
+# 	for _f in "${DESTDIR}/usr/${_llvm_prefix}/${_subdir}/${_files}"; do
+# 		echo "valt : ${_f}"
+# 		_bn=$(basename "${_f}")
+# 		echo "bn: ${_bn}"
+# 		alternatives+=" ${_alt_group}:/usr/${_subdir}/${_bn}:/usr/${_llvm_prefix}/${_subdir}/${_bn}"
+# 		echo "Alts: ${alternatives}"
+# 		# vmove "usr/${_llvm_prefix}/${_f}"
+# 	done
+# }
+
 post_extract() {
 	if [ "$build_option_llvm_spirv" ]; then
 		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_commit}.tar.gz
@@ -389,10 +418,10 @@ clang19_package() {
 	conflicts="clang18>=0 clang17>=0 clang15>=0"
 	short_desc+=" - C language family frontend"
 	homepage="https://clang.llvm.org/"
-	alternatives="
-	 clang:/usr/share/man/man1/clang.1:/${_llvm_mandir}/man1/clang.1
-	 clang:/usr/share/man/man1/diagtool.1:/${_llvm_mandir}/man1/diagtool.1
-	"
+	# alternatives="
+	#  clang:/usr/share/man/man1/clang.1:/${_llvm_mandir}/man1/clang.1
+	#  clang:/usr/share/man/man1/diagtool.1:/${_llvm_mandir}/man1/diagtool.1
+	# "
 	_clang19_files=( \
 		bin/clang-19 \
 		bin/clang \
@@ -421,6 +450,7 @@ clang19_package() {
 		share/man/man1/diagtool.1 \
 		share/man/man1/clang-tblgen.1 \
 	)
+	# _valt "clang" "bin" "clang*"
 
 	for _alt in "${_clang19_files[@]}"; do
 		alternatives+=" clang:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
@@ -437,6 +467,8 @@ clang19_package() {
 			vmove usr/${_llvm_prefix}/${_bin}
 		done
 
+		# vmove "${_llvm_bindir}/clang*"
+
 		if [ "$build_option_polly" ]; then
 			vmove ${_llvm_libdir}/LLVMPolly.so
 			vmove ${_llvm_mandir}/man1/polly.1
@@ -513,7 +545,8 @@ libclang19_package() {
 	depends="clang19-headers>=${version}_${revision}"
 	short_desc+=" - C frontend library"
 	pkg_install() {
-		vmove "${_llvm_libdir}/libclang.so.*"
+		# vmove "${_llvm_libdir}/libclang.so.*"
+		_vlink_libs "${_llvm_libdir}/libclang.so.*"
 	}
 }
 
@@ -521,7 +554,8 @@ libclang-cpp19_package() {
 	depends="clang19-headers>=${version}_${revision}"
 	short_desc+=" - C frontend library (C++ interface)"
 	pkg_install() {
-		vmove "${_llvm_libdir}/libclang-cpp.so.*"
+		# vmove "${_llvm_libdir}/libclang-cpp.so.*"
+		_vlink_libs "${_llvm_libdir}/libclang-cpp.so.*"
 	}
 }
 
@@ -694,7 +728,8 @@ liblldb19_package() {
 	lib32disabled=yes
 	short_desc+=" - LLDB debugger - runtime library"
 	pkg_install() {
-		vmove "${_llvm_libdir}/liblldb*.so.*"
+		# vmove "${_llvm_libdir}/liblldb*.so.*"
+		_vlink_libs "${_llvm_libdir}/liblldb*.so.*"
 	}
 }
 
@@ -722,6 +757,11 @@ lld19_package() {
 		# vmove ${_llvm_bindir}/ld.lld
 		# vmove ${_llvm_bindir}/ld64.lld
 		# vmove ${_llvm_bindir}/wasm-ld
+		# _valt bin/lld
+		# _valt bin/lld-link
+		# _valt bin/ld.lld
+		# _valt bin/ld64.lld
+		# _valt bin/wasm-ld
 	}
 }
 
@@ -742,9 +782,35 @@ mlir19_package() {
 	lib32disabled=yes
 	short_desc+=" - multi-level IR compiler framework"
 	homepage="https://mlir.llvm.org/"
+	_mlir19_files=(  \
+		bin/mlir-cat \
+		bin/mlir-cpu-runner \
+		bin/mlir-linalg-ods-yaml-gen \
+		bin/mlir-lsp-server \
+		bin/mlir-minimal-opt \
+		bin/mlir-minimal-opt-canonicalize \
+		bin/mlir-opt \
+		bin/mlir-pdll \
+		bin/mlir-pdll-lsp-server \
+		bin/mlir-query \
+		bin/mlir-reduce \
+		bin/mlir-tblgen \
+		bin/mlir-transform-opt \
+		bin/mlir-translate \
+		bin/tblgen-lsp-server \
+		share/man/man1/mlir-tblgen.1 \
+	)
+	for _alt in "${_mlir19_files[@]}"; do
+		alternatives+=" mlir:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove "${_llvm_libdir}/libMLIR*.so.*"
-		vmove "${_llvm_libdir}/libmlir*.so.*"
+		for _f in "${_mlir19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+		# vmove "${_llvm_libdir}/libMLIR*.so.*"
+		# vmove "${_llvm_libdir}/libmlir*.so.*"
+		_vlink_libs "${_llvm_libdir}/libMLIR*.so.*"
+		_vlink_libs "${_llvm_libdir}/libmlir*.so.*"
 	}
 }
 
@@ -755,15 +821,15 @@ mlir19-devel_package() {
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
 	pkg_install() {
-		vmove "${_llvm_bindir}/mlir*"
-		vmove ${_llvm_bindir}/tblgen-lsp-server
+		# vmove "${_llvm_bindir}/mlir*"
+		# vmove ${_llvm_bindir}/tblgen-lsp-server
 		vmove ${_llvm_incdir}/mlir
 		vmove ${_llvm_incdir}/mlir-c
 		vmove ${_llvm_libdir}/cmake/mlir
 		vmove "${_llvm_libdir}/libMLIR*"
 		vmove "${_llvm_libdir}/objects-Release/obj.MLIR*"
 		vmove "${_llvm_libdir}/libmlir*"
-		vmove ${_llvm_mandir}/man1/mlir-tblgen.1
+		# vmove ${_llvm_mandir}/man1/mlir-tblgen.1
 	}
 }
 
@@ -774,11 +840,11 @@ flang19_package() {
 	short_desc+=" - Fortran language frontend"
 	homepage="https://flang.llvm.org/"
 	_flang19_files=(  \
-		bin/flang-new
-		bin/bbc
-		bin/f18-parse-demo
-		bin/fir-opt
-		bin/tco
+		bin/flang-new \
+		bin/bbc \
+		bin/f18-parse-demo \
+		bin/fir-opt \
+		bin/tco \
 	)
 	for _alt in "${_flang19_files[@]}"; do
 		alternatives+=" flang:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
@@ -787,6 +853,7 @@ flang19_package() {
 		for _f in "${_flang19_files[@]}"; do
 			vmove usr/${_llvm_prefix}/${_f}
 		done
+		vmove "${_llvm_incdir}/flang/*.mod"
 	}
 }
 
@@ -814,9 +881,39 @@ flang19-devel_package() {
 libomp19_package() {
 	short_desc+=" - Clang OpenMP support library"
 	conflicts="libomp18>=0 libomp17>=0"
+	_libomp19_files=(  \
+		lib/libomp.so \
+		lib/libompd.so \
+	)
+	if [ "$build_option_offload" ]; then
+		_libomp19_files+=("bin/llvm-omp-device-info")
+		_libomp19_files+=("bin/llvm-omp-kernel-replay")
+		_libomp19_files+=("lib/libomptarget.so")
+	fi
+	for _alt in "${_libomp19_files[@]}"; do
+		alternatives+=" libomp:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove "${_llvm_libdir}/libomp*.so*"
+		for _f in "${_libomp19_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+		if [ "$build_option_offload" ]; then
+			echo "LIBOMP TEST: "
+			echo "DESTDIR: ${DESTDIR}"
+			echo "LLVMDIR: ${DESTDIR}/${DESTDIR}/${_llvm_libdir}"
+			for _f in ${DESTDIR}/${_llvm_libdir}/libomp*.so*; do
+				_base=$(basename "${_f}")
+				echo "_base: ${_base}"
+				echo "ln cmd: ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib"
+				ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib
+				vmove ${_llvm_libdir}/${_base}
+				vmove usr/lib/${_base}
+			done
+		fi
 	}
+	# pkg_install() {
+	# 	vmove "${_llvm_libdir}/libomp*.so*"
+	# }
 }
 
 libomp19-devel_package() {
@@ -824,12 +921,6 @@ libomp19-devel_package() {
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
 	pkg_install() {
-		if [ -f "${DESTDIR}/${_llvm_bindir}/llvm-omp-device-info" ]; then
-			vmove ${_llvm_bindir}/llvm-omp-device-info
-		fi
-		if [ -f "${DESTDIR}/${_llvm_bindir}/llvm-omp-kernel-replay" ]; then
-			vmove ${_llvm_bindir}/llvm-omp-kernel-replay
-		fi
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
 		fi
@@ -920,8 +1011,25 @@ compiler-rt19_package() {
 libllvm19_package() {
 	short_desc+=" - library"
 	pkg_install() {
-		vmove "${_llvm_libdir}/libLLVM-*.so"
-		vmove "${_llvm_libdir}/libLLVM.so.*"
+		_vlink_libs "${_llvm_libdir}/libLLVM-*.so"
+		_vlink_libs "${_llvm_libdir}/libLLVM.so.*"
+# ${_llvm_libdir}/libLLVM.so.*
+		# for _f in ${DESTDIR}/${_llvm_libdir}/libLLVM-*.so; do
+		# 	local _base=$(basename "${_f}")
+		# 	echo "_base: ${_base}"
+		# 	echo "ln cmd: ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib"
+		# 	ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib
+		# 	vmove ${_llvm_libdir}/${_base}
+		# 	vmove usr/lib/${_base}
+		# done
+		# for _f in ${DESTDIR}/${_llvm_libdir}/libLLVM.so.*; do
+		# 	local _base=$(basename "${_f}")
+		# 	echo "_base: ${_base}"
+		# 	echo "ln cmd: ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib"
+		# 	ln -s llvm/19/lib/${_base} ${DESTDIR}/usr/lib
+		# 	vmove ${_llvm_libdir}/${_base}
+		# 	vmove usr/lib/${_base}
+		# done
 	}
 }
 

  parent reply	other threads:[~2024-08-06 17:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 13:04 [PR PATCH] " Calandracas606
2024-07-29 13:07 ` [PR PATCH] [Updated] " Calandracas606
2024-07-29 23:42 ` Calandracas606
2024-07-29 23:43 ` Calandracas606
2024-07-30 11:35 ` Calandracas606
2024-07-30 12:04 ` Calandracas606
2024-07-30 13:45 ` [PR PATCH] [Updated] " Calandracas606
2024-07-30 13:46 ` Calandracas606
2024-07-30 13:48 ` [PR PATCH] [Updated] " Calandracas606
2024-07-30 13:49 ` Calandracas606
2024-08-06 17:40 ` Calandracas606 [this message]
2024-08-06 17:50 ` Calandracas606
2024-08-06 17:51 ` Calandracas606
2024-08-06 17:53 ` Calandracas606
2024-08-06 18:01 ` Calandracas606
2024-09-29  1:49 ` [PR PATCH] [Updated] " Calandracas606
2024-09-29  1:57 ` Calandracas606
2024-09-29  2:10 ` Calandracas606
2024-09-29 12:24 ` [PR PATCH] [Updated] " Calandracas606
2024-11-08  3:36 ` Calandracas606
2024-11-08  4:48 ` Calandracas606
2024-11-09 15:41 ` New package: llvm19-19.1.3 Calandracas606
2024-11-09 18:23 ` [PR PATCH] [Updated] " Calandracas606
2024-11-09 18:31 ` [PR REVIEW] " classabbyamp
2024-11-11 22:55 ` [PR PATCH] [Updated] " Calandracas606
2024-11-12 19:04 ` [PR PATCH] [Closed]: " classabbyamp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806174058.CCEBE28585@inbox.vuxu.org \
    --to=calandracas606@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).