291 lines
8.3 KiB
Bash
291 lines
8.3 KiB
Bash
# Template file for 'llvm9'
|
|
pkgname=llvm9
|
|
version=9.0.1
|
|
revision=5
|
|
wrksrc="llvm-${version}.src"
|
|
build_style=cmake
|
|
configure_args="
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
-DLLVM_INSTALL_UTILS=ON
|
|
-DLLVM_BUILD_LLVM_DYLIB=ON
|
|
-DLLVM_LINK_LLVM_DYLIB=ON
|
|
-DLLVM_ENABLE_RTTI=ON
|
|
-DLLVM_ENABLE_FFI=ON
|
|
-DLLVM_BINUTILS_INCDIR=/usr/include"
|
|
hostmakedepends="groff perl python3 zlib-devel libffi-devel swig"
|
|
makedepends="python3-devel zlib-devel libffi-devel libedit-devel
|
|
libxml2-devel binutils-devel libatomic-devel"
|
|
depends="libllvm9"
|
|
short_desc="Low Level Virtual Machine"
|
|
maintainer="q66 <daniel@octaforge.org>"
|
|
license="NCSA"
|
|
homepage="https://www.llvm.org"
|
|
distfiles="
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-${version}.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/lldb-${version}.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/lld-${version}.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/clang-${version}.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/clang-tools-extra-${version}.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/compiler-rt-${version}.src.tar.xz"
|
|
checksum="
|
|
00a1ee1f389f81e9979f3a640a01c431b3021de0d42278f6508391a2f0b81c9a
|
|
8a7b9fd795c31a3e3cba6ce1377a2ae5c67376d92888702ce27e26f0971beb09
|
|
86262bad3e2fd784ba8c5e2158d7aa36f12b85f2515e95bc81d65d75bb9b0c82
|
|
5778512b2e065c204010f88777d44b95250671103e434f9dc7363ab2e3804253
|
|
b26fd72a78bd7db998a26270ec9ec6a01346651d88fa87b4b323e13049fb6f07
|
|
c2bfab95c9986318318363d7f371a85a95e333bc0b34fbfa52edbd3f5e3a9077"
|
|
disable_parallel_builds=yes
|
|
lib32disabled=yes
|
|
# necessary to override auto default
|
|
python_version=3
|
|
|
|
_lldb_enable=yes
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
_lldb_enable=no
|
|
fi
|
|
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
ppc64le*) ;;
|
|
ppc*) _lldb_enable=no ;;
|
|
esac
|
|
|
|
subpackages="clang-tools-extra clang clang-analyzer libllvm9"
|
|
if [ "$_lldb_enable" = "yes" ]; then
|
|
# XXX fails to cross compile due to python
|
|
subpackages+=" lldb lldb-devel"
|
|
fi
|
|
subpackages+=" lld lld-devel"
|
|
|
|
post_patch() {
|
|
# patches
|
|
cd ${XBPS_BUILDDIR}/llvm-${version}.src
|
|
for i in ${FILESDIR}/patches/llvm/llvm-*.patch; do
|
|
msg_normal "Applying $i to llvm\n"
|
|
patch -sNp1 -i ${i}
|
|
done
|
|
|
|
cd ${XBPS_BUILDDIR}/clang-${version}.src
|
|
for i in ${FILESDIR}/patches/clang/clang-*.patch; do
|
|
msg_normal "Applying $i to clang\n"
|
|
patch -sNp1 -i ${i}
|
|
done
|
|
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
armv5*)
|
|
cd ${XBPS_BUILDDIR}/compiler-rt-${version}.src
|
|
for i in ${FILESDIR}/patches/compiler-rt/compiler-rt-*.patch; do
|
|
msg_normal "Applying $i to compiler-rt\n"
|
|
patch -sNp1 -i ${i}
|
|
done
|
|
;;
|
|
esac
|
|
|
|
if [ "$_lldb_enable" = "yes" ]; then
|
|
cd ${XBPS_BUILDDIR}/lldb-${version}.src
|
|
for i in ${FILESDIR}/patches/lldb/*.patch; do
|
|
msg_normal "Applying $i to lldb\n"
|
|
patch -sNp1 -i ${i}
|
|
done
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
*-musl) sed -i 's|__ptrace_request|int|g' source/Plugins/Process/Linux/NativeProcessLinux.cpp ;;
|
|
esac
|
|
fi
|
|
|
|
# Move clang files into the llvm source.
|
|
if [ -d ${XBPS_BUILDDIR}/clang-${version}.src ]; then
|
|
mv ${XBPS_BUILDDIR}/clang-${version}.src ${wrksrc}/tools/clang
|
|
fi
|
|
# Move clang-tools-extra files into llvm source.
|
|
if [ -d ${XBPS_BUILDDIR}/clang-tools-extra-${version}.src ]; then
|
|
mv ${XBPS_BUILDDIR}/clang-tools-extra-${version}.src ${wrksrc}/tools/clang/tools/extra
|
|
fi
|
|
# Move lld files into the llvm source.
|
|
if [ -d ${XBPS_BUILDDIR}/lld-${version}.src ]; then
|
|
mv ${XBPS_BUILDDIR}/lld-${version}.src ${wrksrc}/tools/lld
|
|
fi
|
|
# Move lldb files into the llvm source.
|
|
if [ "$_lldb_enable" = "yes" -a -d ${XBPS_BUILDDIR}/lldb-${version}.src ]; then
|
|
mv ${XBPS_BUILDDIR}/lldb-${version}.src ${wrksrc}/tools/lldb
|
|
fi
|
|
# Move compiler-rt files into the llvm source.
|
|
if [ -d ${XBPS_BUILDDIR}/compiler-rt-${version}.src ]; then
|
|
mv ${XBPS_BUILDDIR}/compiler-rt-${version}.src ${wrksrc}/projects/compiler-rt
|
|
fi
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
*-musl)
|
|
# Disable sanitizers
|
|
sed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' ${wrksrc}/projects/compiler-rt/cmake/config-ix.cmake
|
|
;;
|
|
esac
|
|
|
|
}
|
|
|
|
pre_configure() {
|
|
# Vastly reduce size of debugging symbols:
|
|
CFLAGS=${CFLAGS/ -g/ -g1}
|
|
CXXFLAGS=${CXXFLAGS/ -g/ -g1}
|
|
|
|
# since gcc9, the build likes to blow up for ppc32 apparently because
|
|
# of clang being too large for a 24-bit relative call to the PLT, so
|
|
# optimize for size instead
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
ppc|ppc-musl) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
|
|
esac
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
msg_normal "Building host tblgen\n"
|
|
mkdir -p build/HOST
|
|
cd build/HOST
|
|
CC="$BUILD_CC" CXX="$BUILD_CXX" CFLAGS="$BUILD_CFLAGS" \
|
|
CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" \
|
|
cmake ../.. -DCMAKE_BUILD_TYPE=Release
|
|
make ${makejobs} -C utils/TableGen
|
|
make ${makejobs} -C tools/clang/utils/TableGen
|
|
configure_args+=" -DLLVM_TABLEGEN=${wrksrc}/build/HOST/bin/llvm-tblgen"
|
|
configure_args+=" -DCLANG_TABLEGEN=${wrksrc}/build/HOST/bin/clang-tblgen"
|
|
cd ../..
|
|
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";;
|
|
esac
|
|
configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
|
|
configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}"
|
|
}
|
|
|
|
do_install() {
|
|
vlicense LICENSE.TXT
|
|
|
|
cd build
|
|
cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P cmake_install.cmake
|
|
|
|
# Fix permissions of static libs
|
|
chmod -x ${DESTDIR}/usr/lib/*.a
|
|
|
|
# Required for multilib.
|
|
if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
|
|
for _header in llvm-config; do
|
|
mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
|
|
vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
|
|
usr/include/llvm/Config ${_header}.h
|
|
done
|
|
fi
|
|
|
|
# Remove llvm-config-host in cross builds.
|
|
if [ "$CROSS_BUILD" ]; then
|
|
rm -f ${DESTDIR}/usr/bin/llvm-config-host
|
|
fi
|
|
}
|
|
|
|
clang-analyzer_package() {
|
|
archs=noarch
|
|
pycompile_dirs="usr/share/scan-view"
|
|
depends="clang-${version}_${revision} python3"
|
|
short_desc+=" - A source code analysis framework"
|
|
homepage="https://clang-analyzer.llvm.org/"
|
|
pkg_install() {
|
|
vmove usr/share/man/man1/scan-build.1
|
|
vmove "/usr/bin/scan-*"
|
|
vmove "/usr/share/scan-*"
|
|
vmove "/usr/libexec/*analyzer"
|
|
}
|
|
}
|
|
|
|
clang-tools-extra_package() {
|
|
depends="clang-${version}_${revision} python3"
|
|
short_desc+=" - Extra Clang tools"
|
|
homepage="https://clang.llvm.org/extra/"
|
|
pkg_install() {
|
|
vmove usr/bin/clang-apply-replacements
|
|
vmove usr/bin/clang-query
|
|
vmove usr/bin/clang-rename
|
|
vmove usr/bin/clang-tidy
|
|
vmove usr/bin/modularize
|
|
vmove "usr/lib/libclangApplyReplacements*"
|
|
vmove "usr/lib/libclangQuery*"
|
|
vmove "usr/lib/libclangTidy*"
|
|
vmove "usr/share/clang/*tidy*"
|
|
}
|
|
}
|
|
|
|
clang_package() {
|
|
lib32disabled=yes
|
|
depends="libstdc++-devel libgcc-devel binutils"
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
*-musl) depends+=" musl-devel";;
|
|
*) depends+=" glibc-devel";;
|
|
esac
|
|
short_desc+=" - C language family frontend"
|
|
homepage="https://clang.llvm.org/"
|
|
pkg_install() {
|
|
vmove usr/include/clang
|
|
vmove usr/include/clang-c
|
|
vmove "usr/bin/*clang*"
|
|
vmove usr/bin/c-index-test
|
|
vmove usr/lib/clang
|
|
vmove usr/lib/cmake/clang
|
|
vmove "usr/lib/libclang*"
|
|
vmove "usr/share/clang"
|
|
}
|
|
}
|
|
|
|
lld_package() {
|
|
lib32disabled=yes
|
|
short_desc+=" - linker"
|
|
homepage="https://lld.llvm.org"
|
|
pkg_install() {
|
|
vmove usr/bin/lld*
|
|
vmove usr/bin/wasm-ld
|
|
vmove usr/bin/ld.lld*
|
|
}
|
|
}
|
|
|
|
lld-devel_package() {
|
|
lib32disabled=yes
|
|
short_desc+=" - linker - development files"
|
|
homepage="https://lld.llvm.org"
|
|
pkg_install() {
|
|
vmove usr/include/lld
|
|
vmove "usr/lib/liblld*a"
|
|
}
|
|
}
|
|
|
|
lldb_package() {
|
|
lib32disabled=yes
|
|
depends+=" python3-six"
|
|
short_desc+=" - LLDB debugger"
|
|
homepage="https://lldb.llvm.org/"
|
|
pkg_install() {
|
|
vmove usr/bin/*lldb*
|
|
vmove usr/lib/liblldb*so.*
|
|
vman tools/lldb/docs/lldb.1
|
|
vmove /usr/lib/python*
|
|
# Depend on python3-six instead of conflicting
|
|
rm ${PKGDESTDIR}/usr/lib/python3*/site-packages/six.py
|
|
}
|
|
}
|
|
|
|
lldb-devel_package() {
|
|
depends="lldb>=${version}_${revision}"
|
|
short_desc+=" - LLDB debugger - development files"
|
|
pkg_install() {
|
|
vmove usr/include/lldb
|
|
vmove "usr/lib/liblldb*.so"
|
|
}
|
|
}
|
|
|
|
libllvm9_package() {
|
|
short_desc+=" - runtime library"
|
|
pkg_install() {
|
|
vmove "usr/lib/libLLVM-*.so*"
|
|
}
|
|
}
|