blob: 28eda046701f10f12ad94c35162901614afcc9b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# Maintainer: Donald Carr <sirspudd at gmail dot com>
# lto breaks build with gcc
# module support seem prone to breakage
# I run out of memory when compiling with ninja on a 7950x with 64G of ram
# I constrain the build with taskset --cpu-list 2-27 makepkg
pkgname=('clang-prefixed-release')
#pkgver=15.0.7
_pkgver=19.1.6
_pkg_suffix=
_pkgver_suffix=${_pkgver}
_pkgver_dash_suffix=${_pkgver}
if [[ -n ${_pkg_suffix} ]]; then
_pkgver_suffix=${_pkgver_suffix}${_pkg_suffix}
_pkgver_dash_suffix=${_pkgver_dash_suffix}-${_pkg_suffix}
fi
pkgver=${_pkgver_suffix}
pkgrel=1
arch=('x86_64')
url="https://llvm.org/"
license=('custom:Apache 2.0 with LLVM Exception')
makedepends=('git' 'cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2'
'swig' 'lld' 'python' 'libc++'
'ocl-icd' 'opencl-headers' 'z3' 'jsoncpp' 'clang' 'libunwind')
checkdepends=("python-psutil")
pkgdesc="Up to date official clang releases installed at /opt/clang/latest to avoid system wide usage/impact"
# stable
source=("https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${_pkgver_dash_suffix}.tar.gz")
sha512sums=('e77f4bf0088d32a27ed348ff6f166aad409c1c1c39053ae093a2a2a8961fbfb7a75f089b8f8144f04a3e285d411b9a47b420a2967bd850e8aa5c78c7682e6c2b')
install=clang.install
static_build=false
build_with_gcc=false
prefix_path="/opt/clang"
install_path="${prefix_path}/${pkgver}"
shared_library_build_options=" \
-DCMAKE_EXE_LINKER_FLAGS=-Wl,-Bsymbolic-functions \
-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-Bsymbolic-functions \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DCLANG_LINK_CLANG_DYLIB=ON \
"
enable_all_projects_minus_libc="-DLLVM_ENABLE_PROJECTS=bolt;clang;clang-tools-extra;libclc;lld;lldb;openmp;polly;pstl;compiler-rt"
#enable_all_projects="-DLLVM_ENABLE_PROJECTS=bolt;clang;clang-tools-extra;libc;libclc;lld;lldb;openmp;polly;pstl;compiler-rt"
# both modules and thinlto barf with gcc
# -DLLVM_ENABLE_MODULES=ON now barfs when compiling with clang 18, complaining about missing symbols
build_with_clang_options=" \
-DLLVM_BINUTILS_INCDIR=/usr/include \
-DLLVM_ENABLE_LLD=ON \
-DLLVM_ENABLE_LTO=Thin \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
${enable_all_projects_minus_libc} \
"
additional_build_options=""
if ! $static_build; then
additional_build_options="${additional_build_options} ${shared_library_build_options}"
fi
if $build_with_gcc; then
# libc extricated since it did not build with gcc 13 on last attempt; if it builds for you, let me know
additional_build_options="${additional_build_options} \
${enable_all_projects_minus_libc} \
"
else
additional_build_options="${additional_build_options} ${build_with_clang_options}"
fi
_prepare_install_script() {
cp ${startdir}/.clang.install ${startdir}/clang.install
sed -i "s,CLANG_PREFIX,${prefix_path},g" ${startdir}/clang.install
sed -i "s,CLANG_VERSION,${_pkgver_suffix},g" ${startdir}/clang.install
}
build() {
rm -rf _build
mkdir _build
env > _build/makepkg_env_dump
set > _build/makepkg_set_dump
# "clang;clang-tools-extra;libc;libclc;lld;lldb;openmp;polly;pstl;bolt;flang;libcxx;libcxxabi;libunwind"
(
set -o pipefail
# https://llvm.org/docs/CMake.html
# MinSizeRel
#-DCMAKE_BUILD_TYPE=MinSizeRel \
# we now support makepkg's CFLAGS; be warned that -Os does not successfully build
cmake -B _build \
-DCLANG_DEFAULT_PIE_ON_LINUX=ON \
-DLLVM_ABI_BREAKING_CHECKS:STRING=FORCE_OFF \
-DLLVM_ENABLE_UNWIND_TABLES=OFF \
-DLLVM_ENABLE_LIBCXX=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="${CFLAGS}" \
-DCMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \
-GNinja \
-DCMAKE_INSTALL_PREFIX:PATH=${install_path} \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
${additional_build_options} \
${srcdir}/llvm-project-llvmorg-${_pkgver_dash_suffix}/llvm | tee ${pkgname}-configure.log
time ninja -C _build | tee ${pkgname}-build.log
)
#perf record -e cycles:u -j any,u -- ninja -C _build
}
package() {
_prepare_install_script
(
set -o pipefail
#rm -Rf ${pkgdir}
DESTDIR="$pkgdir" ninja -C _build install | tee ${pkgname}-install.log
)
}
|