Page MenuHomeFreeBSD

www/firefox: port to powerpc64
ClosedPublic

Authored by mikael on Sep 23 2019, 1:17 PM.

Details

Summary

Colors are still a bit funky, tabs tend to crash every now and then.

Test Plan

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

bdragon added a subscriber: bdragon.
bdragon added inline comments.
www/firefox/files/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__ppc64__linux.S
36 ↗(On Diff #62463)

%r12

re: the build.rs patch, perhaps use EXTRA_PATCHES inside a conditional in the Makefile?

mikael edited the summary of this revision. (Show Details)

Address comments.

www/firefox/files/extra-patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #62787)

note to myself, use OSREL?

mikael retitled this revision from www/firefox: WIP port to powerpc64 to www/firefox: port to powerpc64.
mikael added a reviewer: gecko.

Only the changes picked from upstream bugtracker (i.e. files/patch-bug*) have a rationale. I can't maintain patches without one for each change. Firefox has a lot of code churn each update, so being able to easily rebase patches or prune upstreamed is crucial.

www/firefox/Makefile
45 ↗(On Diff #65159)

${ARCH} and ${PPC_ABI} are actually defined in bsd.port.options.mk.

51 ↗(On Diff #65159)

Using = rather than += in conditionals may override previous definition.

60 ↗(On Diff #65159)

Submit upstream, documenting the error.

79 ↗(On Diff #65159)

If you switch to bsd.port.options.mk then this change can be dropped.

www/firefox/files/extra-patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #65159)

Simply hardcode 13.0 if ELFv1 is not supported. Alternatively, patch bundled LLVM in lang/rust to assume ELFv2 if built on ELFv2 by checking FreeBSD version at compile time (not run time).

A number of USES=cargo ports depend on libloading, some of which maybe affected as well.

  • audio/ncspot
  • audio/spotifyd
  • devel/pijul
  • devel/rust-bindgen
  • editors/parinfer-rust
  • games/genact
  • games/veloren
  • multimedia/rav1e
  • net-p2p/parity-ethereum
  • shells/ion
  • textproc/bat
  • textproc/sonic
  • www/geckodriver
  • x11/alacritty
www/firefox/files/patch-media_webrtc_trunk_webrtc_moz.build
11 ↗(On Diff #65159)

This file is auto-generated and may significantly change on update. Better submit upstream. GN->mozbuild converter would likely drop OS-specific conditions if the same directories appear on more than one platform.

# GN from Chromium 75 should work, later version may not yet
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238639
$ cd /usr/ports
$ svn up  -r508721 devel/chromium-gn www/chromium
$ make all deinstall install clean -C devel/chromium-gn

# Get Firefox source and install default dependencies
$ pkg install mercurial py27-sqlite3
$ hg clone https://hg.mozilla.org/mozilla-unified firefox
$ cd firefox
$ hg update central # integration branch from which Nightly is built
$ ./mach bootstrap # select Firefox for Desktop
$ echo 'ac_add_options --with-libclang-path=/usr/local/llvm80/lib # or llvm90' >>.mozconfig

# Some GN files rely on "python" binary but don't support py3 yet
$ mkdir ~/bin # assumig ~/bin is in PATH
$ ln -s $(which python2.7) ~/bin/python

# Save JSON output from GN for optimized build
$ ./mach configure
$ ./mach build-backend -b GnConfigGen
$ cp obj*/media/webrtc/trunk/webrtc/gn-output/ppc64_False_ppc64_freebsd.json media/webrtc/gn-configs

# Save JSON output from GN for debug build
$ echo 'ac_add_options --enable-debug' >>.mozconfig
$ ./mach configure
$ ./mach build-backend -b GnConfigGen
$ cp obj*/media/webrtc/trunk/webrtc/gn-output/ppc64_True_ppc64_freebsd.json media/webrtc/gn-configs

# Convert JSON to moz.build
$ ./mach build-backend -b GnMozbuildWriter

# Prepare patch for submission
$ hg add media/webrtc/gn-configs/*
$ hg ci -m "Bug ? - Add WebRTC 64 gn-configs for FreeBSD powerpc64 (ELFv2)."

See also https://firefox-source-docs.mozilla.org/build/buildsystem/gn.html
Note: if you like Git more than Mercurial then upstream supports contributing via git-cinnabar

www/firefox/files/patch-xpcom_reflect_xptcall_md_unix_moz.build
8 ↗(On Diff #65159)

Submit upstream, documenting the error.

mikael retitled this revision from www/firefox: port to powerpc64 to www/firefox-ppc64: firefox for powerpc64.
mikael removed reviewers: gecko, jbeich.

@jbeich
Is there any problem with this review?

EXTRA_PATCHES= ${.CURDIR}/files is missing in the Makefile

I've opened this pr:
https://bugzilla.mozilla.org/show_bug.cgi?id=1612181
https://bugzilla.mozilla.org/show_bug.cgi?id=1612184

I can't use :

 ./mach build-backend -b GnConfigGen
Reticulating splines...
Running "/usr/local/bin/gn gen /root/firefox_upstream/firefox/obj-powerpc64-unknown-freebsd13.0/media/webrtc/trunk/webrtc/gn-output --args=is_debug=false host_cpu="ppc64" target_os="freebsd" target_cpu="ppc64" --ide=json"
[0x810226800:0129/194321.890724:FATAL:args.cc(341)] Check failed: false. OS architecture not handled. (powerpc)
www/firefox/files/extra-patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #65159)

Someone is running Firefox on elfv1.
I don't understand what you mean with llvm.
Only firefox crates are affected by this issue, the build passes the wrong target triple (powerpc64-unknown-freebsd) because rust has no notions of ABI. Obviously I already checked the bundled crates, only this one is affected.

@jbeich
Is there any problem with this review?

For a slave port review from the maintainer of a master port is not required. Keeping existing MAINTAINER should be fine as pkg-fallout@ doesn't spam the list on Tier2 bustage (although, in aarch64 case I wish it would ;)

If you want the changes in www/firefox rather than www/firefox-ppc64 then I've already pointed out problematic parts.

Thanks.

I can't use :

 ./mach build-backend -b GnConfigGen
Reticulating splines...
Running "/usr/local/bin/gn gen /root/firefox_upstream/firefox/obj-powerpc64-unknown-freebsd13.0/media/webrtc/trunk/webrtc/gn-output --args=is_debug=false host_cpu="ppc64" target_os="freebsd" target_cpu="ppc64" --ide=json"
[0x810226800:0129/194321.890724:FATAL:args.cc(341)] Check failed: false. OS architecture not handled. (powerpc)

GN already has some support for ppc64 (and ppc64le) but not ppc. Try adding conditionals to treat powerpc64 as ppc64.

www/firefox-ppc64/Makefile
14 ↗(On Diff #65431)

Creating a target and making post-patch depend on it maybe more reliable than expecting post-extract to not be defined by master port. See graphics/glew-wayland for an example.

www/firefox/files/extra-patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #65159)

Someone is running Firefox on elfv1.

Why use ELFv1 on FreeBSD 13.0 powerpc64 when binary packages are built for ELFv2?

I don't understand what you mean with llvm.

Example:

--- lang/rust/files/powerpc64-elfv2/patch-src_llvm-project_clang_lib_Basic_Targets_PPC.h
+++ lang/rust/files/powerpc64-elfv2/patch-src_llvm-project_clang_lib_Basic_Targets_PPC.h
@@ -1,6 +1,6 @@
 --- src/llvm-project/clang/lib/Basic/Targets/PPC.h.orig	2019-09-20 16:14:30 UTC
 +++ src/llvm-project/clang/lib/Basic/Targets/PPC.h
-@@ -374,12 +374,29 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public
+@@ -374,12 +374,30 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public
      IntMaxType = SignedLong;
      Int64Type = SignedLong;
  
@@ -14,11 +14,12 @@
 +	break;
 +      }
 +    } else {
-+      if ((Triple.getOS() == llvm::Triple::FreeBSD) &&
-+	      (Triple.getOSMajorVersion() < 13)) {
++      if (Triple.getOS() == llvm::Triple::FreeBSD) {
++#if defined(__FreeBSD__) && __FreeBSD__ < 13
 +        ABI = "elfv1";
-+      } else {
++#else
 +        ABI = "elfv2";
++#endif
 +      }
 +    }
 +
--- lang/rust/files/powerpc64-elfv2/patch-src_llvm-project_llvm_lib_Target_PowerPC_PPCTargetMachine.cpp
+++ lang/rust/files/powerpc64-elfv2/patch-src_llvm-project_llvm_lib_Target_PowerPC_PPCTargetMachine.cpp
@@ -1,6 +1,6 @@
 --- src/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp.orig	2019-09-20 16:14:30 UTC
 +++ src/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
-@@ -209,6 +209,20 @@ static PPCTargetMachine::PPCABI computeTargetABI(const
+@@ -209,6 +209,21 @@ static PPCTargetMachine::PPCABI computeTargetABI(const
    if (TT.isMacOSX())
      return PPCTargetMachine::PPC_ABI_UNKNOWN;
  
@@ -8,10 +8,11 @@
 +    switch (TT.getArch()) {
 +    case Triple::ppc64le:
 +    case Triple::ppc64:
-+      if (TT.getOSMajorVersion() >= 13)
-+        return PPCTargetMachine::PPC_ABI_ELFv2;
-+      else
++#if defined(__FreeBSD__) && __FreeBSD__ < 13
 +        return PPCTargetMachine::PPC_ABI_ELFv1;
++#else
++        return PPCTargetMachine::PPC_ABI_ELFv2;
++#endif
 +    case Triple::ppc:
 +    default:
 +      return PPCTargetMachine::PPC_ABI_UNKNOWN;
www/firefox/files/extra-patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #65159)
  1. Actually, portmgr and clusteradm still didn't upgrade pylon to ELFv2, even though head switched to it over a month ago. So it still builds packages for head for ELFv1.
  2. powerpc64 is supported not only on head. 11 and 12 support it as well and I generally try to keep ports building on 12. There are also official packages (though only for quarterly) for 12. If someone got Firefox to work on 12, I'd rather have those patches in ports.
lwhsu added inline comments.
www/firefox/files/extra-patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #65159)

Just a quick note that the clusteradm just kicked off a cluster refreshing last week, and now the newer package should be available. I think portmgr still need a few moments to test and upgrade things carefully, but hopefully it won't take too long.

Please, rebase after rP525179.

www/firefox-ppc64/files/patch-third__party_rust_libloading_build.rs
7 ↗(On Diff #65431)

Is this still required after files/patch-bug1628567 landed in rP533209?

mikael retitled this revision from www/firefox-ppc64: firefox for powerpc64 to www/firefox: port to powerpc64.

regen
files/patch-bug1628567 fixed the issue with libloading

Looks OK in general.

www/firefox/Makefile
44 ↗(On Diff #71276)

What requires libc++? IIRC, Firefox builds fine with GCC/libstdc++ on amd64.

Approved if you drop IGNORE. It doesn't seem important enough, anyway.

This revision is now accepted and ready to land.May 2 2020, 10:00 AM

drop files/patch-bug1612181_comment3, it's not needed anymore
drop IGNORE for elfv1

This revision now requires review to proceed.May 2 2020, 11:16 AM

drop files/patch-bug1612181_comment3, it's not needed anymore

Is files/patch-bug1612181_comment1 still required given -fno-integrated-as? I still haven't seen the error excerpt from GNU as.

This revision is now accepted and ready to land.May 2 2020, 11:25 AM

drop files/patch-bug1612181_comment3, it's not needed anymore

Is files/patch-bug1612181_comment1 still required given -fno-integrated-as? I still haven't seen the error excerpt from GNU as.

There is no GNU toolchain on powerpc64 elfv2, so yes we need patch-bug1612181_comment1.

www/firefox/Makefile
44 ↗(On Diff #71276)

IIRC some cargo crates, 'style' maybe (I don't remember to be honest)