aboutsummaryrefslogtreecommitdiffstats
path: root/community/ldc/APKBUILD
blob: 8213a5585b27cf6a4377927e7e834328bc32e499 (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
# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Mathias LANG <pro.mathias.lang@gmail.com>
pkgname=ldc
pkgver=1.20.1
pkgrel=4
pkgdesc="The LLVM-based D Compiler"
url="https://github.com/ldc-developers/ldc"
# LDC does not support host compiling on most of the architecture Alpine supports
arch="x86_64"
license="BSD-3-Clause AND BSL-1.0 AND ( Artistic-1.0 OR GPL-2.0-or-later ) AND NCSA AND MIT"
depends="libexecinfo tzdata"
makedepends="chrpath cmake curl-dev diffutils gdmd llvm10-dev llvm10-static libedit-dev libexecinfo-static zlib-dev"
checkdepends="bash gdb grep llvm10-test-utils"
# A user might want to install the '-runtime' subpackage when they have
# a dynamically-linked D program.
subpackages="$pkgname-runtime $pkgname-static $pkgname-dbg"
source="https://github.com/ldc-developers/ldc/releases/download/v$pkgver/ldc-$pkgver-src.tar.gz
		01-conf.patch
		"
builddir="$srcdir/ldc-$pkgver-src/"

build() {
	# First, build LDC using GDC
	mkdir -p "$builddir/stage1"
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DD_COMPILER='gdmd' \
		$CMAKE_CROSSOPTS -S "$builddir" -B "$builddir/stage1"
	make -C "$builddir/stage1"

	# Then, self-build
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	# Don't use None buildtype for now, see
	# https://github.com/ldc-developers/ldc/issues/3386#issuecomment-603370855
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DD_COMPILER="$builddir/stage1/bin/ldmd2" \
		$CMAKE_CROSSOPTS "$builddir"
	make

	# Build the test runners
	make all-test-runners

	# CMake added the rpaths to the shared libs - strip them
	chrpath -d "$builddir"/lib/*.so*
	chrpath -d \
		"$builddir"/bin/ldc2 \
		"$builddir"/bin/ldmd2 \
		"$builddir"/bin/ldc-build-runtime \
		"$builddir"/bin/ldc-prune-cache
}

check() {
	export LD_LIBRARY_PATH="$builddir"/lib
	# Note: The testsuite does not parallelize well, as the 'clean' target get run in parallel.
	# Hence '-j${JOBS}' was left out on purpose
	#
	# - dmd-testsuite takes too long to run and has more to do with language checks
	#	which are less relevant to us than platform integration tests
	# - lit-test disabled because 'TEST 'LDC :: debuginfo/print_gdb.d' FAILED'
	#	Something to do with TLS variables not being printable in GDB
	# - 'druntime-test-shared' fails, probably because it is using 'Object.factory'
	# - 'druntime-test-stdcpp' fails for an unknown reason and is temporarily disabled
	# - 'druntime-test-exceptions' fails for an unknown reason and is temporarily disabled
	ctest --output-on-failure -E "dmd-testsuite|lit-tests|druntime-test-exceptions|druntime-test-shared|druntime-test-stdcpp"
}

package() {
	depends="$pkgname-static=$pkgver-r$pkgrel"
	# Use -j1, the install is flaky with too many build jobs
	make -j1 DESTDIR="$pkgdir" install
}

runtime() {
	depends="libexecinfo-dev"
	pkgdesc="Dynamic runtime library for D code compiled with $pkgname-$pkgver"

	mkdir -p "$subpkgdir/usr/lib/"
	for libn in "libdruntime" "libphobos2";
	do
		mv "$pkgdir"/usr/lib/$libn-ldc-shared.so* "$subpkgdir/usr/lib/"
	done
	mv "$pkgdir"/usr/lib/libldc-jit.so* "$subpkgdir/usr/lib"

	mv "$pkgdir"/usr/lib/*.so* "$subpkgdir/usr/lib/"
}

static() {
	depends="libexecinfo-static"
	pkgdesc="$pkgdesc (static library)"

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

sha512sums="bb699999a69de1773a10998c653b5a1b0bce30e39cfcee0e19b036378b28519b3118ac369b341cfd305a8a9bd904564ffffe83f720a62ab4f2c1942c2e26bb53  ldc-1.20.1-src.tar.gz
1a8ec8d75a5d01a1bc41e4b641e0663344fcbc44f3f10287f8cc716095faeadfa3dfc4ce7d84d72522151454e54d95e9f623ec5862e98e837d8fe44057307ce9  01-conf.patch"