summaryrefslogtreecommitdiff
path: root/user/clang/APKBUILD
blob: 433d79ca37763c8665317dda183ce703fa004775 (plain) (blame)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Contributor Travis Tilley <ttilley@gmail.com>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=clang
# Note: Update together with llvm.
pkgver=18.1.8
pkgrel=0
_llvmver=${pkgver%%.*}
pkgdesc="A C language family front-end for LLVM"
arch="all"
options="!dbg"
url="https://llvm.org/"
license="NCSA"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="cmake isl-dev libedit-dev libexecinfo-dev libxml2-dev libxml2-utils
	llvm${_llvmver}-dev llvm${_llvmver}-static llvm${_llvmver}-test-utils
	z3 z3-dev"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs
	$pkgname-analyzer::noarch"
source="https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver/llvm-project-$pkgver.src.tar.xz
	0001-Add-support-for-Ad-lie-Linux.patch
	big-endian-32.patch
	cfe-005-ppc64-dynamic-linker-path.patch
	ppc-dirwatcher.patch
	ppc-interp.patch
	use-llvm-lit.patch
	"
builddir="$srcdir/llvm-project-$pkgver.src/$pkgname"

prepare() {
	default_prepare

	#1054
	rm -fr \
		test/Coverage/html-diagnostics.c \
		test/Coverage/html-multifile-diagnostics.c \
		test/Modules/crash-vfs-path-emptydir-entries.m \
		test/Modules/crash-vfs-path-symlink-component.m \
		test/Modules/crash-vfs-path-symlink-topheader.m \
		test/Modules/crash-vfs-path-traversal.m \
		test/Modules/crash-vfs-relative-overlay.m \
		test/Modules/crash-vfs-umbrella-frameworks.m \
		test/Modules/load-module-with-errors.m \
		test/Modules/modules-with-same-name.m \
		test/Modules/prebuilt-implicit-modules.m \
		test/Modules/prune.m \
		test/Modules/signal.m \
		test/VFS/module-header-mismatches.m \
		test/VFS/module_missing_vfs.m \
		test/utils/update_cc_test_checks/basic-cplusplus.test \
		test/utils/update_cc_test_checks/check-globals.test \
		test/utils/update_cc_test_checks/check_attrs.test \
		test/utils/update_cc_test_checks/def-and-decl.test \
		test/utils/update_cc_test_checks/exec-all-runlines.test \
		test/utils/update_cc_test_checks/explicit-template-instantiation.test \
		test/utils/update_cc_test_checks/generated-funcs-regex.test \
		test/utils/update_cc_test_checks/generated-funcs.test \
		test/utils/update_cc_test_checks/global-hex-value-regex.test \
		test/utils/update_cc_test_checks/global-value-regex.test \
		test/utils/update_cc_test_checks/mangled_names.test \
		test/utils/update_cc_test_checks/on_the_fly_arg_change.test \
		test/utils/update_cc_test_checks/prefix-never-matches.test \
		test/utils/update_cc_test_checks/replace-value-regex-across-runs.test \
		test/utils/update_cc_test_checks/resolve-tmp-conflict.test \
		;

	rm -f test/Driver/ppc-float-abi-warning.cpp
	# known broken on 32-bit platforms
	rm -f test/CodeGenCUDA/static-device-var-rdc.cu

	case $CARCH in
	ppc)
		for _interp_test in code-undo.cpp const.cpp execute-stmts.cpp \
			execute-weak.cpp execute.cpp fail.cpp global-dtor.cpp \
			inline-virtual.cpp lambda.cpp multiline.cpp \
			simple-exception.cpp; do
			rm test/Interpreter/$_interp_test
		done;;
	esac
}

build() {
	_build_type=MinSizeRel
	case $CARCH in
	ppc64)
		# https://github.com/llvm/llvm-project/issues/102192
		_build_type=Release;;
	esac
	CMAKE_PREFIX_PATH=/usr/lib/llvm$_llvmver/lib/cmake \
	cmake -Wno-dev \
		-DCMAKE_BUILD_TYPE=$_build_type \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=OFF \
		-DCLANG_VENDOR=${DISTRO_SHORT_NAME:-Adélie} \
		-DCLANG_BUILD_EXAMPLES=OFF \
		-DCLANG_INCLUDE_DOCS=ON \
		-DCLANG_INCLUDE_TESTS=ON \
		-DCLANG_PLUGIN_SUPPORT=ON \
		-DLIBCLANG_BUILD_STATIC=ON \
		-DLLVM_ENABLE_EH=ON \
		-DLLVM_ENABLE_RTTI=ON \
		-DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src" \
		-DLLVM_EXTERNAL_LIT="/usr/lib/llvm$_llvmver/bin/lit" \
		-Bbuild \
		.

	make -C build clang-tblgen
	# too memory hungry
	if [ -z "$JOBS" ] || [ $JOBS -gt 32 ]; then
		make -C build -j32
	else
		make -C build
	fi
}

check() {
	make -C build check-clang
}

package() {
	make DESTDIR="$pkgdir" -C build install
	install -m 644 build/lib/libclang.a "$pkgdir"/usr/lib

	# mozilla will never be happy
	mkdir -p "$pkgdir"/usr/lib/llvm$_llvmver/bin
	mkdir -p "$pkgdir"/usr/lib/llvm$_llvmver/lib
	for _dir in bin lib; do
		cd "$pkgdir"/usr/$_dir
		for _file in *; do
			[ -f $_file ] || continue
			ln -s "../../../$_dir/$_file" \
				"$pkgdir"/usr/lib/llvm$_llvmver/$_dir/$_file
		done
		cd "$OLDPWD"
	done

	# needed for at least Qt Creator
	mkdir -p "$pkgdir"/usr/include/llvm$_llvmver
	ln -s ../clang "$pkgdir"/usr/include/llvm$_llvmver/clang
	ln -s ../clang-c "$pkgdir"/usr/include/llvm$_llvmver/clang-c
}

static() {
	pkgdesc="Static libraries for clang"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/
	strip -d "$subpkgdir"/usr/lib/*.a
}

analyzer() {
	pkgdesc="Clang source code analysis framework"
	depends="$pkgname=$pkgver-r$pkgrel perl python3"

	cd "$pkgdir"

	mkdir -p "$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/libexec \
		"$subpkgdir"/usr/share/
	mv usr/bin/scan-* "$subpkgdir"/usr/bin/
	mv usr/libexec/*-analyzer "$subpkgdir"/usr/libexec/
	mv usr/share/scan-* "$subpkgdir"/usr/share/
}

sha512sums="25eeee9984c8b4d0fbc240df90f33cbb000d3b0414baff5c8982beafcc5e59e7ef18f6f85d95b3a5f60cb3d4cd4f877c80487b5768bc21bc833f107698ad93db  llvm-project-18.1.8.src.tar.xz
d37d2339a76c21666aa4405b2a620100e6967eb933535b5cea05f5de25a4d75510479443500715529cea38014028741d71553c7b247d5f349a05660133d66bc6  0001-Add-support-for-Ad-lie-Linux.patch
8928e5f4c5c7160ff1c8bf94b49b54198a6472dfbcb125db45fa0f1f0944b956a33af6004a34636d2ce15022a7ef5a8b77158d8093fb2adde889e0e8085067b3  big-endian-32.patch
8272ec0eeb93287c9cc961099139f7cb0f94561befc31a4521387fa5f7216dc4b3d99750c4560a0b71ec4acde5bd776abef733cfafe81058ef054b62f72fc209  cfe-005-ppc64-dynamic-linker-path.patch
0032fdd3864870d345caff9c4ff44f58bebc802bddf06c4b3bf30276c89e237167e6dea03456d322d3f6e2ee5e3a2ecf9f649ed033f0ab078b80bda44371b3ce  ppc-dirwatcher.patch
a2d90bcfc7cee261d6c8ac3b5dd011f55eab94deff456b63c5ef3598397e358b271e7ae86dec9e56c09c874736645ffbecccde4d31826d9b20908a4a16c61387  ppc-interp.patch
6c6b4fc49539ecf02e4eec9c2bbd89cc37fe01383e7884aa52c90ab0a4aa23cd9a86716bc645af6949f787d2fe3b9a3ad177baef1edbec928437872d14db536d  use-llvm-lit.patch"