summaryrefslogtreecommitdiff
path: root/repo/apps/chromium
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-05-31 11:04:17 +0100
committerdavidovski <david@davidovski.xyz>2022-05-31 11:04:17 +0100
commit871b2b573f01c1b3176a0f65458b3d281b41c437 (patch)
tree1311c682a9307026b039de9ba0e93bd22e35e2f5 /repo/apps/chromium
parentdfcdf333c80ae1d7171f6fa145fd87fecb8c5b73 (diff)
added pandoc and qt5
Diffstat (limited to 'repo/apps/chromium')
-rw-r--r--repo/apps/chromium/chromium-VirtualCursor-standard-layout.patch216
-rw-r--r--repo/apps/chromium/chromium-launcher.sh41
-rw-r--r--repo/apps/chromium/chromium-revert-drop-of-system-java.patch15
-rw-r--r--repo/apps/chromium/chromium-use-alpine-target.patch24
-rw-r--r--repo/apps/chromium/chromium.conf5
-rw-r--r--repo/apps/chromium/chromium.desktop10
-rw-r--r--repo/apps/chromium/chromium.xibuild284
-rw-r--r--repo/apps/chromium/credentials-header.patch11
-rw-r--r--repo/apps/chromium/default-pthread-stacksize.patch45
-rw-r--r--repo/apps/chromium/elf-arm.patch11
-rw-r--r--repo/apps/chromium/enable-GlobalMediaControlsCastStartStop.patch32
-rw-r--r--repo/apps/chromium/fix-narrowing-cast.patch53
-rw-r--r--repo/apps/chromium/fix-unittests-sandbox.patch11
-rw-r--r--repo/apps/chromium/gcc-arm.patch11
-rw-r--r--repo/apps/chromium/gdbinit.patch21
-rw-r--r--repo/apps/chromium/google-api.keys10
-rw-r--r--repo/apps/chromium/media-base.patch10
-rw-r--r--repo/apps/chromium/memory-tagging-arm64.patch18
-rw-r--r--repo/apps/chromium/musl-crashpad.patch25
-rw-r--r--repo/apps/chromium/musl-fixes.patch221
-rw-r--r--repo/apps/chromium/musl-hacks.patch98
-rw-r--r--repo/apps/chromium/musl-sandbox.patch176
-rw-r--r--repo/apps/chromium/musl-stat.patch12
-rw-r--r--repo/apps/chromium/musl-tid-caching.patch81
-rw-r--r--repo/apps/chromium/musl-v8-monotonic-pthread-cont_timedwait.patch22
-rw-r--r--repo/apps/chromium/nasm.patch11
-rw-r--r--repo/apps/chromium/no-execinfo.patch75
-rw-r--r--repo/apps/chromium/no-getcontext.patch26
-rw-r--r--repo/apps/chromium/no-mallinfo.patch83
-rw-r--r--repo/apps/chromium/quiche-arena-size.patch11
-rw-r--r--repo/apps/chromium/remove-strip_binary.patch32
-rw-r--r--repo/apps/chromium/resolver.patch36
-rw-r--r--repo/apps/chromium/revert-use-ffile-compilation-dir.patch48
-rw-r--r--repo/apps/chromium/scoped-file.patch31
-rw-r--r--repo/apps/chromium/sql-make-VirtualCursor-standard-layout-type.patch238
-rw-r--r--repo/apps/chromium/system-opus.patch52
-rw-r--r--repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch12
-rw-r--r--repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch.112
-rw-r--r--repo/apps/chromium/use-deprecated-ffmpeg-api.patch36
-rw-r--r--repo/apps/chromium/use-deprecated-ffmpeg-api.patch.136
-rw-r--r--repo/apps/chromium/use-oauth2-client-switches-as-default.patch17
-rw-r--r--repo/apps/chromium/wayland-egl.patch22
-rw-r--r--repo/apps/chromium/webcodecs-stop-using-AudioOpusEncoder.patch49
-rw-r--r--repo/apps/chromium/webrtc-check-existence-of-cursor-metadata.patch31
44 files changed, 2321 insertions, 0 deletions
diff --git a/repo/apps/chromium/chromium-VirtualCursor-standard-layout.patch b/repo/apps/chromium/chromium-VirtualCursor-standard-layout.patch
new file mode 100644
index 0000000..721e194
--- /dev/null
+++ b/repo/apps/chromium/chromium-VirtualCursor-standard-layout.patch
@@ -0,0 +1,216 @@
+diff --git a/sql/recover_module/btree.cc b/sql/recover_module/btree.cc
+index 9ecaafe..839318a 100644
+--- a/sql/recover_module/btree.cc
++++ b/sql/recover_module/btree.cc
+@@ -135,16 +135,25 @@
+ "Move the destructor to the .cc file if it's non-trival");
+ #endif // !DCHECK_IS_ON()
+
+-LeafPageDecoder::LeafPageDecoder(DatabasePageReader* db_reader) noexcept
+- : page_id_(db_reader->page_id()),
+- db_reader_(db_reader),
+- cell_count_(ComputeCellCount(db_reader)),
+- next_read_index_(0),
+- last_record_size_(0) {
++void LeafPageDecoder::Initialize(DatabasePageReader* db_reader) {
++ DCHECK(db_reader);
+ DCHECK(IsOnValidPage(db_reader));
++ page_id_ = db_reader->page_id();
++ db_reader_ = db_reader;
++ cell_count_ = ComputeCellCount(db_reader);
++ next_read_index_ = 0;
++ last_record_size_ = 0;
+ DCHECK(DatabasePageReader::IsValidPageId(page_id_));
+ }
+
++void LeafPageDecoder::Reset() {
++ db_reader_ = nullptr;
++ page_id_ = 0;
++ cell_count_ = 0;
++ next_read_index_ = 0;
++ last_record_size_ = 0;
++}
++
+ bool LeafPageDecoder::TryAdvance() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK(CanAdvance());
+diff --git a/sql/recover_module/btree.h b/sql/recover_module/btree.h
+index d76d076..33114b0 100644
+--- a/sql/recover_module/btree.h
++++ b/sql/recover_module/btree.h
+@@ -102,7 +102,7 @@
+ //
+ // |db_reader| must have been used to read an inner page of a table B-tree.
+ // |db_reader| must outlive this instance.
+- explicit LeafPageDecoder(DatabasePageReader* db_reader) noexcept;
++ explicit LeafPageDecoder() noexcept = default;
+ ~LeafPageDecoder() noexcept = default;
+
+ LeafPageDecoder(const LeafPageDecoder&) = delete;
+@@ -150,6 +150,15 @@
+ // read as long as CanAdvance() returns true.
+ bool TryAdvance();
+
++ // Initialize with DatabasePageReader
++ void Initialize(DatabasePageReader* db_reader);
++
++ // Reset internal DatabasePageReader
++ void Reset();
++
++ // True if DatabasePageReader is valid
++ bool IsValid() { return (db_reader_ != nullptr); }
++
+ // True if the given reader may point to an inner page in a table B-tree.
+ //
+ // The last ReadPage() call on |db_reader| must have succeeded.
+@@ -163,14 +172,14 @@
+ static int ComputeCellCount(DatabasePageReader* db_reader);
+
+ // The number of the B-tree page this reader is reading.
+- const int64_t page_id_;
++ int64_t page_id_;
+ // Used to read the tree page.
+ //
+ // Raw pointer usage is acceptable because this instance's owner is expected
+ // to ensure that the DatabasePageReader outlives this.
+- DatabasePageReader* const db_reader_;
++ DatabasePageReader* db_reader_;
+ // Caches the ComputeCellCount() value for this reader's page.
+- const int cell_count_ = ComputeCellCount(db_reader_);
++ int cell_count_;
+
+ // The reader's cursor state.
+ //
+diff --git a/sql/recover_module/cursor.cc b/sql/recover_module/cursor.cc
+index 0029ff9..42548bc 100644
+--- a/sql/recover_module/cursor.cc
++++ b/sql/recover_module/cursor.cc
+@@ -26,7 +26,7 @@
+ int VirtualCursor::First() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ inner_decoders_.clear();
+- leaf_decoder_ = nullptr;
++ leaf_decoder_.Reset();
+
+ AppendPageDecoder(table_->root_page_id());
+ return Next();
+@@ -36,18 +36,18 @@
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ record_reader_.Reset();
+
+- while (!inner_decoders_.empty() || leaf_decoder_.get()) {
+- if (leaf_decoder_.get()) {
+- if (!leaf_decoder_->CanAdvance()) {
++ while (!inner_decoders_.empty() || leaf_decoder_.IsValid()) {
++ if (leaf_decoder_.IsValid()) {
++ if (!leaf_decoder_.CanAdvance()) {
+ // The leaf has been exhausted. Remove it from the DFS stack.
+- leaf_decoder_ = nullptr;
++ leaf_decoder_.Reset();
+ continue;
+ }
+- if (!leaf_decoder_->TryAdvance())
++ if (!leaf_decoder_.TryAdvance())
+ continue;
+
+- if (!payload_reader_.Initialize(leaf_decoder_->last_record_size(),
+- leaf_decoder_->last_record_offset())) {
++ if (!payload_reader_.Initialize(leaf_decoder_.last_record_size(),
++ leaf_decoder_.last_record_offset())) {
+ continue;
+ }
+ if (!record_reader_.Initialize())
+@@ -99,13 +99,13 @@
+ int64_t VirtualCursor::RowId() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK(record_reader_.IsInitialized());
+- DCHECK(leaf_decoder_.get());
+- return leaf_decoder_->last_record_rowid();
++ DCHECK(leaf_decoder_.IsValid());
++ return leaf_decoder_.last_record_rowid();
+ }
+
+ void VirtualCursor::AppendPageDecoder(int page_id) {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+- DCHECK(leaf_decoder_.get() == nullptr)
++ DCHECK(!leaf_decoder_.IsValid())
+ << __func__
+ << " must only be called when the current path has no leaf decoder";
+
+@@ -113,7 +113,7 @@
+ return;
+
+ if (LeafPageDecoder::IsOnValidPage(&db_reader_)) {
+- leaf_decoder_ = std::make_unique<LeafPageDecoder>(&db_reader_);
++ leaf_decoder_.Initialize(&db_reader_);
+ return;
+ }
+
+diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
+index afcd690..b15c31d 100644
+--- a/sql/recover_module/cursor.h
++++ b/sql/recover_module/cursor.h
+@@ -129,7 +129,7 @@
+ std::vector<std::unique_ptr<InnerPageDecoder>> inner_decoders_;
+
+ // Decodes the leaf page containing records.
+- std::unique_ptr<LeafPageDecoder> leaf_decoder_;
++ LeafPageDecoder leaf_decoder_;
+
+ SEQUENCE_CHECKER(sequence_checker_);
+ };
+diff --git a/sql/recover_module/pager.cc b/sql/recover_module/pager.cc
+index 58e75de..5fe9620 100644
+--- a/sql/recover_module/pager.cc
++++ b/sql/recover_module/pager.cc
+@@ -23,8 +23,7 @@
+ "ints are not appropriate for representing page IDs");
+
+ DatabasePageReader::DatabasePageReader(VirtualTable* table)
+- : page_data_(std::make_unique<uint8_t[]>(table->page_size())),
+- table_(table) {
++ : page_data_(), table_(table) {
+ DCHECK(table != nullptr);
+ DCHECK(IsValidPageSize(table->page_size()));
+ }
+@@ -57,8 +56,8 @@
+ std::numeric_limits<int64_t>::max(),
+ "The |read_offset| computation above may overflow");
+
+- int sqlite_status =
+- RawRead(sqlite_file, read_size, read_offset, page_data_.get());
++ int sqlite_status = RawRead(sqlite_file, read_size, read_offset,
++ const_cast<uint8_t*>(page_data_.data()));
+
+ // |page_id_| needs to be set to kInvalidPageId if the read failed.
+ // Otherwise, future ReadPage() calls with the previous |page_id_| value
+diff --git a/sql/recover_module/pager.h b/sql/recover_module/pager.h
+index 0e388ddc..99314e3 100644
+--- a/sql/recover_module/pager.h
++++ b/sql/recover_module/pager.h
+@@ -5,6 +5,7 @@
+ #ifndef SQL_RECOVER_MODULE_PAGER_H_
+ #define SQL_RECOVER_MODULE_PAGER_H_
+
++#include <array>
+ #include <cstdint>
+ #include <memory>
+
+@@ -70,7 +71,7 @@
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK_NE(page_id_, kInvalidPageId)
+ << "Successful ReadPage() required before accessing pager state";
+- return page_data_.get();
++ return page_data_.data();
+ }
+
+ // The number of bytes in the page read by the last ReadPage() call.
+@@ -137,7 +138,7 @@
+ int page_id_ = kInvalidPageId;
+ // Stores the bytes of the last page successfully read by ReadPage().
+ // The content is undefined if the last call to ReadPage() did not succeed.
+- const std::unique_ptr<uint8_t[]> page_data_;
++ const std::array<uint8_t, kMaxPageSize> page_data_;
+ // Raw pointer usage is acceptable because this instance's owner is expected
+ // to ensure that the VirtualTable outlives this.
+ VirtualTable* const table_;
diff --git a/repo/apps/chromium/chromium-launcher.sh b/repo/apps/chromium/chromium-launcher.sh
new file mode 100644
index 0000000..ceba3f2
--- /dev/null
+++ b/repo/apps/chromium/chromium-launcher.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+export DBUS_SESSION_BUS_ADDRES=unix:path=/run/dbus/system_bus_socket
+
+# Allow the user to override command-line flags, bug #357629.
+# This is based on Debian's chromium-browser package, and is intended
+# to be consistent with Debian.
+for f in /etc/chromium/*.conf; do
+ [ -f ${f} ] && . "${f}"
+done
+
+# Prefer user defined CHROMIUM_USER_FLAGS (from env) over system
+# default CHROMIUM_FLAGS (from /etc/chromium/default).
+CHROMIUM_FLAGS=${CHROMIUM_USER_FLAGS:-"$CHROMIUM_FLAGS"}
+
+# Let the wrapped binary know that it has been run through the wrapper
+export CHROME_WRAPPER=$(readlink -f "$0")
+
+PROGDIR=${CHROME_WRAPPER%/*}
+
+case ":$PATH:" in
+ *:$PROGDIR:*)
+ # $PATH already contains $PROGDIR
+ ;;
+ *)
+ # Append $PROGDIR to $PATH
+ export PATH="$PATH:$PROGDIR"
+ ;;
+esac
+
+if [ $(id -u) -eq 0 ] && [ $(stat -t -L ${XDG_CONFIG_HOME:-${HOME}} | cut -d' ' -f5) -eq 0 ]; then
+ # Running as root with HOME owned by root.
+ # Pass --user-data-dir to work around upstream failsafe.
+ CHROMIUM_FLAGS="--user-data-dir=${XDG_CONFIG_HOME:-${HOME}/.config}/chromium
+ ${CHROMIUM_FLAGS}"
+fi
+
+# Set the .desktop file name
+export CHROME_DESKTOP="chromium.desktop"
+
+exec "$PROGDIR/chromium" --extra-plugin-dir=/usr/lib/nsbrowser/plugins ${CHROMIUM_FLAGS} "$@"
diff --git a/repo/apps/chromium/chromium-revert-drop-of-system-java.patch b/repo/apps/chromium/chromium-revert-drop-of-system-java.patch
new file mode 100644
index 0000000..117a50f
--- /dev/null
+++ b/repo/apps/chromium/chromium-revert-drop-of-system-java.patch
@@ -0,0 +1,15 @@
+This was dropped for some reason in 6951c37cecd05979b232a39e5c10e6346a0f74ef
+--- a/third_party/closure_compiler/compiler.py 2021-05-20 04:17:53.000000000 +0200
++++ b/third_party/closure_compiler/compiler.py 2021-05-20 04:17:53.000000000 +0200
+@@ -13,8 +13,9 @@
+
+
+ _CURRENT_DIR = os.path.join(os.path.dirname(__file__))
+-_JAVA_PATH = os.path.join(_CURRENT_DIR, "..", "jdk", "current", "bin", "java")
+-assert os.path.isfile(_JAVA_PATH), "java only allowed in android builds"
++_JAVA_BIN = "java"
++_JDK_PATH = os.path.join(_CURRENT_DIR, "..", "jdk", "current", "bin", "java")
++_JAVA_PATH = _JDK_PATH if os.path.isfile(_JDK_PATH) else _JAVA_BIN
+
+ class Compiler(object):
+ """Runs the Closure compiler on given source files to typecheck them
diff --git a/repo/apps/chromium/chromium-use-alpine-target.patch b/repo/apps/chromium/chromium-use-alpine-target.patch
new file mode 100644
index 0000000..8282aca
--- /dev/null
+++ b/repo/apps/chromium/chromium-use-alpine-target.patch
@@ -0,0 +1,24 @@
+--- ./build/config/compiler/BUILD.gn
++++ ./build/config/compiler/BUILD.gn
+@@ -752,8 +752,8 @@
+ }
+ } else if (current_cpu == "arm") {
+ if (is_clang && !is_android && !is_nacl) {
+- cflags += [ "--target=arm-linux-gnueabihf" ]
+- ldflags += [ "--target=arm-linux-gnueabihf" ]
++ cflags += [ "--target=armv7-alpine-linux-musleabihf" ]
++ ldflags += [ "--target=armv7-alpine-linux-musleabihf" ]
+ }
+ if (!is_nacl) {
+ cflags += [
+@@ -766,8 +766,8 @@
+ }
+ } else if (current_cpu == "arm64") {
+ if (is_clang && !is_android && !is_nacl && !is_fuchsia) {
+- cflags += [ "--target=aarch64-linux-gnu" ]
+- ldflags += [ "--target=aarch64-linux-gnu" ]
++ cflags += [ "--target=aarch64-alpine-linux-musl" ]
++ ldflags += [ "--target=aarch64-alpine-linux-musl" ]
+ }
+ } else if (current_cpu == "mipsel" && !is_nacl) {
+ ldflags += [ "-Wl,--hash-style=sysv" ]
diff --git a/repo/apps/chromium/chromium.conf b/repo/apps/chromium/chromium.conf
new file mode 100644
index 0000000..a8b8db3
--- /dev/null
+++ b/repo/apps/chromium/chromium.conf
@@ -0,0 +1,5 @@
+# Default settings for chromium. This file is sourced by /bin/sh from
+# the chromium launcher.
+
+# Options to pass to chromium.
+#CHROMIUM_FLAGS=""
diff --git a/repo/apps/chromium/chromium.desktop b/repo/apps/chromium/chromium.desktop
new file mode 100644
index 0000000..e5f549b
--- /dev/null
+++ b/repo/apps/chromium/chromium.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=Chromium
+GenericName=Web Browser
+Comment=Access the Internet
+Exec=chromium-browser %U
+Terminal=false
+Icon=chromium
+Type=Application
+Categories=GTK;Network;WebBrowser;
+MimeType=text/html;text/xml;application/xhtml+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
diff --git a/repo/apps/chromium/chromium.xibuild b/repo/apps/chromium/chromium.xibuild
new file mode 100644
index 0000000..5131239
--- /dev/null
+++ b/repo/apps/chromium/chromium.xibuild
@@ -0,0 +1,284 @@
+#!/bin/sh
+
+NAME="chromium"
+DESC="Chromium webbrowser (ungoogled)"
+
+MAKEDEPS="meson ninja hwids lld pciutils"
+DEPS="alsa-lib at-spi2-atk at-spi2-core atk cairo dbus eudev expat ffmpeg4 flac font-opensans fontconfig freetype2 glib gtk3 harfbuzz lcms2 libdrm libevent libjpeg-turbo libpng pulseaudio libwebp libx11 libxcb libxcomposite libxdamage libxext libxfixes libxkbcommon libxml2 libxrandr libxslt mesa musl nspr nss opus pango re2 snappy wayland xdg-utils nodejs"
+
+PKG_VER=100.0.4896.127
+
+SOURCE="https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$PKG_VER.tar.xz"
+
+fonts_package=cd96fc55dc243f6c6f4cb63ad117cad6cd48dceb
+_launcher_ver=8
+ADDITIONAL="
+https://github.com/Eloston/ungoogled-chromium/archive/$PKG_VER-1.tar.gz
+https://chromium-fonts.storage.googleapis.com/$fonts_package
+
+chromium-VirtualCursor-standard-layout.patch
+chromium-revert-drop-of-system-java.patch
+chromium-use-alpine-target.patch
+chromium.conf
+chromium-launcher.sh
+chromium.desktop
+credentials-header.patch
+default-pthread-stacksize.patch
+elf-arm.patch
+fix-narrowing-cast.patch
+fix-unittests-sandbox.patch
+gcc-arm.patch
+gdbinit.patch
+google-api.keys
+media-base.patch
+memory-tagging-arm64.patch
+musl-crashpad.patch
+musl-fixes.patch
+musl-hacks.patch
+musl-sandbox.patch
+musl-stat.patch
+musl-tid-caching.patch
+musl-v8-monotonic-pthread-cont_timedwait.patch
+nasm.patch
+no-execinfo.patch
+no-getcontext.patch
+no-mallinfo.patch
+quiche-arena-size.patch
+resolver.patch
+revert-use-ffile-compilation-dir.patch
+scoped-file.patch
+system-opus.patch
+use-deprecated-ffmpeg-api.patch
+unbundle-ffmpeg-av_stream_get_first_dts.patch
+use-oauth2-client-switches-as-default.patch
+wayland-egl.patch
+webcodecs-stop-using-AudioOpusEncoder.patch
+"
+
+prepare () {
+ apply_patches
+
+ # Congratulations, you have found a bug! The bug is in the application that uses this internal glibc header
+ files="third_party/libsync/src/include/sync/sync.h
+ third_party/crashpad/crashpad/compat/linux/sys/ptrace.h
+ base/allocator/allocator_shim_internals.h"
+ for f in $files; do
+ sed -i "s/__BEGIN_DECLS/#ifdef __cplusplus\nextern \"C\" {\n#endif/g" $f
+ sed -i "s/__END_DECLS/#ifdef __cplusplus\n}\n#endif/g" $f
+ sed -i "s,#include <sys/cdefs.h>,," $f
+ done
+
+ # prevent annoying errors when regenerating gni
+ sed -i 's,^update_readme$,#update_readme,' \
+ third_party/libvpx/generate_gni.sh
+
+ # allow system dependencies in "official builds"
+ sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
+ tools/generate_shim_headers/generate_shim_headers.py
+
+
+ tar xf chromium-launcher-$_launcher_ver.tar.gz
+ tar xf $fonts_package
+ tar xf $PKG_VER-1.tar.gz
+ ungoogled_repo="ungoogled-chromium-$PKG_VER-1"
+ utils="${ungoogled_repo}/utils"
+
+ python "$utils/prune_binaries.py" ./ "$ungoogled_repo/pruning.list"
+ python "$utils/patches.py" apply ./ "$ungoogled_repo/patches"
+ python "$utils/domain_substitution.py" apply -r "$ungoogled_repo/domain_regex.list" \
+ -f "$ungoogled_repo/domain_substitution.list" -c domainsubcache.tar.gz ./
+
+ mv test_fonts ./third_party/test_fonts
+
+ sed 's|//third_party/usb_ids/usb.ids|/usr/share/hwdata/usb.ids|g' \
+ -i services/device/public/cpp/usb/BUILD.gn
+
+ mkdir -p third_party/node/linux/node-linux-x64/bin
+ ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
+
+ # Remove bundled libraries for which we will use the system copies; this
+ # *should* do what the remove_bundled_libraries.py script does, with the
+ # added benefit of not having to list all the remaining libraries
+
+ local use_system="
+ ffmpeg
+ flac
+ fontconfig
+ freetype
+ harfbuzz-ng
+ libdrm
+ libevent
+ libjpeg
+ libwebp
+ libxml
+ libxslt
+ opus
+ re2
+ snappy
+ "
+
+ local _lib
+ for _lib in ${use_system}; do
+ for f in $(find "third_party/$_lib/chromium" "third_party/$_lib/google" -type f \( -name "*.gn" -or -name "*.gni" -or -name "*.isolate" \)); do
+ echo "removing $f to use system $_lib"
+ rm $f
+ done
+ done
+
+ python build/linux/unbundle/replace_gn_files.py \
+ --system-libraries ${use_system}
+ python third_party/libaddressinput/chromium/tools/update-strings.py
+}
+
+build () {
+ #export CC=clang
+ #export CXX=clang++
+ #export LD=clang++
+ #export AR=ar
+ #export NM=nm
+ export LDFLAGS="-stdlib=libstdc++"
+
+ flags="
+custom_toolchain=\"//build/toolchain/linux/unbundle:default\"
+host_toolchain=\"//build/toolchain/linux/unbundle:default\"
+enable_nacl=false
+use_sysroot=false
+gold_path=\"/usr/bin/ld.gold\"
+use_custom_libcxx=false
+use_gold=false
+is_debug=false
+blink_symbol_level=0
+symbol_level=0
+icu_use_data_file=true
+use_allocator=\"none\"
+use_allocator_shim=false
+enable_widevine=true
+use_system_harfbuzz=false
+use_system_wayland_scanner=true
+use_cups=false
+use_gnome_keyring=false
+use_vaapi=true
+enable_js_type_check=true
+use_pulseaudio=true
+link_pulseaudio=true
+rtc_use_pipewire=true
+proprietary_codecs=false
+ffmpeg_branding=\"Chrome\"
+fatal_linker_warnings=false
+disable_fieldtrial_testing_config=true
+is_official_build=true
+is_cfi=false
+use_thin_lto=false
+use_cfi_icall=false
+chrome_pgo_phase=0
+ "
+
+ # Append ungoogled chromium flags to _flags array
+ flags="$flags
+ $(cat "ungoogled-chromium-$PKG_VER-1/flags.gn")
+ "
+
+ # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
+ CFLAGS="$CFLAGS -Wno-builtin-macro-redefined"
+ CXXFLAGS="$CXXFLAGS -Wno-builtin-macro-redefined"
+ CPPFLAGS="$CPPFLAGS -D__DATE__= -D__TIME__= -D__TIMESTAMP__="
+
+ # Do not warn about unknown warning options
+ CFLAGS="$CFLAGS -Wno-unknown-warning-option"
+ CXXFLAGS="$CXXFLAGS -Wno-unknown-warning-option"
+
+ python3 tools/gn/bootstrap/bootstrap.py -s -v --skip-generate-buildfiles
+
+ ./out/Release/gn gen out/Release --args="$flags"
+
+ ninja -C out/Release mksnapshot
+ ninja -C out/Release v8_context_snapshot_generator
+
+ ulimit -n 2048
+ ninja -C out/Release chrome chrome_sandbox chromedriver
+}
+
+package () {
+ install -Dm755 chromium-launcher.sh \
+ "$PKG_DEST"/usr/lib/chromium/chromium-launcher.sh
+
+ install -D out/Release/chrome "$PKG_DEST/usr/lib/chromium/chromium"
+ install -D out/Release/chromedriver "$PKG_DEST/usr/bin/chromedriver"
+ install -Dm4755 out/Release/chrome_sandbox "$PKG_DEST/usr/lib/chromium/chrome-sandbox"
+
+ install -Dm644 ../chromium-drirc-disable-10bpc-color-configs.conf \
+ "$PKG_DEST/usr/share/drirc.d/10-chromium.conf"
+
+ install -Dm644 chrome/installer/linux/common/desktop.template \
+ "$PKG_DEST/usr/share/applications/chromium.desktop"
+ install -Dm644 chrome/app/resources/manpage.1.in \
+ "$PKG_DEST/usr/share/man/man1/chromium.1"
+ sed -i \
+ -e 's/@@MENUNAME@@/Chromium/g' \
+ -e 's/@@PACKAGE@@/chromium/g' \
+ -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
+ "$PKG_DEST/usr/share/applications/chromium.desktop" \
+ "$PKG_DEST/usr/share/man/man1/chromium.1"
+
+ install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
+ "$PKG_DEST/usr/share/metainfo/chromium.appdata.xml"
+ sed -ni \
+ -e 's/chromium-browser\.desktop/chromium.desktop/' \
+ -e '/<update_contact>/d' \
+ -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
+ -e '/^<?xml/,$p' \
+ "$PKG_DEST/usr/share/metainfo/chromium.appdata.xml"
+
+ local toplevel_files="
+chrome_100_percent.pak
+chrome_200_percent.pak
+chrome_crashpad_handler
+resources.pak
+v8_context_snapshot.bin
+snapshot_blob.bin
+xdg-mime
+xdg-settings
+libEGL.so
+libGLESv2.so
+libvk_swiftshader.so
+vk_swiftshader_icd.json
+icudtl.dat
+libvulkan.so.1
+ "
+
+ mkdir -p "$PKG_DEST/usr/lib/chromium"
+ mkdir -p "$PKG_DEST/usr/lib/chromium/locales"
+ mkdir -p "$PKG_DEST/usr/lib/chromium/swiftshader"
+
+ for file in $toplevel_files; do
+ cp out/Release/$file "$PKG_DEST/usr/lib/chromium/"
+ done
+
+ for locale in out/Release/locales/* ; do
+ install -Dm644 $locale "$PKG_DEST/usr/lib/chromium/locales"
+ done
+ for shader in out/Release/swiftshader/*.so; do
+ install -Dm755 $shader "$PKG_DEST/usr/lib/chromium/swiftshader"
+ done
+
+ for size in 24 48 64 128 256; do
+ install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
+ "$PKG_DEST/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
+ done
+
+ for size in 16 32; do
+ install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
+ "$PKG_DEST/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
+ done
+
+ install -Dm644 LICENSE "$PKG_DEST/usr/share/licenses/chromium/LICENSE"
+
+ mkdir -p "$PKG_DEST"/usr/bin
+ ln -sf /usr/lib/chromium/chromium-launcher.sh "$PKG_DEST"/usr/bin/chromium-browser
+ install -Dm644 chromium.conf \
+ "$PKG_DEST"/etc/chromium/chromium.conf
+
+ install -Dm644 chromium.desktop \
+ "$PKG_DEST"/usr/share/applications/chromium.desktop
+
+}
diff --git a/repo/apps/chromium/credentials-header.patch b/repo/apps/chromium/credentials-header.patch
new file mode 100644
index 0000000..840bd2a
--- /dev/null
+++ b/repo/apps/chromium/credentials-header.patch
@@ -0,0 +1,11 @@
+--- ./sandbox/linux/services/credentials.h.orig
++++ ./sandbox/linux/services/credentials.h
+@@ -14,6 +14,8 @@
+ #include <string>
+ #include <vector>
+
++#include <sys/types.h>
++
+ #include "sandbox/linux/system_headers/capability.h"
+ #include "sandbox/sandbox_export.h"
+
diff --git a/repo/apps/chromium/default-pthread-stacksize.patch b/repo/apps/chromium/default-pthread-stacksize.patch
new file mode 100644
index 0000000..74ebc76
--- /dev/null
+++ b/repo/apps/chromium/default-pthread-stacksize.patch
@@ -0,0 +1,45 @@
+--- ./base/threading/platform_thread_linux.cc
++++ ./base/threading/platform_thread_linux.cc
+@@ -186,7 +186,8 @@
+
+ size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
+ #if !defined(THREAD_SANITIZER)
+- return 0;
++ // use 2mb to avoid running out of space. This is what android uses
++ return 2 * (1 << 20);
+ #else
+ // ThreadSanitizer bloats the stack heavily. Evidence has been that the
+ // default stack size isn't enough for some browser tests.
+--- ./base/threading/platform_thread_unittest.cc.orig
++++ ./base/threading/platform_thread_unittest.cc
+@@ -420,7 +420,7 @@
+ ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
+ !defined(THREAD_SANITIZER)) || \
+ (BUILDFLAG(IS_ANDROID) && !defined(ADDRESS_SANITIZER))
+- EXPECT_EQ(0u, stack_size);
++ EXPECT_EQ(2u << 20, stack_size);
+ #else
+ EXPECT_GT(stack_size, 0u);
+ EXPECT_LT(stack_size, 20u * (1 << 20));
+--- ./chrome/browser/shutdown_signal_handlers_posix.cc
++++ ./chrome/browser/shutdown_signal_handlers_posix.cc
+@@ -187,11 +187,19 @@
+ g_shutdown_pipe_read_fd = pipefd[0];
+ g_shutdown_pipe_write_fd = pipefd[1];
+ #if !defined(ADDRESS_SANITIZER)
++# if defined(__GLIBC__)
+ const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2;
++# else
++ const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2 * 8; // match up musls 2k PTHREAD_STACK_MIN with glibcs 16k
++# endif
+ #else
++# if defined(__GLIBC__)
+ // ASan instrumentation bloats the stack frames, so we need to increase the
+ // stack size to avoid hitting the guard page.
+ const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4;
++# else
++ const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4 * 8; // match up musls 2k PTHREAD_STACK_MIN with glibcs 16k
++# endif
+ #endif
+ ShutdownDetector* detector = new ShutdownDetector(
+ g_shutdown_pipe_read_fd, std::move(shutdown_callback), task_runner);
diff --git a/repo/apps/chromium/elf-arm.patch b/repo/apps/chromium/elf-arm.patch
new file mode 100644
index 0000000..3799dc9
--- /dev/null
+++ b/repo/apps/chromium/elf-arm.patch
@@ -0,0 +1,11 @@
+--- ./v8/src/base/cpu.cc.orig
++++ ./v8/src/base/cpu.cc
+@@ -16,7 +16,7 @@
+ #if V8_OS_QNX
+ #include <sys/syspage.h> // cpuinfo
+ #endif
+-#if V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64)
++#if V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 || V8_HOST_ARCH_ARM)
+ #include <elf.h>
+ #endif
+ #if V8_OS_AIX
diff --git a/repo/apps/chromium/enable-GlobalMediaControlsCastStartStop.patch b/repo/apps/chromium/enable-GlobalMediaControlsCastStartStop.patch
new file mode 100644
index 0000000..e0d4544
--- /dev/null
+++ b/repo/apps/chromium/enable-GlobalMediaControlsCastStartStop.patch
@@ -0,0 +1,32 @@
+From b58f0f2725a8c1a8a131f9984b5fd53b54119dba Mon Sep 17 00:00:00 2001
+From: Muyao Xu <muyaoxu@google.com>
+Date: Thu, 20 Jan 2022 23:46:21 +0000
+Subject: [PATCH] [Zenith] Enable GlobalMediaControlsCastStartStop flag by
+ default
+
+The feature is rolled out to 100% stable through finch for M96+.
+This CL enables it by default and fixes some unit tests failures.
+
+Bug: 1287242, 1287305
+Change-Id: I7e5c9625b77379fef253c41ef292a0dd6fc366fb
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3388416
+Reviewed-by: Takumi Fujimoto <takumif@chromium.org>
+Commit-Queue: Muyao Xu <muyaoxu@google.com>
+Cr-Commit-Position: refs/heads/main@{#961658}
+---
+ chrome/browser/media/router/media_router_feature.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/chrome/browser/media/router/media_router_feature.cc b/chrome/browser/media/router/media_router_feature.cc
+index f28f9b0b802..a8d544f7d6d 100644
+--- a/chrome/browser/media/router/media_router_feature.cc
++++ b/chrome/browser/media/router/media_router_feature.cc
+@@ -33,7 +33,7 @@ const base::Feature kMediaRouter{"MediaRouter",
+ const base::Feature kCastAllowAllIPsFeature{"CastAllowAllIPs",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+ const base::Feature kGlobalMediaControlsCastStartStop{
+- "GlobalMediaControlsCastStartStop", base::FEATURE_DISABLED_BY_DEFAULT};
++ "GlobalMediaControlsCastStartStop", base::FEATURE_ENABLED_BY_DEFAULT};
+ const base::Feature kAllowAllSitesToInitiateMirroring{
+ "AllowAllSitesToInitiateMirroring", base::FEATURE_DISABLED_BY_DEFAULT};
+ const base::Feature kDialMediaRouteProvider{"DialMediaRouteProvider",
diff --git a/repo/apps/chromium/fix-narrowing-cast.patch b/repo/apps/chromium/fix-narrowing-cast.patch
new file mode 100644
index 0000000..afd42a1
--- /dev/null
+++ b/repo/apps/chromium/fix-narrowing-cast.patch
@@ -0,0 +1,53 @@
+--- a/base/files/file_util_linux.cc
++++ b/base/files/file_util_linux.cc
+@@ -23,14 +23,14 @@
+
+ // Not all possible |statfs_buf.f_type| values are in linux/magic.h.
+ // Missing values are copied from the statfs man page.
+- switch (statfs_buf.f_type) {
++ switch (static_cast<uintmax_t>(statfs_buf.f_type)) {
+ case 0:
+ *type = FILE_SYSTEM_0;
+ break;
+ case EXT2_SUPER_MAGIC: // Also ext3 and ext4
+ case MSDOS_SUPER_MAGIC:
+ case REISERFS_SUPER_MAGIC:
+- case static_cast<int>(BTRFS_SUPER_MAGIC):
++ case BTRFS_SUPER_MAGIC:
+ case 0x5346544E: // NTFS
+ case 0x58465342: // XFS
+ case 0x3153464A: // JFS
+@@ -40,14 +40,14 @@
+ *type = FILE_SYSTEM_NFS;
+ break;
+ case SMB_SUPER_MAGIC:
+- case static_cast<int>(0xFF534D42): // CIFS
++ case 0xFF534D42: // CIFS
+ *type = FILE_SYSTEM_SMB;
+ break;
+ case CODA_SUPER_MAGIC:
+ *type = FILE_SYSTEM_CODA;
+ break;
+- case static_cast<int>(HUGETLBFS_MAGIC):
+- case static_cast<int>(RAMFS_MAGIC):
++ case HUGETLBFS_MAGIC:
++ case RAMFS_MAGIC:
+ case TMPFS_MAGIC:
+ *type = FILE_SYSTEM_MEMORY;
+ break;
+--- a/base/system/sys_info_posix.cc
++++ b/base/system/sys_info_posix.cc
+@@ -100,10 +100,10 @@
+ if (HANDLE_EINTR(statfs(path.value().c_str(), &stats)) != 0)
+ return false;
+
+- switch (stats.f_type) {
++ switch (static_cast<uintmax_t>(stats.f_type)) {
+ case TMPFS_MAGIC:
+- case static_cast<int>(HUGETLBFS_MAGIC):
+- case static_cast<int>(RAMFS_MAGIC):
++ case HUGETLBFS_MAGIC:
++ case RAMFS_MAGIC:
+ return true;
+ }
+ return false;
diff --git a/repo/apps/chromium/fix-unittests-sandbox.patch b/repo/apps/chromium/fix-unittests-sandbox.patch
new file mode 100644
index 0000000..e11face
--- /dev/null
+++ b/repo/apps/chromium/fix-unittests-sandbox.patch
@@ -0,0 +1,11 @@
+--- ./sandbox/linux/syscall_broker/broker_file_permission_unittest.cc.orig
++++ ./sandbox/linux/syscall_broker/broker_file_permission_unittest.cc
+@@ -134,7 +134,7 @@
+ #endif
+
+ const int kNumberOfBitsInOAccMode = 2;
+- static_assert(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1),
++ static_assert(O_ACCMODE == (((1 << kNumberOfBitsInOAccMode) - 1) | O_PATH),
+ "incorrect number of bits");
+ // check every possible flag and act accordingly.
+ // Skipping AccMode bits as they are present in every case.
diff --git a/repo/apps/chromium/gcc-arm.patch b/repo/apps/chromium/gcc-arm.patch
new file mode 100644
index 0000000..9eaa240
--- /dev/null
+++ b/repo/apps/chromium/gcc-arm.patch
@@ -0,0 +1,11 @@
+--- ./third_party/zlib/BUILD.gn.orig
++++ ./third_party/zlib/BUILD.gn
+@@ -21,7 +21,7 @@
+ !(is_win && !is_clang)) {
+ # TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
+ # Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
+- if (arm_use_neon) {
++ if (arm_use_neon && is_clang) {
+ use_arm_neon_optimizations = true
+ }
+ }
diff --git a/repo/apps/chromium/gdbinit.patch b/repo/apps/chromium/gdbinit.patch
new file mode 100644
index 0000000..39d3464
--- /dev/null
+++ b/repo/apps/chromium/gdbinit.patch
@@ -0,0 +1,21 @@
+--- ./tools/gdb/gdbinit.orig
++++ ./tools/gdb/gdbinit
+@@ -50,17 +50,7 @@
+
+ def set_src_dir(compile_dir):
+ global src_dir
+- git = subprocess.Popen(
+- ['git', '-C', compile_dir, 'rev-parse', '--show-toplevel'],
+- stdout=subprocess.PIPE,
+- stderr=subprocess.PIPE)
+- src_dir, _ = git.communicate()
+- if git.returncode:
+- return
+- if isinstance(src_dir, str):
+- src_dir = src_dir.rstrip()
+- else:
+- src_dir = src_dir.decode('utf-8').rstrip()
++ src_dir = os.path.abspath(os.getcwd())
+
+ load_libcxx_pretty_printers(src_dir)
+
diff --git a/repo/apps/chromium/google-api.keys b/repo/apps/chromium/google-api.keys
new file mode 100644
index 0000000..8cd0f0a
--- /dev/null
+++ b/repo/apps/chromium/google-api.keys
@@ -0,0 +1,10 @@
+IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj
+IyMjIyMKIyBQbGVhc2UgZG9udCB1c2UgdGhlc2Uga2V5cyBvdXRzaWRlIG9mIEFscGluZSBMaW51
+eCBwcm9qZWN0ICMKIyBZb3UgY2FuIGNyZWF0ZSB5b3VyIG93biBhdDogICAgICAgICAgICAgICAg
+ICAgICAgICAgICAgICAgICMKIyBodHRwOi8vd3d3LmNocm9taXVtLm9yZy9kZXZlbG9wZXJzL2hv
+dy10b3MvYXBpLWtleXMgICAgICAgICMKIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj
+IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMKX2dvb2dsZV9hcGlfa2V5PSJBSXphU3lDUkk0
+RUdwRHVfQUFISThFMnllbmpWaFdRZHA0RzhpZ2MiCl9nb29nbGVfZGVmYXVsdF9jbGllbnRfaWQ9
+IjQ5NzU1MDYyMjM2Ny11YnRrbWQzYjJwcDVndWxiYTVuNmhhNnNxNG4zNWVoai5hcHBzLmdvb2ds
+ZXVzZXJjb250ZW50LmNvbSIKX2dvb2dsZV9kZWZhdWx0X2NsaWVudF9zZWNyZXQ9Ik5hQ1g4dElJ
+QXBocmpzNTZuM1RwSHhfZSIKCg==
diff --git a/repo/apps/chromium/media-base.patch b/repo/apps/chromium/media-base.patch
new file mode 100644
index 0000000..99b881f
--- /dev/null
+++ b/repo/apps/chromium/media-base.patch
@@ -0,0 +1,10 @@
+--- ./media/base/subsample_entry.h
++++ ./media/base/subsample_entry.h
+@@ -9,6 +9,7 @@
+ #include <stdint.h>
+
+ #include <vector>
++#include <cstddef>
+
+ #include "media/base/media_export.h"
+
diff --git a/repo/apps/chromium/memory-tagging-arm64.patch b/repo/apps/chromium/memory-tagging-arm64.patch
new file mode 100644
index 0000000..6072698
--- /dev/null
+++ b/repo/apps/chromium/memory-tagging-arm64.patch
@@ -0,0 +1,18 @@
+--- ./base/allocator/partition_allocator/tagging.cc.orig
++++ ./base/allocator/partition_allocator/tagging.cc
+@@ -19,15 +19,6 @@
+ #define PR_GET_TAGGED_ADDR_CTRL 56
+ #define PR_TAGGED_ADDR_ENABLE (1UL << 0)
+
+-#if BUILDFLAG(IS_LINUX)
+-#include <linux/version.h>
+-
+-// Linux headers already provide these since v5.10.
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
+-#define HAS_PR_MTE_MACROS
+-#endif
+-#endif
+-
+ #ifndef HAS_PR_MTE_MACROS
+ #define PR_MTE_TCF_SHIFT 1
+ #define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
diff --git a/repo/apps/chromium/musl-crashpad.patch b/repo/apps/chromium/musl-crashpad.patch
new file mode 100644
index 0000000..387deea
--- /dev/null
+++ b/repo/apps/chromium/musl-crashpad.patch
@@ -0,0 +1,25 @@
+diff --git a/third_party/crashpad/crashpad/util/linux/ptracer.cc b/third_party/crashpad/crashpad/util/linux/ptracer.cc
+index c6c9229..a5336b6 100644
+--- ./third_party/crashpad/crashpad/util/linux/ptracer.cc
++++ ./third_party/crashpad/crashpad/util/linux/ptracer.cc
+@@ -26,6 +26,7 @@
+
+ #if defined(ARCH_CPU_X86_FAMILY)
+ #include <asm/ldt.h>
++#include <asm/ptrace-abi.h>
+ #endif
+
+ namespace crashpad {
+diff --git a/third_party/crashpad/crashpad/util/linux/thread_info.h b/third_party/crashpad/crashpad/util/linux/thread_info.h
+index 5b55c24..08cec52 100644
+--- ./third_party/crashpad/crashpad/util/linux/thread_info.h
++++ ./third_party/crashpad/crashpad/util/linux/thread_info.h
+@@ -273,7 +273,7 @@ union FloatContext {
+ "Size mismatch");
+ #elif defined(ARCH_CPU_ARMEL)
+ static_assert(sizeof(f32_t::fpregs) == sizeof(user_fpregs), "Size mismatch");
+-#if !defined(__GLIBC__)
++#if defined(OS_ANDROID)
+ static_assert(sizeof(f32_t::vfp) == sizeof(user_vfp), "Size mismatch");
+ #endif
+ #elif defined(ARCH_CPU_ARM64)
diff --git a/repo/apps/chromium/musl-fixes.patch b/repo/apps/chromium/musl-fixes.patch
new file mode 100644
index 0000000..da2c115
--- /dev/null
+++ b/repo/apps/chromium/musl-fixes.patch
@@ -0,0 +1,221 @@
+--- ./third_party/lss/linux_syscall_support.h.orig
++++ ./third_party/lss/linux_syscall_support.h
+@@ -1127,6 +1127,12 @@
+ #ifndef __NR_fallocate
+ #define __NR_fallocate 285
+ #endif
++
++#undef __NR_pread
++#define __NR_pread __NR_pread64
++#undef __NR_pwrite
++#define __NR_pwrite __NR_pwrite64
++
+ /* End of x86-64 definitions */
+ #elif defined(__mips__)
+ #if _MIPS_SIM == _MIPS_SIM_ABI32
+--- ./third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h.orig
++++ ./third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
+@@ -37,6 +37,10 @@
+ #include "common/memory.h"
+ #include "google_breakpad/common/minidump_format.h"
+
++#if !defined(__GLIBC__)
++ #define _libc_fpstate _fpstate
++#endif
++
+ namespace google_breakpad {
+
+ // Wraps platform-dependent implementations of accessors to ucontext_t structs.
+--- ./third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h.orig
++++ ./third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h
+@@ -36,6 +36,7 @@
+ #include <elf.h>
+ #include <link.h>
+ #include <stddef.h>
++#include <limits.h>
+
+ #include "common/memory_range.h"
+
+--- ./sandbox/linux/suid/process_util.h.orig
++++ ./sandbox/linux/suid/process_util.h
+@@ -11,6 +11,14 @@
+ #include <stdbool.h>
+ #include <sys/types.h>
+
++// Some additional functions
++# define TEMP_FAILURE_RETRY(expression) \
++ (__extension__ \
++ ({ long int __result; \
++ do __result = (long int) (expression); \
++ while (__result == -1L && errno == EINTR); \
++ __result; }))
++
+ // This adjusts /proc/process/oom_score_adj so the Linux OOM killer
+ // will prefer certain process types over others. The range for the
+ // adjustment is [-1000, 1000], with [0, 1000] being user accessible.
+--- ./sandbox/linux/seccomp-bpf/trap.cc.orig 2020-04-12 08:26:40.184159217 -0400
++++ ./sandbox/linux/seccomp-bpf/trap.cc 2020-04-12 08:46:16.737191222 -0400
+@@ -174,7 +174,7 @@
+ // If the version of glibc doesn't include this information in
+ // siginfo_t (older than 2.17), we need to explicitly copy it
+ // into an arch_sigsys structure.
+- memcpy(&sigsys, &info->_sifields, sizeof(sigsys));
++ memcpy(&sigsys, &info->__sifields, sizeof(sigsys));
+ #endif
+
+ #if defined(__mips__)
+diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
+--- ./chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc.orig
++++ ./chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
+@@ -59,7 +59,9 @@
+ // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+ // of lacros-chrome is complete.
+ #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
++#if defined(__GLIBC__)
+ #include <gnu/libc-version.h>
++#endif
+
+ #include "base/linux_util.h"
+ #include "base/strings/string_split.h"
+@@ -321,7 +323,7 @@
+ void RecordLinuxGlibcVersion() {
+ // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+ // of lacros-chrome is complete.
+-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
++#if defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ base::Version version(gnu_get_libc_version());
+
+ UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE;
+--- ./services/device/serial/serial_io_handler_posix.cc.orig 2019-07-03 10:57:32.568171835 -0400
++++ ./services/device/serial/serial_io_handler_posix.cc 2019-07-03 10:57:16.867983031 -0400
+@@ -6,6 +6,7 @@
+
+ #include <sys/ioctl.h>
+ #include <termios.h>
++#include <asm-generic/ioctls.h>
+
+ #include <algorithm>
+ #include <utility>
+diff --git a/third_party/ots/include/opentype-sanitiser.h b/third_party/ots/include/opentype-sanitiser.h
+--- ./third_party/ots/src/include/opentype-sanitiser.h
++++ ./third_party/ots/src/include/opentype-sanitiser.h
+@@ -20,6 +20,7 @@ typedef unsigned __int64 uint64_t;
+ #define htonl(x) _byteswap_ulong (x)
+ #define htons(x) _byteswap_ushort (x)
+ #else
++#include <sys/types.h>
+ #include <arpa/inet.h>
+ #include <stdint.h>
+ #endif
+--- ./base/logging.cc.orig
++++ ./base/logging.cc
+@@ -592,8 +592,7 @@
+
+ LogMessage::~LogMessage() {
+ size_t stack_start = stream_.tellp();
+-#if !defined(OFFICIAL_BUILD) && !BUILDFLAG(IS_NACL) && !defined(__UCLIBC__) && \
+- !BUILDFLAG(IS_AIX)
++#if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && defined(__GLIBC__)
+ if (severity_ == LOGGING_FATAL && !base::debug::BeingDebugged()) {
+ // Include a stack trace on a fatal, unless a debugger is attached.
+ base::debug::StackTrace stack_trace;
+--- ./third_party/blink/renderer/platform/wtf/stack_util.cc.orig
++++ ./third_party/blink/renderer/platform/wtf/stack_util.cc
+@@ -28,7 +28,7 @@
+ // FIXME: On Mac OSX and Linux, this method cannot estimate stack size
+ // correctly for the main thread.
+
+-#elif defined(__GLIBC__) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
++#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
+ BUILDFLAG(IS_FUCHSIA)
+ // pthread_getattr_np() can fail if the thread is not invoked by
+ // pthread_create() (e.g., the main thread of blink_unittests).
+@@ -96,7 +96,7 @@
+ }
+
+ void* GetStackStart() {
+-#if defined(__GLIBC__) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
+ BUILDFLAG(IS_FUCHSIA)
+ pthread_attr_t attr;
+ int error;
+--- ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Signals.inc.orig 2019-06-18 11:51:17.000000000 -0400
++++ ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Signals.inc 2019-07-03 12:32:50.938758186 -0400
+@@ -25,7 +25,7 @@
+ #include "llvm/Support/raw_ostream.h"
+ #include <algorithm>
+ #include <string>
+-#if HAVE_EXECINFO_H
++#if HAVE_EXECINFO_H && defined(__GLIBC__)
+ # include <execinfo.h> // For backtrace().
+ #endif
+ #if HAVE_SIGNAL_H
+@@ -52,6 +52,7 @@
+ #include <unwind.h>
+ #else
+ #undef HAVE__UNWIND_BACKTRACE
++#undef HAVE_BACKTRACE
+ #endif
+ #endif
+
+--- ./third_party/nasm/nasmlib/realpath.c.orig 2019-07-03 12:23:05.021949895 -0400
++++ ./third_party/nasm/nasmlib/realpath.c 2019-07-03 12:24:24.246862665 -0400
+@@ -49,7 +49,7 @@
+
+ #include "nasmlib.h"
+
+-#ifdef HAVE_CANONICALIZE_FILE_NAME
++#if defined(__GLIBC__)
+
+ /*
+ * GNU-specific, but avoids the realpath(..., NULL)
+--- ./third_party/perfetto/include/perfetto/ext/base/thread_utils.h
++++ ./third_party/perfetto/include/perfetto/ext/base/thread_utils.h
+@@ -29,7 +29,7 @@
+ #include <algorithm>
+ #endif
+
+-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
++#if 1
+ #include <sys/prctl.h>
+ #endif
+
+@@ -58,7 +58,7 @@ inline bool MaybeSetThreadName(const std::string& name) {
+
+ inline bool GetThreadName(std::string& out_result) {
+ char buf[16] = {};
+-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
++#if 1
+ if (prctl(PR_GET_NAME, buf) != 0)
+ return false;
+ #else
+--- ./net/dns/public/scoped_res_state.cc.orig
++++ ./net/dns/public/scoped_res_state.cc
+@@ -13,7 +13,7 @@
+ namespace net {
+
+ ScopedResState::ScopedResState() {
+-#if BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_FUCHSIA)
++#if BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_FUCHSIA) || defined(_GNU_SOURCE)
+ // Note: res_ninit in glibc always returns 0 and sets RES_INIT.
+ // res_init behaves the same way.
+ memset(&_res, 0, sizeof(_res));
+@@ -25,16 +25,8 @@
+ }
+
+ ScopedResState::~ScopedResState() {
+-#if !BUILDFLAG(IS_OPENBSD) && !BUILDFLAG(IS_FUCHSIA)
+-
+- // Prefer res_ndestroy where available.
+-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_FREEBSD)
+- res_ndestroy(&res_);
+-#else
+- res_nclose(&res_);
+-#endif // BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_FREEBSD)
+-
+-#endif // !BUILDFLAG(IS_OPENBSD) && !BUILDFLAG(IS_FUCHSIA)
++ // musl res_init() doesn't actually do anything
++ // no destruction is necessary as no memory has been allocated
+ }
+
+ bool ScopedResState::IsValid() const {
diff --git a/repo/apps/chromium/musl-hacks.patch b/repo/apps/chromium/musl-hacks.patch
new file mode 100644
index 0000000..93db25a
--- /dev/null
+++ b/repo/apps/chromium/musl-hacks.patch
@@ -0,0 +1,98 @@
+--- ./base/debug/stack_trace.cc
++++ ./base/debug/stack_trace.cc
+@@ -168,7 +168,7 @@
+
+ #if BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
+ uintptr_t GetStackEnd() {
+-#if BUILDFLAG(IS_ANDROID)
++#if BUILDFLAG(IS_ANDROID) || (defined(OS_LINUX) && !defined(__GLIBC__))
+ // Bionic reads proc/maps on every call to pthread_getattr_np() when called
+ // from the main thread. So we need to cache end of stack in that case to get
+ // acceptable performance.
+@@ -234,8 +234,10 @@
+ defined(MEMORY_SANITIZER)
+ // Sanitizer configurations (ASan, TSan, MSan) emit unsymbolized stacks.
+ return false;
+-#else
++#elif defined(__GLIBC__)
+ return true;
++#else
++ return false;
+ #endif
+ }
+
+@@ -251,7 +253,9 @@
+ }
+
+ void StackTrace::OutputToStream(std::ostream* os) const {
++#if defined(__GLIBC__) && !defined(_AIX)
+ OutputToStreamWithPrefix(os, nullptr);
++#endif
+ }
+
+ std::string StackTrace::ToString() const {
+@@ -259,7 +263,7 @@
+ }
+ std::string StackTrace::ToStringWithPrefix(const char* prefix_string) const {
+ std::stringstream stream;
+-#if !defined(__UCLIBC__) && !defined(_AIX)
++#if defined(__GLIBC__) && !defined(_AIX)
+ OutputToStreamWithPrefix(&stream, prefix_string);
+ #endif
+ return stream.str();
+--- ./net/socket/udp_socket_posix.cc
++++ ./net/socket/udp_socket_posix.cc
+@@ -1191,7 +1191,7 @@
+ msg_iov->push_back({const_cast<char*>(buffer->data()), buffer->length()});
+ msgvec->reserve(buffers.size());
+ for (size_t j = 0; j < buffers.size(); j++)
+- msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0});
++ msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, 0, 0, 0}, 0});
+ int result = HANDLE_EINTR(Sendmmsg(fd, &msgvec[0], buffers.size(), 0));
+ SendResult send_result(0, 0, std::move(buffers));
+ if (result < 0) {
+--- ./base/debug/elf_reader.cc.orig
++++ ./base/debug/elf_reader.cc
+@@ -149,7 +149,12 @@
+ strtab_addr = static_cast<size_t>(dynamic_iter->d_un.d_ptr) +
+ reinterpret_cast<const char*>(relocation_offset);
+ #else
+- strtab_addr = reinterpret_cast<const char*>(dynamic_iter->d_un.d_ptr);
++ if (dynamic_iter->d_un.d_ptr < relocation_offset) {
++ strtab_addr = static_cast<size_t>(dynamic_iter->d_un.d_ptr) +
++ reinterpret_cast<const char*>(relocation_offset);
++ } else {
++ strtab_addr = reinterpret_cast<const char*>(dynamic_iter->d_un.d_ptr);
++ }
+ #endif
+ } else if (dynamic_iter->d_tag == DT_SONAME) {
+ soname_strtab_offset = dynamic_iter->d_un.d_val;
+--- ./mojo/public/c/system/thunks.cc.orig
++++ ./mojo/public/c/system/thunks.cc
+@@ -100,7 +100,8 @@
+ base::ScopedAllowBlocking allow_blocking;
+ base::NativeLibraryOptions library_options;
+ #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) && \
+- !defined(MEMORY_SANITIZER) && !defined(LEAK_SANITIZER)
++ !defined(MEMORY_SANITIZER) && !defined(LEAK_SANITIZER) && \
++ defined(RTLD_DEEPBIND)
+ // Sanitizer builds cannnot support RTLD_DEEPBIND, but they also disable
+ // allocator shims, so it's unnecessary there.
+ library_options.prefer_own_symbols = true;
+--- ./base/native_library_unittest.cc.orig
++++ ./base/native_library_unittest.cc
+@@ -121,6 +121,7 @@
+ #if !defined(OS_ANDROID) && !defined(THREAD_SANITIZER) && \
+ !defined(MEMORY_SANITIZER)
+
++#if defined(RTLD_DEEPBIND)
+ // Verifies that the |prefer_own_symbols| option satisfies its guarantee that
+ // a loaded library will always prefer local symbol resolution before
+ // considering global symbols.
+@@ -156,6 +157,7 @@
+ EXPECT_EQ(2, NativeLibraryTestIncrement());
+ EXPECT_EQ(3, NativeLibraryTestIncrement());
+ }
++#endif // defined(RTLD_DEEPBIND)
+
+ #endif // !defined(OS_ANDROID)
diff --git a/repo/apps/chromium/musl-sandbox.patch b/repo/apps/chromium/musl-sandbox.patch
new file mode 100644
index 0000000..4fe0098
--- /dev/null
+++ b/repo/apps/chromium/musl-sandbox.patch
@@ -0,0 +1,176 @@
+diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+index ff5a1c0..da56b9b 100644
+--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
++++ ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+@@ -139,21 +139,11 @@ namespace sandbox {
+ // present (as in newer versions of posix_spawn).
+ ResultExpr RestrictCloneToThreadsAndEPERMFork() {
+ const Arg<unsigned long> flags(0);
+-
+- // TODO(mdempsky): Extend DSL to support (flags & ~mask1) == mask2.
+- const uint64_t kAndroidCloneMask = CLONE_VM | CLONE_FS | CLONE_FILES |
+- CLONE_SIGHAND | CLONE_THREAD |
+- CLONE_SYSVSEM;
+- const uint64_t kObsoleteAndroidCloneMask = kAndroidCloneMask | CLONE_DETACHED;
+-
+- const uint64_t kGlibcPthreadFlags =
+- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD |
+- CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
+- const BoolExpr glibc_test = flags == kGlibcPthreadFlags;
+-
+- const BoolExpr android_test =
+- AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask,
+- flags == kGlibcPthreadFlags);
++ const int required = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
++ CLONE_THREAD | CLONE_SYSVSEM;
++ const int safe = CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
++ CLONE_DETACHED;
++ const BoolExpr thread_clone_ok = (flags&~safe)==required;
+
+ // The following two flags are the two important flags in any vfork-emulating
+ // clone call. EPERM any clone call that contains both of them.
+@@ -163,7 +153,7 @@ ResultExpr RestrictCloneToThreadsAndEPERMFork() {
+ AnyOf((flags & (CLONE_VM | CLONE_THREAD)) == 0,
+ (flags & kImportantCloneVforkFlags) == kImportantCloneVforkFlags);
+
+- return If(IsAndroid() ? android_test : glibc_test, Allow())
++ return If(thread_clone_ok, Allow())
+ .ElseIf(is_fork_or_clone_vfork, Error(EPERM))
+ .Else(CrashSIGSYSClone());
+ }
+diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+index d9d1882..0567557 100644
+--- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
++++ ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+@@ -392,6 +392,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
+ #if defined(__i386__)
+ case __NR_waitpid:
+ #endif
++ case __NR_set_tid_address:
+ return true;
+ case __NR_clone: // Should be parameter-restricted.
+ case __NR_setns: // Privileged.
+@@ -404,7 +405,6 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
+ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+ case __NR_set_thread_area:
+ #endif
+- case __NR_set_tid_address:
+ case __NR_unshare:
+ #if !defined(__mips__) && !defined(__aarch64__)
+ case __NR_vfork:
+@@ -514,6 +514,8 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
+ case __NR_mlock:
+ case __NR_munlock:
+ case __NR_munmap:
++ case __NR_mremap:
++ case __NR_membarrier:
+ return true;
+ case __NR_madvise:
+ case __NR_mincore:
+@@ -531,7 +533,6 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
+ case __NR_modify_ldt:
+ #endif
+ case __NR_mprotect:
+- case __NR_mremap:
+ case __NR_msync:
+ case __NR_munlockall:
+ case __NR_readahead:
+diff --git a/sandbox/linux/system_headers/arm64_linux_syscalls.h ./sandbox/linux/system_headers/arm64_linux_syscalls.h
+index 59d0eab..7ae7002 100644
+--- a/sandbox/linux/system_headers/arm64_linux_syscalls.h
++++ ./sandbox/linux/system_headers/arm64_linux_syscalls.h
+@@ -1063,4 +1063,8 @@
+ #define __NR_memfd_create 279
+ #endif
+
++#if !defined(__NR_membarrier)
++#define __NR_membarrier 283
++#endif
++
+ #endif // SANDBOX_LINUX_SYSTEM_HEADERS_ARM64_LINUX_SYSCALLS_H_
+diff --git a/sandbox/linux/system_headers/arm_linux_syscalls.h ./sandbox/linux/system_headers/arm_linux_syscalls.h
+index 1addd53..7843b5e 100644
+--- a/sandbox/linux/system_headers/arm_linux_syscalls.h
++++ ./sandbox/linux/system_headers/arm_linux_syscalls.h
+@@ -1385,6 +1385,10 @@
+ #define __NR_memfd_create (__NR_SYSCALL_BASE+385)
+ #endif
+
++#if !defined(__NR_membarrier)
++#define __NR_membarrier (__NR_SYSCALL_BASE+389)
++#endif
++
+ // ARM private syscalls.
+ #if !defined(__ARM_NR_BASE)
+ #define __ARM_NR_BASE (__NR_SYSCALL_BASE + 0xF0000)
+diff --git a/sandbox/linux/system_headers/linux_syscalls.h ./sandbox/linux/system_headers/linux_syscalls.h
+index 2b78a0c..b6fedb5 100644
+--- a/sandbox/linux/system_headers/linux_syscalls.h
++++ ./sandbox/linux/system_headers/linux_syscalls.h
+@@ -10,6 +10,7 @@
+ #define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
+
+ #include "build/build_config.h"
++#include <sys/syscall.h>
+
+ #if defined(__x86_64__)
+ #include "sandbox/linux/system_headers/x86_64_linux_syscalls.h"
+diff --git a/sandbox/linux/system_headers/mips64_linux_syscalls.h ./sandbox/linux/system_headers/mips64_linux_syscalls.h
+index ec75815..5515270 100644
+--- a/sandbox/linux/system_headers/mips64_linux_syscalls.h
++++ ./sandbox/linux/system_headers/mips64_linux_syscalls.h
+@@ -1271,4 +1271,8 @@
+ #define __NR_memfd_create (__NR_Linux + 314)
+ #endif
+
++#if !defined(__NR_membarrier)
++#define __NR_membarrier (__NR_Linux 318)
++#endif
++
+ #endif // SANDBOX_LINUX_SYSTEM_HEADERS_MIPS64_LINUX_SYSCALLS_H_
+diff --git a/sandbox/linux/system_headers/mips_linux_syscalls.h ./sandbox/linux/system_headers/mips_linux_syscalls.h
+index ddbf97f..ad3d64b 100644
+--- a/sandbox/linux/system_headers/mips_linux_syscalls.h
++++ ./sandbox/linux/system_headers/mips_linux_syscalls.h
+@@ -1433,4 +1433,8 @@
+ #define __NR_memfd_create (__NR_Linux + 354)
+ #endif
+
++#if !defined(__NR_membarrier)
++#define __NR_membarrier (__NR_Linux 358)
++#endif
++
+ #endif // SANDBOX_LINUX_SYSTEM_HEADERS_MIPS_LINUX_SYSCALLS_H_
+diff --git a/sandbox/linux/system_headers/x86_64_linux_syscalls.h ./sandbox/linux/system_headers/x86_64_linux_syscalls.h
+index b0ae0a2..8b12029 100644
+--- a/sandbox/linux/system_headers/x86_64_linux_syscalls.h
++++ ./sandbox/linux/system_headers/x86_64_linux_syscalls.h
+@@ -1350,5 +1350,9 @@
+ #define __NR_rseq 334
+ #endif
+
++#if !defined(__NR_membarrier)
++#define __NR_membarrier 324
++#endif
++
+ #endif // SANDBOX_LINUX_SYSTEM_HEADERS_X86_64_LINUX_SYSCALLS_H_
+
+diff --git a/services/service_manager/sandbox/linux/bpf_renderer_policy_linux.cc ./services/service_manager/sandbox/linux/bpf_renderer_policy_linux.cc
+index a85c0ea..715aa1e 100644
+--- a/sandbox/policy/linux/bpf_renderer_policy_linux.cc
++++ ./sandbox/policy/linux/bpf_renderer_policy_linux.cc
+@@ -93,11 +93,11 @@
+ case __NR_sysinfo:
+ case __NR_times:
+ case __NR_uname:
+- return Allow();
+- case __NR_sched_getaffinity:
+ case __NR_sched_getparam:
+ case __NR_sched_getscheduler:
+ case __NR_sched_setscheduler:
++ return Allow();
++ case __NR_sched_getaffinity:
+ return RestrictSchedTarget(GetPolicyPid(), sysno);
+ case __NR_prlimit64:
+ // See crbug.com/662450 and setrlimit comment above.
+
diff --git a/repo/apps/chromium/musl-stat.patch b/repo/apps/chromium/musl-stat.patch
new file mode 100644
index 0000000..5a6036a
--- /dev/null
+++ b/repo/apps/chromium/musl-stat.patch
@@ -0,0 +1,12 @@
+--- a/base/files/file.h.orig
++++ b/base/files/file.h
+@@ -19,7 +19,8 @@
+ #include "build/build_config.h"
+
+ #if BUILDFLAG(IS_BSD) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_NACL) || \
+- BUILDFLAG(IS_FUCHSIA) || (BUILDFLAG(IS_ANDROID) && __ANDROID_API__ < 21)
++ BUILDFLAG(IS_FUCHSIA) || (BUILDFLAG(IS_ANDROID) && __ANDROID_API__ < 21) || \
++ (defined(OS_LINUX) && !defined(__GLIBC__))
+ struct stat;
+ namespace base {
+ typedef struct stat stat_wrapper_t;
diff --git a/repo/apps/chromium/musl-tid-caching.patch b/repo/apps/chromium/musl-tid-caching.patch
new file mode 100644
index 0000000..bb83038
--- /dev/null
+++ b/repo/apps/chromium/musl-tid-caching.patch
@@ -0,0 +1,81 @@
+--- ./sandbox/linux/services/namespace_sandbox.cc.orig
++++ ./sandbox/linux/services/namespace_sandbox.cc
+@@ -209,6 +209,70 @@
+ return base::LaunchProcess(argv, launch_options_copy);
+ }
+
++#if defined(__aarch64__)
++#define TLS_ABOVE_TP
++#endif
++
++struct musl_pthread
++{
++ /* Part 1 -- these fields may be external or
++ * internal (accessed via asm) ABI. Do not change. */
++ struct pthread *self;
++#ifndef TLS_ABOVE_TP
++ uintptr_t *dtv;
++#endif
++ struct pthread *prev, *next; /* non-ABI */
++ uintptr_t sysinfo;
++#ifndef TLS_ABOVE_TP
++#ifdef CANARY_PAD
++ uintptr_t canary_pad;
++#endif
++ uintptr_t canary;
++#endif
++
++/* Part 2 -- implementation details, non-ABI. */
++ int tid;
++ int errno_val;
++ volatile int detach_state;
++ volatile int cancel;
++ volatile unsigned char canceldisable, cancelasync;
++ unsigned char tsd_used:1;
++ unsigned char dlerror_flag:1;
++ unsigned char *map_base;
++ size_t map_size;
++ void *stack;
++ size_t stack_size;
++ size_t guard_size;
++ void *result;
++ struct __ptcb *cancelbuf;
++ void **tsd;
++ struct {
++ volatile void *volatile head;
++ long off;
++ volatile void *volatile pending;
++ } robust_list;
++ int h_errno_val;
++ volatile int timer_id;
++ locale_t locale;
++ volatile int killlock[1];
++ char *dlerror_buf;
++ void *stdio_locks;
++
++ /* Part 3 -- the positions of these fields relative to
++ * the end of the structure is external and internal ABI. */
++#ifdef TLS_ABOVE_TP
++ uintptr_t canary;
++ uintptr_t *dtv;
++#endif
++};
++
++void MaybeUpdateMuslTidCache()
++{
++ pid_t real_tid = sys_gettid();
++ pid_t* cached_tid_location = &reinterpret_cast<struct musl_pthread*>(pthread_self())->tid;
++ *cached_tid_location = real_tid;
++}
++
+ // static
+ pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
+ const pid_t pid =
+@@ -226,6 +290,7 @@
+ #if defined(LIBC_GLIBC)
+ MaybeUpdateGlibcTidCache();
+ #endif
++ MaybeUpdateMuslTidCache();
+ return 0;
+ }
+
diff --git a/repo/apps/chromium/musl-v8-monotonic-pthread-cont_timedwait.patch b/repo/apps/chromium/musl-v8-monotonic-pthread-cont_timedwait.patch
new file mode 100644
index 0000000..768027d
--- /dev/null
+++ b/repo/apps/chromium/musl-v8-monotonic-pthread-cont_timedwait.patch
@@ -0,0 +1,22 @@
+Use monotonic clock for pthread_cond_timedwait with musl too.
+
+--- ./v8/src/base/platform/condition-variable.cc
++++ ./v8/src/base/platform/condition-variable.cc
+@@ -16,7 +16,7 @@
+
+ ConditionVariable::ConditionVariable() {
+ #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
+- (V8_OS_LINUX && V8_LIBC_GLIBC))
++ V8_OS_LINUX)
+ // On Free/Net/OpenBSD and Linux with glibc we can change the time
+ // source for pthread_cond_timedwait() to use the monotonic clock.
+ pthread_condattr_t attr;
+@@ -92,7 +92,7 @@
+ &native_handle_, &mutex->native_handle(), &ts);
+ #else
+ #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
+- (V8_OS_LINUX && V8_LIBC_GLIBC))
++ V8_OS_LINUX)
+ // On Free/Net/OpenBSD and Linux with glibc we can change the time
+ // source for pthread_cond_timedwait() to use the monotonic clock.
+ result = clock_gettime(CLOCK_MONOTONIC, &ts);
diff --git a/repo/apps/chromium/nasm.patch b/repo/apps/chromium/nasm.patch
new file mode 100644
index 0000000..ff22a6f
--- /dev/null
+++ b/repo/apps/chromium/nasm.patch
@@ -0,0 +1,11 @@
+--- ./third_party/nasm/config/config-linux.h
++++ ./third_party/nasm/config/config-linux.h
+@@ -117,7 +117,7 @@
+ #define HAVE_ACCESS 1
+
+ /* Define to 1 if you have the `canonicalize_file_name' function. */
+-#define HAVE_CANONICALIZE_FILE_NAME 1
++// #define HAVE_CANONICALIZE_FILE_NAME 1
+
+ /* Define to 1 if you have the `cpu_to_le16' intrinsic function. */
+ /* #undef HAVE_CPU_TO_LE16 */
diff --git a/repo/apps/chromium/no-execinfo.patch b/repo/apps/chromium/no-execinfo.patch
new file mode 100644
index 0000000..8cb2f79
--- /dev/null
+++ b/repo/apps/chromium/no-execinfo.patch
@@ -0,0 +1,75 @@
+--- ./base/debug/stack_trace_posix.cc
++++ ./base/debug/stack_trace_posix.cc
+@@ -27,7 +27,7 @@
+ #if !defined(USE_SYMBOLIZE)
+ #include <cxxabi.h>
+ #endif
+-#if !defined(__UCLIBC__) && !defined(_AIX)
++#if defined(__GLIBC__) && !defined(_AIX)
+ #include <execinfo.h>
+ #endif
+
+@@ -89,7 +89,7 @@
+ // Note: code in this function is NOT async-signal safe (std::string uses
+ // malloc internally).
+
+-#if !defined(__UCLIBC__) && !defined(_AIX)
++#if defined(__GLIBC__) && !defined(_AIX)
+ std::string::size_type search_from = 0;
+ while (search_from < text->size()) {
+ // Look for the start of a mangled symbol, from search_from.
+@@ -136,7 +136,7 @@
+ virtual ~BacktraceOutputHandler() = default;
+ };
+
+-#if !defined(__UCLIBC__) && !defined(_AIX)
++#if defined(__GLIBC__) && !defined(_AIX)
+ void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
+ // This should be more than enough to store a 64-bit number in hex:
+ // 16 hex digits + 1 for null-terminator.
+@@ -839,7 +839,7 @@
+ // If we do not have unwind tables, then try tracing using frame pointers.
+ return base::debug::TraceStackFramePointers(const_cast<const void**>(trace),
+ count, 0);
+-#elif !defined(__UCLIBC__) && !defined(_AIX)
++#elif defined(__GLIBC__) && !defined(_AIX)
+ // Though the backtrace API man page does not list any possible negative
+ // return values, we take no chance.
+ return base::saturated_cast<size_t>(backtrace(trace, count));
+@@ -852,13 +852,13 @@
+ // NOTE: This code MUST be async-signal safe (it's used by in-process
+ // stack dumping signal handler). NO malloc or stdio is allowed here.
+
+-#if !defined(__UCLIBC__) && !defined(_AIX)
++#if defined(__GLIBC__) && !defined(_AIX)
+ PrintBacktraceOutputHandler handler;
+ ProcessBacktrace(trace_, count_, prefix_string, &handler);
+ #endif
+ }
+
+-#if !defined(__UCLIBC__) && !defined(_AIX)
++#if defined(__GLIBC__) && !defined(_AIX)
+ void StackTrace::OutputToStreamWithPrefix(std::ostream* os,
+ const char* prefix_string) const {
+ StreamBacktraceOutputHandler handler(os);
+--- ./v8/src/codegen/external-reference-table.cc.orig
++++ ./v8/src/codegen/external-reference-table.cc
+@@ -11,7 +11,9 @@
+
+ #if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
+ #define SYMBOLIZE_FUNCTION
++#if defined(__GLIBC__)
+ #include <execinfo.h>
++#endif
+
+ #include <vector>
+
+@@ -96,7 +98,7 @@
+ }
+
+ const char* ExternalReferenceTable::ResolveSymbol(void* address) {
+-#ifdef SYMBOLIZE_FUNCTION
++#if defined(SYMBOLIZE_FUNCTION) && defined(__GLIBC__)
+ char** names = backtrace_symbols(&address, 1);
+ const char* name = names[0];
+ // The array of names is malloc'ed. However, each name string is static
diff --git a/repo/apps/chromium/no-getcontext.patch b/repo/apps/chromium/no-getcontext.patch
new file mode 100644
index 0000000..71c1e91
--- /dev/null
+++ b/repo/apps/chromium/no-getcontext.patch
@@ -0,0 +1,26 @@
+--- ./third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
++++ ./third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
+@@ -490,7 +490,9 @@
+ siginfo.si_code = SI_USER;
+ siginfo.si_pid = getpid();
+ ucontext_t context;
++#if defined(__GLIBC__)
+ getcontext(&context);
++#endif
+ return HandleSignal(sig, &siginfo, &context);
+ }
+
+@@ -675,9 +677,13 @@
+ sys_prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
+
+ CrashContext context;
++#if defined(__GLIBC__)
+ int getcontext_result = getcontext(&context.context);
+ if (getcontext_result)
+ return false;
++#else
++ return false;
++#endif
+
+ #if defined(__i386__)
+ // In CPUFillFromUContext in minidumpwriter.cc the stack pointer is retrieved
diff --git a/repo/apps/chromium/no-mallinfo.patch b/repo/apps/chromium/no-mallinfo.patch
new file mode 100644
index 0000000..23ce40e
--- /dev/null
+++ b/repo/apps/chromium/no-mallinfo.patch
@@ -0,0 +1,83 @@
+--- ./base/trace_event/malloc_dump_provider.cc.orig
++++ ./base/trace_event/malloc_dump_provider.cc
+@@ -212,7 +212,7 @@
+ &allocated_objects_count);
+ #elif defined(OS_FUCHSIA)
+ // TODO(fuchsia): Port, see https://crbug.com/706592.
+-#else
++#elif defined(__GLIBC__)
+ #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+ #if __GLIBC_PREREQ(2, 33)
+ #define MALLINFO2_FOUND_IN_LIBC
+--- ./base/process/process_metrics_posix.cc.orig
++++ ./base/process/process_metrics_posix.cc
+@@ -105,7 +105,7 @@
+
+ #endif // !BUILDFLAG(IS_FUCHSIA)
+
+-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
++#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+ namespace {
+
+ size_t GetMallocUsageMallinfo() {
+@@ -123,7 +123,7 @@
+ }
+
+ } // namespace
+-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
++#endif // (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) ||
+ // BUILDFLAG(IS_ANDROID)
+
+ size_t ProcessMetrics::GetMallocUsage() {
+@@ -131,9 +131,9 @@
+ malloc_statistics_t stats = {0};
+ malloc_zone_statistics(nullptr, &stats);
+ return stats.size_in_use;
+-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
++#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+ return GetMallocUsageMallinfo();
+-#elif BUILDFLAG(IS_FUCHSIA)
++#else
+ // TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
+ return 0;
+ #endif
+--- ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc.orig
++++ ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
+@@ -35,7 +35,7 @@
+
+ MemoryUsage GetMemoryUsage() {
+ MemoryUsage result;
+-#ifdef __linux__
++#if defined(__linux__) && defined(__GLIBC__)
+ rusage res;
+ if (getrusage(RUSAGE_SELF, &res) == 0) {
+ result.max_rss_kb = res.ru_maxrss;
+--- ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc
++++ ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc.orig
+@@ -86,11 +86,11 @@
+ }
+
+ size_t Process::GetMallocUsage() {
+-#if defined(HAVE_MALLINFO2)
++#if defined(HAVE_MALLINFO2) && defined(__GLIBC__)
+ struct mallinfo2 mi;
+ mi = ::mallinfo2();
+ return mi.uordblks;
+-#elif defined(HAVE_MALLINFO)
++#elif defined(HAVE_MALLINFO) && defined(__GLIBC__)
+ struct mallinfo mi;
+ mi = ::mallinfo();
+ return mi.uordblks;
+
+--- ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h.orig 2019-09-30 13:03:42.556880537 -0400
++++ ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h 2019-09-30 13:07:27.989821227 -0400
+@@ -122,7 +122,9 @@
+ /* #undef HAVE_MALLCTL */
+
+ /* Define to 1 if you have the `mallinfo' function. */
++#if defined(__GLIBC__)
+ #define HAVE_MALLINFO 1
++#endif
+
+ /* Define to 1 if you have the <malloc.h> header file. */
+ #define HAVE_MALLOC_H 1
diff --git a/repo/apps/chromium/quiche-arena-size.patch b/repo/apps/chromium/quiche-arena-size.patch
new file mode 100644
index 0000000..50abcae
--- /dev/null
+++ b/repo/apps/chromium/quiche-arena-size.patch
@@ -0,0 +1,11 @@
+--- ./net/third_party/quiche/src/quic/core/quic_one_block_arena.h
++++ ./net/third_party/quiche/src/quic/core/quic_one_block_arena.h
+@@ -69,7 +69,7 @@
+
+ // QuicConnections currently use around 1KB of polymorphic types which would
+ // ordinarily be on the heap. Instead, store them inline in an arena.
+-using QuicConnectionArena = QuicOneBlockArena<1152>;
++using QuicConnectionArena = QuicOneBlockArena<1504>;
+
+ } // namespace quic
+
diff --git a/repo/apps/chromium/remove-strip_binary.patch b/repo/apps/chromium/remove-strip_binary.patch
new file mode 100644
index 0000000..8b13c6a
--- /dev/null
+++ b/repo/apps/chromium/remove-strip_binary.patch
@@ -0,0 +1,32 @@
+--- a/chrome/test/chromedriver/BUILD.gn.orig
++++ b/chrome/test/chromedriver/BUILD.gn
+@@ -308,11 +308,7 @@
+ }
+ }
+
+-if (is_linux) {
+- chromedriver_output = "chromedriver.unstripped"
+-} else {
+- chromedriver_output = "chromedriver"
+-}
++chromedriver_output = "chromedriver"
+
+ executable("$chromedriver_output") {
+ testonly = true
+@@ -336,16 +332,6 @@
+ }
+ }
+
+-if (is_linux) {
+- strip_binary("chromedriver") {
+- testonly = true
+- binary_input = "$root_out_dir/$chromedriver_output"
+- symbol_output = "$root_out_dir/chromedriver.debug"
+- stripped_binary_output = "$root_out_dir/chromedriver"
+- deps = [ ":$chromedriver_output" ]
+- }
+-}
+-
+ python_library("chromedriver_py_tests") {
+ testonly = true
+ deps = [
diff --git a/repo/apps/chromium/resolver.patch b/repo/apps/chromium/resolver.patch
new file mode 100644
index 0000000..8dca36a
--- /dev/null
+++ b/repo/apps/chromium/resolver.patch
@@ -0,0 +1,36 @@
+--- ./net/dns/host_resolver_manager.cc.orig
++++ ./net/dns/host_resolver_manager.cc
+@@ -3014,8 +3014,7 @@
+ NetworkChangeNotifier::AddConnectionTypeObserver(this);
+ if (system_dns_config_notifier_)
+ system_dns_config_notifier_->AddObserver(this);
+-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_OPENBSD) && \
+- !BUILDFLAG(IS_ANDROID)
++#if defined(__GLIBC__)
+ EnsureDnsReloaderInit();
+ #endif
+
+--- ./net/dns/dns_reloader.cc.orig
++++ ./net/dns/dns_reloader.cc
+@@ -6,8 +6,7 @@
+
+ #include "build/build_config.h"
+
+-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_OPENBSD) && \
+- !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
++#if defined(__GLIBC__)
+
+ #include <resolv.h>
+
+--- ./net/dns/host_resolver_proc.cc.orig
++++ ./net/dns/host_resolver_proc.cc
+@@ -176,8 +176,7 @@
+ base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
+ base::BlockingType::WILL_BLOCK);
+
+-#if BUILDFLAG(IS_POSIX) && \
+- !(BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_ANDROID))
++#if defined(__GLIBC__)
+ DnsReloaderMaybeReload();
+ #endif
+ absl::optional<AddressInfo> ai;
diff --git a/repo/apps/chromium/revert-use-ffile-compilation-dir.patch b/repo/apps/chromium/revert-use-ffile-compilation-dir.patch
new file mode 100644
index 0000000..f0c110f
--- /dev/null
+++ b/repo/apps/chromium/revert-use-ffile-compilation-dir.patch
@@ -0,0 +1,48 @@
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index f442166..c325f72 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1248,19 +1248,12 @@ config("compiler_deterministic") {
+ # different build directory like "out/feature_a" and "out/feature_b" if
+ # we build same files with same compile flag.
+ # Other paths are already given in relative, no need to normalize them.
+- if (is_nacl) {
+- # TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here.
+- cflags += [
+- "-Xclang",
+- "-fdebug-compilation-dir",
+- "-Xclang",
+- ".",
+- ]
+- } else {
+- # -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
+- # and -fcoverage-compilation-dir=.
+- cflags += [ "-ffile-compilation-dir=." ]
+- }
++ cflags += [
++ "-Xclang",
++ "-fdebug-compilation-dir",
++ "-Xclang",
++ ".",
++ ]
+ if (!is_win) {
+ # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+ asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
+index 008a386..89e7fdf 100644
+--- a/build/config/compiler/compiler.gni
++++ b/build/config/compiler/compiler.gni
+@@ -238,8 +238,11 @@ declare_args() {
+ # deterministic builds to reduce compile times, so this is less relevant for
+ # official builders.
+ strip_absolute_paths_from_debug_symbols_default =
+- is_android || is_fuchsia || is_nacl || (is_win && use_lld) || is_linux ||
+- is_chromeos || (is_apple && !enable_dsyms)
++ # TODO(crbug.com/1010267): remove '!use_clang_coverage', coverage build has
++ # dependency to absolute path of source files.
++ !use_clang_coverage &&
++ (is_android || is_fuchsia || is_nacl || (is_win && use_lld) || is_linux ||
++ is_chromeos || (is_apple && !enable_dsyms))
+
+ # If the platform uses stripped absolute paths by default, then we don't expose
+ # it as a configuration option. If this is causing problems, please file a bug.
diff --git a/repo/apps/chromium/scoped-file.patch b/repo/apps/chromium/scoped-file.patch
new file mode 100644
index 0000000..34bf6eb
--- /dev/null
+++ b/repo/apps/chromium/scoped-file.patch
@@ -0,0 +1,31 @@
+--- ./base/files/scoped_file_linux.cc.orig
++++ ./base/files/scoped_file_linux.cc
+@@ -7,6 +7,7 @@
+ #include <algorithm>
+ #include <array>
+ #include <atomic>
++#include <dlfcn.h>
+
+ #include "base/compiler_specific.h"
+ #include "base/debug/stack_trace.h"
+@@ -80,9 +81,18 @@
+
+ extern "C" {
+
+-int __close(int);
+-
+ __attribute__((visibility("default"), noinline)) int close(int fd) {
++ static int (*__close)(int) = nullptr;
++
++ if (__close == nullptr) {
++ __close = (int (*)(int))dlsym(RTLD_NEXT, "close");
++
++ if (__close == nullptr) {
++ RAW_LOG(ERROR, "musl close not found\n");
++ IMMEDIATE_CRASH();
++ }
++ }
++
+ if (base::IsFDOwned(fd) && g_is_ownership_enforced)
+ CrashOnFdOwnershipViolation();
+ return __close(fd);
diff --git a/repo/apps/chromium/sql-make-VirtualCursor-standard-layout-type.patch b/repo/apps/chromium/sql-make-VirtualCursor-standard-layout-type.patch
new file mode 100644
index 0000000..3364d41
--- /dev/null
+++ b/repo/apps/chromium/sql-make-VirtualCursor-standard-layout-type.patch
@@ -0,0 +1,238 @@
+From 144479ad7b4287bee4067f95e4218f614798a865 Mon Sep 17 00:00:00 2001
+From: Stephan Hartmann <stha09@googlemail.com>
+Date: Sun, 16 Jan 2022 19:15:26 +0000
+Subject: [PATCH] sql: make VirtualCursor standard layout type
+
+sql::recover::VirtualCursor needs to be a standard layout type, but
+has members of type std::unique_ptr. However, std::unique_ptr is not
+guaranteed to be standard layout. Compiling with clang combined with
+gcc-11 libstdc++ fails because of this.
+
+Bug: 1189788
+Change-Id: Ia6dc388cc5ef1c0f2afc75f8ca45b9f12687ca9c
+---
+ sql/recover_module/btree.cc | 18 ++++++++++++------
+ sql/recover_module/btree.h | 21 +++++++++++++++------
+ sql/recover_module/cursor.cc | 24 ++++++++++++------------
+ sql/recover_module/cursor.h | 2 +-
+ sql/recover_module/pager.cc | 5 ++---
+ sql/recover_module/pager.h | 6 +++---
+ 6 files changed, 45 insertions(+), 31 deletions(-)
+
+diff --git a/sql/recover_module/btree.cc b/sql/recover_module/btree.cc
+index cc9420e5c05..f12d8fa32a2 100644
+--- a/sql/recover_module/btree.cc
++++ b/sql/recover_module/btree.cc
+@@ -136,16 +136,22 @@ static_assert(std::is_trivially_destructible<LeafPageDecoder>::value,
+ "Move the destructor to the .cc file if it's non-trival");
+ #endif // !DCHECK_IS_ON()
+
+-LeafPageDecoder::LeafPageDecoder(DatabasePageReader* db_reader) noexcept
+- : page_id_(db_reader->page_id()),
+- db_reader_(db_reader),
+- cell_count_(ComputeCellCount(db_reader)),
+- next_read_index_(0),
+- last_record_size_(0) {
++LeafPageDecoder::LeafPageDecoder() noexcept = default;
++
++void LeafPageDecoder::Initialize(DatabasePageReader* db_reader) {
++ page_id_ = db_reader->page_id();
++ db_reader_ = db_reader;
++ cell_count_ = ComputeCellCount(db_reader);
++ next_read_index_ = 0;
++ last_record_size_ = 0;
+ DCHECK(IsOnValidPage(db_reader));
+ DCHECK(DatabasePageReader::IsValidPageId(page_id_));
+ }
+
++void LeafPageDecoder::Reset() {
++ db_reader_ = nullptr;
++}
++
+ bool LeafPageDecoder::TryAdvance() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK(CanAdvance());
+diff --git a/sql/recover_module/btree.h b/sql/recover_module/btree.h
+index eaa087a5c52..df0e0c937c0 100644
+--- a/sql/recover_module/btree.h
++++ b/sql/recover_module/btree.h
+@@ -101,9 +101,7 @@ class LeafPageDecoder {
+ public:
+ // Creates a decoder for a DatabasePageReader's last read page.
+ //
+- // |db_reader| must have been used to read an inner page of a table B-tree.
+- // |db_reader| must outlive this instance.
+- explicit LeafPageDecoder(DatabasePageReader* db_reader) noexcept;
++ LeafPageDecoder() noexcept;
+ ~LeafPageDecoder() noexcept = default;
+
+ LeafPageDecoder(const LeafPageDecoder&) = delete;
+@@ -151,6 +149,17 @@ class LeafPageDecoder {
+ // read as long as CanAdvance() returns true.
+ bool TryAdvance();
+
++ // Initialize with DatabasePageReader
++ // |db_reader| must have been used to read an inner page of a table B-tree.
++ // |db_reader| must outlive this instance.
++ void Initialize(DatabasePageReader* db_reader);
++
++ // Reset internal DatabasePageReader
++ void Reset();
++
++ // True if DatabasePageReader is valid
++ bool IsValid() { return (db_reader_ != nullptr); }
++
+ // True if the given reader may point to an inner page in a table B-tree.
+ //
+ // The last ReadPage() call on |db_reader| must have succeeded.
+@@ -164,14 +173,14 @@ class LeafPageDecoder {
+ static int ComputeCellCount(DatabasePageReader* db_reader);
+
+ // The number of the B-tree page this reader is reading.
+- const int64_t page_id_;
++ int64_t page_id_;
+ // Used to read the tree page.
+ //
+ // Raw pointer usage is acceptable because this instance's owner is expected
+ // to ensure that the DatabasePageReader outlives this.
+- DatabasePageReader* const db_reader_;
++ DatabasePageReader* db_reader_;
+ // Caches the ComputeCellCount() value for this reader's page.
+- const int cell_count_ = ComputeCellCount(db_reader_);
++ int cell_count_;
+
+ // The reader's cursor state.
+ //
+diff --git a/sql/recover_module/cursor.cc b/sql/recover_module/cursor.cc
+index 4f827edf1b4..240de4999fe 100644
+--- a/sql/recover_module/cursor.cc
++++ b/sql/recover_module/cursor.cc
+@@ -28,7 +28,7 @@ VirtualCursor::~VirtualCursor() {
+ int VirtualCursor::First() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ inner_decoders_.clear();
+- leaf_decoder_ = nullptr;
++ leaf_decoder_.Reset();
+
+ AppendPageDecoder(table_->root_page_id());
+ return Next();
+@@ -38,18 +38,18 @@ int VirtualCursor::Next() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ record_reader_.Reset();
+
+- while (!inner_decoders_.empty() || leaf_decoder_.get()) {
+- if (leaf_decoder_.get()) {
+- if (!leaf_decoder_->CanAdvance()) {
++ while (!inner_decoders_.empty() || leaf_decoder_.IsValid()) {
++ if (leaf_decoder_.IsValid()) {
++ if (!leaf_decoder_.CanAdvance()) {
+ // The leaf has been exhausted. Remove it from the DFS stack.
+- leaf_decoder_ = nullptr;
++ leaf_decoder_.Reset();
+ continue;
+ }
+- if (!leaf_decoder_->TryAdvance())
++ if (!leaf_decoder_.TryAdvance())
+ continue;
+
+- if (!payload_reader_.Initialize(leaf_decoder_->last_record_size(),
+- leaf_decoder_->last_record_offset())) {
++ if (!payload_reader_.Initialize(leaf_decoder_.last_record_size(),
++ leaf_decoder_.last_record_offset())) {
+ continue;
+ }
+ if (!record_reader_.Initialize())
+@@ -101,13 +101,13 @@ int VirtualCursor::ReadColumn(int column_index,
+ int64_t VirtualCursor::RowId() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK(record_reader_.IsInitialized());
+- DCHECK(leaf_decoder_.get());
+- return leaf_decoder_->last_record_rowid();
++ DCHECK(leaf_decoder_.IsValid());
++ return leaf_decoder_.last_record_rowid();
+ }
+
+ void VirtualCursor::AppendPageDecoder(int page_id) {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+- DCHECK(leaf_decoder_.get() == nullptr)
++ DCHECK(!leaf_decoder_.IsValid())
+ << __func__
+ << " must only be called when the current path has no leaf decoder";
+
+@@ -115,7 +115,7 @@ void VirtualCursor::AppendPageDecoder(int page_id) {
+ return;
+
+ if (LeafPageDecoder::IsOnValidPage(&db_reader_)) {
+- leaf_decoder_ = std::make_unique<LeafPageDecoder>(&db_reader_);
++ leaf_decoder_.Initialize(&db_reader_);
+ return;
+ }
+
+diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
+index 845b7852648..cc4e85f83f9 100644
+--- a/sql/recover_module/cursor.h
++++ b/sql/recover_module/cursor.h
+@@ -130,7 +130,7 @@ class VirtualCursor {
+ std::vector<std::unique_ptr<InnerPageDecoder>> inner_decoders_;
+
+ // Decodes the leaf page containing records.
+- std::unique_ptr<LeafPageDecoder> leaf_decoder_;
++ LeafPageDecoder leaf_decoder_;
+
+ SEQUENCE_CHECKER(sequence_checker_);
+ };
+diff --git a/sql/recover_module/pager.cc b/sql/recover_module/pager.cc
+index 58e75de2704..69d98cef98d 100644
+--- a/sql/recover_module/pager.cc
++++ b/sql/recover_module/pager.cc
+@@ -23,8 +23,7 @@ static_assert(DatabasePageReader::kMaxPageId <= std::numeric_limits<int>::max(),
+ "ints are not appropriate for representing page IDs");
+
+ DatabasePageReader::DatabasePageReader(VirtualTable* table)
+- : page_data_(std::make_unique<uint8_t[]>(table->page_size())),
+- table_(table) {
++ : page_data_(table->page_size()), table_(table) {
+ DCHECK(table != nullptr);
+ DCHECK(IsValidPageSize(table->page_size()));
+ }
+@@ -58,7 +57,7 @@ int DatabasePageReader::ReadPage(int page_id) {
+ "The |read_offset| computation above may overflow");
+
+ int sqlite_status =
+- RawRead(sqlite_file, read_size, read_offset, page_data_.get());
++ RawRead(sqlite_file, read_size, read_offset, page_data_.data());
+
+ // |page_id_| needs to be set to kInvalidPageId if the read failed.
+ // Otherwise, future ReadPage() calls with the previous |page_id_| value
+diff --git a/sql/recover_module/pager.h b/sql/recover_module/pager.h
+index 07cac3cb989..d08f0932fab 100644
+--- a/sql/recover_module/pager.h
++++ b/sql/recover_module/pager.h
+@@ -6,8 +6,8 @@
+ #define SQL_RECOVER_MODULE_PAGER_H_
+
+ #include <cstdint>
+-#include <memory>
+ #include <ostream>
++#include <vector>
+
+ #include "base/check_op.h"
+ #include "base/memory/raw_ptr.h"
+@@ -72,7 +72,7 @@ class DatabasePageReader {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK_NE(page_id_, kInvalidPageId)
+ << "Successful ReadPage() required before accessing pager state";
+- return page_data_.get();
++ return page_data_.data();
+ }
+
+ // The number of bytes in the page read by the last ReadPage() call.
+@@ -139,7 +139,7 @@ class DatabasePageReader {
+ int page_id_ = kInvalidPageId;
+ // Stores the bytes of the last page successfully read by ReadPage().
+ // The content is undefined if the last call to ReadPage() did not succeed.
+- const std::unique_ptr<uint8_t[]> page_data_;
++ std::vector<uint8_t> page_data_;
+ // Raw pointer usage is acceptable because this instance's owner is expected
+ // to ensure that the VirtualTable outlives this.
+ const raw_ptr<VirtualTable> table_;
diff --git a/repo/apps/chromium/system-opus.patch b/repo/apps/chromium/system-opus.patch
new file mode 100644
index 0000000..dc85e80
--- /dev/null
+++ b/repo/apps/chromium/system-opus.patch
@@ -0,0 +1,52 @@
+Has been upstreamed in Chromium main branch, shouldn't be necessary
+when the commit gets pulled into a new release
+
+From 3bd46cb9a51773f103ef52b39d6407740eb0d60a Mon Sep 17 00:00:00 2001
+From: Eugene Zemtsov <eugene@chromium.org>
+Date: Thu, 24 Feb 2022 23:17:20 +0000
+Subject: [PATCH] webcodecs: Stop using AudioOpusEncoder as backed for mojo
+ audio encoder
+
+AudioOpusEncoder was only used here for testing. Let's not let it get
+comfortable. We'll use MF AAC encoder here when we have it. (Soon...)
+
+Bug: 1259883
+Change-Id: Ia1819395c8c8fd6d403d4b8558c12f9a1bf7e761
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3489449
+Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
+Auto-Submit: Eugene Zemtsov <eugene@chromium.org>
+Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
+Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
+Cr-Commit-Position: refs/heads/main@{#974895}
+---
+ media/mojo/services/gpu_mojo_media_client.cc | 10 +---------
+ 1 file changed, 1 insertion(+), 9 deletions(-)
+
+diff --git a/media/mojo/services/gpu_mojo_media_client.cc b/media/mojo/services/gpu_mojo_media_client.cc
+index 8f83a4d6cf662..40cdaff8d3a00 100644
+--- a/media/mojo/services/gpu_mojo_media_client.cc
++++ b/media/mojo/services/gpu_mojo_media_client.cc
+@@ -13,7 +13,6 @@
+ #include "build/chromeos_buildflags.h"
+ #include "gpu/ipc/service/gpu_channel.h"
+ #include "media/audio/audio_features.h"
+-#include "media/audio/audio_opus_encoder.h"
+ #include "media/base/audio_decoder.h"
+ #include "media/base/cdm_factory.h"
+ #include "media/base/media_switches.h"
+@@ -119,14 +118,7 @@ std::unique_ptr<AudioEncoder> GpuMojoMediaClient::CreateAudioEncoder(
+ scoped_refptr<base::SequencedTaskRunner> task_runner) {
+ if (!base::FeatureList::IsEnabled(features::kPlatformAudioEncoder))
+ return nullptr;
+- // TODO(crbug.com/1259883) Right now Opus encoder is all we have, later on
+- // we'll create a real platform encoder here.
+- auto opus_encoder = std::make_unique<AudioOpusEncoder>();
+- auto encoding_runner = base::ThreadPool::CreateSequencedTaskRunner(
+- {base::TaskPriority::USER_BLOCKING});
+- return std::make_unique<OffloadingAudioEncoder>(std::move(opus_encoder),
+- std::move(encoding_runner),
+- std::move(task_runner));
++ return nullptr;
+ }
+
+ VideoDecoderType GpuMojoMediaClient::GetDecoderImplementationType() {
diff --git a/repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch b/repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch
new file mode 100644
index 0000000..dae1add
--- /dev/null
+++ b/repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch
@@ -0,0 +1,12 @@
+diff --git a/build/linux/unbundle/ffmpeg.gn b/build/linux/unbundle/ffmpeg.gn
+index 16e20744706..6a079b32221 100644
+--- a/build/linux/unbundle/ffmpeg.gn
++++ b/build/linux/unbundle/ffmpeg.gn
+@@ -12,6 +12,7 @@ pkg_config("system_ffmpeg") {
+ "libavformat",
+ "libavutil",
+ ]
++ defines = [ "av_stream_get_first_dts(stream)=stream->first_dts" ]
+ }
+
+ buildflag_header("ffmpeg_features") {
diff --git a/repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch.1 b/repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch.1
new file mode 100644
index 0000000..dae1add
--- /dev/null
+++ b/repo/apps/chromium/unbundle-ffmpeg-av_stream_get_first_dts.patch.1
@@ -0,0 +1,12 @@
+diff --git a/build/linux/unbundle/ffmpeg.gn b/build/linux/unbundle/ffmpeg.gn
+index 16e20744706..6a079b32221 100644
+--- a/build/linux/unbundle/ffmpeg.gn
++++ b/build/linux/unbundle/ffmpeg.gn
+@@ -12,6 +12,7 @@ pkg_config("system_ffmpeg") {
+ "libavformat",
+ "libavutil",
+ ]
++ defines = [ "av_stream_get_first_dts(stream)=stream->first_dts" ]
+ }
+
+ buildflag_header("ffmpeg_features") {
diff --git a/repo/apps/chromium/use-deprecated-ffmpeg-api.patch b/repo/apps/chromium/use-deprecated-ffmpeg-api.patch
new file mode 100644
index 0000000..f0ec736
--- /dev/null
+++ b/repo/apps/chromium/use-deprecated-ffmpeg-api.patch
@@ -0,0 +1,36 @@
+diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
+index ac4713b07268..492a9a37d096 100644
+--- a/media/filters/ffmpeg_demuxer.cc
++++ b/media/filters/ffmpeg_demuxer.cc
+@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
+ scoped_refptr<DecoderBuffer> buffer;
+
+ if (type() == DemuxerStream::TEXT) {
+- size_t id_size = 0;
++ int id_size = 0;
+ uint8_t* id_data = av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+
+- size_t settings_size = 0;
++ int settings_size = 0;
+ uint8_t* settings_data = av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+
+@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
+ buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+ side_data.data(), side_data.size());
+ } else {
+- size_t side_data_size = 0;
++ int side_data_size = 0;
+ uint8_t* side_data = av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+
+@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
+ packet->size - data_offset);
+ }
+
+- size_t skip_samples_size = 0;
++ int skip_samples_size = 0;
+ const uint32_t* skip_samples_ptr =
+ reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/repo/apps/chromium/use-deprecated-ffmpeg-api.patch.1 b/repo/apps/chromium/use-deprecated-ffmpeg-api.patch.1
new file mode 100644
index 0000000..f0ec736
--- /dev/null
+++ b/repo/apps/chromium/use-deprecated-ffmpeg-api.patch.1
@@ -0,0 +1,36 @@
+diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
+index ac4713b07268..492a9a37d096 100644
+--- a/media/filters/ffmpeg_demuxer.cc
++++ b/media/filters/ffmpeg_demuxer.cc
+@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
+ scoped_refptr<DecoderBuffer> buffer;
+
+ if (type() == DemuxerStream::TEXT) {
+- size_t id_size = 0;
++ int id_size = 0;
+ uint8_t* id_data = av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+
+- size_t settings_size = 0;
++ int settings_size = 0;
+ uint8_t* settings_data = av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+
+@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
+ buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+ side_data.data(), side_data.size());
+ } else {
+- size_t side_data_size = 0;
++ int side_data_size = 0;
+ uint8_t* side_data = av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+
+@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
+ packet->size - data_offset);
+ }
+
+- size_t skip_samples_size = 0;
++ int skip_samples_size = 0;
+ const uint32_t* skip_samples_ptr =
+ reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+ packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/repo/apps/chromium/use-oauth2-client-switches-as-default.patch b/repo/apps/chromium/use-oauth2-client-switches-as-default.patch
new file mode 100644
index 0000000..9d9c57b
--- /dev/null
+++ b/repo/apps/chromium/use-oauth2-client-switches-as-default.patch
@@ -0,0 +1,17 @@
+diff -upr chromium-89.0.4389.58.orig/google_apis/google_api_keys.cc chromium-89.0.4389.58/google_apis/google_api_keys.cc
+--- chromium-89.0.4389.58.orig/google_apis/google_api_keys.cc 2021-02-24 22:37:18.494007649 +0000
++++ chromium-89.0.4389.58/google_apis/google_api_keys.cc 2021-02-24 22:35:00.865777600 +0000
+@@ -154,11 +154,11 @@ class APIKeyCache {
+
+ std::string default_client_id = CalculateKeyValue(
+ GOOGLE_DEFAULT_CLIENT_ID,
+- STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), nullptr,
++ STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), ::switches::kOAuth2ClientID,
+ std::string(), environment.get(), command_line, gaia_config);
+ std::string default_client_secret = CalculateKeyValue(
+ GOOGLE_DEFAULT_CLIENT_SECRET,
+- STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), nullptr,
++ STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), ::switches::kOAuth2ClientSecret,
+ std::string(), environment.get(), command_line, gaia_config);
+
+ // We currently only allow overriding the baked-in values for the
diff --git a/repo/apps/chromium/wayland-egl.patch b/repo/apps/chromium/wayland-egl.patch
new file mode 100644
index 0000000..58a0798
--- /dev/null
+++ b/repo/apps/chromium/wayland-egl.patch
@@ -0,0 +1,22 @@
+--- a/ui/gl/gl_image_native_pixmap.cc 2020-05-18 11:40:06.000000000 -0700
++++ b/ui/gl/gl_image_native_pixmap.cc 2020-05-22 02:07:16.007770442 -0700
+@@ -288,6 +288,8 @@
+ std::move(scoped_fd));
+ }
+
++ handle.planes[0].size = size_.GetArea();
++
+ return handle;
+ #endif // !defined(OS_FUCHSIA)
+ }
+--- a/gpu/command_buffer/service/error_state.cc 2020-05-18 11:39:22.000000000 -0700
++++ b/gpu/command_buffer/service/error_state.cc 2020-05-22 13:43:09.181180388 -0700
+@@ -115,6 +115,8 @@
+ // buffer.
+ error = GL_NO_ERROR;
+ }
++ if (error == GL_INVALID_ENUM)
++ error = GL_NO_ERROR;
+ return error;
+ }
+
diff --git a/repo/apps/chromium/webcodecs-stop-using-AudioOpusEncoder.patch b/repo/apps/chromium/webcodecs-stop-using-AudioOpusEncoder.patch
new file mode 100644
index 0000000..32957d3
--- /dev/null
+++ b/repo/apps/chromium/webcodecs-stop-using-AudioOpusEncoder.patch
@@ -0,0 +1,49 @@
+From 3bd46cb9a51773f103ef52b39d6407740eb0d60a Mon Sep 17 00:00:00 2001
+From: Eugene Zemtsov <eugene@chromium.org>
+Date: Thu, 24 Feb 2022 23:17:20 +0000
+Subject: [PATCH] webcodecs: Stop using AudioOpusEncoder as backed for mojo
+ audio encoder
+
+AudioOpusEncoder was only used here for testing. Let's not let it get
+comfortable. We'll use MF AAC encoder here when we have it. (Soon...)
+
+Bug: 1259883
+Change-Id: Ia1819395c8c8fd6d403d4b8558c12f9a1bf7e761
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3489449
+Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
+Auto-Submit: Eugene Zemtsov <eugene@chromium.org>
+Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
+Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
+Cr-Commit-Position: refs/heads/main@{#974895}
+---
+ media/mojo/services/gpu_mojo_media_client.cc | 10 +---------
+ 1 file changed, 1 insertion(+), 9 deletions(-)
+
+diff --git a/media/mojo/services/gpu_mojo_media_client.cc b/media/mojo/services/gpu_mojo_media_client.cc
+index 8f83a4d6cf6..40cdaff8d3a 100644
+--- a/media/mojo/services/gpu_mojo_media_client.cc
++++ b/media/mojo/services/gpu_mojo_media_client.cc
+@@ -13,7 +13,6 @@
+ #include "build/chromeos_buildflags.h"
+ #include "gpu/ipc/service/gpu_channel.h"
+ #include "media/audio/audio_features.h"
+-#include "media/audio/audio_opus_encoder.h"
+ #include "media/base/audio_decoder.h"
+ #include "media/base/cdm_factory.h"
+ #include "media/base/media_switches.h"
+@@ -119,14 +118,7 @@ std::unique_ptr<AudioEncoder> GpuMojoMediaClient::CreateAudioEncoder(
+ scoped_refptr<base::SequencedTaskRunner> task_runner) {
+ if (!base::FeatureList::IsEnabled(features::kPlatformAudioEncoder))
+ return nullptr;
+- // TODO(crbug.com/1259883) Right now Opus encoder is all we have, later on
+- // we'll create a real platform encoder here.
+- auto opus_encoder = std::make_unique<AudioOpusEncoder>();
+- auto encoding_runner = base::ThreadPool::CreateSequencedTaskRunner(
+- {base::TaskPriority::USER_BLOCKING});
+- return std::make_unique<OffloadingAudioEncoder>(std::move(opus_encoder),
+- std::move(encoding_runner),
+- std::move(task_runner));
++ return nullptr;
+ }
+
+ VideoDecoderType GpuMojoMediaClient::GetDecoderImplementationType() {
diff --git a/repo/apps/chromium/webrtc-check-existence-of-cursor-metadata.patch b/repo/apps/chromium/webrtc-check-existence-of-cursor-metadata.patch
new file mode 100644
index 0000000..0c7e731
--- /dev/null
+++ b/repo/apps/chromium/webrtc-check-existence-of-cursor-metadata.patch
@@ -0,0 +1,31 @@
+From c2cd814cdd8cbf8dda6ccec2266327a5321fbde8 Mon Sep 17 00:00:00 2001
+From: Jan Grulich <grulja@gmail.com>
+Date: Tue, 15 Mar 2022 14:31:55 +0100
+Subject: [PATCH] PipeWire capturer: check existence of cursor metadata
+
+Check whether there are any cursor metadata before we try to validate
+and use them, otherwise we might crash on this.
+
+Bug: webrtc:13429
+Change-Id: I365da59a189b6b974cebafc94fec49d5b942efae
+Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255601
+Reviewed-by: Alexander Cooper <alcooper@chromium.org>
+Commit-Queue: Alexander Cooper <alcooper@chromium.org>
+Cr-Commit-Position: refs/heads/main@{#36240}
+---
+ .../desktop_capture/linux/wayland/shared_screencast_stream.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+index a8c86e26..9e81df4c 100644
+--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
++++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+@@ -650,7 +650,7 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
+ const struct spa_meta_cursor* cursor =
+ static_cast<struct spa_meta_cursor*>(spa_buffer_find_meta_data(
+ spa_buffer, SPA_META_Cursor, sizeof(*cursor)));
+- if (spa_meta_cursor_is_valid(cursor)) {
++ if (cursor && spa_meta_cursor_is_valid(cursor)) {
+ struct spa_meta_bitmap* bitmap = nullptr;
+
+ if (cursor->bitmap_offset)