From 5220fcc0e044e7b38589f019b21a0a90809d913d Mon Sep 17 00:00:00 2001 From: Daniel Martinez 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 " +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 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 " 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 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 " +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 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 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"