Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] chromium: aarch64 cross build support
@ 2021-10-01 14:31 Duncaen
  2021-10-01 18:25 ` [PR REVIEW] " ericonr
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Duncaen @ 2021-10-01 14:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

There is a new pull request by Duncaen against master on the void-packages repository

https://github.com/Duncaen/void-packages chromium-94
https://github.com/void-linux/void-packages/pull/33208

chromium: aarch64 cross build support
None

A patch file from https://github.com/void-linux/void-packages/pull/33208.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-chromium-94-33208.patch --]
[-- Type: text/x-diff, Size: 11226 bytes --]

From f84cb76feb3fd33af6c1de40ecc8535e022f4ee5 Mon Sep 17 00:00:00 2001
From: Duncaen <duncaen@voidlinux.org>
Date: Sun, 26 Sep 2021 15:47:29 +0200
Subject: [PATCH] chromium: aarch64 cross build support

---
 srcpkgs/chromium/patches/cross-build.patch    | 65 +++++++++++++
 .../patches/unbundled-cross-toolchain.patch   | 12 +++
 srcpkgs/chromium/template                     | 91 +++++++++++++++++--
 3 files changed, 160 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/chromium/patches/cross-build.patch
 create mode 100644 srcpkgs/chromium/patches/unbundled-cross-toolchain.patch

diff --git a/srcpkgs/chromium/patches/cross-build.patch b/srcpkgs/chromium/patches/cross-build.patch
new file mode 100644
index 000000000000..63b89395cb80
--- /dev/null
+++ b/srcpkgs/chromium/patches/cross-build.patch
@@ -0,0 +1,65 @@
+--- a/build/config/compiler/BUILD.gn.orig
++++ b/build/config/compiler/BUILD.gn
+@@ -58,6 +58,10 @@
+ }
+ 
+ declare_args() {
++  is_musl = false
++}
++
++declare_args() {
+   # Normally, Android builds are lightly optimized, even for debug builds, to
+   # keep binary size down. Setting this flag to true disables such optimization
+   android_full_debug = false
+@@ -880,8 +884,13 @@
+       }
+     } else if (current_cpu == "arm64") {
+       if (is_clang && !is_android && !is_nacl && !is_fuchsia) {
+-        cflags += [ "--target=aarch64-linux-gnu" ]
+-        ldflags += [ "--target=aarch64-linux-gnu" ]
++        if (is_musl) {
++          cflags += [ "--target=aarch64-linux-musl" ]
++          ldflags += [ "--target=aarch64-linux-musl" ]
++        } else {
++          cflags += [ "--target=aarch64-linux-gnu" ]
++          ldflags += [ "--target=aarch64-linux-gnu" ]
++        }
+       }
+     } else if (current_cpu == "mipsel" && !is_nacl) {
+       ldflags += [ "-Wl,--hash-style=sysv" ]
+--- a/build/toolchain/linux/unbundle/BUILD.gn.orig
++++ b/build/toolchain/linux/unbundle/BUILD.gn
+@@ -39,3 +39,22 @@
+     current_os = host_os
+   }
+ }
++
++gcc_toolchain("v8_snapshot_cross") {
++  cc = getenv("BUILD_CC")
++  cxx = getenv("BUILD_CXX")
++  ar = getenv("BUILD_AR")
++  nm = getenv("BUILD_NM")
++  ld = cxx
++
++  extra_cflags = getenv("BUILD_CFLAGS")
++  extra_cppflags = getenv("BUILD_CPPFLAGS")
++  extra_cxxflags = getenv("BUILD_CXXFLAGS")
++  extra_ldflags = getenv("BUILD_LDFLAGS")
++
++  toolchain_args = {
++    current_cpu = host_cpu
++    current_os = host_os
++    v8_current_cpu = target_cpu
++  }
++}
+--- a/build/config/linux/pkg_config.gni.orig
++++ b/build/config/linux/pkg_config.gni
+@@ -91,7 +91,7 @@
+   assert(defined(invoker.packages),
+          "Variable |packages| must be defined to be a list in pkg_config.")
+   config(target_name) {
+-    if (host_toolchain == current_toolchain) {
++    if (current_cpu != target_cpu) {
+       args = host_pkg_config_args + invoker.packages
+     } else {
+       args = pkg_config_args + invoker.packages
diff --git a/srcpkgs/chromium/patches/unbundled-cross-toolchain.patch b/srcpkgs/chromium/patches/unbundled-cross-toolchain.patch
new file mode 100644
index 000000000000..c3f2294ac4b2
--- /dev/null
+++ b/srcpkgs/chromium/patches/unbundled-cross-toolchain.patch
@@ -0,0 +1,12 @@
+--- a/build/toolchain/linux/unbundle/BUILD.gn.orig
++++ b/build/toolchain/linux/unbundle/BUILD.gn
+@@ -35,7 +35,7 @@
+   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/srcpkgs/chromium/template b/srcpkgs/chromium/template
index a26d99aa08a9..2e2ae4399185 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -10,7 +10,6 @@ license="BSD-3-Clause"
 homepage="https://www.chromium.org/"
 distfiles="https://commondatastorage.googleapis.com/chromium-browser-official/${pkgname}-${version}.tar.xz"
 checksum=6446db535c02c461c7e5c8d294a0300db03abba791f97f0c70bc52255aedb9bf
-nocross=yes
 
 lib32disabled=yes
 
@@ -24,8 +23,8 @@ desc_option_pulseaudio="Enable support for PulseAudio"
 desc_option_sndio="Enable support for sndio"
 desc_option_pipewire="Enable support for screen sharing for WebRTC via PipeWire"
 
-hostmakedepends="$(vopt_if clang "clang lld llvm12") python pkgconf perl gperf bison ninja nodejs hwids
- libatomic-devel libevent-devel libglib-devel $(vopt_if js_optimize openjdk)"
+hostmakedepends="$(vopt_if clang "clang lld llvm12") python python3 pkgconf perl gperf bison ninja nodejs hwids
+ libatomic-devel libevent-devel libglib-devel $(vopt_if js_optimize openjdk) wayland-devel"
 makedepends="libpng-devel gtk+-devel gtk+3-devel nss-devel pciutils-devel
  libXi-devel libgcrypt-devel libgnome-keyring-devel cups-devel elfutils-devel
  libXcomposite-devel speech-dispatcher-devel libXrandr-devel mit-krb5-devel
@@ -34,7 +33,7 @@ makedepends="libpng-devel gtk+-devel gtk+3-devel nss-devel pciutils-devel
  libXcursor-devel libflac-devel speex-devel libmtp-devel libwebp-devel
  libjpeg-turbo-devel libevent-devel json-c-devel harfbuzz-devel
  minizip-devel jsoncpp-devel zlib-devel libcap-devel libXdamage-devel
- re2-devel fontconfig-devel freetype-devel opus-devel
+ re2-devel fontconfig-devel freetype-devel opus-devel libatomic-devel
  ffmpeg-devel libva-devel python-setuptools xcb-proto libcurl-devel
  $(vopt_if pipewire pipewire-devel) $(vopt_if sndio sndio-devel)"
 depends="libexif hwids desktop-file-utils hicolor-icon-theme xdg-utils"
@@ -43,6 +42,26 @@ case "$XBPS_TARGET_MACHINE" in
 	ppc64*-musl) makedepends+=" libucontext-devel" ;;
 esac
 
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" libX11-devel libxcb-devel pciutils-devel libXext-devel libglvnd-devel
+	 libjpeg-turbo-devel libXi-devel nss-devel libpng-devel libwebp-devel harfbuzz-devel
+	 libxml2-devel $(vopt_if pulseaudio pulseaudio-devel) libxslt-devel libxkbcommon-devel
+	 $(vopt_if pipewire pipewire-devel) ffmpeg-devel opus-devel pango-devel libva-devel
+	 libcurl-devel snappy-devel re2-devel libXrandr-devel libXcomposite-devel cups-devel
+	 mit-krb5-devel alsa-lib-devel"
+fi
+
+if [ ! "$XBPS_WORDSIZE" = "$XBPS_TARGET_WORDSIZE" ]; then
+	broken="chromium (v8) can only be cross compiled if word size matches"
+fi
+
+if [ "$CROSS_BUILD" ]; then
+	case "${XBPS_TARGET_MACHINE}" in
+		aarch64*) ;;
+		*) nocross="chromium can not be cross compiled for this architecture" ;;
+	esac
+fi
+
 post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl-patches/*.patch; do
@@ -80,6 +99,7 @@ post_patch() {
 	vsed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
 		tools/generate_shim_headers/generate_shim_headers.py
 }
+
 do_configure() {
 	local system="" conf=()
 	export -n CFLAGS CXXFLAGS LDFLAGS
@@ -163,8 +183,8 @@ do_configure() {
 		'enable_nacl_nonsfi=false'
 
 		'use_sysroot=false'
-		'custom_toolchain="//build/toolchain/linux/unbundle:default"'
-		'host_toolchain="//build/toolchain/linux/unbundle:default"'
+
+		'host_pkg_config="/usr/bin/pkg-config"'
 
 		"is_clang=$(vopt_if clang true false)"
 		"use_lld=$(vopt_if clang true false)"
@@ -190,6 +210,7 @@ do_configure() {
 		'enable_hangout_services_extension=true'
 
 		'use_system_harfbuzz=true'
+		'use_system_wayland_scanner=true'
 
 		'use_cups=true'
 
@@ -229,11 +250,28 @@ do_configure() {
 		'chrome_pgo_phase=0'
 	)
 
+	if [ "$CROSS_BUILD" ]; then
+		conf+=(
+			'custom_toolchain="//build/toolchain/linux/unbundle:default"'
+			'host_toolchain="//build/toolchain/linux/unbundle:host"'
+			'v8_snapshot_toolchain="//build/toolchain/linux/unbundle:v8_snapshot_cross"'
+		)
+	else
+		conf+=(
+			'custom_toolchain="//build/toolchain/linux/unbundle:default"'
+			'host_toolchain="//build/toolchain/linux/unbundle:default"'
+		)
+	fi
+
 	# this does not work on ppc64 yet
 	case "$XBPS_TARGET_MACHINE" in
 		ppc64*) conf+=( "enable_jxl_decoder=false" );;
 	esac
 
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		conf+=( 'is_musl=true' )
+	fi
+
 	case "${XBPS_TARGET_MACHINE}" in
 		x86_64*) conf+=( 'target_cpu="x64"' ) ;;
 		i686*) conf+=( 'target_cpu="x86"' ) ;;
@@ -242,29 +280,66 @@ do_configure() {
 		ppc64*) conf+=( 'target_cpu="ppc64"' ) ;;
 	esac
 
+	if [ "$CROSS_BUILD" ]; then
+		case "${XBPS_MACHINE}" in
+			x86_64*) conf+=( 'host_cpu="x64"' ) ;;
+			i686*) conf+=( 'host_cpu="x86"' ) ;;
+			arm*) conf+=( 'host_cpu="arm"' ) ;;
+			aarch64*) conf+=( 'host_cpu="arm64"' ) ;;
+			ppc64*) conf+=( 'host_cpu="ppc64"' ) ;;
+		esac
+	fi
+
 	if [ "$build_option_clang" ]; then
+		local gcc_version=$(gcc -dumpversion)
+		local clang_version=$(clang -dumpversion)
 		export CC=clang
 		export CXX=clang++
 		export AR=llvm-ar
 		export NM=llvm-nm
 		export CFLAGS="-Wno-unknown-warning-option"
 		export CXXFLAGS="-Wno-unknown-warning-option"
+		export BUILD_CC=clang
+		export BUILD_CXX=clang++
+		export BUILD_AR=llvm-ar
+		export BUILD_NM=llvm-nm
+		export BUILD_CFLAGS="-Wno-unknown-warning-option"
+		export BUILD_CXXFLAGS="-Wno-unknown-warning-option"
+		if [ "$CROSS_BUILD" ]; then
+			CFLAGS+=" --gcc-toolchain=/usr --sysroot=${XBPS_CROSS_BASE} -nostdinc -isystem ${XBPS_CROSS_BASE}/usr/include -isystem /usr/lib/clang/${clang_version}/include"
+			CXXFLAGS+=" --gcc-toolchain=/usr --sysroot=${XBPS_CROSS_BASE} -nostdinc++ -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*} -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/${XBPS_CROSS_TRIPLET} -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward -nostdinc -isystem ${XBPS_CROSS_BASE}/usr/include -isystem /usr/lib/clang/${clang_version}/include"
+			export LDFLAGS="--gcc-toolchain=/usr --sysroot=${XBPS_CROSS_BASE}"
+		fi
 	fi
 
 	out/Release/gn gen out/Release --args="${conf[*]}"
 }
+
 do_build() {
 	if [ "$build_option_clang" ]; then
+		local gcc_version=$(gcc -dumpversion)
+		local clang_version=$(clang -dumpversion)
 		export CC=clang
 		export CXX=clang++
 		export AR=llvm-ar
 		export NM=llvm-nm
 		export CFLAGS="-Wno-unknown-warning-option"
 		export CXXFLAGS="-Wno-unknown-warning-option"
+		export BUILD_CC=clang
+		export BUILD_CXX=clang++
+		export BUILD_AR=llvm-ar
+		export BUILD_NM=llvm-nm
+		export BUILD_CFLAGS="-Wno-unknown-warning-option"
+		export BUILD_CXXFLAGS="-Wno-unknown-warning-option"
+		if [ "$CROSS_BUILD" ]; then
+			CFLAGS+=" --gcc-toolchain=/usr --sysroot=${XBPS_CROSS_BASE} -nostdinc -isystem ${XBPS_CROSS_BASE}/usr/include -isystem /usr/lib/clang/${clang_version}/include"
+			CXXFLAGS+=" --gcc-toolchain=/usr --sysroot=${XBPS_CROSS_BASE} -nostdinc++ -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*} -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/${XBPS_CROSS_TRIPLET} -isystem ${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward -nostdinc -isystem ${XBPS_CROSS_BASE}/usr/include -isystem /usr/lib/clang/${clang_version}/include"
+			export LDFLAGS="--gcc-toolchain=/usr --sysroot=${XBPS_CROSS_BASE}"
+		fi
 	fi
-
-	ninja -C out/Release ${makejobs} chrome chromedriver mksnapshot chrome_crashpad_handler
+	ninja -C out/Release ${makejobs} chrome chromedriver chrome_crashpad_handler
 }
+
 do_install() {
 	vinstall out/Release/chrome 755 usr/lib/${pkgname} ${pkgname}
 	vinstall out/Release/chrome_crashpad_handler 755 usr/lib/${pkgname} chrome_crashpad_handler

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-17  1:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 14:31 [PR PATCH] chromium: aarch64 cross build support Duncaen
2021-10-01 18:25 ` [PR REVIEW] " ericonr
2021-10-01 18:32 ` Duncaen
2021-10-01 18:36 ` Duncaen
2021-10-01 18:38 ` Duncaen
2021-10-01 18:38 ` Duncaen
2021-10-01 18:38 ` Duncaen
2021-10-01 18:44 ` [PR REVIEW] " ericonr
2021-10-01 18:46 ` ericonr
2021-10-14 18:50 ` [PR PATCH] [Updated] " Duncaen
2021-10-14 18:54 ` Duncaen
2021-11-17  1:14 ` ericonr
2021-11-17  1:14 ` [PR PATCH] [Closed]: " ericonr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).