Page 1 of 1

Emerging firefox-60.0.1 on arm64 (patches)

Posted: Sun Jun 03, 2018 1:29 pm
by Sakaki
Hello,

to get the current in-tree firefox-60.0.1 to build on arm64, two additional patches are required. These are both afaik accepted upstream at Mozilla, so the next point release should automatically work, but if you want to get something running now, the following may be of interest.

First, there is an issue where www-client/firefox-60.0.1 tries to build various sse2-optimized sources, which obviously fails on arm64. This is [bug=657146]Gentoo bug #657146[/bug], and Mozilla bug #1434589.
The following is the relevant part of the (much larger) patch submitted on the Mozilla bug report thread (the original patch also adds ppc64 support):

Code: Select all

diff -r 2b504eb4567d -r 2a266219f547 media/webrtc/trunk/moz.build
--- a/media/webrtc/trunk/moz.build	Wed May 23 13:03:58 2018 +1200
+++ b/media/webrtc/trunk/moz.build	Sun May 27 22:21:07 2018 -0700
@@ -143,12 +143,8 @@
 if CONFIG["OS_TARGET"] == "Linux":
 
     DIRS += [
-        "/media/webrtc/trunk/webrtc/common_audio/common_audio_sse2_gn",
-        "/media/webrtc/trunk/webrtc/modules/audio_processing/audio_processing_sse2_gn",
-        "/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
         "/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_gn",
         "/media/webrtc/trunk/webrtc/modules/desktop_capture/primitives_gn",
-        "/media/webrtc/trunk/webrtc/modules/video_processing/video_processing_sse2_gn",
         "/media/webrtc/trunk/webrtc/system_wrappers/cpu_features_linux_gn",
         "/media/webrtc/trunk/webrtc/video_engine/video_engine_gn"
     ]
@@ -185,6 +181,24 @@
         "/media/webrtc/trunk/webrtc/modules/video_processing/video_processing_neon_gn"
     ]
 
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+    DIRS += [
+        "/media/webrtc/trunk/webrtc/common_audio/common_audio_sse2_gn",
+        "/media/webrtc/trunk/webrtc/modules/audio_processing/audio_processing_sse2_gn",
+        "/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
+        "/media/webrtc/trunk/webrtc/modules/video_processing/video_processing_sse2_gn"
+    ]
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+    DIRS += [
+        "/media/webrtc/trunk/webrtc/common_audio/common_audio_sse2_gn",
+        "/media/webrtc/trunk/webrtc/modules/audio_processing/audio_processing_sse2_gn",
+        "/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
+        "/media/webrtc/trunk/webrtc/modules/video_processing/video_processing_sse2_gn"
+    ]
+
 if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
 
     DIRS += [
The second issue is that some skia code fails to build under gcc (6.4.0, at any rate), producing "error: ‘vcvt_f16_f32’ was not declared in this scope". This is Mozilla bug # 1453892, for which the patch is:

Code: Select all

From: Mike Hommey <mh+mozilla@glandium.org>
Date: Sat, 19 May 2018 12:03:56 +0900
Subject: Bug 1462868 - Fix Skia build on arm64 linux with GCC. r?lsalzman

---
 gfx/skia/skia/src/jumper/SkJumper_stages.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gfx/skia/skia/src/jumper/SkJumper_stages.cpp b/gfx/skia/skia/src/jumper/SkJumper_stages.cpp
index 19b6cd694aa6..36792390dece 100644
--- a/gfx/skia/skia/src/jumper/SkJumper_stages.cpp
+++ b/gfx/skia/skia/src/jumper/SkJumper_stages.cpp
@@ -666,7 +666,7 @@ SI F approx_powf(F x, F y) {
 }
 
 SI F from_half(U16 h) {
-#if defined(__aarch64__) && !defined(SK_BUILD_FOR_GOOGLE3)  // Temporary workaround for some Google3 builds.
+#if defined(JUMPER_IS_NEON) && !defined(SK_BUILD_FOR_GOOGLE3)  // Temporary workaround for some Google3 builds.
     return vcvt_f32_f16(h);
 
 #elif defined(JUMPER_IS_HSW) || defined(JUMPER_IS_AVX512)
@@ -686,7 +686,7 @@ SI F from_half(U16 h) {
 }
 
 SI U16 to_half(F f) {
-#if defined(__aarch64__) && !defined(SK_BUILD_FOR_GOOGLE3)  // Temporary workaround for some Google3 builds.
+#if defined(JUMPER_IS_NEON) && !defined(SK_BUILD_FOR_GOOGLE3)  // Temporary workaround for some Google3 builds.
     return vcvt_f16_f32(f);
 
 #elif defined(JUMPER_IS_HSW) || defined(JUMPER_IS_AVX512)
To apply these, create the directory /etc/portage/patches/www-client/firefox-60.0.1, and then save the first patch above as (e.g.) Bug-1434589-Fix-sse2-dependency-for-linux.patch and the second patch above as (e.g.) Bug-1453892-Fix-Skia-build-on-arm64-linux-with-GCC.patch within that directory (for more details on using /etc/portage/patches, please see these notes).

Then emerge firefox-60.0.1 again, it should build cleanly this time.

If you'd prefer to use a binary package, I have one available for firefox-60.0.1 on arm64 here. I have also pushed a patched www-client/firefox-60.0.1 ebuild to the rpi3-overlay used by the gentoo-on-rpi3-64bit image, so if you are using this image, on your next weekly genup run firefox should upgrade automatically to 60.0.1 (using the binhost binary package).

firefox-bin

Posted: Mon Jun 04, 2018 12:58 am
by Maleita
install firefox-bin

Re: firefox-bin

Posted: Mon Jun 04, 2018 2:41 am
by bobbymcgee
Maleita wrote:install firefox-bin
is that thank you in Portuguese?

Seriously though, thanks for your work Sakaki.

Re: firefox-bin

Posted: Mon Jun 04, 2018 3:34 am
by Hu
Maleita wrote:install firefox-bin
Could you explain why you think that is good advice here? This is a thread about ARM, a CPU family that cannot run x86/amd64 code. www-client/firefox-bin is keyworded -* ~amd64 ~x86, because no Gentoo maintainer has provided a prebuilt ARM Firefox. Thus, install firefox-bin is impossible for ARM users.

Posted: Mon Jun 04, 2018 3:01 pm
by NeddySeagoon
Hu,

firefox-bin pulls the upstream binary build. If it didn't, we could not call it firefox, nor use the firefox logo.
If there is an upstream -bin for arm64, then the firefox-bin ebuild could be expanded to arm64.

Posted: Mon Jun 04, 2018 4:34 pm
by NeddySeagoon
Sakaki,

Thank you.

I can confirm that both patches are required with gcc-7.3 too.