aboutsummaryrefslogtreecommitdiffstats
path: root/community/mozjs102/APKBUILD
blob: 1580de0aaa189c865a7efc775bd081eb8b519460 (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
# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Newbyte <newbie13xd@gmail.com>
pkgname=mozjs102
pkgver=102.8.0
pkgrel=0
pkgdesc="Standalone Mozilla JavaScript engine (102 ESR)"
url="https://spidermonkey.dev/"
# s390x: no lld
# armhf: unsupported assembly
arch="all !armhf !s390x"
license="MPL-2.0"
depends_dev="
	$pkgname
	icu-dev
	libffi-dev
	nspr-dev
	"
_llvmver=15
makedepends="
	$depends_dev
	cargo
	clang
	linux-headers
	lld
	llvm$_llvmver-dev
	m4
	perl
	python3
	rust
	sed
	zlib-dev
	"
checkdepends="icu-data-full"
subpackages="$pkgname-dev"

source="https://ftp.mozilla.org/pub/firefox/releases/${pkgver}esr/source/firefox-${pkgver}esr.source.tar.xz
	disable-moz-stackwalk.patch
	fix-musl-build.patch
	fix-rust-target.patch
	"
builddir="$srcdir"/firefox-$pkgver

case "$CARCH" in
riscv64)
	# binutils can't strip llvm output on riscv for some reason
	options="$options !strip"
	;;
esac

export CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse"

prepare() {
	default_prepare
	mkdir "$srcdir/mozbuild"

	# invalid as passed and fail the build
	unset RUSTFLAGS

	cat > .mozconfig <<- END
	ac_add_options --enable-application=js
	mk_add_options MOZ_OBJDIR='${PWD}'/obj
	ac_add_options --prefix=/usr
	ac_add_options --enable-release
	ac_add_options --enable-hardening
	ac_add_options --enable-optimize="$CFLAGS -O2"
	ac_add_options --enable-rust-simd
	ac_add_options --enable-linker=lld
	ac_add_options --disable-bootstrap
	ac_add_options --disable-debug
	ac_add_options --disable-debug-symbols
	ac_add_options --disable-jemalloc
	ac_add_options --disable-strip

	# System libraries
	ac_add_options --with-system-icu
	ac_add_options --with-system-nspr
	ac_add_options --with-system-zlib

	# Features
	ac_add_options --enable-shared-js
	ac_add_options --enable-tests
	ac_add_options --with-intl-api
	END
}

build() {
	export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=1048576"

	# FF doesn't have SIMD available on armhf/v7
	case "$CARCH" in
	arm*)
		echo 'ac_add_options --disable-rust-simd' >> .mozconfig
		;;
	*)
		echo 'ac_add_options --enable-rust-simd' >> .mozconfig
		;;
	esac

	unset CARGO_PROFILE_RELEASE_OPT_LEVEL
	unset CARGO_PROFILE_RELEASE_LTO
	export CC=clang
	export CXX=clang++
	export CFLAGS="$CFLAGS -O2"
	export CXXFLAGS="$CXXFLAGS -O2"
	export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
	export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
	export MOZ_NOSPAM=1
	export PYTHON=/usr/bin/python3
	export RUST_TARGET="$CTARGET"
	export SHELL=/bin/ash
	export RUSTFLAGS="$RUSTFLAGS -C debuginfo=1"

	./mach build
}

check() {
	obj/dist/bin/jsapi-tests \
		--format=none \
		--exclude-random \
		basic
}

package() {
	cd obj
	make DESTDIR="$pkgdir" install
	rm -f "$pkgdir"/usr/lib/*.ajs
}

sha512sums="
93ea87997b66088b94c6e943b6e99e9a71d1908444d096c0f65b6876d2c584e55ff6120266f3851f986b664bd1f12fa31206b03479c2b751e7c3ca097ac14275  firefox-102.8.0esr.source.tar.xz
454ea3263cabce099accbdc47aaf83be26a19f8b5a4568c01a7ef0384601cf8315efd86cd917f9c8bf419c2c845db89a905f3ff9a8eb0c8e41042e93aa96a85c  disable-moz-stackwalk.patch
bc91c2fb15eb22acb8acc36d086fb18fbf6f202b4511d138769b5ecaaed4a673349c55f808270c762616fafa42e3b01e74dc0af1dcbeea1289e043926e2750c8  fix-musl-build.patch
0b222a36cf3fd446dfb7fd171d77c58c0f19bc4df8f61cb2d99f2dfa0998a24e4d11a92fb88a1144b1bdd8ace95a858dca0a5e9ad5a4ea37a13b2cb7c245758a  fix-rust-target.patch
"