llvm19: bootstrap build, fix cmake and spirv translator.

This commit is contained in:
Daniel Martinez 2024-11-16 14:29:47 -05:00 committed by classabbyamp
parent 9c15b1e011
commit 4044d000ce

View file

@ -1,7 +1,7 @@
# Template file for 'llvm19' # Template file for 'llvm19'
pkgname=llvm19 pkgname=llvm19
version=19.1.3 version=19.1.3
revision=2 revision=3
build_wrksrc=llvm build_wrksrc=llvm
build_style=cmake build_style=cmake
_llvm_prefix=lib/llvm/19 _llvm_prefix=lib/llvm/19
@ -16,7 +16,6 @@ configure_args="
-DCMAKE_BUILD_TYPE=Release -Wno-dev -DCMAKE_BUILD_TYPE=Release -Wno-dev
-DCMAKE_INSTALL_PREFIX=/usr/${_llvm_prefix} -DCMAKE_INSTALL_PREFIX=/usr/${_llvm_prefix}
-DENABLE_LINKER_BUILD_ID=YES -DENABLE_LINKER_BUILD_ID=YES
-DLLDB_USE_SYSTEM_SIX=YES
-DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
-DLIBCXXABI_USE_COMPILER_RT=YES -DLIBCXXABI_USE_COMPILER_RT=YES
-DLIBCXXABI_USE_LLVM_UNWINDER=YES -DLIBCXXABI_USE_LLVM_UNWINDER=YES
@ -43,45 +42,29 @@ configure_args="
-DLLDB_PYTHON_RELATIVE_PATH=lib/python${py3_ver}/site-packages -DLLDB_PYTHON_RELATIVE_PATH=lib/python${py3_ver}/site-packages
-DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver} -DLLDB_PYTHON_EXE_RELATIVE_PATH=bin/python${py3_ver}
-DLLDB_PYTHON_EXT_SUFFIX=$_ext_suffix -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_ENABLE_PER_TARGET_RUNTIME_DIR=NO
-DLLVM_SPIRV=/usr/bin/llvm-spirv
" "
hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx 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-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)" patchelf $(vopt_if graphviz graphviz)"
makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel 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" short_desc="LLVM Compiler Infrastructure Project - Version 19"
maintainer="Daniel Martinez <danielmartinez@cock.li>" maintainer="Daniel Martinez <danielmartinez@cock.li>"
license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception" license="Apache-2.0 AND NCSA AND custom:Apache-2.0-with-llvm-exception"
homepage="https://www.llvm.org" homepage="https://www.llvm.org"
_spirv_version=v19.1.0 distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz"
distfiles="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.tar.gz checksum=e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/${_spirv_version}.tar.gz"
checksum="e5106e2bef341b3f5e41340e4b6c6a58259f4021ad801acf14e88f1a84567b05
2e64231db8646d8c220d44136712549b5d4c4194c6ce0e57c4f5ab342beee9a2"
skip_extraction=${_spirv_version}.tar.gz
conflicts="llvm18>=0 llvm17>=0 llvm15>=0" conflicts="llvm18>=0 llvm17>=0 llvm15>=0"
lib32disabled=yes lib32disabled=yes
python_version=3 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 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 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"
# fails to build with libquadmth on musl # fails to build with libquadmth on musl
case "$XBPS_TARGET_MACHINE" in case "$XBPS_TARGET_MACHINE" in
@ -90,9 +73,7 @@ esac
case "$XBPS_TARGET_MACHINE" in case "$XBPS_TARGET_MACHINE" in
x86_64*|aarch64*|riscv64*) x86_64*|aarch64*|riscv64*)
build_options_default+=" bolt" build_options_default+=" bolt flang"
# flang disabled to save space on buildders
# build_options_default+=" flang"
if [ -z "$CROSS_BUILD" ]; then if [ -z "$CROSS_BUILD" ]; then
build_options_default+=" offload" build_options_default+=" offload"
fi fi
@ -105,7 +86,10 @@ case "$XBPS_TARGET_MACHINE" in
esac esac
if [ -z "$CROSS_BUILD" ]; then 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 fi
# build fails because compiler_rt generates armv7 instructions when target is armv6 # 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}" configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
if [ "$CROSS_BUILD" ]; then 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_TOOLS_BINAIRY_DIR=/${_llvm_bindir}"
configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}" configure_args+=" -DLLVM_NATIVE_TOOL_DIR=/${_llvm_bindir}"
@ -195,17 +179,11 @@ fi
if [ -z "$CROSS_BUILD" ]; then if [ -z "$CROSS_BUILD" ]; then
subpackages="llvm19-cross-tools ${subpackages}" subpackages="llvm19-cross-tools ${subpackages}"
# OCaml cross build is broken # OCaml cross build is broken
hostmakedepends+=" ocaml ocaml-findlib " hostmakedepends+=" ocaml ocaml-findlib"
# lldb cross build fails with lua # lldb cross build fails with lua
makedepends+=" lua53-devel " makedepends+=" lua53-devel "
fi 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 case "$XBPS_TARGET_MACHINE" in
arm*-musl|i686-musl) arm*-musl|i686-musl)
# sanitizer code is broken since it duplicates some libc bits # sanitizer code is broken since it duplicates some libc bits
@ -245,12 +223,6 @@ _vlink_libs() {
done done
} }
post_extract() {
if [ "$build_option_llvm_spirv" ]; then
vsrcextract -C llvm/projects/llvm-spirv ${_spirv_version}.tar.gz
fi
}
post_patch() { post_patch() {
# need libssp_nonshared on some musl platforms (because of nodefaultlibs) # need libssp_nonshared on some musl platforms (because of nodefaultlibs)
case "$XBPS_TARGET_MACHINE" in case "$XBPS_TARGET_MACHINE" in
@ -266,35 +238,46 @@ post_patch() {
} }
_setup_cross_cflags() { _setup_cross_cflags() {
CC="clang" CC="clang"
CXX="clang++" CXX="clang++"
CFLAGS+=" -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" 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+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
CFLAGS+=" --gcc-toolchain=/usr" CFLAGS+=" --gcc-toolchain=/usr"
CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include" CFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include"
CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}" CXXFLAGS+=" --target=${XBPS_CROSS_TRIPLET} --sysroot=${XBPS_CROSS_BASE}"
CXXFLAGS+=" --gcc-toolchain=/usr" CXXFLAGS+=" --gcc-toolchain=/usr"
CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}" 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%.*}/${XBPS_CROSS_TRIPLET}"
CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward" CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward"
CXXFLAGS+=" -isystem ${XBPS_CROSS_BASE}/usr/include" 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() { pre_configure() {
CC="clang"
CXX="clang++"
if [ "$CROSS_BUILD" ]; then if [ "$CROSS_BUILD" ]; then
_setup_cross_cflags _setup_cross_cflags
fi fi
if [ "$build_option_llvm_spirv" ]; then
configure_args+=" -DLLVM_SPIRV=${wrksrc}/llvm/build/bin/llvm-spirv" _setup_debug
else }
configure_args+=" -DLLVM_SPIRV=/${_llvm_bindir}/llvm-spirv"
fi pre_build() {
_setup_debug
} }
post_build() { post_build() {
@ -567,8 +550,8 @@ clang19_package() {
if [ "$build_option_polly" ]; then if [ "$build_option_polly" ]; then
alternatives+=" alternatives+="
clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so clang:/usr/lib/LLVMPolly.so:/${_llvm_libdir}/LLVMPolly.so
clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1 clang:/usr/share/man/man1/polly.1:/${_llvm_mandir}/man1/polly1.1
" "
fi fi
pkg_install() { pkg_install() {
@ -1066,7 +1049,6 @@ llvm19-devel_package() {
if [ "$build_option_clang" ]; then if [ "$build_option_clang" ]; then
depends+=" clang19-devel>=${version}_${revision} " depends+=" clang19-devel>=${version}_${revision} "
fi fi
alternatives+=" llvm-devel:/usr/lib/cmake/llvm:/usr/${_llvm_libdir}/cmake/llvm"
pkg_install() { pkg_install() {
vmove ${_llvm_libdir}/libLLVM.so vmove ${_llvm_libdir}/libLLVM.so
vmove ${_llvm_libdir}/libLTO.so vmove ${_llvm_libdir}/libLTO.so
@ -1105,14 +1087,6 @@ llvm19-cross-tools_package() {
if [ "$build_option_mlir" ]; then if [ "$build_option_mlir" ]; then
vcopy build/bin/mlir-src-sharder ${_llvm_bindir} vcopy build/bin/mlir-src-sharder ${_llvm_bindir}
fi 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
} }
} }