From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1362889-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 6C831158087
	for <garchives@archives.gentoo.org>; Sun, 30 Jan 2022 08:37:50 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id E4B122BC003;
	Sun, 30 Jan 2022 08:37:48 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 06C072BC003
	for <gentoo-commits@lists.gentoo.org>; Sun, 30 Jan 2022 08:37:48 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id F3670343444
	for <gentoo-commits@lists.gentoo.org>; Sun, 30 Jan 2022 08:37:46 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 6DAEE275
	for <gentoo-commits@lists.gentoo.org>; Sun, 30 Jan 2022 08:37:45 +0000 (UTC)
From: "Stephan Hartmann" <sultan@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Stephan Hartmann" <sultan@gentoo.org>
Message-ID: <1643531855.c65f1fb18943313a621d8cce43d0a68ebf65d2f4.sultan@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: www-client/chromium/files/, www-client/chromium/
X-VCS-Repository: repo/gentoo
X-VCS-Files: www-client/chromium/Manifest www-client/chromium/chromium-99.0.4840.0.ebuild www-client/chromium/chromium-99.0.4844.11.ebuild www-client/chromium/files/chromium-cross-compile.patch www-client/chromium/metadata.xml
X-VCS-Directories: www-client/chromium/files/ www-client/chromium/
X-VCS-Committer: sultan
X-VCS-Committer-Name: Stephan Hartmann
X-VCS-Revision: c65f1fb18943313a621d8cce43d0a68ebf65d2f4
X-VCS-Branch: master
Date: Sun, 30 Jan 2022 08:37:45 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: b44d32ee-cb35-40e1-9b29-2d5fd8d3c9b6
X-Archives-Hash: 1326d042d92d3a0a4bc16da912a2c062

commit:     c65f1fb18943313a621d8cce43d0a68ebf65d2f4
Author:     Stephan Hartmann <sultan <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 30 08:36:59 2022 +0000
Commit:     Stephan Hartmann <sultan <AT> gentoo <DOT> org>
CommitDate: Sun Jan 30 08:37:35 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c65f1fb1

www-client/chromium: dev channel bump to 99.0.4844.11

- improve headless builds
- fix cross compiling
- remove CHROMIUM_FORCE_LIBCXX and add USE=libcxx instead
- allow building with GTK4

Bug: https://bugs.gentoo.org/786597
Bug: https://bugs.gentoo.org/828442
Package-Manager: Portage-3.0.28, Repoman-3.0.3
Signed-off-by: Stephan Hartmann <sultan <AT> gentoo.org>

 www-client/chromium/Manifest                       |   4 +-
 ....4840.0.ebuild => chromium-99.0.4844.11.ebuild} | 242 +++++++++++++--------
 .../chromium/files/chromium-cross-compile.patch    |  12 +
 www-client/chromium/metadata.xml                   |   2 +
 4 files changed, 162 insertions(+), 98 deletions(-)

diff --git a/www-client/chromium/Manifest b/www-client/chromium/Manifest
index 1a157501d7c6..3bcb68c6ac93 100644
--- a/www-client/chromium/Manifest
+++ b/www-client/chromium/Manifest
@@ -2,5 +2,5 @@ DIST chromium-97-patchset-4.tar.xz 4240 BLAKE2B 450d013b6fd68f7e0bcb21a2b0828d53
 DIST chromium-97.0.4692.99.tar.xz 1213731872 BLAKE2B e7fdf30f562fe6d50615b8213e762825d3b346c9c87e3512c957cc68dc75bf31b551b262f72801a3b0b51f2ff5ee31939dc7d4b2c2f005a4aaaec1c37983909d SHA512 928684286b5bbc15b0e60bdf3b1eb5d644f31d13baa0b55c652b9e302f48776fac367af99d89b85ff8258455551846f7efb4f11772b182aa743c6beff844e7d5
 DIST chromium-98-patchset-5.tar.xz 4928 BLAKE2B f96fb34d5cb3c3ac2c6e327805322e5d6047b0b190a043795de1063c934ca6400800aafaaa4eea7ebad571298b96bf67e48ee0d2d1eb3e0bf23b14932734e026 SHA512 fae1010b91af7e6aa981ea22fc15c32a510b3e78ab71fec73b65290d963dfe6c42e5a2965446803519356858b60cd587018b1b2aea36e112e4d315efbdad7d8f
 DIST chromium-98.0.4758.74.tar.xz 1242612520 BLAKE2B ed4beb62e04254508d2d8ebd35c69308f403954bd082cd8dce0f23c5f36df155193c96d3204d8cf9a4d8767ca5a692a32a199d30ada6363865b000f86650332f SHA512 dd9ba829d4d8e28299f84eeaffa8f94d30cdc3daa7709938886a31e67fcb6a458bfcb68be69b31a92872e028b76a88421a1a1e02cd44c7d78ed7e4fc4da18e45
-DIST chromium-99-patchset-2.tar.xz 4264 BLAKE2B 3c81029085931df7db5724845a9a1ef17fd19e1964cdb53f78cf0b8c3765ff81f97ccea344e4db853f780c14e18b6bf1839f0ef142906042385bfcde01364ab8 SHA512 14eef917ecab7668072834aac277d2faf32e9c2ca85268a7591b94ff69e9df331c0114da1ebcb92a332f8ad066eeaebd841a937e80198baf4649065b677cc2c3
-DIST chromium-99.0.4840.0.tar.xz 1315491932 BLAKE2B 7c01c962e604c8147d446cf0e9fd86538b7112d93a535ffdfd2a938462f0e9edf51c12bf01b068ff0d64776726bbfb04991fbfa0dcfedd428e7ee79610534559 SHA512 79f9b2e8f7e56ae0bcc49d1f5b7dc306d167dfc6b2652874b6f4fc795d63c6f4dc3bb74545ba586e57ba5e0a5f350eaf8ac1202953d9ed2f94b71198f494c907
+DIST chromium-99-patchset-3.tar.xz 3912 BLAKE2B 79030156e81ebd6b3c348fb429e23d0c866059e047e7cdc0f656a1b1ee290f3afa8b358d0e1df18a86616a35a9a256e7432a5ab4e9b952c7a360aed871236659 SHA512 63d951cb3d17c1d02d9ddbee3a44aca000c5ba2f908012584944ce7fc435aebfe39b9628d4bd043df97c4dd7afa0ad614c65368ca759b64a84654126f06f9ea8
+DIST chromium-99.0.4844.11.tar.xz 1315744804 BLAKE2B f91dfdca603d789dbc34eeb563868f7ae20a2946b2978db7455b3b9f332fd2a8a59f3aa408dd99f77b13074b47a9992fc2aea029116b3363156f76e306efdb69 SHA512 eb353fe470abffb8f99a4aa8b86991b43678786f8b0c456c676ebe000653ba938384cc135438f5bee9f39e236908b1acef6e12fa2b13880b69177b0f271fdec4

diff --git a/www-client/chromium/chromium-99.0.4840.0.ebuild b/www-client/chromium/chromium-99.0.4844.11.ebuild
similarity index 85%
rename from www-client/chromium/chromium-99.0.4840.0.ebuild
rename to www-client/chromium/chromium-99.0.4844.11.ebuild
index 539cfcc65eb4..ce883356d49c 100644
--- a/www-client/chromium/chromium-99.0.4840.0.ebuild
+++ b/www-client/chromium/chromium-99.0.4844.11.ebuild
@@ -13,7 +13,7 @@ inherit check-reqs chromium-2 desktop flag-o-matic ninja-utils pax-utils python-
 
 DESCRIPTION="Open-source version of Google Chrome web browser"
 HOMEPAGE="https://chromium.org/"
-PATCHSET="2"
+PATCHSET="3"
 PATCHSET_NAME="chromium-$(ver_cut 1)-patchset-${PATCHSET}"
 SRC_URI="https://commondatastorage.googleapis.com/chromium-browser-official/${P}.tar.xz
 	https://github.com/stha09/chromium-patches/releases/download/${PATCHSET_NAME}/${PATCHSET_NAME}.tar.xz"
@@ -21,44 +21,64 @@ SRC_URI="https://commondatastorage.googleapis.com/chromium-browser-official/${P}
 LICENSE="BSD"
 SLOT="0/dev"
 KEYWORDS="~amd64 ~arm64 ~x86"
-IUSE="component-build cups cpu_flags_arm_neon debug +hangouts headless +js-type-check kerberos +official pic +proprietary-codecs pulseaudio screencast selinux +suid +system-ffmpeg +system-harfbuzz +system-icu +system-png vaapi wayland widevine"
+IUSE="component-build cups cpu_flags_arm_neon debug gtk4 +hangouts headless +js-type-check kerberos libcxx +official pic +proprietary-codecs pulseaudio screencast selinux +suid +system-ffmpeg +system-harfbuzz +system-icu +system-png vaapi wayland widevine"
 REQUIRED_USE="
-	component-build? ( !suid )
+	component-build? ( !suid !libcxx )
 	screencast? ( wayland )
 "
 
 COMMON_X_DEPEND="
-	media-libs/mesa:=[gbm(+)]
-	x11-libs/libX11:=
+	x11-libs/gdk-pixbuf:2
 	x11-libs/libXcomposite:=
 	x11-libs/libXcursor:=
 	x11-libs/libXdamage:=
-	x11-libs/libXext:=
 	x11-libs/libXfixes:=
 	>=x11-libs/libXi-1.6.0:=
 	x11-libs/libXrandr:=
 	x11-libs/libXrender:=
 	x11-libs/libXtst:=
-	x11-libs/libxcb:=
 	x11-libs/libxshmfence:=
-	vaapi? ( >=x11-libs/libva-2.7:=[X,drm] )
+	virtual/opengl
 "
 
-COMMON_DEPEND="
-	app-arch/bzip2:=
-	cups? ( >=net-print/cups-1.3.11:= )
-	dev-libs/expat:=
-	dev-libs/glib:2
+COMMON_SNAPSHOT_DEPEND="
+	system-icu? ( >=dev-libs/icu-69.1:= )
 	>=dev-libs/libxml2-2.9.4-r3:=[icu]
 	dev-libs/nspr:=
 	>=dev-libs/nss-3.26:=
-	>=media-libs/alsa-lib-1.0.19:=
+	!libcxx? ( >=dev-libs/re2-0.2019.08.01:= )
+	dev-libs/libxslt:=
 	media-libs/fontconfig:=
 	>=media-libs/freetype-2.11.0-r1:=
 	system-harfbuzz? ( >=media-libs/harfbuzz-3:0=[icu(-)] )
 	media-libs/libjpeg-turbo:=
 	system-png? ( media-libs/libpng:=[-apng] )
-	pulseaudio? ( media-sound/pulseaudio:= )
+	>=media-libs/libwebp-0.4.0:=
+	media-libs/mesa:=[gbm(+)]
+	>=media-libs/openh264-1.6.0:=
+	sys-libs/zlib:=
+	x11-libs/libdrm:=
+	!headless? (
+		dev-libs/glib:2
+		>=media-libs/alsa-lib-1.0.19:=
+		pulseaudio? ( media-sound/pulseaudio:= )
+		kerberos? ( virtual/krb5 )
+		vaapi? ( >=x11-libs/libva-2.7:=[X,drm] )
+		x11-libs/libX11:=
+		x11-libs/libXext:=
+		x11-libs/libxcb:=
+		x11-libs/libxkbcommon:=
+		wayland? (
+			dev-libs/wayland:=
+			screencast? ( media-video/pipewire:= )
+		)
+	)
+"
+
+COMMON_DEPEND="
+	${COMMON_SNAPSHOT_DEPEND}
+	app-arch/bzip2:=
+	dev-libs/expat:=
 	system-ffmpeg? (
 		>=media-video/ffmpeg-4.3:=
 		|| (
@@ -69,45 +89,46 @@ COMMON_DEPEND="
 	)
 	net-misc/curl[ssl]
 	sys-apps/dbus:=
-	sys-apps/pciutils:=
-	virtual/udev
-	x11-libs/cairo:=
-	x11-libs/gdk-pixbuf:2
-	x11-libs/libxkbcommon:=
-	x11-libs/pango:=
 	media-libs/flac:=
-	>=media-libs/libwebp-0.4.0:=
 	sys-libs/zlib:=[minizip]
-	kerberos? ( virtual/krb5 )
 	!headless? (
 		${COMMON_X_DEPEND}
 		>=app-accessibility/at-spi2-atk-2.26:2
 		>=app-accessibility/at-spi2-core-2.26:2
 		>=dev-libs/atk-2.26
-		x11-libs/gtk+:3[X]
-		wayland? (
-			dev-libs/wayland:=
-			screencast? ( media-video/pipewire:= )
-			x11-libs/gtk+:3[wayland,X]
-			x11-libs/libdrm:=
-		)
+		cups? ( >=net-print/cups-1.3.11:= )
+		sys-apps/pciutils:=
+		virtual/udev
+		x11-libs/cairo:=
+		x11-libs/pango:=
 	)
 "
 RDEPEND="${COMMON_DEPEND}
+	!headless? (
+		|| (
+			x11-libs/gtk+:3[X,wayland?]
+			gui-libs/gtk:4[X,wayland?]
+		)
+	)
 	x11-misc/xdg-utils
-	virtual/opengl
 	virtual/ttf-fonts
 	selinux? ( sec-policy/selinux-chromium )
 "
 DEPEND="${COMMON_DEPEND}
+	!headless? (
+		gtk4? ( gui-libs/gtk:4[X,wayland?] )
+		!gtk4? ( x11-libs/gtk+:3[X,wayland?] )
+	)
 "
 # dev-vcs/git - https://bugs.gentoo.org/593476
 BDEPEND="
+	${COMMON_SNAPSHOT_DEPEND}
 	${PYTHON_DEPS}
 	$(python_gen_any_dep '
 		dev-python/setuptools[${PYTHON_USEDEP}]
 	')
 	>=app-arch/gzip-1.7
+	libcxx? ( >=sys-devel/clang-12 )
 	dev-lang/perl
 	>=dev-util/gn-0.1807
 	dev-vcs/git
@@ -122,26 +143,11 @@ BDEPEND="
 
 # These are intended for ebuild maintainer use to force clang if GCC is broken.
 : ${CHROMIUM_FORCE_CLANG=no}
-: ${CHROMIUM_FORCE_LIBCXX=no}
 
 if [[ ${CHROMIUM_FORCE_CLANG} == yes ]]; then
 	BDEPEND+=" >=sys-devel/clang-12"
 fi
 
-if [[ ${CHROMIUM_FORCE_LIBCXX} == yes ]]; then
-	RDEPEND+=" >=sys-libs/libcxx-12"
-	DEPEND+=" >=sys-libs/libcxx-12"
-else
-	COMMON_DEPEND="
-		dev-libs/libxslt:=
-		>=dev-libs/re2-0.2019.08.01:=
-		>=media-libs/openh264-1.6.0:=
-		system-icu? ( >=dev-libs/icu-69.1:= )
-	"
-	RDEPEND+="${COMMON_DEPEND}"
-	DEPEND+="${COMMON_DEPEND}"
-fi
-
 if ! has chromium_pkg_die ${EBUILD_DEATH_HOOKS}; then
 	EBUILD_DEATH_HOOKS+=" chromium_pkg_die";
 fi
@@ -185,8 +191,9 @@ pre_build_checks() {
 		if tc-is-gcc && ! ver_test "$(gcc-version)" -ge 9.2; then
 			die "At least gcc 9.2 is required"
 		fi
-		if [[ ${CHROMIUM_FORCE_CLANG} == yes ]] || tc-is-clang; then
-			CPP="${CHOST}-clang++ -E"
+		if [[ ${CHROMIUM_FORCE_CLANG} == yes ]] || tc-is-clang || use libcxx; then
+			tc-is-cross-compiler && CPP=${CBUILD}-clang++ || CPP=${CHOST}-clang++
+			CPP+=" -E"
 			if ! ver_test "$(clang-major-version)" -ge 12; then
 				die "At least clang 12 is required"
 			fi
@@ -196,6 +203,7 @@ pre_build_checks() {
 	# Check build requirements, bug #541816 and bug #471810 .
 	CHECKREQS_MEMORY="4G"
 	CHECKREQS_DISK_BUILD="9G"
+	tc-is-cross-compiler && CHECKREQS_DISK_BUILD="12G"
 	if ( shopt -s extglob; is-flagq '-g?(gdb)?([1-9])' ); then
 		if use custom-cflags || use component-build; then
 			CHECKREQS_DISK_BUILD="25G"
@@ -209,6 +217,13 @@ pre_build_checks() {
 
 pkg_pretend() {
 	pre_build_checks
+
+	if use headless; then
+		local headless_unused_flags=("cups" "kerberos" "pulseaudio" "vaapi" "wayland")
+		for myiuse in ${headless_unused_flags[@]}; do
+			use ${myiuse} && ewarn "Ignoring USE=${myiuse} since USE=headless is set."
+		done
+	fi
 }
 
 pkg_setup() {
@@ -236,6 +251,7 @@ src_prepare() {
 		"${FILESDIR}/chromium-glibc-2.34-r1.patch"
 		"${FILESDIR}/chromium-use-oauth2-client-switches-as-default.patch"
 		"${FILESDIR}/chromium-shim_headers.patch"
+		"${FILESDIR}/chromium-cross-compile.patch"
 	)
 
 	default
@@ -492,6 +508,9 @@ src_prepare() {
 	if ! use system-png; then
 		keeplibs+=( third_party/libpng )
 	fi
+	if use libcxx; then
+		keeplibs+=( third_party/re2 )
+	fi
 	if use system-harfbuzz; then
 		keeplibs+=( third_party/harfbuzz-ng/utils )
 	else
@@ -500,15 +519,6 @@ src_prepare() {
 	if use wayland && ! use headless ; then
 		keeplibs+=( third_party/wayland )
 	fi
-	if [[ ${CHROMIUM_FORCE_LIBCXX} == yes ]]; then
-		keeplibs+=( third_party/libxml )
-		keeplibs+=( third_party/libxslt )
-		keeplibs+=( third_party/openh264 )
-		keeplibs+=( third_party/re2 )
-		if use system-icu; then
-			keeplibs+=( third_party/icu )
-		fi
-	fi
 	if use arm64 || use ppc64 ; then
 		keeplibs+=( third_party/swiftshader/third_party/llvm-10.0 )
 	fi
@@ -542,19 +552,23 @@ src_configure() {
 	# Make sure the build system will use the right tools, bug #340795.
 	tc-export AR CC CXX NM
 
-	if [[ ${CHROMIUM_FORCE_CLANG} == yes ]] && ! tc-is-clang; then
-		# Force clang since gcc is pretty broken at the moment.
-		CC=${CHOST}-clang
-		CXX=${CHOST}-clang++
+	if { [[ ${CHROMIUM_FORCE_CLANG} == yes ]] || use libcxx; } && ! tc-is-clang; then
+		# Force clang since gcc is either broken or build is using libcxx.
+		if tc-is-cross-compiler; then
+			CC="${CBUILD}-clang -target ${CHOST} --sysroot ${ESYSROOT}"
+			CXX="${CBUILD}-clang++ -target ${CHOST} --sysroot ${ESYSROOT}"
+			BUILD_CC=${CBUILD}-clang
+			BUILD_CXX=${CBUILD}-clang++
+		else
+			CC=${CHOST}-clang
+			CXX=${CHOST}-clang++
+		fi
 		strip-unsupported-flags
 	fi
 
-	if tc-is-clang; then
+	if tc-is-clang || use libcxx; then
 		myconf_gn+=" is_clang=true clang_use_chrome_plugins=false"
 	else
-		if [[ ${CHROMIUM_FORCE_LIBCXX} == yes ]]; then
-			die "Compiling with sys-libs/libcxx requires clang."
-		fi
 		myconf_gn+=" is_clang=false"
 	fi
 
@@ -565,6 +579,18 @@ src_configure() {
 		tc-export BUILD_{AR,CC,CXX,NM}
 		myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:host\""
 		myconf_gn+=" v8_snapshot_toolchain=\"//build/toolchain/linux/unbundle:host\""
+		myconf_gn+=" pkg_config=\"$(tc-get_PKG_CONFIG)\""
+		myconf_gn+=" host_pkg_config=\"$(tc-getBUILD_PKG_CONFIG)\""
+
+		# setup cups-config, build system only uses --libs option
+		if use cups; then
+			mkdir "${T}/cups-config" || die
+			cp "${ESYSROOT}/usr/bin/${CHOST}-cups-config" "${T}/cups-config/cups-config" || die
+			export PATH="${PATH}:${T}/cups-config"
+		fi
+
+		# Don't inherit PKG_CONFIG_PATH from environment
+		local -x PKG_CONFIG_PATH=
 	else
 		myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:default\""
 	fi
@@ -600,6 +626,9 @@ src_configure() {
 		libdrm
 		libjpeg
 		libwebp
+		libxml
+		libxslt
+		openh264
 		zlib
 	)
 	if use system-ffmpeg; then
@@ -611,11 +640,8 @@ src_configure() {
 	if use system-png; then
 		gn_system_libraries+=( libpng )
 	fi
-	if [[ ${CHROMIUM_FORCE_LIBCXX} != yes ]]; then
-		# unbundle only without libc++, because libc++ is not fully ABI compatible with libstdc++
-		gn_system_libraries+=( libxml )
-		gn_system_libraries+=( libxslt )
-		gn_system_libraries+=( openh264 )
+	# re2 library interface relies on std::string and std::vector
+	if ! use libcxx; then
 		gn_system_libraries+=( re2 )
 	fi
 	build/linux/unbundle/replace_gn_files.py --system-libraries "${gn_system_libraries[@]}" || die
@@ -630,11 +656,21 @@ src_configure() {
 	myconf_gn+=" enable_js_type_check=$(usex js-type-check true false)"
 	myconf_gn+=" enable_hangout_services_extension=$(usex hangouts true false)"
 	myconf_gn+=" enable_widevine=$(usex widevine true false)"
-	myconf_gn+=" use_cups=$(usex cups true false)"
-	myconf_gn+=" use_kerberos=$(usex kerberos true false)"
-	myconf_gn+=" use_pulseaudio=$(usex pulseaudio true false)"
-	myconf_gn+=" use_vaapi=$(usex vaapi true false)"
-	myconf_gn+=" rtc_use_pipewire=$(usex screencast true false)"
+
+	if use headless; then
+		myconf_gn+=" use_cups=false"
+		myconf_gn+=" use_kerberos=false"
+		myconf_gn+=" use_pulseaudio=false"
+		myconf_gn+=" use_vaapi=false"
+		myconf_gn+=" rtc_use_pipewire=false"
+	else
+		myconf_gn+=" use_cups=$(usex cups true false)"
+		myconf_gn+=" use_kerberos=$(usex kerberos true false)"
+		myconf_gn+=" use_pulseaudio=$(usex pulseaudio true false)"
+		myconf_gn+=" use_vaapi=$(usex vaapi true false)"
+		myconf_gn+=" rtc_use_pipewire=$(usex screencast true false)"
+		myconf_gn+=" gtk_version=$(usex gtk4 4 3)"
+	fi
 
 	# TODO: link_pulseaudio=true for GN.
 
@@ -643,7 +679,8 @@ src_configure() {
 	# Never use bundled gold binary. Disable gold linker flags for now.
 	# Do not use bundled clang.
 	# Trying to use gold results in linker crash.
-	myconf_gn+=" use_gold=false use_sysroot=false use_custom_libcxx=false"
+	myconf_gn+=" use_gold=false use_sysroot=false"
+	myconf_gn+=" use_custom_libcxx=$(usex libcxx true false)"
 
 	# Disable forced lld, bug 641556
 	myconf_gn+=" use_lld=false"
@@ -688,11 +725,6 @@ src_configure() {
 		fi
 	fi
 
-	if [[ ${CHROMIUM_FORCE_LIBCXX} == yes ]]; then
-		append-flags -stdlib=libc++
-		append-ldflags -stdlib=libc++
-	fi
-
 	if [[ $myarch = amd64 ]] ; then
 		myconf_gn+=" target_cpu=\"x64\""
 		ffmpeg_target_arch=x64
@@ -749,10 +781,16 @@ src_configure() {
 	fi
 
 	# Disable unknown warning message from clang.
-	tc-is-clang && append-flags -Wno-unknown-warning-option
+	if tc-is-clang; then
+		append-flags -Wno-unknown-warning-option
+		if tc-is-cross-compiler; then
+			export BUILD_CXXFLAGS+=" -Wno-unknown-warning-option"
+			export BUILD_CFLAGS+=" -Wno-unknown-warning-option"
+		fi
+	fi
 
-	# Explicitly disable ICU data file support for system-icu builds.
-	if use system-icu; then
+	# Explicitly disable ICU data file support for system-icu/headless builds.
+	if use system-icu || use headless; then
 		myconf_gn+=" icu_use_data_file=false"
 	fi
 
@@ -763,7 +801,12 @@ src_configure() {
 	if use wayland || use headless; then
 		if use headless; then
 			myconf_gn+=" ozone_platform=\"headless\""
-			myconf_gn+=" use_x11=false"
+			myconf_gn+=" use_xkbcommon=false use_gtk=false"
+			myconf_gn+=" use_glib=false use_gio=false"
+			myconf_gn+=" use_pangocairo=false use_alsa=false"
+			myconf_gn+=" use_libpci=false use_udev=false"
+			myconf_gn+=" enable_print_preview=false"
+			myconf_gn+=" enable_remoting=false"
 		else
 			myconf_gn+=" ozone_platform_wayland=true"
 			myconf_gn+=" use_system_libdrm=true"
@@ -897,7 +940,7 @@ src_install() {
 		[[ ${#files[@]} -gt 0 ]] && doins "${files[@]}"
 	)
 
-	if ! use system-icu; then
+	if ! use system-icu && ! use headless; then
 		doins out/Release/icudtl.dat
 	fi
 
@@ -947,15 +990,22 @@ pkg_postinst() {
 	xdg_desktop_database_update
 	readme.gentoo_print_elog
 
-	if use vaapi; then
-		elog "VA-API is disabled by default at runtime. You have to enable it"
-		elog "by adding --enable-features=VaapiVideoDecoder to CHROMIUM_FLAGS"
-		elog "in /etc/chromium/default."
-	fi
-	if use screencast; then
-		elog "Screencast is disabled by default at runtime. Either enable it"
-		elog "by navigating to chrome://flags/#enable-webrtc-pipewire-capturer"
-		elog "inside Chromium or add --enable-webrtc-pipewire-capturer"
-		elog "to CHROMIUM_FLAGS in /etc/chromium/default."
+	if ! use headless; then
+		if use vaapi; then
+			elog "VA-API is disabled by default at runtime. You have to enable it"
+			elog "by adding --enable-features=VaapiVideoDecoder to CHROMIUM_FLAGS"
+			elog "in /etc/chromium/default."
+		fi
+		if use screencast; then
+			elog "Screencast is disabled by default at runtime. Either enable it"
+			elog "by navigating to chrome://flags/#enable-webrtc-pipewire-capturer"
+			elog "inside Chromium or add --enable-webrtc-pipewire-capturer"
+			elog "to CHROMIUM_FLAGS in /etc/chromium/default."
+		fi
+		if use gtk4; then
+			elog "Chromium prefers GTK3 over GTK4 at runtime. To override this"
+			elog "behavior you need to pass --gtk-version=4, e.g. by adding it"
+			elog "to CHROMIUM_FLAGS in /etc/chromium/default."
+		fi
 	fi
 }

diff --git a/www-client/chromium/files/chromium-cross-compile.patch b/www-client/chromium/files/chromium-cross-compile.patch
new file mode 100644
index 000000000000..430ceb7a4924
--- /dev/null
+++ b/www-client/chromium/files/chromium-cross-compile.patch
@@ -0,0 +1,12 @@
+--- a/build/toolchain/linux/unbundle/BUILD.gn
++++ b/build/toolchain/linux/unbundle/BUILD.gn
+@@ -35,7 +35,7 @@ gcc_toolchain("host") {
+   extra_ldflags = getenv("BUILD_LDFLAGS")
+ 
+   toolchain_args = {
+-    current_cpu = current_cpu
+-    current_os = current_os
++    current_cpu = host_cpu
++    current_os = host_os
+   }
+ }

diff --git a/www-client/chromium/metadata.xml b/www-client/chromium/metadata.xml
index dcdaa4ce4a04..b97df5c6f029 100644
--- a/www-client/chromium/metadata.xml
+++ b/www-client/chromium/metadata.xml
@@ -9,8 +9,10 @@
 		<flag name="js-type-check">Enable JavaScript type-checking for Chrome's web technology-based UI. Requires Java.</flag>
 		<flag name="component-build">Split build into more shared libraries to speed up linking. Mostly intended for debugging and development, NOT RECOMMENDED for general use.</flag>
 		<flag name="debug">Enable DCHECK feature with severity configurable at runtime. Mostly intended for debugging and development, NOT RECOMMENDED for general use.</flag>
+		<flag name="gtk4">Build with GTK4 headers.</flag>
 		<flag name="headless">Build Ozone only with headless backend, NOT RECOMMENDED for general use.</flag>
 		<flag name="hangouts">Enable support for Google Hangouts features such as screen sharing</flag>
+		<flag name="libcxx">Use bundled libc++ instead of libstdc++ for building.</flag>
 		<flag name="official">Enable Official build instead of Developer build.</flag>
 		<flag name="pic">Disable optimized assembly code that is not PIC friendly</flag>
 		<flag name="proprietary-codecs">Enable codecs for patent-encumbered audio and video formats.</flag>