Closed Bug 1760484 Opened 3 years ago Closed 2 years ago

fix webrtc build on OpenBSD/arm64

Categories

(Core :: WebRTC, defect, P3)

ARM64
Unspecified
defect

Tracking

()

VERIFIED FIXED
103 Branch
Tracking Status
firefox-esr102 --- fixed
firefox103 --- fixed

People

(Reporter: gaston, Assigned: glandium)

References

Details

Attachments

(1 file)

webrtc build was fixed for OpenBSD/amd64 in bug #1747862, but at the time i didnt have access to arm64 (and still dont, and dont plan to have some), but i've been reported that as-is firefox doesnt build on OpenBSD/arm64 in webrtc.

apparently, some x86 targets are also build on arm64, which cant work.

a patch in the generated moz.build file seems to help (only reporting informations..)

Index: third_party/libwebrtc/moz.build
--- third_party/libwebrtc/moz.build.orig
+++ third_party/libwebrtc/moz.build
@@ -401,15 +401,20 @@ if CONFIG["OS_TARGET"] == "OpenBSD":
     DIRS += [
         "/third_party/libwebrtc/api/audio_codecs/isac/audio_decoder_isac_float_gn",
         "/third_party/libwebrtc/api/audio_codecs/isac/audio_encoder_isac_float_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
         "/third_party/libwebrtc/modules/audio_coding/isac_c_gn",
         "/third_party/libwebrtc/modules/audio_coding/isac_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
         "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_generic_gn",
         "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
         "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
+    ]
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+    DIRS += [
+        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
+        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
+        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
+        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
         "/third_party/libwebrtc/modules/video_processing/video_processing_sse2_gn"
     ]
 

ofc, now one would have to figure out what to change where in the BUILD.gn files ..

This is the final set of diffs I needed to build and run firefox on OpenBSD arm64. They are pretty simply just making OpenBSD a normal multi-arch OS.

Index: third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build
--- third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build.orig
+++ third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build
@@ -90,10 +90,6 @@ if CONFIG["OS_TARGET"] == "Linux":
 
 if CONFIG["OS_TARGET"] == "OpenBSD":
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
     DEFINES["USE_GLIB"] = "1"
     DEFINES["WEBRTC_BSD"] = True
     DEFINES["WEBRTC_POSIX"] = True
@@ -102,6 +98,12 @@ if CONFIG["OS_TARGET"] == "OpenBSD":
     DEFINES["_LARGEFILE_SOURCE"] = True
     DEFINES["__STDC_CONSTANT_MACROS"] = True
     DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+    CXXFLAGS += [
+        "-msse2"
+    ]
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc"
Index: third_party/libwebrtc/moz.build
--- third_party/libwebrtc/moz.build.orig
+++ third_party/libwebrtc/moz.build
@@ -401,16 +401,29 @@ if CONFIG["OS_TARGET"] == "OpenBSD":
     DIRS += [
         "/third_party/libwebrtc/api/audio_codecs/isac/audio_decoder_isac_float_gn",
         "/third_party/libwebrtc/api/audio_codecs/isac/audio_encoder_isac_float_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
         "/third_party/libwebrtc/modules/audio_coding/isac_c_gn",
         "/third_party/libwebrtc/modules/audio_coding/isac_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
         "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_generic_gn",
         "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
         "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
+    ]
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+    DIRS += [
+        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
+        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
+        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
+        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
         "/third_party/libwebrtc/modules/video_processing/video_processing_sse2_gn"
+    ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+    DIRS += [
+        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
+        "/third_party/libwebrtc/common_audio/common_audio_neon_gn",
+        "/third_party/libwebrtc/modules/video_processing/video_processing_neon_gn"
     ]
 
 if CONFIG["OS_TARGET"] == "WINNT":

:mjf, is there any chance to land those changes directly in the moz.build files ? from my understanding, otherwise one would have to check/compare the arm64 vs amd64 json files which are generated from the BUILD.gn files to figure out what would need fixes in those files..

Anyway, were the moz.build files regenerated for a fix on another platform, i'm not even sure the generated moz.build files would still work for OpenBSD ?

(honestly, my recollection of the process is: "it was painful and time-consuming")

Flags: needinfo?(mfroman)

Fwiw, where most of the work was done for OpenBSD/amd64 was in bug #1654448 (not much in bug #1747862) if some brave soul plans to do the right thing for OpenBSD/arm64.

my take would be:

  • diff dom/media/webrtc/third_party_build/gn-configs/x64_False_{arm64,x64}_linux.json, checking where sse2/neon appears or not
  • apply manually those modifications to dom/media/webrtc/third_party_build/gn-configs/x64_*arm64_openbsd.json

or read https://searchfox.org/mozilla-central/source/dom/media/webrtc/third_party_build/gn-configs/README-openbsd.md and apply to arm64, thanks :mjf i hadnt seen that you wrote this.

(In reply to Landry Breuil (:gaston) from comment #2)

:mjf, is there any chance to land those changes directly in the moz.build files ? from my understanding, otherwise one would have to check/compare the arm64 vs amd64 json files which are generated from the BUILD.gn files to figure out what would need fixes in those files..

Since the moz.build files are generated (as are the json files), we will not accept manual changes to those files. The BUILD.gn files are the place to make the changes.

Anyway, were the moz.build files regenerated for a fix on another platform, i'm not even sure the generated moz.build files would still work for OpenBSD ?

Correct, if anything else required regenerating files, any manual changes would be lost.

Flags: needinfo?(mfroman)
Severity: -- → S4
Priority: -- → P3
Depends on: 1773223
Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/85f0cccbd2a8 Add webrtc configs for arm64 openbsd. r=mjf
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/20c541be9a37 Add webrtc configs for arm64 openbsd. r=mjf
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/7be63a667b04 Add webrtc configs for arm64 openbsd. r=mjf
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch

Comment on attachment 9281531 [details]
Bug 1760484 - Add webrtc configs for arm64 openbsd.

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Broken builds for tier-3 downstreams.
  • User impact if declined:
  • Fix Landed on Version: 103
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): NPOTB
Attachment #9281531 - Flags: approval-mozilla-esr102?

Comment on attachment 9281531 [details]
Bug 1760484 - Add webrtc configs for arm64 openbsd.

Approved for 102.1esr.

Attachment #9281531 - Flags: approval-mozilla-esr102? → approval-mozilla-esr102+

Fwiw, with glandium's work in this bug and bug #1773223, i've been able to build 103.0b1 (which includes https://hg.mozilla.org/mozilla-central/rev/7be63a667b04) on OpenBSD/arm64 after having dropped/removed all the local patches we had (https://github.com/openbsd/ports/commit/48a1d304638782f82e5a52a674c0ae538849d225). Havent been able to actually test webrtc on arm64 but at least it builds fine unpatched !

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: