Bug 261642 - www/firefox: Update to 97 (phase: Beta, ETA: 2022-02-08)
Summary: www/firefox: Update to 97 (phase: Beta, ETA: 2022-02-08)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Christoph Moench-Tegeder
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2022-02-01 00:55 UTC by Ghost
Modified: 2022-02-01 18:44 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (gecko)


Attachments
v1.0 (unzstd, git am) (88.85 KB, application/octet-stream)
2022-02-01 00:55 UTC, Ghost
no flags Details
depot.patch (1.56 KB, patch)
2022-02-01 01:01 UTC, Ghost
no flags Details | Diff
jsons.patch.zst (57.47 KB, application/octet-stream)
2022-02-01 01:03 UTC, Ghost
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ghost 2022-02-01 00:55:27 UTC
Created attachment 231478 [details]
v1.0 (unzstd, git am)

patch-webrtc deleted, patch-libwebrtc-generate(d) are added.

patch-libwebrtc-generate has almost everything needed to generate moz.build files,
except for a small depot_tools patch that will follow shortly together with how-to.

patch-libwebrtc-generated has generated moz.build files for amd64, i386 (i686 with -msse2), and aarch64 targets.

IDK if crediting jbeich review in bug 261410 is fine here, so git commit --amend if.

Note: consider that I submit patches and how-to and leave. I can't spend more time
on FOSS till Q2-Q3, but can't leave gecko@ without how-to and stuff.
Comment 1 Ghost 2022-02-01 01:01:03 UTC
Created attachment 231479 [details]
depot.patch

# v1.0.patch and depot.patch are in /usr/ports
# ppc64 related parts are commented out because chroot doesn't work

cd /usr/ports && git am v1.0.patch
rm /usr/ports/www/firefox/files/patch-libwebrtc-generated
cd www/firefox
export WRKDIR=/tmp/fox/src
make patch
(cd "$WRKDIR/firefox-97.0" ; git init && git add . && git commit -m init)
cp ../../depot.patch $WRKDIR/firefox-97.0

pkg install qemu-user-static
service qemu_user_static onestart
poudriere jail -c -j clean-aarch64 -v 13.0-RELEASE -a arm64.aarch64 -X
#poudriere jail -c -j clean-powerpc64 -v 13.0-STABLE -a powerpc.powerpc64 -X
poudriere jail -c -j clean -v 13.0-RELEASE

export ARMJAIL=/usr/local/poudriere/jails/clean-aarch64
#export PPCJAIL=/usr/local/poudriere/jails/clean-powerpc64
export CLNJAIL=/usr/local/poudriere/jails/clean

mkdir $ARMJAIL/tmp/fox
#mkdir $PPCJAIL/tmp/fox
mkdir $CLNJAIL/tmp/fox
mkdir $ARMJAIL/usr/ports
#mkdir $PPCJAIL/usr/ports
mkdir $CLNJAIL/usr/ports
mount_nullfs /tmp/fox $CLNJAIL/tmp/fox
mount_nullfs /usr/ports $CLNJAIL/usr/ports

cp /etc/resolv.conf $ARMJAIL/etc/resolv.conf
#cp /etc/resolv.conf $PPCJAIL/etc/resolv.conf
cp /etc/resolv.conf $CLNJAIL/etc/resolv.conf
mount -t devfs devfs $ARMJAIL/dev
#mount -t devfs devfs $PPCJAIL/dev
mount -t devfs devfs $CLNJAIL/dev

mkdir $CLNJAIL/arm
mkdir $CLNJAIL/ppc
mount_nullfs $ARMJAIL $CLNJAIL/arm
mount_nullfs $PPCJAIL $CLNJAIL/ppc

service qemu_user_static onestop
chroot $CLNJAIL
export TERM=xterm PS1="(clean) # "

# Check that chroot works (network, ports and gecko source)
file /bin/echo
/bin/echo test
host example.com
ls -alh /usr/ports
ls -alh /tmp/fox

pkg install -y qemu-user-static
service qemu_user_static onestart
mkdir -p /arm/usr/local/bin
#mkdir -p /ppc/usr/local/bin
cp /usr/local/bin/qemu-aarch64-static /arm/usr/local/bin
#cp /usr/local/bin/qemu-ppc64-static /ppc/usr/local/bin
mount_nullfs /tmp/fox /arm/tmp/fox
#mount_nullfs /tmp/fox /ppc/tmp/fox
mount_nullfs /usr/ports /arm/usr/ports
#mount_nullfs /usr/ports /ppc/usr/ports

# Check that qemu-user-static aarch64 chroot is OK
chroot /arm
file /bin/echo
/bin/echo test
host example.com
ls -alh /usr/ports
ls -alh /tmp/fox
Ctrl^D

# ppc64 related parts are commented out because of this, no further steps for ppc64
#Assertion failed: (!have_mmap_lock()), function cpu_exec, file /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-6ffee39fe2e4/accel/tcg/cpu-exec.c, line 697.
#Abort trap
#chroot /ppc

# (this is a "goto" mark for steps from aarch64 chroot down below)
PREPARE:

export I_DONT_CARE_IF_MY_BUILDS_TARGET_THE_WRONG_RELEASE=yes
pkg install -y pkg
# pkg is interactive, asks first to fetch packages, then to install
# make install-missing-packages will install everything needed and unneeded,
# saves a ton of time installing everything "./mach configure" asks for
(cd /usr/ports/www/firefox ; make install-missing-packages)

# Save the password from pw, one will need it when installing i686 Rust libs
# if in qemu chroot, one may not need doas, but it's a good idea to save it anyway
pkg install -y bash doas
pw user add fox -d /tmp/fox/home -w random -s /usr/local/bin/bash
mkdir /tmp/fox/home

echo 'permit fox as root' > /usr/local/etc/doas.conf
chown -R fox /tmp/fox
chown -R fox /usr/ports/www/firefox

ln -s /usr/local/bin/python3.8 /usr/local/bin/python3
ln -s /usr/local/bin/python3.8 /usr/local/bin/python
ln -s /usr/local/bin/pip-3.8 /usr/local/bin/pip3
ln -s /usr/local/bin/bash /bin/bash

su -l fox
cd ../src/firefox-97.0/

# if in qemu chroot, don't
git clone https://gn.googlesource.com/gn
(cd gn && git checkout 8fe02009)

# Use ninja from ports because the ports one is fine and building in qemu is slow
export NINJA=/usr/local/bin/ninja
(cd gn ; python build/gen.py && $NINJA -C out)
export GN=`pwd`/gn/out/gn

# if in qemu chroot, don't
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
(cd depot_tools && git checkout e7d1862b155a)
(cd depot_tools && git apply ../depot.patch)

export DEPOT_TOOLS=`pwd`/depot_tools
export CC=/usr/local/bin/clang13 CPP=/usr/local/bin/clang-cpp13 CXX=/usr/local/bin/clang++13

# (will prompt you then download and build tons of stuff in /tmp/fox/home (Press Enter)
# glean-sdk will fail in qemu but it apparently does not affect generate.sh:
# "Could not install glean-sdk, so telemetry will not be collected. Continuing."
./mach configure --prefix="/usr/local" --with-libclang-path="/usr/local/llvm13/lib" --with-wasi-sysroot="/usr/local/share/wasi-sysroot"

# if in qemu chroot, don't
fetch 'https://pkg.FreeBSD.org/FreeBSD:13:i386/quarterly/All/rust-1.57.0.pkg' -o rust-i386.pkg
mkdir ../rustlib
tar -C ../rustlib -xf rust-i386.pkg --include='*-unknown-freebsd*' --strip-components 5
doas cp -a ../rustlib /usr/local/lib
rm -rf ../rustlib

# if in qemu chroot, uncomment the arm64 CONFIG line, and comment out PC CONFIG lines
# in dom/media/webrtc/third_party_build/gn-configs/generate-gn-build-files.sh
# "generate-gn-build-files.sh" in qemu is slow, be patient
# If you get the following output, consider success:
# "Done generating gn build files. You should now be able to build with ./mach build"
DEBUG_GEN=1 ./dom/media/webrtc/third_party_build/gn-configs/generate-gn-build-files.sh

git add "./*moz.build*" "dom/media/webrtc/third_party_build/gn-configs/*.json"

# Do below if in (clean) non-qemu environment
# If you don't delete the remaining PC binaries in home,
# then qemu would hang
git commit -m 'PC'
rm -rf /tmp/fox/home/.cache /tmp/fox/home/.cargo /tmp/fox/home/.local \
/tmp/fox/home/.mozbuild gn/out

# Do below if in qemu
# Work is done after outputting to "patch-webrtc-generated"
git commit -m 'ARM'
git diff --no-prefix HEAD~2 HEAD -- ":(exclude)*/$1/*.json" > /usr/ports/www/firefox/files/patch-webrtc-generated

# If in (clean) non-qemu environment
#
# Exit to (clean), mount /dev for qemu chroot
# (Nested nullfs in chroot doesn't work the way it seems to, so
# instead of starting from scratch and redoing the whole how-to,
# just mount devfs to /arm/dev)
Ctrl^D
mount -t devfs devfs /arm/dev
chroot /arm
export PS1="(aarch64) # "

# Search for "PREPARE" in this how-to and repeat the same from there
# Good luck and be patient
goto PREPARE

---

Here is a rustc wrapper script for cross-compiling as noted in bug 261410.
Rust part will pass but then the clang cross-compile test would fail:
/tmp/hello-25a9fd.o is incompatible with /usr/lib/crt1.o
ENOTIME to work on cross-compile.

mv /usr/local/bin/rustc /usr/local/bin/rustc-real
cat >/usr/local/bin/rustc <<'EOF'
#!/usr/local/bin/bash

cmd=()
VAR=()

for i in "$@"; do
  cmd+=("$i")
  case $i in
    --target=*)
      TARGET="${i#*=}"
      if [ "$TARGET" = "aarch64-unknown-freebsd" ]; then
        VAR+=("-C link-arg=--sysroot -C link-arg=/tmp/130-aarch64")
      fi
      shift
      ;;
    *)
      ;;
  esac
done

env RUSTFLAGS="$VAR" /usr/local/bin/rustc-real "${cmd[@]}"
EOF
chmod +x /usr/local/bin/rustc
Comment 2 Ghost 2022-02-01 01:03:36 UTC
Created attachment 231480 [details]
jsons.patch.zst

Attached jsons etc in a patch applied to 97.0b9 source if anyone needs that.
Comment 3 Ghost 2022-02-01 01:05:56 UTC
(In reply to Evgeniy Khramtsov from comment #1)

I almost forgot. I had issues before on 14-CURRENT kernel, ASLR/W^X and QEMU.
I did the steps with them turned off.
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-02-01 16:32:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a012dd67b23d35b6a44c8b8b3ecaf0f750bb9238

commit a012dd67b23d35b6a44c8b8b3ecaf0f750bb9238
Author:     Evgeniy Khramtsov <evgeniy@khramtsov.org>
AuthorDate: 2022-02-01 00:30:08 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2022-02-01 16:31:51 +0000

    www/firefox: update to 97.0 (rc1)

    Release Notes (soon):
      https://www.mozilla.org/en-US/firefox/97.0/releasenotes/

    PR:             261642

 Mk/bsd.gecko.mk                                    |      3 +
 www/firefox/Makefile                               |      4 +-
 www/firefox/distinfo                               |      6 +-
 www/firefox/files/patch-bug1640982                 |      2 -
 www/firefox/files/patch-bug1664115                 |      4 +-
 www/firefox/files/patch-bug1749604 (new)           |    249 +
 www/firefox/files/patch-bug847568                  |     14 +-
 www/firefox/files/patch-libwebrtc-generate (new)   |    192 +
 www/firefox/files/patch-libwebrtc-generated (new)  |  19756 ++
 .../files/patch-media_libcubeb_src_cubeb__oss.c    |    385 +-
 www/firefox/files/patch-webrtc (gone)              | 253107 ------------------
 11 files changed, 20249 insertions(+), 253473 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-02-01 16:33:50 UTC
A commit in branch 2022Q1 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=34c6e1527b0ca53901af31d6e040b53c2d9dad98

commit 34c6e1527b0ca53901af31d6e040b53c2d9dad98
Author:     Evgeniy Khramtsov <evgeniy@khramtsov.org>
AuthorDate: 2022-02-01 00:30:08 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2022-02-01 16:33:05 +0000

    www/firefox: update to 97.0 (rc1)

    Release Notes (soon):
      https://www.mozilla.org/en-US/firefox/97.0/releasenotes/

    PR:             261642
    (cherry picked from commit a012dd67b23d35b6a44c8b8b3ecaf0f750bb9238)

 Mk/bsd.gecko.mk                                    |      3 +
 www/firefox/Makefile                               |      4 +-
 www/firefox/distinfo                               |      6 +-
 www/firefox/files/patch-bug1640982                 |      2 -
 www/firefox/files/patch-bug1664115                 |      4 +-
 www/firefox/files/patch-bug1749604 (new)           |    249 +
 www/firefox/files/patch-bug847568                  |     14 +-
 www/firefox/files/patch-libwebrtc-generate (new)   |    192 +
 www/firefox/files/patch-libwebrtc-generated (new)  |  19756 ++
 .../files/patch-media_libcubeb_src_cubeb__oss.c    |    385 +-
 www/firefox/files/patch-webrtc (gone)              | 253107 ------------------
 11 files changed, 20249 insertions(+), 253473 deletions(-)