Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
@ 2024-11-16 19:33 Calandracas606
  2024-11-16 20:15 ` [PR PATCH] [Updated] " Calandracas606
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-16 19:33 UTC (permalink / raw)
  To: ml

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

There is a new pull request by Calandracas606 against master on the void-packages repository

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

DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
<--
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/3] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 505b1f319ac61f6ef6841a3e14e8a65d0ed976d1 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/3] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 51 +++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..5dfe9007b4314f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -607,6 +596,10 @@ clang19-devel_package() {
 	fi
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
+	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
+	if [ "$build_option_polly" ]; then
+		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+	fi
 	pkg_install() {
 		vmove ${_llvm_incdir}/clang
 		vmove ${_llvm_incdir}/clang-c
@@ -816,6 +809,7 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
+	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
 	pkg_install() {
 		vmove ${_llvm_incdir}/lld
 		vmove ${_llvm_libdir}/cmake/lld
@@ -863,6 +857,7 @@ mlir19-devel_package() {
 	conflicts="mlir18-devel>=0 mlir17-devel>=0"
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
+	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
 	pkg_install() {
 		vmove ${_llvm_incdir}/mlir
 		vmove ${_llvm_incdir}/mlir-c
@@ -905,6 +900,7 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
+	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
 	pkg_install() {
 		vmove ${_llvm_incdir}/flang
 		vmove ${_llvm_libdir}/cmake/flang
@@ -947,6 +943,7 @@ libomp19-devel_package() {
 	short_desc+=" - Clang OpenMP support library - development files"
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
+	alternatives="libomp-devel:/usr/lib/cmake/openmp:/${_llvm_libdir}/cmake/openmp"
 	pkg_install() {
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
@@ -1066,7 +1063,7 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
+	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so

From bbf2e526f755f318e35567b1ac6c707ac0fc06ec Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/3] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 35 ++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..bdafc5f1b43498 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..55cfb758a50f7f
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,35 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
@ 2024-11-16 20:15 ` Calandracas606
  2024-11-16 22:04 ` Calandracas606
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-16 20:15 UTC (permalink / raw)
  To: ml

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

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

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

DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
<--
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/4] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 505b1f319ac61f6ef6841a3e14e8a65d0ed976d1 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/4] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 51 +++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..5dfe9007b4314f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -607,6 +596,10 @@ clang19-devel_package() {
 	fi
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
+	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
+	if [ "$build_option_polly" ]; then
+		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+	fi
 	pkg_install() {
 		vmove ${_llvm_incdir}/clang
 		vmove ${_llvm_incdir}/clang-c
@@ -816,6 +809,7 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
+	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
 	pkg_install() {
 		vmove ${_llvm_incdir}/lld
 		vmove ${_llvm_libdir}/cmake/lld
@@ -863,6 +857,7 @@ mlir19-devel_package() {
 	conflicts="mlir18-devel>=0 mlir17-devel>=0"
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
+	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
 	pkg_install() {
 		vmove ${_llvm_incdir}/mlir
 		vmove ${_llvm_incdir}/mlir-c
@@ -905,6 +900,7 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
+	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
 	pkg_install() {
 		vmove ${_llvm_incdir}/flang
 		vmove ${_llvm_libdir}/cmake/flang
@@ -947,6 +943,7 @@ libomp19-devel_package() {
 	short_desc+=" - Clang OpenMP support library - development files"
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
+	alternatives="libomp-devel:/usr/lib/cmake/openmp:/${_llvm_libdir}/cmake/openmp"
 	pkg_install() {
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
@@ -1066,7 +1063,7 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
+	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so

From bbf2e526f755f318e35567b1ac6c707ac0fc06ec Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/4] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 35 ++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..bdafc5f1b43498 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..55cfb758a50f7f
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,35 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From e542b41c5d19c326e9e0263bb907bd65ee31a4c6 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 15:15:09 -0500
Subject: [PATCH 4/4] llvm19: !fixup

---
 srcpkgs/llvm19/template | 105 ++++++++++++++++++++++++++++------------
 1 file changed, 74 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 5dfe9007b4314f..dd2c21d0ffd5cc 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -591,32 +591,41 @@ clang19-devel_package() {
 	 clang19>=${version}_${revision} clang-analyzer19>=${version}_${revision}
 	 llvm19>=${version}_${revision}"
 	conflicts="clang18-devel clang17-devel clang15-devel"
+	short_desc+=" - C language family frontend - development Files"
+	homepage="https://clang.llvm.org/"
+	_clang19_devel_files=(
+		include/clang
+		include/clang-c
+		lib/cmake/clang
+	)
 	if [ "$build_option_clang_tools_extra" ]; then
 		depends+=" clang-tools-extra19>=${version}_${revision}"
+		_clang19_devel_files+=(include/clang-tidy)
 	fi
-	short_desc+=" - C language family frontend - development Files"
-	homepage="https://clang.llvm.org/"
-	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
 	if [ "$build_option_polly" ]; then
-		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+		_clang19_devel_files+=(
+			include/polly
+			lib/cmake/polly
+		)
 	fi
+	for _alt in "${_clang19_devel_files[@]}"; do
+		alternatives+=" clang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		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 ${_llvm_incdir}/clang-tidy
 			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
-			vmove ${_llvm_incdir}/polly
-			vmove ${_llvm_libdir}/cmake/polly
 			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
+		for _f in "${_clang19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+
 	}
 }
 
@@ -766,9 +775,17 @@ lldb19-devel_package() {
 	depends="lldb19>=${version}_${revision}"
 	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
 	short_desc+=" - LLDB debugger - development files"
+	_lldb19_devel_files=(
+		include/lldb
+	)
+	for _alt in "${_lldb19_devel_files[@]}"; do
+		alternatives+=" lldb-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/lldb
 		vmove "${_llvm_libdir}/liblldb*.so"
+		for _f in "${_lldb19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -809,11 +826,20 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
-	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
+	# alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
+	_lld19_devel_files=(
+		include/lld
+		lib/cmake/lld
+	)
+	for _alt in "${_lld19_devel_files[@]}"; do
+		alternatives+=" lld-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/lld
-		vmove ${_llvm_libdir}/cmake/lld
 		vmove "${_llvm_libdir}/liblld*.a"
+
+		for _f in "${_lld19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -858,13 +884,22 @@ mlir19-devel_package() {
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
 	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
+	_mlir19_devel_files=(
+		include/mlir
+		include/mlir-c
+	)
+	for _alt in "${_mlir19_devel_files[@]}"; do
+		alternatives+=" mlir-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		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*"
+
+		for _f in "${_mlir19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -900,13 +935,21 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
-	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
+	_flang19_devel_files=(
+		include/flang
+		lib/cmake/flang
+	)
+	for _alt in "${_flang19_devel_files[@]}"; do
+		alternatives+=" flang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/flang
-		vmove ${_llvm_libdir}/cmake/flang
 		vmove "${_llvm_libdir}/libFIR*.a"
 		vmove "${_llvm_libdir}/libHLFIR*.a"
 		vmove "${_llvm_libdir}/libCUF*.a"
+
+		for _f in "${_flang19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -1063,15 +1106,23 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
+	_llvm19_devel_files=(
+		lib/cmake/llvm
+		include/llvm
+		include/llvm-c
+	)
+	for _alt in "${_llvm19_devel_files[@]}"; do
+		alternatives+=" llvm-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
 		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
+
+		for _f in "${_llvm19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -1102,14 +1153,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
  2024-11-16 20:15 ` [PR PATCH] [Updated] " Calandracas606
@ 2024-11-16 22:04 ` Calandracas606
  2024-11-16 22:06 ` Calandracas606
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-16 22:04 UTC (permalink / raw)
  To: ml

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

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

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

DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
<!--
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 505b1f319ac61f6ef6841a3e14e8a65d0ed976d1 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 51 +++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..5dfe9007b4314f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -607,6 +596,10 @@ clang19-devel_package() {
 	fi
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
+	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
+	if [ "$build_option_polly" ]; then
+		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+	fi
 	pkg_install() {
 		vmove ${_llvm_incdir}/clang
 		vmove ${_llvm_incdir}/clang-c
@@ -816,6 +809,7 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
+	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
 	pkg_install() {
 		vmove ${_llvm_incdir}/lld
 		vmove ${_llvm_libdir}/cmake/lld
@@ -863,6 +857,7 @@ mlir19-devel_package() {
 	conflicts="mlir18-devel>=0 mlir17-devel>=0"
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
+	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
 	pkg_install() {
 		vmove ${_llvm_incdir}/mlir
 		vmove ${_llvm_incdir}/mlir-c
@@ -905,6 +900,7 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
+	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
 	pkg_install() {
 		vmove ${_llvm_incdir}/flang
 		vmove ${_llvm_libdir}/cmake/flang
@@ -947,6 +943,7 @@ libomp19-devel_package() {
 	short_desc+=" - Clang OpenMP support library - development files"
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
+	alternatives="libomp-devel:/usr/lib/cmake/openmp:/${_llvm_libdir}/cmake/openmp"
 	pkg_install() {
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
@@ -1066,7 +1063,7 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
+	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so

From bbf2e526f755f318e35567b1ac6c707ac0fc06ec Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 35 ++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..bdafc5f1b43498 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..55cfb758a50f7f
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,35 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From e542b41c5d19c326e9e0263bb907bd65ee31a4c6 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 15:15:09 -0500
Subject: [PATCH 4/5] llvm19: !fixup

---
 srcpkgs/llvm19/template | 105 ++++++++++++++++++++++++++++------------
 1 file changed, 74 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 5dfe9007b4314f..dd2c21d0ffd5cc 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -591,32 +591,41 @@ clang19-devel_package() {
 	 clang19>=${version}_${revision} clang-analyzer19>=${version}_${revision}
 	 llvm19>=${version}_${revision}"
 	conflicts="clang18-devel clang17-devel clang15-devel"
+	short_desc+=" - C language family frontend - development Files"
+	homepage="https://clang.llvm.org/"
+	_clang19_devel_files=(
+		include/clang
+		include/clang-c
+		lib/cmake/clang
+	)
 	if [ "$build_option_clang_tools_extra" ]; then
 		depends+=" clang-tools-extra19>=${version}_${revision}"
+		_clang19_devel_files+=(include/clang-tidy)
 	fi
-	short_desc+=" - C language family frontend - development Files"
-	homepage="https://clang.llvm.org/"
-	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
 	if [ "$build_option_polly" ]; then
-		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+		_clang19_devel_files+=(
+			include/polly
+			lib/cmake/polly
+		)
 	fi
+	for _alt in "${_clang19_devel_files[@]}"; do
+		alternatives+=" clang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		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 ${_llvm_incdir}/clang-tidy
 			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
-			vmove ${_llvm_incdir}/polly
-			vmove ${_llvm_libdir}/cmake/polly
 			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
+		for _f in "${_clang19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+
 	}
 }
 
@@ -766,9 +775,17 @@ lldb19-devel_package() {
 	depends="lldb19>=${version}_${revision}"
 	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
 	short_desc+=" - LLDB debugger - development files"
+	_lldb19_devel_files=(
+		include/lldb
+	)
+	for _alt in "${_lldb19_devel_files[@]}"; do
+		alternatives+=" lldb-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/lldb
 		vmove "${_llvm_libdir}/liblldb*.so"
+		for _f in "${_lldb19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -809,11 +826,20 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
-	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
+	# alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
+	_lld19_devel_files=(
+		include/lld
+		lib/cmake/lld
+	)
+	for _alt in "${_lld19_devel_files[@]}"; do
+		alternatives+=" lld-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/lld
-		vmove ${_llvm_libdir}/cmake/lld
 		vmove "${_llvm_libdir}/liblld*.a"
+
+		for _f in "${_lld19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -858,13 +884,22 @@ mlir19-devel_package() {
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
 	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
+	_mlir19_devel_files=(
+		include/mlir
+		include/mlir-c
+	)
+	for _alt in "${_mlir19_devel_files[@]}"; do
+		alternatives+=" mlir-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		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*"
+
+		for _f in "${_mlir19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -900,13 +935,21 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
-	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
+	_flang19_devel_files=(
+		include/flang
+		lib/cmake/flang
+	)
+	for _alt in "${_flang19_devel_files[@]}"; do
+		alternatives+=" flang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/flang
-		vmove ${_llvm_libdir}/cmake/flang
 		vmove "${_llvm_libdir}/libFIR*.a"
 		vmove "${_llvm_libdir}/libHLFIR*.a"
 		vmove "${_llvm_libdir}/libCUF*.a"
+
+		for _f in "${_flang19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -1063,15 +1106,23 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
+	_llvm19_devel_files=(
+		lib/cmake/llvm
+		include/llvm
+		include/llvm-c
+	)
+	for _alt in "${_llvm19_devel_files[@]}"; do
+		alternatives+=" llvm-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
 		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
+
+		for _f in "${_llvm19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -1102,14 +1153,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From cab9bb85dfad376c53b22a8624756c20178d3def Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 17:04:22 -0500
Subject: [PATCH 5/5] llvm19: !fixup

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 10 ++-
 srcpkgs/llvm19/template                  | 87 ++++--------------------
 2 files changed, 24 insertions(+), 73 deletions(-)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 55cfb758a50f7f..59ce5305ad1479 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -6,9 +6,13 @@ _llvm_ver=${version%.*.*}
 build_style=cmake
 configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
  -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr"
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
 hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+# hostmakedepends="pkg-config"
 makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+# makedepends="SPIRV-Headers SPIRV-Tools-devel"
 short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="NCSA"
@@ -18,6 +22,10 @@ checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
+# if [ "$CROSS_BUILD" ]; then
+# 	# configure_args+=" -DLINK_DIRECTORIES=/usr/lib/llvm/19/lib/"
+# fi
+
 post_install() {
 	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
 	vlicense LICENSE.TXT
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dd2c21d0ffd5cc..dd69254f141db1 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -593,26 +593,14 @@ clang19-devel_package() {
 	conflicts="clang18-devel clang17-devel clang15-devel"
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
-	_clang19_devel_files=(
-		include/clang
-		include/clang-c
-		lib/cmake/clang
-	)
 	if [ "$build_option_clang_tools_extra" ]; then
 		depends+=" clang-tools-extra19>=${version}_${revision}"
-		_clang19_devel_files+=(include/clang-tidy)
-	fi
-	if [ "$build_option_polly" ]; then
-		_clang19_devel_files+=(
-			include/polly
-			lib/cmake/polly
-		)
 	fi
-	for _alt in "${_clang19_devel_files[@]}"; do
-		alternatives+=" clang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		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
@@ -620,11 +608,10 @@ clang19-devel_package() {
 			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
+			vmove ${_llvm_incdir}/polly
+			vmove ${_llvm_libdir}/cmake/polly
 			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
-		for _f in "${_clang19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 
 	}
 }
@@ -775,13 +762,8 @@ lldb19-devel_package() {
 	depends="lldb19>=${version}_${revision}"
 	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
 	short_desc+=" - LLDB debugger - development files"
-	_lldb19_devel_files=(
-		include/lldb
-	)
-	for _alt in "${_lldb19_devel_files[@]}"; do
-		alternatives+=" lldb-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		vmove ${_llvm_incdir}/lldb
 		vmove "${_llvm_libdir}/liblldb*.so"
 		for _f in "${_lldb19_devel_files[@]}"; do
 			vmove usr/${_llvm_prefix}/${_f}
@@ -826,20 +808,10 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
-	# alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
-	_lld19_devel_files=(
-		include/lld
-		lib/cmake/lld
-	)
-	for _alt in "${_lld19_devel_files[@]}"; do
-		alternatives+=" lld-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		vmove ${_llvm_incdir}/lld
+		vmove ${_llvm_libdir}/cmake/lld
 		vmove "${_llvm_libdir}/liblld*.a"
-
-		for _f in "${_lld19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 
@@ -883,23 +855,13 @@ mlir19-devel_package() {
 	conflicts="mlir18-devel>=0 mlir17-devel>=0"
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
-	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
-	_mlir19_devel_files=(
-		include/mlir
-		include/mlir-c
-	)
-	for _alt in "${_mlir19_devel_files[@]}"; do
-		alternatives+=" mlir-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		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*"
-
-		for _f in "${_mlir19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 
@@ -935,21 +897,12 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
-	_flang19_devel_files=(
-		include/flang
-		lib/cmake/flang
-	)
-	for _alt in "${_flang19_devel_files[@]}"; do
-		alternatives+=" flang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		vmove ${_llvm_incdir}/flang
+		vmove ${_llvm_libdir}/cmake/flang
 		vmove "${_llvm_libdir}/libFIR*.a"
 		vmove "${_llvm_libdir}/libHLFIR*.a"
 		vmove "${_llvm_libdir}/libCUF*.a"
-
-		for _f in "${_flang19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 
@@ -986,7 +939,6 @@ libomp19-devel_package() {
 	short_desc+=" - Clang OpenMP support library - development files"
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
-	alternatives="libomp-devel:/usr/lib/cmake/openmp:/${_llvm_libdir}/cmake/openmp"
 	pkg_install() {
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
@@ -1106,23 +1058,14 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	_llvm19_devel_files=(
-		lib/cmake/llvm
-		include/llvm
-		include/llvm-c
-	)
-	for _alt in "${_llvm19_devel_files[@]}"; do
-		alternatives+=" llvm-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
 		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"
-
-		for _f in "${_llvm19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
+		vmove ${_llvm_libdir}/cmake/llvm
 	}
 }
 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
  2024-11-16 20:15 ` [PR PATCH] [Updated] " Calandracas606
  2024-11-16 22:04 ` Calandracas606
@ 2024-11-16 22:06 ` Calandracas606
  2024-11-17  2:52 ` Calandracas606
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-16 22:06 UTC (permalink / raw)
  To: ml

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

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

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

DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
<!--
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 505b1f319ac61f6ef6841a3e14e8a65d0ed976d1 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 51 +++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..5dfe9007b4314f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -607,6 +596,10 @@ clang19-devel_package() {
 	fi
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
+	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
+	if [ "$build_option_polly" ]; then
+		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+	fi
 	pkg_install() {
 		vmove ${_llvm_incdir}/clang
 		vmove ${_llvm_incdir}/clang-c
@@ -816,6 +809,7 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
+	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
 	pkg_install() {
 		vmove ${_llvm_incdir}/lld
 		vmove ${_llvm_libdir}/cmake/lld
@@ -863,6 +857,7 @@ mlir19-devel_package() {
 	conflicts="mlir18-devel>=0 mlir17-devel>=0"
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
+	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
 	pkg_install() {
 		vmove ${_llvm_incdir}/mlir
 		vmove ${_llvm_incdir}/mlir-c
@@ -905,6 +900,7 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
+	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
 	pkg_install() {
 		vmove ${_llvm_incdir}/flang
 		vmove ${_llvm_libdir}/cmake/flang
@@ -947,6 +943,7 @@ libomp19-devel_package() {
 	short_desc+=" - Clang OpenMP support library - development files"
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
+	alternatives="libomp-devel:/usr/lib/cmake/openmp:/${_llvm_libdir}/cmake/openmp"
 	pkg_install() {
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
@@ -1066,7 +1063,7 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
+	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so

From bbf2e526f755f318e35567b1ac6c707ac0fc06ec Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 35 ++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..bdafc5f1b43498 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..55cfb758a50f7f
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,35 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From e542b41c5d19c326e9e0263bb907bd65ee31a4c6 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 15:15:09 -0500
Subject: [PATCH 4/6] llvm19: !fixup

---
 srcpkgs/llvm19/template | 105 ++++++++++++++++++++++++++++------------
 1 file changed, 74 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 5dfe9007b4314f..dd2c21d0ffd5cc 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -591,32 +591,41 @@ clang19-devel_package() {
 	 clang19>=${version}_${revision} clang-analyzer19>=${version}_${revision}
 	 llvm19>=${version}_${revision}"
 	conflicts="clang18-devel clang17-devel clang15-devel"
+	short_desc+=" - C language family frontend - development Files"
+	homepage="https://clang.llvm.org/"
+	_clang19_devel_files=(
+		include/clang
+		include/clang-c
+		lib/cmake/clang
+	)
 	if [ "$build_option_clang_tools_extra" ]; then
 		depends+=" clang-tools-extra19>=${version}_${revision}"
+		_clang19_devel_files+=(include/clang-tidy)
 	fi
-	short_desc+=" - C language family frontend - development Files"
-	homepage="https://clang.llvm.org/"
-	alternatives="clang19-devel:/usr/lib/cmake/clang:/${_llvm_libdir}/cmake/clang"
 	if [ "$build_option_polly" ]; then
-		alternatives+=" clang19-devel:/usr/lib/cmake/polly:/${_llvm_libdir}/cmake/polly"
+		_clang19_devel_files+=(
+			include/polly
+			lib/cmake/polly
+		)
 	fi
+	for _alt in "${_clang19_devel_files[@]}"; do
+		alternatives+=" clang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		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 ${_llvm_incdir}/clang-tidy
 			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
-			vmove ${_llvm_incdir}/polly
-			vmove ${_llvm_libdir}/cmake/polly
 			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
+		for _f in "${_clang19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
+
 	}
 }
 
@@ -766,9 +775,17 @@ lldb19-devel_package() {
 	depends="lldb19>=${version}_${revision}"
 	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
 	short_desc+=" - LLDB debugger - development files"
+	_lldb19_devel_files=(
+		include/lldb
+	)
+	for _alt in "${_lldb19_devel_files[@]}"; do
+		alternatives+=" lldb-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/lldb
 		vmove "${_llvm_libdir}/liblldb*.so"
+		for _f in "${_lldb19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -809,11 +826,20 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
-	alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
+	# alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
+	_lld19_devel_files=(
+		include/lld
+		lib/cmake/lld
+	)
+	for _alt in "${_lld19_devel_files[@]}"; do
+		alternatives+=" lld-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/lld
-		vmove ${_llvm_libdir}/cmake/lld
 		vmove "${_llvm_libdir}/liblld*.a"
+
+		for _f in "${_lld19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -858,13 +884,22 @@ mlir19-devel_package() {
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
 	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
+	_mlir19_devel_files=(
+		include/mlir
+		include/mlir-c
+	)
+	for _alt in "${_mlir19_devel_files[@]}"; do
+		alternatives+=" mlir-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		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*"
+
+		for _f in "${_mlir19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -900,13 +935,21 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
-	alternatives="flang-devel:/usr/lib/cmake/flang:/${_llvm_libdir}/cmake/flang"
+	_flang19_devel_files=(
+		include/flang
+		lib/cmake/flang
+	)
+	for _alt in "${_flang19_devel_files[@]}"; do
+		alternatives+=" flang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
-		vmove ${_llvm_incdir}/flang
-		vmove ${_llvm_libdir}/cmake/flang
 		vmove "${_llvm_libdir}/libFIR*.a"
 		vmove "${_llvm_libdir}/libHLFIR*.a"
 		vmove "${_llvm_libdir}/libCUF*.a"
+
+		for _f in "${_flang19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -1063,15 +1106,23 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives="llvm-devel:/usr/lib/cmake/llvm:/${_llvm_libdir}/cmake/llvm"
+	_llvm19_devel_files=(
+		lib/cmake/llvm
+		include/llvm
+		include/llvm-c
+	)
+	for _alt in "${_llvm19_devel_files[@]}"; do
+		alternatives+=" llvm-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
+	done
 	pkg_install() {
 		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
+
+		for _f in "${_llvm19_devel_files[@]}"; do
+			vmove usr/${_llvm_prefix}/${_f}
+		done
 	}
 }
 
@@ -1102,14 +1153,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From cab9bb85dfad376c53b22a8624756c20178d3def Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 17:04:22 -0500
Subject: [PATCH 5/6] llvm19: !fixup

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 10 ++-
 srcpkgs/llvm19/template                  | 87 ++++--------------------
 2 files changed, 24 insertions(+), 73 deletions(-)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 55cfb758a50f7f..59ce5305ad1479 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -6,9 +6,13 @@ _llvm_ver=${version%.*.*}
 build_style=cmake
 configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
  -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr"
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
 hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+# hostmakedepends="pkg-config"
 makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+# makedepends="SPIRV-Headers SPIRV-Tools-devel"
 short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="NCSA"
@@ -18,6 +22,10 @@ checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
+# if [ "$CROSS_BUILD" ]; then
+# 	# configure_args+=" -DLINK_DIRECTORIES=/usr/lib/llvm/19/lib/"
+# fi
+
 post_install() {
 	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
 	vlicense LICENSE.TXT
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dd2c21d0ffd5cc..dd69254f141db1 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -593,26 +593,14 @@ clang19-devel_package() {
 	conflicts="clang18-devel clang17-devel clang15-devel"
 	short_desc+=" - C language family frontend - development Files"
 	homepage="https://clang.llvm.org/"
-	_clang19_devel_files=(
-		include/clang
-		include/clang-c
-		lib/cmake/clang
-	)
 	if [ "$build_option_clang_tools_extra" ]; then
 		depends+=" clang-tools-extra19>=${version}_${revision}"
-		_clang19_devel_files+=(include/clang-tidy)
-	fi
-	if [ "$build_option_polly" ]; then
-		_clang19_devel_files+=(
-			include/polly
-			lib/cmake/polly
-		)
 	fi
-	for _alt in "${_clang19_devel_files[@]}"; do
-		alternatives+=" clang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		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
@@ -620,11 +608,10 @@ clang19-devel_package() {
 			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
+			vmove ${_llvm_incdir}/polly
+			vmove ${_llvm_libdir}/cmake/polly
 			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
-		for _f in "${_clang19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 
 	}
 }
@@ -775,13 +762,8 @@ lldb19-devel_package() {
 	depends="lldb19>=${version}_${revision}"
 	conflicts="lldb18-devel>=0 lldb17-devel>=0 lldb15-devel>=0"
 	short_desc+=" - LLDB debugger - development files"
-	_lldb19_devel_files=(
-		include/lldb
-	)
-	for _alt in "${_lldb19_devel_files[@]}"; do
-		alternatives+=" lldb-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		vmove ${_llvm_incdir}/lldb
 		vmove "${_llvm_libdir}/liblldb*.so"
 		for _f in "${_lldb19_devel_files[@]}"; do
 			vmove usr/${_llvm_prefix}/${_f}
@@ -826,20 +808,10 @@ lld19-devel_package() {
 	conflicts="lld18-devel>=0 lld17-devel>=0 lld15-devel>=0"
 	short_desc+=" - linker - development files"
 	homepage="https://lld.llvm.org"
-	# alternatives="lld19-devel:/usr/lib/cmake/lld:/${_llvm_libdir}/cmake/lld"
-	_lld19_devel_files=(
-		include/lld
-		lib/cmake/lld
-	)
-	for _alt in "${_lld19_devel_files[@]}"; do
-		alternatives+=" lld-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		vmove ${_llvm_incdir}/lld
+		vmove ${_llvm_libdir}/cmake/lld
 		vmove "${_llvm_libdir}/liblld*.a"
-
-		for _f in "${_lld19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 
@@ -883,23 +855,13 @@ mlir19-devel_package() {
 	conflicts="mlir18-devel>=0 mlir17-devel>=0"
 	short_desc+=" - multi-level IR compiler framework - development files"
 	homepage="https://mlir.llvm.org/"
-	alternatives="mlir-devel:/usr/lib/cmake/mlir:/${_llvm_libdir}/cmake/mlir"
-	_mlir19_devel_files=(
-		include/mlir
-		include/mlir-c
-	)
-	for _alt in "${_mlir19_devel_files[@]}"; do
-		alternatives+=" mlir-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		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*"
-
-		for _f in "${_mlir19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 
@@ -935,21 +897,12 @@ flang19-devel_package() {
 	conflicts="flang18-devel>=0 flang17-devel>=0"
 	short_desc+=" - Fortran language frontend - development files"
 	homepage="https://flang.llvm.org/"
-	_flang19_devel_files=(
-		include/flang
-		lib/cmake/flang
-	)
-	for _alt in "${_flang19_devel_files[@]}"; do
-		alternatives+=" flang-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
+		vmove ${_llvm_incdir}/flang
+		vmove ${_llvm_libdir}/cmake/flang
 		vmove "${_llvm_libdir}/libFIR*.a"
 		vmove "${_llvm_libdir}/libHLFIR*.a"
 		vmove "${_llvm_libdir}/libCUF*.a"
-
-		for _f in "${_flang19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 
@@ -986,7 +939,6 @@ libomp19-devel_package() {
 	short_desc+=" - Clang OpenMP support library - development files"
 	depends="libomp19>=${version}_${revision}"
 	conflicts="libomp18-devel>=0 libomp17-devel>=0"
-	alternatives="libomp-devel:/usr/lib/cmake/openmp:/${_llvm_libdir}/cmake/openmp"
 	pkg_install() {
 		if [ -f "${DESTDIR}/${_llvm_libdir}/libarcher.so" ]; then
 			vmove "${_llvm_libdir}/libarcher*.so"
@@ -1106,23 +1058,14 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	_llvm19_devel_files=(
-		lib/cmake/llvm
-		include/llvm
-		include/llvm-c
-	)
-	for _alt in "${_llvm19_devel_files[@]}"; do
-		alternatives+=" llvm-devel:/usr/${_alt}:/usr/${_llvm_prefix}/${_alt}"
-	done
 	pkg_install() {
 		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"
-
-		for _f in "${_llvm19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
+		vmove ${_llvm_libdir}/cmake/llvm
 	}
 }
 

From 0eb84216ccf64538528750a16ce86fa203a98189 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 17:06:14 -0500
Subject: [PATCH 6/6] llvm19: !fixup

---
 srcpkgs/llvm19/template | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dd69254f141db1..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -591,11 +591,11 @@ clang19-devel_package() {
 	 clang19>=${version}_${revision} clang-analyzer19>=${version}_${revision}
 	 llvm19>=${version}_${revision}"
 	conflicts="clang18-devel clang17-devel clang15-devel"
-	short_desc+=" - C language family frontend - development Files"
-	homepage="https://clang.llvm.org/"
 	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 ${_llvm_incdir}/clang
 		vmove ${_llvm_incdir}/clang-c
@@ -605,6 +605,7 @@ clang19-devel_package() {
 		vmove "${_llvm_libdir}/libclang*.so"
 		vmove ${_llvm_datadir}/clang
 		if [ "$build_option_clang_tools_extra" ]; then
+			vmove ${_llvm_incdir}/clang-tidy
 			vmove ${_llvm_libdir}/libfindAllSymbols.a
 		fi
 		if [ "$build_option_polly" ]; then
@@ -612,7 +613,6 @@ clang19-devel_package() {
 			vmove ${_llvm_libdir}/cmake/polly
 			vmove "${_llvm_libdir}/libPolly*.a"
 		fi
-
 	}
 }
 
@@ -765,9 +765,6 @@ lldb19-devel_package() {
 	pkg_install() {
 		vmove ${_llvm_incdir}/lldb
 		vmove "${_llvm_libdir}/liblldb*.so"
-		for _f in "${_lldb19_devel_files[@]}"; do
-			vmove usr/${_llvm_prefix}/${_f}
-		done
 	}
 }
 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (2 preceding siblings ...)
  2024-11-16 22:06 ` Calandracas606
@ 2024-11-17  2:52 ` Calandracas606
  2024-11-17 17:17 ` [PR PATCH] [Updated] " Calandracas606
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17  2:52 UTC (permalink / raw)
  To: ml

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

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

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

DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
<!--
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/4] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/4] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 6b6a4df744ba5731848dc7c6b83d35d9d3791174 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/4] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..bdafc5f1b43498 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From fe058bbbca813f4a9c0c39fe7edc53a6dbcf19fa Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/4] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (3 preceding siblings ...)
  2024-11-17  2:52 ` Calandracas606
@ 2024-11-17 17:17 ` Calandracas606
  2024-11-17 17:22 ` Calandracas606
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 17:17 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/4] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/4] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/4] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/4] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (4 preceding siblings ...)
  2024-11-17 17:17 ` [PR PATCH] [Updated] " Calandracas606
@ 2024-11-17 17:22 ` Calandracas606
  2024-11-17 18:15 ` Calandracas606
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 17:22 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/5] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/5] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (5 preceding siblings ...)
  2024-11-17 17:22 ` Calandracas606
@ 2024-11-17 18:15 ` Calandracas606
  2024-11-17 18:31 ` Calandracas606
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 18:15 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/6] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/6] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

From 54eb6c61adc75381fca08a13475f6eda792383a8 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 13:15:10 -0500
Subject: [PATCH 6/6] llvm19: !fixup nodebug

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

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dbe921cf647eed..63f1f00d628766 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -68,18 +68,19 @@ python_version=3
 
 nocross="im sorry buildbot"
 
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload llvm_spirv lto graphviz enable_debug full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
  libcxx libunwind"
 
 # mlir disabled to save space on builders
 # build_options_default+=" mlir"
 
+
+if [ ! "$build_option_full_debug" ] || [ ! "$build_option_enable_debug" ]; then
+	nodebug=yes
+fi
+
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
 	x86_64|i686) makedepends+=" libquadmath-devel" ;;

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (6 preceding siblings ...)
  2024-11-17 18:15 ` Calandracas606
@ 2024-11-17 18:31 ` Calandracas606
  2024-11-17 18:32 ` Calandracas606
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 18:31 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/6] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/6] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

From 8b7c9876d0a99735360b8cedfcbf70919e24c2cb Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 13:15:10 -0500
Subject: [PATCH 6/6] llvm19: !fixup nodebug

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

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dbe921cf647eed..cde9ac5242f152 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -68,18 +68,19 @@ python_version=3
 
 nocross="im sorry buildbot"
 
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload llvm_spirv lto graphviz enable_debug full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
  libcxx libunwind"
 
 # mlir disabled to save space on builders
 # build_options_default+=" mlir"
 
+
+if [ ! "$build_option_full_debug" ] && [ ! "$build_option_enable_debug" ]; then
+	nodebug=yes
+fi
+
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
 	x86_64|i686) makedepends+=" libquadmath-devel" ;;

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (7 preceding siblings ...)
  2024-11-17 18:31 ` Calandracas606
@ 2024-11-17 18:32 ` Calandracas606
  2024-11-17 19:38 ` Calandracas606
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 18:32 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/6] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/6] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

From 29196a8d5bb4ca50b102cc7bf7a512d937ffe78e Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 13:15:10 -0500
Subject: [PATCH 6/6] llvm19: !fixup nodebug

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

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dbe921cf647eed..a748dae5c8b62b 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -68,17 +68,14 @@ python_version=3
 
 nocross="im sorry buildbot"
 
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload llvm_spirv lto graphviz enable_debug full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
- libcxx libunwind"
+ libcxx libunwind mlir"
 
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+if [ ! "$build_option_full_debug" ] && [ ! "$build_option_enable_debug" ]; then
+	nodebug=yes
+fi
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -87,9 +84,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (8 preceding siblings ...)
  2024-11-17 18:32 ` Calandracas606
@ 2024-11-17 19:38 ` Calandracas606
  2024-11-17 19:59 ` Calandracas606
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 19:38 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/6] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/6] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

From d3d751e7be4157c322e0e03876d3e90aca7516a9 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 13:15:10 -0500
Subject: [PATCH 6/6] llvm19: !fixup nodebug

---
 srcpkgs/llvm19/template | 63 +++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dbe921cf647eed..8bbadea4cf15aa 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -68,17 +68,10 @@ python_version=3
 
 nocross="im sorry buildbot"
 
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 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 libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -87,9 +80,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -200,12 +191,6 @@ 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
@@ -260,24 +245,32 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -g1}
+		CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+	fi
 }
 
 pre_configure() {
@@ -286,6 +279,12 @@ pre_configure() {
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {
@@ -306,6 +305,8 @@ post_build() {
 		export CXX=${wrksrc}/llvm/build/bin/clang++
 	fi
 
+	_setup_debug
+
 	mkdir -p ${wrksrc}/${build_wrksrc}/builddir_runtimes
 	cmake -G Ninja ${wrksrc}/runtimes -B ${wrksrc}/${build_wrksrc}/builddir_runtimes \
 		-DCMAKE_INSTALL_PREFIX=/usr \

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (9 preceding siblings ...)
  2024-11-17 19:38 ` Calandracas606
@ 2024-11-17 19:59 ` Calandracas606
  2024-11-17 21:47 ` Calandracas606
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 19:59 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/6] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/6] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

From 53eaf16e567d5135cc4c61a1e6e89338385b76d2 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 13:15:10 -0500
Subject: [PATCH 6/6] llvm19: !fixup nodebug

---
 srcpkgs/llvm19/template | 61 ++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dbe921cf647eed..b7e3ecf2ebd2dc 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -68,17 +68,10 @@ python_version=3
 
 nocross="im sorry buildbot"
 
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 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 libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -87,9 +80,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -200,12 +191,6 @@ 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
@@ -260,24 +245,32 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -g1}
+		CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+	fi
 }
 
 pre_configure() {
@@ -286,6 +279,12 @@ pre_configure() {
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (10 preceding siblings ...)
  2024-11-17 19:59 ` Calandracas606
@ 2024-11-17 21:47 ` Calandracas606
  2024-11-17 21:49 ` Calandracas606
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 21:47 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/6] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From fb3141b34b2aa5382b2623ec5dbf771d2c7e80dd Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/6] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 50 +++++++++++++----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..29c67b5235265f 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,30 +47,25 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi
@@ -105,7 +100,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +167,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,7 +193,7 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	makedepends+=" lua53-devel "
 fi
@@ -245,12 +243,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -287,14 +279,11 @@ _setup_cross_cflags() {
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
 }
 
 post_build() {
@@ -567,8 +556,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1055,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1093,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 2a9cc43bf62541705cb35466f0ba9dbbcc608478 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/6] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 0ddb54a4413f25a63611f752002a3a5c5f2ef678 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/6] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 29c67b5235265f..dbe921cf647eed 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 if [ "$XBPS_WORDSIZE" == "32" ]; then
 	nodebug=yes  # 32bit memory exhasted
 fi

From c9447e5d1443bac1cb01eea6c5784a38034687b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/6] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

From 07bedfc255bd6e767e9d482d3af903aae9e51398 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 13:15:10 -0500
Subject: [PATCH 6/6] llvm19: !fixup nodebug

---
 srcpkgs/llvm19/template | 61 ++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index dbe921cf647eed..f52bfeb2dfde0c 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -68,17 +68,10 @@ python_version=3
 
 nocross="im sorry buildbot"
 
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 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 libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -87,9 +80,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -200,12 +191,6 @@ 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
@@ -260,24 +245,32 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -gline-tables-only}
+		CXXFLAGS=${CXXFLAGS/ -g/ -gline-tables-only}
+	fi
 }
 
 pre_configure() {
@@ -286,6 +279,12 @@ pre_configure() {
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (11 preceding siblings ...)
  2024-11-17 21:47 ` Calandracas606
@ 2024-11-17 21:49 ` Calandracas606
  2024-11-18  1:38 ` Calandracas606
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-17 21:49 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From d866fac8f94c238be93604a7a59d7536623640e7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 1472a83d3e2bbed4b43d4b1cacfe1a363ac14ed5 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 111 ++++++++++++++++------------------------
 1 file changed, 45 insertions(+), 66 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..319acac5abbda6 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -47,41 +47,29 @@ configure_args="
  -DBASE_LLVM_VERSION=${version}
  -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
 _spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 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 libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -90,9 +78,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -105,7 +91,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +158,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,17 +184,11 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	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
@@ -245,12 +228,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -266,35 +243,46 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -gline-tables-only}
+		CXXFLAGS=${CXXFLAGS/ -g/ -gline-tables-only}
+	fi
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {
@@ -567,8 +555,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1054,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1092,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 6fd60857aec9e55f34fb6c2e2de83720eda90364 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 7c5765d5337f7c..1f569a0c254bf2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 7e8b85adc9430c1cc777f320cc3aea18be6237c7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/5] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 319acac5abbda6..f52bfeb2dfde0c 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -66,6 +66,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 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 libclc polly lldb

From e496484a4b70e3076644623e8510c6954fc2348e Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/5] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (12 preceding siblings ...)
  2024-11-17 21:49 ` Calandracas606
@ 2024-11-18  1:38 ` Calandracas606
  2024-11-18  2:58 ` Calandracas606
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-18  1:38 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From 5220fcc0e044e7b38589f019b21a0a90809d913d Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 1e5fd51ab745b502003802c1dee37113c2962ec8 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 117 ++++++++++++++++------------------------
 1 file changed, 47 insertions(+), 70 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..3afb7a0f3f5e41 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -45,43 +45,29 @@ configure_args="
  -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
  -DLIBC_WNO_ERROR=YES
  -DBASE_LLVM_VERSION=${version}
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
+ python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
-_spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -90,9 +76,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -105,7 +89,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +156,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,17 +182,11 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	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
@@ -245,12 +226,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -266,35 +241,46 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -gline-tables-only}
+		CXXFLAGS=${CXXFLAGS/ -g/ -gline-tables-only}
+	fi
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {
@@ -567,8 +553,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1052,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1090,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 775faa194ca93d883baed0becb7811e17a12a1ae Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 808b1d5dd7dc8b..381c6ef8bcc866 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..1998680f7d07b9
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 8b254ee3da0d9ecb3f9e5326858be0c218768e77 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/5] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 1998680f7d07b9..8fad3a5fb149bb 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 3afb7a0f3f5e41..e6fd6a351893bf 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -64,6 +64,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
  openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb

From 7b867e268c2d0c8dfda4fbf52ce2ce7b112206c1 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/5] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (13 preceding siblings ...)
  2024-11-18  1:38 ` Calandracas606
@ 2024-11-18  2:58 ` Calandracas606
  2024-11-18  7:03 ` classabbyamp
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-18  2:58 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From 5220fcc0e044e7b38589f019b21a0a90809d913d Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 74 +++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..223bcfd2e01c1e
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,74 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+	echo "${configure_args}"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From 1e5fd51ab745b502003802c1dee37113c2962ec8 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 117 ++++++++++++++++------------------------
 1 file changed, 47 insertions(+), 70 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..3afb7a0f3f5e41 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -45,43 +45,29 @@ configure_args="
  -DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix
  -DLIBC_WNO_ERROR=YES
  -DBASE_LLVM_VERSION=${version}
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
+ python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
-_spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -90,9 +76,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -105,7 +89,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +156,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,17 +182,11 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	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
@@ -245,12 +226,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -266,35 +241,46 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -gline-tables-only}
+		CXXFLAGS=${CXXFLAGS/ -g/ -gline-tables-only}
+	fi
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {
@@ -567,8 +553,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1052,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1090,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 7882f287a2aea32f61e3f282799de82e0970b45c Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 808b1d5dd7dc8b..381c6ef8bcc866 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..d530bbfcd5746b
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator-devel>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From eec4351d0ff6be2ddaa15fe434bedddd46eecb58 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/5] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index d530bbfcd5746b..e16bf6356632b4 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 3afb7a0f3f5e41..e6fd6a351893bf 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -64,6 +64,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
  openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb

From 0179816bc511e8a490aa3c66ccd2e6bcc18ca798 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/5] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (14 preceding siblings ...)
  2024-11-18  2:58 ` Calandracas606
@ 2024-11-18  7:03 ` classabbyamp
  2024-11-18 20:54 ` [PR PATCH] [Updated] " Calandracas606
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: classabbyamp @ 2024-11-18  7:03 UTC (permalink / raw)
  To: ml

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

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/53096#issuecomment-2482112865

Comment:
could these be cleaned up?
```
CMake Warning:
  Manually-specified variables were not used by the project:

    BASE_LLVM_VERSION
    LIBC_WNO_ERROR
    LLDB_USE_SYSTEM_SIX
    LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR
    OFFLOAD_INSTALL_LIBDIR
```

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (15 preceding siblings ...)
  2024-11-18  7:03 ` classabbyamp
@ 2024-11-18 20:54 ` Calandracas606
  2024-11-18 20:58 ` Calandracas606
  2024-11-18 21:00 ` [PR PATCH] [Merged]: " classabbyamp
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-18 20:54 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From ba708288df2f26d492ccacde7077d671ea3cce2f Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 73 +++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..c209a3360d0ffa
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,73 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From d348af753bac16ed05b9fc2a019d6e0536990b43 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 120 ++++++++++++++++------------------------
 1 file changed, 47 insertions(+), 73 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..c140037362e266 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -16,7 +16,6 @@ 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_COMPILER_RT=YES
  -DLIBCXXABI_USE_LLVM_UNWINDER=YES
@@ -43,45 +42,29 @@ 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
- -DBASE_LLVM_VERSION=${version}
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
+ python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
-_spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -90,9 +73,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -105,7 +86,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +153,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,17 +179,11 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	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
@@ -245,12 +223,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -266,35 +238,46 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -gline-tables-only}
+		CXXFLAGS=${CXXFLAGS/ -g/ -gline-tables-only}
+	fi
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {
@@ -567,8 +550,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1049,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1087,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 7c8a0cd3401a5b2fb6bf1afa15b72ecd87d035b7 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 808b1d5dd7dc8b..381c6ef8bcc866 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..d530bbfcd5746b
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%.*.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator-devel>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 2f9557b5e2c5a46fae5d1a3b77f5656df0101d43 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/5] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index d530bbfcd5746b..e16bf6356632b4 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index c140037362e266..a70ea062bca608 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -61,6 +61,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
  openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb

From 8a0645ebe72c934bed432274ef7addf3ad649e45 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/5] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (16 preceding siblings ...)
  2024-11-18 20:54 ` [PR PATCH] [Updated] " Calandracas606
@ 2024-11-18 20:58 ` Calandracas606
  2024-11-18 21:00 ` [PR PATCH] [Merged]: " classabbyamp
  18 siblings, 0 replies; 20+ messages in thread
From: Calandracas606 @ 2024-11-18 20:58 UTC (permalink / raw)
  To: ml

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

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

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

llvm19: bootstrap build, fix cmake, fix spirv translator
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


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

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

From ba708288df2f26d492ccacde7077d671ea3cce2f Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:27:12 -0500
Subject: [PATCH 1/5] New package: llvm19-bootstrap-19.1.3

---
 srcpkgs/llvm19-bootstrap/patches  |  1 +
 srcpkgs/llvm19-bootstrap/template | 73 +++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/llvm19-bootstrap/patches
 create mode 100644 srcpkgs/llvm19-bootstrap/template

diff --git a/srcpkgs/llvm19-bootstrap/patches b/srcpkgs/llvm19-bootstrap/patches
new file mode 120000
index 00000000000000..61bc4babf371f0
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/patches
@@ -0,0 +1 @@
+../llvm19/patches
\ No newline at end of file
diff --git a/srcpkgs/llvm19-bootstrap/template b/srcpkgs/llvm19-bootstrap/template
new file mode 100644
index 00000000000000..c209a3360d0ffa
--- /dev/null
+++ b/srcpkgs/llvm19-bootstrap/template
@@ -0,0 +1,73 @@
+# Template file for 'llvm19-bootstrap'
+pkgname=llvm19-bootstrap
+version=19.1.3
+revision=1
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include
+ -DBASE_LLVM_VERSION=${version}
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_ENABLE_PROJECTS=clang;lld
+"
+hostmakedepends="perl python3 pkg-config"
+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"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
+homepage="https://www.llvm.org"
+_spirv_version=v19.1.1
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
+ https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
+checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
+ 7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336"
+skip_extraction=${_spirv_version}.tar.gz
+conflicts="llvm19>=0 llvm18>=0 llvm17>=0 llvm15>=0"
+lib32disabled=yes
+python_version=3
+nodebug=yes
+repository=bootstrap
+nocross="bootstrap package"
+
+# fails to build with libquadmth on musl
+case "$XBPS_TARGET_MACHINE" in
+	x86_64|i686) makedepends+=" libquadmath-devel" ;;
+esac
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES
+	 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF"
+fi
+
+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
+
+configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+
+pre_configure() {
+	configure_args+=" -DLLVM_HOST_TRIPLE=$($CC -dumpmachine)"
+	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=$($CXX -dumpmachine)"
+}
+
+post_extract() {
+	vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
+}
+
+post_install() {
+	vlicense ${wrksrc}/LICENSE.TXT
+}

From d348af753bac16ed05b9fc2a019d6e0536990b43 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:29:47 -0500
Subject: [PATCH 2/5] llvm19: bootstrap build, fix cmake and spirv translator.

---
 srcpkgs/llvm19/template | 120 ++++++++++++++++------------------------
 1 file changed, 47 insertions(+), 73 deletions(-)

diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index 774ef89d66064f..c140037362e266 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -1,7 +1,7 @@
 # Template file for 'llvm19'
 pkgname=llvm19
 version=19.1.3
-revision=2
+revision=3
 build_wrksrc=llvm
 build_style=cmake
 _llvm_prefix=lib/llvm/19
@@ -16,7 +16,6 @@ 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_COMPILER_RT=YES
  -DLIBCXXABI_USE_LLVM_UNWINDER=YES
@@ -43,45 +42,29 @@ 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
- -DBASE_LLVM_VERSION=${version}
- -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=NO
+ -DLLVM_SPIRV=/usr/bin/llvm-spirv
 "
 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
+ python3-mdit-py-plugins python3-MyST-Parser python3-markdown-it
  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"
+ libxml2-devel binutils-devel z3-devel"
 short_desc="LLVM Compiler Infrastructure Project - Version 19"
 maintainer="Daniel Martinez <danielmartinez@cock.li>"
 license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
 homepage="https://www.llvm.org"
-_spirv_version=v19.1.0
-distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz
- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
-checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
- 2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
-skip_extraction=${_spirv_version}.tar.gz
+distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
+checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
 conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
-CFLAGS="-Wno-unused-command-line-argument"
-CXXFLAGS="-Wno-unused-command-line-argument"
-
-if [ "$XBPS_WORDSIZE" == "32" ]; then
-	nodebug=yes  # 32bit memory exhasted
-fi
-
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
- openmp libc libcxx libunwind offload llvm_spirv lto graphviz full_debug"
+ openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb
- libcxx libunwind"
-
-# mlir disabled to save space on builders
-# build_options_default+=" mlir"
+ libcxx libunwind mlir"
 
 # fails to build with libquadmth on musl
 case "$XBPS_TARGET_MACHINE" in
@@ -90,9 +73,7 @@ esac
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|aarch64*|riscv64*)
-		build_options_default+=" bolt"
-		# flang disabled to save space on buildders
-		# build_options_default+=" flang"
+		build_options_default+=" bolt flang"
 		if [ -z "$CROSS_BUILD" ]; then
 			build_options_default+=" offload"
 		fi
@@ -105,7 +86,10 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ -z "$CROSS_BUILD" ]; then
-	build_options_default+=" llvm_spirv"
+	hostmakedepends+=" llvm19-bootstrap"
+
+	# Needs lld on the target machine
+	configure_args+=" -DLLVM_USE_LINKER=lld"
 fi
 
 # build fails because compiler_rt generates armv7 instructions when target is armv6
@@ -169,7 +153,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 SPIRV-LLVM-Translator19"
 
 	configure_args+=" -DLLVM_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
 	configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@@ -195,17 +179,11 @@ fi
 if [ -z "$CROSS_BUILD" ]; then
 	subpackages="llvm19-cross-tools ${subpackages}"
 	# OCaml cross build is broken
-	hostmakedepends+=" ocaml ocaml-findlib "
+	hostmakedepends+=" ocaml ocaml-findlib"
 	# lldb cross build fails with lua
 	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
@@ -245,12 +223,6 @@ _vlink_libs() {
 	done
 }
 
-post_extract() {
-	if [ "$build_option_llvm_spirv" ]; then
-		vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
-	fi
-}
-
 post_patch() {
 	# need libssp_nonshared on some musl platforms (because of nodefaultlibs)
 	case "$XBPS_TARGET_MACHINE" in
@@ -266,35 +238,46 @@ post_patch() {
 }
 
 _setup_cross_cflags() {
-		CC="clang"
-		CXX="clang++"
+	CC="clang"
+	CXX="clang++"
 
-		CFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
-		CXXFLAGS+=" -Wno-gnu-include-next -Wno-unused-command-line-argument"
+	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)
+	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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
+	CFLAGS+=" --gcc-toolchain=/usr"
+	CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/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+=" --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"
+}
+
+_setup_debug() {
+	if [ ! "$build_option_full_debug" ]; then
+		# Vastly reduce size of debugging symbols:
+		CFLAGS=${CFLAGS/ -g/ -gline-tables-only}
+		CXXFLAGS=${CXXFLAGS/ -g/ -gline-tables-only}
+	fi
 }
 
 pre_configure() {
+	CC="clang"
+	CXX="clang++"
 	if [ "$CROSS_BUILD" ]; then
 		_setup_cross_cflags
 	fi
-	if [ "$build_option_llvm_spirv" ]; then
-		configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv"
-	else
-		configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
-	fi
+
+	_setup_debug
+}
+
+pre_build() {
+	_setup_debug
 }
 
 post_build() {
@@ -567,8 +550,8 @@ clang19_package() {
 
 	if [ "$build_option_polly" ]; then
 		alternatives+="
-			clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
-			clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
+		 clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
+		 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
 		"
 	fi
 	pkg_install() {
@@ -1066,7 +1049,6 @@ llvm19-devel_package() {
 	if [ "$build_option_clang" ]; then
 		depends+=" clang19-devel>=${version}_${revision} "
 	fi
-	alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
 	pkg_install() {
 		vmove ${_llvm_libdir}/libLLVM.so
 		vmove ${_llvm_libdir}/libLTO.so
@@ -1105,14 +1087,6 @@ llvm19-cross-tools_package() {
 		if [ "$build_option_mlir" ]; then
 			vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
 		fi
-
-		if [ "$build_option_llvm_spirv" ]; then
-			patchelf --add-rpath '$ORIGIN/../lib' ${DESTDIR}/${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_bindir}/llvm-spirv
-			vmove ${_llvm_incdir}/LLVMSPIRVLib
-			vmove ${_llvm_libdir}/pkgconfig/LLVMSPIRVLib.pc
-			vmove "${_llvm_libdir}/libLLVMSPIRV*.a"
-		fi
 	}
 }
 

From 4b85870f6b92a1892c2b47f3e8a5a4cefb6205a8 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 14:31:52 -0500
Subject: [PATCH 3/5] New package: SPIRV-LLVM-Translator19

---
 common/shlibs                            |  1 +
 srcpkgs/SPIRV-LLVM-Translator19          |  1 -
 srcpkgs/SPIRV-LLVM-Translator19-devel    |  2 +-
 srcpkgs/SPIRV-LLVM-Translator19/template | 37 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
 delete mode 120000 srcpkgs/SPIRV-LLVM-Translator19
 create mode 100644 srcpkgs/SPIRV-LLVM-Translator19/template

diff --git a/common/shlibs b/common/shlibs
index 808b1d5dd7dc8b..381c6ef8bcc866 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1000,6 +1000,7 @@ libLLVM-17.so libllvm17-17.0.6_1
 libLLVM.so.18.1 libllvm18-18.1.8_1
 libLLVM.so.19.1 libllvm19-19.1.0_1
 libLLVMSPIRVLib.so.18.1 SPIRV-LLVM-Translator-18.1.2_1
+libLLVMSPIRVLib.so.19.1 SPIRV-LLVM-Translator19-19.1.1_1
 libomp.so.5 libomp-17.0.6_1
 libomptarget.so.18.1 libomp-18.1.8_1
 libisofs.so.6 libisofs-0.6.24_1
diff --git a/srcpkgs/SPIRV-LLVM-Translator19 b/srcpkgs/SPIRV-LLVM-Translator19
deleted file mode 120000
index 985027fe0a5c8d..00000000000000
--- a/srcpkgs/SPIRV-LLVM-Translator19
+++ /dev/null
@@ -1 +0,0 @@
-llvm19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19-devel b/srcpkgs/SPIRV-LLVM-Translator19-devel
index 985027fe0a5c8d..05559ceaa12cf0 120000
--- a/srcpkgs/SPIRV-LLVM-Translator19-devel
+++ b/srcpkgs/SPIRV-LLVM-Translator19-devel
@@ -1 +1 @@
-llvm19
\ No newline at end of file
+SPIRV-LLVM-Translator19
\ No newline at end of file
diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
new file mode 100644
index 00000000000000..449accfe440ab3
--- /dev/null
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -0,0 +1,37 @@
+# Template file for 'SPIRV-LLVM-Translator19'
+pkgname=SPIRV-LLVM-Translator19
+version=19.1.1
+revision=1
+_llvm_ver=${version%%.*}
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_SKIP_RPATH=ON
+ -DLLVM_SPIRV_INCLUDE_TESTS=OFF -DBUILD_SHARED_LIBS=ON
+ -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr
+ -DCMAKE_PREFIX_PATH=${XBPS_CROSS_BASE}/usr/lib/llvm/${_llvm_ver}
+"
+hostmakedepends="clang${_llvm_ver} llvm${_llvm_ver} pkg-config"
+makedepends="llvm${_llvm_ver}-devel SPIRV-Headers SPIRV-Tools-devel"
+short_desc="API and commands for processing SPIR-V modules - LLVM ${_llvm_ver}"
+maintainer="Daniel Martinez <danielmartinez@cock.li>"
+license="NCSA"
+homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
+distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
+checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
+
+alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
+
+post_install() {
+	mv ${DESTDIR}/usr/bin/llvm-spirv ${DESTDIR}/usr/bin/llvm-spirv-${_llvm_ver}
+	vlicense LICENSE.TXT
+}
+
+SPIRV-LLVM-Translator19-devel_package() {
+	depends="SPIRV-LLVM-Translator${_llvm_ver}-${version}_${revision}"
+	conflicts="SPIRV-LLVM-Translator-devel>=0"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 7ba43db2f511903bfe9bff39f5a8c6204ea903b6 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sat, 16 Nov 2024 21:52:09 -0500
Subject: [PATCH 4/5] llvm19: nocross (im sorry buildbot)

---
 srcpkgs/SPIRV-LLVM-Translator19/template | 2 ++
 srcpkgs/llvm19/template                  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/srcpkgs/SPIRV-LLVM-Translator19/template b/srcpkgs/SPIRV-LLVM-Translator19/template
index 449accfe440ab3..9fcf0aa84f87bd 100644
--- a/srcpkgs/SPIRV-LLVM-Translator19/template
+++ b/srcpkgs/SPIRV-LLVM-Translator19/template
@@ -18,6 +18,8 @@ homepage="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
 distfiles="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v${version}.tar.gz"
 checksum=7f6f7a1af0eb40910ddf3a7647d2186c8c5dc5a47945afa935aeec56bacf4336
 
+nocross="im sorry buildbot"
+
 alternatives="llvm-spirv:llvm-spirv:/usr/bin/llvm-spirv-${_llvm_ver}"
 
 post_install() {
diff --git a/srcpkgs/llvm19/template b/srcpkgs/llvm19/template
index c140037362e266..a70ea062bca608 100644
--- a/srcpkgs/llvm19/template
+++ b/srcpkgs/llvm19/template
@@ -61,6 +61,8 @@ conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
 lib32disabled=yes
 python_version=3
 
+nocross="im sorry buildbot"
+
 build_options="clang clang_tools_extra lld mlir libclc polly lldb flang bolt
  openmp libc libcxx libunwind offload lto graphviz full_debug"
 build_options_default="clang clang_tools_extra lld libclc polly lldb

From a36ef5153fc1b9a96650521107813eb422f65591 Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez@cock.li>
Date: Sun, 17 Nov 2024 12:21:58 -0500
Subject: [PATCH 5/5] llvm18: disable libcxx option

---
 srcpkgs/llvm18/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/llvm18/template b/srcpkgs/llvm18/template
index c72b16151ae53a..fd8b92e8d05523 100644
--- a/srcpkgs/llvm18/template
+++ b/srcpkgs/llvm18/template
@@ -49,7 +49,7 @@ 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 libcxx"
+build_options_default="clang clang_tools_extra lld mlir libclc polly lldb openmp"
 
 if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
 	build_options_default+=" flang bolt"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Merged]: llvm19: bootstrap build, fix cmake, fix spirv translator
  2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
                   ` (17 preceding siblings ...)
  2024-11-18 20:58 ` Calandracas606
@ 2024-11-18 21:00 ` classabbyamp
  18 siblings, 0 replies; 20+ messages in thread
From: classabbyamp @ 2024-11-18 21:00 UTC (permalink / raw)
  To: ml

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

There's a merged pull request on the void-packages repository

llvm19: bootstrap build, fix cmake, fix spirv translator
https://github.com/void-linux/void-packages/pull/53096

Description:
<!-- Uncomment relevant sections and delete options which are not applicable -->

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

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

<!-- 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):
  - x86_64-musl
  - i686
  - aarch64 (cross)
  - aarch64-musl (cross)
  - armv7l (cross)
  - armv7l-musl (cross)
  - armv6l (cross)
  - armv6l-musl (cross)

[ci skip]


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-11-18 21:00 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-16 19:33 [PR PATCH] DRAFT: llvm19: bootstrap build, fix cmake, fix spirv translator Calandracas606
2024-11-16 20:15 ` [PR PATCH] [Updated] " Calandracas606
2024-11-16 22:04 ` Calandracas606
2024-11-16 22:06 ` Calandracas606
2024-11-17  2:52 ` Calandracas606
2024-11-17 17:17 ` [PR PATCH] [Updated] " Calandracas606
2024-11-17 17:22 ` Calandracas606
2024-11-17 18:15 ` Calandracas606
2024-11-17 18:31 ` Calandracas606
2024-11-17 18:32 ` Calandracas606
2024-11-17 19:38 ` Calandracas606
2024-11-17 19:59 ` Calandracas606
2024-11-17 21:47 ` Calandracas606
2024-11-17 21:49 ` Calandracas606
2024-11-18  1:38 ` Calandracas606
2024-11-18  2:58 ` Calandracas606
2024-11-18  7:03 ` classabbyamp
2024-11-18 20:54 ` [PR PATCH] [Updated] " Calandracas606
2024-11-18 20:58 ` Calandracas606
2024-11-18 21:00 ` [PR PATCH] [Merged]: " classabbyamp

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).