Diff thunderbird-102.15.1 with a thunderbird-115.3.0

/usr/portage/mail-client/thunderbird/thunderbird-115.3.0.ebuild 2023-10-09 14:52:31.576368403 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
FIREFOX_PATCHSET="firefox-102esr-patches-13.tar.xz"
6
FIREFOX_PATCHSET="firefox-115esr-patches-05.tar.xz"
7 7

  
8 8
LLVM_MAX_SLOT=16
9 9

  
......
12 12

  
13 13
WANT_AUTOCONF="2.1"
14 14

  
15
VIRTUALX_REQUIRED="pgo"
15
VIRTUALX_REQUIRED="manual"
16 16

  
17 17
MOZ_ESR=
18 18

  
......
37 37
MOZ_PV_DISTFILES="${MOZ_PV}${MOZ_PV_SUFFIX}"
38 38
MOZ_P_DISTFILES="${MOZ_PN}-${MOZ_PV_DISTFILES}"
39 39

  
40
inherit autotools check-reqs desktop flag-o-matic gnome2-utils \
40
inherit autotools check-reqs desktop flag-o-matic gnome2-utils linux-info \
41 41
	llvm multiprocessing optfeature pax-utils python-any-r1 toolchain-funcs \
42 42
	virtualx xdg
43 43

  
......
48 48
fi
49 49

  
50 50
PATCH_URIS=(
51
	https://dev.gentoo.org/~{juippis,whissi,slashbeast}/mozilla/patchsets/${FIREFOX_PATCHSET}
51
	https://dev.gentoo.org/~juippis/mozilla/patchsets/${FIREFOX_PATCHSET}
52 52
)
53 53

  
54 54
SRC_URI="${MOZ_SRC_BASE_URI}/source/${MOZ_P}.source.tar.xz -> ${MOZ_P_DISTFILES}.source.tar.xz
......
65 65
IUSE="+clang cpu_flags_arm_neon dbus debug eme-free hardened hwaccel"
66 66
IUSE+=" jack libproxy lto +openh264 pgo pulseaudio sndio selinux"
67 67
IUSE+=" +system-av1 +system-harfbuzz +system-icu +system-jpeg +system-libevent +system-libvpx system-png system-python-libs +system-webp"
68
IUSE+=" wayland wifi"
68
IUSE+=" wayland wifi +X"
69 69

  
70 70
# Thunderbird-only USE flags.
71 71
IUSE+=" +system-librnp"
72 72

  
73
REQUIRED_USE="debug? ( !system-av1 )
73
REQUIRED_USE="|| ( X wayland )
74
	debug? ( !system-av1 )
74 75
	pgo? ( lto )
75
	wayland? ( dbus )
76 76
	wifi? ( dbus )"
77 77

  
78
# Thunderbird-only dependencies.
79 78
TB_ONLY_DEPEND="!<x11-plugins/enigmail-2.2
80 79
	selinux? ( sec-policy/selinux-thunderbird )
81 80
	!system-librnp? ( dev-libs/jsoncpp )
82 81
	system-librnp? ( dev-util/librnp )"
83 82
BDEPEND="${PYTHON_DEPS}
84 83
	|| (
85
	(
84
		(
86 85
			sys-devel/clang:16
87 86
			sys-devel/llvm:16
88 87
			clang? (
89
				|| (
90
					sys-devel/lld:16
91
					sys-devel/mold
92
				)
88
				sys-devel/lld:16
93 89
				virtual/rust:0/llvm-16
94 90
				pgo? ( =sys-libs/compiler-rt-sanitizers-16*[profile] )
95 91
			)
......
103 99
				pgo? ( =sys-libs/compiler-rt-sanitizers-15*[profile] )
104 100
			)
105 101
		)
106
		(
107
			sys-devel/clang:14
108
			sys-devel/llvm:14
109
			clang? (
110
				sys-devel/lld:14
111
				virtual/rust:0/llvm-14
112
				pgo? ( =sys-libs/compiler-rt-sanitizers-14*[profile] )
113
			)
114
		)
115 102
	)
116
	!clang? ( virtual/rust )
103
	app-alternatives/awk
117 104
	app-arch/unzip
118 105
	app-arch/zip
119 106
	>=dev-util/cbindgen-0.24.3
120 107
	net-libs/nodejs
121 108
	virtual/pkgconfig
109
	!clang? ( >=virtual/rust-1.65 )
122 110
	amd64? ( >=dev-lang/nasm-2.14 )
123
	x86? ( >=dev-lang/nasm-2.14 )"
124

  
111
	x86? ( >=dev-lang/nasm-2.14 )
112
	pgo? (
113
		X? (
114
			sys-devel/gettext
115
			x11-base/xorg-server[xvfb]
116
			x11-apps/xhost
117
		)
118
		wayland? (
119
			>=gui-libs/wlroots-0.15.1-r1[tinywl]
120
			x11-misc/xkeyboard-config
121
		)
122
	)"
125 123
COMMON_DEPEND="${TB_ONLY_DEPEND}
126 124
	>=app-accessibility/at-spi2-core-2.46.0:2
127 125
	dev-libs/expat
128 126
	dev-libs/glib:2
129 127
	dev-libs/libffi:=
130
	>=dev-libs/nss-3.79.2
131
	>=dev-libs/nspr-4.34
128
	>=dev-libs/nss-3.90
129
	>=dev-libs/nspr-4.35
132 130
	media-libs/alsa-lib
133 131
	media-libs/fontconfig
134 132
	media-libs/freetype
......
136 134
	media-video/ffmpeg
137 135
	sys-libs/zlib
138 136
	virtual/freedesktop-icon-theme
139
	virtual/opengl
140
	x11-libs/cairo[X]
137
	x11-libs/cairo
141 138
	x11-libs/gdk-pixbuf
142
	x11-libs/gtk+:3[X]
143
	x11-libs/libX11
144
	x11-libs/libXcomposite
145
	x11-libs/libXdamage
146
	x11-libs/libXext
147
	x11-libs/libXfixes
148
	x11-libs/libXrandr
149
	x11-libs/libXtst
150
	x11-libs/libxcb:=
151
	x11-libs/libxkbcommon[X]
152 139
	x11-libs/pango
153 140
	x11-libs/pixman
154 141
	dbus? (
......
156 143
		sys-apps/dbus
157 144
	)
158 145
	jack? ( virtual/jack )
159
	libproxy? ( net-libs/libproxy )
160 146
	pulseaudio? (
161 147
		|| (
162 148
			media-libs/libpulse
163 149
			>=media-sound/apulse-0.1.12-r4[sdk]
164 150
		)
165 151
	)
152
	libproxy? ( net-libs/libproxy )
153
	selinux? ( sec-policy/selinux-mozilla )
166 154
	sndio? ( >=media-sound/sndio-1.8.0-r1 )
167 155
	system-av1? (
168 156
		>=media-libs/dav1d-1.0.0:=
......
172 160
		>=media-gfx/graphite2-1.3.13
173 161
		>=media-libs/harfbuzz-2.8.1:0=
174 162
	)
175
	system-icu? ( >=dev-libs/icu-71.1:= )
163
	system-icu? ( >=dev-libs/icu-73.1:= )
176 164
	system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1 )
177
	system-libevent? ( >=dev-libs/libevent-2.0:0=[threads(+)] )
165
	system-libevent? ( >=dev-libs/libevent-2.1.12:0=[threads(+)] )
178 166
	system-libvpx? ( >=media-libs/libvpx-1.8.2:0=[postproc] )
179 167
	system-png? ( >=media-libs/libpng-1.6.35:0=[apng] )
180 168
	system-webp? ( >=media-libs/libwebp-1.1.0:0= )
181 169
	wayland? (
170
		>=media-libs/libepoxy-1.5.10-r1
182 171
		x11-libs/gtk+:3[wayland]
183
		x11-libs/libdrm
184 172
		x11-libs/libxkbcommon[wayland]
185 173
	)
186 174
	wifi? (
......
189 177
			net-misc/networkmanager
190 178
			sys-apps/dbus
191 179
		)
180
	)
181
	X? (
182
		virtual/opengl
183
		x11-libs/cairo[X]
184
		x11-libs/gtk+:3[X]
185
		x11-libs/libX11
186
		x11-libs/libXcomposite
187
		x11-libs/libXdamage
188
		x11-libs/libXext
189
		x11-libs/libXfixes
190
		x11-libs/libxkbcommon[X]
191
		x11-libs/libXrandr
192
		x11-libs/libXtst
193
		x11-libs/libxcb:=
192 194
	)"
193

  
194 195
RDEPEND="${COMMON_DEPEND}
195 196
	jack? ( virtual/jack )
196 197
	openh264? ( media-libs/openh264:*[plugin] )"
197

  
198 198
DEPEND="${COMMON_DEPEND}
199
	x11-base/xorg-proto
200
	x11-libs/libICE
201
	x11-libs/libSM"
199
	X? (
200
		x11-base/xorg-proto
201
		x11-libs/libICE
202
		x11-libs/libSM
203
	)"
202 204

  
203 205
S="${WORKDIR}/${PN}-${PV%_*}"
204 206

  
......
208 210
		return 1
209 211
	fi
210 212

  
211
	if use clang ; then
213
	if use clang && ! tc-ld-is-mold ; then
212 214
		if ! has_version -b "sys-devel/lld:${LLVM_SLOT}" ; then
213 215
			einfo "sys-devel/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
214 216
			return 1
......
372 374
	mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}"
373 375
}
374 376

  
377
# This is a straight copypaste from toolchain-funcs.eclass's 'tc-ld-is-lld', and is temporarily
378
# placed here until toolchain-funcs.eclass gets an official support for mold linker.
379
# Please see:
380
# https://github.com/gentoo/gentoo/pull/28366 ||
381
# https://github.com/gentoo/gentoo/pull/28355
382
tc-ld-is-mold() {
383
	local out
384

  
385
	# Ensure ld output is in English.
386
	local -x LC_ALL=C
387

  
388
	# First check the linker directly.
389
	out=$($(tc-getLD "$@") --version 2>&1)
390
	if [[ ${out} == *"mold"* ]] ; then
391
		return 0
392
	fi
393

  
394
	# Then see if they're selecting mold via compiler flags.
395
	# Note: We're assuming they're using LDFLAGS to hold the
396
	# options and not CFLAGS/CXXFLAGS.
397
	local base="${T}/test-tc-linker"
398
	cat <<-EOF > "${base}.c"
399
	int main() { return 0; }
400
	EOF
401
	out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
402
	rm -f "${base}"*
403
	if [[ ${out} == *"mold"* ]] ; then
404
		return 0
405
	fi
406

  
407
	# No mold here!
408
	return 1
409
}
410

  
411
virtwl() {
412
	debug-print-function ${FUNCNAME} "$@"
413

  
414
	[[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument"
415
	[[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to be set; try xdg_environment_reset"
416
	tinywl -h >/dev/null || die 'tinywl -h failed'
417

  
418
	# TODO: don't run addpredict in utility function. WLR_RENDERER=pixman doesn't work
419
	addpredict /dev/dri
420
	local VIRTWL VIRTWL_PID
421
	coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo $WAYLAND_DISPLAY; read _; kill $PPID'; }
422
	local -x WAYLAND_DISPLAY
423
	read WAYLAND_DISPLAY <&${VIRTWL[0]}
424

  
425
	debug-print "${FUNCNAME}: $@"
426
	"$@"
427
	local r=$?
428

  
429
	[[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly"
430
	exec {VIRTWL[0]}<&- {VIRTWL[1]}>&-
431
	return $r
432
}
433

  
375 434
pkg_pretend() {
376 435
	if [[ ${MERGE_TYPE} != binary ]] ; then
377 436
		if use pgo ; then
......
410 469

  
411 470
		llvm_pkg_setup
412 471

  
413
		if use clang && use lto ; then
472
		if use clang && use lto && tc-ld-is-lld ; then
414 473
			local version_lld=$(ld.lld --version 2>/dev/null | awk '{ print $2 }')
415 474
			[[ -n ${version_lld} ]] && version_lld=$(ver_cut 1 "${version_lld}")
416 475
			[[ -z ${version_lld} ]] && die "Failed to read ld.lld version!"
......
448 507
		addpredict /proc/self/oom_score_adj
449 508

  
450 509
		if use pgo ; then
510
			# Update 105.0: "/proc/self/oom_score_adj" isn't enough anymore with pgo, but not sure
511
			# whether that's due to better OOM handling by Firefox (bmo#1771712), or portage
512
			# (PORTAGE_SCHEDULING_POLICY) update...
513
			addpredict /proc
514

  
515
			# May need a wider addpredict when using wayland+pgo.
516
			addpredict /dev/dri
517

  
451 518
			# Allow access to GPU during PGO run
452 519
			local ati_cards mesa_cards nvidia_cards render_cards
453 520
			shopt -s nullglob
......
526 593
		rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die
527 594
	fi
528 595

  
596
	if ! use ppc64; then
597
		rm -v "${WORKDIR}"/firefox-patches/*ppc64*.patch || die
598
	fi
599

  
529 600
	eapply "${WORKDIR}/firefox-patches"
530 601

  
531 602
	# Allow user to apply any additional patches without modifing ebuild
......
558 629
		|| die "sed failed to disable ccache stats call"
559 630

  
560 631
	einfo "Removing pre-built binaries ..."
561
	find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die
562 632

  
563
	# Clearing crate checksums where we have applied patches
564
	moz_clear_vendor_checksums bindgen
633
	find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die
565 634

  
566 635
	# Create build dir
567 636
	BUILD_DIR="${WORKDIR}/${PN}_build"
......
587 656
	if use clang; then
588 657
		# Force clang
589 658
		einfo "Enforcing the use of clang due to USE=clang ..."
659

  
660
		local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }')
661
		[[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}")
662
		[[ -z ${version_clang} ]] && die "Failed to read clang version!"
663

  
590 664
		if tc-is-gcc; then
591 665
			have_switched_compiler=yes
592 666
		fi
593 667
		AR=llvm-ar
594
		CC=${CHOST}-clang
595
		CXX=${CHOST}-clang++
668
		CC=${CHOST}-clang-${version_clang}
669
		CXX=${CHOST}-clang++-${version_clang}
596 670
		NM=llvm-nm
597 671
		RANLIB=llvm-ranlib
598 672
	elif ! use clang && ! tc-is-gcc ; then
......
612 686
		strip-unsupported-flags
613 687
	fi
614 688

  
615
	# Ensure we use correct toolchain
689
	# Ensure we use correct toolchain,
690
	# AS is used in a non-standard way by upstream, #bmo1654031
616 691
	export HOST_CC="$(tc-getBUILD_CC)"
617 692
	export HOST_CXX="$(tc-getBUILD_CXX)"
618 693
	export AS="$(tc-getCC) -c"
......
637 712

  
638 713
	# Initialize MOZCONFIG
639 714
	mozconfig_add_options_ac '' --enable-application=comm/mail
715
	mozconfig_add_options_ac '' --enable-project=comm/mail
640 716

  
641 717
	# Set Gentoo defaults
642
	export MOZILLA_OFFICIAL=1
643

  
644 718
	mozconfig_add_options_ac 'Gentoo default' \
645 719
		--allow-addon-sideload \
646 720
		--disable-cargo-incremental \
......
649 723
		--disable-install-strip \
650 724
		--disable-parental-controls \
651 725
		--disable-strip \
726
		--disable-tests \
652 727
		--disable-updater \
728
		--disable-wmf \
653 729
		--enable-js-shell \
730
		--enable-legacy-profile-creation \
654 731
		--enable-negotiateauth \
655 732
		--enable-new-pass-manager \
656 733
		--enable-official-branding \
657 734
		--enable-release \
658 735
		--enable-system-ffi \
659 736
		--enable-system-pixman \
737
		--enable-system-policies \
660 738
		--host="${CBUILD:-${CHOST}}" \
661 739
		--libdir="${EPREFIX}/usr/$(get_libdir)" \
662 740
		--prefix="${EPREFIX}/usr" \
......
685 763
	# For future keywording: This is currently (97.0) only supported on:
686 764
	# amd64, arm, arm64 & x86.
687 765
	# Might want to flip the logic around if Firefox is to support more arches.
688
	if use ppc64; then
766
	# bug 833001, bug 903411#c8
767
	if use ppc64 || use riscv; then
689 768
		mozconfig_add_options_ac '' --disable-sandbox
690 769
	else
691 770
		mozconfig_add_options_ac '' --enable-sandbox
692 771
	fi
693 772

  
773
	# Enable JIT on riscv64 explicitly
774
	# Can be removed once upstream enable it by default in the future.
775
	use riscv && mozconfig_add_options_ac 'Enable JIT for RISC-V 64' --enable-jit
776

  
694 777
	if [[ -s "${S}/api-google.key" ]] ; then
695 778
		local key_origin="Gentoo default"
696 779
		if [[ $(cat "${S}/api-google.key" | md5sum | awk '{ print $1 }') != 709560c02f94b41f9ad2c49207be6c54 ]] ; then
......
766 849

  
767 850
	mozconfig_use_enable wifi necko-wifi
768 851

  
769
	if use wayland ; then
852
	if use X && use wayland ; then
770 853
		mozconfig_add_options_ac '+x11+wayland' --enable-default-toolkit=cairo-gtk3-x11-wayland
854
	elif ! use X && use wayland ; then
855
		mozconfig_add_options_ac '+wayland' --enable-default-toolkit=cairo-gtk3-wayland-only
771 856
	else
772 857
		mozconfig_add_options_ac '+x11' --enable-default-toolkit=cairo-gtk3
773 858
	fi
774 859

  
775 860
	if use lto ; then
776 861
		if use clang ; then
777
			# Upstream only supports lld when using clang
778
			mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld
862
			# Upstream only supports lld or mold when using clang.
863
			if tc-ld-is-mold ; then
864
				mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
865
			else
866
				mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld
867
			fi
779 868

  
780 869
			mozconfig_add_options_ac '+lto' --enable-lto=cross
781 870

  
782 871
		else
783
			# ThinLTO is currently broken, see bmo#1644409
872
			# ThinLTO is currently broken, see bmo#1644409.
873
			# mold does not support gcc+lto combination.
784 874
			mozconfig_add_options_ac '+lto' --enable-lto=full
785 875
			mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd
786 876
		fi
......
796 886
	else
797 887
		# Avoid auto-magic on linker
798 888
		if use clang ; then
799
			# This is upstream's default
800
			mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld
889
			# lld is upstream's default
890
			if tc-ld-is-mold ; then
891
				mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
892
			else
893
				mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld
894
			fi
895

  
801 896
		else
802
			mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd
897
			if tc-ld-is-mold ; then
898
				mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
899
			else
900
				mozconfig_add_options_ac "linker is set to bfd due to USE=-clang" --enable-linker=bfd
901
			fi
803 902
		fi
804 903
	fi
805 904

  
......
809 908
	mozconfig_use_enable debug
810 909
	if use debug ; then
811 910
		mozconfig_add_options_ac '+debug' --disable-optimize
911
		mozconfig_add_options_ac '+debug' --enable-real-time-tracing
812 912
	else
913
		mozconfig_add_options_ac 'Gentoo defaults' --disable-real-time-tracing
914

  
813 915
		if is-flag '-g*' ; then
814 916
			if use clang ; then
815 917
				mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols=$(get-flag '-g*')
......
887 989
		fi
888 990
	fi
889 991

  
992
	if use elibc_musl && use arm64 ; then
993
		mozconfig_add_options_ac 'elf-hack is broken when using musl/arm64' --disable-elf-hack
994
	fi
995

  
890 996
	# Additional ARCH support
891 997
	case "${ARCH}" in
892 998
		arm)
......
902 1008
			;;
903 1009
	esac
904 1010

  
905
	if ! use elibc_glibc ; then
1011
	if ! use elibc_glibc; then
906 1012
		mozconfig_add_options_ac '!elibc_glibc' --disable-jemalloc
907 1013
	fi
908 1014

  
......
970 1076
src_compile() {
971 1077
	local virtx_cmd=
972 1078

  
973
	if use pgo ; then
974
		virtx_cmd=virtx
1079
	if tc-ld-is-mold && use lto; then
1080
		# increase ulimit with mold+lto, bugs #892641, #907485
1081
		if ! ulimit -n 16384 1>/dev/null 2>&1 ; then
1082
			ewarn "Unable to modify ulimits - building with mold+lto might fail due to low ulimit -n resources."
1083
			ewarn "Please see bugs #892641 & #907485."
1084
		else
1085
			ulimit -n 16384
1086
		fi
1087
	fi
975 1088

  
1089
	if use pgo; then
976 1090
		# Reset and cleanup environment variables used by GNOME/XDG
977 1091
		gnome2_environment_reset
978 1092

  
979 1093
		addpredict /root
1094

  
1095
		if ! use X; then
1096
			virtx_cmd=virtwl
1097
		else
1098
			virtx_cmd=virtx
1099
		fi
980 1100
	fi
981 1101

  
982
	local -x GDK_BACKEND=x11
1102
	if ! use X; then
1103
		local -x GDK_BACKEND=wayland
1104
	else
1105
		local -x GDK_BACKEND=x11
1106
	fi
983 1107

  
984
	${virtx_cmd} ./mach build --verbose \
985
		|| die
1108
	${virtx_cmd} ./mach build --verbose || die
986 1109
}
987 1110

  
988 1111
src_install() {
Thank you!