Closed Bug 1876554 Opened 1 year ago Closed 1 year ago

duplicate entries in moz.build files break the build on OpenBSD/riscv64

Categories

(Core :: WebRTC, defect)

RISCV64
OpenBSD
defect

Tracking

()

RESOLVED FIXED
124 Branch
Tracking Status
firefox124 --- fixed

People

(Reporter: gaston, Assigned: mjf)

References

Details

Attachments

(5 files)

an OpenBSD developer is working on enabling the build of firefox on riscv64, but so far the build fails because of duplicate sections in some webrtc moz.build generated files:

mozbuild.frontend.reader.SandboxValidationError:
==============================
FATAL ERROR PROCESSING MOZBUILD FILE
==============================
The error occurred while processing the following file or one of the files it includes:
/local/pobj/firefox-121.0.1/firefox-121.0.1/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build
The error occurred when validating the result of the execution. The reported error is:
/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c from UNIFIED_SOURCES would have the same object name as 
/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c from UNIFIED_SOURCES in non-unified builds.

there are apparently multiple sections like this, i'm attaching a patch against 122.0 to list them, but since iirc those files are autogenerate from some contraption, i suppose the proper fix is ... 'somewhere else'. and since libwebrtc might have been upgraded in the meantime...

Michael, you may be interested in this.

Flags: needinfo?(mfroman)

Generating the moz.build files under libwebrtc is done by running:

./mach python python/mozbuild/mozbuild/gn_processor.py dom/media/webrtc/third_party_build/gn-configs/webrtc.json

The fix is probably some combination of modifying either python/mozbuild/mozbuild/gn_processor.py and/or third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/BUILD.gn to write a different moz.build file. :glandium may have further info to add.

Flags: needinfo?(mfroman) → needinfo?(mh+mozilla)

This is essentially another instance of bug 1775202. The script is dumb-ish, and that shows. spl_sqrt_floor.c is behind the following conditions:

if CONFIG["OS_TARGET"] == "Darwin":
if CONFIG["OS_TARGET"] == "OpenBSD":
if CONFIG["OS_TARGET"] == "WINNT":
if CONFIG["TARGET_CPU"] == "arm":
if CONFIG["TARGET_CPU"] == "mips32":
if CONFIG["TARGET_CPU"] == "mips64":
if CONFIG["TARGET_CPU"] == "ppc64":
if CONFIG["TARGET_CPU"] == "riscv64":
if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64":
if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64":
if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":

Of course, since they aren't all mutually exclusive, that doesn't work...

Flags: needinfo?(mh+mozilla)

In ways, it's similar to bug 1760484.

But of course, gn doesn't work with the combination openbsd+riscv64, barfing:

ERROR Unresolved dependencies.
//:dcsctp(//build/toolchain/linux:clang_riscv64)
  needs //build/toolchain/linux:clang_riscv64()
//:poison_audio_codecs(//build/toolchain/linux:clang_riscv64)
  needs //build/toolchain/linux:clang_riscv64()

etc.

jca@openbsd has access to riscv64 and is working on a proper fix in gn_processor.py. It also needs some work in xpcom but that's unrelated to libwebrtc.

my understanding is that:

  • gn_processor needs the correct arch list (first patch)
  • and with that, one needs to run it (on linux ? on OpenBSD ?) to generate the moz.build changes (second patch)
  • and one needs to test the resulting moz.build on OpenBSD/riscv64 to confirm it builds
    right ?

(In reply to Mike Hommey [:glandium] from comment #6)

But of course, gn doesn't work with the combination openbsd+riscv64, barfing:

ERROR Unresolved dependencies.
//:dcsctp(//build/toolchain/linux:clang_riscv64)
  needs //build/toolchain/linux:clang_riscv64()
//:poison_audio_codecs(//build/toolchain/linux:clang_riscv64)
  needs //build/toolchain/linux:clang_riscv64()

etc.

jca@openbsd here. I'm stuck on the same issue, trying to regen the moz.build files after patching gn_processor.py. Are you attempting this from an OpenBSD machine?

(To get to that error on an OpenBSD machine, I had to drop "android" from target_os, because of the assert at third_party/libwebrtc/build/config/BUILDCONFIG.gn:222).

OK so I managed to regen the libwebrtc moz.build files using some hacks.

  1. The third_party/libwebrtc/build/toolchain/linux/BUILD.gn diff adds support for native (not cross-compile) clang_riscv64 on Linux. The change was copied from the other clang_$arch blocks in the same file.

  2. The python/mozbuild/mozbuild/gn_processor.py diff adds support for OpenBSD/riscv64.

  3. The third_party/libwebrtc/build/config/BUILDCONFIG.gn and third_party/libwebrtc/build/config/android/config.gni diffs are only here to let me run gn for the Android target from OpenBSD. Else the resulting diff for the moz.build files is larger and less clear.

  4. The diff for the various moz.build files shows that the riscv64-specific lines that resulted in duplicated additions to UNIFIED_SOURCES are now guarded with:

-if CONFIG["TARGET_CPU"] == "riscv64":
+if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":

... which appears to be the desired outcome, and would avoid the need for libwebrtc/*/moz.build patches in the OpenBSD port. IIUC we'd need to properly submit 1. and 2.

Disclaimer: I'm not sure why Linux appears to be handled differently from the other platforms here.

To ensure that this works smoothly with the libwebrtc update process. I think we need to turn this into 3 patches before we land it. The first with the gn_processor.py changes, the second will have the changes to the GN files under third_party/libwebrtc, and the third will have only the generated moz.build files. Either :mjf or I can handle that after review.

:glandium, will this require uplift?

Flags: needinfo?(mh+mozilla)

That would be a question for the openbsd people.

Flags: needinfo?(mh+mozilla)

(In reply to Mike Hommey [:glandium] from comment #11)

That would be a question for the openbsd people.

IIUC an uplift is a request for changes to be integrated in the next firefox releases. If so, yes I would appreciate that, as I'd like to save :gaston some trouble with conflicting patches at update time (for example the update from 121 to 122 lead to conflicts in the patched moz.build files).

(In reply to Nico Grunbaum [:ng, @chew:mozilla.org] from comment #10)

To ensure that this works smoothly with the libwebrtc update process. I think we need to turn this into 3 patches before we land it. The first with the gn_processor.py changes, the second will have the changes to the GN files under third_party/libwebrtc, and the third will have only the generated moz.build files.

I have two questions:

  • should the third_party/libwebrtc/build/toolchain/linux/BUILD.gn patch happen first, before the patch for gn_processor.py? Without the former, Mike and I get an error when regenerating the moz.build files.
  • regarding "the changes to the GN files under third_party/libwebrtc", I think only the patch for third_party/libwebrtc/build/toolchain/linux/BUILD.gn is valid to commit. The others are hacks to let me run gn and regen the moz.build files on OpenBSD but I have no idea if they are correct or meaningful.

Either :mjf or I can handle that after review.
For a review to happen, is the diff I posted earlier good enough? Or shall I clean up it up and split it into three commits?
Is this bug report enough for the review, or should I learn to use Phabricator...?

Sorry for the rookie questions.

Assignee: nobody → mfroman
Status: NEW → ASSIGNED
Comment on attachment 9378510 [details] [diff] [review] libwebrtc-openbsd-riscv64.diff Review of attachment 9378510 [details] [diff] [review]: ----------------------------------------------------------------- These changes were good, but all in a combined patch. I've submitted a broken up patch set and a try run.
Attachment #9378510 - Flags: review?(mfroman)

Sorry for the rookie questions.

No worries at all. Thanks for submitting the patches. As for Phabricator, it would speed things up for us if future patches were submitted that way, and it would be appreciated, but do not let that become an impediment.

Try builds look good with the exception of 'build-linux64-plain-clang-trunk/opt', but it fails with out our changes (see here).

i haven't followed closely, but the phabricator reviews match what :jca sent me that produced a working binary on OpenBSD/riscv64 for him, so i'm all for it :)

as for the uplifting, if webrtc hasnt been updated in the 123/124 timeframe and its not a hassle, i'll welcome an uplift to beta (while it might be late for 123 ?) otherwise the commits will probably be shipped as local patches until 124 is released.

This needs a rebase for a conflict with the CLOBBER file.

Flags: needinfo?(mfroman)

Yes, agreed - I'm waiting on another patch to land before I can rebase. Thank you for the heads up.

Depends on: 1879898
Flags: needinfo?(mfroman)

This doesn't need to touch CLOBBER at all, though.

(In reply to Mike Hommey [:glandium] from comment #24)

This doesn't need to touch CLOBBER at all, though.

The libwebrtc update scripts touch the CLOBBER file anytime we generate moz.build files and commit the changes. In the past, we've not been able to programmatically determine when this is needed and when it is not. If you can describe an algorithm that allows us to make that determination and that does not hide build failures do to stale object files left over from previous builds, I'd definitely like to add that functionality to our scripts.

I'm also waiting for a change from 1879898 because we're missing a build file change that was missed.

Generally speaking, there shouldn't be a need to CLOBBER unless a source file is renamed from e.g. .c to .cpp with the same base name. There might be other corner cases, but that's the main one.

We've run into the issue enough on libwebrtc updates that I'm concerned we exercise too many of those corner cases during libwebrtc updates to safely ignore them.

Well, in this specific case, there's no concern.

Pushed by mfroman@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9170e1167dfe libwebrtc change to support openbsd riscv64 toolchain. r=ng,webrtc-reviewers https://hg.mozilla.org/integration/autoland/rev/d67778b576e8 update gn_processor.py to support openbsd on riscv64. r=ng https://hg.mozilla.org/integration/autoland/rev/3b6d2e1cea3c libwebrtc changes to support openbsd on riscv64 - moz.build file updates. r=ng,webrtc-reviewers
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: