aboutsummaryrefslogtreecommitdiffstats
path: root/main/zstd/APKBUILD
blob: c73c00f95961a1e53725f7fae5b100549553af70 (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
# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: stef <l0ls0fo2i@ctrlc.hu>
# Contributor: André Klitzing <aklitzing@gmail.com>
# Maintainer: psykose <alice@ayaya.dev>
pkgname=zstd
pkgver=1.5.4
pkgrel=1
pkgdesc="Zstandard - Fast real-time compression algorithm"
url="https://www.zstd.net/"
arch="all"
license="BSD-3-Clause GPL-2.0-or-later"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="grep meson"
checkdepends="file"
subpackages="
	$pkgname-libs
	$pkgname-dev
	$pkgname-doc
	$pkgname-frugal
	"
source="zstd-$pkgver.tar.gz::https://github.com/facebook/zstd/archive/v$pkgver.tar.gz
	$pkgname-setvbuf-segfault.patch::https://github.com/facebook/zstd/commit/283c228abe369687b5641ff377815fa468fe1fab.patch
	zstdConfig.cmake
	zstdConfigVersion.cmake
	zstdTargets.cmake
	zstdTargets-none.cmake
	"
# we run the tests in build() for pgo, so it's tested from there.
# options="!check"

# secfixes:
#   1.4.9-r0:
#     - CVE-2021-24032
#   1.4.1-r0:
#     - CVE-2021-24031
#   1.3.8-r0:
#     - CVE-2019-11922

prepare() {
	default_prepare

	sed -i "s/_PKGVER_/$pkgver/g" "$srcdir"/zstdConfigVersion.cmake "$srcdir"/zstdTargets-none.cmake
}

build() {
	export CFLAGS="${CFLAGS/-Os/-O2} -flto=auto -ffat-lto-objects"
	export CXXFLAGS="${CXXFLAGS/-Os/-O2} -flto=auto -ffat-lto-objects"
	export CPPFLAGS="${CPPFLAGS/-Os/-O2} -flto=auto -ffat-lto-objects"
	if [ -z "$BOOTSTRAP" ]; then
		local pgo=true
	fi
	# 2-stage pgo+lto build (non-bootstrap), standard meson usage.
	# note that with clang,
	#  llvm-profdata merge --output=output/somefilename(?) output/*.profraw
	# is needed.
	# believe it or not, this is +30% faster on x86_64 than the default makefile build (same params)..
	# maybe needs more testing
	# shellcheck disable=2046
	abuild-meson \
		--default-library=both \
		$(test $pgo = true && echo -Db_pgo=generate) \
		-Dbin_contrib=true \
		-Dbin_programs=true \
		-Dbin_tests="$(want_check && echo true || echo false)" \
		-Dbacktrace=disabled \
		-Dmulti_thread=enabled \
		-Dlz4=disabled \
		-Dlzma=disabled \
		-Dzlib=disabled \
		build/meson output

	meson compile -C output

	if [ $pgo = true ]; then
		meson test -t 4 --no-rebuild --print-errorlogs -C output
		meson configure -Db_pgo=use output
		meson compile -C output
	fi
}

check() {
	# ran in build above, via pgo
	return 0
	#meson test -t 4 --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	install -Dm644 -t "$pkgdir"/usr/lib/cmake/zstd/ \
		"$srcdir"/*.cmake
}

frugal() {
	pkgdesc="$pkgdesc (frugal cli)"

	amove usr/bin/zstd-frugal
}

sha512sums="
b6f64850ceb6cfed831fff3c43508d2a72338862a96dd9430b1d3ebbfcee40201c8b6dcf8b6b603e252bb96f3f283c9cb07da7f24414187f5f1fea3b51e01863  zstd-1.5.4.tar.gz
f9ca75bd6c619d23d4ca26b73b019bdfbcbfbcede52a85e2fd5ef6d680dc2112cc58c3a736ffe45c07844c05ddd61d29d86357c6c8d3afeeafcc46da8680b649  zstd-setvbuf-segfault.patch
14f5b63928c1025c314d861b8937aa86605bbd20f9c6f21403660d6708cc2d5825bec77fb89d9a88b3b473eb92efec6f5222a9f4337d5dc7c478b3db74ea8759  zstdConfig.cmake
9f944061692c1e2e76fc7b818817ab2e4c55b18043d1ee205c277e454f5ef71040aa31a9d515f06ed15e6709bacee6f9cde007a515247d4a3c596b33a8285a3a  zstdConfigVersion.cmake
2139366f16a117bf0f165f5feb0e5aafddd020f1b8f285d45a46280d1293b69f01d01f4196b4e9786eee448e3eeb7a3e16302203fb1ca66fdae4f41ab2e94749  zstdTargets.cmake
7b340a57492a18832a5ed994d7db19f83b2d45f4ac8bb750d219fa12c15f8cb82f12396e7301cb84e959a37be9a708f59334ef0d83deb7f00934c510dac10432  zstdTargets-none.cmake
"