aboutsummaryrefslogtreecommitdiffstats
path: root/main/llvm/APKBUILD
blob: 9325ab8bb6ca87c133c9ede7fb29ff76ff4bb548 (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
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: Travis Tilley <ttilley@gmail.com>
pkgname=llvm
pkgver=3.8.0
pkgrel=0
pkgdesc="low level virtual machine compiler system"
arch="all"
url="http://llvm.org/"
license="UOI-NCSA"
depends=""
depends_dev="perl"
makedepends="$depends_dev
	binutils-dev
	bison
	chrpath
	cmake
	flex
	groff
	isl-dev
	libffi-dev
	make
	paxmark
	py-sphinx
	python
	python-dev
	zlib-dev
	"
install=
subpackages="$pkgname-static $pkgname-doc $pkgname-dev $pkgname-libs"
source="
	llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch
	llvm-0002-Fix-build-with-musl-libc.patch
	llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch
	llvm-nm-workaround.patch

	http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.xz
	"

_builddir="$srcdir"/build

_cmake_common_flags="\
"


_srcdir="$srcdir"/"$pkgname-$pkgver.src"

prepare() {
	msg "Patching LLVM core..."
	cd "$_srcdir" || return 1
	update_config_sub || return 1
	sed -i -e '/case "\${UNAME_MACHINE}:\${UNAME_SYSTEM}:\${UNAME_RELEASE}:\${UNAME_VERSION}" in/i \' \
	       -e 'if [ x != "x$CBUILD" ]; then echo "$CBUILD"; exit; fi' \
		./autoconf/config.guess || return 1
	for i in $source; do
		case $i in
		llvm-*.patch)
			msg "Applying $i..."
			patch -s -p1 -N -i "$srcdir"/$i || return 1
			;;
		esac
	done
	# remove some tests that fails
	rm test/tools/llvm-objdump/macho-compact-unwind-x86_64.test \
		test/tools/llvm-objdump/macho-compact-unwind-i386.test \
		test/Transforms/GlobalOpt/alias-used.ll \
		test/tools/llvm-symbolizer/print_context.c
		|| return 1
}

build() {
	mkdir -p "$_builddir"
	cd "$_builddir"

	# auto-detect it by guessing either.
	_ffi_include_dir="$(pkg-config --cflags-only-I libffi | sed 's|^-I||g')"

	cmake -G "Unix Makefiles" -Wno-dev \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=NO \
		\
		-DFFI_INCLUDE_DIR="$_ffi_include_dir" \
		-DLLVM_BINUTILS_INCDIR=/usr/include \
		-DLLVM_BUILD_DOCS=YES \
		-DLLVM_BUILD_EXAMPLES=NO \
		-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \
		-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
		-DLLVM_BUILD_TESTS=YES \
		-DLLVM_DEFAULT_TARGET_TRIPLE=$CBUILD \
		-DLLVM_DYLIB_EXPORT_ALL:BOOL=ON \
		-DLLVM_ENABLE_ASSERTIONS=NO \
		-DLLVM_ENABLE_CXX1Y=YES \
		-DLLVM_ENABLE_FFI=YES \
		-DLLVM_ENABLE_LIBCXX=NO \
		-DLLVM_ENABLE_PIC=YES \
		-DLLVM_ENABLE_RTTI=YES \
		-DLLVM_ENABLE_SPHINX=YES \
		-DLLVM_ENABLE_TERMINFO=YES \
		-DLLVM_ENABLE_ZLIB=YES \
		-DLLVM_HOST_TRIPLE=$CHOST \
		-DLLVM_INCLUDE_EXAMPLES=NO \
		-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
		-DLLVM_TARGETS_TO_BUILD=all \
		\
		-DSPHINX_WARNINGS_AS_ERRORS=NO \
		"${_srcdir}" || return 1

	make llvm-tblgen || return 1
	make || return 1

	paxmark m bin/llvm-rtdyld
	paxmark m bin/lli
	paxmark m bin/lli-child-target

	paxmark m unittests/ExecutionEngine/MCJIT/MCJITTests
	paxmark m unittests/Support/SupportTests


	case "$CARCH" in
	arm*)
		# ARM has few failures in test suite
		# that we don't care about currently
		;;
	*)
		make check-llvm		|| return 1
		;;
	esac
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install
	file "$pkgdir"/usr/lib/*.so | awk -F: '$2~/ELF/{print $1}' | xargs -r chrpath -d
	file "$pkgdir"/usr/bin/* | awk -F: '$2~/ELF/{print $1}' | xargs -r chrpath -d
}

static() {
	pkgdesc="LLVM static libraries"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/
}

dev() {
	default_dev || return 1
	mv "$pkgdir"/usr/lib/LLVMHello.so "$subpkgdir"/usr/lib/ || return 1
	mv "$pkgdir"/usr/share "$subpkgdir"/usr/ || return 1
}

libs() {
	pkgdesc="LLVM runtiem libraries"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libLLVM-[0-9]*.so* "$subpkgdir"/usr/lib/
}


md5sums="10904f363abd86c5c4729e5630ea319c  llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch
b0cd098117223159b76e96c3f884536b  llvm-0002-Fix-build-with-musl-libc.patch
9cc5050619f764ca9dc842a5ab122290  llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch
785147afd8ab80fa95955a5637b6582f  llvm-nm-workaround.patch
07a7a74f3c6bd65de4702bf941b511a0  llvm-3.8.0.src.tar.xz"
sha256sums="708db2b21570e48e2c2e155a0c7b7969acecbb82393e306b5b69b0353ac108dd  llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch
e1b0fd5f6918d8c8404f3ec4b8d3ab8fbe8dadc2d6011792349b56e5e8ee51e2  llvm-0002-Fix-build-with-musl-libc.patch
fc28356bf0d5fcfe9b99e28f4abbc2f49f50d263b44e428e30f33bf5472747b4  llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch
1870f910a6f5f2ba6144bd079ec55ed879fe8fd8b1b1b384935f36da43e5f114  llvm-nm-workaround.patch
555b028e9ee0f6445ff8f949ea10e9cd8be0d084840e21fbbe1d31d51fc06e46  llvm-3.8.0.src.tar.xz"
sha512sums="a97ad7a71ec4878f1a8a335dbc0c161323d957aeb95917b0c4837405c69b53b5f9718094e0e9fd7814c74f44aaa8cff3a9379202964b537c8162a53214621bc5  llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch
4cb3fabbb627b596ce398ed717c66ad20bbea7092ba30751520cc5a63d38e1ac53d23e98a6ad82121ddcf2434383ba5cadbc2990f99a4528e99c6e2160c2f725  llvm-0002-Fix-build-with-musl-libc.patch
19bfb9282455d39d07dbb2b1293b03a45c57d522fbb9c5e58dac034200669628b97e7a90cd4ff5d52d9bb79acfccbef653d8a1140a7f0589ecd6f9b7c4ba0eb6  llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch
11db6f3c5d697bc536c7d053530f7a5572756185e16399c32c31306861b58046ca9bc14b8d8097758c00a8c1a7026cbfb75636c0e697e59c53dda5848f93b006  llvm-nm-workaround.patch
2c76e79d803768ed20af6ca1801cf2518071bf9835c54580ea3eb6219a66cdcf8b4c575f192c15082cc18d2468b7611dacb57950b605813a2317125c2d33c138  llvm-3.8.0.src.tar.xz"