Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

383 Commits   1 Branch   1 Tag
Index: radix-1.9/X11/app/chromium/119.0.6026.1/Makefile
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/Makefile	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/Makefile	(revision 192)
@@ -0,0 +1,518 @@
+
+COMPONENT_TARGETS  = $(HARDWARE_INTEL_PC32)
+COMPONENT_TARGETS += $(HARDWARE_INTEL_PC64)
+COMPONENT_TARGETS += $(HARDWARE_EBOX_3350DX2)
+COMPONENT_TARGETS += $(HARDWARE_CB1X)
+COMPONENT_TARGETS += $(HARDWARE_CB2X)
+COMPONENT_TARGETS += $(HARDWARE_CB3X)
+COMPONENT_TARGETS += $(HARDWARE_ORANGE_PP2E)
+COMPONENT_TARGETS += $(HARDWARE_NANOPI_NEO)
+COMPONENT_TARGETS += $(HARDWARE_ORANGE_PP)
+COMPONENT_TARGETS += $(HARDWARE_ORANGE_PL2)
+COMPONENT_TARGETS += $(HARDWARE_ORANGE_PI5)
+COMPONENT_TARGETS += $(HARDWARE_ORANGE_PI5B)
+COMPONENT_TARGETS += $(HARDWARE_ORANGE_PI5P)
+COMPONENT_TARGETS += $(HARDWARE_ROCK_5B)
+COMPONENT_TARGETS += $(HARDWARE_WECHIP_TX6)
+COMPONENT_TARGETS += $(HARDWARE_REPKA_PI3)
+COMPONENT_TARGETS += $(HARDWARE_FFRK3288)
+COMPONENT_TARGETS += $(HARDWARE_POIN2)
+COMPONENT_TARGETS += $(HARDWARE_RK3328_CC)
+COMPONENT_TARGETS += $(HARDWARE_KHADAS_EDGE)
+COMPONENT_TARGETS += $(HARDWARE_LEEZ_P710)
+COMPONENT_TARGETS += $(HARDWARE_M201)
+COMPONENT_TARGETS += $(HARDWARE_MXV)
+COMPONENT_TARGETS += $(HARDWARE_P201)
+COMPONENT_TARGETS += $(HARDWARE_NEXBOX_A95X)
+COMPONENT_TARGETS += $(HARDWARE_ODROID_C2)
+COMPONENT_TARGETS += $(HARDWARE_P212)
+COMPONENT_TARGETS += $(HARDWARE_KHADAS_VIM)
+COMPONENT_TARGETS += $(HARDWARE_Q201)
+COMPONENT_TARGETS += $(HARDWARE_ENYBOX_X2)
+COMPONENT_TARGETS += $(HARDWARE_KHADAS_VIM2)
+COMPONENT_TARGETS += $(HARDWARE_NIT6Q)
+COMPONENT_TARGETS += $(HARDWARE_OKMX6DL_C)
+COMPONENT_TARGETS += $(HARDWARE_OKMX6Q_C)
+COMPONENT_TARGETS += $(HARDWARE_BONE_BLACK)
+COMPONENT_TARGETS += $(HARDWARE_OMAP5UEVM)
+COMPONENT_TARGETS += $(HARDWARE_DRA7XXEVM)
+COMPONENT_TARGETS += $(HARDWARE_CI20)
+COMPONENT_TARGETS += $(HARDWARE_BAIKAL_T1)
+COMPONENT_TARGETS += $(HARDWARE_BAIKAL_M1)
+COMPONENT_TARGETS += $(HARDWARE_S824L)
+COMPONENT_TARGETS += $(HARDWARE_VESNIN)
+COMPONENT_TARGETS += $(HARDWARE_S824L_LSB)
+COMPONENT_TARGETS += $(HARDWARE_VESNIN_LSB)
+COMPONENT_TARGETS += $(HARDWARE_TL2WK2)
+COMPONENT_TARGETS += $(HARDWARE_TL2SV2)
+COMPONENT_TARGETS += $(HARDWARE_TL2WK2_LSB)
+COMPONENT_TARGETS += $(HARDWARE_TL2SV2_LSB)
+COMPONENT_TARGETS += $(HARDWARE_SIFIVE_U740)
+
+
+NEED_ABS_PATH      = true
+COMPONENT_IS_3PP   = true
+
+
+include ../../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES    = sources/packages/x/chromium
+
+REQUIRES           = X11/libs/qt5/5.15.8
+REQUIRES          += X11/media/pipewire/0.3.80
+REQUIRES          += X11/media/pulseaudio/16.1
+REQUIRES          += X11/libs/cairo/1.17.8
+REQUIRES          += X11/libs/pango/1.50.12
+REQUIRES          += X11/app/cups-filters/1.28.16
+REQUIRES          += X11/X.org/lib/libXrandr/1.5.3
+REQUIRES          += X11/X.org/lib/libXdamage/1.1.6
+REQUIRES          += X11/X.org/lib/libXcomposite/0.4.6
+REQUIRES          += libs/expat/2.5.0
+REQUIRES          += libs/libffi/3.4.4
+REQUIRES          += app/dbus/1.13.18
+REQUIRES          += net/nss/3.93
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version            = 119.0.6026.1
+SRC_DIR            = $(TARGET_BUILD_DIR)/src
+doc_dir_name       = chromium-$(version)
+src_done           = $(TARGET_BUILD_DIR)/.source_done
+
+unsupported        = $(TARGET_BUILD_DIR)/.unsupported_hardware
+
+
+PATCHES = PATCHES
+
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_A1X_GLIBC)    $(TOOLCHAIN_A2X_GLIBC)      \
+                             $(TOOLCHAIN_H3_GLIBC)     $(TOOLCHAIN_RK328X_GLIBC)   \
+                             $(TOOLCHAIN_S8XX_GLIBC)   $(TOOLCHAIN_IMX6_GLIBC)     \
+                             $(TOOLCHAIN_AM335X_GLIBC) $(TOOLCHAIN_OMAP543X_GLIBC)),)
+target-cpu    = arm
+target-v8-cpu = arm
+OPT_PATCHES   = PATCHES.arm
+endif
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_H5_GLIBC)     $(TOOLCHAIN_RK33XX_GLIBC) \
+                             $(TOOLCHAIN_RK339X_GLIBC) $(TOOLCHAIN_RK358X_GLIBC) \
+                             $(TOOLCHAIN_S9XX_GLIBC)   \
+                             $(TOOLCHAIN_A311X_GLIBC)  $(TOOLCHAIN_M1000_GLIBC)),)
+target-cpu    = arm64
+target-v8-cpu = arm64
+OPT_PATCHES   = PATCHES.aarch64
+endif
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_X86_64_GLIBC)),)
+target-cpu    = x64
+target-v8-cpu = x64
+OPT_PATCHES   = PATCHES.x86_64
+endif
+
+build_dir          = $(TARGET_BUILD_DIR)/build
+build_target       = $(TARGET_BUILD_DIR)/.build_done
+install_target     = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = xapp
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+CHROMIUM_PKG_NAME                = chromium
+CHROMIUM_PKG_VERSION             = 119.0.6026.1
+CHROMIUM_PKG_ARCH                = $(PKGARCH)
+CHROMIUM_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+CHROMIUM_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+CHROMIUM_PKG_GROUP               = $(PKG_GROUP)
+###                               |---handy-ruler-------------------------------|
+CHROMIUM_PKG_SHORT_DESCRIPTION   = Open Source version of Chrome Web Browser
+CHROMIUM_PKG_URL                 = $(BUG_URL)
+CHROMIUM_PKG_LICENSE             = custom
+CHROMIUM_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(CHROMIUM_PKG_NAME)-pkg-description
+CHROMIUM_PKG_DESCRIPTION_FILE_IN = $(CHROMIUM_PKG_NAME)-pkg-description.in
+CHROMIUM_PKG_INSTALL_SCRIPT      = $(CHROMIUM_PKG_NAME)-pkg-install.sh
+
+CHROMIUM_PKG     = $(CURDIR)/$(TARGET_BUILD_DIR)/$(CHROMIUM_PKG_NAME)-package
+
+pkg_basename     = $(CHROMIUM_PKG_NAME)-$(CHROMIUM_PKG_VERSION)-$(CHROMIUM_PKG_ARCH)-$(CHROMIUM_PKG_DISTRO_NAME)-$(CHROMIUM_PKG_DISTRO_VERSION)
+
+pkg_archive      = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_signature    = $(call sign-name,$(pkg_archive))
+pkg_description  = $(call desc-name,$(pkg_archive))
+products         = $(call pkg-files,$(pkg_archive))
+
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_JZ47XX_GLIBC)   $(TOOLCHAIN_P5600_GLIBC)    \
+                             $(TOOLCHAIN_POWER8_GLIBC)   $(TOOLCHAIN_POWER9_GLIBC)   \
+                             $(TOOLCHAIN_POWER8LE_GLIBC) $(TOOLCHAIN_POWER9LE_GLIBC) \
+                             $(TOOLCHAIN_RISCV64_GLIBC)                              \
+                             $(TOOLCHAIN_I586_GLIBC)     $(TOOLCHAIN_I686_GLIBC)),)
+target-message   = Chromium doesn't support this CPU architecture
+BUILD_TARGETS    = $(unsupported)
+PRODUCT_TARGETS  =
+ROOTFS_TARGETS   =
+else
+BUILD_TARGETS    = $(build_target)
+BUILD_TARGETS   += $(install_target)
+PRODUCT_TARGETS  = $(products)
+ROOTFS_TARGETS   = $(pkg_archive)
+endif
+
+
+include ../../../../build-system/core.mk
+
+
+env_sysroot = DESTDIR=$(CHROMIUM_PKG)
+
+
+JOBS := $(shell echo 'if( $(NUMPROCS) > 2) { $(NUMPROCS) / 2 } else { 1 }' | bc)
+NINJA_JOBS := -j$(JOBS) -l$(JOBS)
+
+
+output_dir         = out/Release
+
+chromium_url       = https://chromium.googlesource.com/chromium
+gclient_file       = .gclient
+gn_args_file       = $(output_dir)/args.gn
+
+depot_tools_url    = https://chromium.googlesource.com/chromium/tools
+depot_tools_dir    = $(CURDIR)/$(TARGET_BUILD_DIR)/depot_tools
+
+host_sysroot       = $(CURDIR)/$(SRC_DIR)/build/linux/debian_bullseye_amd64-sysroot
+
+
+####### Dependencies
+
+$(unsupported):
+	#######
+	####### $(target-message)
+	#######
+	################################################################
+	@echo "$(target-message)" > $@
+	@touch $@
+
+$(src_done): $(PATCHES_DEP)
+	@mkdir -p $(SRC_DIR)
+	# ======= Get Chromium sources =======
+	@( cd $(TARGET_BUILD_DIR) ; \
+	   git clone $(depot_tools_url)/depot_tools.git ; \
+	   git clone --depth 1 --branch $(version) $(chromium_url)/src.git 2>/dev/null ; \
+	   echo 'solutions = ['                         >  $(gclient_file) ; \
+	   echo '  {'                                   >> $(gclient_file) ; \
+	   echo '    "name": "src",'                    >> $(gclient_file) ; \
+	   echo '    "url": "$(chromium_url)/src.git",' >> $(gclient_file) ; \
+	   echo '    "managed": False,'                 >> $(gclient_file) ; \
+	   echo '    "custom_deps": {},'                >> $(gclient_file) ; \
+	   echo '    "custom_vars": {},'                >> $(gclient_file) ; \
+	   echo '  },'                                  >> $(gclient_file) ; \
+	   echo ']'                                     >> $(gclient_file) ; \
+	 )
+	# ======= Prepare Chromium sources =======
+	@( cd $(SRC_DIR) ; \
+	   export PATH="$(depot_tools_dir):$${PATH}" ; \
+	   gclient sync 2>/dev/null; \
+	 )
+	$(APPLY_PATCHES)
+	$(call apply-opt-patches, $(SRC_DIR))
+	# ======= Tune compiler for target architecture: =======
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_A1X_GLIBC)    $(TOOLCHAIN_A2X_GLIBC)      \
+                             $(TOOLCHAIN_H3_GLIBC)     $(TOOLCHAIN_RK328X_GLIBC)   \
+                             $(TOOLCHAIN_S8XX_GLIBC)   $(TOOLCHAIN_IMX6_GLIBC)     \
+                             $(TOOLCHAIN_AM335X_GLIBC) $(TOOLCHAIN_OMAP543X_GLIBC)),)
+	@sed -i 's,@ARM_TARGET@,$(TARGET),g' $(SRC_DIR)/build/config/compiler/BUILD.gn
+endif
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_H5_GLIBC)     $(TOOLCHAIN_RK33XX_GLIBC) \
+                             $(TOOLCHAIN_RK339X_GLIBC) $(TOOLCHAIN_RK358X_GLIBC) \
+                             $(TOOLCHAIN_S9XX_GLIBC)   \
+                             $(TOOLCHAIN_A311X_GLIBC)  $(TOOLCHAIN_M1000_GLIBC)),)
+	@sed -i 's,@AARCH64_TARGET@,$(TARGET),g' $(SRC_DIR)/build/config/compiler/BUILD.gn
+endif
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_X86_64_GLIBC)),)
+	@sed -i 's,@X64_TARGET@,$(TARGET),g' $(SRC_DIR)/build/config/compiler/BUILD.gn
+endif
+	@touch $@
+
+$(build_target): $(src_done)
+	# ======= Create pkg-config wrappers =======
+	@( cd $(SRC_DIR) ; \
+	   echo    '#!/bin/sh'                                             >  target-pkg-config ; \
+	   echo    ''                                                      >> target-pkg-config ; \
+	   echo -n 'PKG_CONFIG_PATH=$(ROOTFS_DEST_DIR)/usr/lib/pkgconfig:' >> target-pkg-config ; \
+	   echo    '$(ROOTFS_DEST_DIR)/usr/share/pkgconfig \'              >> target-pkg-config ; \
+	   echo    'pkg-config "$$@"'                                      >> target-pkg-config ; \
+	   chmod a+x target-pkg-config ; \
+	 )
+ifeq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_X86_64_GLIBC)),)
+	@( cd $(SRC_DIR) ; \
+	   echo    '#!/bin/sh'                                             >    host-pkg-config ; \
+	   echo    ''                                                      >>   host-pkg-config ; \
+	   echo -n 'PKG_CONFIG_PATH=$(host_sysroot)/usr/lib/pkgconfig:'    >>   host-pkg-config ; \
+	   echo    '$(host_sysroot)/usr/share/pkgconfig \'                 >>   host-pkg-config ; \
+	   echo    'pkg-config "$$@"'                                      >>   host-pkg-config ; \
+	   chmod a+x host-pkg-config ; \
+	 )
+endif
+	# ======= Configure Chromium sources =======
+	@( cd $(SRC_DIR) ; \
+	   mkdir -p $(output_dir) ; \
+	   echo ''                                         >  $(gn_args_file) ; \
+	   echo 'is_official_build = true'                 >> $(gn_args_file) ; \
+	   echo 'chrome_pgo_phase = 0'                     >> $(gn_args_file) ; \
+	   echo 'is_debug = false'                         >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   echo 'symbol_level = 0'                         >> $(gn_args_file) ; \
+	   echo 'v8_symbol_level = 0'                      >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   echo 'use_qt = true'                            >> $(gn_args_file) ; \
+	   echo 'use_qt6 = false'                          >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   echo 'target_os = "linux"'                      >> $(gn_args_file) ; \
+	   echo 'target_cpu = "$(target-cpu)"'             >> $(gn_args_file) ; \
+	   echo 'v8_target_cpu = "$(target-v8-cpu)"'       >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	 )
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_X86_64_GLIBC)),)
+	@( cd $(SRC_DIR) ; \
+	   echo 'pkg_config = "$(CURDIR)/$(SRC_DIR)/target-pkg-config"'      >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   echo 'sysroot = "$(ROOTFS_DEST_DIR)"'           >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	 )
+else
+	@( cd $(SRC_DIR) ; \
+	   echo 'pkg_config = "$(CURDIR)/$(SRC_DIR)/target-pkg-config"'      >> $(gn_args_file) ; \
+	   echo 'host_pkg_config = "$(CURDIR)/$(SRC_DIR)/host-pkg-config"'   >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   echo 'target_sysroot = "$(ROOTFS_DEST_DIR)"'    >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	 )
+endif
+	@( cd $(SRC_DIR) ; \
+	   echo 'is_clang = true'                          >> $(gn_args_file) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   echo 'enable_pseudolocales = false'             >> $(gn_args_file) ; \
+	   echo 'rtc_use_pipewire = true'                  >> $(gn_args_file) ; \
+	   echo 'use_system_libffi = true'                 >> $(gn_args_file) ; \
+	   echo 'enable_vulkan = true'                     >> $(gn_args_file) ; \
+	   echo 'enable_rust = false'                      >> $(gn_args_file) ; \
+	   echo 'use_cups = true'                          >> $(gn_args_file) ; \
+	   echo 'ffmpeg_branding = "ChromeOS"'             >> $(gn_args_file) ; \
+	   echo 'link_pulseaudio = true'                   >> $(gn_args_file) ; \
+	   echo 'use_pulseaudio = true'                    >> $(gn_args_file) ; \
+	   echo 'proprietary_codecs = true'                >> $(gn_args_file) ; \
+	   echo 'enable_platform_hevc = true'              >> $(gn_args_file) ; \
+	   echo 'enable_platform_ac3_eac3_audio = true'    >> $(gn_args_file) ; \
+	   echo 'enable_platform_mpeg_h_audio = true'      >> $(gn_args_file) ; \
+	   echo 'enable_platform_dolby_vision = true'      >> $(gn_args_file) ; \
+	   echo 'enable_mse_mpeg2ts_stream_parser = true'  >> $(gn_args_file) ; \
+	   echo 'enable_nacl = false'                      >> $(gn_args_file) ; \
+	 )
+	# ======= Generate Chromium ninja files =======
+	@( cd $(SRC_DIR) ; \
+	   echo ''                                         >> $(gn_args_file) ; \
+	   export PATH="$(depot_tools_dir):$${PATH}" ; \
+	   gn gen $(output_dir) ; \
+	 )
+	# ======= Take care of Debian/Ubuntu related missing header issues: =======
+	@( cd $(SRC_DIR)/build/linux/debian_bullseye_amd64-sysroot ; \
+	   ln -sf ../../lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h \
+	          usr/include/glib-2.0/glibconfig.h ; \
+	   ln -s ../../../lib/x86_64-linux-gnu/dbus-1.0/include/dbus/dbus-arch-deps.h \
+	         usr/include/dbus-1.0/dbus/dbus-arch-deps.h ; \
+	   ln -s ../../lib/x86_64-linux-gnu/graphene-1.0/include/graphene-config.h \
+	         usr/include/graphene-1.0/graphene-config.h ; \
+	   ( cd usr/lib/x86_64-linux-gnu ; \
+	     ln -sf libsqlite3.so.0 libsqlite3.so ; \
+	     for nss in nss/*.so ; do ln -sf $${nss} . ; done ; \
+	   ) ; \
+	 )
+	@( cd $(SRC_DIR)/build/linux/debian_bullseye_i386-sysroot ; \
+	   ln -sf ../../lib/i386-linux-gnu/glib-2.0/include/glibconfig.h \
+	          usr/include/glib-2.0/glibconfig.h ; \
+	   ln -s ../../../lib/i386-linux-gnu/dbus-1.0/include/dbus/dbus-arch-deps.h \
+	         usr/include/dbus-1.0/dbus/dbus-arch-deps.h ; \
+	   ln -s ../../lib/i386-linux-gnu/graphene-1.0/include/graphene-config.h \
+	         usr/include/graphene-1.0/graphene-config.h ; \
+	   ( cd usr/lib/i386-linux-gnu ; \
+	     ln -sf libsqlite3.so.0 libsqlite3.so ; \
+	     for nss in nss/*.so ; do ln -sf $${nss} . ; done ; \
+	   ) ; \
+	 )
+	# ======= Build Chromium =======
+	@( cd $(SRC_DIR) ; \
+	   ninja $(NINJA_JOBS) -C $(output_dir) chrome ; \
+	 )
+	# ======= Build Chrome Sandbox =======
+	@( cd $(SRC_DIR) ; \
+	   ninja $(NINJA_JOBS) -C $(output_dir) chrome_sandbox ; \
+	 )
+	# ======= Build Chrome driver =======
+	@( cd $(SRC_DIR) ; \
+	   ninja $(NINJA_JOBS) -C $(output_dir) chromedriver ; \
+	 )
+	@touch $@
+
+$(install_target): $(build_target)
+	# ======= Create Chromium Package =======
+	@mkdir -p $(CHROMIUM_PKG)/usr/bin
+	@mkdir -p $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/extensions
+	@mkdir -p $(CHROMIUM_PKG)/etc/chromium
+	# ======= Install main binary: =======
+	@install -D $(SRC_DIR)/$(output_dir)/chrome $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/chromium
+	# ======= Install Chrome Sandbox: =======
+	@install -D $(SRC_DIR)/$(output_dir)/chrome_sandbox $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/chrome-sandbox
+	# ======= Install Chromium implementation of the WebDriver wire protocol : =======
+	@install -D $(SRC_DIR)/$(output_dir)/chromedriver $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/chromedriver
+	# ======= Install Crashpad, the Chromium crash-reporting client: =======
+	@install -D $(SRC_DIR)/$(output_dir)/chrome_crashpad_handler $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/chrome_crashpad_handler
+	# ======= Install Libraries: =======
+	@for lib in {libEGL,libGLESv2,libVkICD_mock_icd,libVkLayer_khronos_validation,libqt5_shim,libvk_swiftshader}.so libvulkan.so.1 ; do \
+	   if [ -f "$(SRC_DIR)/$(output_dir)/$${lib}" ] ; then \
+	     install -D -m0755 $(SRC_DIR)/$(output_dir)/$${lib} $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/$${lib} ; \
+	   fi ; \
+	 done
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_X86_64_GLIBC)),)
+ifneq ($(PATCHELF),)
+	# ======= Set Interpreter for x86_64 target binaries: =======
+	@( cd $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/firefox ; \
+	   for file in `find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     $(PATCHELF) --set-interpreter /lib$(LIBSUFFIX)/ld-linux-x86-64.so.2 $$file 1> /dev/null 2> /dev/null ; \
+	   done ; \
+	 )
+endif
+endif
+	@install -D -m0644 $(SRC_DIR)/$(output_dir)/vk_swiftshader_icd.json $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/vk_swiftshader_icd.json
+	# ======= Copy icudtl.dat: =======
+	@cp -a $(SRC_DIR)/$(output_dir)/icudtl.dat $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/
+	# ======= Copy over the remaining binaries: =======
+	@cp -a $(SRC_DIR)/$(output_dir)/angledata $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/
+	@cp -a $(SRC_DIR)/$(output_dir)/MEIPreload $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/
+	@cp -a $(SRC_DIR)/$(output_dir)/*.pak $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/
+	@for blob in {snapshot_blob,v8_context_snapshot}.bin ; do \
+	   if [ -f $(SRC_DIR)/$(output_dir)/$${blob} ] ; then \
+	     cp -a $(SRC_DIR)/$(output_dir)/$${blob} $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/ ; \
+	   fi ; \
+	 done
+	# ======= Add locales: =======
+	@mkdir -p $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/locales
+	@cp -a $(SRC_DIR)/$(output_dir)/locales/*.pak $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/locales/
+	@ln -sf locales $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/remoting_locales
+	# ======= Add resource files: =======
+	@cp -a $(SRC_DIR)/$(output_dir)/resources $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/
+	# ======= Install appdata: =======
+	@mkdir -p $(CHROMIUM_PKG)/usr/share/metainfo
+	# ------- Remove text with relevance to Google only (thanks Arch): -------
+	@sed -n \
+	     -e '/<update_contact>/d' \
+	     -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
+	     -e '/^<?xml/,$$p' \
+	   $(SRC_DIR)/chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
+	   > $(CHROMIUM_PKG)/usr/share/metainfo/$(CHROMIUM_PKG_NAME).appdata.xml
+	@chmod 644 $(CHROMIUM_PKG)/usr/share/metainfo/$(CHROMIUM_PKG_NAME).appdata.xml
+	# ======= Install $(CHROMIUM_PKG_NAME).desktop file: =======
+	@cat $(SRC_DIR)/chrome/installer/linux/common/desktop.template | \
+	   sed -e "s/@@MENUNAME@@/Chromium Web Browser/g"              | \
+	   sed -e "s/@@USR_BIN_SYMLINK_NAME@@/$(CHROMIUM_PKG_NAME)/g"  | \
+	   sed -e "s/@@PACKAGE@@/$(CHROMIUM_PKG_NAME)/g" > $(SRC_DIR)/$(output_dir)/$(CHROMIUM_PKG_NAME).desktop
+	@install -D -m0644 $(SRC_DIR)/$(output_dir)/$(CHROMIUM_PKG_NAME).desktop \
+	         $(CHROMIUM_PKG)/usr/share/applications/$(CHROMIUM_PKG_NAME).desktop
+	# ======= Install desktop icons: =======
+	@for size in 16 32 ; do \
+	   install -D -m0644 \
+	     $(SRC_DIR)/chrome/app/theme/default_100_percent/chromium/product_logo_$${size}.png \
+	     $(CHROMIUM_PKG)/usr/share/icons/hicolor/$${size}x$${size}/apps/$(CHROMIUM_PKG_NAME).png ; \
+	   ln -sf $(CHROMIUM_PKG_NAME).png \
+	          $(CHROMIUM_PKG)/usr/share/icons/hicolor/$${size}x$${size}/apps/chromium-browser.png ; \
+	 done
+	@for size in 24 48 64 128 256 ; do \
+	   install -D -m0644 \
+	     $(SRC_DIR)/chrome/app/theme/chromium/product_logo_$${size}.png \
+	     $(CHROMIUM_PKG)/usr/share/icons/hicolor/$${size}x$${size}/apps/$(CHROMIUM_PKG_NAME).png ; \
+	   ln -sf $(CHROMIUM_PKG_NAME).png \
+	          $(CHROMIUM_PKG)/usr/share/icons/hicolor/$${size}x$${size}/apps/chromium-browser.png ; \
+	 done
+	# ======= Make the chromedriver available in the PATH : =======
+	@ln -sf ../lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME)/chromedriver $(CHROMIUM_PKG)/usr/bin/chromedriver
+	# ======= Install a wrapper script: =======
+	@cat $(CURDIR)/scripts/chromium.in                | \
+	   sed -e "s/@CRFLAGS@/CHROMIUM_FLAGS/g"          | \
+	   sed -e "s/@CRUSERFLAGS@/CHROMIUM_USER_FLAGS/g" | \
+	   sed -e "s/@LIBDIRSUFFIX@/$(LIBSUFFIX)/g" > $(CHROMIUM_PKG)/usr/bin/$(CHROMIUM_PKG_NAME)
+	@chmod 755 $(CHROMIUM_PKG)/usr/bin/$(CHROMIUM_PKG_NAME)
+	# ======= xdg-utils looks for "chromium-browser" so symlink it to the wrapper: =======
+	@ln -sf $(CHROMIUM_PKG_NAME) $(CHROMIUM_PKG)/usr/bin/chromium-browser
+	# ======= Install 'default' file: =======
+	@cat $(CURDIR)/scripts/chromium.default | \
+	   sed -e "s/@CRFLAGS@/CHROMIUM_FLAGS/g"  > $(CHROMIUM_PKG)/etc/chromium/00-default.conf.new
+	@chmod 644 $(CHROMIUM_PKG)/etc/chromium/00-default.conf.new
+	# ======= Install the API keys sample file: =======
+	@cat $(CURDIR)/scripts/chromium.apikeys.sample > $(CHROMIUM_PKG)/etc/chromium/01-apikeys.conf.new
+	@chmod 644 $(CHROMIUM_PKG)/etc/chromium/01-apikeys.conf.new
+	# ======= Install a man page: =======
+	@cat $(SRC_DIR)/chrome/app/resources/manpage.1.in | \
+	   sed -e "s/@@MENUNAME@@/Chromium Web Browser/g"              | \
+	   sed -e "s/@@PACKAGE@@/$(CHROMIUM_PKG_NAME)/g" > $(SRC_DIR)/$(output_dir)/$(CHROMIUM_PKG_NAME).1
+	@install -D -m0644 $(SRC_DIR)/$(output_dir)/$(CHROMIUM_PKG_NAME).1 \
+	   $(CHROMIUM_PKG)/usr/share/man/man1/$(CHROMIUM_PKG_NAME).1
+	# ======= Install Documentation =======
+	@if [ -d $(CHROMIUM_PKG)/usr/share/man ]; then \
+	  ( cd $(CHROMIUM_PKG)/usr/share/man ; \
+	    for manpagedir in `find . -type d -name "man*"` ; do \
+	      ( cd $$manpagedir ; \
+	        for eachpage in `find . -type l -maxdepth 1` ; do \
+	          ln -s `readlink $$eachpage`.gz $$eachpage.gz ; \
+	          rm $$eachpage ; \
+	        done ; \
+	        gzip -9 *.?  ; \
+	      ) \
+	    done \
+	  ) \
+	 fi
+	@mkdir -p $(CHROMIUM_PKG)/usr/doc/$(src_dir_name)
+	@cp -a $(SRC_DIR)/AUTHORS $(SRC_DIR)/LICENSE \
+	       $(CHROMIUM_PKG)/usr/doc/$(src_dir_name)
+	@mkdir -p $(CHROMIUM_PKG)/usr/share/doc/$(src_dir_name)
+	@( cd $(SRC_DIR) ; \
+	   cp -a AUTHORS LICENSE README.md \
+	         $(CHROMIUM_PKG)/usr/share/doc/$(src_dir_name) ; \
+	 )
+	@( cd $(SRC_DIR) ; \
+	   if [ -r ChangeLog -a -s ChangeLog ]; then \
+	     DOCSDIR=`echo $(CHROMIUM_PKG)/usr/share/doc/$(src_dir_name)` ; \
+	     cat ChangeLog | head -n 1000 > $$DOCSDIR/ChangeLog ; \
+	     touch -r ChangeLog $$DOCSDIR/ChangeLog ; \
+	   fi \
+	 )
+	# ======= Install the same to $(TARGET_DEST_DIR) =======
+	$(call install-into-devenv, $(CHROMIUM_PKG))
+	# ======= Strip binaries =======
+	@( cd $(CHROMIUM_PKG)/usr/lib$(LIBSUFFIX)/$(CHROMIUM_PKG_NAME) ; \
+	   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	 )
+	@touch $@
+
+$(CHROMIUM_PKG_DESCRIPTION_FILE): $(CHROMIUM_PKG_DESCRIPTION_FILE_IN)
+	@cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@
+
+$(pkg_certificate) : $(pkg_archive) ;
+$(pkg_signature)   : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_target) $(CHROMIUM_PKG_DESCRIPTION_FILE) $(CHROMIUM_PKG_INSTALL_SCRIPT)
+	@cp $(CHROMIUM_PKG_DESCRIPTION_FILE) $(CHROMIUM_PKG)/.DESCRIPTION
+	@cp $(CHROMIUM_PKG_INSTALL_SCRIPT) $(CHROMIUM_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(CHROMIUM_PKG)/.REQUIRES
+	@echo "pkgname=$(CHROMIUM_PKG_NAME)"                            >  $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(CHROMIUM_PKG_VERSION)"                          >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "arch=$(CHROMIUM_PKG_ARCH)"                               >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "distroname=$(CHROMIUM_PKG_DISTRO_NAME)"                  >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "distrover=$(CHROMIUM_PKG_DISTRO_VERSION)"                >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "group=$(CHROMIUM_PKG_GROUP)"                             >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(CHROMIUM_PKG_SHORT_DESCRIPTION)\"" >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "url=$(CHROMIUM_PKG_URL)"                                 >> $(CHROMIUM_PKG)/.PKGINFO ; \
+	 echo "license=$(CHROMIUM_PKG_LICENSE)"                         >> $(CHROMIUM_PKG)/.PKGINFO
+	@$(PSEUDO) sh -c "cd $(CHROMIUM_PKG) && \
+	                  chown -R root:root . && \
+	                  $(MAKE_PACKAGE) -J --linkadd=yes $(GNUPG_OPTIONS) -m -d .. ."
Index: radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES	(revision 192)
@@ -0,0 +1,5 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-cross-compile.patch       -p0
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-dangling-gsl.patch        -p0
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-inc-drop-host-crash.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-oauth2-default.patch      -p0
Index: radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.aarch64
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.aarch64	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.aarch64	(revision 192)
@@ -0,0 +1,3 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-host-pkg-config.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-target-aarch64.patch  -p0
Index: radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.arm
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.arm	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.arm	(revision 192)
@@ -0,0 +1,3 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-host-pkg-config.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-target-arm.patch      -p0
Index: radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.x86_64
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.x86_64	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/PATCHES.x86_64	(revision 192)
@@ -0,0 +1,2 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-119.0.6026.1-target-x86_64.patch   -p0
Index: radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-description.in
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-description.in	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-description.in	(revision 192)
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+        |-----handy-ruler------------------------------------------------------|
+chromium: chromium @VERSION@ (Open Source version of Chrome Web Browser)
+chromium:
+chromium: Chromium is the open-source project behind Google Chrome,
+chromium: an attempt at creating a safer, faster, and more stable browser.
+chromium:
+chromium:
+chromium:
+chromium: chromium home: http://www.chromium.org/
+chromium:
+chromium:
+chromium:
Index: radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-install.sh
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-install.sh	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-install.sh	(revision 192)
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+# Preserve new files
+install_file() {
+  NEW="$1"
+  OLD="`dirname $NEW`/`basename $NEW .new`"
+  # If there's no file by that name, mv it over:
+  if [ ! -r $OLD ]; then
+    mv $NEW $OLD
+  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
+    rm $NEW
+  fi
+  # Otherwise, we leave the .new copy for the admin to consider...
+}
+
+
+# arg 1:  the new package version
+pre_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+post_install() {
+  install_file etc/chromium/00-default.conf.new
+  install_file etc/chromium/01-apikeys.conf.new
+
+  # Update desktop database
+  if [ -x /usr/bin/update-desktop-database ]; then
+    /usr/bin/update-desktop-database -q usr/share/applications > /dev/null 2>&1
+  fi
+
+  # Notice we use an absolute path below, rather than usr/bin/update-mime-database.
+  # This is because we're testing to see if we are on the bootdisk, which will not
+  # have /usr/bin/update-mime-database.
+  # The presence of "/etc/system-installer" is under consideration as a better test.
+  # Also we have to check that we are not in the installer mode on the target system
+  # ("/etc/system-installer"), and we have to be sure that we are on the working system
+  # on the target hardware ("proc/sys/kernel/osrelease" - relative path).
+  if [ -r proc/sys/kernel/osrelease -a ! -r /etc/system-installer -a -x /usr/bin/update-mime-database ]; then
+    /usr/bin/update-mime-database /usr/share/mime 1>/dev/null 2>/dev/null
+    cat /etc/passwd | while read passwdline ; do
+      homedir=$(echo $passwdline | cut -f 6 -d :)
+      if [ -d $homedir/.local/share/mime ]; then
+        username=$(echo $passwdline | cut -f 1 -d :)
+        su $username -c "/usr/bin/update-mime-database $homedir/.local/share/mime 1>/dev/null 2>/dev/null" 2> /dev/null
+      fi
+    done
+    # This is just "cleanup" in case something might be missed in /home/*/
+    for homemimedir in /home/*/.local/share/mime ; do
+      if [ -d $homemimedir ]; then
+        username=$(echo $homemimedir | cut -f 3 -d /)
+        su $username -c "/usr/bin/update-mime-database $homemimedir 1>/dev/null 2>/dev/null" 2> /dev/null
+      fi
+    done
+  else
+    # We are not on the target system and we can make use build-machine's utility
+    if [ -x /usr/bin/update-mime-database ] ; then
+      update-mime-database usr/share/mime 1>/dev/null 2>/dev/null
+    fi
+  fi
+
+  if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
+    if [ -x /usr/bin/gtk-update-icon-cache ]; then
+      /usr/bin/gtk-update-icon-cache usr/share/icons/hicolor > /dev/null 2>&1
+    fi
+  fi
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+pre_update() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_update() {
+  post_install
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  /bin/true
+}
+
+# arg 1:  the old package version
+post_remove() {
+  /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*

Property changes on: radix-1.9/X11/app/chromium/119.0.6026.1/chromium-pkg-install.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.apikeys.sample
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.apikeys.sample	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.apikeys.sample	(revision 192)
@@ -0,0 +1,7 @@
+# Remove the '.sample' suffix from the filename to enable its content:
+
+# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
+# Example using values found in the public Chromium sources, YMMV:
+export GOOGLE_API_KEY='AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY'
+export GOOGLE_DEFAULT_CLIENT_ID='77185425430.apps.googleusercontent.com'
+export GOOGLE_DEFAULT_CLIENT_SECRET='OTJgUOQcT7lO7GsGZq2G4IlT'
Index: radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.default
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.default	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.default	(revision 192)
@@ -0,0 +1,6 @@
+# Default settings for chromium
+# This file is sourced by /usr/bin/chromium
+
+# Options to pass to chromium:
+#@CRFLAGS@=""
+
Index: radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.in
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.in	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1/scripts/chromium.in	(revision 192)
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Allow users to override command-line options
+for file in /etc/chromium/*.conf ; do
+  [[ -f ${file} ]] && source "${file}"
+done
+
+# Prefer user defined @CRUSERFLAGS@ flags (from environment)
+# over system default @CRFLAGS@ (from /etc/chromium/)
+@CRFLAGS@=${@CRUSERFLAGS@:-$@CRFLAGS@}
+
+export CHROME_WRAPPER=$(readlink -f "$0")
+export CHROME_DESKTOP=chromium.desktop
+
+exec /usr/lib@LIBDIRSUFFIX@/chromium/chromium $@CRFLAGS@ "$@"
Index: radix-1.9/X11/app/chromium/119.0.6026.1
===================================================================
--- radix-1.9/X11/app/chromium/119.0.6026.1	(nonexistent)
+++ radix-1.9/X11/app/chromium/119.0.6026.1	(revision 192)

Property changes on: radix-1.9/X11/app/chromium/119.0.6026.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,74 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.rk358x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: radix-1.9/products/X11/Makefile
===================================================================
--- radix-1.9/products/X11/Makefile	(revision 191)
+++ radix-1.9/products/X11/Makefile	(revision 192)
@@ -861,7 +861,15 @@
 REQUIRES += X11/app/thunderbird/115.3.1
 REQUIRES += X11/app/libreoffice/7.6.2.1
 
+ifeq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_JZ47XX_GLIBC)   $(TOOLCHAIN_P5600_GLIBC)    \
+                            $(TOOLCHAIN_POWER8_GLIBC)   $(TOOLCHAIN_POWER9_GLIBC)   \
+                            $(TOOLCHAIN_POWER8LE_GLIBC) $(TOOLCHAIN_POWER9LE_GLIBC) \
+                            $(TOOLCHAIN_RISCV64_GLIBC)                              \
+                            $(TOOLCHAIN_I586_GLIBC)     $(TOOLCHAIN_I686_GLIBC)),)
+REQUIRES += X11/app/chromium/119.0.6026.1
+endif
 
+
 #######
 ####### Desktop development (IDE):
 #######
Index: radix-1.9/sources/packages/x/chromium/Makefile
===================================================================
--- radix-1.9/sources/packages/x/chromium/Makefile	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/Makefile	(revision 192)
@@ -0,0 +1,47 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../build-system/constants.mk
+
+
+url         = $(DOWNLOAD_SERVER)/sources/packages/x/fontconfig
+
+versions    = 119.0.6026.1
+pkgname     = chromium
+
+patches     = $(CURDIR)/patches/chromium-119.0.6026.1-cross-compile.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-dangling-gsl.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-host-pkg-config.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-inc-drop-host-crash.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-oauth2-default.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-target-aarch64.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-target-arm.patch
+patches    += $(CURDIR)/patches/chromium-119.0.6026.1-target-x86_64.patch
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(patches)
+
+
+include ../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(patches):
+	@echo -e "\n======= Create Patches =======\n" ; \
+	 ( cd create-119.0.6026.1-cross-compile-patch       ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-dangling-gsl-patch        ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-host-pkg-config-patch     ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-inc-drop-host-crash-patch ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-oauth2-default-patch      ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-target-aarch64-patch      ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-target-arm-patch          ; ./create.patch.sh ) ; \
+	 ( cd create-119.0.6026.1-target-x86_64-patch       ; ./create.patch.sh ) ; \
+	 echo -e "\n"
+
+download_clean:
+	@rm -f $(patches)
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-cross-compile.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/src/build/toolchain/linux/unbundle/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/src/build/toolchain/linux/unbundle/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/src/build/toolchain/linux/unbundle/BUILD.gn	(revision 192)
@@ -0,0 +1,41 @@
+# Copyright 2017 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/toolchain/gcc_toolchain.gni")
+
+gcc_toolchain("default") {
+  cc = getenv("CC")
+  cxx = getenv("CXX")
+  ar = getenv("AR")
+  nm = getenv("NM")
+  ld = cxx
+
+  extra_cflags = getenv("CFLAGS")
+  extra_cppflags = getenv("CPPFLAGS")
+  extra_cxxflags = getenv("CXXFLAGS")
+  extra_ldflags = getenv("LDFLAGS")
+
+  toolchain_args = {
+    current_cpu = current_cpu
+    current_os = current_os
+  }
+}
+
+gcc_toolchain("host") {
+  cc = getenv("BUILD_CC")
+  cxx = getenv("BUILD_CXX")
+  ar = getenv("BUILD_AR")
+  nm = getenv("BUILD_NM")
+  ld = cxx
+
+  extra_cflags = getenv("BUILD_CFLAGS")
+  extra_cppflags = getenv("BUILD_CPPFLAGS")
+  extra_cxxflags = getenv("BUILD_CXXFLAGS")
+  extra_ldflags = getenv("BUILD_LDFLAGS")
+
+  toolchain_args = {
+    current_cpu = host_cpu
+    current_os = host_os
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/src-orig/build/toolchain/linux/unbundle/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/src-orig/build/toolchain/linux/unbundle/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-cross-compile-patch/src-orig/build/toolchain/linux/unbundle/BUILD.gn	(revision 192)
@@ -0,0 +1,41 @@
+# Copyright 2017 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/toolchain/gcc_toolchain.gni")
+
+gcc_toolchain("default") {
+  cc = getenv("CC")
+  cxx = getenv("CXX")
+  ar = getenv("AR")
+  nm = getenv("NM")
+  ld = cxx
+
+  extra_cflags = getenv("CFLAGS")
+  extra_cppflags = getenv("CPPFLAGS")
+  extra_cxxflags = getenv("CXXFLAGS")
+  extra_ldflags = getenv("LDFLAGS")
+
+  toolchain_args = {
+    current_cpu = current_cpu
+    current_os = current_os
+  }
+}
+
+gcc_toolchain("host") {
+  cc = getenv("BUILD_CC")
+  cxx = getenv("BUILD_CXX")
+  ar = getenv("BUILD_AR")
+  nm = getenv("BUILD_NM")
+  ld = cxx
+
+  extra_cflags = getenv("BUILD_CFLAGS")
+  extra_cppflags = getenv("BUILD_CPPFLAGS")
+  extra_cxxflags = getenv("BUILD_CXXFLAGS")
+  extra_ldflags = getenv("BUILD_LDFLAGS")
+
+  toolchain_args = {
+    current_cpu = current_cpu
+    current_os = current_os
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-dangling-gsl.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/src/ui/accessibility/platform/ax_platform_node_auralinux.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/src/ui/accessibility/platform/ax_platform_node_auralinux.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/src/ui/accessibility/platform/ax_platform_node_auralinux.cc	(revision 192)
@@ -0,0 +1,5095 @@
+// Copyright 2017 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/accessibility/platform/ax_platform_node_auralinux.h"
+#include "base/memory/raw_ptr.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <algorithm>
+#include <memory>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/debug/leak_annotations.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/no_destructor.h"
+#include "base/ranges/algorithm.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/sys_string_conversions.h"
+#include "base/strings/utf_string_conversion_utils.h"
+#include "base/strings/utf_string_conversions.h"
+#include "build/build_config.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
+#include "ui/accessibility/ax_action_data.h"
+#include "ui/accessibility/ax_enum_util.h"
+#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/accessibility/ax_node_data.h"
+#include "ui/accessibility/ax_role_properties.h"
+#include "ui/accessibility/ax_selection.h"
+#include "ui/accessibility/platform/atk_util_auralinux.h"
+#include "ui/accessibility/platform/ax_platform_atk_hyperlink.h"
+#include "ui/accessibility/platform/ax_platform_node_delegate.h"
+#include "ui/accessibility/platform/ax_platform_text_boundary.h"
+#include "ui/accessibility/platform/child_iterator.h"
+#include "ui/gfx/geometry/rect_conversions.h"
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 10, 0)
+#define ATK_210
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 12, 0)
+#define ATK_212
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 16, 0)
+#define ATK_216
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 26, 0)
+#define ATK_226
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 30, 0)
+#define ATK_230
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 32, 0)
+#define ATK_232
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 34, 0)
+#define ATK_234
+#endif
+
+namespace ui {
+
+namespace {
+
+// IMPORTANT!
+// These values are written to logs.  Do not renumber or delete
+// existing items; add new entries to the end of the list.
+enum class UmaAtkApi {
+  kGetName = 0,
+  kGetDescription = 1,
+  kGetNChildren = 2,
+  kRefChild = 3,
+  kGetIndexInParent = 4,
+  kGetParent = 5,
+  kRefRelationSet = 6,
+  kGetAttributes = 7,
+  kGetRole = 8,
+  kRefStateSet = 9,
+  // This must always be the last enum. It's okay for its value to
+  // increase, but none of the other enum values may change.
+  kMaxValue = kRefStateSet,
+};
+
+void RecordAccessibilityAtkApi(UmaAtkApi enum_value) {
+  UMA_HISTOGRAM_ENUMERATION("Accessibility.ATK-APIs", enum_value);
+}
+
+// When accepting input from clients calling the API, an ATK character offset
+// of -1 can often represent the length of the string.
+static const int kStringLengthOffset = -1;
+
+// We must forward declare this because it is used by the traditional GObject
+// type manipulation macros.
+namespace atk_object {
+GType GetType();
+}  // namespace atk_object
+
+//
+// ax_platform_node_auralinux AtkObject definition and implementation.
+//
+#define AX_PLATFORM_NODE_AURALINUX_TYPE (atk_object::GetType())
+#define AX_PLATFORM_NODE_AURALINUX(obj)                               \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), AX_PLATFORM_NODE_AURALINUX_TYPE, \
+                              AXPlatformNodeAuraLinuxObject))
+#define AX_PLATFORM_NODE_AURALINUX_CLASS(klass)                      \
+  (G_TYPE_CHECK_CLASS_CAST((klass), AX_PLATFORM_NODE_AURALINUX_TYPE, \
+                           AXPlatformNodeAuraLinuxClass))
+#define IS_AX_PLATFORM_NODE_AURALINUX(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), AX_PLATFORM_NODE_AURALINUX_TYPE))
+#define IS_AX_PLATFORM_NODE_AURALINUX_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), AX_PLATFORM_NODE_AURALINUX_TYPE))
+#define AX_PLATFORM_NODE_AURALINUX_GET_CLASS(obj)                    \
+  (G_TYPE_INSTANCE_GET_CLASS((obj), AX_PLATFORM_NODE_AURALINUX_TYPE, \
+                             AXPlatformNodeAuraLinuxClass))
+
+typedef struct _AXPlatformNodeAuraLinuxObject AXPlatformNodeAuraLinuxObject;
+typedef struct _AXPlatformNodeAuraLinuxClass AXPlatformNodeAuraLinuxClass;
+
+struct _AXPlatformNodeAuraLinuxObject {
+  AtkObject parent;
+  raw_ptr<AXPlatformNodeAuraLinux> m_object;
+};
+
+struct _AXPlatformNodeAuraLinuxClass {
+  AtkObjectClass parent_class;
+};
+
+// The root-level Application object that's the parent of all top-level windows.
+AXPlatformNode* g_root_application = nullptr;
+
+// The last AtkObject with keyboard focus. Tracking this is required to emit the
+// ATK_STATE_FOCUSED change to false.
+AtkObject* g_current_focused = nullptr;
+
+// The last object which was selected. Tracking this is required because
+// widgets in the browser UI only emit notifications upon becoming selected,
+// but clients also expect notifications when items become unselected.
+AXPlatformNodeAuraLinux* g_current_selected = nullptr;
+
+// The AtkObject with role=ATK_ROLE_FRAME that represents the toplevel desktop
+// window with focus. If this window is not one of our windows, this value
+// should be null. This is a weak pointer as well, so its value will also be
+// null if if the AtkObject is destroyed.
+AtkObject* g_active_top_level_frame = nullptr;
+
+AtkObject* g_active_views_dialog = nullptr;
+
+#if defined(ATK_216)
+constexpr AtkRole kStaticRole = ATK_ROLE_STATIC;
+constexpr AtkRole kSubscriptRole = ATK_ROLE_SUBSCRIPT;
+constexpr AtkRole kSuperscriptRole = ATK_ROLE_SUPERSCRIPT;
+#else
+constexpr AtkRole kStaticRole = ATK_ROLE_TEXT;
+constexpr AtkRole kSubscriptRole = ATK_ROLE_TEXT;
+constexpr AtkRole kSuperscriptRole = ATK_ROLE_TEXT;
+#endif
+
+#if defined(ATK_226)
+constexpr AtkRole kAtkFootnoteRole = ATK_ROLE_FOOTNOTE;
+#else
+constexpr AtkRole kAtkFootnoteRole = ATK_ROLE_LIST_ITEM;
+#endif
+
+#if defined(ATK_234)
+constexpr AtkRole kAtkRoleContentDeletion = ATK_ROLE_CONTENT_DELETION;
+constexpr AtkRole kAtkRoleContentInsertion = ATK_ROLE_CONTENT_INSERTION;
+#else
+constexpr AtkRole kAtkRoleContentDeletion = ATK_ROLE_SECTION;
+constexpr AtkRole kAtkRoleContentInsertion = ATK_ROLE_SECTION;
+#endif
+
+using GetTypeFunc = GType (*)();
+using GetColumnHeaderCellsFunc = GPtrArray* (*)(AtkTableCell* cell);
+using GetRowHeaderCellsFunc = GPtrArray* (*)(AtkTableCell* cell);
+using GetRowColumnSpanFunc = bool (*)(AtkTableCell* cell,
+                                      gint* row,
+                                      gint* column,
+                                      gint* row_span,
+                                      gint* col_span);
+
+static GetTypeFunc g_atk_table_cell_get_type;
+static GetColumnHeaderCellsFunc g_atk_table_cell_get_column_header_cells;
+static GetRowHeaderCellsFunc g_atk_table_cell_get_row_header_cells;
+static GetRowColumnSpanFunc g_atk_table_cell_get_row_column_span;
+
+// The ATK API often requires pointers to be used as out arguments, while
+// allowing for those pointers to be null if the caller is not interested in
+// the value. This function is a simpler helper to avoid continually checking
+// for null and to help prevent forgetting to check for null.
+void SetIntPointerValueIfNotNull(int* pointer, int value) {
+  if (pointer)
+    *pointer = value;
+}
+
+#if defined(ATK_230)
+bool SupportsAtkComponentScrollingInterface() {
+  return dlsym(RTLD_DEFAULT, "atk_component_scroll_to_point");
+}
+#endif
+
+#if defined(ATK_232)
+bool SupportsAtkTextScrollingInterface() {
+  return dlsym(RTLD_DEFAULT, "atk_text_scroll_substring_to_point");
+}
+#endif
+
+AtkObject* FindAtkObjectParentFrame(AtkObject* atk_object) {
+  AXPlatformNodeAuraLinux* node =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  while (node) {
+    if (node->GetAtkRole() == ATK_ROLE_FRAME)
+      return node->GetNativeViewAccessible();
+    node = AXPlatformNodeAuraLinux::FromAtkObject(node->GetParent());
+  }
+  return nullptr;
+}
+
+AtkObject* FindAtkObjectToplevelParentDocument(AtkObject* atk_object) {
+  AXPlatformNodeAuraLinux* node =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  AtkObject* toplevel_document = nullptr;
+  while (node) {
+    if (node->GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
+      toplevel_document = node->GetNativeViewAccessible();
+    node = AXPlatformNodeAuraLinux::FromAtkObject(node->GetParent());
+  }
+  return toplevel_document;
+}
+
+bool IsFrameAncestorOfAtkObject(AtkObject* frame, AtkObject* atk_object) {
+  AtkObject* current_frame = FindAtkObjectParentFrame(atk_object);
+  while (current_frame) {
+    if (current_frame == frame)
+      return true;
+    AXPlatformNodeAuraLinux* frame_node =
+        AXPlatformNodeAuraLinux::FromAtkObject(current_frame);
+    current_frame = FindAtkObjectParentFrame(frame_node->GetParent());
+  }
+  return false;
+}
+
+// Returns a stack of AtkObjects of activated popup menus. Since each popup
+// menu and submenu has its own native window, we want to properly manage the
+// activated state for their containing frames.
+std::vector<AtkObject*>& GetActiveMenus() {
+  static base::NoDestructor<std::vector<AtkObject*>> active_menus;
+  return *active_menus;
+}
+
+std::map<AtkObject*, FindInPageResultInfo>& GetActiveFindInPageResults() {
+  static base::NoDestructor<std::map<AtkObject*, FindInPageResultInfo>>
+      active_results;
+  return *active_results;
+}
+
+// The currently active frame is g_active_top_level_frame, unless there is an
+// active menu. If there is an active menu the parent frame of the
+// most-recently opened active menu should be the currently active frame.
+AtkObject* ComputeActiveTopLevelFrame() {
+  if (!GetActiveMenus().empty())
+    return FindAtkObjectParentFrame(GetActiveMenus().back());
+  return g_active_top_level_frame;
+}
+
+const char* GetUniqueAccessibilityGTypeName(
+    ImplementedAtkInterfaces interface_mask) {
+  // 37 characters is enough for "AXPlatformNodeAuraLinux%x" with any integer
+  // value.
+  static char name[37];
+  snprintf(name, sizeof(name), "AXPlatformNodeAuraLinux%x",
+           interface_mask.value());
+  return name;
+}
+
+void SetWeakGPtrToAtkObject(AtkObject** weak_pointer, AtkObject* new_value) {
+  DCHECK(weak_pointer);
+  if (*weak_pointer == new_value)
+    return;
+
+  if (*weak_pointer) {
+    g_object_remove_weak_pointer(G_OBJECT(*weak_pointer),
+                                 reinterpret_cast<void**>(weak_pointer));
+  }
+
+  *weak_pointer = new_value;
+
+  if (new_value) {
+    g_object_add_weak_pointer(G_OBJECT(new_value),
+                              reinterpret_cast<void**>(weak_pointer));
+  }
+}
+
+void SetActiveTopLevelFrame(AtkObject* new_top_level_frame) {
+  SetWeakGPtrToAtkObject(&g_active_top_level_frame, new_top_level_frame);
+}
+
+AXCoordinateSystem AtkCoordTypeToAXCoordinateSystem(
+    AtkCoordType coordinate_type) {
+  switch (coordinate_type) {
+    case ATK_XY_SCREEN:
+      return AXCoordinateSystem::kScreenDIPs;
+    case ATK_XY_WINDOW:
+      return AXCoordinateSystem::kRootFrame;
+#if defined(ATK_230)
+    case ATK_XY_PARENT:
+      // AXCoordinateSystem does not support parent coordinates.
+      NOTIMPLEMENTED();
+      return AXCoordinateSystem::kFrame;
+#endif
+    default:
+      return AXCoordinateSystem::kScreenDIPs;
+  }
+}
+
+const char* BuildDescriptionFromHeaders(AXPlatformNodeDelegate* delegate,
+                                        const std::vector<int32_t>& ids) {
+  std::vector<std::string> names;
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* header = delegate->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_header = header->GetNativeViewAccessible()) {
+        if (const gchar* name = atk_object_get_name(atk_header))
+          names.push_back(name);
+      }
+    }
+  }
+
+  std::string result = base::JoinString(names, " ");
+
+#if defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
+  // http://crbug.com/982839
+  // atk_table_get_column_description and atk_table_get_row_description return
+  // const gchar*, which suggests the caller does not gain ownership of the
+  // returned string. The g_strdup below causes a new allocation, which does not
+  // fit that pattern and causes a leak in tests.
+  ScopedLeakSanitizerDisabler lsan_disabler;
+#endif
+
+  return g_strdup(result.c_str());
+}
+
+AtkAttributeSet* PrependAtkAttributeToAtkAttributeSet(
+    const char* name,
+    const char* value,
+    AtkAttributeSet* attribute_set) {
+  AtkAttribute* attribute =
+      static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
+  attribute->name = g_strdup(name);
+  attribute->value = g_strdup(value);
+  return g_slist_prepend(attribute_set, attribute);
+}
+
+void PrependTextAttributeToSet(const std::string& attribute,
+                               const std::string& value,
+                               AtkAttributeSet** attributes) {
+  DCHECK(attributes);
+
+  AtkAttribute* new_attribute =
+      static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
+  new_attribute->name = g_strdup(attribute.c_str());
+  new_attribute->value = g_strdup(value.c_str());
+  *attributes = g_slist_prepend(*attributes, new_attribute);
+}
+
+void PrependAtkTextAttributeToSet(const AtkTextAttribute attribute,
+                                  const std::string& value,
+                                  AtkAttributeSet** attributes) {
+  PrependTextAttributeToSet(atk_text_attribute_get_name(attribute), value,
+                            attributes);
+}
+
+std::string ToAtkTextAttributeColor(const std::string color) {
+  // The platform-independent color string is in the form "rgb(r, g, b)",
+  // but ATK expects a string like "r, g, b". We convert the string here
+  // by stripping away the unnecessary characters.
+  DCHECK(base::StartsWith(color, "rgb(", base::CompareCase::INSENSITIVE_ASCII));
+  DCHECK(base::EndsWith(color, ")", base::CompareCase::INSENSITIVE_ASCII));
+  return color.substr(4, color.length() - 5);
+}
+
+AtkAttributeSet* ToAtkAttributeSet(const TextAttributeList& attributes) {
+  AtkAttributeSet* copied_attributes = nullptr;
+  for (const auto& attribute : attributes) {
+    if (attribute.first == "background-color") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_BG_COLOR,
+                                   ToAtkTextAttributeColor(attribute.second),
+                                   &copied_attributes);
+    } else if (attribute.first == "color") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_FG_COLOR,
+                                   ToAtkTextAttributeColor(attribute.second),
+                                   &copied_attributes);
+    } else if (attribute.first == "font-family") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_FAMILY_NAME, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "font-size") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_SIZE, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "font-weight" && attribute.second == "bold") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_WEIGHT, "700",
+                                   &copied_attributes);
+    } else if (attribute.first == "font-style") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_STYLE, "italic",
+                                   &copied_attributes);
+    } else if (attribute.first == "text-line-through-style") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_STRIKETHROUGH, "true",
+                                   &copied_attributes);
+    } else if (attribute.first == "text-underline-style") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_UNDERLINE, "single",
+                                   &copied_attributes);
+    } else if (attribute.first == "invalid") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_INVALID, attribute.second,
+                                   &copied_attributes);
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_UNDERLINE, "error",
+                                   &copied_attributes);
+    } else if (attribute.first == "language") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_LANGUAGE, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "writing-mode") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_DIRECTION, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "text-position") {
+      PrependTextAttributeToSet(attribute.first, attribute.second,
+                                &copied_attributes);
+    }
+  }
+
+  return g_slist_reverse(copied_attributes);
+}
+
+namespace atk_component {
+
+void GetExtents(AtkComponent* atk_component,
+                gint* x,
+                gint* y,
+                gint* width,
+                gint* height,
+                AtkCoordType coord_type) {
+  g_return_if_fail(ATK_IS_COMPONENT(atk_component));
+
+  if (x)
+    *x = 0;
+  if (y)
+    *y = 0;
+  if (width)
+    *width = 0;
+  if (height)
+    *height = 0;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetExtents(x, y, width, height, coord_type);
+}
+
+void GetPosition(AtkComponent* atk_component,
+                 gint* x,
+                 gint* y,
+                 AtkCoordType coord_type) {
+  g_return_if_fail(ATK_IS_COMPONENT(atk_component));
+
+  if (x)
+    *x = 0;
+  if (y)
+    *y = 0;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetPosition(x, y, coord_type);
+}
+
+void GetSize(AtkComponent* atk_component, gint* width, gint* height) {
+  g_return_if_fail(ATK_IS_COMPONENT(atk_component));
+
+  if (width)
+    *width = 0;
+  if (height)
+    *height = 0;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetSize(width, height);
+}
+
+AtkObject* RefAccesibleAtPoint(AtkComponent* atk_component,
+                               gint x,
+                               gint y,
+                               AtkCoordType coord_type) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), nullptr);
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  AtkObject* result = obj->HitTestSync(x, y, coord_type);
+  if (result)
+    g_object_ref(result);
+  return result;
+}
+
+gboolean GrabFocus(AtkComponent* atk_component) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return FALSE;
+
+  return obj->GrabFocus();
+}
+
+#if defined(ATK_230)
+gboolean ScrollTo(AtkComponent* atk_component, AtkScrollType scroll_type) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_component));
+  if (!obj)
+    return FALSE;
+
+  obj->ScrollNodeIntoView(scroll_type);
+  return TRUE;
+}
+
+gboolean ScrollToPoint(AtkComponent* atk_component,
+                       AtkCoordType atk_coord_type,
+                       gint x,
+                       gint y) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_component));
+  if (!obj)
+    return FALSE;
+
+  obj->ScrollToPoint(atk_coord_type, x, y);
+  return TRUE;
+}
+#endif
+
+void Init(AtkComponentIface* iface) {
+  iface->get_extents = GetExtents;
+  iface->get_position = GetPosition;
+  iface->get_size = GetSize;
+  iface->ref_accessible_at_point = RefAccesibleAtPoint;
+  iface->grab_focus = GrabFocus;
+#if defined(ATK_230)
+  if (SupportsAtkComponentScrollingInterface()) {
+    iface->scroll_to = ScrollTo;
+    iface->scroll_to_point = ScrollToPoint;
+  }
+#endif
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_component
+
+namespace atk_action {
+
+gboolean DoAction(AtkAction* atk_action, gint index) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), FALSE);
+  g_return_val_if_fail(index >= 0, FALSE);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return FALSE;
+
+  const std::vector<ax::mojom::Action> actions =
+      obj->GetDelegate()->GetSupportedActions();
+  g_return_val_if_fail(index < static_cast<gint>(actions.size()), FALSE);
+
+  AXActionData data;
+  data.action = actions[index];
+  return obj->GetDelegate()->AccessibilityPerformAction(data);
+}
+
+gint GetNActions(AtkAction* atk_action) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  return static_cast<gint>(obj->GetDelegate()->GetSupportedActions().size());
+}
+
+const gchar* GetDescription(AtkAction*, gint) {
+  // Not implemented. Right now Orca does not provide this and
+  // Chromium is not providing a string for the action description.
+  return nullptr;
+}
+
+const gchar* GetName(AtkAction* atk_action, gint index) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  const std::vector<ax::mojom::Action> actions =
+      obj->GetDelegate()->GetSupportedActions();
+  g_return_val_if_fail(index < static_cast<gint>(actions.size()), nullptr);
+
+  if (index == 0 && obj->GetDelegate()->HasDefaultActionVerb()) {
+    // If there is a default action, it will always be at index 0.
+    return obj->GetDefaultActionName();
+  }
+  return ToString(actions[index]);
+}
+
+const gchar* GetKeybinding(AtkAction* atk_action, gint index) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  const std::vector<ax::mojom::Action> actions =
+      obj->GetDelegate()->GetSupportedActions();
+  g_return_val_if_fail(index < static_cast<gint>(actions.size()), nullptr);
+
+  if (index == 0 && obj->GetDelegate()->HasDefaultActionVerb()) {
+    // If there is a default action, it will always be at index 0. Only the
+    // default action has a key binding.
+    return obj->GetStringAttribute(ax::mojom::StringAttribute::kAccessKey)
+        .c_str();
+  }
+  return nullptr;
+}
+
+void Init(AtkActionIface* iface) {
+  iface->do_action = DoAction;
+  iface->get_n_actions = GetNActions;
+  iface->get_description = GetDescription;
+  iface->get_name = GetName;
+  iface->get_keybinding = GetKeybinding;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_action
+
+namespace atk_document {
+
+const gchar* GetDocumentAttributeValue(AtkDocument* atk_doc,
+                                       const gchar* attribute) {
+  g_return_val_if_fail(ATK_IS_DOCUMENT(atk_doc), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_doc);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetDocumentAttributeValue(attribute);
+}
+
+AtkAttributeSet* GetDocumentAttributes(AtkDocument* atk_doc) {
+  g_return_val_if_fail(ATK_IS_DOCUMENT(atk_doc), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_doc);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetDocumentAttributes();
+}
+
+void Init(AtkDocumentIface* iface) {
+  iface->get_document_attribute_value = GetDocumentAttributeValue;
+  iface->get_document_attributes = GetDocumentAttributes;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_document
+
+namespace atk_image {
+
+void GetImagePosition(AtkImage* atk_img,
+                      gint* x,
+                      gint* y,
+                      AtkCoordType coord_type) {
+  g_return_if_fail(ATK_IMAGE(atk_img));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_img);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetPosition(x, y, coord_type);
+}
+
+const gchar* GetImageDescription(AtkImage* atk_img) {
+  g_return_val_if_fail(ATK_IMAGE(atk_img), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_img);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetStringAttribute(ax::mojom::StringAttribute::kDescription)
+      .c_str();
+}
+
+void GetImageSize(AtkImage* atk_img, gint* width, gint* height) {
+  g_return_if_fail(ATK_IMAGE(atk_img));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_img);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetSize(width, height);
+}
+
+void Init(AtkImageIface* iface) {
+  iface->get_image_position = GetImagePosition;
+  iface->get_image_description = GetImageDescription;
+  iface->get_image_size = GetImageSize;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_image
+
+namespace atk_value {
+
+void GetCurrentValue(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kValueForRange,
+                                 value);
+}
+
+void GetMinimumValue(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kMinValueForRange,
+                                 value);
+}
+
+void GetMaximumValue(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kMaxValueForRange,
+                                 value);
+}
+
+void GetMinimumIncrement(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kStepValueForRange,
+                                 value);
+}
+
+gboolean SetCurrentValue(AtkValue* atk_value, const GValue* value) {
+  g_return_val_if_fail(ATK_IS_VALUE(atk_value), FALSE);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return FALSE;
+
+  std::string new_value;
+  switch (G_VALUE_TYPE(value)) {
+    case G_TYPE_FLOAT:
+      new_value = base::NumberToString(g_value_get_float(value));
+      break;
+    case G_TYPE_INT:
+      new_value = base::NumberToString(g_value_get_int(value));
+      break;
+    case G_TYPE_INT64:
+      new_value = base::NumberToString(g_value_get_int64(value));
+      break;
+    case G_TYPE_STRING:
+      new_value = g_value_get_string(value);
+      break;
+    default:
+      return FALSE;
+  }
+
+  AXActionData data;
+  data.action = ax::mojom::Action::kSetValue;
+  data.value = new_value;
+  obj->GetDelegate()->AccessibilityPerformAction(data);
+  return TRUE;
+}
+
+void Init(AtkValueIface* iface) {
+  iface->get_current_value = GetCurrentValue;
+  iface->get_maximum_value = GetMaximumValue;
+  iface->get_minimum_value = GetMinimumValue;
+  iface->get_minimum_increment = GetMinimumIncrement;
+  iface->set_current_value = SetCurrentValue;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_value
+
+namespace atk_hyperlink {
+
+AtkHyperlink* GetHyperlink(AtkHyperlinkImpl* atk_hyperlink_impl) {
+  g_return_val_if_fail(ATK_HYPERLINK_IMPL(atk_hyperlink_impl), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_hyperlink_impl);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  AtkHyperlink* atk_hyperlink = obj->GetAtkHyperlink();
+  g_object_ref(atk_hyperlink);
+
+  return atk_hyperlink;
+}
+
+void Init(AtkHyperlinkImplIface* iface) {
+  iface->get_hyperlink = GetHyperlink;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_hyperlink
+
+namespace atk_hypertext {
+
+AtkHyperlink* GetLink(AtkHypertext* hypertext, int index) {
+  g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
+  if (!obj)
+    return nullptr;
+
+  const AXLegacyHypertext& ax_hypertext = obj->GetAXHypertext();
+  if (index >= static_cast<int>(ax_hypertext.hyperlinks.size()) || index < 0)
+    return nullptr;
+
+  int32_t id = ax_hypertext.hyperlinks[index];
+  auto* link = static_cast<AXPlatformNodeAuraLinux*>(
+      AXPlatformNodeBase::GetFromUniqueId(id));
+  if (!link)
+    return nullptr;
+
+  return link->GetAtkHyperlink();
+}
+
+int GetNLinks(AtkHypertext* hypertext) {
+  g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
+  return obj ? obj->GetAXHypertext().hyperlinks.size() : 0;
+}
+
+int GetLinkIndex(AtkHypertext* hypertext, int char_index) {
+  g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
+  if (!obj)
+    return -1;
+
+  auto it = obj->GetAXHypertext().hyperlink_offset_to_index.find(char_index);
+  if (it == obj->GetAXHypertext().hyperlink_offset_to_index.end())
+    return -1;
+  return it->second;
+}
+
+void Init(AtkHypertextIface* iface) {
+  iface->get_link = GetLink;
+  iface->get_n_links = GetNLinks;
+  iface->get_link_index = GetLinkIndex;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_hypertext
+
+namespace atk_text {
+
+gchar* GetText(AtkText* atk_text, gint start_offset, gint end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  std::u16string text = obj->GetHypertext();
+
+  start_offset = obj->UnicodeToUTF16OffsetInText(start_offset);
+  if (start_offset < 0 || start_offset >= static_cast<int>(text.size()))
+    return nullptr;
+
+  if (end_offset < 0) {
+    end_offset = text.size();
+  } else {
+    end_offset = obj->UnicodeToUTF16OffsetInText(end_offset);
+    end_offset =
+        std::clamp(static_cast<int>(text.size()), start_offset, end_offset);
+  }
+
+  DCHECK_GE(start_offset, 0);
+  DCHECK_GE(end_offset, start_offset);
+
+  const auto ret_substr = base::UTF16ToUTF8(text.substr(start_offset, end_offset - start_offset));
+  return g_strdup(ret_substr.c_str());
+}
+
+gint GetCharacterCount(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  return obj->UTF16ToUnicodeOffsetInText(obj->GetHypertext().length());
+}
+
+gunichar GetCharacterAtOffset(AtkText* atk_text, int offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  std::u16string text = obj->GetHypertext();
+  size_t text_length = text.length();
+
+  offset = obj->UnicodeToUTF16OffsetInText(offset);
+  offset = std::max(offset, 0);
+  size_t limited_offset = std::min(static_cast<size_t>(offset), text_length);
+
+  base_icu::UChar32 code_point;
+  base::ReadUnicodeCharacter(text.c_str(), text_length + 1, &limited_offset,
+                             &code_point);
+  return code_point;
+}
+
+gint GetOffsetAtPoint(AtkText* text, gint x, gint y, AtkCoordType coords) {
+  g_return_val_if_fail(ATK_IS_TEXT(text), -1);
+
+  AtkObject* atk_object = ATK_OBJECT(text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return -1;
+
+  return obj->GetTextOffsetAtPoint(x, y, coords);
+}
+
+// This function returns a single character as a UTF-8 encoded C string because
+// the character may be encoded into more than one byte.
+char* GetCharacter(AtkText* atk_text,
+                   int offset,
+                   int* start_offset,
+                   int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  *start_offset = -1;
+  *end_offset = -1;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (offset < 0 || offset >= GetCharacterCount(atk_text))
+    return nullptr;
+
+  char* text = GetText(atk_text, offset, offset + 1);
+  if (!text)
+    return nullptr;
+
+  *start_offset = offset;
+  *end_offset = offset + 1;
+  return text;
+}
+
+char* GetTextWithBoundaryType(AtkText* atk_text,
+                              int offset,
+                              ax::mojom::TextBoundary boundary,
+                              int* start_offset_ptr,
+                              int* end_offset_ptr) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (offset < 0 || offset >= atk_text_get_character_count(atk_text))
+    return nullptr;
+
+  // The offset that we receive from the API is a Unicode character offset.
+  // Since we calculate boundaries in terms of UTF-16 code point offsets, we
+  // need to convert this input value.
+  offset = obj->UnicodeToUTF16OffsetInText(offset);
+
+  int start_offset = obj->FindTextBoundary(
+      boundary, offset, ax::mojom::MoveDirection::kBackward,
+      ax::mojom::TextAffinity::kDownstream);
+  int end_offset = obj->FindTextBoundary(boundary, offset,
+                                         ax::mojom::MoveDirection::kForward,
+                                         ax::mojom::TextAffinity::kDownstream);
+  if (start_offset < 0 || end_offset < 0)
+    return nullptr;
+
+  DCHECK_LE(start_offset, end_offset)
+      << "Start offset should be less than or equal the end offset.";
+
+  // The ATK API is also expecting Unicode character offsets as output
+  // values.
+  *start_offset_ptr = obj->UTF16ToUnicodeOffsetInText(start_offset);
+  *end_offset_ptr = obj->UTF16ToUnicodeOffsetInText(end_offset);
+
+  std::u16string text = obj->GetHypertext();
+  DCHECK_LE(end_offset, static_cast<int>(text.size()));
+
+  std::u16string substr = text.substr(start_offset, end_offset - start_offset);
+  const auto ret_substr = base::UTF16ToUTF8(substr);
+  return g_strdup(ret_substr.c_str());
+}
+
+char* GetTextAtOffset(AtkText* atk_text,
+                      int offset,
+                      AtkTextBoundary atk_boundary,
+                      int* start_offset,
+                      int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+  ax::mojom::TextBoundary boundary = FromAtkTextBoundary(atk_boundary);
+  return GetTextWithBoundaryType(atk_text, offset, boundary, start_offset,
+                                 end_offset);
+}
+
+char* GetTextAfterOffset(AtkText* atk_text,
+                         int offset,
+                         AtkTextBoundary boundary,
+                         int* start_offset,
+                         int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  if (boundary != ATK_TEXT_BOUNDARY_CHAR) {
+    *start_offset = -1;
+    *end_offset = -1;
+    return nullptr;
+  }
+
+  // ATK does not offer support for the special negative index and we don't
+  // want to do arithmetic on that value below.
+  if (offset == kStringLengthOffset)
+    return nullptr;
+
+  return GetCharacter(atk_text, offset + 1, start_offset, end_offset);
+}
+
+char* GetTextBeforeOffset(AtkText* atk_text,
+                          int offset,
+                          AtkTextBoundary boundary,
+                          int* start_offset,
+                          int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  if (boundary != ATK_TEXT_BOUNDARY_CHAR) {
+    *start_offset = -1;
+    *end_offset = -1;
+    return nullptr;
+  }
+
+  // ATK does not offer support for the special negative index and we don't
+  // want to do arithmetic on that value below.
+  if (offset == kStringLengthOffset)
+    return nullptr;
+
+  return GetCharacter(atk_text, offset - 1, start_offset, end_offset);
+}
+
+gint GetCaretOffset(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), -1);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return -1;
+  return obj->GetCaretOffset();
+}
+
+gboolean SetCaretOffset(AtkText* atk_text, gint offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+  if (!obj->SetCaretOffset(offset))
+    return FALSE;
+
+  // Orca expects atk_text_set_caret_offset to either focus the target element
+  // or set the sequential focus navigation starting point there.
+  int utf16_offset = obj->UnicodeToUTF16OffsetInText(offset);
+  obj->GrabFocusOrSetSequentialFocusNavigationStartingPointAtOffset(
+      utf16_offset);
+
+  return TRUE;
+}
+
+int GetNSelections(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return 0;
+
+  if (obj->HasSelection())
+    return 1;
+
+  absl::optional<FindInPageResultInfo> result =
+      obj->GetSelectionOffsetsFromFindInPage();
+  if (result.has_value() && result->node == ATK_OBJECT(atk_text))
+    return 1;
+
+  return 0;
+}
+
+gchar* GetSelection(AtkText* atk_text,
+                    int selection_num,
+                    int* start_offset,
+                    int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return nullptr;
+  if (selection_num != 0)
+    return nullptr;
+
+  return obj->GetSelectionWithText(start_offset, end_offset);
+}
+
+gboolean RemoveSelection(AtkText* atk_text, int selection_num) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  if (selection_num != 0)
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  // Simply collapse the selection to the position of the caret if a caret is
+  // visible, otherwise set the selection to 0.
+  int selection_end = obj->UTF16ToUnicodeOffsetInText(
+      obj->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd));
+  return SetCaretOffset(atk_text, selection_end);
+}
+
+gboolean SetSelection(AtkText* atk_text,
+                      int selection_num,
+                      int start_offset,
+                      int end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  if (selection_num != 0)
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  return obj->SetTextSelectionForAtkText(start_offset, end_offset);
+}
+
+gboolean AddSelection(AtkText* atk_text, int start_offset, int end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  // We only support one selection.
+  return SetSelection(atk_text, 0, start_offset, end_offset);
+}
+
+#if defined(ATK_210)
+char* GetStringAtOffset(AtkText* atk_text,
+                        int offset,
+                        AtkTextGranularity atk_granularity,
+                        int* start_offset,
+                        int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  *start_offset = -1;
+  *end_offset = -1;
+
+  ax::mojom::TextBoundary boundary = FromAtkTextGranularity(atk_granularity);
+  return GetTextWithBoundaryType(atk_text, offset, boundary, start_offset,
+                                 end_offset);
+}
+#endif
+
+#if defined(ATK_230)
+gfx::Rect GetUnclippedParentHypertextRangeBoundsRect(
+    AXPlatformNodeDelegate* ax_platform_node_delegate,
+    const int start_offset,
+    const int end_offset) {
+  const AXPlatformNode* parent_platform_node =
+      AXPlatformNode::FromNativeViewAccessible(
+          ax_platform_node_delegate->GetParent());
+  if (!parent_platform_node)
+    return gfx::Rect();
+
+  const AXPlatformNodeDelegate* parent_ax_platform_node_delegate =
+      parent_platform_node->GetDelegate();
+  if (!parent_ax_platform_node_delegate)
+    return gfx::Rect();
+
+  return ax_platform_node_delegate->GetHypertextRangeBoundsRect(
+             start_offset, end_offset, AXCoordinateSystem::kRootFrame,
+             AXClippingBehavior::kUnclipped) -
+         parent_ax_platform_node_delegate
+             ->GetBoundsRect(AXCoordinateSystem::kRootFrame,
+                             AXClippingBehavior::kClipped)
+             .OffsetFromOrigin();
+}
+#endif
+
+void GetCharacterExtents(AtkText* atk_text,
+                         int offset,
+                         int* x,
+                         int* y,
+                         int* width,
+                         int* height,
+                         AtkCoordType coordinate_type) {
+  g_return_if_fail(ATK_IS_TEXT(atk_text));
+
+  gfx::Rect rect;
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (obj) {
+    switch (coordinate_type) {
+#if defined(ATK_230)
+      case ATK_XY_PARENT:
+        rect = GetUnclippedParentHypertextRangeBoundsRect(obj->GetDelegate(),
+                                                          offset, offset + 1);
+        break;
+#endif
+      default:
+        rect = obj->GetDelegate()->GetHypertextRangeBoundsRect(
+            obj->UnicodeToUTF16OffsetInText(offset),
+            obj->UnicodeToUTF16OffsetInText(offset + 1),
+            AtkCoordTypeToAXCoordinateSystem(coordinate_type),
+            AXClippingBehavior::kUnclipped);
+        break;
+    }
+  }
+
+  if (x)
+    *x = rect.x();
+  if (y)
+    *y = rect.y();
+  if (width)
+    *width = rect.width();
+  if (height)
+    *height = rect.height();
+}
+
+void GetRangeExtents(AtkText* atk_text,
+                     int start_offset,
+                     int end_offset,
+                     AtkCoordType coordinate_type,
+                     AtkTextRectangle* out_rectangle) {
+  g_return_if_fail(ATK_IS_TEXT(atk_text));
+
+  if (!out_rectangle)
+    return;
+
+  gfx::Rect rect;
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (obj) {
+    switch (coordinate_type) {
+#if defined(ATK_230)
+      case ATK_XY_PARENT:
+        rect = GetUnclippedParentHypertextRangeBoundsRect(
+            obj->GetDelegate(), start_offset, end_offset);
+        break;
+#endif
+      default:
+        rect = obj->GetDelegate()->GetHypertextRangeBoundsRect(
+            obj->UnicodeToUTF16OffsetInText(start_offset),
+            obj->UnicodeToUTF16OffsetInText(end_offset),
+            AtkCoordTypeToAXCoordinateSystem(coordinate_type),
+            AXClippingBehavior::kUnclipped);
+        break;
+    }
+  }
+
+  out_rectangle->x = rect.x();
+  out_rectangle->y = rect.y();
+  out_rectangle->width = rect.width();
+  out_rectangle->height = rect.height();
+}
+
+AtkAttributeSet* GetRunAttributes(AtkText* atk_text,
+                                  gint offset,
+                                  gint* start_offset,
+                                  gint* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  SetIntPointerValueIfNotNull(start_offset, -1);
+  SetIntPointerValueIfNotNull(end_offset, -1);
+
+  if (offset < 0 || offset > GetCharacterCount(atk_text))
+    return nullptr;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return ToAtkAttributeSet(
+      obj->GetTextAttributes(offset, start_offset, end_offset));
+}
+
+AtkAttributeSet* GetDefaultAttributes(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+  return ToAtkAttributeSet(obj->GetDefaultTextAttributes());
+}
+
+#if defined(ATK_232)
+gboolean ScrollSubstringTo(AtkText* atk_text,
+                           gint start_offset,
+                           gint end_offset,
+                           AtkScrollType scroll_type) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  return obj->ScrollSubstringIntoView(scroll_type, start_offset, end_offset);
+}
+
+gboolean ScrollSubstringToPoint(AtkText* atk_text,
+                                gint start_offset,
+                                gint end_offset,
+                                AtkCoordType atk_coord_type,
+                                gint x,
+                                gint y) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  return obj->ScrollSubstringToPoint(start_offset, end_offset, atk_coord_type,
+                                     x, y);
+}
+#endif  // ATK_232
+
+void Init(AtkTextIface* iface) {
+  iface->get_text = GetText;
+  iface->get_character_count = GetCharacterCount;
+  iface->get_character_at_offset = GetCharacterAtOffset;
+  iface->get_offset_at_point = GetOffsetAtPoint;
+  iface->get_text_after_offset = GetTextAfterOffset;
+  iface->get_text_before_offset = GetTextBeforeOffset;
+  iface->get_text_at_offset = GetTextAtOffset;
+  iface->get_caret_offset = GetCaretOffset;
+  iface->set_caret_offset = SetCaretOffset;
+  iface->get_character_extents = GetCharacterExtents;
+  iface->get_range_extents = GetRangeExtents;
+  iface->get_n_selections = GetNSelections;
+  iface->get_selection = GetSelection;
+  iface->add_selection = AddSelection;
+  iface->remove_selection = RemoveSelection;
+  iface->set_selection = SetSelection;
+
+  iface->get_run_attributes = GetRunAttributes;
+  iface->get_default_attributes = GetDefaultAttributes;
+
+#if defined(ATK_210)
+  iface->get_string_at_offset = GetStringAtOffset;
+#endif
+
+#if defined(ATK_232)
+  if (SupportsAtkTextScrollingInterface()) {
+    iface->scroll_substring_to = ScrollSubstringTo;
+    iface->scroll_substring_to_point = ScrollSubstringToPoint;
+  }
+#endif
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_text
+
+namespace atk_window {
+void Init(AtkWindowIface* iface) {}
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+}  // namespace atk_window
+
+namespace atk_selection {
+
+gboolean AddSelection(AtkSelection* selection, gint index) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+  if (index < 0 || static_cast<size_t>(index) >= obj->GetChildCount())
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* child =
+      AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(index));
+  if (!child)
+    return FALSE;
+
+  if (!child->SupportsSelectionWithAtkSelection())
+    return FALSE;
+
+  bool selected = child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+  if (selected)
+    return TRUE;
+
+  AXActionData data;
+  data.action = ax::mojom::Action::kDoDefault;
+  return child->GetDelegate()->AccessibilityPerformAction(data);
+}
+
+gboolean ClearSelection(AtkSelection* selection) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+
+  int child_count = obj->GetChildCount();
+  bool success = true;
+  for (int i = 0; i < child_count; ++i) {
+    AXPlatformNodeAuraLinux* child =
+        AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    if (!child->SupportsSelectionWithAtkSelection())
+      continue;
+
+    bool selected =
+        child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+    if (!selected)
+      continue;
+
+    AXActionData data;
+    data.action = ax::mojom::Action::kDoDefault;
+    success = success && child->GetDelegate()->AccessibilityPerformAction(data);
+  }
+
+  return success;
+}
+
+AtkObject* RefSelection(AtkSelection* selection, gint requested_child_index) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return nullptr;
+
+  if (auto* selected_child = obj->GetSelectedItem(requested_child_index)) {
+    if (AtkObject* atk_object = selected_child->GetNativeViewAccessible()) {
+      g_object_ref(atk_object);
+      return atk_object;
+    }
+  }
+
+  return nullptr;
+}
+
+gint GetSelectionCount(AtkSelection* selection) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), 0);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return 0;
+
+  return obj->GetSelectionCount();
+}
+
+gboolean IsChildSelected(AtkSelection* selection, gint index) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+  if (index < 0 || static_cast<size_t>(index) >= obj->GetChildCount())
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* child =
+      AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(index));
+  return child && child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+}
+
+gboolean RemoveSelection(AtkSelection* selection,
+                         gint index_into_selected_children) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+
+  int child_count = obj->GetChildCount();
+  for (int i = 0; i < child_count; ++i) {
+    AXPlatformNodeAuraLinux* child =
+        AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    bool selected =
+        child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+    if (selected && index_into_selected_children == 0) {
+      if (!child->SupportsSelectionWithAtkSelection())
+        return FALSE;
+
+      AXActionData data;
+      data.action = ax::mojom::Action::kDoDefault;
+      return child->GetDelegate()->AccessibilityPerformAction(data);
+    } else if (selected) {
+      index_into_selected_children--;
+    }
+  }
+
+  return FALSE;
+}
+
+gboolean SelectAllSelection(AtkSelection* selection) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+
+  int child_count = obj->GetChildCount();
+  bool success = true;
+  for (int i = 0; i < child_count; ++i) {
+    AXPlatformNodeAuraLinux* child =
+        AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    if (!child->SupportsSelectionWithAtkSelection())
+      continue;
+
+    bool selected =
+        child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+    if (selected)
+      continue;
+
+    AXActionData data;
+    data.action = ax::mojom::Action::kDoDefault;
+    success = success && child->GetDelegate()->AccessibilityPerformAction(data);
+  }
+
+  return success;
+}
+
+void Init(AtkSelectionIface* iface) {
+  iface->add_selection = AddSelection;
+  iface->clear_selection = ClearSelection;
+  iface->ref_selection = RefSelection;
+  iface->get_selection_count = GetSelectionCount;
+  iface->is_child_selected = IsChildSelected;
+  iface->remove_selection = RemoveSelection;
+  iface->select_all_selection = SelectAllSelection;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_selection
+
+namespace atk_table {
+
+AtkObject* RefAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      if (AtkObject* atk_cell = cell->GetNativeViewAccessible()) {
+        g_object_ref(atk_cell);
+        return atk_cell;
+      }
+    }
+  }
+
+  return nullptr;
+}
+
+gint GetIndexAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), -1);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      DCHECK(cell->GetTableCellIndex().has_value());
+      return cell->GetTableCellIndex().value();
+    }
+  }
+
+  return -1;
+}
+
+gint GetColumnAtIndex(AtkTable* table, gint index) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), -1);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(index)) {
+      DCHECK(cell->GetTableColumn().has_value());
+      return cell->GetTableColumn().value();
+    }
+  }
+
+  return -1;
+}
+
+gint GetRowAtIndex(AtkTable* table, gint index) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), -1);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(index)) {
+      DCHECK(cell->GetTableRow().has_value());
+      return cell->GetTableRow().value();
+    }
+  }
+
+  return -1;
+}
+
+gint GetNColumns(AtkTable* table) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    // If the object is not a table, we return 0.
+    return obj->GetTableColumnCount().value_or(0);
+  }
+
+  return 0;
+}
+
+gint GetNRows(AtkTable* table) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    // If the object is not a table, we return 0.
+    return obj->GetTableRowCount().value_or(0);
+  }
+
+  return 0;
+}
+
+gint GetColumnExtentAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      DCHECK(cell->GetTableColumnSpan().has_value());
+      return cell->GetTableColumnSpan().value();
+    }
+  }
+
+  return 0;
+}
+
+gint GetRowExtentAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      DCHECK(cell->GetTableRowSpan().has_value());
+      return cell->GetTableRowSpan().value();
+    }
+  }
+
+  return 0;
+}
+
+AtkObject* GetColumnHeader(AtkTable* table, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  // AtkTable supports only one column header object. So return the first one
+  // we find. In the case of multiple headers, ATs can fall back on the column
+  // description.
+  std::vector<int32_t> ids = obj->GetDelegate()->GetColHeaderNodeIds(column);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* header = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_header = header->GetNativeViewAccessible()) {
+        g_object_ref(atk_header);
+        return atk_header;
+      }
+    }
+  }
+
+  return nullptr;
+}
+
+AtkObject* GetRowHeader(AtkTable* table, gint row) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  // AtkTable supports only one row header object. So return the first one
+  // we find. In the case of multiple headers, ATs can fall back on the row
+  // description.
+  std::vector<int32_t> ids = obj->GetDelegate()->GetRowHeaderNodeIds(row);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* header = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_header = header->GetNativeViewAccessible()) {
+        g_object_ref(atk_header);
+        return atk_header;
+      }
+    }
+  }
+
+  return nullptr;
+}
+
+AtkObject* GetCaption(AtkTable* table) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (auto* caption = obj->GetTableCaption())
+      return caption->GetNativeViewAccessible();
+  }
+
+  return nullptr;
+}
+
+const gchar* GetColumnDescription(AtkTable* table, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  std::vector<int32_t> ids = obj->GetDelegate()->GetColHeaderNodeIds(column);
+  return BuildDescriptionFromHeaders(obj->GetDelegate(), ids);
+}
+
+const gchar* GetRowDescription(AtkTable* table, gint row) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  std::vector<int32_t> ids = obj->GetDelegate()->GetRowHeaderNodeIds(row);
+  return BuildDescriptionFromHeaders(obj->GetDelegate(), ids);
+}
+
+void Init(AtkTableIface* iface) {
+  iface->ref_at = RefAt;
+  iface->get_index_at = GetIndexAt;
+  iface->get_column_at_index = GetColumnAtIndex;
+  iface->get_row_at_index = GetRowAtIndex;
+  iface->get_n_columns = GetNColumns;
+  iface->get_n_rows = GetNRows;
+  iface->get_column_extent_at = GetColumnExtentAt;
+  iface->get_row_extent_at = GetRowExtentAt;
+  iface->get_column_header = GetColumnHeader;
+  iface->get_row_header = GetRowHeader;
+  iface->get_caption = GetCaption;
+  iface->get_column_description = GetColumnDescription;
+  iface->get_row_description = GetRowDescription;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_table
+
+// The ATK table cell interface was added in ATK 2.12.
+#if defined(ATK_212)
+
+namespace atk_table_cell {
+
+gint GetColumnSpan(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()), 0);
+
+  if (const AXPlatformNodeBase* obj =
+          AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    // If the object is not a cell, we return 0.
+    return obj->GetTableColumnSpan().value_or(0);
+  }
+
+  return 0;
+}
+
+GPtrArray* GetColumnHeaderCells(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      nullptr);
+
+  GPtrArray* array = g_ptr_array_new_with_free_func(g_object_unref);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell));
+  if (!obj)
+    return array;
+
+  // AtkTableCell is implemented on cells, row headers, and column headers.
+  // Calling GetColHeaderNodeIds() on a column header cell will include that
+  // column header, along with any other column headers in the column which
+  // may or may not describe the header cell in question. Therefore, just return
+  // headers for non-header cells.
+  if (obj->GetAtkRole() != ATK_ROLE_TABLE_CELL)
+    return array;
+
+  absl::optional<int> col_index = obj->GetTableColumn();
+  if (!col_index)
+    return array;
+
+  const std::vector<int32_t> ids =
+      obj->GetDelegate()->GetColHeaderNodeIds(*col_index);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* node = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_node = node->GetNativeViewAccessible()) {
+        g_ptr_array_add(array, g_object_ref(atk_node));
+      }
+    }
+  }
+
+  return array;
+}
+
+gboolean GetCellPosition(AtkTableCell* cell, gint* row, gint* column) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      FALSE);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    absl::optional<int> row_index = obj->GetTableRow();
+    absl::optional<int> col_index = obj->GetTableColumn();
+    if (!row_index || !col_index)
+      return false;
+
+    *row = *row_index;
+    *column = *col_index;
+    return true;
+  }
+
+  return false;
+}
+
+gint GetRowSpan(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    // If the object is not a cell, we return 0.
+    return obj->GetTableRowSpan().value_or(0);
+  }
+
+  return 0;
+}
+
+GPtrArray* GetRowHeaderCells(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      nullptr);
+
+  GPtrArray* array = g_ptr_array_new_with_free_func(g_object_unref);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell));
+  if (!obj)
+    return array;
+
+  // AtkTableCell is implemented on cells, row headers, and column headers.
+  // Calling GetRowHeaderNodeIds() on a row header cell will include that
+  // row header, along with any other row headers in the row which may or
+  // may not describe the header cell in question. Therefore, just return
+  // headers for non-header cells.
+  if (obj->GetAtkRole() != ATK_ROLE_TABLE_CELL)
+    return array;
+
+  absl::optional<int> row_index = obj->GetTableRow();
+  if (!row_index)
+    return array;
+
+  const std::vector<int32_t> ids =
+      obj->GetDelegate()->GetRowHeaderNodeIds(*row_index);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* node = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_node = node->GetNativeViewAccessible()) {
+        g_ptr_array_add(array, g_object_ref(atk_node));
+      }
+    }
+  }
+
+  return array;
+}
+
+AtkObject* GetTable(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      nullptr);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    if (auto* table = obj->GetTable())
+      return table->GetNativeViewAccessible();
+  }
+
+  return nullptr;
+}
+
+using AtkTableCellIface = struct _AtkTableCellIface;
+
+void Init(AtkTableCellIface* iface) {
+  iface->get_column_span = GetColumnSpan;
+  iface->get_column_header_cells = GetColumnHeaderCells;
+  iface->get_position = GetCellPosition;
+  iface->get_row_span = GetRowSpan;
+  iface->get_row_header_cells = GetRowHeaderCells;
+  iface->get_table = GetTable;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_table_cell
+
+#endif  // ATK_212
+
+namespace atk_object {
+
+gpointer kAXPlatformNodeAuraLinuxParentClass = nullptr;
+
+const gchar* GetName(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (!obj->IsNameExposed())
+    return nullptr;
+
+  ax::mojom::NameFrom name_from = obj->GetNameFrom();
+  if (obj->GetName().empty() &&
+      name_from != ax::mojom::NameFrom::kAttributeExplicitlyEmpty) {
+    return nullptr;
+  }
+
+  obj->accessible_name_ = obj->GetName();
+  return obj->accessible_name_.c_str();
+}
+
+const gchar* AtkGetName(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetName);
+  return GetName(atk_object);
+}
+
+const gchar* GetDescription(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetStringAttribute(ax::mojom::StringAttribute::kDescription)
+      .c_str();
+}
+
+const gchar* AtkGetDescription(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetDescription);
+  return GetDescription(atk_object);
+}
+
+gint GetNChildren(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), 0);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  return obj->GetChildCount();
+}
+
+gint AtkGetNChildren(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetNChildren);
+  return GetNChildren(atk_object);
+}
+
+AtkObject* RefChild(AtkObject* atk_object, gint index) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (index < 0 || static_cast<size_t>(index) >= obj->GetChildCount())
+    return nullptr;
+
+  AtkObject* result = obj->ChildAtIndex(index);
+  if (result)
+    g_object_ref(result);
+  return result;
+}
+
+AtkObject* AtkRefChild(AtkObject* atk_object, gint index) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kRefChild);
+  return RefChild(atk_object, index);
+}
+
+gint GetIndexInParent(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), -1);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return -1;
+
+  auto index_in_parent = obj->GetIndexInParent();
+  return index_in_parent.has_value()
+             ? static_cast<gint>(index_in_parent.value())
+             : -1;
+}
+
+gint AtkGetIndexInParent(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetIndexInParent);
+  return GetIndexInParent(atk_object);
+}
+
+AtkObject* GetParent(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetParent();
+}
+
+AtkObject* AtkGetParent(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetParent);
+  return GetParent(atk_object);
+}
+
+AtkRelationSet* RefRelationSet(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return atk_relation_set_new();
+  return obj->GetAtkRelations();
+}
+
+AtkRelationSet* AtkRefRelationSet(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kRefRelationSet);
+  // Enables AX mode. Most AT does not call AtkRefRelationSet, but Orca does,
+  // which is why it's a good signal to enable accessibility for Orca users
+  // without too many false positives.
+  AXPlatformNodeAuraLinux::EnableAXMode();
+  return RefRelationSet(atk_object);
+}
+
+AtkAttributeSet* GetAttributes(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetAtkAttributes();
+}
+
+AtkAttributeSet* AtkGetAttributes(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetAttributes);
+  // Enables AX mode. Most AT does not call AtkGetAttributes, but Orca does,
+  // which is why it's a good signal to enable accessibility for Orca users
+  // without too many false positives.
+  AXPlatformNodeAuraLinux::EnableAXMode();
+  return GetAttributes(atk_object);
+}
+
+AtkRole GetRole(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), ATK_ROLE_INVALID);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return ATK_ROLE_INVALID;
+  return obj->GetAtkRole();
+}
+
+AtkRole AtkGetRole(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetRole);
+  return GetRole(atk_object);
+}
+
+AtkStateSet* RefStateSet(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AtkStateSet* atk_state_set =
+      ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)
+          ->ref_state_set(atk_object);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_DEFUNCT);
+  } else {
+    obj->GetAtkState(atk_state_set);
+  }
+  return atk_state_set;
+}
+
+AtkStateSet* AtkRefStateSet(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kRefStateSet);
+  return RefStateSet(atk_object);
+}
+
+void Initialize(AtkObject* atk_object, gpointer data) {
+  if (ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)->initialize) {
+    ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)
+        ->initialize(atk_object, data);
+  }
+
+  AX_PLATFORM_NODE_AURALINUX(atk_object)->m_object =
+      reinterpret_cast<AXPlatformNodeAuraLinux*>(data);
+}
+
+void Finalize(GObject* atk_object) {
+  G_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)->finalize(atk_object);
+}
+
+void ClassInit(gpointer class_pointer, gpointer /* class_data */) {
+  GObjectClass* gobject_class = G_OBJECT_CLASS(class_pointer);
+  kAXPlatformNodeAuraLinuxParentClass = g_type_class_peek_parent(gobject_class);
+  gobject_class->finalize = Finalize;
+
+  AtkObjectClass* atk_object_class = ATK_OBJECT_CLASS(gobject_class);
+  atk_object_class->initialize = Initialize;
+  atk_object_class->get_name = AtkGetName;
+  atk_object_class->get_description = AtkGetDescription;
+  atk_object_class->get_parent = AtkGetParent;
+  atk_object_class->get_n_children = AtkGetNChildren;
+  atk_object_class->ref_child = AtkRefChild;
+  atk_object_class->get_role = AtkGetRole;
+  atk_object_class->ref_state_set = AtkRefStateSet;
+  atk_object_class->get_index_in_parent = AtkGetIndexInParent;
+  atk_object_class->ref_relation_set = AtkRefRelationSet;
+  atk_object_class->get_attributes = AtkGetAttributes;
+}
+
+GType GetType() {
+  AXPlatformNodeAuraLinux::EnsureGTypeInit();
+
+  static gsize type_id = 0;
+  if (g_once_init_enter(&type_id)) {
+    static const GTypeInfo type_info = {
+        sizeof(AXPlatformNodeAuraLinuxClass),  // class_size
+        nullptr,                               // base_init
+        nullptr,                               // base_finalize
+        atk_object::ClassInit,
+        nullptr,                                // class_finalize
+        nullptr,                                // class_data
+        sizeof(AXPlatformNodeAuraLinuxObject),  // instance_size
+        0,                                      // n_preallocs
+        nullptr,                                // instance_init
+        nullptr                                 // value_table
+    };
+
+    GType type = g_type_register_static(
+        ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &type_info, GTypeFlags(0));
+    g_once_init_leave(&type_id, type);
+  }
+
+  return type_id;
+}
+
+void Detach(AXPlatformNodeAuraLinuxObject* atk_object) {
+  if (!atk_object->m_object)
+    return;
+
+  atk_object->m_object = nullptr;
+}
+
+}  //  namespace atk_object
+
+}  // namespace
+
+// static
+NO_SANITIZE("cfi-icall")
+GType AtkTableCellInterface::GetType() {
+  return g_atk_table_cell_get_type();
+}
+
+// static
+NO_SANITIZE("cfi-icall")
+GPtrArray* AtkTableCellInterface::GetColumnHeaderCells(AtkTableCell* cell) {
+  return g_atk_table_cell_get_column_header_cells(cell);
+}
+
+// static
+NO_SANITIZE("cfi-icall")
+GPtrArray* AtkTableCellInterface::GetRowHeaderCells(AtkTableCell* cell) {
+  return g_atk_table_cell_get_row_header_cells(cell);
+}
+
+// static
+NO_SANITIZE("cfi-icall")
+bool AtkTableCellInterface::GetRowColumnSpan(AtkTableCell* cell,
+                                             gint* row,
+                                             gint* column,
+                                             gint* row_span,
+                                             gint* col_span) {
+  return g_atk_table_cell_get_row_column_span(cell, row, column, row_span,
+                                              col_span);
+}
+
+// static
+bool AtkTableCellInterface::Exists() {
+  g_atk_table_cell_get_type = reinterpret_cast<GetTypeFunc>(
+      dlsym(RTLD_DEFAULT, "atk_table_cell_get_type"));
+  g_atk_table_cell_get_column_header_cells =
+      reinterpret_cast<GetColumnHeaderCellsFunc>(
+          dlsym(RTLD_DEFAULT, "atk_table_cell_get_column_header_cells"));
+  g_atk_table_cell_get_row_header_cells =
+      reinterpret_cast<GetRowHeaderCellsFunc>(
+          dlsym(RTLD_DEFAULT, "atk_table_cell_get_row_header_cells"));
+  g_atk_table_cell_get_row_column_span = reinterpret_cast<GetRowColumnSpanFunc>(
+      dlsym(RTLD_DEFAULT, "atk_table_cell_get_row_column_span"));
+  return *g_atk_table_cell_get_type;
+}
+
+void AXPlatformNodeAuraLinux::EnsureGTypeInit() {
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+  static bool first_time = true;
+  if (UNLIKELY(first_time)) {
+    g_type_init();
+    first_time = false;
+  }
+#endif
+}
+
+// static
+ImplementedAtkInterfaces AXPlatformNodeAuraLinux::GetGTypeInterfaceMask(
+    const AXNodeData& data) {
+  // The default implementation set includes the AtkComponent and AtkAction
+  // interfaces, which are provided by all the AtkObjects that we produce.
+  ImplementedAtkInterfaces interface_mask;
+
+  if (!IsImageOrVideo(data.role)) {
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kText);
+    if (!data.IsAtomicTextField())
+      interface_mask.Add(ImplementedAtkInterfaces::Value::kHypertext);
+  }
+
+  if (data.IsRangeValueSupported())
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kValue);
+
+  if (ui::IsPlatformDocument(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kDocument);
+
+  if (IsImage(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kImage);
+
+  // The AtkHyperlinkImpl interface allows getting a AtkHyperlink from an
+  // AtkObject. It is indeed implemented by actual web hyperlinks, but also by
+  // objects that will become embedded objects in ATK hypertext, so the name is
+  // a bit of a misnomer from the ATK API.
+  if (IsLink(data.role) || !ui::IsText(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kHyperlink);
+
+  if (data.role == ax::mojom::Role::kWindow)
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kWindow);
+
+  if (IsContainerWithSelectableChildren(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kSelection);
+
+  if (IsTableLike(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kTable);
+
+  // Because the TableCell Interface is only supported in ATK version 2.12 and
+  // later, GetAccessibilityGType has a runtime check to verify we have a recent
+  // enough version. If we don't, GetAccessibilityGType will exclude
+  // AtkTableCell from the supported interfaces and none of its methods or
+  // properties will be exposed to assistive technologies.
+  if (IsCellOrTableHeader(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kTableCell);
+
+  return interface_mask;
+}
+
+GType AXPlatformNodeAuraLinux::GetAccessibilityGType() {
+  static const GTypeInfo type_info = {
+      sizeof(AXPlatformNodeAuraLinuxClass),
+      (GBaseInitFunc) nullptr,
+      (GBaseFinalizeFunc) nullptr,
+      (GClassInitFunc) nullptr,
+      (GClassFinalizeFunc) nullptr,
+      nullptr,                               /* class data */
+      sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */
+      0,                                     /* nb preallocs */
+      (GInstanceInitFunc) nullptr,
+      nullptr /* value table */
+  };
+
+  const char* atk_type_name = GetUniqueAccessibilityGTypeName(interface_mask_);
+  GType type = g_type_from_name(atk_type_name);
+  if (type)
+    return type;
+
+  type = g_type_register_static(AX_PLATFORM_NODE_AURALINUX_TYPE, atk_type_name,
+                                &type_info, GTypeFlags(0));
+
+  // The AtkComponent and AtkAction interfaces are always supported.
+  g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &atk_component::Info);
+  g_type_add_interface_static(type, ATK_TYPE_ACTION, &atk_action::Info);
+
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kDocument))
+    g_type_add_interface_static(type, ATK_TYPE_DOCUMENT, &atk_document::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kImage))
+    g_type_add_interface_static(type, ATK_TYPE_IMAGE, &atk_image::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kValue))
+    g_type_add_interface_static(type, ATK_TYPE_VALUE, &atk_value::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kHyperlink)) {
+    g_type_add_interface_static(type, ATK_TYPE_HYPERLINK_IMPL,
+                                &atk_hyperlink::Info);
+  }
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kHypertext))
+    g_type_add_interface_static(type, ATK_TYPE_HYPERTEXT, &atk_hypertext::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kText))
+    g_type_add_interface_static(type, ATK_TYPE_TEXT, &atk_text::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kWindow))
+    g_type_add_interface_static(type, ATK_TYPE_WINDOW, &atk_window::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kSelection))
+    g_type_add_interface_static(type, ATK_TYPE_SELECTION, &atk_selection::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kTable))
+    g_type_add_interface_static(type, ATK_TYPE_TABLE, &atk_table::Info);
+
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kTableCell)) {
+    // Run-time check to ensure AtkTableCell is supported (requires ATK 2.12).
+    if (AtkTableCellInterface::Exists()) {
+      g_type_add_interface_static(type, AtkTableCellInterface::GetType(),
+                                  &atk_table_cell::Info);
+    }
+  }
+
+  return type;
+}
+
+void AXPlatformNodeAuraLinux::SetDocumentParentOnFrameIfNecessary() {
+  if (GetAtkRole() != ATK_ROLE_DOCUMENT_WEB)
+    return;
+
+  if (!GetDelegate()->IsWebContent())
+    return;
+
+  AtkObject* parent_atk_object = GetParent();
+  AXPlatformNodeAuraLinux* parent =
+      AXPlatformNodeAuraLinux::FromAtkObject(parent_atk_object);
+  if (!parent)
+    return;
+
+  if (parent->GetDelegate()->IsWebContent())
+    return;
+
+  AXPlatformNodeAuraLinux* frame = AXPlatformNodeAuraLinux::FromAtkObject(
+      FindAtkObjectParentFrame(parent_atk_object));
+  if (!frame)
+    return;
+
+  frame->SetDocumentParent(parent_atk_object);
+}
+
+AtkObject* AXPlatformNodeAuraLinux::FindPrimaryWebContentDocument() {
+  // It could get multiple web contents since additional web content is added,
+  // when the DevTools window is opened.
+  std::vector<AtkObject*> web_content_candidates;
+  for (auto child_iterator_ptr = GetDelegate()->ChildrenBegin();
+       *child_iterator_ptr != *GetDelegate()->ChildrenEnd();
+       ++(*child_iterator_ptr)) {
+    AtkObject* child = child_iterator_ptr->GetNativeViewAccessible();
+    auto* child_node = AXPlatformNodeAuraLinux::FromAtkObject(child);
+    if (!child_node)
+      continue;
+    if (!child_node->GetDelegate()->IsWebContent())
+      continue;
+    if (child_node->GetAtkRole() != ATK_ROLE_DOCUMENT_WEB)
+      continue;
+    web_content_candidates.push_back(child);
+  }
+
+  if (web_content_candidates.empty())
+    return nullptr;
+
+  // If it finds just one web content, return it.
+  if (web_content_candidates.size() == 1)
+    return web_content_candidates[0];
+
+  for (auto* object : web_content_candidates) {
+    auto* child_node = AXPlatformNodeAuraLinux::FromAtkObject(object);
+    // If it is a primary web contents, return it.
+    if (child_node->GetDelegate()->IsPrimaryWebContentsForWindow()) {
+      return object;
+    }
+  }
+  return nullptr;
+}
+
+bool AXPlatformNodeAuraLinux::IsWebDocumentForRelations() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return false;
+  AXPlatformNodeAuraLinux* parent = FromAtkObject(GetParent());
+  if (!parent || !GetDelegate()->IsWebContent() ||
+      GetAtkRole() != ATK_ROLE_DOCUMENT_WEB)
+    return false;
+  return parent->FindPrimaryWebContentDocument() == atk_object;
+}
+
+AtkObject* AXPlatformNodeAuraLinux::CreateAtkObject() {
+  if (GetRole() != ax::mojom::Role::kApplication &&
+      !GetDelegate()->IsToplevelBrowserWindow() &&
+      !GetAccessibilityMode().has_mode(AXMode::kNativeAPIs)) {
+    return nullptr;
+  }
+  if (GetDelegate()->IsChildOfLeaf())
+    return nullptr;
+  EnsureGTypeInit();
+  interface_mask_ = GetGTypeInterfaceMask(GetData());
+  GType type = GetAccessibilityGType();
+  AtkObject* atk_object = static_cast<AtkObject*>(g_object_new(type, nullptr));
+
+  atk_object_initialize(atk_object, this);
+
+  SetDocumentParentOnFrameIfNecessary();
+
+  return ATK_OBJECT(atk_object);
+}
+
+void AXPlatformNodeAuraLinux::DestroyAtkObjects() {
+  if (atk_hyperlink_) {
+    ax_platform_atk_hyperlink_set_object(
+        AX_PLATFORM_ATK_HYPERLINK(atk_hyperlink_), nullptr);
+    g_object_unref(atk_hyperlink_);
+    atk_hyperlink_ = nullptr;
+  }
+
+  if (atk_object_) {
+    // We explicitly clear g_current_focused just in case there is another
+    // reference to atk_object_ somewhere.
+    if (atk_object_ == g_current_focused)
+      SetWeakGPtrToAtkObject(&g_current_focused, nullptr);
+    atk_object::Detach(AX_PLATFORM_NODE_AURALINUX(atk_object_));
+
+    g_object_unref(atk_object_);
+    atk_object_ = nullptr;
+  }
+}
+
+// static
+AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
+  AXPlatformNodeAuraLinux* node = new AXPlatformNodeAuraLinux();
+  node->Init(delegate);
+  return node;
+}
+
+// static
+AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
+    gfx::NativeViewAccessible accessible) {
+  return AXPlatformNodeAuraLinux::FromAtkObject(accessible);
+}
+
+//
+// AXPlatformNodeAuraLinux implementation.
+//
+
+// static
+AXPlatformNodeAuraLinux* AXPlatformNodeAuraLinux::FromAtkObject(
+    const AtkObject* atk_object) {
+  if (!atk_object)
+    return nullptr;
+
+  if (IS_AX_PLATFORM_NODE_AURALINUX(atk_object)) {
+    AXPlatformNodeAuraLinuxObject* platform_object =
+        AX_PLATFORM_NODE_AURALINUX(atk_object);
+    return platform_object->m_object;
+  }
+
+  return nullptr;
+}
+
+// static
+void AXPlatformNodeAuraLinux::SetApplication(AXPlatformNode* application) {
+  g_root_application = application;
+}
+
+// static
+AXPlatformNode* AXPlatformNodeAuraLinux::application() {
+  return g_root_application;
+}
+
+// static
+void AXPlatformNodeAuraLinux::StaticInitialize() {
+  AtkUtilAuraLinux::GetInstance()->InitializeAsync();
+}
+
+// static
+void AXPlatformNodeAuraLinux::EnableAXMode() {
+  AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
+}
+
+AtkRole AXPlatformNodeAuraLinux::GetAtkRole() const {
+  switch (GetRole()) {
+    case ax::mojom::Role::kAlert:
+      return ATK_ROLE_NOTIFICATION;
+    case ax::mojom::Role::kAlertDialog:
+      return ATK_ROLE_ALERT;
+    case ax::mojom::Role::kComment:
+    case ax::mojom::Role::kSuggestion:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kApplication:
+      // Only use ATK_ROLE_APPLICATION for elements with no parent, since it
+      // is only for top level app windows and not ARIA applications.
+      if (!GetParent()) {
+        return ATK_ROLE_APPLICATION;
+      } else {
+        return ATK_ROLE_EMBEDDED;
+      }
+    case ax::mojom::Role::kArticle:
+      return ATK_ROLE_ARTICLE;
+    case ax::mojom::Role::kAudio:
+      return ATK_ROLE_AUDIO;
+    case ax::mojom::Role::kBanner:
+    case ax::mojom::Role::kHeader:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kBlockquote:
+      return ATK_ROLE_BLOCK_QUOTE;
+    case ax::mojom::Role::kCaret:
+      return ATK_ROLE_UNKNOWN;
+    case ax::mojom::Role::kButton:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kCanvas:
+      return ATK_ROLE_CANVAS;
+    case ax::mojom::Role::kCaption:
+      return ATK_ROLE_CAPTION;
+    case ax::mojom::Role::kCell:
+      return ATK_ROLE_TABLE_CELL;
+    case ax::mojom::Role::kCheckBox:
+      return ATK_ROLE_CHECK_BOX;
+    case ax::mojom::Role::kSwitch:
+      return ATK_ROLE_TOGGLE_BUTTON;
+    case ax::mojom::Role::kColorWell:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kColumn:
+      return ATK_ROLE_UNKNOWN;
+    case ax::mojom::Role::kColumnHeader:
+      return ATK_ROLE_COLUMN_HEADER;
+    case ax::mojom::Role::kComboBoxGrouping:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kComboBoxMenuButton:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kComboBoxSelect:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kComplementary:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kContentDeletion:
+      return kAtkRoleContentDeletion;
+    case ax::mojom::Role::kContentInsertion:
+      return kAtkRoleContentInsertion;
+    case ax::mojom::Role::kContentInfo:
+    case ax::mojom::Role::kFooter:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kDate:
+      return ATK_ROLE_DATE_EDITOR;
+    case ax::mojom::Role::kDateTime:
+      return ATK_ROLE_DATE_EDITOR;
+    case ax::mojom::Role::kDefinition:
+    case ax::mojom::Role::kDescriptionListDetail:
+      return ATK_ROLE_DESCRIPTION_VALUE;
+    case ax::mojom::Role::kDescriptionList:
+      return ATK_ROLE_DESCRIPTION_LIST;
+    case ax::mojom::Role::kDescriptionListTerm:
+      return ATK_ROLE_DESCRIPTION_TERM;
+    case ax::mojom::Role::kDetails:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kDialog:
+      return ATK_ROLE_DIALOG;
+    case ax::mojom::Role::kDirectory:
+      return ATK_ROLE_LIST;
+    case ax::mojom::Role::kDisclosureTriangle:
+      return ATK_ROLE_TOGGLE_BUTTON;
+    case ax::mojom::Role::kDocCover:
+      return ATK_ROLE_IMAGE;
+    case ax::mojom::Role::kDocBackLink:
+    case ax::mojom::Role::kDocBiblioRef:
+    case ax::mojom::Role::kDocGlossRef:
+    case ax::mojom::Role::kDocNoteRef:
+      return ATK_ROLE_LINK;
+    case ax::mojom::Role::kDocBiblioEntry:
+    case ax::mojom::Role::kDocEndnote:
+      return ATK_ROLE_LIST_ITEM;
+    case ax::mojom::Role::kDocNotice:
+    case ax::mojom::Role::kDocTip:
+      return ATK_ROLE_COMMENT;
+    case ax::mojom::Role::kDocFootnote:
+      return kAtkFootnoteRole;
+    case ax::mojom::Role::kDocPageBreak:
+      return ATK_ROLE_SEPARATOR;
+    case ax::mojom::Role::kDocPageFooter:
+      return ATK_ROLE_FOOTER;
+    case ax::mojom::Role::kDocPageHeader:
+      return ATK_ROLE_HEADER;
+    case ax::mojom::Role::kDocAcknowledgments:
+    case ax::mojom::Role::kDocAfterword:
+    case ax::mojom::Role::kDocAppendix:
+    case ax::mojom::Role::kDocBibliography:
+    case ax::mojom::Role::kDocChapter:
+    case ax::mojom::Role::kDocConclusion:
+    case ax::mojom::Role::kDocCredits:
+    case ax::mojom::Role::kDocEndnotes:
+    case ax::mojom::Role::kDocEpilogue:
+    case ax::mojom::Role::kDocErrata:
+    case ax::mojom::Role::kDocForeword:
+    case ax::mojom::Role::kDocGlossary:
+    case ax::mojom::Role::kDocIndex:
+    case ax::mojom::Role::kDocIntroduction:
+    case ax::mojom::Role::kDocPageList:
+    case ax::mojom::Role::kDocPart:
+    case ax::mojom::Role::kDocPreface:
+    case ax::mojom::Role::kDocPrologue:
+    case ax::mojom::Role::kDocToc:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kDocAbstract:
+    case ax::mojom::Role::kDocColophon:
+    case ax::mojom::Role::kDocCredit:
+    case ax::mojom::Role::kDocDedication:
+    case ax::mojom::Role::kDocEpigraph:
+    case ax::mojom::Role::kDocExample:
+    case ax::mojom::Role::kDocPullquote:
+    case ax::mojom::Role::kDocQna:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kDocSubtitle:
+      return ATK_ROLE_HEADING;
+    case ax::mojom::Role::kDocument:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kEmbeddedObject:
+      return ATK_ROLE_EMBEDDED;
+    case ax::mojom::Role::kForm:
+      // TODO(accessibility) Forms which lack an accessible name are no longer
+      // exposed as forms. http://crbug.com/874384. Forms which have accessible
+      // names should be exposed as ATK_ROLE_LANDMARK according to Core AAM.
+      return ATK_ROLE_FORM;
+    case ax::mojom::Role::kFigure:
+    case ax::mojom::Role::kFeed:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kGenericContainer:
+    case ax::mojom::Role::kFooterAsNonLandmark:
+    case ax::mojom::Role::kHeaderAsNonLandmark:
+    case ax::mojom::Role::kRuby:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kGraphicsDocument:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kGraphicsObject:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kGraphicsSymbol:
+      return ATK_ROLE_IMAGE;
+    case ax::mojom::Role::kGrid:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kGroup:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kHeading:
+      return ATK_ROLE_HEADING;
+    case ax::mojom::Role::kIframe:
+    case ax::mojom::Role::kIframePresentational:
+      return ATK_ROLE_INTERNAL_FRAME;
+    case ax::mojom::Role::kImage:
+      return IsImageWithMap() ? ATK_ROLE_IMAGE_MAP : ATK_ROLE_IMAGE;
+    case ax::mojom::Role::kInlineTextBox:
+      return kStaticRole;
+    case ax::mojom::Role::kInputTime:
+      return ATK_ROLE_DATE_EDITOR;
+    case ax::mojom::Role::kLabelText:
+      return ATK_ROLE_LABEL;
+    case ax::mojom::Role::kLegend:
+      return ATK_ROLE_LABEL;
+    // Layout table objects are treated the same as Role::kGenericContainer.
+    case ax::mojom::Role::kLayoutTable:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kLayoutTableCell:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kLayoutTableRow:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kLineBreak:
+      // TODO(Accessibility) Having a separate accessible object for line breaks
+      // is inconsistent with other implementations. http://crbug.com/873144#c1.
+      return kStaticRole;
+    case ax::mojom::Role::kLink:
+      return ATK_ROLE_LINK;
+    case ax::mojom::Role::kList:
+      return ATK_ROLE_LIST;
+    case ax::mojom::Role::kListBox:
+      return ATK_ROLE_LIST_BOX;
+    // TODO(Accessibility) Use ATK_ROLE_MENU_ITEM inside a combo box, see how
+    // ax_platform_node_win.cc code does this.
+    case ax::mojom::Role::kListBoxOption:
+      return ATK_ROLE_LIST_ITEM;
+    case ax::mojom::Role::kListGrid:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kListItem:
+      return ATK_ROLE_LIST_ITEM;
+    case ax::mojom::Role::kListMarker:
+      // Regular list markers only expose their alternative text, but do not
+      // expose their descendants; and the descendants should be ignored. This
+      // is because the alternative text depends on the counter style and can
+      // be different from the actual (visual) marker text, and hence,
+      // inconsistent with the descendants. We treat a list marker as non-text
+      // only if it still has non-ignored descendants, which happens only when:
+      // - The list marker itself is ignored but the descendants are not
+      // - Or the list marker contains images
+      if (!GetChildCount())
+        return kStaticRole;
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kLog:
+      return ATK_ROLE_LOG;
+    case ax::mojom::Role::kMain:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kMark:
+      return kStaticRole;
+    case ax::mojom::Role::kMath:
+    case ax::mojom::Role::kMathMLMath:
+      return ATK_ROLE_MATH;
+    // https://w3c.github.io/mathml-aam/#mathml-element-mappings
+    case ax::mojom::Role::kMathMLFraction:
+      return ATK_ROLE_MATH_FRACTION;
+    case ax::mojom::Role::kMathMLIdentifier:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLMultiscripts:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLNoneScript:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLNumber:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLPrescriptDelimiter:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLOperator:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLOver:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLRoot:
+      return ATK_ROLE_MATH_ROOT;
+    case ax::mojom::Role::kMathMLRow:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLSquareRoot:
+      return ATK_ROLE_MATH_ROOT;
+    case ax::mojom::Role::kMathMLStringLiteral:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLSub:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLSubSup:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLSup:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLTable:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kMathMLTableCell:
+      return ATK_ROLE_TABLE_CELL;
+    case ax::mojom::Role::kMathMLTableRow:
+      return ATK_ROLE_TABLE_ROW;
+    case ax::mojom::Role::kMathMLText:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLUnder:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLUnderOver:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMarquee:
+      return ATK_ROLE_MARQUEE;
+    case ax::mojom::Role::kMenu:
+      return ATK_ROLE_MENU;
+    case ax::mojom::Role::kMenuBar:
+      return ATK_ROLE_MENU_BAR;
+    case ax::mojom::Role::kMenuItem:
+      return ATK_ROLE_MENU_ITEM;
+    case ax::mojom::Role::kMenuItemCheckBox:
+      return ATK_ROLE_CHECK_MENU_ITEM;
+    case ax::mojom::Role::kMenuItemRadio:
+      return ATK_ROLE_RADIO_MENU_ITEM;
+    case ax::mojom::Role::kMenuListPopup:
+      return ATK_ROLE_MENU;
+    case ax::mojom::Role::kMenuListOption:
+      return ATK_ROLE_MENU_ITEM;
+    case ax::mojom::Role::kMeter:
+      return ATK_ROLE_LEVEL_BAR;
+    case ax::mojom::Role::kNavigation:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kNote:
+      return ATK_ROLE_COMMENT;
+    case ax::mojom::Role::kPane:
+    case ax::mojom::Role::kScrollView:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kParagraph:
+      return ATK_ROLE_PARAGRAPH;
+    case ax::mojom::Role::kPdfActionableHighlight:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kPdfRoot:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kPluginObject:
+      return ATK_ROLE_EMBEDDED;
+    case ax::mojom::Role::kPopUpButton:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kPortal:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kProgressIndicator:
+      return ATK_ROLE_PROGRESS_BAR;
+    case ax::mojom::Role::kRadioButton:
+      return ATK_ROLE_RADIO_BUTTON;
+    case ax::mojom::Role::kRadioGroup:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kRegion:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kRootWebArea:
+      return ATK_ROLE_DOCUMENT_WEB;
+    case ax::mojom::Role::kRow:
+      return ATK_ROLE_TABLE_ROW;
+    case ax::mojom::Role::kRowGroup:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kRowHeader:
+      return ATK_ROLE_ROW_HEADER;
+    case ax::mojom::Role::kRubyAnnotation:
+      // Generally exposed as description on <ruby> (Role::kRuby) element, not
+      // as its own object in the tree.
+      // However, it's possible to make a kRubyAnnotation element show up in the
+      // AX tree, for example by adding tabindex="0" to the source <rp> or <rt>
+      // element or making the source element the target of an aria-owns.
+      // Therefore, browser side needs to gracefully handle it if it actually
+      // shows up in the tree.
+      return kStaticRole;
+    case ax::mojom::Role::kSection:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kScrollBar:
+      return ATK_ROLE_SCROLL_BAR;
+    case ax::mojom::Role::kSearch:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kSlider:
+      return ATK_ROLE_SLIDER;
+    case ax::mojom::Role::kSpinButton:
+      return ATK_ROLE_SPIN_BUTTON;
+    case ax::mojom::Role::kSplitter:
+      return ATK_ROLE_SEPARATOR;
+    case ax::mojom::Role::kStaticText:
+      return kStaticRole;
+    case ax::mojom::Role::kStatus:
+      return ATK_ROLE_STATUSBAR;
+    case ax::mojom::Role::kSubscript:
+      return kSubscriptRole;
+    case ax::mojom::Role::kSuperscript:
+      return kSuperscriptRole;
+    case ax::mojom::Role::kSvgRoot:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kTab:
+      return ATK_ROLE_PAGE_TAB;
+    case ax::mojom::Role::kTable:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kTableHeaderContainer:
+      // TODO(accessibility) This mapping is correct, but it doesn't seem to be
+      // used. We don't necessarily want to always expose these containers, but
+      // we must do so if they are focusable. http://crbug.com/874043
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kTabList:
+      return ATK_ROLE_PAGE_TAB_LIST;
+    case ax::mojom::Role::kTabPanel:
+      return ATK_ROLE_SCROLL_PANE;
+    case ax::mojom::Role::kTerm:
+      return ATK_ROLE_DESCRIPTION_TERM;
+    case ax::mojom::Role::kTitleBar:
+      return ATK_ROLE_TITLE_BAR;
+    case ax::mojom::Role::kTextField:
+    case ax::mojom::Role::kSearchBox:
+      if (HasState(ax::mojom::State::kProtected))
+        return ATK_ROLE_PASSWORD_TEXT;
+      return ATK_ROLE_ENTRY;
+    case ax::mojom::Role::kTextFieldWithComboBox:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kAbbr:
+    case ax::mojom::Role::kCode:
+    case ax::mojom::Role::kEmphasis:
+    case ax::mojom::Role::kStrong:
+    case ax::mojom::Role::kTime:
+      return kStaticRole;
+    case ax::mojom::Role::kTimer:
+      return ATK_ROLE_TIMER;
+    case ax::mojom::Role::kToggleButton:
+      return ATK_ROLE_TOGGLE_BUTTON;
+    case ax::mojom::Role::kToolbar:
+      return ATK_ROLE_TOOL_BAR;
+    case ax::mojom::Role::kTooltip:
+      return ATK_ROLE_TOOL_TIP;
+    case ax::mojom::Role::kTree:
+      return ATK_ROLE_TREE;
+    case ax::mojom::Role::kTreeItem:
+      return ATK_ROLE_TREE_ITEM;
+    case ax::mojom::Role::kTreeGrid:
+      return ATK_ROLE_TREE_TABLE;
+    case ax::mojom::Role::kVideo:
+      return ATK_ROLE_VIDEO;
+    case ax::mojom::Role::kWindow:
+      // In ATK elements with ATK_ROLE_FRAME are windows with titles and
+      // buttons, while those with ATK_ROLE_WINDOW are windows without those
+      // elements.
+      return ATK_ROLE_FRAME;
+    case ax::mojom::Role::kClient:
+    case ax::mojom::Role::kDesktop:
+    case ax::mojom::Role::kWebView:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kFigcaption:
+      return ATK_ROLE_CAPTION;
+    case ax::mojom::Role::kUnknown:
+      // When we are not in web content, assume that a node with an unknown
+      // role is a view (which often have the unknown role).
+      return !GetDelegate()->IsWebContent() ? ATK_ROLE_PANEL : ATK_ROLE_UNKNOWN;
+    case ax::mojom::Role::kImeCandidate:
+    case ax::mojom::Role::kKeyboard:
+    case ax::mojom::Role::kNone:
+      return ATK_ROLE_REDUNDANT_OBJECT;
+    case ax::mojom::Role::kPreDeprecated:
+      NOTREACHED_NORETURN();
+  }
+}
+
+// If we were compiled with a newer version of ATK than the runtime version,
+// it's possible that the state we want to expose and/or emit an event for
+// is not present. This will generate a runtime error.
+bool PlatformSupportsState(AtkStateType atk_state_type) {
+  static absl::optional<int> max_state_type = absl::nullopt;
+  if (!max_state_type.has_value()) {
+    GEnumClass* enum_class =
+        G_ENUM_CLASS(g_type_class_ref(atk_state_type_get_type()));
+    max_state_type = enum_class->maximum;
+    g_type_class_unref(enum_class);
+  }
+  return atk_state_type < max_state_type.value();
+}
+
+void AXPlatformNodeAuraLinux::GetAtkState(AtkStateSet* atk_state_set) {
+  bool menu_active = !GetActiveMenus().empty();
+  if (!menu_active && atk_object_ == g_active_top_level_frame)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+  if (menu_active &&
+      FindAtkObjectParentFrame(GetActiveMenus().back()) == atk_object_)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+
+  if (atk_object_ && atk_object_ == g_active_views_dialog)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+
+  bool is_minimized = delegate_->IsMinimized();
+  if (is_minimized && GetRole() == ax::mojom::Role::kWindow)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ICONIFIED);
+
+  if (HasState(ax::mojom::State::kCollapsed))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDABLE);
+  if (HasState(ax::mojom::State::kDefault))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_DEFAULT);
+  if ((HasState(ax::mojom::State::kEditable) ||
+       HasState(ax::mojom::State::kRichlyEditable)) &&
+      GetData().GetRestriction() != ax::mojom::Restriction::kReadOnly) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EDITABLE);
+  }
+  if (HasState(ax::mojom::State::kExpanded)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDABLE);
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDED);
+  }
+  if (IsFocused())
+    atk_state_set_add_state(atk_state_set, ATK_STATE_FOCUSED);
+  if (IsFocusable())
+    atk_state_set_add_state(atk_state_set, ATK_STATE_FOCUSABLE);
+  if (HasState(ax::mojom::State::kHorizontal))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_HORIZONTAL);
+  if (!IsInvisibleOrIgnored()) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_VISIBLE);
+    if (!delegate_->IsOffscreen() && !is_minimized)
+      atk_state_set_add_state(atk_state_set, ATK_STATE_SHOWING);
+  }
+  if (HasState(ax::mojom::State::kMultiselectable))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_MULTISELECTABLE);
+  if (HasState(ax::mojom::State::kRequired))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_REQUIRED);
+  if (HasState(ax::mojom::State::kVertical))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_VERTICAL);
+  if (HasState(ax::mojom::State::kVisited))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_VISITED);
+  if (HasIntAttribute(ax::mojom::IntAttribute::kInvalidState) &&
+      GetIntAttribute(ax::mojom::IntAttribute::kInvalidState) !=
+          static_cast<int32_t>(ax::mojom::InvalidState::kFalse)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_INVALID_ENTRY);
+  }
+  if (HasIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState) &&
+      GetIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState) !=
+          static_cast<int32_t>(ax::mojom::AriaCurrentState::kFalse)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+  }
+#if defined(ATK_216)
+  // Runtime checks in case we were compiled with a newer version of ATK.
+  if (IsPlatformCheckable() && PlatformSupportsState(ATK_STATE_CHECKABLE))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_CHECKABLE);
+  if (HasIntAttribute(ax::mojom::IntAttribute::kHasPopup) &&
+      PlatformSupportsState(ATK_STATE_HAS_POPUP))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_HAS_POPUP);
+#endif
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kBusy))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_BUSY);
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kModal))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_MODAL);
+  if (GetData().IsSelectable())
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTABLE);
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kSelected))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTED);
+
+  if (IsTextField()) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTABLE_TEXT);
+    if (HasState(ax::mojom::State::kMultiline))
+      atk_state_set_add_state(atk_state_set, ATK_STATE_MULTI_LINE);
+    else
+      atk_state_set_add_state(atk_state_set, ATK_STATE_SINGLE_LINE);
+  }
+
+  // Special case for indeterminate progressbar.
+  if (GetRole() == ax::mojom::Role::kProgressIndicator &&
+      !HasFloatAttribute(ax::mojom::FloatAttribute::kValueForRange)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_INDETERMINATE);
+  }
+
+  if (!GetStringAttribute(ax::mojom::StringAttribute::kAutoComplete).empty() ||
+      HasState(ax::mojom::State::kAutofillAvailable)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SUPPORTS_AUTOCOMPLETION);
+  }
+
+  // Checked state
+  const auto checked_state = GetData().GetCheckedState();
+  if (checked_state == ax::mojom::CheckedState::kTrue ||
+      checked_state == ax::mojom::CheckedState::kMixed) {
+    atk_state_set_add_state(atk_state_set, GetAtkStateTypeForCheckableNode());
+  }
+
+  if (GetData().GetRestriction() != ax::mojom::Restriction::kDisabled) {
+    if (GetDelegate()->IsReadOnlySupported() &&
+        GetDelegate()->IsReadOnlyOrDisabled()) {
+#if defined(ATK_216)
+      // Runtime check in case we were compiled with a newer version of ATK.
+      if (PlatformSupportsState(ATK_STATE_READ_ONLY))
+        atk_state_set_add_state(atk_state_set, ATK_STATE_READ_ONLY);
+#endif
+    } else {
+      atk_state_set_add_state(atk_state_set, ATK_STATE_ENABLED);
+      atk_state_set_add_state(atk_state_set, ATK_STATE_SENSITIVE);
+    }
+  }
+}
+
+// Some relations only exist in a high enough ATK version.
+// If a relation has a version requirement, it will be documented in
+// the link below.
+// https://docs.gtk.org/atk/enum.RelationType.html
+struct AtkIntRelation {
+  ax::mojom::IntAttribute attribute;
+  AtkRelationType relation;
+  absl::optional<AtkRelationType> reverse_relation;
+};
+
+static AtkIntRelation kIntRelations[] = {
+    {ax::mojom::IntAttribute::kMemberOfId, ATK_RELATION_MEMBER_OF,
+     absl::nullopt},
+    {ax::mojom::IntAttribute::kPopupForId, ATK_RELATION_POPUP_FOR,
+     absl::nullopt},
+};
+
+struct AtkIntListRelation {
+  ax::mojom::IntListAttribute attribute;
+  AtkRelationType relation;
+  absl::optional<AtkRelationType> reverse_relation;
+};
+
+static AtkIntListRelation kIntListRelations[] = {
+    {ax::mojom::IntListAttribute::kControlsIds, ATK_RELATION_CONTROLLER_FOR,
+     ATK_RELATION_CONTROLLED_BY},
+#if defined(ATK_226)
+    {ax::mojom::IntListAttribute::kDetailsIds, ATK_RELATION_DETAILS,
+     ATK_RELATION_DETAILS_FOR},
+#endif
+    {ax::mojom::IntListAttribute::kDescribedbyIds, ATK_RELATION_DESCRIBED_BY,
+     ATK_RELATION_DESCRIPTION_FOR},
+#if defined(ATK_226)
+    {ax::mojom::IntListAttribute::kErrormessageIds, ATK_RELATION_ERROR_MESSAGE,
+     ATK_RELATION_ERROR_FOR},
+#endif
+    {ax::mojom::IntListAttribute::kFlowtoIds, ATK_RELATION_FLOWS_TO,
+     ATK_RELATION_FLOWS_FROM},
+    {ax::mojom::IntListAttribute::kLabelledbyIds, ATK_RELATION_LABELLED_BY,
+     ATK_RELATION_LABEL_FOR},
+};
+
+void AXPlatformNodeAuraLinux::AddRelationToSet(AtkRelationSet* relation_set,
+                                               AtkRelationType relation,
+                                               AXPlatformNode* target) {
+  DCHECK(target);
+  DCHECK(GetDelegate()->IsValidRelationTarget(target));
+
+  // If we were compiled with a newer version of ATK than the runtime version,
+  // it's possible that we might try to add a relation that doesn't exist in
+  // the runtime version of the AtkRelationType enum. This will cause a runtime
+  // error, so return early here if we are about to do that.
+  static absl::optional<int> max_relation_type = absl::nullopt;
+  if (!max_relation_type.has_value()) {
+    GEnumClass* enum_class =
+        G_ENUM_CLASS(g_type_class_ref(atk_relation_type_get_type()));
+    max_relation_type = enum_class->maximum;
+    g_type_class_unref(enum_class);
+  }
+  if (relation >= max_relation_type.value())
+    return;
+
+  atk_relation_set_add_relation_by_type(relation_set, relation,
+                                        target->GetNativeViewAccessible());
+}
+
+AtkRelationSet* AXPlatformNodeAuraLinux::GetAtkRelations() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return nullptr;
+
+  AtkRelationSet* relation_set = atk_relation_set_new();
+
+  if (IsWebDocumentForRelations()) {
+    AtkObject* parent_frame = FindAtkObjectParentFrame(atk_object);
+    if (parent_frame) {
+      atk_relation_set_add_relation_by_type(
+          relation_set, ATK_RELATION_EMBEDDED_BY, parent_frame);
+    }
+  }
+
+  if (auto* document_parent = FromAtkObject(document_parent_)) {
+    AtkObject* document = document_parent->FindPrimaryWebContentDocument();
+    if (document) {
+      atk_relation_set_add_relation_by_type(relation_set, ATK_RELATION_EMBEDS,
+                                            document);
+    }
+  }
+
+  // For each possible relation defined by an IntAttribute, we test that
+  // attribute and then look for reverse relations.
+  for (auto relation : kIntRelations) {
+    if (AXPlatformNode* target =
+            GetDelegate()->GetTargetNodeForRelation(relation.attribute))
+      AddRelationToSet(relation_set, relation.relation, target);
+
+    if (!relation.reverse_relation.has_value())
+      continue;
+
+    std::vector<AXPlatformNode*> target_ids =
+        GetDelegate()->GetSourceNodesForReverseRelations(relation.attribute);
+    for (AXPlatformNode* target : target_ids) {
+      AddRelationToSet(relation_set, relation.reverse_relation.value(), target);
+    }
+  }
+
+  // Now we do the same for each possible relation defined by an
+  // IntListAttribute. In this case we need to handle each target in the list.
+  for (const auto& relation : kIntListRelations) {
+    std::vector<AXPlatformNode*> targets =
+        GetDelegate()->GetTargetNodesForRelation(relation.attribute);
+    for (AXPlatformNode* target : targets) {
+      AddRelationToSet(relation_set, relation.relation, target);
+    }
+
+    if (!relation.reverse_relation.has_value())
+      continue;
+
+    std::vector<AXPlatformNode*> reverse_target_ids =
+        GetDelegate()->GetSourceNodesForReverseRelations(relation.attribute);
+    for (AXPlatformNode* target : reverse_target_ids) {
+      AddRelationToSet(relation_set, relation.reverse_relation.value(), target);
+    }
+  }
+
+  return relation_set;
+}
+
+AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() = default;
+
+AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() {
+  if (g_current_selected == this)
+    g_current_selected = nullptr;
+
+  DestroyAtkObjects();
+
+  if (window_activate_event_postponed_)
+    AtkUtilAuraLinux::GetInstance()->CancelPostponedEventsFor(this);
+
+  SetWeakGPtrToAtkObject(&document_parent_, nullptr);
+}
+
+void AXPlatformNodeAuraLinux::Destroy() {
+  DestroyAtkObjects();
+  AXPlatformNodeBase::Destroy();
+}
+
+void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) {
+  // Initialize ATK.
+  AXPlatformNodeBase::Init(delegate);
+
+  // Only create the AtkObject if we know enough information.
+  if (GetRole() != ax::mojom::Role::kUnknown)
+    GetOrCreateAtkObject();
+}
+
+bool AXPlatformNodeAuraLinux::IsPlatformCheckable() const {
+  if (GetRole() == ax::mojom::Role::kToggleButton)
+    return false;
+
+  return AXPlatformNodeBase::IsPlatformCheckable();
+}
+
+absl::optional<size_t> AXPlatformNodeAuraLinux::GetIndexInParent() {
+  AXPlatformNode* parent =
+      AXPlatformNode::FromNativeViewAccessible(GetParent());
+  // Even though the node doesn't have its parent, GetParent() could return the
+  // application. Since the detached view has the kUnknown role and the
+  // restriction is kDisabled, it early returns before finding the index.
+  if (parent == AXPlatformNodeAuraLinux::application() &&
+      GetRole() == ax::mojom::Role::kUnknown &&
+      GetData().GetRestriction() == ax::mojom::Restriction::kDisabled) {
+    return absl::nullopt;
+  }
+
+  return AXPlatformNodeBase::GetIndexInParent();
+}
+
+void AXPlatformNodeAuraLinux::EnsureAtkObjectIsValid() {
+  if (atk_object_) {
+    // If the object's role changes and that causes its
+    // interface mask to change, we need to create a new
+    // AtkObject for it.
+    ImplementedAtkInterfaces interface_mask = GetGTypeInterfaceMask(GetData());
+    if (interface_mask != interface_mask_)
+      DestroyAtkObjects();
+  }
+
+  if (!atk_object_) {
+    GetOrCreateAtkObject();
+  }
+}
+
+gfx::NativeViewAccessible AXPlatformNodeAuraLinux::GetNativeViewAccessible() {
+  return GetOrCreateAtkObject();
+}
+
+gfx::NativeViewAccessible AXPlatformNodeAuraLinux::GetOrCreateAtkObject() {
+  if (!atk_object_) {
+    atk_object_ = CreateAtkObject();
+  }
+  return atk_object_;
+}
+
+void AXPlatformNodeAuraLinux::OnCheckedStateChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(
+      ATK_OBJECT(obj), GetAtkStateTypeForCheckableNode(),
+      GetData().GetCheckedState() != ax::mojom::CheckedState::kFalse);
+}
+
+void AXPlatformNodeAuraLinux::OnEnabledChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(
+      obj, ATK_STATE_ENABLED,
+      GetData().GetRestriction() != ax::mojom::Restriction::kDisabled);
+
+  atk_object_notify_state_change(
+      obj, ATK_STATE_SENSITIVE,
+      GetData().GetRestriction() != ax::mojom::Restriction::kDisabled);
+}
+
+void AXPlatformNodeAuraLinux::OnBusyStateChanged(bool is_busy) {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(obj, ATK_STATE_BUSY, is_busy);
+}
+
+void AXPlatformNodeAuraLinux::OnExpandedStateChanged(bool is_expanded) {
+  // When a list box is expanded, it becomes visible. This means that it might
+  // now have a different role (the role for hidden Views is kUnknown).  We
+  // need to recreate the AtkObject in this case because a change in roles
+  // might imply a change in ATK interfaces implemented.
+  EnsureAtkObjectIsValid();
+
+  DCHECK(HasState(ax::mojom::State::kCollapsed) ||
+         HasState(ax::mojom::State::kExpanded));
+
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(obj, ATK_STATE_EXPANDED, is_expanded);
+}
+
+void AXPlatformNodeAuraLinux::OnShowingStateChanged(bool is_showing) {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(obj, ATK_STATE_SHOWING, is_showing);
+}
+
+void AXPlatformNodeAuraLinux::OnMenuPopupStart() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  AtkObject* parent_frame = FindAtkObjectParentFrame(atk_object);
+  if (!parent_frame)
+    return;
+
+  // Exit early if kMenuPopupStart is sent multiple times for the same menu.
+  std::vector<AtkObject*>& active_menus = GetActiveMenus();
+  bool menu_already_open = !active_menus.empty();
+  if (menu_already_open && active_menus.back() == atk_object)
+    return;
+
+  // We also want to inform the AT that menu the is now showing. Normally this
+  // event is not fired because the menu will be created with the
+  // ATK_STATE_SHOWING already set to TRUE.
+  atk_object_notify_state_change(atk_object, ATK_STATE_SHOWING, TRUE);
+
+  // We need to compute this before modifying the active menu stack.
+  AtkObject* previous_active_frame = ComputeActiveTopLevelFrame();
+
+  active_menus.push_back(atk_object);
+
+  // We exit early if the newly activated menu has the same AtkWindow as the
+  // previous one.
+  if (previous_active_frame == parent_frame)
+    return;
+  if (previous_active_frame) {
+    g_signal_emit_by_name(previous_active_frame, "deactivate");
+    atk_object_notify_state_change(previous_active_frame, ATK_STATE_ACTIVE,
+                                   FALSE);
+  }
+  g_signal_emit_by_name(parent_frame, "activate");
+  atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, TRUE);
+}
+
+void AXPlatformNodeAuraLinux::OnMenuPopupEnd() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  AtkObject* parent_frame = FindAtkObjectParentFrame(atk_object);
+  if (!parent_frame)
+    return;
+
+  atk_object_notify_state_change(atk_object, ATK_STATE_SHOWING, FALSE);
+
+  // kMenuPopupHide may be called multiple times for the same menu, so only
+  // remove it if our parent frame matches the most recently opened menu.
+  std::vector<AtkObject*>& active_menus = GetActiveMenus();
+  DCHECK(!active_menus.empty())
+      << "Asymmetrical menupopupend events -- too many";
+
+  active_menus.pop_back();
+  AtkObject* new_active_item = ComputeActiveTopLevelFrame();
+  if (new_active_item != parent_frame) {
+    // Newly activated menu has the different AtkWindow as the previous one.
+    g_signal_emit_by_name(parent_frame, "deactivate");
+    atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, FALSE);
+    if (new_active_item) {
+      g_signal_emit_by_name(new_active_item, "activate");
+      atk_object_notify_state_change(new_active_item, ATK_STATE_ACTIVE, TRUE);
+    }
+  }
+
+  // All menus are closed.
+  if (active_menus.empty())
+    OnAllMenusEnded();
+}
+
+void AXPlatformNodeAuraLinux::ResendFocusSignalsForCurrentlyFocusedNode() {
+  auto* frame = FromAtkObject(g_active_top_level_frame);
+  if (!frame)
+    return;
+
+  AtkObject* focused_node = frame->GetDelegate()->GetFocus();
+  if (!focused_node)
+    return;
+
+  g_signal_emit_by_name(focused_node, "focus-event", true);
+  atk_object_notify_state_change(focused_node, ATK_STATE_FOCUSED, true);
+}
+
+void AXPlatformNodeAuraLinux::SetAsCurrentlyFocusedNode() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  SetWeakGPtrToAtkObject(&g_current_focused, obj);
+}
+
+// All menus have closed.
+void AXPlatformNodeAuraLinux::OnAllMenusEnded() {
+  if (!GetActiveMenus().empty() && g_active_top_level_frame &&
+      ComputeActiveTopLevelFrame() != g_active_top_level_frame) {
+    g_signal_emit_by_name(g_active_top_level_frame, "activate");
+    atk_object_notify_state_change(g_active_top_level_frame, ATK_STATE_ACTIVE,
+                                   TRUE);
+  }
+
+  GetActiveMenus().clear();
+  ResendFocusSignalsForCurrentlyFocusedNode();
+}
+
+void AXPlatformNodeAuraLinux::OnWindowActivated() {
+  AtkObject* parent_frame = FindAtkObjectParentFrame(GetOrCreateAtkObject());
+  if (!parent_frame || parent_frame == g_active_top_level_frame)
+    return;
+
+  SetActiveTopLevelFrame(parent_frame);
+
+  g_signal_emit_by_name(parent_frame, "activate");
+  atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, TRUE);
+
+  // We also send a focus event for the currently focused element, so that
+  // the user knows where the focus is when the toplevel window regains focus.
+  if (g_current_focused &&
+      IsFrameAncestorOfAtkObject(parent_frame, g_current_focused)) {
+    g_signal_emit_by_name(g_current_focused, "focus-event", true);
+    atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
+                                   ATK_STATE_FOCUSED, true);
+  }
+}
+
+void AXPlatformNodeAuraLinux::OnWindowDeactivated() {
+  AtkObject* parent_frame = FindAtkObjectParentFrame(GetOrCreateAtkObject());
+  if (!parent_frame || parent_frame != g_active_top_level_frame)
+    return;
+
+  SetActiveTopLevelFrame(nullptr);
+
+  g_signal_emit_by_name(parent_frame, "deactivate");
+  atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, FALSE);
+}
+
+void AXPlatformNodeAuraLinux::OnWindowVisibilityChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  if (GetAtkRole() != ATK_ROLE_FRAME)
+    return;
+
+  bool minimized = delegate_->IsMinimized();
+  if (minimized == was_minimized_)
+    return;
+
+  was_minimized_ = minimized;
+  if (minimized)
+    g_signal_emit_by_name(atk_object, "minimize");
+  else
+    g_signal_emit_by_name(atk_object, "restore");
+  atk_object_notify_state_change(atk_object, ATK_STATE_ICONIFIED, minimized);
+}
+
+void AXPlatformNodeAuraLinux::OnScrolledToAnchor() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+  // The text-caret-moved event is used to signal a scroll to anchor event.
+  if (ATK_IS_TEXT(atk_object)) {
+    g_signal_emit_by_name(atk_object, "text-caret-moved", 0);
+  }
+}
+
+void AXPlatformNodeAuraLinux::SetActiveViewsDialog() {
+  AtkObject* old_views_dialog = g_active_views_dialog;
+  AtkObject* new_views_dialog = nullptr;
+
+  AtkObject* parent = GetOrCreateAtkObject();
+  if (!parent)
+    return;
+
+  if (!GetDelegate()->IsWebContent()) {
+    while (parent) {
+      if (atk_object::GetRole(parent) == ATK_ROLE_DIALOG) {
+        new_views_dialog = parent;
+        break;
+      }
+      parent = atk_object::GetParent(parent);
+    }
+  }
+
+  if (old_views_dialog == new_views_dialog)
+    return;
+
+  SetWeakGPtrToAtkObject(&g_active_views_dialog, new_views_dialog);
+  if (old_views_dialog)
+    atk_object_notify_state_change(old_views_dialog, ATK_STATE_ACTIVE, FALSE);
+  if (new_views_dialog)
+    atk_object_notify_state_change(new_views_dialog, ATK_STATE_ACTIVE, TRUE);
+}
+
+void AXPlatformNodeAuraLinux::OnFocused() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  if (atk_object::GetRole(atk_object) == ATK_ROLE_FRAME) {
+    OnWindowActivated();
+    return;
+  }
+
+  if (atk_object == g_current_focused)
+    return;
+
+  SetActiveViewsDialog();
+
+  if (g_current_focused) {
+    g_signal_emit_by_name(g_current_focused, "focus-event", false);
+    atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
+                                   ATK_STATE_FOCUSED, false);
+  }
+
+  SetWeakGPtrToAtkObject(&g_current_focused, atk_object);
+
+  g_signal_emit_by_name(g_current_focused, "focus-event", true);
+  atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
+                                 ATK_STATE_FOCUSED, true);
+}
+
+void AXPlatformNodeAuraLinux::OnSelected() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+  if (g_current_selected && !g_current_selected->GetBoolAttribute(
+                                ax::mojom::BoolAttribute::kSelected)) {
+    atk_object_notify_state_change(
+        ATK_OBJECT(g_current_selected->GetOrCreateAtkObject()),
+        ATK_STATE_SELECTED, false);
+  }
+
+  g_current_selected = this;
+  if (ATK_IS_OBJECT(atk_object)) {
+    atk_object_notify_state_change(ATK_OBJECT(atk_object), ATK_STATE_SELECTED,
+                                   true);
+  }
+}
+
+void AXPlatformNodeAuraLinux::OnSelectedChildrenChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  g_signal_emit_by_name(obj, "selection-changed", true);
+}
+
+bool AXPlatformNodeAuraLinux::EmitsAtkTextEvents() const {
+  // Objects which do not implement AtkText cannot emit AtkText events.
+  if (!atk_object_ || !ATK_IS_TEXT(atk_object_))
+    return false;
+
+  // Objects which do implement AtkText, but are ignored or invisible should not
+  // emit AtkText events.
+  if (IsInvisibleOrIgnored())
+    return false;
+
+  // If this node is not a static text node, it supports the full AtkText
+  // interface.
+  if (GetAtkRole() != kStaticRole)
+    return true;
+
+  // If this node has children it is not a static text leaf node and supports
+  // the full AtkText interface.
+  if (GetChildCount())
+    return true;
+
+  return false;
+}
+
+void AXPlatformNodeAuraLinux::GetFullSelection(int32_t* anchor_node_id,
+                                               int* anchor_offset,
+                                               int32_t* focus_node_id,
+                                               int* focus_offset) {
+  DCHECK(anchor_node_id);
+  DCHECK(anchor_offset);
+  DCHECK(focus_node_id);
+  DCHECK(focus_offset);
+
+  if (IsAtomicTextField() &&
+      GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, anchor_offset) &&
+      GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, focus_offset)) {
+    int32_t node_id = GetData().id != -1 ? GetData().id : GetUniqueId();
+    *anchor_node_id = *focus_node_id = node_id;
+    return;
+  }
+
+  AXSelection selection = GetDelegate()->GetUnignoredSelection();
+  *anchor_node_id = selection.anchor_object_id;
+  *anchor_offset = selection.anchor_offset;
+  *focus_node_id = selection.focus_object_id;
+  *focus_offset = selection.focus_offset;
+}
+
+AXPlatformNodeAuraLinux& AXPlatformNodeAuraLinux::FindEditableRootOrDocument() {
+  if (GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
+    return *this;
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kNonAtomicTextFieldRoot) &&
+      HasState(ax::mojom::State::kEditable))
+    return *this;
+  if (auto* parent = FromAtkObject(GetParent()))
+    return parent->FindEditableRootOrDocument();
+  return *this;
+}
+
+AXPlatformNodeAuraLinux* AXPlatformNodeAuraLinux::FindCommonAncestor(
+    AXPlatformNodeAuraLinux* other) {
+  if (this == other || other->IsDescendantOf(this))
+    return this;
+  if (auto* parent = FromAtkObject(GetParent()))
+    return parent->FindCommonAncestor(other);
+  return nullptr;
+}
+
+void AXPlatformNodeAuraLinux::UpdateSelectionInformation(int32_t anchor_node_id,
+                                                         int anchor_offset,
+                                                         int32_t focus_node_id,
+                                                         int focus_offset) {
+  had_nonzero_width_selection =
+      focus_node_id != anchor_node_id || focus_offset != anchor_offset;
+  current_caret_ = std::make_pair(focus_node_id, focus_offset);
+}
+
+void AXPlatformNodeAuraLinux::EmitSelectionChangedSignal(bool had_selection) {
+  if (!EmitsAtkTextEvents()) {
+    if (auto* parent = FromAtkObject(GetParent()))
+      parent->EmitSelectionChangedSignal(had_selection);
+    return;
+  }
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+  DCHECK(ATK_IS_TEXT(atk_object));
+
+  // ATK does not consider a collapsed selection a selection, so
+  // when the collapsed selection changes (caret movement), we should
+  // avoid sending text-selection-changed events.
+  if (HasSelection() || had_selection)
+    g_signal_emit_by_name(atk_object, "text-selection-changed");
+}
+
+void AXPlatformNodeAuraLinux::EmitCaretChangedSignal() {
+  if (!EmitsAtkTextEvents()) {
+    if (auto* parent = FromAtkObject(GetParent()))
+      parent->EmitCaretChangedSignal();
+    return;
+  }
+
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  DCHECK(ATK_IS_TEXT(atk_object));
+  g_signal_emit_by_name(atk_object, "text-caret-moved",
+                        UTF16ToUnicodeOffsetInText(selection.second));
+}
+
+void AXPlatformNodeAuraLinux::OnTextAttributesChanged() {
+  if (!EmitsAtkTextEvents()) {
+    if (auto* parent = FromAtkObject(GetParent()))
+      parent->OnTextAttributesChanged();
+    return;
+  }
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  DCHECK(ATK_IS_TEXT(atk_object));
+  g_signal_emit_by_name(atk_object, "text-attributes-changed");
+}
+
+void AXPlatformNodeAuraLinux::OnTextSelectionChanged() {
+  int32_t anchor_node_id, focus_node_id;
+  int anchor_offset, focus_offset;
+  GetFullSelection(&anchor_node_id, &anchor_offset, &focus_node_id,
+                   &focus_offset);
+
+  auto* anchor_node = static_cast<AXPlatformNodeAuraLinux*>(
+      GetDelegate()->GetFromNodeID(anchor_node_id));
+  auto* focus_node = static_cast<AXPlatformNodeAuraLinux*>(
+      GetDelegate()->GetFromNodeID(focus_node_id));
+  if (!anchor_node || !focus_node)
+    return;
+
+  AXPlatformNodeAuraLinux& editable_root = FindEditableRootOrDocument();
+  AXPlatformNodeAuraLinux* common_ancestor =
+      focus_node->FindCommonAncestor(anchor_node);
+  if (common_ancestor) {
+    common_ancestor->EmitSelectionChangedSignal(
+        editable_root.HadNonZeroWidthSelection());
+  }
+
+  // It's possible for the selection to change and for the caret to stay in
+  // place. This might happen if the selection is totally reset with a
+  // different anchor node, but the same focus node. We should avoid sending a
+  // caret changed signal in that case.
+  std::pair<int32_t, int> prev_caret = editable_root.GetCurrentCaret();
+  if (prev_caret.first != focus_node_id || prev_caret.second != focus_offset)
+    focus_node->EmitCaretChangedSignal();
+
+  editable_root.UpdateSelectionInformation(anchor_node_id, anchor_offset,
+                                           focus_node_id, focus_offset);
+}
+
+bool AXPlatformNodeAuraLinux::SupportsSelectionWithAtkSelection() {
+  return SupportsToggle(GetRole()) ||
+         GetRole() == ax::mojom::Role::kListBoxOption;
+}
+
+void AXPlatformNodeAuraLinux::OnDescriptionChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  std::string description;
+  GetStringAttribute(ax::mojom::StringAttribute::kDescription, &description);
+
+  AtkPropertyValues property_values;
+  property_values.property_name = "accessible-description";
+  property_values.new_value = G_VALUE_INIT;
+  g_value_init(&property_values.new_value, G_TYPE_STRING);
+  g_value_set_string(&property_values.new_value, description.c_str());
+  g_signal_emit_by_name(G_OBJECT(atk_object),
+                        "property-change::accessible-description",
+                        &property_values, nullptr);
+  g_value_unset(&property_values.new_value);
+}
+
+void AXPlatformNodeAuraLinux::OnSortDirectionChanged() {
+  AXPlatformNodeBase* table = GetTable();
+  if (!table)
+    return;
+
+  AtkObject* atk_table = table->GetNativeViewAccessible();
+  DCHECK(ATK_IS_TABLE(atk_table));
+
+  if (GetRole() == ax::mojom::Role::kColumnHeader)
+    g_signal_emit_by_name(atk_table, "row-reordered");
+  else if (GetRole() == ax::mojom::Role::kRowHeader)
+    g_signal_emit_by_name(atk_table, "column-reordered");
+}
+
+void AXPlatformNodeAuraLinux::OnValueChanged() {
+  // For the AtkText interface to work on non-web content nodes, we need to
+  // update the nodes' hypertext and trigger text change signals when the value
+  // changes. Otherwise, for web and PDF content, this is handled by
+  // "BrowserAccessibilityAuraLinux".
+  if (!GetDelegate()->IsWebContent())
+    UpdateHypertext();
+
+  if (!GetData().IsRangeValueSupported())
+    return;
+
+  float float_val;
+  if (!GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, &float_val))
+    return;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  AtkPropertyValues property_values;
+  property_values.property_name = "accessible-value";
+
+  property_values.new_value = G_VALUE_INIT;
+  g_value_init(&property_values.new_value, G_TYPE_DOUBLE);
+  g_value_set_double(&property_values.new_value,
+                     static_cast<double>(float_val));
+  g_signal_emit_by_name(G_OBJECT(atk_object),
+                        "property-change::accessible-value", &property_values,
+                        nullptr);
+}
+
+void AXPlatformNodeAuraLinux::OnNameChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object) {
+    return;
+  }
+  std::string previous_accessible_name = accessible_name_;
+  // Calling atk_object_get_name will update the value of accessible_name_.
+  if (!g_strcmp0(atk_object::GetName(atk_object),
+                 previous_accessible_name.c_str()))
+    return;
+
+  g_object_notify(G_OBJECT(atk_object), "accessible-name");
+}
+
+void AXPlatformNodeAuraLinux::OnDocumentTitleChanged() {
+  if (!g_active_top_level_frame)
+    return;
+
+  // We always want to notify on the top frame.
+  AXPlatformNodeAuraLinux* window = FromAtkObject(g_active_top_level_frame);
+  if (window)
+    window->OnNameChanged();
+}
+
+void AXPlatformNodeAuraLinux::OnSubtreeCreated() {
+  // We might not have a parent, in that case we don't need to send the event.
+  // We also don't want to notify if this is an ignored node
+  if (!GetParent() || GetData().IsIgnored())
+    return;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  auto index_in_parent = GetIndexInParent();
+  gint index_gint = index_in_parent.has_value()
+                        ? static_cast<gint>(index_in_parent.value())
+                        : -1;
+  g_signal_emit_by_name(GetParent(), "children-changed::add", index_gint,
+                        atk_object);
+}
+
+void AXPlatformNodeAuraLinux::OnSubtreeWillBeDeleted() {
+  // There is a chance there won't be a parent as we're in the deletion process.
+  // We also don't want to notify if this is an ignored node
+  if (!GetParent() || GetData().IsIgnored())
+    return;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  auto index_in_parent = GetIndexInParent();
+  gint index_gint = index_in_parent.has_value()
+                        ? static_cast<gint>(index_in_parent.value())
+                        : -1;
+  g_signal_emit_by_name(GetParent(), "children-changed::remove", index_gint,
+                        atk_object);
+}
+
+void AXPlatformNodeAuraLinux::OnParentChanged() {
+  if (!atk_object_)
+    return;
+
+  AtkPropertyValues property_values;
+  property_values.property_name = "accessible-parent";
+  property_values.new_value = G_VALUE_INIT;
+  g_value_init(&property_values.new_value, G_TYPE_OBJECT);
+  g_value_set_object(&property_values.new_value, GetParent());
+  g_signal_emit_by_name(G_OBJECT(atk_object_),
+                        "property-change::accessible-parent", &property_values,
+                        nullptr);
+  g_value_unset(&property_values.new_value);
+}
+
+void AXPlatformNodeAuraLinux::OnReadonlyChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+#if defined(ATK_216)
+  // Runtime check in case we were compiled with a newer version of ATK.
+  if (!PlatformSupportsState(ATK_STATE_READ_ONLY))
+    return;
+
+  atk_object_notify_state_change(
+      obj, ATK_STATE_READ_ONLY,
+      GetData().GetRestriction() == ax::mojom::Restriction::kReadOnly);
+#endif
+}
+
+void AXPlatformNodeAuraLinux::OnInvalidStatusChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  atk_object_notify_state_change(
+      ATK_OBJECT(atk_object), ATK_STATE_INVALID_ENTRY,
+      GetData().GetInvalidState() != ax::mojom::InvalidState::kFalse);
+}
+
+void AXPlatformNodeAuraLinux::OnAriaCurrentChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  ax::mojom::AriaCurrentState aria_current =
+      static_cast<ax::mojom::AriaCurrentState>(
+          GetIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState));
+  atk_object_notify_state_change(
+      ATK_OBJECT(atk_object), ATK_STATE_ACTIVE,
+      aria_current != ax::mojom::AriaCurrentState::kNone &&
+          aria_current != ax::mojom::AriaCurrentState::kFalse);
+}
+
+void AXPlatformNodeAuraLinux::OnAlertShown() {
+  DCHECK(ui::IsAlert(GetRole()));
+  atk_object_notify_state_change(ATK_OBJECT(GetOrCreateAtkObject()),
+                                 ATK_STATE_SHOWING, TRUE);
+}
+
+void AXPlatformNodeAuraLinux::RunPostponedEvents() {
+  if (window_activate_event_postponed_) {
+    OnWindowActivated();
+    window_activate_event_postponed_ = false;
+  }
+}
+
+void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(
+    ax::mojom::Event event_type) {
+  if (!GetOrCreateAtkObject())
+    return;
+  AXPlatformNodeBase::NotifyAccessibilityEvent(event_type);
+  switch (event_type) {
+    // kMenuStart/kMenuEnd: the menu system has started / stopped.
+    // kMenuPopupStart/kMenuPopupEnd: an individual menu/submenu has
+    // opened/closed.
+    case ax::mojom::Event::kMenuPopupStart:
+      OnMenuPopupStart();
+      break;
+    case ax::mojom::Event::kMenuPopupEnd:
+      OnMenuPopupEnd();
+      break;
+    case ax::mojom::Event::kCheckedStateChanged:
+      OnCheckedStateChanged();
+      break;
+    case ax::mojom::Event::kExpandedChanged:
+      OnExpandedStateChanged(HasState(ax::mojom::State::kExpanded));
+      break;
+    case ax::mojom::Event::kFocus:
+    case ax::mojom::Event::kFocusContext:
+      OnFocused();
+      break;
+    case ax::mojom::Event::kFocusAfterMenuClose:
+      // The saved focused object is not always getting cleared when a popup
+      // becomes active. As a result, when the popup is dismissed, OnFocused()
+      // will return early thinking focus has not changed. Rather than trying
+      // to catch every case, take kFocusAfterMenuClose as a clear indication
+      // that a focus change should be presented and reset the saved focus.
+      g_current_focused = nullptr;
+      OnFocused();
+      break;
+    case ax::mojom::Event::kSelection:
+      OnSelected();
+      // When changing tabs also fire a name changed event.
+      if (GetRole() == ax::mojom::Role::kTab)
+        OnDocumentTitleChanged();
+      break;
+    case ax::mojom::Event::kSelectedChildrenChanged:
+      OnSelectedChildrenChanged();
+      break;
+    case ax::mojom::Event::kStateChanged:
+      // We need to know what state changed and fire an event for that specific
+      // state. Because we don't know what state changed, we deliberately do
+      // nothing here.
+      break;
+    case ax::mojom::Event::kTextChanged:
+      OnNameChanged();
+      break;
+    case ax::mojom::Event::kTextSelectionChanged:
+      OnTextSelectionChanged();
+      break;
+    case ax::mojom::Event::kValueChanged:
+      OnValueChanged();
+      break;
+    case ax::mojom::Event::kWindowActivated:
+      if (AtkUtilAuraLinux::GetInstance()->IsAtSpiReady()) {
+        OnWindowActivated();
+      } else {
+        AtkUtilAuraLinux::GetInstance()->PostponeEventsFor(this);
+        window_activate_event_postponed_ = true;
+      }
+      break;
+    case ax::mojom::Event::kWindowDeactivated:
+      if (AtkUtilAuraLinux::GetInstance()->IsAtSpiReady()) {
+        OnWindowDeactivated();
+      } else {
+        AtkUtilAuraLinux::GetInstance()->CancelPostponedEventsFor(this);
+        window_activate_event_postponed_ = false;
+      }
+      break;
+    case ax::mojom::Event::kWindowVisibilityChanged:
+      OnWindowVisibilityChanged();
+      break;
+    case ax::mojom::Event::kLoadComplete:
+    case ax::mojom::Event::kDocumentTitleChanged:
+      // Sometimes, e.g. upon navigating away from the page, the tree is
+      // rebuilt rather than modified. The kDocumentTitleChanged event occurs
+      // prior to the rebuild and so is added on the previous root node. When
+      // the tree is rebuilt and the old node removed, the events on the old
+      // node are removed and no new kDocumentTitleChanged will be emitted. To
+      // ensure we still fire the event, though, we also pay attention to
+      // kLoadComplete.
+      OnDocumentTitleChanged();
+      break;
+    case ax::mojom::Event::kAlert:
+      OnAlertShown();
+      break;
+    default:
+      break;
+  }
+}
+
+absl::optional<std::pair<int, int>>
+AXPlatformNodeAuraLinux::GetEmbeddedObjectIndicesForId(int id) {
+  auto iterator = base::ranges::find(hypertext_.hyperlinks, id);
+  if (iterator == hypertext_.hyperlinks.end())
+    return absl::nullopt;
+  int hyperlink_index = std::distance(hypertext_.hyperlinks.begin(), iterator);
+
+  auto offset =
+      base::ranges::find(hypertext_.hyperlink_offset_to_index, hyperlink_index,
+                         &AXLegacyHypertext::OffsetToIndex::value_type::second);
+  if (offset == hypertext_.hyperlink_offset_to_index.end())
+    return absl::nullopt;
+
+  return std::make_pair(UTF16ToUnicodeOffsetInText(offset->first),
+                        UTF16ToUnicodeOffsetInText(offset->first + 1));
+}
+
+absl::optional<std::pair<int, int>>
+AXPlatformNodeAuraLinux::GetEmbeddedObjectIndices() {
+  auto* parent = FromAtkObject(GetParent());
+  if (!parent)
+    return absl::nullopt;
+  return parent->GetEmbeddedObjectIndicesForId(GetUniqueId());
+}
+
+void AXPlatformNodeAuraLinux::UpdateHypertext() {
+  EnsureAtkObjectIsValid();
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  AXLegacyHypertext old_hypertext = hypertext_;
+  base::OffsetAdjuster::Adjustments old_adjustments = GetHypertextAdjustments();
+
+  UpdateComputedHypertext();
+  text_unicode_adjustments_ = absl::nullopt;
+  offset_to_text_attributes_.clear();
+
+  if ((!HasState(ax::mojom::State::kEditable) ||
+       GetData().GetRestriction() == ax::mojom::Restriction::kReadOnly) &&
+      !IsInLiveRegion()) {
+    return;
+  }
+
+  if (!EmitsAtkTextEvents())
+    return;
+
+  size_t shared_prefix, old_len, new_len;
+  ComputeHypertextRemovedAndInserted(old_hypertext, &shared_prefix, &old_len,
+                                     &new_len);
+  if (old_len > 0) {
+    std::u16string removed_substring =
+        old_hypertext.hypertext.substr(shared_prefix, old_len);
+
+    size_t shared_unicode_prefix = shared_prefix;
+    base::OffsetAdjuster::AdjustOffset(old_adjustments, &shared_unicode_prefix);
+    size_t shared_unicode_suffix = shared_prefix + old_len;
+    base::OffsetAdjuster::AdjustOffset(old_adjustments, &shared_unicode_suffix);
+
+    g_signal_emit_by_name(
+        atk_object, "text-remove",
+        shared_unicode_prefix,                  // position of removal
+        shared_unicode_suffix - shared_prefix,  // length of removal
+        base::UTF16ToUTF8(removed_substring).c_str());
+  }
+
+  if (new_len > 0) {
+    std::u16string inserted_substring =
+        hypertext_.hypertext.substr(shared_prefix, new_len);
+    size_t shared_unicode_prefix = UTF16ToUnicodeOffsetInText(shared_prefix);
+    size_t shared_unicode_suffix =
+        UTF16ToUnicodeOffsetInText(shared_prefix + new_len);
+    g_signal_emit_by_name(
+        atk_object, "text-insert",
+        shared_unicode_prefix,                          // position of insertion
+        shared_unicode_suffix - shared_unicode_prefix,  // length of insertion
+        base::UTF16ToUTF8(inserted_substring).c_str());
+  }
+}
+
+const AXLegacyHypertext& AXPlatformNodeAuraLinux::GetAXHypertext() {
+  return hypertext_;
+}
+
+const base::OffsetAdjuster::Adjustments&
+AXPlatformNodeAuraLinux::GetHypertextAdjustments() {
+  if (text_unicode_adjustments_.has_value())
+    return *text_unicode_adjustments_;
+
+  text_unicode_adjustments_.emplace();
+
+  std::u16string text = GetHypertext();
+  size_t text_length = text.size();
+  for (size_t i = 0; i < text_length; i++) {
+    base_icu::UChar32 code_point;
+    size_t original_i = i;
+    base::ReadUnicodeCharacter(text.c_str(), text_length + 1, &i, &code_point);
+
+    if ((i - original_i + 1) != 1) {
+      text_unicode_adjustments_->push_back(
+          base::OffsetAdjuster::Adjustment(original_i, i - original_i + 1, 1));
+    }
+  }
+
+  return *text_unicode_adjustments_;
+}
+
+size_t AXPlatformNodeAuraLinux::UTF16ToUnicodeOffsetInText(
+    size_t utf16_offset) {
+  size_t unicode_offset = utf16_offset;
+  base::OffsetAdjuster::AdjustOffset(GetHypertextAdjustments(),
+                                     &unicode_offset);
+  return unicode_offset;
+}
+
+size_t AXPlatformNodeAuraLinux::UnicodeToUTF16OffsetInText(int unicode_offset) {
+  if (unicode_offset == kStringLengthOffset)
+    return GetHypertext().size();
+
+  size_t utf16_offset = unicode_offset;
+  base::OffsetAdjuster::UnadjustOffset(GetHypertextAdjustments(),
+                                       &utf16_offset);
+  return utf16_offset;
+}
+
+int AXPlatformNodeAuraLinux::GetTextOffsetAtPoint(int x,
+                                                  int y,
+                                                  AtkCoordType atk_coord_type) {
+  if (!GetExtentsRelativeToAtkCoordinateType(atk_coord_type).Contains(x, y))
+    return -1;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return -1;
+
+  int count = atk_text::GetCharacterCount(ATK_TEXT(atk_object));
+  for (int i = 0; i < count; i++) {
+    int out_x, out_y, out_width, out_height;
+    atk_text::GetCharacterExtents(ATK_TEXT(atk_object), i, &out_x, &out_y,
+                                  &out_width, &out_height, atk_coord_type);
+    gfx::Rect rect(out_x, out_y, out_width, out_height);
+    if (rect.Contains(x, y))
+      return i;
+  }
+  return -1;
+}
+
+gfx::Vector2d AXPlatformNodeAuraLinux::GetParentOriginInScreenCoordinates()
+    const {
+  AtkObject* parent = GetParent();
+  if (!parent)
+    return gfx::Vector2d();
+
+  const AXPlatformNode* parent_node =
+      AXPlatformNode::FromNativeViewAccessible(parent);
+  if (!parent)
+    return gfx::Vector2d();
+
+  return parent_node->GetDelegate()
+      ->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                      AXClippingBehavior::kUnclipped)
+      .OffsetFromOrigin();
+}
+
+gfx::Vector2d AXPlatformNodeAuraLinux::GetParentFrameOriginInScreenCoordinates()
+    const {
+  AtkObject* frame = FindAtkObjectParentFrame(atk_object_);
+  if (!frame)
+    return gfx::Vector2d();
+
+  const AXPlatformNode* frame_node =
+      AXPlatformNode::FromNativeViewAccessible(frame);
+  if (!frame_node)
+    return gfx::Vector2d();
+
+  return frame_node->GetDelegate()
+      ->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                      AXClippingBehavior::kUnclipped)
+      .OffsetFromOrigin();
+}
+
+gfx::Rect AXPlatformNodeAuraLinux::GetExtentsRelativeToAtkCoordinateType(
+    AtkCoordType coord_type) const {
+  gfx::Rect extents = delegate_->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                                               AXClippingBehavior::kUnclipped);
+  switch (coord_type) {
+    case ATK_XY_SCREEN:
+      break;
+    case ATK_XY_WINDOW: {
+      gfx::Vector2d window_origin = -GetParentFrameOriginInScreenCoordinates();
+      extents.Offset(window_origin);
+      break;
+    }
+#if defined(ATK_230)
+    case ATK_XY_PARENT: {
+      gfx::Vector2d parent_origin = -GetParentOriginInScreenCoordinates();
+      extents.Offset(parent_origin);
+      break;
+    }
+#endif
+  }
+
+  return extents;
+}
+
+void AXPlatformNodeAuraLinux::GetExtents(gint* x,
+                                         gint* y,
+                                         gint* width,
+                                         gint* height,
+                                         AtkCoordType coord_type) {
+  gfx::Rect extents = GetExtentsRelativeToAtkCoordinateType(coord_type);
+  if (x)
+    *x = extents.x();
+  if (y)
+    *y = extents.y();
+  if (width)
+    *width = extents.width();
+  if (height)
+    *height = extents.height();
+}
+
+void AXPlatformNodeAuraLinux::GetPosition(gint* x,
+                                          gint* y,
+                                          AtkCoordType coord_type) {
+  gfx::Rect extents = GetExtentsRelativeToAtkCoordinateType(coord_type);
+  if (x)
+    *x = extents.x();
+  if (y)
+    *y = extents.y();
+}
+
+void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) {
+  gfx::Rect rect_size = gfx::ToEnclosingRect(GetData().relative_bounds.bounds);
+  if (width)
+    *width = rect_size.width();
+  if (height)
+    *height = rect_size.height();
+}
+
+gfx::NativeViewAccessible
+AXPlatformNodeAuraLinux::HitTestSync(gint x, gint y, AtkCoordType coord_type) {
+  gfx::Point scroll_to(x, y);
+  scroll_to = ConvertPointToScreenCoordinates(scroll_to, coord_type);
+
+  AXPlatformNode* current_result = this;
+  while (true) {
+    gfx::NativeViewAccessible hit_child =
+        current_result->GetDelegate()->HitTestSync(scroll_to.x(),
+                                                   scroll_to.y());
+    if (!hit_child)
+      return nullptr;
+    AXPlatformNode* hit_child_node =
+        AXPlatformNode::FromNativeViewAccessible(hit_child);
+    if (!hit_child_node || !hit_child_node->IsDescendantOf(current_result))
+      break;
+
+    // If we get the same node, we're done.
+    if (hit_child_node == current_result)
+      break;
+
+    // Continue to check recursively. That's because HitTestSync may have
+    // returned the best result within a particular accessibility tree,
+    // but we might need to recurse further in a tree of a different type
+    // (for example, from Views to Web).
+    current_result = hit_child_node;
+  }
+  return current_result->GetNativeViewAccessible();
+}
+
+bool AXPlatformNodeAuraLinux::GrabFocus() {
+  AXActionData action_data;
+  action_data.action = ax::mojom::Action::kFocus;
+  return delegate_->AccessibilityPerformAction(action_data);
+}
+
+bool AXPlatformNodeAuraLinux::FocusFirstFocusableAncestorInWebContent() {
+  if (!GetDelegate()->IsWebContent())
+    return false;
+
+  // Don't cross document boundaries in order to avoid having this operation
+  // cross iframe boundaries or escape to non-document UI elements.
+  if (GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
+    return false;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return false;
+
+  if (IsFocusable()) {
+    if (g_current_focused != atk_object)
+      GrabFocus();
+    return true;
+  }
+
+  auto* parent = FromAtkObject(GetParent());
+  if (!parent)
+    return false;
+
+  // If any of the siblings of this element are focusable, focusing the parent
+  // would be like moving the focus position backward, so we should fall back
+  // to setting the sequential focus navigation starting point.
+  for (auto child_iterator_ptr = parent->GetDelegate()->ChildrenBegin();
+       *child_iterator_ptr != *parent->GetDelegate()->ChildrenEnd();
+       ++(*child_iterator_ptr)) {
+    auto* child = FromAtkObject(child_iterator_ptr->GetNativeViewAccessible());
+    if (!child || child == this)
+      continue;
+
+    if (child->IsFocusable())
+      return false;
+  }
+
+  return parent->FocusFirstFocusableAncestorInWebContent();
+}
+
+bool AXPlatformNodeAuraLinux::SetSequentialFocusNavigationStartingPoint() {
+  AXActionData action_data;
+  action_data.action =
+      ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint;
+  return delegate_->AccessibilityPerformAction(action_data);
+}
+
+bool AXPlatformNodeAuraLinux::
+    GrabFocusOrSetSequentialFocusNavigationStartingPoint() {
+  // First we try to grab focus on this node if any ancestor in the same
+  // document is focusable. Otherwise we set the sequential navigation starting
+  // point.
+  if (!FocusFirstFocusableAncestorInWebContent())
+    return SetSequentialFocusNavigationStartingPoint();
+  else
+    return true;
+}
+
+bool AXPlatformNodeAuraLinux::
+    GrabFocusOrSetSequentialFocusNavigationStartingPointAtOffset(int offset) {
+  int child_count = delegate_->GetChildCount();
+  if (IsAtomicTextField() || child_count == 0)
+    return GrabFocusOrSetSequentialFocusNavigationStartingPoint();
+
+  // When this node has children, we walk through them to figure out what child
+  // node should get focus. We are essentially repeating the process used when
+  // building the hypertext here.
+  int current_offset = 0;
+  for (int i = 0; i < child_count; ++i) {
+    auto* child = FromAtkObject(delegate_->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    if (child->IsText()) {
+      current_offset += child->GetName().size();
+    } else {
+      // Add an offset for the embedded character.
+      current_offset += 1;
+    }
+
+    // If the offset is larger than our size, try to work with the last child,
+    // which is also the behavior of SetCaretOffset.
+    if (offset <= current_offset || i == child_count - 1)
+      return child->GrabFocusOrSetSequentialFocusNavigationStartingPoint();
+  }
+
+  NOTREACHED();
+  return false;
+}
+
+const gchar* AXPlatformNodeAuraLinux::GetDefaultActionName() {
+  int action;
+  if (!GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, &action))
+    return nullptr;
+
+  // If this object cannot receive focus and has a button role, use click as
+  // the default action. On the AuraLinux platform, the press action is a
+  // signal to users that they can trigger the action using the keyboard, while
+  // a click action means the user should trigger the action via a simulated
+  // click. If this object cannot receive focus, it's impossible to trigger it
+  // with a key press.
+  if (GetRole() == ax::mojom::Role::kButton &&
+      action == static_cast<int>(ax::mojom::DefaultActionVerb::kPress) &&
+      !IsFocusable()) {
+    action = static_cast<int>(ax::mojom::DefaultActionVerb::kClick);
+  }
+
+  std::string action_verb =
+      ui::ToString(static_cast<ax::mojom::DefaultActionVerb>(action));
+
+  ATK_AURALINUX_RETURN_STRING(action_verb);
+}
+
+AtkAttributeSet* AXPlatformNodeAuraLinux::GetAtkAttributes() {
+  AtkAttributeSet* attribute_list = nullptr;
+  ComputeAttributes(&attribute_list);
+  return attribute_list;
+}
+
+AtkStateType AXPlatformNodeAuraLinux::GetAtkStateTypeForCheckableNode() {
+  if (GetData().GetCheckedState() == ax::mojom::CheckedState::kMixed)
+    return ATK_STATE_INDETERMINATE;
+  if (IsPlatformCheckable())
+    return ATK_STATE_CHECKED;
+  return ATK_STATE_PRESSED;
+}
+
+// AtkDocumentHelpers
+
+const gchar* AXPlatformNodeAuraLinux::GetDocumentAttributeValue(
+    const gchar* attribute) const {
+  if (!g_ascii_strcasecmp(attribute, "DocType"))
+    return delegate_->GetTreeData().doctype.c_str();
+  else if (!g_ascii_strcasecmp(attribute, "MimeType"))
+    return delegate_->GetTreeData().mimetype.c_str();
+  else if (!g_ascii_strcasecmp(attribute, "Title"))
+    return delegate_->GetTreeData().title.c_str();
+  else if (!g_ascii_strcasecmp(attribute, "URI"))
+    return delegate_->GetTreeData().url.c_str();
+
+  return nullptr;
+}
+
+AtkAttributeSet* AXPlatformNodeAuraLinux::GetDocumentAttributes() const {
+  AtkAttributeSet* attribute_set = nullptr;
+  const gchar* doc_attributes[] = {"DocType", "MimeType", "Title", "URI"};
+  const gchar* value = nullptr;
+
+  for (unsigned i = 0; i < G_N_ELEMENTS(doc_attributes); i++) {
+    value = GetDocumentAttributeValue(doc_attributes[i]);
+    if (value) {
+      attribute_set = PrependAtkAttributeToAtkAttributeSet(
+          doc_attributes[i], value, attribute_set);
+    }
+  }
+
+  return attribute_set;
+}
+
+//
+// AtkHyperlink helpers
+//
+
+AtkHyperlink* AXPlatformNodeAuraLinux::GetAtkHyperlink() {
+  if (atk_hyperlink_)
+    return atk_hyperlink_;
+
+  atk_hyperlink_ =
+      ATK_HYPERLINK(g_object_new(AX_PLATFORM_ATK_HYPERLINK_TYPE, 0));
+  ax_platform_atk_hyperlink_set_object(
+      AX_PLATFORM_ATK_HYPERLINK(atk_hyperlink_), this);
+  return atk_hyperlink_;
+}
+
+//
+// Misc helpers
+//
+
+void AXPlatformNodeAuraLinux::GetFloatAttributeInGValue(
+    ax::mojom::FloatAttribute attr,
+    GValue* value) {
+  float float_val;
+  if (GetFloatAttribute(attr, &float_val)) {
+    memset(value, 0, sizeof(*value));
+    g_value_init(value, G_TYPE_FLOAT);
+    g_value_set_float(value, float_val);
+  }
+}
+
+void AXPlatformNodeAuraLinux::AddAttributeToList(const char* name,
+                                                 const char* value,
+                                                 AtkAttributeSet** attributes) {
+  *attributes = PrependAtkAttributeToAtkAttributeSet(name, value, *attributes);
+}
+
+void AXPlatformNodeAuraLinux::SetDocumentParent(
+    AtkObject* new_document_parent) {
+  DCHECK(GetAtkRole() == ATK_ROLE_FRAME);
+  SetWeakGPtrToAtkObject(&document_parent_, new_document_parent);
+}
+
+bool AXPlatformNodeAuraLinux::IsNameExposed() {
+  switch (GetRole()) {
+    case ax::mojom::Role::kListMarker:
+      return !GetChildCount();
+    default:
+      return true;
+  }
+}
+
+int AXPlatformNodeAuraLinux::GetCaretOffset() {
+  if (!HasVisibleCaretOrSelection()) {
+    absl::optional<FindInPageResultInfo> result =
+        GetSelectionOffsetsFromFindInPage();
+    AtkObject* atk_object = GetOrCreateAtkObject();
+    if (!atk_object)
+      return -1;
+    if (result.has_value() && result->node == atk_object)
+      return UTF16ToUnicodeOffsetInText(result->end_offset);
+    return -1;
+  }
+
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  return UTF16ToUnicodeOffsetInText(selection.second);
+}
+
+bool AXPlatformNodeAuraLinux::SetCaretOffset(int offset) {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return false;
+
+  int character_count = atk_text_get_character_count(ATK_TEXT(atk_object));
+  if (offset < 0 || offset > character_count)
+    offset = character_count;
+
+  // Even if we don't change anything, we still want to act like we
+  // were successful.
+  if (offset == GetCaretOffset() && !HasSelection())
+    return true;
+
+  offset = UnicodeToUTF16OffsetInText(offset);
+  if (!SetHypertextSelection(offset, offset))
+    return false;
+
+  return true;
+}
+
+bool AXPlatformNodeAuraLinux::SetTextSelectionForAtkText(int start_offset,
+                                                         int end_offset) {
+  start_offset = UnicodeToUTF16OffsetInText(start_offset);
+  end_offset = UnicodeToUTF16OffsetInText(end_offset);
+
+  std::u16string text = GetHypertext();
+  if (start_offset < 0 || start_offset > static_cast<int>(text.length()))
+    return false;
+  if (end_offset < 0 || end_offset > static_cast<int>(text.length()))
+    return false;
+
+  // We must put these in the correct order so that we can do
+  // a comparison with the existing start and end below.
+  if (end_offset < start_offset)
+    std::swap(start_offset, end_offset);
+
+  // Even if we don't change anything, we still want to act like we
+  // were successful.
+  std::pair<int, int> old_offsets = GetSelectionOffsetsForAtk();
+  if (old_offsets.first == start_offset && old_offsets.second == end_offset)
+    return true;
+
+  if (!SetHypertextSelection(start_offset, end_offset))
+    return false;
+
+  return true;
+}
+
+bool AXPlatformNodeAuraLinux::HasSelection() {
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  return selection.first >= 0 && selection.second >= 0 &&
+         selection.first != selection.second;
+}
+
+void AXPlatformNodeAuraLinux::GetSelectionExtents(int* start_offset,
+                                                  int* end_offset) {
+  if (start_offset)
+    *start_offset = 0;
+  if (end_offset)
+    *end_offset = 0;
+
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  if (selection.first < 0 || selection.second < 0 ||
+      selection.first == selection.second)
+    return;
+
+  // We should ignore the direction of the selection when exposing start and
+  // end offsets. According to the ATK documentation the end offset is always
+  // the offset immediately past the end of the selection. This wouldn't make
+  // sense if end < start.
+  if (selection.second < selection.first)
+    std::swap(selection.first, selection.second);
+
+  selection.first = UTF16ToUnicodeOffsetInText(selection.first);
+  selection.second = UTF16ToUnicodeOffsetInText(selection.second);
+
+  if (start_offset)
+    *start_offset = selection.first;
+  if (end_offset)
+    *end_offset = selection.second;
+}
+
+// Since this method doesn't return a static gchar*, we expect the caller of
+// atk_text_get_selection to free the return value.
+gchar* AXPlatformNodeAuraLinux::GetSelectionWithText(int* start_offset,
+                                                     int* end_offset) {
+  int selection_start, selection_end;
+  GetSelectionExtents(&selection_start, &selection_end);
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return nullptr;
+
+  if (selection_start < 0 || selection_end < 0 ||
+      selection_start == selection_end) {
+    absl::optional<FindInPageResultInfo> find_in_page_result =
+        GetSelectionOffsetsFromFindInPage();
+    if (!find_in_page_result.has_value() ||
+        find_in_page_result->node != atk_object) {
+      *start_offset = 0;
+      *end_offset = 0;
+      return nullptr;
+    }
+
+    selection_start = find_in_page_result->start_offset;
+    selection_end = find_in_page_result->end_offset;
+  }
+
+  selection_start = UTF16ToUnicodeOffsetInText(selection_start);
+  selection_end = UTF16ToUnicodeOffsetInText(selection_end);
+  if (selection_start < 0 || selection_end < 0 ||
+      selection_start == selection_end) {
+    return nullptr;
+  }
+
+  if (start_offset)
+    *start_offset = selection_start;
+  if (end_offset)
+    *end_offset = selection_end;
+  return atk_text::GetText(ATK_TEXT(atk_object), selection_start,
+                           selection_end);
+}
+
+bool AXPlatformNodeAuraLinux::IsInLiveRegion() {
+  return HasStringAttribute(ax::mojom::StringAttribute::kContainerLiveStatus);
+}
+
+#if defined(ATK_230)
+void AXPlatformNodeAuraLinux::ScrollToPoint(AtkCoordType atk_coord_type,
+                                            int x,
+                                            int y) {
+  gfx::Point scroll_to(x, y);
+  scroll_to = ConvertPointToScreenCoordinates(scroll_to, atk_coord_type);
+
+  AXActionData action_data;
+  action_data.target_node_id = GetData().id;
+  action_data.action = ax::mojom::Action::kScrollToPoint;
+  action_data.target_point = scroll_to;
+  GetDelegate()->AccessibilityPerformAction(action_data);
+}
+
+void AXPlatformNodeAuraLinux::ScrollNodeRectIntoView(
+    gfx::Rect rect,
+    AtkScrollType atk_scroll_type) {
+  AXActionData action_data;
+  action_data.target_node_id = GetData().id;
+  action_data.action = ax::mojom::Action::kScrollToMakeVisible;
+  action_data.target_rect = rect;
+
+  action_data.scroll_behavior = ax::mojom::ScrollBehavior::kScrollIfVisible;
+  action_data.horizontal_scroll_alignment = ax::mojom::ScrollAlignment::kNone;
+  action_data.vertical_scroll_alignment = ax::mojom::ScrollAlignment::kNone;
+
+  switch (atk_scroll_type) {
+    case ATK_SCROLL_TOP_LEFT:
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentTop;
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentLeft;
+      break;
+    case ATK_SCROLL_BOTTOM_RIGHT:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentRight;
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentBottom;
+      break;
+    case ATK_SCROLL_TOP_EDGE:
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentTop;
+      break;
+    case ATK_SCROLL_BOTTOM_EDGE:
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentBottom;
+      break;
+    case ATK_SCROLL_LEFT_EDGE:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentLeft;
+      break;
+    case ATK_SCROLL_RIGHT_EDGE:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentRight;
+      break;
+    case ATK_SCROLL_ANYWHERE:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentClosestEdge;
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentClosestEdge;
+      break;
+  }
+
+  GetDelegate()->AccessibilityPerformAction(action_data);
+}
+
+void AXPlatformNodeAuraLinux::ScrollNodeIntoView(
+    AtkScrollType atk_scroll_type) {
+  gfx::Rect rect = GetDelegate()->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                                                AXClippingBehavior::kUnclipped);
+  rect -= rect.OffsetFromOrigin();
+  ScrollNodeRectIntoView(rect, atk_scroll_type);
+}
+#endif  // defined(ATK_230)
+
+#if defined(ATK_232)
+absl::optional<gfx::Rect>
+AXPlatformNodeAuraLinux::GetUnclippedHypertextRangeBoundsRect(int start_offset,
+                                                              int end_offset) {
+  start_offset = UnicodeToUTF16OffsetInText(start_offset);
+  end_offset = UnicodeToUTF16OffsetInText(end_offset);
+
+  std::u16string text = GetHypertext();
+  if (start_offset < 0 || start_offset > static_cast<int>(text.length()))
+    return absl::nullopt;
+  if (end_offset < 0 || end_offset > static_cast<int>(text.length()))
+    return absl::nullopt;
+
+  if (end_offset < start_offset)
+    std::swap(start_offset, end_offset);
+
+  return GetDelegate()->GetHypertextRangeBoundsRect(
+      UnicodeToUTF16OffsetInText(start_offset),
+      UnicodeToUTF16OffsetInText(end_offset), AXCoordinateSystem::kScreenDIPs,
+      AXClippingBehavior::kUnclipped);
+}
+
+bool AXPlatformNodeAuraLinux::ScrollSubstringIntoView(
+    AtkScrollType atk_scroll_type,
+    int start_offset,
+    int end_offset) {
+  absl::optional<gfx::Rect> optional_rect =
+      GetUnclippedHypertextRangeBoundsRect(start_offset, end_offset);
+  if (!optional_rect.has_value())
+    return false;
+
+  gfx::Rect rect = *optional_rect;
+  gfx::Rect node_rect = GetDelegate()->GetBoundsRect(
+      AXCoordinateSystem::kScreenDIPs, AXClippingBehavior::kUnclipped);
+  rect -= node_rect.OffsetFromOrigin();
+  ScrollNodeRectIntoView(rect, atk_scroll_type);
+
+  return true;
+}
+
+bool AXPlatformNodeAuraLinux::ScrollSubstringToPoint(
+    int start_offset,
+    int end_offset,
+    AtkCoordType atk_coord_type,
+    int x,
+    int y) {
+  absl::optional<gfx::Rect> optional_rect =
+      GetUnclippedHypertextRangeBoundsRect(start_offset, end_offset);
+  if (!optional_rect.has_value())
+    return false;
+
+  gfx::Rect rect = *optional_rect;
+  gfx::Rect node_rect = GetDelegate()->GetBoundsRect(
+      AXCoordinateSystem::kScreenDIPs, AXClippingBehavior::kUnclipped);
+  ScrollToPoint(atk_coord_type, x - (rect.x() - node_rect.x()),
+                y - (rect.y() - node_rect.y()));
+
+  return true;
+}
+#endif  // defined(ATK_232)
+
+void AXPlatformNodeAuraLinux::ComputeStylesIfNeeded() {
+  if (!offset_to_text_attributes_.empty())
+    return;
+
+  default_text_attributes_ = ComputeTextAttributes();
+  TextAttributeMap attributes_map =
+      GetDelegate()->ComputeTextAttributeMap(default_text_attributes_);
+  offset_to_text_attributes_.swap(attributes_map);
+}
+
+int AXPlatformNodeAuraLinux::FindStartOfStyle(
+    int start_offset,
+    ax::mojom::MoveDirection direction) {
+  int text_length = GetHypertext().length();
+  DCHECK_GE(start_offset, 0);
+  DCHECK_LE(start_offset, text_length);
+  DCHECK(!offset_to_text_attributes_.empty());
+
+  switch (direction) {
+    case ax::mojom::MoveDirection::kNone:
+      NOTREACHED();
+      return start_offset;
+    case ax::mojom::MoveDirection::kBackward: {
+      auto iterator = offset_to_text_attributes_.upper_bound(start_offset);
+      --iterator;
+      return iterator->first;
+    }
+    case ax::mojom::MoveDirection::kForward: {
+      const auto iterator =
+          offset_to_text_attributes_.upper_bound(start_offset);
+      if (iterator == offset_to_text_attributes_.end())
+        return text_length;
+      return iterator->first;
+    }
+  }
+
+  NOTREACHED();
+  return start_offset;
+}
+
+const TextAttributeList& AXPlatformNodeAuraLinux::GetTextAttributes(
+    int offset,
+    int* start_offset,
+    int* end_offset) {
+  ComputeStylesIfNeeded();
+  DCHECK(!offset_to_text_attributes_.empty());
+
+  int utf16_offset = UnicodeToUTF16OffsetInText(offset);
+  int style_start =
+      FindStartOfStyle(utf16_offset, ax::mojom::MoveDirection::kBackward);
+  int style_end =
+      FindStartOfStyle(utf16_offset, ax::mojom::MoveDirection::kForward);
+
+  auto iterator = offset_to_text_attributes_.find(style_start);
+  DCHECK(iterator != offset_to_text_attributes_.end());
+
+  SetIntPointerValueIfNotNull(start_offset,
+                              UTF16ToUnicodeOffsetInText(style_start));
+  SetIntPointerValueIfNotNull(end_offset,
+                              UTF16ToUnicodeOffsetInText(style_end));
+
+  if (iterator == offset_to_text_attributes_.end())
+    return default_text_attributes_;
+
+  return iterator->second;
+}
+
+const TextAttributeList& AXPlatformNodeAuraLinux::GetDefaultTextAttributes() {
+  ComputeStylesIfNeeded();
+  return default_text_attributes_;
+}
+
+void AXPlatformNodeAuraLinux::TerminateFindInPage() {
+  ForgetCurrentFindInPageResult();
+}
+
+void AXPlatformNodeAuraLinux::ActivateFindInPageResult(int start_offset,
+                                                       int end_offset) {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  DCHECK(ATK_IS_TEXT(atk_object));
+
+  if (!EmitsAtkTextEvents()) {
+    ActivateFindInPageInParent(start_offset, end_offset);
+    return;
+  }
+
+  AtkObject* parent_doc = FindAtkObjectToplevelParentDocument(atk_object);
+  if (!parent_doc)
+    return;
+
+  std::map<AtkObject*, FindInPageResultInfo>& active_results =
+      GetActiveFindInPageResults();
+  auto iterator = active_results.find(parent_doc);
+  FindInPageResultInfo new_info = {atk_object, start_offset, end_offset};
+  if (iterator != active_results.end() && iterator->second == new_info)
+    return;
+
+  active_results[parent_doc] = new_info;
+  g_signal_emit_by_name(atk_object, "text-selection-changed");
+  g_signal_emit_by_name(atk_object, "text-caret-moved",
+                        UTF16ToUnicodeOffsetInText(end_offset));
+}
+
+absl::optional<std::pair<int, int>>
+AXPlatformNodeAuraLinux::GetHypertextExtentsOfChild(
+    AXPlatformNodeAuraLinux* child_to_find) {
+  int current_offset = 0;
+  for (auto child_iterator_ptr = GetDelegate()->ChildrenBegin();
+       *child_iterator_ptr != *GetDelegate()->ChildrenEnd();
+       ++(*child_iterator_ptr)) {
+    auto* child = FromAtkObject(child_iterator_ptr->GetNativeViewAccessible());
+    if (!child)
+      continue;
+
+    // If this object is a text only object, it is included directly into this
+    // node's hypertext, otherwise it is represented as an embedded object
+    // character.
+    int size = child->IsText() ? child->GetName().size() : 1;
+    if (child == child_to_find)
+      return std::make_pair(current_offset, current_offset + size);
+    current_offset += size;
+  }
+
+  return absl::nullopt;
+}
+
+void AXPlatformNodeAuraLinux::ActivateFindInPageInParent(int start_offset,
+                                                         int end_offset) {
+  auto* parent = FromAtkObject(GetParent());
+  if (!parent)
+    return;
+
+  absl::optional<std::pair<int, int>> extents_in_parent =
+      parent->GetHypertextExtentsOfChild(this);
+  if (!extents_in_parent.has_value())
+    return;
+
+  DCHECK(IsText());
+  parent->ActivateFindInPageResult(extents_in_parent->first + start_offset,
+                                   extents_in_parent->first + end_offset);
+}
+
+void AXPlatformNodeAuraLinux::ForgetCurrentFindInPageResult() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  AtkObject* parent_doc = FindAtkObjectToplevelParentDocument(atk_object);
+  if (parent_doc)
+    GetActiveFindInPageResults().erase(parent_doc);
+}
+
+absl::optional<FindInPageResultInfo>
+AXPlatformNodeAuraLinux::GetSelectionOffsetsFromFindInPage() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return absl::nullopt;
+
+  AtkObject* parent_doc = FindAtkObjectToplevelParentDocument(atk_object);
+  if (!parent_doc)
+    return absl::nullopt;
+
+  std::map<AtkObject*, FindInPageResultInfo>& active_results =
+      GetActiveFindInPageResults();
+  auto iterator = active_results.find(parent_doc);
+  if (iterator == active_results.end())
+    return absl::nullopt;
+
+  return iterator->second;
+}
+
+gfx::Point AXPlatformNodeAuraLinux::ConvertPointToScreenCoordinates(
+    const gfx::Point& point,
+    AtkCoordType atk_coord_type) {
+  switch (atk_coord_type) {
+    case ATK_XY_WINDOW:
+      return point + GetParentFrameOriginInScreenCoordinates();
+#if defined(ATK_230)
+    case ATK_XY_PARENT:
+      return point + GetParentOriginInScreenCoordinates();
+#endif
+    case ATK_XY_SCREEN:
+    default:
+      return point;
+  }
+}
+
+std::pair<int, int> AXPlatformNodeAuraLinux::GetSelectionOffsetsForAtk() {
+  // In web content we always want to look at the selection from the tree
+  // instead of the selection that might be set via node attributes. This is
+  // because the tree selection is the absolute truth about what is visually
+  // selected, whereas node attributes might contain selection extents that are
+  // no longer part of the visual selection.
+  std::pair<int, int> selection;
+  if (GetDelegate()->IsWebContent()) {
+    AXSelection unignored_selection = GetDelegate()->GetUnignoredSelection();
+    GetSelectionOffsetsFromTree(&unignored_selection, &selection.first,
+                                &selection.second);
+  } else {
+    GetSelectionOffsets(&selection.first, &selection.second);
+  }
+  return selection;
+}
+
+}  // namespace ui
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/src-orig/ui/accessibility/platform/ax_platform_node_auralinux.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/src-orig/ui/accessibility/platform/ax_platform_node_auralinux.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-dangling-gsl-patch/src-orig/ui/accessibility/platform/ax_platform_node_auralinux.cc	(revision 192)
@@ -0,0 +1,5095 @@
+// Copyright 2017 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/accessibility/platform/ax_platform_node_auralinux.h"
+#include "base/memory/raw_ptr.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <algorithm>
+#include <memory>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/debug/leak_annotations.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/no_destructor.h"
+#include "base/ranges/algorithm.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/sys_string_conversions.h"
+#include "base/strings/utf_string_conversion_utils.h"
+#include "base/strings/utf_string_conversions.h"
+#include "build/build_config.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
+#include "ui/accessibility/ax_action_data.h"
+#include "ui/accessibility/ax_enum_util.h"
+#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/accessibility/ax_node_data.h"
+#include "ui/accessibility/ax_role_properties.h"
+#include "ui/accessibility/ax_selection.h"
+#include "ui/accessibility/platform/atk_util_auralinux.h"
+#include "ui/accessibility/platform/ax_platform_atk_hyperlink.h"
+#include "ui/accessibility/platform/ax_platform_node_delegate.h"
+#include "ui/accessibility/platform/ax_platform_text_boundary.h"
+#include "ui/accessibility/platform/child_iterator.h"
+#include "ui/gfx/geometry/rect_conversions.h"
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 10, 0)
+#define ATK_210
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 12, 0)
+#define ATK_212
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 16, 0)
+#define ATK_216
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 26, 0)
+#define ATK_226
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 30, 0)
+#define ATK_230
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 32, 0)
+#define ATK_232
+#endif
+
+#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 34, 0)
+#define ATK_234
+#endif
+
+namespace ui {
+
+namespace {
+
+// IMPORTANT!
+// These values are written to logs.  Do not renumber or delete
+// existing items; add new entries to the end of the list.
+enum class UmaAtkApi {
+  kGetName = 0,
+  kGetDescription = 1,
+  kGetNChildren = 2,
+  kRefChild = 3,
+  kGetIndexInParent = 4,
+  kGetParent = 5,
+  kRefRelationSet = 6,
+  kGetAttributes = 7,
+  kGetRole = 8,
+  kRefStateSet = 9,
+  // This must always be the last enum. It's okay for its value to
+  // increase, but none of the other enum values may change.
+  kMaxValue = kRefStateSet,
+};
+
+void RecordAccessibilityAtkApi(UmaAtkApi enum_value) {
+  UMA_HISTOGRAM_ENUMERATION("Accessibility.ATK-APIs", enum_value);
+}
+
+// When accepting input from clients calling the API, an ATK character offset
+// of -1 can often represent the length of the string.
+static const int kStringLengthOffset = -1;
+
+// We must forward declare this because it is used by the traditional GObject
+// type manipulation macros.
+namespace atk_object {
+GType GetType();
+}  // namespace atk_object
+
+//
+// ax_platform_node_auralinux AtkObject definition and implementation.
+//
+#define AX_PLATFORM_NODE_AURALINUX_TYPE (atk_object::GetType())
+#define AX_PLATFORM_NODE_AURALINUX(obj)                               \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), AX_PLATFORM_NODE_AURALINUX_TYPE, \
+                              AXPlatformNodeAuraLinuxObject))
+#define AX_PLATFORM_NODE_AURALINUX_CLASS(klass)                      \
+  (G_TYPE_CHECK_CLASS_CAST((klass), AX_PLATFORM_NODE_AURALINUX_TYPE, \
+                           AXPlatformNodeAuraLinuxClass))
+#define IS_AX_PLATFORM_NODE_AURALINUX(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), AX_PLATFORM_NODE_AURALINUX_TYPE))
+#define IS_AX_PLATFORM_NODE_AURALINUX_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), AX_PLATFORM_NODE_AURALINUX_TYPE))
+#define AX_PLATFORM_NODE_AURALINUX_GET_CLASS(obj)                    \
+  (G_TYPE_INSTANCE_GET_CLASS((obj), AX_PLATFORM_NODE_AURALINUX_TYPE, \
+                             AXPlatformNodeAuraLinuxClass))
+
+typedef struct _AXPlatformNodeAuraLinuxObject AXPlatformNodeAuraLinuxObject;
+typedef struct _AXPlatformNodeAuraLinuxClass AXPlatformNodeAuraLinuxClass;
+
+struct _AXPlatformNodeAuraLinuxObject {
+  AtkObject parent;
+  raw_ptr<AXPlatformNodeAuraLinux> m_object;
+};
+
+struct _AXPlatformNodeAuraLinuxClass {
+  AtkObjectClass parent_class;
+};
+
+// The root-level Application object that's the parent of all top-level windows.
+AXPlatformNode* g_root_application = nullptr;
+
+// The last AtkObject with keyboard focus. Tracking this is required to emit the
+// ATK_STATE_FOCUSED change to false.
+AtkObject* g_current_focused = nullptr;
+
+// The last object which was selected. Tracking this is required because
+// widgets in the browser UI only emit notifications upon becoming selected,
+// but clients also expect notifications when items become unselected.
+AXPlatformNodeAuraLinux* g_current_selected = nullptr;
+
+// The AtkObject with role=ATK_ROLE_FRAME that represents the toplevel desktop
+// window with focus. If this window is not one of our windows, this value
+// should be null. This is a weak pointer as well, so its value will also be
+// null if if the AtkObject is destroyed.
+AtkObject* g_active_top_level_frame = nullptr;
+
+AtkObject* g_active_views_dialog = nullptr;
+
+#if defined(ATK_216)
+constexpr AtkRole kStaticRole = ATK_ROLE_STATIC;
+constexpr AtkRole kSubscriptRole = ATK_ROLE_SUBSCRIPT;
+constexpr AtkRole kSuperscriptRole = ATK_ROLE_SUPERSCRIPT;
+#else
+constexpr AtkRole kStaticRole = ATK_ROLE_TEXT;
+constexpr AtkRole kSubscriptRole = ATK_ROLE_TEXT;
+constexpr AtkRole kSuperscriptRole = ATK_ROLE_TEXT;
+#endif
+
+#if defined(ATK_226)
+constexpr AtkRole kAtkFootnoteRole = ATK_ROLE_FOOTNOTE;
+#else
+constexpr AtkRole kAtkFootnoteRole = ATK_ROLE_LIST_ITEM;
+#endif
+
+#if defined(ATK_234)
+constexpr AtkRole kAtkRoleContentDeletion = ATK_ROLE_CONTENT_DELETION;
+constexpr AtkRole kAtkRoleContentInsertion = ATK_ROLE_CONTENT_INSERTION;
+#else
+constexpr AtkRole kAtkRoleContentDeletion = ATK_ROLE_SECTION;
+constexpr AtkRole kAtkRoleContentInsertion = ATK_ROLE_SECTION;
+#endif
+
+using GetTypeFunc = GType (*)();
+using GetColumnHeaderCellsFunc = GPtrArray* (*)(AtkTableCell* cell);
+using GetRowHeaderCellsFunc = GPtrArray* (*)(AtkTableCell* cell);
+using GetRowColumnSpanFunc = bool (*)(AtkTableCell* cell,
+                                      gint* row,
+                                      gint* column,
+                                      gint* row_span,
+                                      gint* col_span);
+
+static GetTypeFunc g_atk_table_cell_get_type;
+static GetColumnHeaderCellsFunc g_atk_table_cell_get_column_header_cells;
+static GetRowHeaderCellsFunc g_atk_table_cell_get_row_header_cells;
+static GetRowColumnSpanFunc g_atk_table_cell_get_row_column_span;
+
+// The ATK API often requires pointers to be used as out arguments, while
+// allowing for those pointers to be null if the caller is not interested in
+// the value. This function is a simpler helper to avoid continually checking
+// for null and to help prevent forgetting to check for null.
+void SetIntPointerValueIfNotNull(int* pointer, int value) {
+  if (pointer)
+    *pointer = value;
+}
+
+#if defined(ATK_230)
+bool SupportsAtkComponentScrollingInterface() {
+  return dlsym(RTLD_DEFAULT, "atk_component_scroll_to_point");
+}
+#endif
+
+#if defined(ATK_232)
+bool SupportsAtkTextScrollingInterface() {
+  return dlsym(RTLD_DEFAULT, "atk_text_scroll_substring_to_point");
+}
+#endif
+
+AtkObject* FindAtkObjectParentFrame(AtkObject* atk_object) {
+  AXPlatformNodeAuraLinux* node =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  while (node) {
+    if (node->GetAtkRole() == ATK_ROLE_FRAME)
+      return node->GetNativeViewAccessible();
+    node = AXPlatformNodeAuraLinux::FromAtkObject(node->GetParent());
+  }
+  return nullptr;
+}
+
+AtkObject* FindAtkObjectToplevelParentDocument(AtkObject* atk_object) {
+  AXPlatformNodeAuraLinux* node =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  AtkObject* toplevel_document = nullptr;
+  while (node) {
+    if (node->GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
+      toplevel_document = node->GetNativeViewAccessible();
+    node = AXPlatformNodeAuraLinux::FromAtkObject(node->GetParent());
+  }
+  return toplevel_document;
+}
+
+bool IsFrameAncestorOfAtkObject(AtkObject* frame, AtkObject* atk_object) {
+  AtkObject* current_frame = FindAtkObjectParentFrame(atk_object);
+  while (current_frame) {
+    if (current_frame == frame)
+      return true;
+    AXPlatformNodeAuraLinux* frame_node =
+        AXPlatformNodeAuraLinux::FromAtkObject(current_frame);
+    current_frame = FindAtkObjectParentFrame(frame_node->GetParent());
+  }
+  return false;
+}
+
+// Returns a stack of AtkObjects of activated popup menus. Since each popup
+// menu and submenu has its own native window, we want to properly manage the
+// activated state for their containing frames.
+std::vector<AtkObject*>& GetActiveMenus() {
+  static base::NoDestructor<std::vector<AtkObject*>> active_menus;
+  return *active_menus;
+}
+
+std::map<AtkObject*, FindInPageResultInfo>& GetActiveFindInPageResults() {
+  static base::NoDestructor<std::map<AtkObject*, FindInPageResultInfo>>
+      active_results;
+  return *active_results;
+}
+
+// The currently active frame is g_active_top_level_frame, unless there is an
+// active menu. If there is an active menu the parent frame of the
+// most-recently opened active menu should be the currently active frame.
+AtkObject* ComputeActiveTopLevelFrame() {
+  if (!GetActiveMenus().empty())
+    return FindAtkObjectParentFrame(GetActiveMenus().back());
+  return g_active_top_level_frame;
+}
+
+const char* GetUniqueAccessibilityGTypeName(
+    ImplementedAtkInterfaces interface_mask) {
+  // 37 characters is enough for "AXPlatformNodeAuraLinux%x" with any integer
+  // value.
+  static char name[37];
+  snprintf(name, sizeof(name), "AXPlatformNodeAuraLinux%x",
+           interface_mask.value());
+  return name;
+}
+
+void SetWeakGPtrToAtkObject(AtkObject** weak_pointer, AtkObject* new_value) {
+  DCHECK(weak_pointer);
+  if (*weak_pointer == new_value)
+    return;
+
+  if (*weak_pointer) {
+    g_object_remove_weak_pointer(G_OBJECT(*weak_pointer),
+                                 reinterpret_cast<void**>(weak_pointer));
+  }
+
+  *weak_pointer = new_value;
+
+  if (new_value) {
+    g_object_add_weak_pointer(G_OBJECT(new_value),
+                              reinterpret_cast<void**>(weak_pointer));
+  }
+}
+
+void SetActiveTopLevelFrame(AtkObject* new_top_level_frame) {
+  SetWeakGPtrToAtkObject(&g_active_top_level_frame, new_top_level_frame);
+}
+
+AXCoordinateSystem AtkCoordTypeToAXCoordinateSystem(
+    AtkCoordType coordinate_type) {
+  switch (coordinate_type) {
+    case ATK_XY_SCREEN:
+      return AXCoordinateSystem::kScreenDIPs;
+    case ATK_XY_WINDOW:
+      return AXCoordinateSystem::kRootFrame;
+#if defined(ATK_230)
+    case ATK_XY_PARENT:
+      // AXCoordinateSystem does not support parent coordinates.
+      NOTIMPLEMENTED();
+      return AXCoordinateSystem::kFrame;
+#endif
+    default:
+      return AXCoordinateSystem::kScreenDIPs;
+  }
+}
+
+const char* BuildDescriptionFromHeaders(AXPlatformNodeDelegate* delegate,
+                                        const std::vector<int32_t>& ids) {
+  std::vector<std::string> names;
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* header = delegate->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_header = header->GetNativeViewAccessible()) {
+        if (const gchar* name = atk_object_get_name(atk_header))
+          names.push_back(name);
+      }
+    }
+  }
+
+  std::string result = base::JoinString(names, " ");
+
+#if defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
+  // http://crbug.com/982839
+  // atk_table_get_column_description and atk_table_get_row_description return
+  // const gchar*, which suggests the caller does not gain ownership of the
+  // returned string. The g_strdup below causes a new allocation, which does not
+  // fit that pattern and causes a leak in tests.
+  ScopedLeakSanitizerDisabler lsan_disabler;
+#endif
+
+  return g_strdup(result.c_str());
+}
+
+AtkAttributeSet* PrependAtkAttributeToAtkAttributeSet(
+    const char* name,
+    const char* value,
+    AtkAttributeSet* attribute_set) {
+  AtkAttribute* attribute =
+      static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
+  attribute->name = g_strdup(name);
+  attribute->value = g_strdup(value);
+  return g_slist_prepend(attribute_set, attribute);
+}
+
+void PrependTextAttributeToSet(const std::string& attribute,
+                               const std::string& value,
+                               AtkAttributeSet** attributes) {
+  DCHECK(attributes);
+
+  AtkAttribute* new_attribute =
+      static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
+  new_attribute->name = g_strdup(attribute.c_str());
+  new_attribute->value = g_strdup(value.c_str());
+  *attributes = g_slist_prepend(*attributes, new_attribute);
+}
+
+void PrependAtkTextAttributeToSet(const AtkTextAttribute attribute,
+                                  const std::string& value,
+                                  AtkAttributeSet** attributes) {
+  PrependTextAttributeToSet(atk_text_attribute_get_name(attribute), value,
+                            attributes);
+}
+
+std::string ToAtkTextAttributeColor(const std::string color) {
+  // The platform-independent color string is in the form "rgb(r, g, b)",
+  // but ATK expects a string like "r, g, b". We convert the string here
+  // by stripping away the unnecessary characters.
+  DCHECK(base::StartsWith(color, "rgb(", base::CompareCase::INSENSITIVE_ASCII));
+  DCHECK(base::EndsWith(color, ")", base::CompareCase::INSENSITIVE_ASCII));
+  return color.substr(4, color.length() - 5);
+}
+
+AtkAttributeSet* ToAtkAttributeSet(const TextAttributeList& attributes) {
+  AtkAttributeSet* copied_attributes = nullptr;
+  for (const auto& attribute : attributes) {
+    if (attribute.first == "background-color") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_BG_COLOR,
+                                   ToAtkTextAttributeColor(attribute.second),
+                                   &copied_attributes);
+    } else if (attribute.first == "color") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_FG_COLOR,
+                                   ToAtkTextAttributeColor(attribute.second),
+                                   &copied_attributes);
+    } else if (attribute.first == "font-family") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_FAMILY_NAME, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "font-size") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_SIZE, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "font-weight" && attribute.second == "bold") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_WEIGHT, "700",
+                                   &copied_attributes);
+    } else if (attribute.first == "font-style") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_STYLE, "italic",
+                                   &copied_attributes);
+    } else if (attribute.first == "text-line-through-style") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_STRIKETHROUGH, "true",
+                                   &copied_attributes);
+    } else if (attribute.first == "text-underline-style") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_UNDERLINE, "single",
+                                   &copied_attributes);
+    } else if (attribute.first == "invalid") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_INVALID, attribute.second,
+                                   &copied_attributes);
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_UNDERLINE, "error",
+                                   &copied_attributes);
+    } else if (attribute.first == "language") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_LANGUAGE, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "writing-mode") {
+      PrependAtkTextAttributeToSet(ATK_TEXT_ATTR_DIRECTION, attribute.second,
+                                   &copied_attributes);
+    } else if (attribute.first == "text-position") {
+      PrependTextAttributeToSet(attribute.first, attribute.second,
+                                &copied_attributes);
+    }
+  }
+
+  return g_slist_reverse(copied_attributes);
+}
+
+namespace atk_component {
+
+void GetExtents(AtkComponent* atk_component,
+                gint* x,
+                gint* y,
+                gint* width,
+                gint* height,
+                AtkCoordType coord_type) {
+  g_return_if_fail(ATK_IS_COMPONENT(atk_component));
+
+  if (x)
+    *x = 0;
+  if (y)
+    *y = 0;
+  if (width)
+    *width = 0;
+  if (height)
+    *height = 0;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetExtents(x, y, width, height, coord_type);
+}
+
+void GetPosition(AtkComponent* atk_component,
+                 gint* x,
+                 gint* y,
+                 AtkCoordType coord_type) {
+  g_return_if_fail(ATK_IS_COMPONENT(atk_component));
+
+  if (x)
+    *x = 0;
+  if (y)
+    *y = 0;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetPosition(x, y, coord_type);
+}
+
+void GetSize(AtkComponent* atk_component, gint* width, gint* height) {
+  g_return_if_fail(ATK_IS_COMPONENT(atk_component));
+
+  if (width)
+    *width = 0;
+  if (height)
+    *height = 0;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetSize(width, height);
+}
+
+AtkObject* RefAccesibleAtPoint(AtkComponent* atk_component,
+                               gint x,
+                               gint y,
+                               AtkCoordType coord_type) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), nullptr);
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  AtkObject* result = obj->HitTestSync(x, y, coord_type);
+  if (result)
+    g_object_ref(result);
+  return result;
+}
+
+gboolean GrabFocus(AtkComponent* atk_component) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
+  AtkObject* atk_object = ATK_OBJECT(atk_component);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return FALSE;
+
+  return obj->GrabFocus();
+}
+
+#if defined(ATK_230)
+gboolean ScrollTo(AtkComponent* atk_component, AtkScrollType scroll_type) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_component));
+  if (!obj)
+    return FALSE;
+
+  obj->ScrollNodeIntoView(scroll_type);
+  return TRUE;
+}
+
+gboolean ScrollToPoint(AtkComponent* atk_component,
+                       AtkCoordType atk_coord_type,
+                       gint x,
+                       gint y) {
+  g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_component));
+  if (!obj)
+    return FALSE;
+
+  obj->ScrollToPoint(atk_coord_type, x, y);
+  return TRUE;
+}
+#endif
+
+void Init(AtkComponentIface* iface) {
+  iface->get_extents = GetExtents;
+  iface->get_position = GetPosition;
+  iface->get_size = GetSize;
+  iface->ref_accessible_at_point = RefAccesibleAtPoint;
+  iface->grab_focus = GrabFocus;
+#if defined(ATK_230)
+  if (SupportsAtkComponentScrollingInterface()) {
+    iface->scroll_to = ScrollTo;
+    iface->scroll_to_point = ScrollToPoint;
+  }
+#endif
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_component
+
+namespace atk_action {
+
+gboolean DoAction(AtkAction* atk_action, gint index) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), FALSE);
+  g_return_val_if_fail(index >= 0, FALSE);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return FALSE;
+
+  const std::vector<ax::mojom::Action> actions =
+      obj->GetDelegate()->GetSupportedActions();
+  g_return_val_if_fail(index < static_cast<gint>(actions.size()), FALSE);
+
+  AXActionData data;
+  data.action = actions[index];
+  return obj->GetDelegate()->AccessibilityPerformAction(data);
+}
+
+gint GetNActions(AtkAction* atk_action) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  return static_cast<gint>(obj->GetDelegate()->GetSupportedActions().size());
+}
+
+const gchar* GetDescription(AtkAction*, gint) {
+  // Not implemented. Right now Orca does not provide this and
+  // Chromium is not providing a string for the action description.
+  return nullptr;
+}
+
+const gchar* GetName(AtkAction* atk_action, gint index) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  const std::vector<ax::mojom::Action> actions =
+      obj->GetDelegate()->GetSupportedActions();
+  g_return_val_if_fail(index < static_cast<gint>(actions.size()), nullptr);
+
+  if (index == 0 && obj->GetDelegate()->HasDefaultActionVerb()) {
+    // If there is a default action, it will always be at index 0.
+    return obj->GetDefaultActionName();
+  }
+  return ToString(actions[index]);
+}
+
+const gchar* GetKeybinding(AtkAction* atk_action, gint index) {
+  g_return_val_if_fail(ATK_IS_ACTION(atk_action), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_action);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  const std::vector<ax::mojom::Action> actions =
+      obj->GetDelegate()->GetSupportedActions();
+  g_return_val_if_fail(index < static_cast<gint>(actions.size()), nullptr);
+
+  if (index == 0 && obj->GetDelegate()->HasDefaultActionVerb()) {
+    // If there is a default action, it will always be at index 0. Only the
+    // default action has a key binding.
+    return obj->GetStringAttribute(ax::mojom::StringAttribute::kAccessKey)
+        .c_str();
+  }
+  return nullptr;
+}
+
+void Init(AtkActionIface* iface) {
+  iface->do_action = DoAction;
+  iface->get_n_actions = GetNActions;
+  iface->get_description = GetDescription;
+  iface->get_name = GetName;
+  iface->get_keybinding = GetKeybinding;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_action
+
+namespace atk_document {
+
+const gchar* GetDocumentAttributeValue(AtkDocument* atk_doc,
+                                       const gchar* attribute) {
+  g_return_val_if_fail(ATK_IS_DOCUMENT(atk_doc), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_doc);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetDocumentAttributeValue(attribute);
+}
+
+AtkAttributeSet* GetDocumentAttributes(AtkDocument* atk_doc) {
+  g_return_val_if_fail(ATK_IS_DOCUMENT(atk_doc), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_doc);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetDocumentAttributes();
+}
+
+void Init(AtkDocumentIface* iface) {
+  iface->get_document_attribute_value = GetDocumentAttributeValue;
+  iface->get_document_attributes = GetDocumentAttributes;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_document
+
+namespace atk_image {
+
+void GetImagePosition(AtkImage* atk_img,
+                      gint* x,
+                      gint* y,
+                      AtkCoordType coord_type) {
+  g_return_if_fail(ATK_IMAGE(atk_img));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_img);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetPosition(x, y, coord_type);
+}
+
+const gchar* GetImageDescription(AtkImage* atk_img) {
+  g_return_val_if_fail(ATK_IMAGE(atk_img), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_img);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetStringAttribute(ax::mojom::StringAttribute::kDescription)
+      .c_str();
+}
+
+void GetImageSize(AtkImage* atk_img, gint* width, gint* height) {
+  g_return_if_fail(ATK_IMAGE(atk_img));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_img);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetSize(width, height);
+}
+
+void Init(AtkImageIface* iface) {
+  iface->get_image_position = GetImagePosition;
+  iface->get_image_description = GetImageDescription;
+  iface->get_image_size = GetImageSize;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_image
+
+namespace atk_value {
+
+void GetCurrentValue(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kValueForRange,
+                                 value);
+}
+
+void GetMinimumValue(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kMinValueForRange,
+                                 value);
+}
+
+void GetMaximumValue(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kMaxValueForRange,
+                                 value);
+}
+
+void GetMinimumIncrement(AtkValue* atk_value, GValue* value) {
+  g_return_if_fail(ATK_IS_VALUE(atk_value));
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return;
+
+  obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kStepValueForRange,
+                                 value);
+}
+
+gboolean SetCurrentValue(AtkValue* atk_value, const GValue* value) {
+  g_return_val_if_fail(ATK_IS_VALUE(atk_value), FALSE);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_value);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return FALSE;
+
+  std::string new_value;
+  switch (G_VALUE_TYPE(value)) {
+    case G_TYPE_FLOAT:
+      new_value = base::NumberToString(g_value_get_float(value));
+      break;
+    case G_TYPE_INT:
+      new_value = base::NumberToString(g_value_get_int(value));
+      break;
+    case G_TYPE_INT64:
+      new_value = base::NumberToString(g_value_get_int64(value));
+      break;
+    case G_TYPE_STRING:
+      new_value = g_value_get_string(value);
+      break;
+    default:
+      return FALSE;
+  }
+
+  AXActionData data;
+  data.action = ax::mojom::Action::kSetValue;
+  data.value = new_value;
+  obj->GetDelegate()->AccessibilityPerformAction(data);
+  return TRUE;
+}
+
+void Init(AtkValueIface* iface) {
+  iface->get_current_value = GetCurrentValue;
+  iface->get_maximum_value = GetMaximumValue;
+  iface->get_minimum_value = GetMinimumValue;
+  iface->get_minimum_increment = GetMinimumIncrement;
+  iface->set_current_value = SetCurrentValue;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_value
+
+namespace atk_hyperlink {
+
+AtkHyperlink* GetHyperlink(AtkHyperlinkImpl* atk_hyperlink_impl) {
+  g_return_val_if_fail(ATK_HYPERLINK_IMPL(atk_hyperlink_impl), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_hyperlink_impl);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  AtkHyperlink* atk_hyperlink = obj->GetAtkHyperlink();
+  g_object_ref(atk_hyperlink);
+
+  return atk_hyperlink;
+}
+
+void Init(AtkHyperlinkImplIface* iface) {
+  iface->get_hyperlink = GetHyperlink;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_hyperlink
+
+namespace atk_hypertext {
+
+AtkHyperlink* GetLink(AtkHypertext* hypertext, int index) {
+  g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
+  if (!obj)
+    return nullptr;
+
+  const AXLegacyHypertext& ax_hypertext = obj->GetAXHypertext();
+  if (index >= static_cast<int>(ax_hypertext.hyperlinks.size()) || index < 0)
+    return nullptr;
+
+  int32_t id = ax_hypertext.hyperlinks[index];
+  auto* link = static_cast<AXPlatformNodeAuraLinux*>(
+      AXPlatformNodeBase::GetFromUniqueId(id));
+  if (!link)
+    return nullptr;
+
+  return link->GetAtkHyperlink();
+}
+
+int GetNLinks(AtkHypertext* hypertext) {
+  g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
+  return obj ? obj->GetAXHypertext().hyperlinks.size() : 0;
+}
+
+int GetLinkIndex(AtkHypertext* hypertext, int char_index) {
+  g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
+  if (!obj)
+    return -1;
+
+  auto it = obj->GetAXHypertext().hyperlink_offset_to_index.find(char_index);
+  if (it == obj->GetAXHypertext().hyperlink_offset_to_index.end())
+    return -1;
+  return it->second;
+}
+
+void Init(AtkHypertextIface* iface) {
+  iface->get_link = GetLink;
+  iface->get_n_links = GetNLinks;
+  iface->get_link_index = GetLinkIndex;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_hypertext
+
+namespace atk_text {
+
+gchar* GetText(AtkText* atk_text, gint start_offset, gint end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  std::u16string text = obj->GetHypertext();
+
+  start_offset = obj->UnicodeToUTF16OffsetInText(start_offset);
+  if (start_offset < 0 || start_offset >= static_cast<int>(text.size()))
+    return nullptr;
+
+  if (end_offset < 0) {
+    end_offset = text.size();
+  } else {
+    end_offset = obj->UnicodeToUTF16OffsetInText(end_offset);
+    end_offset =
+        std::clamp(static_cast<int>(text.size()), start_offset, end_offset);
+  }
+
+  DCHECK_GE(start_offset, 0);
+  DCHECK_GE(end_offset, start_offset);
+
+  return g_strdup(
+      base::UTF16ToUTF8(text.substr(start_offset, end_offset - start_offset))
+          .c_str());
+}
+
+gint GetCharacterCount(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  return obj->UTF16ToUnicodeOffsetInText(obj->GetHypertext().length());
+}
+
+gunichar GetCharacterAtOffset(AtkText* atk_text, int offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  std::u16string text = obj->GetHypertext();
+  size_t text_length = text.length();
+
+  offset = obj->UnicodeToUTF16OffsetInText(offset);
+  offset = std::max(offset, 0);
+  size_t limited_offset = std::min(static_cast<size_t>(offset), text_length);
+
+  base_icu::UChar32 code_point;
+  base::ReadUnicodeCharacter(text.c_str(), text_length + 1, &limited_offset,
+                             &code_point);
+  return code_point;
+}
+
+gint GetOffsetAtPoint(AtkText* text, gint x, gint y, AtkCoordType coords) {
+  g_return_val_if_fail(ATK_IS_TEXT(text), -1);
+
+  AtkObject* atk_object = ATK_OBJECT(text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return -1;
+
+  return obj->GetTextOffsetAtPoint(x, y, coords);
+}
+
+// This function returns a single character as a UTF-8 encoded C string because
+// the character may be encoded into more than one byte.
+char* GetCharacter(AtkText* atk_text,
+                   int offset,
+                   int* start_offset,
+                   int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  *start_offset = -1;
+  *end_offset = -1;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (offset < 0 || offset >= GetCharacterCount(atk_text))
+    return nullptr;
+
+  char* text = GetText(atk_text, offset, offset + 1);
+  if (!text)
+    return nullptr;
+
+  *start_offset = offset;
+  *end_offset = offset + 1;
+  return text;
+}
+
+char* GetTextWithBoundaryType(AtkText* atk_text,
+                              int offset,
+                              ax::mojom::TextBoundary boundary,
+                              int* start_offset_ptr,
+                              int* end_offset_ptr) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (offset < 0 || offset >= atk_text_get_character_count(atk_text))
+    return nullptr;
+
+  // The offset that we receive from the API is a Unicode character offset.
+  // Since we calculate boundaries in terms of UTF-16 code point offsets, we
+  // need to convert this input value.
+  offset = obj->UnicodeToUTF16OffsetInText(offset);
+
+  int start_offset = obj->FindTextBoundary(
+      boundary, offset, ax::mojom::MoveDirection::kBackward,
+      ax::mojom::TextAffinity::kDownstream);
+  int end_offset = obj->FindTextBoundary(boundary, offset,
+                                         ax::mojom::MoveDirection::kForward,
+                                         ax::mojom::TextAffinity::kDownstream);
+  if (start_offset < 0 || end_offset < 0)
+    return nullptr;
+
+  DCHECK_LE(start_offset, end_offset)
+      << "Start offset should be less than or equal the end offset.";
+
+  // The ATK API is also expecting Unicode character offsets as output
+  // values.
+  *start_offset_ptr = obj->UTF16ToUnicodeOffsetInText(start_offset);
+  *end_offset_ptr = obj->UTF16ToUnicodeOffsetInText(end_offset);
+
+  std::u16string text = obj->GetHypertext();
+  DCHECK_LE(end_offset, static_cast<int>(text.size()));
+
+  std::u16string substr = text.substr(start_offset, end_offset - start_offset);
+  return g_strdup(base::UTF16ToUTF8(substr).c_str());
+}
+
+char* GetTextAtOffset(AtkText* atk_text,
+                      int offset,
+                      AtkTextBoundary atk_boundary,
+                      int* start_offset,
+                      int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+  ax::mojom::TextBoundary boundary = FromAtkTextBoundary(atk_boundary);
+  return GetTextWithBoundaryType(atk_text, offset, boundary, start_offset,
+                                 end_offset);
+}
+
+char* GetTextAfterOffset(AtkText* atk_text,
+                         int offset,
+                         AtkTextBoundary boundary,
+                         int* start_offset,
+                         int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  if (boundary != ATK_TEXT_BOUNDARY_CHAR) {
+    *start_offset = -1;
+    *end_offset = -1;
+    return nullptr;
+  }
+
+  // ATK does not offer support for the special negative index and we don't
+  // want to do arithmetic on that value below.
+  if (offset == kStringLengthOffset)
+    return nullptr;
+
+  return GetCharacter(atk_text, offset + 1, start_offset, end_offset);
+}
+
+char* GetTextBeforeOffset(AtkText* atk_text,
+                          int offset,
+                          AtkTextBoundary boundary,
+                          int* start_offset,
+                          int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  if (boundary != ATK_TEXT_BOUNDARY_CHAR) {
+    *start_offset = -1;
+    *end_offset = -1;
+    return nullptr;
+  }
+
+  // ATK does not offer support for the special negative index and we don't
+  // want to do arithmetic on that value below.
+  if (offset == kStringLengthOffset)
+    return nullptr;
+
+  return GetCharacter(atk_text, offset - 1, start_offset, end_offset);
+}
+
+gint GetCaretOffset(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), -1);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return -1;
+  return obj->GetCaretOffset();
+}
+
+gboolean SetCaretOffset(AtkText* atk_text, gint offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+  if (!obj->SetCaretOffset(offset))
+    return FALSE;
+
+  // Orca expects atk_text_set_caret_offset to either focus the target element
+  // or set the sequential focus navigation starting point there.
+  int utf16_offset = obj->UnicodeToUTF16OffsetInText(offset);
+  obj->GrabFocusOrSetSequentialFocusNavigationStartingPointAtOffset(
+      utf16_offset);
+
+  return TRUE;
+}
+
+int GetNSelections(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return 0;
+
+  if (obj->HasSelection())
+    return 1;
+
+  absl::optional<FindInPageResultInfo> result =
+      obj->GetSelectionOffsetsFromFindInPage();
+  if (result.has_value() && result->node == ATK_OBJECT(atk_text))
+    return 1;
+
+  return 0;
+}
+
+gchar* GetSelection(AtkText* atk_text,
+                    int selection_num,
+                    int* start_offset,
+                    int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return nullptr;
+  if (selection_num != 0)
+    return nullptr;
+
+  return obj->GetSelectionWithText(start_offset, end_offset);
+}
+
+gboolean RemoveSelection(AtkText* atk_text, int selection_num) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  if (selection_num != 0)
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  // Simply collapse the selection to the position of the caret if a caret is
+  // visible, otherwise set the selection to 0.
+  int selection_end = obj->UTF16ToUnicodeOffsetInText(
+      obj->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd));
+  return SetCaretOffset(atk_text, selection_end);
+}
+
+gboolean SetSelection(AtkText* atk_text,
+                      int selection_num,
+                      int start_offset,
+                      int end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  if (selection_num != 0)
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  return obj->SetTextSelectionForAtkText(start_offset, end_offset);
+}
+
+gboolean AddSelection(AtkText* atk_text, int start_offset, int end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  // We only support one selection.
+  return SetSelection(atk_text, 0, start_offset, end_offset);
+}
+
+#if defined(ATK_210)
+char* GetStringAtOffset(AtkText* atk_text,
+                        int offset,
+                        AtkTextGranularity atk_granularity,
+                        int* start_offset,
+                        int* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  *start_offset = -1;
+  *end_offset = -1;
+
+  ax::mojom::TextBoundary boundary = FromAtkTextGranularity(atk_granularity);
+  return GetTextWithBoundaryType(atk_text, offset, boundary, start_offset,
+                                 end_offset);
+}
+#endif
+
+#if defined(ATK_230)
+gfx::Rect GetUnclippedParentHypertextRangeBoundsRect(
+    AXPlatformNodeDelegate* ax_platform_node_delegate,
+    const int start_offset,
+    const int end_offset) {
+  const AXPlatformNode* parent_platform_node =
+      AXPlatformNode::FromNativeViewAccessible(
+          ax_platform_node_delegate->GetParent());
+  if (!parent_platform_node)
+    return gfx::Rect();
+
+  const AXPlatformNodeDelegate* parent_ax_platform_node_delegate =
+      parent_platform_node->GetDelegate();
+  if (!parent_ax_platform_node_delegate)
+    return gfx::Rect();
+
+  return ax_platform_node_delegate->GetHypertextRangeBoundsRect(
+             start_offset, end_offset, AXCoordinateSystem::kRootFrame,
+             AXClippingBehavior::kUnclipped) -
+         parent_ax_platform_node_delegate
+             ->GetBoundsRect(AXCoordinateSystem::kRootFrame,
+                             AXClippingBehavior::kClipped)
+             .OffsetFromOrigin();
+}
+#endif
+
+void GetCharacterExtents(AtkText* atk_text,
+                         int offset,
+                         int* x,
+                         int* y,
+                         int* width,
+                         int* height,
+                         AtkCoordType coordinate_type) {
+  g_return_if_fail(ATK_IS_TEXT(atk_text));
+
+  gfx::Rect rect;
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (obj) {
+    switch (coordinate_type) {
+#if defined(ATK_230)
+      case ATK_XY_PARENT:
+        rect = GetUnclippedParentHypertextRangeBoundsRect(obj->GetDelegate(),
+                                                          offset, offset + 1);
+        break;
+#endif
+      default:
+        rect = obj->GetDelegate()->GetHypertextRangeBoundsRect(
+            obj->UnicodeToUTF16OffsetInText(offset),
+            obj->UnicodeToUTF16OffsetInText(offset + 1),
+            AtkCoordTypeToAXCoordinateSystem(coordinate_type),
+            AXClippingBehavior::kUnclipped);
+        break;
+    }
+  }
+
+  if (x)
+    *x = rect.x();
+  if (y)
+    *y = rect.y();
+  if (width)
+    *width = rect.width();
+  if (height)
+    *height = rect.height();
+}
+
+void GetRangeExtents(AtkText* atk_text,
+                     int start_offset,
+                     int end_offset,
+                     AtkCoordType coordinate_type,
+                     AtkTextRectangle* out_rectangle) {
+  g_return_if_fail(ATK_IS_TEXT(atk_text));
+
+  if (!out_rectangle)
+    return;
+
+  gfx::Rect rect;
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (obj) {
+    switch (coordinate_type) {
+#if defined(ATK_230)
+      case ATK_XY_PARENT:
+        rect = GetUnclippedParentHypertextRangeBoundsRect(
+            obj->GetDelegate(), start_offset, end_offset);
+        break;
+#endif
+      default:
+        rect = obj->GetDelegate()->GetHypertextRangeBoundsRect(
+            obj->UnicodeToUTF16OffsetInText(start_offset),
+            obj->UnicodeToUTF16OffsetInText(end_offset),
+            AtkCoordTypeToAXCoordinateSystem(coordinate_type),
+            AXClippingBehavior::kUnclipped);
+        break;
+    }
+  }
+
+  out_rectangle->x = rect.x();
+  out_rectangle->y = rect.y();
+  out_rectangle->width = rect.width();
+  out_rectangle->height = rect.height();
+}
+
+AtkAttributeSet* GetRunAttributes(AtkText* atk_text,
+                                  gint offset,
+                                  gint* start_offset,
+                                  gint* end_offset) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  SetIntPointerValueIfNotNull(start_offset, -1);
+  SetIntPointerValueIfNotNull(end_offset, -1);
+
+  if (offset < 0 || offset > GetCharacterCount(atk_text))
+    return nullptr;
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return ToAtkAttributeSet(
+      obj->GetTextAttributes(offset, start_offset, end_offset));
+}
+
+AtkAttributeSet* GetDefaultAttributes(AtkText* atk_text) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
+
+  AtkObject* atk_object = ATK_OBJECT(atk_text);
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+  return ToAtkAttributeSet(obj->GetDefaultTextAttributes());
+}
+
+#if defined(ATK_232)
+gboolean ScrollSubstringTo(AtkText* atk_text,
+                           gint start_offset,
+                           gint end_offset,
+                           AtkScrollType scroll_type) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  return obj->ScrollSubstringIntoView(scroll_type, start_offset, end_offset);
+}
+
+gboolean ScrollSubstringToPoint(AtkText* atk_text,
+                                gint start_offset,
+                                gint end_offset,
+                                AtkCoordType atk_coord_type,
+                                gint x,
+                                gint y) {
+  g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
+  if (!obj)
+    return FALSE;
+
+  return obj->ScrollSubstringToPoint(start_offset, end_offset, atk_coord_type,
+                                     x, y);
+}
+#endif  // ATK_232
+
+void Init(AtkTextIface* iface) {
+  iface->get_text = GetText;
+  iface->get_character_count = GetCharacterCount;
+  iface->get_character_at_offset = GetCharacterAtOffset;
+  iface->get_offset_at_point = GetOffsetAtPoint;
+  iface->get_text_after_offset = GetTextAfterOffset;
+  iface->get_text_before_offset = GetTextBeforeOffset;
+  iface->get_text_at_offset = GetTextAtOffset;
+  iface->get_caret_offset = GetCaretOffset;
+  iface->set_caret_offset = SetCaretOffset;
+  iface->get_character_extents = GetCharacterExtents;
+  iface->get_range_extents = GetRangeExtents;
+  iface->get_n_selections = GetNSelections;
+  iface->get_selection = GetSelection;
+  iface->add_selection = AddSelection;
+  iface->remove_selection = RemoveSelection;
+  iface->set_selection = SetSelection;
+
+  iface->get_run_attributes = GetRunAttributes;
+  iface->get_default_attributes = GetDefaultAttributes;
+
+#if defined(ATK_210)
+  iface->get_string_at_offset = GetStringAtOffset;
+#endif
+
+#if defined(ATK_232)
+  if (SupportsAtkTextScrollingInterface()) {
+    iface->scroll_substring_to = ScrollSubstringTo;
+    iface->scroll_substring_to_point = ScrollSubstringToPoint;
+  }
+#endif
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_text
+
+namespace atk_window {
+void Init(AtkWindowIface* iface) {}
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+}  // namespace atk_window
+
+namespace atk_selection {
+
+gboolean AddSelection(AtkSelection* selection, gint index) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+  if (index < 0 || static_cast<size_t>(index) >= obj->GetChildCount())
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* child =
+      AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(index));
+  if (!child)
+    return FALSE;
+
+  if (!child->SupportsSelectionWithAtkSelection())
+    return FALSE;
+
+  bool selected = child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+  if (selected)
+    return TRUE;
+
+  AXActionData data;
+  data.action = ax::mojom::Action::kDoDefault;
+  return child->GetDelegate()->AccessibilityPerformAction(data);
+}
+
+gboolean ClearSelection(AtkSelection* selection) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+
+  int child_count = obj->GetChildCount();
+  bool success = true;
+  for (int i = 0; i < child_count; ++i) {
+    AXPlatformNodeAuraLinux* child =
+        AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    if (!child->SupportsSelectionWithAtkSelection())
+      continue;
+
+    bool selected =
+        child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+    if (!selected)
+      continue;
+
+    AXActionData data;
+    data.action = ax::mojom::Action::kDoDefault;
+    success = success && child->GetDelegate()->AccessibilityPerformAction(data);
+  }
+
+  return success;
+}
+
+AtkObject* RefSelection(AtkSelection* selection, gint requested_child_index) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return nullptr;
+
+  if (auto* selected_child = obj->GetSelectedItem(requested_child_index)) {
+    if (AtkObject* atk_object = selected_child->GetNativeViewAccessible()) {
+      g_object_ref(atk_object);
+      return atk_object;
+    }
+  }
+
+  return nullptr;
+}
+
+gint GetSelectionCount(AtkSelection* selection) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), 0);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return 0;
+
+  return obj->GetSelectionCount();
+}
+
+gboolean IsChildSelected(AtkSelection* selection, gint index) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+  if (index < 0 || static_cast<size_t>(index) >= obj->GetChildCount())
+    return FALSE;
+
+  AXPlatformNodeAuraLinux* child =
+      AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(index));
+  return child && child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+}
+
+gboolean RemoveSelection(AtkSelection* selection,
+                         gint index_into_selected_children) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+
+  int child_count = obj->GetChildCount();
+  for (int i = 0; i < child_count; ++i) {
+    AXPlatformNodeAuraLinux* child =
+        AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    bool selected =
+        child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+    if (selected && index_into_selected_children == 0) {
+      if (!child->SupportsSelectionWithAtkSelection())
+        return FALSE;
+
+      AXActionData data;
+      data.action = ax::mojom::Action::kDoDefault;
+      return child->GetDelegate()->AccessibilityPerformAction(data);
+    } else if (selected) {
+      index_into_selected_children--;
+    }
+  }
+
+  return FALSE;
+}
+
+gboolean SelectAllSelection(AtkSelection* selection) {
+  g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
+  if (!obj)
+    return FALSE;
+
+  int child_count = obj->GetChildCount();
+  bool success = true;
+  for (int i = 0; i < child_count; ++i) {
+    AXPlatformNodeAuraLinux* child =
+        AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    if (!child->SupportsSelectionWithAtkSelection())
+      continue;
+
+    bool selected =
+        child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+    if (selected)
+      continue;
+
+    AXActionData data;
+    data.action = ax::mojom::Action::kDoDefault;
+    success = success && child->GetDelegate()->AccessibilityPerformAction(data);
+  }
+
+  return success;
+}
+
+void Init(AtkSelectionIface* iface) {
+  iface->add_selection = AddSelection;
+  iface->clear_selection = ClearSelection;
+  iface->ref_selection = RefSelection;
+  iface->get_selection_count = GetSelectionCount;
+  iface->is_child_selected = IsChildSelected;
+  iface->remove_selection = RemoveSelection;
+  iface->select_all_selection = SelectAllSelection;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_selection
+
+namespace atk_table {
+
+AtkObject* RefAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      if (AtkObject* atk_cell = cell->GetNativeViewAccessible()) {
+        g_object_ref(atk_cell);
+        return atk_cell;
+      }
+    }
+  }
+
+  return nullptr;
+}
+
+gint GetIndexAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), -1);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      DCHECK(cell->GetTableCellIndex().has_value());
+      return cell->GetTableCellIndex().value();
+    }
+  }
+
+  return -1;
+}
+
+gint GetColumnAtIndex(AtkTable* table, gint index) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), -1);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(index)) {
+      DCHECK(cell->GetTableColumn().has_value());
+      return cell->GetTableColumn().value();
+    }
+  }
+
+  return -1;
+}
+
+gint GetRowAtIndex(AtkTable* table, gint index) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), -1);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(index)) {
+      DCHECK(cell->GetTableRow().has_value());
+      return cell->GetTableRow().value();
+    }
+  }
+
+  return -1;
+}
+
+gint GetNColumns(AtkTable* table) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    // If the object is not a table, we return 0.
+    return obj->GetTableColumnCount().value_or(0);
+  }
+
+  return 0;
+}
+
+gint GetNRows(AtkTable* table) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    // If the object is not a table, we return 0.
+    return obj->GetTableRowCount().value_or(0);
+  }
+
+  return 0;
+}
+
+gint GetColumnExtentAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      DCHECK(cell->GetTableColumnSpan().has_value());
+      return cell->GetTableColumnSpan().value();
+    }
+  }
+
+  return 0;
+}
+
+gint GetRowExtentAt(AtkTable* table, gint row, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
+      DCHECK(cell->GetTableRowSpan().has_value());
+      return cell->GetTableRowSpan().value();
+    }
+  }
+
+  return 0;
+}
+
+AtkObject* GetColumnHeader(AtkTable* table, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  // AtkTable supports only one column header object. So return the first one
+  // we find. In the case of multiple headers, ATs can fall back on the column
+  // description.
+  std::vector<int32_t> ids = obj->GetDelegate()->GetColHeaderNodeIds(column);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* header = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_header = header->GetNativeViewAccessible()) {
+        g_object_ref(atk_header);
+        return atk_header;
+      }
+    }
+  }
+
+  return nullptr;
+}
+
+AtkObject* GetRowHeader(AtkTable* table, gint row) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  // AtkTable supports only one row header object. So return the first one
+  // we find. In the case of multiple headers, ATs can fall back on the row
+  // description.
+  std::vector<int32_t> ids = obj->GetDelegate()->GetRowHeaderNodeIds(row);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* header = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_header = header->GetNativeViewAccessible()) {
+        g_object_ref(atk_header);
+        return atk_header;
+      }
+    }
+  }
+
+  return nullptr;
+}
+
+AtkObject* GetCaption(AtkTable* table) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
+    if (auto* caption = obj->GetTableCaption())
+      return caption->GetNativeViewAccessible();
+  }
+
+  return nullptr;
+}
+
+const gchar* GetColumnDescription(AtkTable* table, gint column) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  std::vector<int32_t> ids = obj->GetDelegate()->GetColHeaderNodeIds(column);
+  return BuildDescriptionFromHeaders(obj->GetDelegate(), ids);
+}
+
+const gchar* GetRowDescription(AtkTable* table, gint row) {
+  g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
+  if (!obj)
+    return nullptr;
+
+  std::vector<int32_t> ids = obj->GetDelegate()->GetRowHeaderNodeIds(row);
+  return BuildDescriptionFromHeaders(obj->GetDelegate(), ids);
+}
+
+void Init(AtkTableIface* iface) {
+  iface->ref_at = RefAt;
+  iface->get_index_at = GetIndexAt;
+  iface->get_column_at_index = GetColumnAtIndex;
+  iface->get_row_at_index = GetRowAtIndex;
+  iface->get_n_columns = GetNColumns;
+  iface->get_n_rows = GetNRows;
+  iface->get_column_extent_at = GetColumnExtentAt;
+  iface->get_row_extent_at = GetRowExtentAt;
+  iface->get_column_header = GetColumnHeader;
+  iface->get_row_header = GetRowHeader;
+  iface->get_caption = GetCaption;
+  iface->get_column_description = GetColumnDescription;
+  iface->get_row_description = GetRowDescription;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_table
+
+// The ATK table cell interface was added in ATK 2.12.
+#if defined(ATK_212)
+
+namespace atk_table_cell {
+
+gint GetColumnSpan(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()), 0);
+
+  if (const AXPlatformNodeBase* obj =
+          AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    // If the object is not a cell, we return 0.
+    return obj->GetTableColumnSpan().value_or(0);
+  }
+
+  return 0;
+}
+
+GPtrArray* GetColumnHeaderCells(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      nullptr);
+
+  GPtrArray* array = g_ptr_array_new_with_free_func(g_object_unref);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell));
+  if (!obj)
+    return array;
+
+  // AtkTableCell is implemented on cells, row headers, and column headers.
+  // Calling GetColHeaderNodeIds() on a column header cell will include that
+  // column header, along with any other column headers in the column which
+  // may or may not describe the header cell in question. Therefore, just return
+  // headers for non-header cells.
+  if (obj->GetAtkRole() != ATK_ROLE_TABLE_CELL)
+    return array;
+
+  absl::optional<int> col_index = obj->GetTableColumn();
+  if (!col_index)
+    return array;
+
+  const std::vector<int32_t> ids =
+      obj->GetDelegate()->GetColHeaderNodeIds(*col_index);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* node = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_node = node->GetNativeViewAccessible()) {
+        g_ptr_array_add(array, g_object_ref(atk_node));
+      }
+    }
+  }
+
+  return array;
+}
+
+gboolean GetCellPosition(AtkTableCell* cell, gint* row, gint* column) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      FALSE);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    absl::optional<int> row_index = obj->GetTableRow();
+    absl::optional<int> col_index = obj->GetTableColumn();
+    if (!row_index || !col_index)
+      return false;
+
+    *row = *row_index;
+    *column = *col_index;
+    return true;
+  }
+
+  return false;
+}
+
+gint GetRowSpan(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()), 0);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    // If the object is not a cell, we return 0.
+    return obj->GetTableRowSpan().value_or(0);
+  }
+
+  return 0;
+}
+
+GPtrArray* GetRowHeaderCells(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      nullptr);
+
+  GPtrArray* array = g_ptr_array_new_with_free_func(g_object_unref);
+
+  auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell));
+  if (!obj)
+    return array;
+
+  // AtkTableCell is implemented on cells, row headers, and column headers.
+  // Calling GetRowHeaderNodeIds() on a row header cell will include that
+  // row header, along with any other row headers in the row which may or
+  // may not describe the header cell in question. Therefore, just return
+  // headers for non-header cells.
+  if (obj->GetAtkRole() != ATK_ROLE_TABLE_CELL)
+    return array;
+
+  absl::optional<int> row_index = obj->GetTableRow();
+  if (!row_index)
+    return array;
+
+  const std::vector<int32_t> ids =
+      obj->GetDelegate()->GetRowHeaderNodeIds(*row_index);
+  for (const auto& node_id : ids) {
+    if (AXPlatformNode* node = obj->GetDelegate()->GetFromNodeID(node_id)) {
+      if (AtkObject* atk_node = node->GetNativeViewAccessible()) {
+        g_ptr_array_add(array, g_object_ref(atk_node));
+      }
+    }
+  }
+
+  return array;
+}
+
+AtkObject* GetTable(AtkTableCell* cell) {
+  DCHECK(g_atk_table_cell_get_type);
+  g_return_val_if_fail(
+      G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
+      nullptr);
+
+  if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
+    if (auto* table = obj->GetTable())
+      return table->GetNativeViewAccessible();
+  }
+
+  return nullptr;
+}
+
+using AtkTableCellIface = struct _AtkTableCellIface;
+
+void Init(AtkTableCellIface* iface) {
+  iface->get_column_span = GetColumnSpan;
+  iface->get_column_header_cells = GetColumnHeaderCells;
+  iface->get_position = GetCellPosition;
+  iface->get_row_span = GetRowSpan;
+  iface->get_row_header_cells = GetRowHeaderCells;
+  iface->get_table = GetTable;
+}
+
+const GInterfaceInfo Info = {reinterpret_cast<GInterfaceInitFunc>(Init),
+                             nullptr, nullptr};
+
+}  // namespace atk_table_cell
+
+#endif  // ATK_212
+
+namespace atk_object {
+
+gpointer kAXPlatformNodeAuraLinuxParentClass = nullptr;
+
+const gchar* GetName(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (!obj->IsNameExposed())
+    return nullptr;
+
+  ax::mojom::NameFrom name_from = obj->GetNameFrom();
+  if (obj->GetName().empty() &&
+      name_from != ax::mojom::NameFrom::kAttributeExplicitlyEmpty) {
+    return nullptr;
+  }
+
+  obj->accessible_name_ = obj->GetName();
+  return obj->accessible_name_.c_str();
+}
+
+const gchar* AtkGetName(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetName);
+  return GetName(atk_object);
+}
+
+const gchar* GetDescription(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetStringAttribute(ax::mojom::StringAttribute::kDescription)
+      .c_str();
+}
+
+const gchar* AtkGetDescription(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetDescription);
+  return GetDescription(atk_object);
+}
+
+gint GetNChildren(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), 0);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return 0;
+
+  return obj->GetChildCount();
+}
+
+gint AtkGetNChildren(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetNChildren);
+  return GetNChildren(atk_object);
+}
+
+AtkObject* RefChild(AtkObject* atk_object, gint index) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  if (index < 0 || static_cast<size_t>(index) >= obj->GetChildCount())
+    return nullptr;
+
+  AtkObject* result = obj->ChildAtIndex(index);
+  if (result)
+    g_object_ref(result);
+  return result;
+}
+
+AtkObject* AtkRefChild(AtkObject* atk_object, gint index) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kRefChild);
+  return RefChild(atk_object, index);
+}
+
+gint GetIndexInParent(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), -1);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return -1;
+
+  auto index_in_parent = obj->GetIndexInParent();
+  return index_in_parent.has_value()
+             ? static_cast<gint>(index_in_parent.value())
+             : -1;
+}
+
+gint AtkGetIndexInParent(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetIndexInParent);
+  return GetIndexInParent(atk_object);
+}
+
+AtkObject* GetParent(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetParent();
+}
+
+AtkObject* AtkGetParent(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetParent);
+  return GetParent(atk_object);
+}
+
+AtkRelationSet* RefRelationSet(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return atk_relation_set_new();
+  return obj->GetAtkRelations();
+}
+
+AtkRelationSet* AtkRefRelationSet(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kRefRelationSet);
+  // Enables AX mode. Most AT does not call AtkRefRelationSet, but Orca does,
+  // which is why it's a good signal to enable accessibility for Orca users
+  // without too many false positives.
+  AXPlatformNodeAuraLinux::EnableAXMode();
+  return RefRelationSet(atk_object);
+}
+
+AtkAttributeSet* GetAttributes(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return nullptr;
+
+  return obj->GetAtkAttributes();
+}
+
+AtkAttributeSet* AtkGetAttributes(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetAttributes);
+  // Enables AX mode. Most AT does not call AtkGetAttributes, but Orca does,
+  // which is why it's a good signal to enable accessibility for Orca users
+  // without too many false positives.
+  AXPlatformNodeAuraLinux::EnableAXMode();
+  return GetAttributes(atk_object);
+}
+
+AtkRole GetRole(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), ATK_ROLE_INVALID);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj)
+    return ATK_ROLE_INVALID;
+  return obj->GetAtkRole();
+}
+
+AtkRole AtkGetRole(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kGetRole);
+  return GetRole(atk_object);
+}
+
+AtkStateSet* RefStateSet(AtkObject* atk_object) {
+  g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
+
+  AtkStateSet* atk_state_set =
+      ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)
+          ->ref_state_set(atk_object);
+
+  AXPlatformNodeAuraLinux* obj =
+      AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
+  if (!obj) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_DEFUNCT);
+  } else {
+    obj->GetAtkState(atk_state_set);
+  }
+  return atk_state_set;
+}
+
+AtkStateSet* AtkRefStateSet(AtkObject* atk_object) {
+  RecordAccessibilityAtkApi(UmaAtkApi::kRefStateSet);
+  return RefStateSet(atk_object);
+}
+
+void Initialize(AtkObject* atk_object, gpointer data) {
+  if (ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)->initialize) {
+    ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)
+        ->initialize(atk_object, data);
+  }
+
+  AX_PLATFORM_NODE_AURALINUX(atk_object)->m_object =
+      reinterpret_cast<AXPlatformNodeAuraLinux*>(data);
+}
+
+void Finalize(GObject* atk_object) {
+  G_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)->finalize(atk_object);
+}
+
+void ClassInit(gpointer class_pointer, gpointer /* class_data */) {
+  GObjectClass* gobject_class = G_OBJECT_CLASS(class_pointer);
+  kAXPlatformNodeAuraLinuxParentClass = g_type_class_peek_parent(gobject_class);
+  gobject_class->finalize = Finalize;
+
+  AtkObjectClass* atk_object_class = ATK_OBJECT_CLASS(gobject_class);
+  atk_object_class->initialize = Initialize;
+  atk_object_class->get_name = AtkGetName;
+  atk_object_class->get_description = AtkGetDescription;
+  atk_object_class->get_parent = AtkGetParent;
+  atk_object_class->get_n_children = AtkGetNChildren;
+  atk_object_class->ref_child = AtkRefChild;
+  atk_object_class->get_role = AtkGetRole;
+  atk_object_class->ref_state_set = AtkRefStateSet;
+  atk_object_class->get_index_in_parent = AtkGetIndexInParent;
+  atk_object_class->ref_relation_set = AtkRefRelationSet;
+  atk_object_class->get_attributes = AtkGetAttributes;
+}
+
+GType GetType() {
+  AXPlatformNodeAuraLinux::EnsureGTypeInit();
+
+  static gsize type_id = 0;
+  if (g_once_init_enter(&type_id)) {
+    static const GTypeInfo type_info = {
+        sizeof(AXPlatformNodeAuraLinuxClass),  // class_size
+        nullptr,                               // base_init
+        nullptr,                               // base_finalize
+        atk_object::ClassInit,
+        nullptr,                                // class_finalize
+        nullptr,                                // class_data
+        sizeof(AXPlatformNodeAuraLinuxObject),  // instance_size
+        0,                                      // n_preallocs
+        nullptr,                                // instance_init
+        nullptr                                 // value_table
+    };
+
+    GType type = g_type_register_static(
+        ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &type_info, GTypeFlags(0));
+    g_once_init_leave(&type_id, type);
+  }
+
+  return type_id;
+}
+
+void Detach(AXPlatformNodeAuraLinuxObject* atk_object) {
+  if (!atk_object->m_object)
+    return;
+
+  atk_object->m_object = nullptr;
+}
+
+}  //  namespace atk_object
+
+}  // namespace
+
+// static
+NO_SANITIZE("cfi-icall")
+GType AtkTableCellInterface::GetType() {
+  return g_atk_table_cell_get_type();
+}
+
+// static
+NO_SANITIZE("cfi-icall")
+GPtrArray* AtkTableCellInterface::GetColumnHeaderCells(AtkTableCell* cell) {
+  return g_atk_table_cell_get_column_header_cells(cell);
+}
+
+// static
+NO_SANITIZE("cfi-icall")
+GPtrArray* AtkTableCellInterface::GetRowHeaderCells(AtkTableCell* cell) {
+  return g_atk_table_cell_get_row_header_cells(cell);
+}
+
+// static
+NO_SANITIZE("cfi-icall")
+bool AtkTableCellInterface::GetRowColumnSpan(AtkTableCell* cell,
+                                             gint* row,
+                                             gint* column,
+                                             gint* row_span,
+                                             gint* col_span) {
+  return g_atk_table_cell_get_row_column_span(cell, row, column, row_span,
+                                              col_span);
+}
+
+// static
+bool AtkTableCellInterface::Exists() {
+  g_atk_table_cell_get_type = reinterpret_cast<GetTypeFunc>(
+      dlsym(RTLD_DEFAULT, "atk_table_cell_get_type"));
+  g_atk_table_cell_get_column_header_cells =
+      reinterpret_cast<GetColumnHeaderCellsFunc>(
+          dlsym(RTLD_DEFAULT, "atk_table_cell_get_column_header_cells"));
+  g_atk_table_cell_get_row_header_cells =
+      reinterpret_cast<GetRowHeaderCellsFunc>(
+          dlsym(RTLD_DEFAULT, "atk_table_cell_get_row_header_cells"));
+  g_atk_table_cell_get_row_column_span = reinterpret_cast<GetRowColumnSpanFunc>(
+      dlsym(RTLD_DEFAULT, "atk_table_cell_get_row_column_span"));
+  return *g_atk_table_cell_get_type;
+}
+
+void AXPlatformNodeAuraLinux::EnsureGTypeInit() {
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+  static bool first_time = true;
+  if (UNLIKELY(first_time)) {
+    g_type_init();
+    first_time = false;
+  }
+#endif
+}
+
+// static
+ImplementedAtkInterfaces AXPlatformNodeAuraLinux::GetGTypeInterfaceMask(
+    const AXNodeData& data) {
+  // The default implementation set includes the AtkComponent and AtkAction
+  // interfaces, which are provided by all the AtkObjects that we produce.
+  ImplementedAtkInterfaces interface_mask;
+
+  if (!IsImageOrVideo(data.role)) {
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kText);
+    if (!data.IsAtomicTextField())
+      interface_mask.Add(ImplementedAtkInterfaces::Value::kHypertext);
+  }
+
+  if (data.IsRangeValueSupported())
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kValue);
+
+  if (ui::IsPlatformDocument(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kDocument);
+
+  if (IsImage(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kImage);
+
+  // The AtkHyperlinkImpl interface allows getting a AtkHyperlink from an
+  // AtkObject. It is indeed implemented by actual web hyperlinks, but also by
+  // objects that will become embedded objects in ATK hypertext, so the name is
+  // a bit of a misnomer from the ATK API.
+  if (IsLink(data.role) || !ui::IsText(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kHyperlink);
+
+  if (data.role == ax::mojom::Role::kWindow)
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kWindow);
+
+  if (IsContainerWithSelectableChildren(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kSelection);
+
+  if (IsTableLike(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kTable);
+
+  // Because the TableCell Interface is only supported in ATK version 2.12 and
+  // later, GetAccessibilityGType has a runtime check to verify we have a recent
+  // enough version. If we don't, GetAccessibilityGType will exclude
+  // AtkTableCell from the supported interfaces and none of its methods or
+  // properties will be exposed to assistive technologies.
+  if (IsCellOrTableHeader(data.role))
+    interface_mask.Add(ImplementedAtkInterfaces::Value::kTableCell);
+
+  return interface_mask;
+}
+
+GType AXPlatformNodeAuraLinux::GetAccessibilityGType() {
+  static const GTypeInfo type_info = {
+      sizeof(AXPlatformNodeAuraLinuxClass),
+      (GBaseInitFunc) nullptr,
+      (GBaseFinalizeFunc) nullptr,
+      (GClassInitFunc) nullptr,
+      (GClassFinalizeFunc) nullptr,
+      nullptr,                               /* class data */
+      sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */
+      0,                                     /* nb preallocs */
+      (GInstanceInitFunc) nullptr,
+      nullptr /* value table */
+  };
+
+  const char* atk_type_name = GetUniqueAccessibilityGTypeName(interface_mask_);
+  GType type = g_type_from_name(atk_type_name);
+  if (type)
+    return type;
+
+  type = g_type_register_static(AX_PLATFORM_NODE_AURALINUX_TYPE, atk_type_name,
+                                &type_info, GTypeFlags(0));
+
+  // The AtkComponent and AtkAction interfaces are always supported.
+  g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &atk_component::Info);
+  g_type_add_interface_static(type, ATK_TYPE_ACTION, &atk_action::Info);
+
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kDocument))
+    g_type_add_interface_static(type, ATK_TYPE_DOCUMENT, &atk_document::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kImage))
+    g_type_add_interface_static(type, ATK_TYPE_IMAGE, &atk_image::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kValue))
+    g_type_add_interface_static(type, ATK_TYPE_VALUE, &atk_value::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kHyperlink)) {
+    g_type_add_interface_static(type, ATK_TYPE_HYPERLINK_IMPL,
+                                &atk_hyperlink::Info);
+  }
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kHypertext))
+    g_type_add_interface_static(type, ATK_TYPE_HYPERTEXT, &atk_hypertext::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kText))
+    g_type_add_interface_static(type, ATK_TYPE_TEXT, &atk_text::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kWindow))
+    g_type_add_interface_static(type, ATK_TYPE_WINDOW, &atk_window::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kSelection))
+    g_type_add_interface_static(type, ATK_TYPE_SELECTION, &atk_selection::Info);
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kTable))
+    g_type_add_interface_static(type, ATK_TYPE_TABLE, &atk_table::Info);
+
+  if (interface_mask_.Implements(ImplementedAtkInterfaces::Value::kTableCell)) {
+    // Run-time check to ensure AtkTableCell is supported (requires ATK 2.12).
+    if (AtkTableCellInterface::Exists()) {
+      g_type_add_interface_static(type, AtkTableCellInterface::GetType(),
+                                  &atk_table_cell::Info);
+    }
+  }
+
+  return type;
+}
+
+void AXPlatformNodeAuraLinux::SetDocumentParentOnFrameIfNecessary() {
+  if (GetAtkRole() != ATK_ROLE_DOCUMENT_WEB)
+    return;
+
+  if (!GetDelegate()->IsWebContent())
+    return;
+
+  AtkObject* parent_atk_object = GetParent();
+  AXPlatformNodeAuraLinux* parent =
+      AXPlatformNodeAuraLinux::FromAtkObject(parent_atk_object);
+  if (!parent)
+    return;
+
+  if (parent->GetDelegate()->IsWebContent())
+    return;
+
+  AXPlatformNodeAuraLinux* frame = AXPlatformNodeAuraLinux::FromAtkObject(
+      FindAtkObjectParentFrame(parent_atk_object));
+  if (!frame)
+    return;
+
+  frame->SetDocumentParent(parent_atk_object);
+}
+
+AtkObject* AXPlatformNodeAuraLinux::FindPrimaryWebContentDocument() {
+  // It could get multiple web contents since additional web content is added,
+  // when the DevTools window is opened.
+  std::vector<AtkObject*> web_content_candidates;
+  for (auto child_iterator_ptr = GetDelegate()->ChildrenBegin();
+       *child_iterator_ptr != *GetDelegate()->ChildrenEnd();
+       ++(*child_iterator_ptr)) {
+    AtkObject* child = child_iterator_ptr->GetNativeViewAccessible();
+    auto* child_node = AXPlatformNodeAuraLinux::FromAtkObject(child);
+    if (!child_node)
+      continue;
+    if (!child_node->GetDelegate()->IsWebContent())
+      continue;
+    if (child_node->GetAtkRole() != ATK_ROLE_DOCUMENT_WEB)
+      continue;
+    web_content_candidates.push_back(child);
+  }
+
+  if (web_content_candidates.empty())
+    return nullptr;
+
+  // If it finds just one web content, return it.
+  if (web_content_candidates.size() == 1)
+    return web_content_candidates[0];
+
+  for (auto* object : web_content_candidates) {
+    auto* child_node = AXPlatformNodeAuraLinux::FromAtkObject(object);
+    // If it is a primary web contents, return it.
+    if (child_node->GetDelegate()->IsPrimaryWebContentsForWindow()) {
+      return object;
+    }
+  }
+  return nullptr;
+}
+
+bool AXPlatformNodeAuraLinux::IsWebDocumentForRelations() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return false;
+  AXPlatformNodeAuraLinux* parent = FromAtkObject(GetParent());
+  if (!parent || !GetDelegate()->IsWebContent() ||
+      GetAtkRole() != ATK_ROLE_DOCUMENT_WEB)
+    return false;
+  return parent->FindPrimaryWebContentDocument() == atk_object;
+}
+
+AtkObject* AXPlatformNodeAuraLinux::CreateAtkObject() {
+  if (GetRole() != ax::mojom::Role::kApplication &&
+      !GetDelegate()->IsToplevelBrowserWindow() &&
+      !GetAccessibilityMode().has_mode(AXMode::kNativeAPIs)) {
+    return nullptr;
+  }
+  if (GetDelegate()->IsChildOfLeaf())
+    return nullptr;
+  EnsureGTypeInit();
+  interface_mask_ = GetGTypeInterfaceMask(GetData());
+  GType type = GetAccessibilityGType();
+  AtkObject* atk_object = static_cast<AtkObject*>(g_object_new(type, nullptr));
+
+  atk_object_initialize(atk_object, this);
+
+  SetDocumentParentOnFrameIfNecessary();
+
+  return ATK_OBJECT(atk_object);
+}
+
+void AXPlatformNodeAuraLinux::DestroyAtkObjects() {
+  if (atk_hyperlink_) {
+    ax_platform_atk_hyperlink_set_object(
+        AX_PLATFORM_ATK_HYPERLINK(atk_hyperlink_), nullptr);
+    g_object_unref(atk_hyperlink_);
+    atk_hyperlink_ = nullptr;
+  }
+
+  if (atk_object_) {
+    // We explicitly clear g_current_focused just in case there is another
+    // reference to atk_object_ somewhere.
+    if (atk_object_ == g_current_focused)
+      SetWeakGPtrToAtkObject(&g_current_focused, nullptr);
+    atk_object::Detach(AX_PLATFORM_NODE_AURALINUX(atk_object_));
+
+    g_object_unref(atk_object_);
+    atk_object_ = nullptr;
+  }
+}
+
+// static
+AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
+  AXPlatformNodeAuraLinux* node = new AXPlatformNodeAuraLinux();
+  node->Init(delegate);
+  return node;
+}
+
+// static
+AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
+    gfx::NativeViewAccessible accessible) {
+  return AXPlatformNodeAuraLinux::FromAtkObject(accessible);
+}
+
+//
+// AXPlatformNodeAuraLinux implementation.
+//
+
+// static
+AXPlatformNodeAuraLinux* AXPlatformNodeAuraLinux::FromAtkObject(
+    const AtkObject* atk_object) {
+  if (!atk_object)
+    return nullptr;
+
+  if (IS_AX_PLATFORM_NODE_AURALINUX(atk_object)) {
+    AXPlatformNodeAuraLinuxObject* platform_object =
+        AX_PLATFORM_NODE_AURALINUX(atk_object);
+    return platform_object->m_object;
+  }
+
+  return nullptr;
+}
+
+// static
+void AXPlatformNodeAuraLinux::SetApplication(AXPlatformNode* application) {
+  g_root_application = application;
+}
+
+// static
+AXPlatformNode* AXPlatformNodeAuraLinux::application() {
+  return g_root_application;
+}
+
+// static
+void AXPlatformNodeAuraLinux::StaticInitialize() {
+  AtkUtilAuraLinux::GetInstance()->InitializeAsync();
+}
+
+// static
+void AXPlatformNodeAuraLinux::EnableAXMode() {
+  AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
+}
+
+AtkRole AXPlatformNodeAuraLinux::GetAtkRole() const {
+  switch (GetRole()) {
+    case ax::mojom::Role::kAlert:
+      return ATK_ROLE_NOTIFICATION;
+    case ax::mojom::Role::kAlertDialog:
+      return ATK_ROLE_ALERT;
+    case ax::mojom::Role::kComment:
+    case ax::mojom::Role::kSuggestion:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kApplication:
+      // Only use ATK_ROLE_APPLICATION for elements with no parent, since it
+      // is only for top level app windows and not ARIA applications.
+      if (!GetParent()) {
+        return ATK_ROLE_APPLICATION;
+      } else {
+        return ATK_ROLE_EMBEDDED;
+      }
+    case ax::mojom::Role::kArticle:
+      return ATK_ROLE_ARTICLE;
+    case ax::mojom::Role::kAudio:
+      return ATK_ROLE_AUDIO;
+    case ax::mojom::Role::kBanner:
+    case ax::mojom::Role::kHeader:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kBlockquote:
+      return ATK_ROLE_BLOCK_QUOTE;
+    case ax::mojom::Role::kCaret:
+      return ATK_ROLE_UNKNOWN;
+    case ax::mojom::Role::kButton:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kCanvas:
+      return ATK_ROLE_CANVAS;
+    case ax::mojom::Role::kCaption:
+      return ATK_ROLE_CAPTION;
+    case ax::mojom::Role::kCell:
+      return ATK_ROLE_TABLE_CELL;
+    case ax::mojom::Role::kCheckBox:
+      return ATK_ROLE_CHECK_BOX;
+    case ax::mojom::Role::kSwitch:
+      return ATK_ROLE_TOGGLE_BUTTON;
+    case ax::mojom::Role::kColorWell:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kColumn:
+      return ATK_ROLE_UNKNOWN;
+    case ax::mojom::Role::kColumnHeader:
+      return ATK_ROLE_COLUMN_HEADER;
+    case ax::mojom::Role::kComboBoxGrouping:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kComboBoxMenuButton:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kComboBoxSelect:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kComplementary:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kContentDeletion:
+      return kAtkRoleContentDeletion;
+    case ax::mojom::Role::kContentInsertion:
+      return kAtkRoleContentInsertion;
+    case ax::mojom::Role::kContentInfo:
+    case ax::mojom::Role::kFooter:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kDate:
+      return ATK_ROLE_DATE_EDITOR;
+    case ax::mojom::Role::kDateTime:
+      return ATK_ROLE_DATE_EDITOR;
+    case ax::mojom::Role::kDefinition:
+    case ax::mojom::Role::kDescriptionListDetail:
+      return ATK_ROLE_DESCRIPTION_VALUE;
+    case ax::mojom::Role::kDescriptionList:
+      return ATK_ROLE_DESCRIPTION_LIST;
+    case ax::mojom::Role::kDescriptionListTerm:
+      return ATK_ROLE_DESCRIPTION_TERM;
+    case ax::mojom::Role::kDetails:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kDialog:
+      return ATK_ROLE_DIALOG;
+    case ax::mojom::Role::kDirectory:
+      return ATK_ROLE_LIST;
+    case ax::mojom::Role::kDisclosureTriangle:
+      return ATK_ROLE_TOGGLE_BUTTON;
+    case ax::mojom::Role::kDocCover:
+      return ATK_ROLE_IMAGE;
+    case ax::mojom::Role::kDocBackLink:
+    case ax::mojom::Role::kDocBiblioRef:
+    case ax::mojom::Role::kDocGlossRef:
+    case ax::mojom::Role::kDocNoteRef:
+      return ATK_ROLE_LINK;
+    case ax::mojom::Role::kDocBiblioEntry:
+    case ax::mojom::Role::kDocEndnote:
+      return ATK_ROLE_LIST_ITEM;
+    case ax::mojom::Role::kDocNotice:
+    case ax::mojom::Role::kDocTip:
+      return ATK_ROLE_COMMENT;
+    case ax::mojom::Role::kDocFootnote:
+      return kAtkFootnoteRole;
+    case ax::mojom::Role::kDocPageBreak:
+      return ATK_ROLE_SEPARATOR;
+    case ax::mojom::Role::kDocPageFooter:
+      return ATK_ROLE_FOOTER;
+    case ax::mojom::Role::kDocPageHeader:
+      return ATK_ROLE_HEADER;
+    case ax::mojom::Role::kDocAcknowledgments:
+    case ax::mojom::Role::kDocAfterword:
+    case ax::mojom::Role::kDocAppendix:
+    case ax::mojom::Role::kDocBibliography:
+    case ax::mojom::Role::kDocChapter:
+    case ax::mojom::Role::kDocConclusion:
+    case ax::mojom::Role::kDocCredits:
+    case ax::mojom::Role::kDocEndnotes:
+    case ax::mojom::Role::kDocEpilogue:
+    case ax::mojom::Role::kDocErrata:
+    case ax::mojom::Role::kDocForeword:
+    case ax::mojom::Role::kDocGlossary:
+    case ax::mojom::Role::kDocIndex:
+    case ax::mojom::Role::kDocIntroduction:
+    case ax::mojom::Role::kDocPageList:
+    case ax::mojom::Role::kDocPart:
+    case ax::mojom::Role::kDocPreface:
+    case ax::mojom::Role::kDocPrologue:
+    case ax::mojom::Role::kDocToc:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kDocAbstract:
+    case ax::mojom::Role::kDocColophon:
+    case ax::mojom::Role::kDocCredit:
+    case ax::mojom::Role::kDocDedication:
+    case ax::mojom::Role::kDocEpigraph:
+    case ax::mojom::Role::kDocExample:
+    case ax::mojom::Role::kDocPullquote:
+    case ax::mojom::Role::kDocQna:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kDocSubtitle:
+      return ATK_ROLE_HEADING;
+    case ax::mojom::Role::kDocument:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kEmbeddedObject:
+      return ATK_ROLE_EMBEDDED;
+    case ax::mojom::Role::kForm:
+      // TODO(accessibility) Forms which lack an accessible name are no longer
+      // exposed as forms. http://crbug.com/874384. Forms which have accessible
+      // names should be exposed as ATK_ROLE_LANDMARK according to Core AAM.
+      return ATK_ROLE_FORM;
+    case ax::mojom::Role::kFigure:
+    case ax::mojom::Role::kFeed:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kGenericContainer:
+    case ax::mojom::Role::kFooterAsNonLandmark:
+    case ax::mojom::Role::kHeaderAsNonLandmark:
+    case ax::mojom::Role::kRuby:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kGraphicsDocument:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kGraphicsObject:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kGraphicsSymbol:
+      return ATK_ROLE_IMAGE;
+    case ax::mojom::Role::kGrid:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kGroup:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kHeading:
+      return ATK_ROLE_HEADING;
+    case ax::mojom::Role::kIframe:
+    case ax::mojom::Role::kIframePresentational:
+      return ATK_ROLE_INTERNAL_FRAME;
+    case ax::mojom::Role::kImage:
+      return IsImageWithMap() ? ATK_ROLE_IMAGE_MAP : ATK_ROLE_IMAGE;
+    case ax::mojom::Role::kInlineTextBox:
+      return kStaticRole;
+    case ax::mojom::Role::kInputTime:
+      return ATK_ROLE_DATE_EDITOR;
+    case ax::mojom::Role::kLabelText:
+      return ATK_ROLE_LABEL;
+    case ax::mojom::Role::kLegend:
+      return ATK_ROLE_LABEL;
+    // Layout table objects are treated the same as Role::kGenericContainer.
+    case ax::mojom::Role::kLayoutTable:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kLayoutTableCell:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kLayoutTableRow:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kLineBreak:
+      // TODO(Accessibility) Having a separate accessible object for line breaks
+      // is inconsistent with other implementations. http://crbug.com/873144#c1.
+      return kStaticRole;
+    case ax::mojom::Role::kLink:
+      return ATK_ROLE_LINK;
+    case ax::mojom::Role::kList:
+      return ATK_ROLE_LIST;
+    case ax::mojom::Role::kListBox:
+      return ATK_ROLE_LIST_BOX;
+    // TODO(Accessibility) Use ATK_ROLE_MENU_ITEM inside a combo box, see how
+    // ax_platform_node_win.cc code does this.
+    case ax::mojom::Role::kListBoxOption:
+      return ATK_ROLE_LIST_ITEM;
+    case ax::mojom::Role::kListGrid:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kListItem:
+      return ATK_ROLE_LIST_ITEM;
+    case ax::mojom::Role::kListMarker:
+      // Regular list markers only expose their alternative text, but do not
+      // expose their descendants; and the descendants should be ignored. This
+      // is because the alternative text depends on the counter style and can
+      // be different from the actual (visual) marker text, and hence,
+      // inconsistent with the descendants. We treat a list marker as non-text
+      // only if it still has non-ignored descendants, which happens only when:
+      // - The list marker itself is ignored but the descendants are not
+      // - Or the list marker contains images
+      if (!GetChildCount())
+        return kStaticRole;
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kLog:
+      return ATK_ROLE_LOG;
+    case ax::mojom::Role::kMain:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kMark:
+      return kStaticRole;
+    case ax::mojom::Role::kMath:
+    case ax::mojom::Role::kMathMLMath:
+      return ATK_ROLE_MATH;
+    // https://w3c.github.io/mathml-aam/#mathml-element-mappings
+    case ax::mojom::Role::kMathMLFraction:
+      return ATK_ROLE_MATH_FRACTION;
+    case ax::mojom::Role::kMathMLIdentifier:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLMultiscripts:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLNoneScript:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLNumber:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLPrescriptDelimiter:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLOperator:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLOver:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLRoot:
+      return ATK_ROLE_MATH_ROOT;
+    case ax::mojom::Role::kMathMLRow:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLSquareRoot:
+      return ATK_ROLE_MATH_ROOT;
+    case ax::mojom::Role::kMathMLStringLiteral:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLSub:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLSubSup:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLSup:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLTable:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kMathMLTableCell:
+      return ATK_ROLE_TABLE_CELL;
+    case ax::mojom::Role::kMathMLTableRow:
+      return ATK_ROLE_TABLE_ROW;
+    case ax::mojom::Role::kMathMLText:
+      return ATK_ROLE_STATIC;
+    case ax::mojom::Role::kMathMLUnder:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMathMLUnderOver:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kMarquee:
+      return ATK_ROLE_MARQUEE;
+    case ax::mojom::Role::kMenu:
+      return ATK_ROLE_MENU;
+    case ax::mojom::Role::kMenuBar:
+      return ATK_ROLE_MENU_BAR;
+    case ax::mojom::Role::kMenuItem:
+      return ATK_ROLE_MENU_ITEM;
+    case ax::mojom::Role::kMenuItemCheckBox:
+      return ATK_ROLE_CHECK_MENU_ITEM;
+    case ax::mojom::Role::kMenuItemRadio:
+      return ATK_ROLE_RADIO_MENU_ITEM;
+    case ax::mojom::Role::kMenuListPopup:
+      return ATK_ROLE_MENU;
+    case ax::mojom::Role::kMenuListOption:
+      return ATK_ROLE_MENU_ITEM;
+    case ax::mojom::Role::kMeter:
+      return ATK_ROLE_LEVEL_BAR;
+    case ax::mojom::Role::kNavigation:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kNote:
+      return ATK_ROLE_COMMENT;
+    case ax::mojom::Role::kPane:
+    case ax::mojom::Role::kScrollView:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kParagraph:
+      return ATK_ROLE_PARAGRAPH;
+    case ax::mojom::Role::kPdfActionableHighlight:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kPdfRoot:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kPluginObject:
+      return ATK_ROLE_EMBEDDED;
+    case ax::mojom::Role::kPopUpButton:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kPortal:
+      return ATK_ROLE_PUSH_BUTTON;
+    case ax::mojom::Role::kProgressIndicator:
+      return ATK_ROLE_PROGRESS_BAR;
+    case ax::mojom::Role::kRadioButton:
+      return ATK_ROLE_RADIO_BUTTON;
+    case ax::mojom::Role::kRadioGroup:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kRegion:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kRootWebArea:
+      return ATK_ROLE_DOCUMENT_WEB;
+    case ax::mojom::Role::kRow:
+      return ATK_ROLE_TABLE_ROW;
+    case ax::mojom::Role::kRowGroup:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kRowHeader:
+      return ATK_ROLE_ROW_HEADER;
+    case ax::mojom::Role::kRubyAnnotation:
+      // Generally exposed as description on <ruby> (Role::kRuby) element, not
+      // as its own object in the tree.
+      // However, it's possible to make a kRubyAnnotation element show up in the
+      // AX tree, for example by adding tabindex="0" to the source <rp> or <rt>
+      // element or making the source element the target of an aria-owns.
+      // Therefore, browser side needs to gracefully handle it if it actually
+      // shows up in the tree.
+      return kStaticRole;
+    case ax::mojom::Role::kSection:
+      return ATK_ROLE_SECTION;
+    case ax::mojom::Role::kScrollBar:
+      return ATK_ROLE_SCROLL_BAR;
+    case ax::mojom::Role::kSearch:
+      return ATK_ROLE_LANDMARK;
+    case ax::mojom::Role::kSlider:
+      return ATK_ROLE_SLIDER;
+    case ax::mojom::Role::kSpinButton:
+      return ATK_ROLE_SPIN_BUTTON;
+    case ax::mojom::Role::kSplitter:
+      return ATK_ROLE_SEPARATOR;
+    case ax::mojom::Role::kStaticText:
+      return kStaticRole;
+    case ax::mojom::Role::kStatus:
+      return ATK_ROLE_STATUSBAR;
+    case ax::mojom::Role::kSubscript:
+      return kSubscriptRole;
+    case ax::mojom::Role::kSuperscript:
+      return kSuperscriptRole;
+    case ax::mojom::Role::kSvgRoot:
+      return ATK_ROLE_DOCUMENT_FRAME;
+    case ax::mojom::Role::kTab:
+      return ATK_ROLE_PAGE_TAB;
+    case ax::mojom::Role::kTable:
+      return ATK_ROLE_TABLE;
+    case ax::mojom::Role::kTableHeaderContainer:
+      // TODO(accessibility) This mapping is correct, but it doesn't seem to be
+      // used. We don't necessarily want to always expose these containers, but
+      // we must do so if they are focusable. http://crbug.com/874043
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kTabList:
+      return ATK_ROLE_PAGE_TAB_LIST;
+    case ax::mojom::Role::kTabPanel:
+      return ATK_ROLE_SCROLL_PANE;
+    case ax::mojom::Role::kTerm:
+      return ATK_ROLE_DESCRIPTION_TERM;
+    case ax::mojom::Role::kTitleBar:
+      return ATK_ROLE_TITLE_BAR;
+    case ax::mojom::Role::kTextField:
+    case ax::mojom::Role::kSearchBox:
+      if (HasState(ax::mojom::State::kProtected))
+        return ATK_ROLE_PASSWORD_TEXT;
+      return ATK_ROLE_ENTRY;
+    case ax::mojom::Role::kTextFieldWithComboBox:
+      return ATK_ROLE_COMBO_BOX;
+    case ax::mojom::Role::kAbbr:
+    case ax::mojom::Role::kCode:
+    case ax::mojom::Role::kEmphasis:
+    case ax::mojom::Role::kStrong:
+    case ax::mojom::Role::kTime:
+      return kStaticRole;
+    case ax::mojom::Role::kTimer:
+      return ATK_ROLE_TIMER;
+    case ax::mojom::Role::kToggleButton:
+      return ATK_ROLE_TOGGLE_BUTTON;
+    case ax::mojom::Role::kToolbar:
+      return ATK_ROLE_TOOL_BAR;
+    case ax::mojom::Role::kTooltip:
+      return ATK_ROLE_TOOL_TIP;
+    case ax::mojom::Role::kTree:
+      return ATK_ROLE_TREE;
+    case ax::mojom::Role::kTreeItem:
+      return ATK_ROLE_TREE_ITEM;
+    case ax::mojom::Role::kTreeGrid:
+      return ATK_ROLE_TREE_TABLE;
+    case ax::mojom::Role::kVideo:
+      return ATK_ROLE_VIDEO;
+    case ax::mojom::Role::kWindow:
+      // In ATK elements with ATK_ROLE_FRAME are windows with titles and
+      // buttons, while those with ATK_ROLE_WINDOW are windows without those
+      // elements.
+      return ATK_ROLE_FRAME;
+    case ax::mojom::Role::kClient:
+    case ax::mojom::Role::kDesktop:
+    case ax::mojom::Role::kWebView:
+      return ATK_ROLE_PANEL;
+    case ax::mojom::Role::kFigcaption:
+      return ATK_ROLE_CAPTION;
+    case ax::mojom::Role::kUnknown:
+      // When we are not in web content, assume that a node with an unknown
+      // role is a view (which often have the unknown role).
+      return !GetDelegate()->IsWebContent() ? ATK_ROLE_PANEL : ATK_ROLE_UNKNOWN;
+    case ax::mojom::Role::kImeCandidate:
+    case ax::mojom::Role::kKeyboard:
+    case ax::mojom::Role::kNone:
+      return ATK_ROLE_REDUNDANT_OBJECT;
+    case ax::mojom::Role::kPreDeprecated:
+      NOTREACHED_NORETURN();
+  }
+}
+
+// If we were compiled with a newer version of ATK than the runtime version,
+// it's possible that the state we want to expose and/or emit an event for
+// is not present. This will generate a runtime error.
+bool PlatformSupportsState(AtkStateType atk_state_type) {
+  static absl::optional<int> max_state_type = absl::nullopt;
+  if (!max_state_type.has_value()) {
+    GEnumClass* enum_class =
+        G_ENUM_CLASS(g_type_class_ref(atk_state_type_get_type()));
+    max_state_type = enum_class->maximum;
+    g_type_class_unref(enum_class);
+  }
+  return atk_state_type < max_state_type.value();
+}
+
+void AXPlatformNodeAuraLinux::GetAtkState(AtkStateSet* atk_state_set) {
+  bool menu_active = !GetActiveMenus().empty();
+  if (!menu_active && atk_object_ == g_active_top_level_frame)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+  if (menu_active &&
+      FindAtkObjectParentFrame(GetActiveMenus().back()) == atk_object_)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+
+  if (atk_object_ && atk_object_ == g_active_views_dialog)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+
+  bool is_minimized = delegate_->IsMinimized();
+  if (is_minimized && GetRole() == ax::mojom::Role::kWindow)
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ICONIFIED);
+
+  if (HasState(ax::mojom::State::kCollapsed))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDABLE);
+  if (HasState(ax::mojom::State::kDefault))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_DEFAULT);
+  if ((HasState(ax::mojom::State::kEditable) ||
+       HasState(ax::mojom::State::kRichlyEditable)) &&
+      GetData().GetRestriction() != ax::mojom::Restriction::kReadOnly) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EDITABLE);
+  }
+  if (HasState(ax::mojom::State::kExpanded)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDABLE);
+    atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDED);
+  }
+  if (IsFocused())
+    atk_state_set_add_state(atk_state_set, ATK_STATE_FOCUSED);
+  if (IsFocusable())
+    atk_state_set_add_state(atk_state_set, ATK_STATE_FOCUSABLE);
+  if (HasState(ax::mojom::State::kHorizontal))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_HORIZONTAL);
+  if (!IsInvisibleOrIgnored()) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_VISIBLE);
+    if (!delegate_->IsOffscreen() && !is_minimized)
+      atk_state_set_add_state(atk_state_set, ATK_STATE_SHOWING);
+  }
+  if (HasState(ax::mojom::State::kMultiselectable))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_MULTISELECTABLE);
+  if (HasState(ax::mojom::State::kRequired))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_REQUIRED);
+  if (HasState(ax::mojom::State::kVertical))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_VERTICAL);
+  if (HasState(ax::mojom::State::kVisited))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_VISITED);
+  if (HasIntAttribute(ax::mojom::IntAttribute::kInvalidState) &&
+      GetIntAttribute(ax::mojom::IntAttribute::kInvalidState) !=
+          static_cast<int32_t>(ax::mojom::InvalidState::kFalse)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_INVALID_ENTRY);
+  }
+  if (HasIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState) &&
+      GetIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState) !=
+          static_cast<int32_t>(ax::mojom::AriaCurrentState::kFalse)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_ACTIVE);
+  }
+#if defined(ATK_216)
+  // Runtime checks in case we were compiled with a newer version of ATK.
+  if (IsPlatformCheckable() && PlatformSupportsState(ATK_STATE_CHECKABLE))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_CHECKABLE);
+  if (HasIntAttribute(ax::mojom::IntAttribute::kHasPopup) &&
+      PlatformSupportsState(ATK_STATE_HAS_POPUP))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_HAS_POPUP);
+#endif
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kBusy))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_BUSY);
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kModal))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_MODAL);
+  if (GetData().IsSelectable())
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTABLE);
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kSelected))
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTED);
+
+  if (IsTextField()) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTABLE_TEXT);
+    if (HasState(ax::mojom::State::kMultiline))
+      atk_state_set_add_state(atk_state_set, ATK_STATE_MULTI_LINE);
+    else
+      atk_state_set_add_state(atk_state_set, ATK_STATE_SINGLE_LINE);
+  }
+
+  // Special case for indeterminate progressbar.
+  if (GetRole() == ax::mojom::Role::kProgressIndicator &&
+      !HasFloatAttribute(ax::mojom::FloatAttribute::kValueForRange)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_INDETERMINATE);
+  }
+
+  if (!GetStringAttribute(ax::mojom::StringAttribute::kAutoComplete).empty() ||
+      HasState(ax::mojom::State::kAutofillAvailable)) {
+    atk_state_set_add_state(atk_state_set, ATK_STATE_SUPPORTS_AUTOCOMPLETION);
+  }
+
+  // Checked state
+  const auto checked_state = GetData().GetCheckedState();
+  if (checked_state == ax::mojom::CheckedState::kTrue ||
+      checked_state == ax::mojom::CheckedState::kMixed) {
+    atk_state_set_add_state(atk_state_set, GetAtkStateTypeForCheckableNode());
+  }
+
+  if (GetData().GetRestriction() != ax::mojom::Restriction::kDisabled) {
+    if (GetDelegate()->IsReadOnlySupported() &&
+        GetDelegate()->IsReadOnlyOrDisabled()) {
+#if defined(ATK_216)
+      // Runtime check in case we were compiled with a newer version of ATK.
+      if (PlatformSupportsState(ATK_STATE_READ_ONLY))
+        atk_state_set_add_state(atk_state_set, ATK_STATE_READ_ONLY);
+#endif
+    } else {
+      atk_state_set_add_state(atk_state_set, ATK_STATE_ENABLED);
+      atk_state_set_add_state(atk_state_set, ATK_STATE_SENSITIVE);
+    }
+  }
+}
+
+// Some relations only exist in a high enough ATK version.
+// If a relation has a version requirement, it will be documented in
+// the link below.
+// https://docs.gtk.org/atk/enum.RelationType.html
+struct AtkIntRelation {
+  ax::mojom::IntAttribute attribute;
+  AtkRelationType relation;
+  absl::optional<AtkRelationType> reverse_relation;
+};
+
+static AtkIntRelation kIntRelations[] = {
+    {ax::mojom::IntAttribute::kMemberOfId, ATK_RELATION_MEMBER_OF,
+     absl::nullopt},
+    {ax::mojom::IntAttribute::kPopupForId, ATK_RELATION_POPUP_FOR,
+     absl::nullopt},
+};
+
+struct AtkIntListRelation {
+  ax::mojom::IntListAttribute attribute;
+  AtkRelationType relation;
+  absl::optional<AtkRelationType> reverse_relation;
+};
+
+static AtkIntListRelation kIntListRelations[] = {
+    {ax::mojom::IntListAttribute::kControlsIds, ATK_RELATION_CONTROLLER_FOR,
+     ATK_RELATION_CONTROLLED_BY},
+#if defined(ATK_226)
+    {ax::mojom::IntListAttribute::kDetailsIds, ATK_RELATION_DETAILS,
+     ATK_RELATION_DETAILS_FOR},
+#endif
+    {ax::mojom::IntListAttribute::kDescribedbyIds, ATK_RELATION_DESCRIBED_BY,
+     ATK_RELATION_DESCRIPTION_FOR},
+#if defined(ATK_226)
+    {ax::mojom::IntListAttribute::kErrormessageIds, ATK_RELATION_ERROR_MESSAGE,
+     ATK_RELATION_ERROR_FOR},
+#endif
+    {ax::mojom::IntListAttribute::kFlowtoIds, ATK_RELATION_FLOWS_TO,
+     ATK_RELATION_FLOWS_FROM},
+    {ax::mojom::IntListAttribute::kLabelledbyIds, ATK_RELATION_LABELLED_BY,
+     ATK_RELATION_LABEL_FOR},
+};
+
+void AXPlatformNodeAuraLinux::AddRelationToSet(AtkRelationSet* relation_set,
+                                               AtkRelationType relation,
+                                               AXPlatformNode* target) {
+  DCHECK(target);
+  DCHECK(GetDelegate()->IsValidRelationTarget(target));
+
+  // If we were compiled with a newer version of ATK than the runtime version,
+  // it's possible that we might try to add a relation that doesn't exist in
+  // the runtime version of the AtkRelationType enum. This will cause a runtime
+  // error, so return early here if we are about to do that.
+  static absl::optional<int> max_relation_type = absl::nullopt;
+  if (!max_relation_type.has_value()) {
+    GEnumClass* enum_class =
+        G_ENUM_CLASS(g_type_class_ref(atk_relation_type_get_type()));
+    max_relation_type = enum_class->maximum;
+    g_type_class_unref(enum_class);
+  }
+  if (relation >= max_relation_type.value())
+    return;
+
+  atk_relation_set_add_relation_by_type(relation_set, relation,
+                                        target->GetNativeViewAccessible());
+}
+
+AtkRelationSet* AXPlatformNodeAuraLinux::GetAtkRelations() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return nullptr;
+
+  AtkRelationSet* relation_set = atk_relation_set_new();
+
+  if (IsWebDocumentForRelations()) {
+    AtkObject* parent_frame = FindAtkObjectParentFrame(atk_object);
+    if (parent_frame) {
+      atk_relation_set_add_relation_by_type(
+          relation_set, ATK_RELATION_EMBEDDED_BY, parent_frame);
+    }
+  }
+
+  if (auto* document_parent = FromAtkObject(document_parent_)) {
+    AtkObject* document = document_parent->FindPrimaryWebContentDocument();
+    if (document) {
+      atk_relation_set_add_relation_by_type(relation_set, ATK_RELATION_EMBEDS,
+                                            document);
+    }
+  }
+
+  // For each possible relation defined by an IntAttribute, we test that
+  // attribute and then look for reverse relations.
+  for (auto relation : kIntRelations) {
+    if (AXPlatformNode* target =
+            GetDelegate()->GetTargetNodeForRelation(relation.attribute))
+      AddRelationToSet(relation_set, relation.relation, target);
+
+    if (!relation.reverse_relation.has_value())
+      continue;
+
+    std::vector<AXPlatformNode*> target_ids =
+        GetDelegate()->GetSourceNodesForReverseRelations(relation.attribute);
+    for (AXPlatformNode* target : target_ids) {
+      AddRelationToSet(relation_set, relation.reverse_relation.value(), target);
+    }
+  }
+
+  // Now we do the same for each possible relation defined by an
+  // IntListAttribute. In this case we need to handle each target in the list.
+  for (const auto& relation : kIntListRelations) {
+    std::vector<AXPlatformNode*> targets =
+        GetDelegate()->GetTargetNodesForRelation(relation.attribute);
+    for (AXPlatformNode* target : targets) {
+      AddRelationToSet(relation_set, relation.relation, target);
+    }
+
+    if (!relation.reverse_relation.has_value())
+      continue;
+
+    std::vector<AXPlatformNode*> reverse_target_ids =
+        GetDelegate()->GetSourceNodesForReverseRelations(relation.attribute);
+    for (AXPlatformNode* target : reverse_target_ids) {
+      AddRelationToSet(relation_set, relation.reverse_relation.value(), target);
+    }
+  }
+
+  return relation_set;
+}
+
+AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() = default;
+
+AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() {
+  if (g_current_selected == this)
+    g_current_selected = nullptr;
+
+  DestroyAtkObjects();
+
+  if (window_activate_event_postponed_)
+    AtkUtilAuraLinux::GetInstance()->CancelPostponedEventsFor(this);
+
+  SetWeakGPtrToAtkObject(&document_parent_, nullptr);
+}
+
+void AXPlatformNodeAuraLinux::Destroy() {
+  DestroyAtkObjects();
+  AXPlatformNodeBase::Destroy();
+}
+
+void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) {
+  // Initialize ATK.
+  AXPlatformNodeBase::Init(delegate);
+
+  // Only create the AtkObject if we know enough information.
+  if (GetRole() != ax::mojom::Role::kUnknown)
+    GetOrCreateAtkObject();
+}
+
+bool AXPlatformNodeAuraLinux::IsPlatformCheckable() const {
+  if (GetRole() == ax::mojom::Role::kToggleButton)
+    return false;
+
+  return AXPlatformNodeBase::IsPlatformCheckable();
+}
+
+absl::optional<size_t> AXPlatformNodeAuraLinux::GetIndexInParent() {
+  AXPlatformNode* parent =
+      AXPlatformNode::FromNativeViewAccessible(GetParent());
+  // Even though the node doesn't have its parent, GetParent() could return the
+  // application. Since the detached view has the kUnknown role and the
+  // restriction is kDisabled, it early returns before finding the index.
+  if (parent == AXPlatformNodeAuraLinux::application() &&
+      GetRole() == ax::mojom::Role::kUnknown &&
+      GetData().GetRestriction() == ax::mojom::Restriction::kDisabled) {
+    return absl::nullopt;
+  }
+
+  return AXPlatformNodeBase::GetIndexInParent();
+}
+
+void AXPlatformNodeAuraLinux::EnsureAtkObjectIsValid() {
+  if (atk_object_) {
+    // If the object's role changes and that causes its
+    // interface mask to change, we need to create a new
+    // AtkObject for it.
+    ImplementedAtkInterfaces interface_mask = GetGTypeInterfaceMask(GetData());
+    if (interface_mask != interface_mask_)
+      DestroyAtkObjects();
+  }
+
+  if (!atk_object_) {
+    GetOrCreateAtkObject();
+  }
+}
+
+gfx::NativeViewAccessible AXPlatformNodeAuraLinux::GetNativeViewAccessible() {
+  return GetOrCreateAtkObject();
+}
+
+gfx::NativeViewAccessible AXPlatformNodeAuraLinux::GetOrCreateAtkObject() {
+  if (!atk_object_) {
+    atk_object_ = CreateAtkObject();
+  }
+  return atk_object_;
+}
+
+void AXPlatformNodeAuraLinux::OnCheckedStateChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(
+      ATK_OBJECT(obj), GetAtkStateTypeForCheckableNode(),
+      GetData().GetCheckedState() != ax::mojom::CheckedState::kFalse);
+}
+
+void AXPlatformNodeAuraLinux::OnEnabledChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(
+      obj, ATK_STATE_ENABLED,
+      GetData().GetRestriction() != ax::mojom::Restriction::kDisabled);
+
+  atk_object_notify_state_change(
+      obj, ATK_STATE_SENSITIVE,
+      GetData().GetRestriction() != ax::mojom::Restriction::kDisabled);
+}
+
+void AXPlatformNodeAuraLinux::OnBusyStateChanged(bool is_busy) {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(obj, ATK_STATE_BUSY, is_busy);
+}
+
+void AXPlatformNodeAuraLinux::OnExpandedStateChanged(bool is_expanded) {
+  // When a list box is expanded, it becomes visible. This means that it might
+  // now have a different role (the role for hidden Views is kUnknown).  We
+  // need to recreate the AtkObject in this case because a change in roles
+  // might imply a change in ATK interfaces implemented.
+  EnsureAtkObjectIsValid();
+
+  DCHECK(HasState(ax::mojom::State::kCollapsed) ||
+         HasState(ax::mojom::State::kExpanded));
+
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(obj, ATK_STATE_EXPANDED, is_expanded);
+}
+
+void AXPlatformNodeAuraLinux::OnShowingStateChanged(bool is_showing) {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  atk_object_notify_state_change(obj, ATK_STATE_SHOWING, is_showing);
+}
+
+void AXPlatformNodeAuraLinux::OnMenuPopupStart() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  AtkObject* parent_frame = FindAtkObjectParentFrame(atk_object);
+  if (!parent_frame)
+    return;
+
+  // Exit early if kMenuPopupStart is sent multiple times for the same menu.
+  std::vector<AtkObject*>& active_menus = GetActiveMenus();
+  bool menu_already_open = !active_menus.empty();
+  if (menu_already_open && active_menus.back() == atk_object)
+    return;
+
+  // We also want to inform the AT that menu the is now showing. Normally this
+  // event is not fired because the menu will be created with the
+  // ATK_STATE_SHOWING already set to TRUE.
+  atk_object_notify_state_change(atk_object, ATK_STATE_SHOWING, TRUE);
+
+  // We need to compute this before modifying the active menu stack.
+  AtkObject* previous_active_frame = ComputeActiveTopLevelFrame();
+
+  active_menus.push_back(atk_object);
+
+  // We exit early if the newly activated menu has the same AtkWindow as the
+  // previous one.
+  if (previous_active_frame == parent_frame)
+    return;
+  if (previous_active_frame) {
+    g_signal_emit_by_name(previous_active_frame, "deactivate");
+    atk_object_notify_state_change(previous_active_frame, ATK_STATE_ACTIVE,
+                                   FALSE);
+  }
+  g_signal_emit_by_name(parent_frame, "activate");
+  atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, TRUE);
+}
+
+void AXPlatformNodeAuraLinux::OnMenuPopupEnd() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  AtkObject* parent_frame = FindAtkObjectParentFrame(atk_object);
+  if (!parent_frame)
+    return;
+
+  atk_object_notify_state_change(atk_object, ATK_STATE_SHOWING, FALSE);
+
+  // kMenuPopupHide may be called multiple times for the same menu, so only
+  // remove it if our parent frame matches the most recently opened menu.
+  std::vector<AtkObject*>& active_menus = GetActiveMenus();
+  DCHECK(!active_menus.empty())
+      << "Asymmetrical menupopupend events -- too many";
+
+  active_menus.pop_back();
+  AtkObject* new_active_item = ComputeActiveTopLevelFrame();
+  if (new_active_item != parent_frame) {
+    // Newly activated menu has the different AtkWindow as the previous one.
+    g_signal_emit_by_name(parent_frame, "deactivate");
+    atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, FALSE);
+    if (new_active_item) {
+      g_signal_emit_by_name(new_active_item, "activate");
+      atk_object_notify_state_change(new_active_item, ATK_STATE_ACTIVE, TRUE);
+    }
+  }
+
+  // All menus are closed.
+  if (active_menus.empty())
+    OnAllMenusEnded();
+}
+
+void AXPlatformNodeAuraLinux::ResendFocusSignalsForCurrentlyFocusedNode() {
+  auto* frame = FromAtkObject(g_active_top_level_frame);
+  if (!frame)
+    return;
+
+  AtkObject* focused_node = frame->GetDelegate()->GetFocus();
+  if (!focused_node)
+    return;
+
+  g_signal_emit_by_name(focused_node, "focus-event", true);
+  atk_object_notify_state_change(focused_node, ATK_STATE_FOCUSED, true);
+}
+
+void AXPlatformNodeAuraLinux::SetAsCurrentlyFocusedNode() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  SetWeakGPtrToAtkObject(&g_current_focused, obj);
+}
+
+// All menus have closed.
+void AXPlatformNodeAuraLinux::OnAllMenusEnded() {
+  if (!GetActiveMenus().empty() && g_active_top_level_frame &&
+      ComputeActiveTopLevelFrame() != g_active_top_level_frame) {
+    g_signal_emit_by_name(g_active_top_level_frame, "activate");
+    atk_object_notify_state_change(g_active_top_level_frame, ATK_STATE_ACTIVE,
+                                   TRUE);
+  }
+
+  GetActiveMenus().clear();
+  ResendFocusSignalsForCurrentlyFocusedNode();
+}
+
+void AXPlatformNodeAuraLinux::OnWindowActivated() {
+  AtkObject* parent_frame = FindAtkObjectParentFrame(GetOrCreateAtkObject());
+  if (!parent_frame || parent_frame == g_active_top_level_frame)
+    return;
+
+  SetActiveTopLevelFrame(parent_frame);
+
+  g_signal_emit_by_name(parent_frame, "activate");
+  atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, TRUE);
+
+  // We also send a focus event for the currently focused element, so that
+  // the user knows where the focus is when the toplevel window regains focus.
+  if (g_current_focused &&
+      IsFrameAncestorOfAtkObject(parent_frame, g_current_focused)) {
+    g_signal_emit_by_name(g_current_focused, "focus-event", true);
+    atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
+                                   ATK_STATE_FOCUSED, true);
+  }
+}
+
+void AXPlatformNodeAuraLinux::OnWindowDeactivated() {
+  AtkObject* parent_frame = FindAtkObjectParentFrame(GetOrCreateAtkObject());
+  if (!parent_frame || parent_frame != g_active_top_level_frame)
+    return;
+
+  SetActiveTopLevelFrame(nullptr);
+
+  g_signal_emit_by_name(parent_frame, "deactivate");
+  atk_object_notify_state_change(parent_frame, ATK_STATE_ACTIVE, FALSE);
+}
+
+void AXPlatformNodeAuraLinux::OnWindowVisibilityChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  if (GetAtkRole() != ATK_ROLE_FRAME)
+    return;
+
+  bool minimized = delegate_->IsMinimized();
+  if (minimized == was_minimized_)
+    return;
+
+  was_minimized_ = minimized;
+  if (minimized)
+    g_signal_emit_by_name(atk_object, "minimize");
+  else
+    g_signal_emit_by_name(atk_object, "restore");
+  atk_object_notify_state_change(atk_object, ATK_STATE_ICONIFIED, minimized);
+}
+
+void AXPlatformNodeAuraLinux::OnScrolledToAnchor() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+  // The text-caret-moved event is used to signal a scroll to anchor event.
+  if (ATK_IS_TEXT(atk_object)) {
+    g_signal_emit_by_name(atk_object, "text-caret-moved", 0);
+  }
+}
+
+void AXPlatformNodeAuraLinux::SetActiveViewsDialog() {
+  AtkObject* old_views_dialog = g_active_views_dialog;
+  AtkObject* new_views_dialog = nullptr;
+
+  AtkObject* parent = GetOrCreateAtkObject();
+  if (!parent)
+    return;
+
+  if (!GetDelegate()->IsWebContent()) {
+    while (parent) {
+      if (atk_object::GetRole(parent) == ATK_ROLE_DIALOG) {
+        new_views_dialog = parent;
+        break;
+      }
+      parent = atk_object::GetParent(parent);
+    }
+  }
+
+  if (old_views_dialog == new_views_dialog)
+    return;
+
+  SetWeakGPtrToAtkObject(&g_active_views_dialog, new_views_dialog);
+  if (old_views_dialog)
+    atk_object_notify_state_change(old_views_dialog, ATK_STATE_ACTIVE, FALSE);
+  if (new_views_dialog)
+    atk_object_notify_state_change(new_views_dialog, ATK_STATE_ACTIVE, TRUE);
+}
+
+void AXPlatformNodeAuraLinux::OnFocused() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  if (atk_object::GetRole(atk_object) == ATK_ROLE_FRAME) {
+    OnWindowActivated();
+    return;
+  }
+
+  if (atk_object == g_current_focused)
+    return;
+
+  SetActiveViewsDialog();
+
+  if (g_current_focused) {
+    g_signal_emit_by_name(g_current_focused, "focus-event", false);
+    atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
+                                   ATK_STATE_FOCUSED, false);
+  }
+
+  SetWeakGPtrToAtkObject(&g_current_focused, atk_object);
+
+  g_signal_emit_by_name(g_current_focused, "focus-event", true);
+  atk_object_notify_state_change(ATK_OBJECT(g_current_focused),
+                                 ATK_STATE_FOCUSED, true);
+}
+
+void AXPlatformNodeAuraLinux::OnSelected() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+  if (g_current_selected && !g_current_selected->GetBoolAttribute(
+                                ax::mojom::BoolAttribute::kSelected)) {
+    atk_object_notify_state_change(
+        ATK_OBJECT(g_current_selected->GetOrCreateAtkObject()),
+        ATK_STATE_SELECTED, false);
+  }
+
+  g_current_selected = this;
+  if (ATK_IS_OBJECT(atk_object)) {
+    atk_object_notify_state_change(ATK_OBJECT(atk_object), ATK_STATE_SELECTED,
+                                   true);
+  }
+}
+
+void AXPlatformNodeAuraLinux::OnSelectedChildrenChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+  g_signal_emit_by_name(obj, "selection-changed", true);
+}
+
+bool AXPlatformNodeAuraLinux::EmitsAtkTextEvents() const {
+  // Objects which do not implement AtkText cannot emit AtkText events.
+  if (!atk_object_ || !ATK_IS_TEXT(atk_object_))
+    return false;
+
+  // Objects which do implement AtkText, but are ignored or invisible should not
+  // emit AtkText events.
+  if (IsInvisibleOrIgnored())
+    return false;
+
+  // If this node is not a static text node, it supports the full AtkText
+  // interface.
+  if (GetAtkRole() != kStaticRole)
+    return true;
+
+  // If this node has children it is not a static text leaf node and supports
+  // the full AtkText interface.
+  if (GetChildCount())
+    return true;
+
+  return false;
+}
+
+void AXPlatformNodeAuraLinux::GetFullSelection(int32_t* anchor_node_id,
+                                               int* anchor_offset,
+                                               int32_t* focus_node_id,
+                                               int* focus_offset) {
+  DCHECK(anchor_node_id);
+  DCHECK(anchor_offset);
+  DCHECK(focus_node_id);
+  DCHECK(focus_offset);
+
+  if (IsAtomicTextField() &&
+      GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, anchor_offset) &&
+      GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, focus_offset)) {
+    int32_t node_id = GetData().id != -1 ? GetData().id : GetUniqueId();
+    *anchor_node_id = *focus_node_id = node_id;
+    return;
+  }
+
+  AXSelection selection = GetDelegate()->GetUnignoredSelection();
+  *anchor_node_id = selection.anchor_object_id;
+  *anchor_offset = selection.anchor_offset;
+  *focus_node_id = selection.focus_object_id;
+  *focus_offset = selection.focus_offset;
+}
+
+AXPlatformNodeAuraLinux& AXPlatformNodeAuraLinux::FindEditableRootOrDocument() {
+  if (GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
+    return *this;
+  if (GetBoolAttribute(ax::mojom::BoolAttribute::kNonAtomicTextFieldRoot) &&
+      HasState(ax::mojom::State::kEditable))
+    return *this;
+  if (auto* parent = FromAtkObject(GetParent()))
+    return parent->FindEditableRootOrDocument();
+  return *this;
+}
+
+AXPlatformNodeAuraLinux* AXPlatformNodeAuraLinux::FindCommonAncestor(
+    AXPlatformNodeAuraLinux* other) {
+  if (this == other || other->IsDescendantOf(this))
+    return this;
+  if (auto* parent = FromAtkObject(GetParent()))
+    return parent->FindCommonAncestor(other);
+  return nullptr;
+}
+
+void AXPlatformNodeAuraLinux::UpdateSelectionInformation(int32_t anchor_node_id,
+                                                         int anchor_offset,
+                                                         int32_t focus_node_id,
+                                                         int focus_offset) {
+  had_nonzero_width_selection =
+      focus_node_id != anchor_node_id || focus_offset != anchor_offset;
+  current_caret_ = std::make_pair(focus_node_id, focus_offset);
+}
+
+void AXPlatformNodeAuraLinux::EmitSelectionChangedSignal(bool had_selection) {
+  if (!EmitsAtkTextEvents()) {
+    if (auto* parent = FromAtkObject(GetParent()))
+      parent->EmitSelectionChangedSignal(had_selection);
+    return;
+  }
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+  DCHECK(ATK_IS_TEXT(atk_object));
+
+  // ATK does not consider a collapsed selection a selection, so
+  // when the collapsed selection changes (caret movement), we should
+  // avoid sending text-selection-changed events.
+  if (HasSelection() || had_selection)
+    g_signal_emit_by_name(atk_object, "text-selection-changed");
+}
+
+void AXPlatformNodeAuraLinux::EmitCaretChangedSignal() {
+  if (!EmitsAtkTextEvents()) {
+    if (auto* parent = FromAtkObject(GetParent()))
+      parent->EmitCaretChangedSignal();
+    return;
+  }
+
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  DCHECK(ATK_IS_TEXT(atk_object));
+  g_signal_emit_by_name(atk_object, "text-caret-moved",
+                        UTF16ToUnicodeOffsetInText(selection.second));
+}
+
+void AXPlatformNodeAuraLinux::OnTextAttributesChanged() {
+  if (!EmitsAtkTextEvents()) {
+    if (auto* parent = FromAtkObject(GetParent()))
+      parent->OnTextAttributesChanged();
+    return;
+  }
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  DCHECK(ATK_IS_TEXT(atk_object));
+  g_signal_emit_by_name(atk_object, "text-attributes-changed");
+}
+
+void AXPlatformNodeAuraLinux::OnTextSelectionChanged() {
+  int32_t anchor_node_id, focus_node_id;
+  int anchor_offset, focus_offset;
+  GetFullSelection(&anchor_node_id, &anchor_offset, &focus_node_id,
+                   &focus_offset);
+
+  auto* anchor_node = static_cast<AXPlatformNodeAuraLinux*>(
+      GetDelegate()->GetFromNodeID(anchor_node_id));
+  auto* focus_node = static_cast<AXPlatformNodeAuraLinux*>(
+      GetDelegate()->GetFromNodeID(focus_node_id));
+  if (!anchor_node || !focus_node)
+    return;
+
+  AXPlatformNodeAuraLinux& editable_root = FindEditableRootOrDocument();
+  AXPlatformNodeAuraLinux* common_ancestor =
+      focus_node->FindCommonAncestor(anchor_node);
+  if (common_ancestor) {
+    common_ancestor->EmitSelectionChangedSignal(
+        editable_root.HadNonZeroWidthSelection());
+  }
+
+  // It's possible for the selection to change and for the caret to stay in
+  // place. This might happen if the selection is totally reset with a
+  // different anchor node, but the same focus node. We should avoid sending a
+  // caret changed signal in that case.
+  std::pair<int32_t, int> prev_caret = editable_root.GetCurrentCaret();
+  if (prev_caret.first != focus_node_id || prev_caret.second != focus_offset)
+    focus_node->EmitCaretChangedSignal();
+
+  editable_root.UpdateSelectionInformation(anchor_node_id, anchor_offset,
+                                           focus_node_id, focus_offset);
+}
+
+bool AXPlatformNodeAuraLinux::SupportsSelectionWithAtkSelection() {
+  return SupportsToggle(GetRole()) ||
+         GetRole() == ax::mojom::Role::kListBoxOption;
+}
+
+void AXPlatformNodeAuraLinux::OnDescriptionChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  std::string description;
+  GetStringAttribute(ax::mojom::StringAttribute::kDescription, &description);
+
+  AtkPropertyValues property_values;
+  property_values.property_name = "accessible-description";
+  property_values.new_value = G_VALUE_INIT;
+  g_value_init(&property_values.new_value, G_TYPE_STRING);
+  g_value_set_string(&property_values.new_value, description.c_str());
+  g_signal_emit_by_name(G_OBJECT(atk_object),
+                        "property-change::accessible-description",
+                        &property_values, nullptr);
+  g_value_unset(&property_values.new_value);
+}
+
+void AXPlatformNodeAuraLinux::OnSortDirectionChanged() {
+  AXPlatformNodeBase* table = GetTable();
+  if (!table)
+    return;
+
+  AtkObject* atk_table = table->GetNativeViewAccessible();
+  DCHECK(ATK_IS_TABLE(atk_table));
+
+  if (GetRole() == ax::mojom::Role::kColumnHeader)
+    g_signal_emit_by_name(atk_table, "row-reordered");
+  else if (GetRole() == ax::mojom::Role::kRowHeader)
+    g_signal_emit_by_name(atk_table, "column-reordered");
+}
+
+void AXPlatformNodeAuraLinux::OnValueChanged() {
+  // For the AtkText interface to work on non-web content nodes, we need to
+  // update the nodes' hypertext and trigger text change signals when the value
+  // changes. Otherwise, for web and PDF content, this is handled by
+  // "BrowserAccessibilityAuraLinux".
+  if (!GetDelegate()->IsWebContent())
+    UpdateHypertext();
+
+  if (!GetData().IsRangeValueSupported())
+    return;
+
+  float float_val;
+  if (!GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, &float_val))
+    return;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  AtkPropertyValues property_values;
+  property_values.property_name = "accessible-value";
+
+  property_values.new_value = G_VALUE_INIT;
+  g_value_init(&property_values.new_value, G_TYPE_DOUBLE);
+  g_value_set_double(&property_values.new_value,
+                     static_cast<double>(float_val));
+  g_signal_emit_by_name(G_OBJECT(atk_object),
+                        "property-change::accessible-value", &property_values,
+                        nullptr);
+}
+
+void AXPlatformNodeAuraLinux::OnNameChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object) {
+    return;
+  }
+  std::string previous_accessible_name = accessible_name_;
+  // Calling atk_object_get_name will update the value of accessible_name_.
+  if (!g_strcmp0(atk_object::GetName(atk_object),
+                 previous_accessible_name.c_str()))
+    return;
+
+  g_object_notify(G_OBJECT(atk_object), "accessible-name");
+}
+
+void AXPlatformNodeAuraLinux::OnDocumentTitleChanged() {
+  if (!g_active_top_level_frame)
+    return;
+
+  // We always want to notify on the top frame.
+  AXPlatformNodeAuraLinux* window = FromAtkObject(g_active_top_level_frame);
+  if (window)
+    window->OnNameChanged();
+}
+
+void AXPlatformNodeAuraLinux::OnSubtreeCreated() {
+  // We might not have a parent, in that case we don't need to send the event.
+  // We also don't want to notify if this is an ignored node
+  if (!GetParent() || GetData().IsIgnored())
+    return;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  auto index_in_parent = GetIndexInParent();
+  gint index_gint = index_in_parent.has_value()
+                        ? static_cast<gint>(index_in_parent.value())
+                        : -1;
+  g_signal_emit_by_name(GetParent(), "children-changed::add", index_gint,
+                        atk_object);
+}
+
+void AXPlatformNodeAuraLinux::OnSubtreeWillBeDeleted() {
+  // There is a chance there won't be a parent as we're in the deletion process.
+  // We also don't want to notify if this is an ignored node
+  if (!GetParent() || GetData().IsIgnored())
+    return;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  auto index_in_parent = GetIndexInParent();
+  gint index_gint = index_in_parent.has_value()
+                        ? static_cast<gint>(index_in_parent.value())
+                        : -1;
+  g_signal_emit_by_name(GetParent(), "children-changed::remove", index_gint,
+                        atk_object);
+}
+
+void AXPlatformNodeAuraLinux::OnParentChanged() {
+  if (!atk_object_)
+    return;
+
+  AtkPropertyValues property_values;
+  property_values.property_name = "accessible-parent";
+  property_values.new_value = G_VALUE_INIT;
+  g_value_init(&property_values.new_value, G_TYPE_OBJECT);
+  g_value_set_object(&property_values.new_value, GetParent());
+  g_signal_emit_by_name(G_OBJECT(atk_object_),
+                        "property-change::accessible-parent", &property_values,
+                        nullptr);
+  g_value_unset(&property_values.new_value);
+}
+
+void AXPlatformNodeAuraLinux::OnReadonlyChanged() {
+  AtkObject* obj = GetOrCreateAtkObject();
+  if (!obj)
+    return;
+
+#if defined(ATK_216)
+  // Runtime check in case we were compiled with a newer version of ATK.
+  if (!PlatformSupportsState(ATK_STATE_READ_ONLY))
+    return;
+
+  atk_object_notify_state_change(
+      obj, ATK_STATE_READ_ONLY,
+      GetData().GetRestriction() == ax::mojom::Restriction::kReadOnly);
+#endif
+}
+
+void AXPlatformNodeAuraLinux::OnInvalidStatusChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  atk_object_notify_state_change(
+      ATK_OBJECT(atk_object), ATK_STATE_INVALID_ENTRY,
+      GetData().GetInvalidState() != ax::mojom::InvalidState::kFalse);
+}
+
+void AXPlatformNodeAuraLinux::OnAriaCurrentChanged() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  ax::mojom::AriaCurrentState aria_current =
+      static_cast<ax::mojom::AriaCurrentState>(
+          GetIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState));
+  atk_object_notify_state_change(
+      ATK_OBJECT(atk_object), ATK_STATE_ACTIVE,
+      aria_current != ax::mojom::AriaCurrentState::kNone &&
+          aria_current != ax::mojom::AriaCurrentState::kFalse);
+}
+
+void AXPlatformNodeAuraLinux::OnAlertShown() {
+  DCHECK(ui::IsAlert(GetRole()));
+  atk_object_notify_state_change(ATK_OBJECT(GetOrCreateAtkObject()),
+                                 ATK_STATE_SHOWING, TRUE);
+}
+
+void AXPlatformNodeAuraLinux::RunPostponedEvents() {
+  if (window_activate_event_postponed_) {
+    OnWindowActivated();
+    window_activate_event_postponed_ = false;
+  }
+}
+
+void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(
+    ax::mojom::Event event_type) {
+  if (!GetOrCreateAtkObject())
+    return;
+  AXPlatformNodeBase::NotifyAccessibilityEvent(event_type);
+  switch (event_type) {
+    // kMenuStart/kMenuEnd: the menu system has started / stopped.
+    // kMenuPopupStart/kMenuPopupEnd: an individual menu/submenu has
+    // opened/closed.
+    case ax::mojom::Event::kMenuPopupStart:
+      OnMenuPopupStart();
+      break;
+    case ax::mojom::Event::kMenuPopupEnd:
+      OnMenuPopupEnd();
+      break;
+    case ax::mojom::Event::kCheckedStateChanged:
+      OnCheckedStateChanged();
+      break;
+    case ax::mojom::Event::kExpandedChanged:
+      OnExpandedStateChanged(HasState(ax::mojom::State::kExpanded));
+      break;
+    case ax::mojom::Event::kFocus:
+    case ax::mojom::Event::kFocusContext:
+      OnFocused();
+      break;
+    case ax::mojom::Event::kFocusAfterMenuClose:
+      // The saved focused object is not always getting cleared when a popup
+      // becomes active. As a result, when the popup is dismissed, OnFocused()
+      // will return early thinking focus has not changed. Rather than trying
+      // to catch every case, take kFocusAfterMenuClose as a clear indication
+      // that a focus change should be presented and reset the saved focus.
+      g_current_focused = nullptr;
+      OnFocused();
+      break;
+    case ax::mojom::Event::kSelection:
+      OnSelected();
+      // When changing tabs also fire a name changed event.
+      if (GetRole() == ax::mojom::Role::kTab)
+        OnDocumentTitleChanged();
+      break;
+    case ax::mojom::Event::kSelectedChildrenChanged:
+      OnSelectedChildrenChanged();
+      break;
+    case ax::mojom::Event::kStateChanged:
+      // We need to know what state changed and fire an event for that specific
+      // state. Because we don't know what state changed, we deliberately do
+      // nothing here.
+      break;
+    case ax::mojom::Event::kTextChanged:
+      OnNameChanged();
+      break;
+    case ax::mojom::Event::kTextSelectionChanged:
+      OnTextSelectionChanged();
+      break;
+    case ax::mojom::Event::kValueChanged:
+      OnValueChanged();
+      break;
+    case ax::mojom::Event::kWindowActivated:
+      if (AtkUtilAuraLinux::GetInstance()->IsAtSpiReady()) {
+        OnWindowActivated();
+      } else {
+        AtkUtilAuraLinux::GetInstance()->PostponeEventsFor(this);
+        window_activate_event_postponed_ = true;
+      }
+      break;
+    case ax::mojom::Event::kWindowDeactivated:
+      if (AtkUtilAuraLinux::GetInstance()->IsAtSpiReady()) {
+        OnWindowDeactivated();
+      } else {
+        AtkUtilAuraLinux::GetInstance()->CancelPostponedEventsFor(this);
+        window_activate_event_postponed_ = false;
+      }
+      break;
+    case ax::mojom::Event::kWindowVisibilityChanged:
+      OnWindowVisibilityChanged();
+      break;
+    case ax::mojom::Event::kLoadComplete:
+    case ax::mojom::Event::kDocumentTitleChanged:
+      // Sometimes, e.g. upon navigating away from the page, the tree is
+      // rebuilt rather than modified. The kDocumentTitleChanged event occurs
+      // prior to the rebuild and so is added on the previous root node. When
+      // the tree is rebuilt and the old node removed, the events on the old
+      // node are removed and no new kDocumentTitleChanged will be emitted. To
+      // ensure we still fire the event, though, we also pay attention to
+      // kLoadComplete.
+      OnDocumentTitleChanged();
+      break;
+    case ax::mojom::Event::kAlert:
+      OnAlertShown();
+      break;
+    default:
+      break;
+  }
+}
+
+absl::optional<std::pair<int, int>>
+AXPlatformNodeAuraLinux::GetEmbeddedObjectIndicesForId(int id) {
+  auto iterator = base::ranges::find(hypertext_.hyperlinks, id);
+  if (iterator == hypertext_.hyperlinks.end())
+    return absl::nullopt;
+  int hyperlink_index = std::distance(hypertext_.hyperlinks.begin(), iterator);
+
+  auto offset =
+      base::ranges::find(hypertext_.hyperlink_offset_to_index, hyperlink_index,
+                         &AXLegacyHypertext::OffsetToIndex::value_type::second);
+  if (offset == hypertext_.hyperlink_offset_to_index.end())
+    return absl::nullopt;
+
+  return std::make_pair(UTF16ToUnicodeOffsetInText(offset->first),
+                        UTF16ToUnicodeOffsetInText(offset->first + 1));
+}
+
+absl::optional<std::pair<int, int>>
+AXPlatformNodeAuraLinux::GetEmbeddedObjectIndices() {
+  auto* parent = FromAtkObject(GetParent());
+  if (!parent)
+    return absl::nullopt;
+  return parent->GetEmbeddedObjectIndicesForId(GetUniqueId());
+}
+
+void AXPlatformNodeAuraLinux::UpdateHypertext() {
+  EnsureAtkObjectIsValid();
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  AXLegacyHypertext old_hypertext = hypertext_;
+  base::OffsetAdjuster::Adjustments old_adjustments = GetHypertextAdjustments();
+
+  UpdateComputedHypertext();
+  text_unicode_adjustments_ = absl::nullopt;
+  offset_to_text_attributes_.clear();
+
+  if ((!HasState(ax::mojom::State::kEditable) ||
+       GetData().GetRestriction() == ax::mojom::Restriction::kReadOnly) &&
+      !IsInLiveRegion()) {
+    return;
+  }
+
+  if (!EmitsAtkTextEvents())
+    return;
+
+  size_t shared_prefix, old_len, new_len;
+  ComputeHypertextRemovedAndInserted(old_hypertext, &shared_prefix, &old_len,
+                                     &new_len);
+  if (old_len > 0) {
+    std::u16string removed_substring =
+        old_hypertext.hypertext.substr(shared_prefix, old_len);
+
+    size_t shared_unicode_prefix = shared_prefix;
+    base::OffsetAdjuster::AdjustOffset(old_adjustments, &shared_unicode_prefix);
+    size_t shared_unicode_suffix = shared_prefix + old_len;
+    base::OffsetAdjuster::AdjustOffset(old_adjustments, &shared_unicode_suffix);
+
+    g_signal_emit_by_name(
+        atk_object, "text-remove",
+        shared_unicode_prefix,                  // position of removal
+        shared_unicode_suffix - shared_prefix,  // length of removal
+        base::UTF16ToUTF8(removed_substring).c_str());
+  }
+
+  if (new_len > 0) {
+    std::u16string inserted_substring =
+        hypertext_.hypertext.substr(shared_prefix, new_len);
+    size_t shared_unicode_prefix = UTF16ToUnicodeOffsetInText(shared_prefix);
+    size_t shared_unicode_suffix =
+        UTF16ToUnicodeOffsetInText(shared_prefix + new_len);
+    g_signal_emit_by_name(
+        atk_object, "text-insert",
+        shared_unicode_prefix,                          // position of insertion
+        shared_unicode_suffix - shared_unicode_prefix,  // length of insertion
+        base::UTF16ToUTF8(inserted_substring).c_str());
+  }
+}
+
+const AXLegacyHypertext& AXPlatformNodeAuraLinux::GetAXHypertext() {
+  return hypertext_;
+}
+
+const base::OffsetAdjuster::Adjustments&
+AXPlatformNodeAuraLinux::GetHypertextAdjustments() {
+  if (text_unicode_adjustments_.has_value())
+    return *text_unicode_adjustments_;
+
+  text_unicode_adjustments_.emplace();
+
+  std::u16string text = GetHypertext();
+  size_t text_length = text.size();
+  for (size_t i = 0; i < text_length; i++) {
+    base_icu::UChar32 code_point;
+    size_t original_i = i;
+    base::ReadUnicodeCharacter(text.c_str(), text_length + 1, &i, &code_point);
+
+    if ((i - original_i + 1) != 1) {
+      text_unicode_adjustments_->push_back(
+          base::OffsetAdjuster::Adjustment(original_i, i - original_i + 1, 1));
+    }
+  }
+
+  return *text_unicode_adjustments_;
+}
+
+size_t AXPlatformNodeAuraLinux::UTF16ToUnicodeOffsetInText(
+    size_t utf16_offset) {
+  size_t unicode_offset = utf16_offset;
+  base::OffsetAdjuster::AdjustOffset(GetHypertextAdjustments(),
+                                     &unicode_offset);
+  return unicode_offset;
+}
+
+size_t AXPlatformNodeAuraLinux::UnicodeToUTF16OffsetInText(int unicode_offset) {
+  if (unicode_offset == kStringLengthOffset)
+    return GetHypertext().size();
+
+  size_t utf16_offset = unicode_offset;
+  base::OffsetAdjuster::UnadjustOffset(GetHypertextAdjustments(),
+                                       &utf16_offset);
+  return utf16_offset;
+}
+
+int AXPlatformNodeAuraLinux::GetTextOffsetAtPoint(int x,
+                                                  int y,
+                                                  AtkCoordType atk_coord_type) {
+  if (!GetExtentsRelativeToAtkCoordinateType(atk_coord_type).Contains(x, y))
+    return -1;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return -1;
+
+  int count = atk_text::GetCharacterCount(ATK_TEXT(atk_object));
+  for (int i = 0; i < count; i++) {
+    int out_x, out_y, out_width, out_height;
+    atk_text::GetCharacterExtents(ATK_TEXT(atk_object), i, &out_x, &out_y,
+                                  &out_width, &out_height, atk_coord_type);
+    gfx::Rect rect(out_x, out_y, out_width, out_height);
+    if (rect.Contains(x, y))
+      return i;
+  }
+  return -1;
+}
+
+gfx::Vector2d AXPlatformNodeAuraLinux::GetParentOriginInScreenCoordinates()
+    const {
+  AtkObject* parent = GetParent();
+  if (!parent)
+    return gfx::Vector2d();
+
+  const AXPlatformNode* parent_node =
+      AXPlatformNode::FromNativeViewAccessible(parent);
+  if (!parent)
+    return gfx::Vector2d();
+
+  return parent_node->GetDelegate()
+      ->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                      AXClippingBehavior::kUnclipped)
+      .OffsetFromOrigin();
+}
+
+gfx::Vector2d AXPlatformNodeAuraLinux::GetParentFrameOriginInScreenCoordinates()
+    const {
+  AtkObject* frame = FindAtkObjectParentFrame(atk_object_);
+  if (!frame)
+    return gfx::Vector2d();
+
+  const AXPlatformNode* frame_node =
+      AXPlatformNode::FromNativeViewAccessible(frame);
+  if (!frame_node)
+    return gfx::Vector2d();
+
+  return frame_node->GetDelegate()
+      ->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                      AXClippingBehavior::kUnclipped)
+      .OffsetFromOrigin();
+}
+
+gfx::Rect AXPlatformNodeAuraLinux::GetExtentsRelativeToAtkCoordinateType(
+    AtkCoordType coord_type) const {
+  gfx::Rect extents = delegate_->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                                               AXClippingBehavior::kUnclipped);
+  switch (coord_type) {
+    case ATK_XY_SCREEN:
+      break;
+    case ATK_XY_WINDOW: {
+      gfx::Vector2d window_origin = -GetParentFrameOriginInScreenCoordinates();
+      extents.Offset(window_origin);
+      break;
+    }
+#if defined(ATK_230)
+    case ATK_XY_PARENT: {
+      gfx::Vector2d parent_origin = -GetParentOriginInScreenCoordinates();
+      extents.Offset(parent_origin);
+      break;
+    }
+#endif
+  }
+
+  return extents;
+}
+
+void AXPlatformNodeAuraLinux::GetExtents(gint* x,
+                                         gint* y,
+                                         gint* width,
+                                         gint* height,
+                                         AtkCoordType coord_type) {
+  gfx::Rect extents = GetExtentsRelativeToAtkCoordinateType(coord_type);
+  if (x)
+    *x = extents.x();
+  if (y)
+    *y = extents.y();
+  if (width)
+    *width = extents.width();
+  if (height)
+    *height = extents.height();
+}
+
+void AXPlatformNodeAuraLinux::GetPosition(gint* x,
+                                          gint* y,
+                                          AtkCoordType coord_type) {
+  gfx::Rect extents = GetExtentsRelativeToAtkCoordinateType(coord_type);
+  if (x)
+    *x = extents.x();
+  if (y)
+    *y = extents.y();
+}
+
+void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) {
+  gfx::Rect rect_size = gfx::ToEnclosingRect(GetData().relative_bounds.bounds);
+  if (width)
+    *width = rect_size.width();
+  if (height)
+    *height = rect_size.height();
+}
+
+gfx::NativeViewAccessible
+AXPlatformNodeAuraLinux::HitTestSync(gint x, gint y, AtkCoordType coord_type) {
+  gfx::Point scroll_to(x, y);
+  scroll_to = ConvertPointToScreenCoordinates(scroll_to, coord_type);
+
+  AXPlatformNode* current_result = this;
+  while (true) {
+    gfx::NativeViewAccessible hit_child =
+        current_result->GetDelegate()->HitTestSync(scroll_to.x(),
+                                                   scroll_to.y());
+    if (!hit_child)
+      return nullptr;
+    AXPlatformNode* hit_child_node =
+        AXPlatformNode::FromNativeViewAccessible(hit_child);
+    if (!hit_child_node || !hit_child_node->IsDescendantOf(current_result))
+      break;
+
+    // If we get the same node, we're done.
+    if (hit_child_node == current_result)
+      break;
+
+    // Continue to check recursively. That's because HitTestSync may have
+    // returned the best result within a particular accessibility tree,
+    // but we might need to recurse further in a tree of a different type
+    // (for example, from Views to Web).
+    current_result = hit_child_node;
+  }
+  return current_result->GetNativeViewAccessible();
+}
+
+bool AXPlatformNodeAuraLinux::GrabFocus() {
+  AXActionData action_data;
+  action_data.action = ax::mojom::Action::kFocus;
+  return delegate_->AccessibilityPerformAction(action_data);
+}
+
+bool AXPlatformNodeAuraLinux::FocusFirstFocusableAncestorInWebContent() {
+  if (!GetDelegate()->IsWebContent())
+    return false;
+
+  // Don't cross document boundaries in order to avoid having this operation
+  // cross iframe boundaries or escape to non-document UI elements.
+  if (GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
+    return false;
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return false;
+
+  if (IsFocusable()) {
+    if (g_current_focused != atk_object)
+      GrabFocus();
+    return true;
+  }
+
+  auto* parent = FromAtkObject(GetParent());
+  if (!parent)
+    return false;
+
+  // If any of the siblings of this element are focusable, focusing the parent
+  // would be like moving the focus position backward, so we should fall back
+  // to setting the sequential focus navigation starting point.
+  for (auto child_iterator_ptr = parent->GetDelegate()->ChildrenBegin();
+       *child_iterator_ptr != *parent->GetDelegate()->ChildrenEnd();
+       ++(*child_iterator_ptr)) {
+    auto* child = FromAtkObject(child_iterator_ptr->GetNativeViewAccessible());
+    if (!child || child == this)
+      continue;
+
+    if (child->IsFocusable())
+      return false;
+  }
+
+  return parent->FocusFirstFocusableAncestorInWebContent();
+}
+
+bool AXPlatformNodeAuraLinux::SetSequentialFocusNavigationStartingPoint() {
+  AXActionData action_data;
+  action_data.action =
+      ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint;
+  return delegate_->AccessibilityPerformAction(action_data);
+}
+
+bool AXPlatformNodeAuraLinux::
+    GrabFocusOrSetSequentialFocusNavigationStartingPoint() {
+  // First we try to grab focus on this node if any ancestor in the same
+  // document is focusable. Otherwise we set the sequential navigation starting
+  // point.
+  if (!FocusFirstFocusableAncestorInWebContent())
+    return SetSequentialFocusNavigationStartingPoint();
+  else
+    return true;
+}
+
+bool AXPlatformNodeAuraLinux::
+    GrabFocusOrSetSequentialFocusNavigationStartingPointAtOffset(int offset) {
+  int child_count = delegate_->GetChildCount();
+  if (IsAtomicTextField() || child_count == 0)
+    return GrabFocusOrSetSequentialFocusNavigationStartingPoint();
+
+  // When this node has children, we walk through them to figure out what child
+  // node should get focus. We are essentially repeating the process used when
+  // building the hypertext here.
+  int current_offset = 0;
+  for (int i = 0; i < child_count; ++i) {
+    auto* child = FromAtkObject(delegate_->ChildAtIndex(i));
+    if (!child)
+      continue;
+
+    if (child->IsText()) {
+      current_offset += child->GetName().size();
+    } else {
+      // Add an offset for the embedded character.
+      current_offset += 1;
+    }
+
+    // If the offset is larger than our size, try to work with the last child,
+    // which is also the behavior of SetCaretOffset.
+    if (offset <= current_offset || i == child_count - 1)
+      return child->GrabFocusOrSetSequentialFocusNavigationStartingPoint();
+  }
+
+  NOTREACHED();
+  return false;
+}
+
+const gchar* AXPlatformNodeAuraLinux::GetDefaultActionName() {
+  int action;
+  if (!GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, &action))
+    return nullptr;
+
+  // If this object cannot receive focus and has a button role, use click as
+  // the default action. On the AuraLinux platform, the press action is a
+  // signal to users that they can trigger the action using the keyboard, while
+  // a click action means the user should trigger the action via a simulated
+  // click. If this object cannot receive focus, it's impossible to trigger it
+  // with a key press.
+  if (GetRole() == ax::mojom::Role::kButton &&
+      action == static_cast<int>(ax::mojom::DefaultActionVerb::kPress) &&
+      !IsFocusable()) {
+    action = static_cast<int>(ax::mojom::DefaultActionVerb::kClick);
+  }
+
+  std::string action_verb =
+      ui::ToString(static_cast<ax::mojom::DefaultActionVerb>(action));
+
+  ATK_AURALINUX_RETURN_STRING(action_verb);
+}
+
+AtkAttributeSet* AXPlatformNodeAuraLinux::GetAtkAttributes() {
+  AtkAttributeSet* attribute_list = nullptr;
+  ComputeAttributes(&attribute_list);
+  return attribute_list;
+}
+
+AtkStateType AXPlatformNodeAuraLinux::GetAtkStateTypeForCheckableNode() {
+  if (GetData().GetCheckedState() == ax::mojom::CheckedState::kMixed)
+    return ATK_STATE_INDETERMINATE;
+  if (IsPlatformCheckable())
+    return ATK_STATE_CHECKED;
+  return ATK_STATE_PRESSED;
+}
+
+// AtkDocumentHelpers
+
+const gchar* AXPlatformNodeAuraLinux::GetDocumentAttributeValue(
+    const gchar* attribute) const {
+  if (!g_ascii_strcasecmp(attribute, "DocType"))
+    return delegate_->GetTreeData().doctype.c_str();
+  else if (!g_ascii_strcasecmp(attribute, "MimeType"))
+    return delegate_->GetTreeData().mimetype.c_str();
+  else if (!g_ascii_strcasecmp(attribute, "Title"))
+    return delegate_->GetTreeData().title.c_str();
+  else if (!g_ascii_strcasecmp(attribute, "URI"))
+    return delegate_->GetTreeData().url.c_str();
+
+  return nullptr;
+}
+
+AtkAttributeSet* AXPlatformNodeAuraLinux::GetDocumentAttributes() const {
+  AtkAttributeSet* attribute_set = nullptr;
+  const gchar* doc_attributes[] = {"DocType", "MimeType", "Title", "URI"};
+  const gchar* value = nullptr;
+
+  for (unsigned i = 0; i < G_N_ELEMENTS(doc_attributes); i++) {
+    value = GetDocumentAttributeValue(doc_attributes[i]);
+    if (value) {
+      attribute_set = PrependAtkAttributeToAtkAttributeSet(
+          doc_attributes[i], value, attribute_set);
+    }
+  }
+
+  return attribute_set;
+}
+
+//
+// AtkHyperlink helpers
+//
+
+AtkHyperlink* AXPlatformNodeAuraLinux::GetAtkHyperlink() {
+  if (atk_hyperlink_)
+    return atk_hyperlink_;
+
+  atk_hyperlink_ =
+      ATK_HYPERLINK(g_object_new(AX_PLATFORM_ATK_HYPERLINK_TYPE, 0));
+  ax_platform_atk_hyperlink_set_object(
+      AX_PLATFORM_ATK_HYPERLINK(atk_hyperlink_), this);
+  return atk_hyperlink_;
+}
+
+//
+// Misc helpers
+//
+
+void AXPlatformNodeAuraLinux::GetFloatAttributeInGValue(
+    ax::mojom::FloatAttribute attr,
+    GValue* value) {
+  float float_val;
+  if (GetFloatAttribute(attr, &float_val)) {
+    memset(value, 0, sizeof(*value));
+    g_value_init(value, G_TYPE_FLOAT);
+    g_value_set_float(value, float_val);
+  }
+}
+
+void AXPlatformNodeAuraLinux::AddAttributeToList(const char* name,
+                                                 const char* value,
+                                                 AtkAttributeSet** attributes) {
+  *attributes = PrependAtkAttributeToAtkAttributeSet(name, value, *attributes);
+}
+
+void AXPlatformNodeAuraLinux::SetDocumentParent(
+    AtkObject* new_document_parent) {
+  DCHECK(GetAtkRole() == ATK_ROLE_FRAME);
+  SetWeakGPtrToAtkObject(&document_parent_, new_document_parent);
+}
+
+bool AXPlatformNodeAuraLinux::IsNameExposed() {
+  switch (GetRole()) {
+    case ax::mojom::Role::kListMarker:
+      return !GetChildCount();
+    default:
+      return true;
+  }
+}
+
+int AXPlatformNodeAuraLinux::GetCaretOffset() {
+  if (!HasVisibleCaretOrSelection()) {
+    absl::optional<FindInPageResultInfo> result =
+        GetSelectionOffsetsFromFindInPage();
+    AtkObject* atk_object = GetOrCreateAtkObject();
+    if (!atk_object)
+      return -1;
+    if (result.has_value() && result->node == atk_object)
+      return UTF16ToUnicodeOffsetInText(result->end_offset);
+    return -1;
+  }
+
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  return UTF16ToUnicodeOffsetInText(selection.second);
+}
+
+bool AXPlatformNodeAuraLinux::SetCaretOffset(int offset) {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return false;
+
+  int character_count = atk_text_get_character_count(ATK_TEXT(atk_object));
+  if (offset < 0 || offset > character_count)
+    offset = character_count;
+
+  // Even if we don't change anything, we still want to act like we
+  // were successful.
+  if (offset == GetCaretOffset() && !HasSelection())
+    return true;
+
+  offset = UnicodeToUTF16OffsetInText(offset);
+  if (!SetHypertextSelection(offset, offset))
+    return false;
+
+  return true;
+}
+
+bool AXPlatformNodeAuraLinux::SetTextSelectionForAtkText(int start_offset,
+                                                         int end_offset) {
+  start_offset = UnicodeToUTF16OffsetInText(start_offset);
+  end_offset = UnicodeToUTF16OffsetInText(end_offset);
+
+  std::u16string text = GetHypertext();
+  if (start_offset < 0 || start_offset > static_cast<int>(text.length()))
+    return false;
+  if (end_offset < 0 || end_offset > static_cast<int>(text.length()))
+    return false;
+
+  // We must put these in the correct order so that we can do
+  // a comparison with the existing start and end below.
+  if (end_offset < start_offset)
+    std::swap(start_offset, end_offset);
+
+  // Even if we don't change anything, we still want to act like we
+  // were successful.
+  std::pair<int, int> old_offsets = GetSelectionOffsetsForAtk();
+  if (old_offsets.first == start_offset && old_offsets.second == end_offset)
+    return true;
+
+  if (!SetHypertextSelection(start_offset, end_offset))
+    return false;
+
+  return true;
+}
+
+bool AXPlatformNodeAuraLinux::HasSelection() {
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  return selection.first >= 0 && selection.second >= 0 &&
+         selection.first != selection.second;
+}
+
+void AXPlatformNodeAuraLinux::GetSelectionExtents(int* start_offset,
+                                                  int* end_offset) {
+  if (start_offset)
+    *start_offset = 0;
+  if (end_offset)
+    *end_offset = 0;
+
+  std::pair<int, int> selection = GetSelectionOffsetsForAtk();
+  if (selection.first < 0 || selection.second < 0 ||
+      selection.first == selection.second)
+    return;
+
+  // We should ignore the direction of the selection when exposing start and
+  // end offsets. According to the ATK documentation the end offset is always
+  // the offset immediately past the end of the selection. This wouldn't make
+  // sense if end < start.
+  if (selection.second < selection.first)
+    std::swap(selection.first, selection.second);
+
+  selection.first = UTF16ToUnicodeOffsetInText(selection.first);
+  selection.second = UTF16ToUnicodeOffsetInText(selection.second);
+
+  if (start_offset)
+    *start_offset = selection.first;
+  if (end_offset)
+    *end_offset = selection.second;
+}
+
+// Since this method doesn't return a static gchar*, we expect the caller of
+// atk_text_get_selection to free the return value.
+gchar* AXPlatformNodeAuraLinux::GetSelectionWithText(int* start_offset,
+                                                     int* end_offset) {
+  int selection_start, selection_end;
+  GetSelectionExtents(&selection_start, &selection_end);
+
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return nullptr;
+
+  if (selection_start < 0 || selection_end < 0 ||
+      selection_start == selection_end) {
+    absl::optional<FindInPageResultInfo> find_in_page_result =
+        GetSelectionOffsetsFromFindInPage();
+    if (!find_in_page_result.has_value() ||
+        find_in_page_result->node != atk_object) {
+      *start_offset = 0;
+      *end_offset = 0;
+      return nullptr;
+    }
+
+    selection_start = find_in_page_result->start_offset;
+    selection_end = find_in_page_result->end_offset;
+  }
+
+  selection_start = UTF16ToUnicodeOffsetInText(selection_start);
+  selection_end = UTF16ToUnicodeOffsetInText(selection_end);
+  if (selection_start < 0 || selection_end < 0 ||
+      selection_start == selection_end) {
+    return nullptr;
+  }
+
+  if (start_offset)
+    *start_offset = selection_start;
+  if (end_offset)
+    *end_offset = selection_end;
+  return atk_text::GetText(ATK_TEXT(atk_object), selection_start,
+                           selection_end);
+}
+
+bool AXPlatformNodeAuraLinux::IsInLiveRegion() {
+  return HasStringAttribute(ax::mojom::StringAttribute::kContainerLiveStatus);
+}
+
+#if defined(ATK_230)
+void AXPlatformNodeAuraLinux::ScrollToPoint(AtkCoordType atk_coord_type,
+                                            int x,
+                                            int y) {
+  gfx::Point scroll_to(x, y);
+  scroll_to = ConvertPointToScreenCoordinates(scroll_to, atk_coord_type);
+
+  AXActionData action_data;
+  action_data.target_node_id = GetData().id;
+  action_data.action = ax::mojom::Action::kScrollToPoint;
+  action_data.target_point = scroll_to;
+  GetDelegate()->AccessibilityPerformAction(action_data);
+}
+
+void AXPlatformNodeAuraLinux::ScrollNodeRectIntoView(
+    gfx::Rect rect,
+    AtkScrollType atk_scroll_type) {
+  AXActionData action_data;
+  action_data.target_node_id = GetData().id;
+  action_data.action = ax::mojom::Action::kScrollToMakeVisible;
+  action_data.target_rect = rect;
+
+  action_data.scroll_behavior = ax::mojom::ScrollBehavior::kScrollIfVisible;
+  action_data.horizontal_scroll_alignment = ax::mojom::ScrollAlignment::kNone;
+  action_data.vertical_scroll_alignment = ax::mojom::ScrollAlignment::kNone;
+
+  switch (atk_scroll_type) {
+    case ATK_SCROLL_TOP_LEFT:
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentTop;
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentLeft;
+      break;
+    case ATK_SCROLL_BOTTOM_RIGHT:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentRight;
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentBottom;
+      break;
+    case ATK_SCROLL_TOP_EDGE:
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentTop;
+      break;
+    case ATK_SCROLL_BOTTOM_EDGE:
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentBottom;
+      break;
+    case ATK_SCROLL_LEFT_EDGE:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentLeft;
+      break;
+    case ATK_SCROLL_RIGHT_EDGE:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentRight;
+      break;
+    case ATK_SCROLL_ANYWHERE:
+      action_data.horizontal_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentClosestEdge;
+      action_data.vertical_scroll_alignment =
+          ax::mojom::ScrollAlignment::kScrollAlignmentClosestEdge;
+      break;
+  }
+
+  GetDelegate()->AccessibilityPerformAction(action_data);
+}
+
+void AXPlatformNodeAuraLinux::ScrollNodeIntoView(
+    AtkScrollType atk_scroll_type) {
+  gfx::Rect rect = GetDelegate()->GetBoundsRect(AXCoordinateSystem::kScreenDIPs,
+                                                AXClippingBehavior::kUnclipped);
+  rect -= rect.OffsetFromOrigin();
+  ScrollNodeRectIntoView(rect, atk_scroll_type);
+}
+#endif  // defined(ATK_230)
+
+#if defined(ATK_232)
+absl::optional<gfx::Rect>
+AXPlatformNodeAuraLinux::GetUnclippedHypertextRangeBoundsRect(int start_offset,
+                                                              int end_offset) {
+  start_offset = UnicodeToUTF16OffsetInText(start_offset);
+  end_offset = UnicodeToUTF16OffsetInText(end_offset);
+
+  std::u16string text = GetHypertext();
+  if (start_offset < 0 || start_offset > static_cast<int>(text.length()))
+    return absl::nullopt;
+  if (end_offset < 0 || end_offset > static_cast<int>(text.length()))
+    return absl::nullopt;
+
+  if (end_offset < start_offset)
+    std::swap(start_offset, end_offset);
+
+  return GetDelegate()->GetHypertextRangeBoundsRect(
+      UnicodeToUTF16OffsetInText(start_offset),
+      UnicodeToUTF16OffsetInText(end_offset), AXCoordinateSystem::kScreenDIPs,
+      AXClippingBehavior::kUnclipped);
+}
+
+bool AXPlatformNodeAuraLinux::ScrollSubstringIntoView(
+    AtkScrollType atk_scroll_type,
+    int start_offset,
+    int end_offset) {
+  absl::optional<gfx::Rect> optional_rect =
+      GetUnclippedHypertextRangeBoundsRect(start_offset, end_offset);
+  if (!optional_rect.has_value())
+    return false;
+
+  gfx::Rect rect = *optional_rect;
+  gfx::Rect node_rect = GetDelegate()->GetBoundsRect(
+      AXCoordinateSystem::kScreenDIPs, AXClippingBehavior::kUnclipped);
+  rect -= node_rect.OffsetFromOrigin();
+  ScrollNodeRectIntoView(rect, atk_scroll_type);
+
+  return true;
+}
+
+bool AXPlatformNodeAuraLinux::ScrollSubstringToPoint(
+    int start_offset,
+    int end_offset,
+    AtkCoordType atk_coord_type,
+    int x,
+    int y) {
+  absl::optional<gfx::Rect> optional_rect =
+      GetUnclippedHypertextRangeBoundsRect(start_offset, end_offset);
+  if (!optional_rect.has_value())
+    return false;
+
+  gfx::Rect rect = *optional_rect;
+  gfx::Rect node_rect = GetDelegate()->GetBoundsRect(
+      AXCoordinateSystem::kScreenDIPs, AXClippingBehavior::kUnclipped);
+  ScrollToPoint(atk_coord_type, x - (rect.x() - node_rect.x()),
+                y - (rect.y() - node_rect.y()));
+
+  return true;
+}
+#endif  // defined(ATK_232)
+
+void AXPlatformNodeAuraLinux::ComputeStylesIfNeeded() {
+  if (!offset_to_text_attributes_.empty())
+    return;
+
+  default_text_attributes_ = ComputeTextAttributes();
+  TextAttributeMap attributes_map =
+      GetDelegate()->ComputeTextAttributeMap(default_text_attributes_);
+  offset_to_text_attributes_.swap(attributes_map);
+}
+
+int AXPlatformNodeAuraLinux::FindStartOfStyle(
+    int start_offset,
+    ax::mojom::MoveDirection direction) {
+  int text_length = GetHypertext().length();
+  DCHECK_GE(start_offset, 0);
+  DCHECK_LE(start_offset, text_length);
+  DCHECK(!offset_to_text_attributes_.empty());
+
+  switch (direction) {
+    case ax::mojom::MoveDirection::kNone:
+      NOTREACHED();
+      return start_offset;
+    case ax::mojom::MoveDirection::kBackward: {
+      auto iterator = offset_to_text_attributes_.upper_bound(start_offset);
+      --iterator;
+      return iterator->first;
+    }
+    case ax::mojom::MoveDirection::kForward: {
+      const auto iterator =
+          offset_to_text_attributes_.upper_bound(start_offset);
+      if (iterator == offset_to_text_attributes_.end())
+        return text_length;
+      return iterator->first;
+    }
+  }
+
+  NOTREACHED();
+  return start_offset;
+}
+
+const TextAttributeList& AXPlatformNodeAuraLinux::GetTextAttributes(
+    int offset,
+    int* start_offset,
+    int* end_offset) {
+  ComputeStylesIfNeeded();
+  DCHECK(!offset_to_text_attributes_.empty());
+
+  int utf16_offset = UnicodeToUTF16OffsetInText(offset);
+  int style_start =
+      FindStartOfStyle(utf16_offset, ax::mojom::MoveDirection::kBackward);
+  int style_end =
+      FindStartOfStyle(utf16_offset, ax::mojom::MoveDirection::kForward);
+
+  auto iterator = offset_to_text_attributes_.find(style_start);
+  DCHECK(iterator != offset_to_text_attributes_.end());
+
+  SetIntPointerValueIfNotNull(start_offset,
+                              UTF16ToUnicodeOffsetInText(style_start));
+  SetIntPointerValueIfNotNull(end_offset,
+                              UTF16ToUnicodeOffsetInText(style_end));
+
+  if (iterator == offset_to_text_attributes_.end())
+    return default_text_attributes_;
+
+  return iterator->second;
+}
+
+const TextAttributeList& AXPlatformNodeAuraLinux::GetDefaultTextAttributes() {
+  ComputeStylesIfNeeded();
+  return default_text_attributes_;
+}
+
+void AXPlatformNodeAuraLinux::TerminateFindInPage() {
+  ForgetCurrentFindInPageResult();
+}
+
+void AXPlatformNodeAuraLinux::ActivateFindInPageResult(int start_offset,
+                                                       int end_offset) {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  DCHECK(ATK_IS_TEXT(atk_object));
+
+  if (!EmitsAtkTextEvents()) {
+    ActivateFindInPageInParent(start_offset, end_offset);
+    return;
+  }
+
+  AtkObject* parent_doc = FindAtkObjectToplevelParentDocument(atk_object);
+  if (!parent_doc)
+    return;
+
+  std::map<AtkObject*, FindInPageResultInfo>& active_results =
+      GetActiveFindInPageResults();
+  auto iterator = active_results.find(parent_doc);
+  FindInPageResultInfo new_info = {atk_object, start_offset, end_offset};
+  if (iterator != active_results.end() && iterator->second == new_info)
+    return;
+
+  active_results[parent_doc] = new_info;
+  g_signal_emit_by_name(atk_object, "text-selection-changed");
+  g_signal_emit_by_name(atk_object, "text-caret-moved",
+                        UTF16ToUnicodeOffsetInText(end_offset));
+}
+
+absl::optional<std::pair<int, int>>
+AXPlatformNodeAuraLinux::GetHypertextExtentsOfChild(
+    AXPlatformNodeAuraLinux* child_to_find) {
+  int current_offset = 0;
+  for (auto child_iterator_ptr = GetDelegate()->ChildrenBegin();
+       *child_iterator_ptr != *GetDelegate()->ChildrenEnd();
+       ++(*child_iterator_ptr)) {
+    auto* child = FromAtkObject(child_iterator_ptr->GetNativeViewAccessible());
+    if (!child)
+      continue;
+
+    // If this object is a text only object, it is included directly into this
+    // node's hypertext, otherwise it is represented as an embedded object
+    // character.
+    int size = child->IsText() ? child->GetName().size() : 1;
+    if (child == child_to_find)
+      return std::make_pair(current_offset, current_offset + size);
+    current_offset += size;
+  }
+
+  return absl::nullopt;
+}
+
+void AXPlatformNodeAuraLinux::ActivateFindInPageInParent(int start_offset,
+                                                         int end_offset) {
+  auto* parent = FromAtkObject(GetParent());
+  if (!parent)
+    return;
+
+  absl::optional<std::pair<int, int>> extents_in_parent =
+      parent->GetHypertextExtentsOfChild(this);
+  if (!extents_in_parent.has_value())
+    return;
+
+  DCHECK(IsText());
+  parent->ActivateFindInPageResult(extents_in_parent->first + start_offset,
+                                   extents_in_parent->first + end_offset);
+}
+
+void AXPlatformNodeAuraLinux::ForgetCurrentFindInPageResult() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return;
+
+  AtkObject* parent_doc = FindAtkObjectToplevelParentDocument(atk_object);
+  if (parent_doc)
+    GetActiveFindInPageResults().erase(parent_doc);
+}
+
+absl::optional<FindInPageResultInfo>
+AXPlatformNodeAuraLinux::GetSelectionOffsetsFromFindInPage() {
+  AtkObject* atk_object = GetOrCreateAtkObject();
+  if (!atk_object)
+    return absl::nullopt;
+
+  AtkObject* parent_doc = FindAtkObjectToplevelParentDocument(atk_object);
+  if (!parent_doc)
+    return absl::nullopt;
+
+  std::map<AtkObject*, FindInPageResultInfo>& active_results =
+      GetActiveFindInPageResults();
+  auto iterator = active_results.find(parent_doc);
+  if (iterator == active_results.end())
+    return absl::nullopt;
+
+  return iterator->second;
+}
+
+gfx::Point AXPlatformNodeAuraLinux::ConvertPointToScreenCoordinates(
+    const gfx::Point& point,
+    AtkCoordType atk_coord_type) {
+  switch (atk_coord_type) {
+    case ATK_XY_WINDOW:
+      return point + GetParentFrameOriginInScreenCoordinates();
+#if defined(ATK_230)
+    case ATK_XY_PARENT:
+      return point + GetParentOriginInScreenCoordinates();
+#endif
+    case ATK_XY_SCREEN:
+    default:
+      return point;
+  }
+}
+
+std::pair<int, int> AXPlatformNodeAuraLinux::GetSelectionOffsetsForAtk() {
+  // In web content we always want to look at the selection from the tree
+  // instead of the selection that might be set via node attributes. This is
+  // because the tree selection is the absolute truth about what is visually
+  // selected, whereas node attributes might contain selection extents that are
+  // no longer part of the visual selection.
+  std::pair<int, int> selection;
+  if (GetDelegate()->IsWebContent()) {
+    AXSelection unignored_selection = GetDelegate()->GetUnignoredSelection();
+    GetSelectionOffsetsFromTree(&unignored_selection, &selection.first,
+                                &selection.second);
+  } else {
+    GetSelectionOffsets(&selection.first, &selection.second);
+  }
+  return selection;
+}
+
+}  // namespace ui
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-host-pkg-config.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/src/build/config/linux/pkg_config.gni
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/src/build/config/linux/pkg_config.gni	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/src/build/config/linux/pkg_config.gni	(revision 192)
@@ -0,0 +1,129 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/sysroot.gni")
+
+# Defines a config specifying the result of running pkg-config for the given
+# packages. Put the package names you want to query in the "packages" variable
+# inside the template invocation.
+#
+# You can also add defines via the "defines" variable. This can be useful to
+# add this to the config to pass defines that the library expects to get by
+# users of its headers.
+#
+# Example:
+#   pkg_config("mything") {
+#     packages = [ "mything1", "mything2" ]
+#     defines = [ "ENABLE_AWESOME" ]
+#   }
+#
+# You can also use "extra args" to filter out results (see pkg-config.py):
+#   extra_args = [ "-v, "foo" ]
+# To ignore libs and ldflags (only cflags/defines will be set, which is useful
+# when doing manual dynamic linking), set:
+#   ignore_libs = true
+
+declare_args() {
+  # A pkg-config wrapper to call instead of trying to find and call the right
+  # pkg-config directly. Wrappers like this are common in cross-compilation
+  # environments.
+  # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on
+  # the sysroot mechanism to find the right .pc files.
+  pkg_config = ""
+
+  # A optional pkg-config wrapper to use for tools built on the host.
+  host_pkg_config = ""
+
+  # CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig
+  # and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfig
+  # depending on whether the systemroot is for a 32 or 64 bit architecture.
+  #
+  # When build under GYP, CrOS board builds specify the 'system_libdir' variable
+  # as part of the GYP_DEFINES provided by the CrOS emerge build or simple
+  # chrome build scheme. This variable permits controlling this for GN builds
+  # in similar fashion by setting the `system_libdir` variable in the build's
+  # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
+  system_libdir = "lib"
+}
+
+pkg_config_script = "//build/config/linux/pkg-config.py"
+
+# Define the args we pass to the pkg-config script for other build files that
+# need to invoke it manually.
+pkg_config_args = []
+
+common_pkg_config_args = []
+if (sysroot != "") {
+  # Pass the sysroot if we're using one (it requires the CPU arch also).
+  common_pkg_config_args += [
+    "-s",
+    rebase_path(sysroot),
+    "-a",
+    current_cpu,
+  ]
+}
+
+if (pkg_config != "") {
+  pkg_config_args += [
+    "-p",
+    pkg_config,
+  ]
+}
+
+# Only use the custom libdir when building with the target sysroot.
+if (target_sysroot != "" && sysroot == target_sysroot) {
+  pkg_config_args += [
+    "--system_libdir",
+    system_libdir,
+  ]
+}
+
+if (host_pkg_config != "") {
+  host_pkg_config_args = [
+    "-p",
+    host_pkg_config,
+  ]
+} else {
+  host_pkg_config_args = pkg_config_args
+}
+
+template("pkg_config") {
+  assert(defined(invoker.packages),
+         "Variable |packages| must be defined to be a list in pkg_config.")
+  config(target_name) {
+    if (host_toolchain == current_toolchain || current_cpu == "x64") {
+      args = common_pkg_config_args + host_pkg_config_args + invoker.packages
+    } else {
+      args = common_pkg_config_args + pkg_config_args + invoker.packages
+    }
+    if (defined(invoker.extra_args)) {
+      args += invoker.extra_args
+    }
+
+    pkgresult = exec_script(pkg_config_script, args, "json")
+    cflags = pkgresult[1]
+
+    foreach(include, pkgresult[0]) {
+      if (use_sysroot) {
+        # We want the system include paths to use -isystem instead of -I to
+        # suppress warnings in those headers.
+        include_relativized = rebase_path(include, root_build_dir)
+        cflags += [ "-isystem$include_relativized" ]
+      } else {
+        cflags += [ "-I$include" ]
+      }
+    }
+
+    if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) {
+      libs = pkgresult[2]
+      lib_dirs = pkgresult[3]
+    }
+
+    forward_variables_from(invoker,
+                           [
+                             "defines",
+                             "visibility",
+                           ])
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/src-orig/build/config/linux/pkg_config.gni
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/src-orig/build/config/linux/pkg_config.gni	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-host-pkg-config-patch/src-orig/build/config/linux/pkg_config.gni	(revision 192)
@@ -0,0 +1,129 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/sysroot.gni")
+
+# Defines a config specifying the result of running pkg-config for the given
+# packages. Put the package names you want to query in the "packages" variable
+# inside the template invocation.
+#
+# You can also add defines via the "defines" variable. This can be useful to
+# add this to the config to pass defines that the library expects to get by
+# users of its headers.
+#
+# Example:
+#   pkg_config("mything") {
+#     packages = [ "mything1", "mything2" ]
+#     defines = [ "ENABLE_AWESOME" ]
+#   }
+#
+# You can also use "extra args" to filter out results (see pkg-config.py):
+#   extra_args = [ "-v, "foo" ]
+# To ignore libs and ldflags (only cflags/defines will be set, which is useful
+# when doing manual dynamic linking), set:
+#   ignore_libs = true
+
+declare_args() {
+  # A pkg-config wrapper to call instead of trying to find and call the right
+  # pkg-config directly. Wrappers like this are common in cross-compilation
+  # environments.
+  # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on
+  # the sysroot mechanism to find the right .pc files.
+  pkg_config = ""
+
+  # A optional pkg-config wrapper to use for tools built on the host.
+  host_pkg_config = ""
+
+  # CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig
+  # and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfig
+  # depending on whether the systemroot is for a 32 or 64 bit architecture.
+  #
+  # When build under GYP, CrOS board builds specify the 'system_libdir' variable
+  # as part of the GYP_DEFINES provided by the CrOS emerge build or simple
+  # chrome build scheme. This variable permits controlling this for GN builds
+  # in similar fashion by setting the `system_libdir` variable in the build's
+  # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
+  system_libdir = "lib"
+}
+
+pkg_config_script = "//build/config/linux/pkg-config.py"
+
+# Define the args we pass to the pkg-config script for other build files that
+# need to invoke it manually.
+pkg_config_args = []
+
+common_pkg_config_args = []
+if (sysroot != "") {
+  # Pass the sysroot if we're using one (it requires the CPU arch also).
+  common_pkg_config_args += [
+    "-s",
+    rebase_path(sysroot),
+    "-a",
+    current_cpu,
+  ]
+}
+
+if (pkg_config != "") {
+  pkg_config_args += [
+    "-p",
+    pkg_config,
+  ]
+}
+
+# Only use the custom libdir when building with the target sysroot.
+if (target_sysroot != "" && sysroot == target_sysroot) {
+  pkg_config_args += [
+    "--system_libdir",
+    system_libdir,
+  ]
+}
+
+if (host_pkg_config != "") {
+  host_pkg_config_args = [
+    "-p",
+    host_pkg_config,
+  ]
+} else {
+  host_pkg_config_args = pkg_config_args
+}
+
+template("pkg_config") {
+  assert(defined(invoker.packages),
+         "Variable |packages| must be defined to be a list in pkg_config.")
+  config(target_name) {
+    if (host_toolchain == current_toolchain) {
+      args = common_pkg_config_args + host_pkg_config_args + invoker.packages
+    } else {
+      args = common_pkg_config_args + pkg_config_args + invoker.packages
+    }
+    if (defined(invoker.extra_args)) {
+      args += invoker.extra_args
+    }
+
+    pkgresult = exec_script(pkg_config_script, args, "json")
+    cflags = pkgresult[1]
+
+    foreach(include, pkgresult[0]) {
+      if (use_sysroot) {
+        # We want the system include paths to use -isystem instead of -I to
+        # suppress warnings in those headers.
+        include_relativized = rebase_path(include, root_build_dir)
+        cflags += [ "-isystem$include_relativized" ]
+      } else {
+        cflags += [ "-I$include" ]
+      }
+    }
+
+    if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) {
+      libs = pkgresult[2]
+      lib_dirs = pkgresult[3]
+    }
+
+    forward_variables_from(invoker,
+                           [
+                             "defines",
+                             "visibility",
+                           ])
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-inc-drop-host-crash.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/src/ui/views/animation/ink_drop_host.h
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/src/ui/views/animation/ink_drop_host.h	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/src/ui/views/animation/ink_drop_host.h	(revision 192)
@@ -0,0 +1,302 @@
+// Copyright 2016 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_ANIMATION_INK_DROP_HOST_H_
+#define UI_VIEWS_ANIMATION_INK_DROP_HOST_H_
+
+#include <memory>
+
+#include "base/memory/raw_ptr.h"
+#include "third_party/abseil-cpp/absl/types/variant.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/color/color_id.h"
+#include "ui/color/color_provider.h"
+#include "ui/gfx/color_palette.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/views/animation/ink_drop_event_handler.h"
+#include "ui/views/metadata/view_factory.h"
+#include "ui/views/view.h"
+
+namespace ui {
+class Layer;
+class LocatedEvent;
+}  // namespace ui
+
+namespace views {
+
+class InkDrop;
+class InkDropHighlight;
+class InkDropImpl;
+class InkDropMask;
+class InkDropRipple;
+enum class InkDropState;
+
+namespace test {
+class InkDropHostTestApi;
+}  // namespace test
+
+// TODO(crbug.com/931964): Rename this type and move this header. Also consider
+// if InkDropHost should be what implements the InkDrop interface and have that
+// be the public interface.
+// The current division of labor is roughly as follows:
+// * InkDropHost manages an InkDrop and is responsible for a lot of its
+//   configuration and creating the parts of the InkDrop.
+// * InkDrop manages the parts of the ink-drop effect once it's up and running.
+// * InkDropRipple is a ripple effect that usually triggers as a result of
+//   clicking or activating the button / similar which hosts this.
+// * InkDropHighlight manages the hover/focus highlight layer.
+// TODO(pbos): See if this can be the only externally visible surface for an
+// ink-drop effect, and rename this InkDrop, or consolidate with InkDrop.
+class VIEWS_EXPORT InkDropHost {
+ public:
+  // Used in SetMode() to specify whether the ink drop effect is enabled
+  // or not for the view. In case of having an ink drop, it also specifies
+  // whether the default event handler for the ink drop should be installed or
+  // the subclass will handle ink drop events itself.
+  enum class InkDropMode {
+    OFF,
+    ON,
+    ON_NO_GESTURE_HANDLER,
+    ON_NO_ANIMATE,
+  };
+
+  explicit InkDropHost(View* host);
+  InkDropHost(const InkDropHost&) = delete;
+  InkDropHost& operator=(const InkDropHost&) = delete;
+  virtual ~InkDropHost();
+
+  // Returns a configured InkDrop. To override default behavior call
+  // SetCreateInkDropCallback().
+  std::unique_ptr<InkDrop> CreateInkDrop();
+
+  // Replace CreateInkDrop() behavior.
+  void SetCreateInkDropCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDrop>()> callback);
+
+  // Creates and returns the visual effect used for press. Used by InkDropImpl
+  // instances.
+  std::unique_ptr<InkDropRipple> CreateInkDropRipple() const;
+
+  // Replaces CreateInkDropRipple() behavior.
+  void SetCreateRippleCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDropRipple>()> callback);
+
+  // Returns the point of the |last_ripple_triggering_event_| if it was a
+  // LocatedEvent, otherwise the center point of the local bounds is returned.
+  // This is nominally used by the InkDropRipple.
+  gfx::Point GetInkDropCenterBasedOnLastEvent() const;
+
+  // Creates and returns the visual effect used for hover and focus. Used by
+  // InkDropImpl instances. To override behavior call
+  // SetCreateHighlightCallback().
+  std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const;
+
+  // Replaces CreateInkDropHighlight() behavior.
+  void SetCreateHighlightCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDropHighlight>()> callback);
+
+  // Callback replacement of CreateInkDropMask().
+  // TODO(pbos): Investigate removing this. It currently is only used by
+  // PieMenuView.
+  void SetCreateMaskCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDropMask>()> callback);
+
+  // Toggles ink drop attention state on/off. If set on, a pulsing highlight
+  // is shown, prompting users to interact with `host_view_`.
+  // Called by components that want to call into user's attention, e.g. IPH.
+  void ToggleAttentionState(bool attention_on);
+
+  // Returns the base color for the ink drop.
+  SkColor GetBaseColor() const;
+
+  // Sets the base color of the ink drop. If `SetBaseColor` is called, the
+  // effect of previous calls to `SetBaseColorId` and `SetBaseColorCallback` is
+  // overwritten and vice versa.
+  // TODO(crbug.com/1341361): Replace SetBaseColor with SetBaseColorId.
+  void SetBaseColor(SkColor color);
+  void SetBaseColorId(ui::ColorId color_id);
+  // Callback version of `GetBaseColor`. If possible, prefer using
+  // `SetBaseColor` or `SetBaseColorId`.
+  void SetBaseColorCallback(base::RepeatingCallback<SkColor()> callback);
+
+  // Toggle to enable/disable an InkDrop on this View.  Descendants can override
+  // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel
+  // of the InkDrop.
+  //
+  // TODO(bruthig): Add an easier mechanism than overriding functions to allow
+  // subclasses/clients to specify the flavor of ink drop.
+  void SetMode(InkDropMode ink_drop_mode);
+  InkDropMode GetMode() const;
+
+  // Set whether the ink drop layers should be placed into the region above or
+  // below the view layer. The default is kBelow;
+  void SetLayerRegion(LayerRegion region);
+  LayerRegion GetLayerRegion() const;
+
+  void SetVisibleOpacity(float visible_opacity);
+  float GetVisibleOpacity() const;
+
+  void SetHighlightOpacity(absl::optional<float> opacity);
+
+  void SetSmallCornerRadius(int small_radius);
+  int GetSmallCornerRadius() const;
+
+  void SetLargeCornerRadius(int large_radius);
+  int GetLargeCornerRadius() const;
+
+  // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the
+  // last_ripple_triggering_event().
+  //
+  // *** NOTE ***: |event| has been plumbed through on a best effort basis for
+  // the purposes of centering ink drop ripples on located Events.  Thus nullptr
+  // has been used by clients who do not have an Event instance available to
+  // them.
+  void AnimateToState(InkDropState state, const ui::LocatedEvent* event);
+
+  // Returns true if an ink drop instance has been created.
+  bool HasInkDrop() const;
+
+  // Provides public access to |ink_drop_| so that factory methods can configure
+  // the inkdrop. Implements lazy initialization of |ink_drop_| so as to avoid
+  // virtual method calls during construction since subclasses should be able to
+  // call SetMode() during construction.
+  InkDrop* GetInkDrop();
+
+  // Returns whether the ink drop should be considered "highlighted" (in or
+  // animating into "highlight visible" steady state).
+  bool GetHighlighted() const;
+
+  base::CallbackListSubscription AddHighlightedChangedCallback(
+      base::RepeatingClosure callback);
+
+  // Should be called by InkDrop implementations when their highlight state
+  // changes, to trigger the corresponding property change notification here.
+  void OnInkDropHighlightedChanged();
+
+  // Methods called by InkDrop for attaching its layer.
+  // TODO(pbos): Investigate using direct calls on View::AddLayerToRegion.
+  void AddInkDropLayer(ui::Layer* ink_drop_layer);
+  void RemoveInkDropLayer(ui::Layer* ink_drop_layer);
+
+  // Size used by default for the SquareInkDropRipple.
+  static constexpr gfx::Size kDefaultSquareInkDropSize = gfx::Size(24, 24);
+
+  // Returns a large scaled size used by SquareInkDropRipple and Highlight.
+  static gfx::Size GetLargeSize(gfx::Size small_size);
+
+  // Creates a SquareInkDropRipple centered on |center_point|.
+  std::unique_ptr<InkDropRipple> CreateSquareRipple(
+      const gfx::Point& center_point,
+      const gfx::Size& size = kDefaultSquareInkDropSize) const;
+
+  View* host_view() { return host_view_; }
+  const View* host_view() const { return host_view_; }
+
+ private:
+  friend class test::InkDropHostTestApi;
+
+  class ViewLayerTransformObserver : public ViewObserver {
+   public:
+    ViewLayerTransformObserver(InkDropHost* ink_drop_host, View* host);
+    ~ViewLayerTransformObserver() override;
+
+    void OnViewLayerTransformed(View* observed_view) override;
+
+   private:
+    base::ScopedObservation<View, ViewObserver> observation_{this};
+    const raw_ptr<InkDropHost> ink_drop_host_;
+  };
+
+  class InkDropHostEventHandlerDelegate : public InkDropEventHandler::Delegate {
+   public:
+    explicit InkDropHostEventHandlerDelegate(InkDropHost* host);
+
+    // InkDropEventHandler::Delegate:
+    InkDrop* GetInkDrop() override;
+    bool HasInkDrop() const override;
+
+    bool SupportsGestureEvents() const override;
+
+   private:
+    // The host.
+    const raw_ptr<InkDropHost> ink_drop_host_;
+  };
+
+  const InkDropEventHandler* GetEventHandler() const;
+  InkDropEventHandler* GetEventHandler();
+
+  // This generates a mask for the InkDrop.
+  std::unique_ptr<views::InkDropMask> CreateInkDropMask() const;
+
+  // Adds a clip rect on the root layer of the ink drop impl. This is a more
+  // performant alternative to using circles or rectangle mask layers. Returns
+  // true if a clip was added.
+  bool AddInkDropClip(ui::Layer* ink_drop_layer);
+
+  // Initializes and sets a mask on `ink_drop_layer`. This will not run if
+  // AddInkDropClip() succeeds in the default implementation of
+  // AddInkDropLayer().
+  void InstallInkDropMask(ui::Layer* ink_drop_layer);
+
+  const raw_ptr<View> host_view_;
+
+  // Defines what type of |ink_drop_| to create.
+  InkDropMode ink_drop_mode_ = views::InkDropHost::InkDropMode::OFF;
+
+  // Into which region should the ink drop layers be placed.
+  LayerRegion layer_region_ = LayerRegion::kBelow;
+
+  // Used to observe View and inform the InkDrop of host-transform changes.
+  ViewLayerTransformObserver host_view_transform_observer_;
+
+  // Declared before |ink_drop_|, because InkDropImpl may call
+  // RemoveInkDropLayer on partly destructed InkDropHost. In
+  // that case |ink_drop_mask_| must be still valid.
+  std::unique_ptr<views::InkDropMask> ink_drop_mask_;
+
+  // Should not be accessed directly. Use GetInkDrop() instead.
+  std::unique_ptr<InkDrop> ink_drop_;
+
+  // Intentionally declared after |ink_drop_| so that it doesn't access a
+  // destroyed |ink_drop_| during destruction.
+  InkDropHostEventHandlerDelegate ink_drop_event_handler_delegate_;
+  InkDropEventHandler ink_drop_event_handler_;
+
+  float ink_drop_visible_opacity_ = 0.175f;
+
+  // The color of the ripple and hover.
+  absl::variant<SkColor, ui::ColorId, base::RepeatingCallback<SkColor()>>
+      ink_drop_base_color_ = gfx::kPlaceholderColor;
+
+  // TODO(pbos): Audit call sites to make sure highlight opacity is either
+  // always set or using the default value. Then make this a non-optional float.
+  absl::optional<float> ink_drop_highlight_opacity_;
+
+  // Radii used for the SquareInkDropRipple.
+  int ink_drop_small_corner_radius_ = 2;
+  int ink_drop_large_corner_radius_ = 4;
+
+  base::RepeatingCallback<std::unique_ptr<InkDrop>()> create_ink_drop_callback_;
+  base::RepeatingCallback<std::unique_ptr<InkDropRipple>()>
+      create_ink_drop_ripple_callback_;
+  base::RepeatingCallback<std::unique_ptr<InkDropHighlight>()>
+      create_ink_drop_highlight_callback_;
+
+  base::RepeatingCallback<std::unique_ptr<InkDropMask>()>
+      create_ink_drop_mask_callback_;
+
+  base::RepeatingClosureList highlighted_changed_callbacks_;
+
+  // Attention is a state we apply on Buttons' ink drop when we want to draw
+  // users' attention to this button and prompt users' interaction.
+  // It consists of two visual effects: a default light blue color and a pulsing
+  // effect. Current use case is IPH. Go to chrome://internals/user-education
+  // and press e.g. IPH_TabSearch to see the effects.
+  bool in_attention_state_ = false;
+};
+
+}  // namespace views
+
+#endif  // UI_VIEWS_ANIMATION_INK_DROP_HOST_H_
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/src-orig/ui/views/animation/ink_drop_host.h
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/src-orig/ui/views/animation/ink_drop_host.h	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-inc-drop-host-crash-patch/src-orig/ui/views/animation/ink_drop_host.h	(revision 192)
@@ -0,0 +1,299 @@
+// Copyright 2016 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_ANIMATION_INK_DROP_HOST_H_
+#define UI_VIEWS_ANIMATION_INK_DROP_HOST_H_
+
+#include <memory>
+
+#include "base/memory/raw_ptr.h"
+#include "third_party/abseil-cpp/absl/types/variant.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/color/color_id.h"
+#include "ui/color/color_provider.h"
+#include "ui/gfx/color_palette.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/views/animation/ink_drop_event_handler.h"
+#include "ui/views/metadata/view_factory.h"
+#include "ui/views/view.h"
+
+namespace ui {
+class Layer;
+class LocatedEvent;
+}  // namespace ui
+
+namespace views {
+
+class InkDrop;
+class InkDropHighlight;
+class InkDropImpl;
+class InkDropMask;
+class InkDropRipple;
+enum class InkDropState;
+
+namespace test {
+class InkDropHostTestApi;
+}  // namespace test
+
+// TODO(crbug.com/931964): Rename this type and move this header. Also consider
+// if InkDropHost should be what implements the InkDrop interface and have that
+// be the public interface.
+// The current division of labor is roughly as follows:
+// * InkDropHost manages an InkDrop and is responsible for a lot of its
+//   configuration and creating the parts of the InkDrop.
+// * InkDrop manages the parts of the ink-drop effect once it's up and running.
+// * InkDropRipple is a ripple effect that usually triggers as a result of
+//   clicking or activating the button / similar which hosts this.
+// * InkDropHighlight manages the hover/focus highlight layer.
+// TODO(pbos): See if this can be the only externally visible surface for an
+// ink-drop effect, and rename this InkDrop, or consolidate with InkDrop.
+class VIEWS_EXPORT InkDropHost {
+ public:
+  // Used in SetMode() to specify whether the ink drop effect is enabled
+  // or not for the view. In case of having an ink drop, it also specifies
+  // whether the default event handler for the ink drop should be installed or
+  // the subclass will handle ink drop events itself.
+  enum class InkDropMode {
+    OFF,
+    ON,
+    ON_NO_GESTURE_HANDLER,
+    ON_NO_ANIMATE,
+  };
+
+  explicit InkDropHost(View* host);
+  InkDropHost(const InkDropHost&) = delete;
+  InkDropHost& operator=(const InkDropHost&) = delete;
+  virtual ~InkDropHost();
+
+  // Returns a configured InkDrop. To override default behavior call
+  // SetCreateInkDropCallback().
+  std::unique_ptr<InkDrop> CreateInkDrop();
+
+  // Replace CreateInkDrop() behavior.
+  void SetCreateInkDropCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDrop>()> callback);
+
+  // Creates and returns the visual effect used for press. Used by InkDropImpl
+  // instances.
+  std::unique_ptr<InkDropRipple> CreateInkDropRipple() const;
+
+  // Replaces CreateInkDropRipple() behavior.
+  void SetCreateRippleCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDropRipple>()> callback);
+
+  // Returns the point of the |last_ripple_triggering_event_| if it was a
+  // LocatedEvent, otherwise the center point of the local bounds is returned.
+  // This is nominally used by the InkDropRipple.
+  gfx::Point GetInkDropCenterBasedOnLastEvent() const;
+
+  // Creates and returns the visual effect used for hover and focus. Used by
+  // InkDropImpl instances. To override behavior call
+  // SetCreateHighlightCallback().
+  std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const;
+
+  // Replaces CreateInkDropHighlight() behavior.
+  void SetCreateHighlightCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDropHighlight>()> callback);
+
+  // Callback replacement of CreateInkDropMask().
+  // TODO(pbos): Investigate removing this. It currently is only used by
+  // PieMenuView.
+  void SetCreateMaskCallback(
+      base::RepeatingCallback<std::unique_ptr<InkDropMask>()> callback);
+
+  // Toggles ink drop attention state on/off. If set on, a pulsing highlight
+  // is shown, prompting users to interact with `host_view_`.
+  // Called by components that want to call into user's attention, e.g. IPH.
+  void ToggleAttentionState(bool attention_on);
+
+  // Returns the base color for the ink drop.
+  SkColor GetBaseColor() const;
+
+  // Sets the base color of the ink drop. If `SetBaseColor` is called, the
+  // effect of previous calls to `SetBaseColorId` and `SetBaseColorCallback` is
+  // overwritten and vice versa.
+  // TODO(crbug.com/1341361): Replace SetBaseColor with SetBaseColorId.
+  void SetBaseColor(SkColor color);
+  void SetBaseColorId(ui::ColorId color_id);
+  // Callback version of `GetBaseColor`. If possible, prefer using
+  // `SetBaseColor` or `SetBaseColorId`.
+  void SetBaseColorCallback(base::RepeatingCallback<SkColor()> callback);
+
+  // Toggle to enable/disable an InkDrop on this View.  Descendants can override
+  // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel
+  // of the InkDrop.
+  //
+  // TODO(bruthig): Add an easier mechanism than overriding functions to allow
+  // subclasses/clients to specify the flavor of ink drop.
+  void SetMode(InkDropMode ink_drop_mode);
+  InkDropMode GetMode() const;
+
+  // Set whether the ink drop layers should be placed into the region above or
+  // below the view layer. The default is kBelow;
+  void SetLayerRegion(LayerRegion region);
+  LayerRegion GetLayerRegion() const;
+
+  void SetVisibleOpacity(float visible_opacity);
+  float GetVisibleOpacity() const;
+
+  void SetHighlightOpacity(absl::optional<float> opacity);
+
+  void SetSmallCornerRadius(int small_radius);
+  int GetSmallCornerRadius() const;
+
+  void SetLargeCornerRadius(int large_radius);
+  int GetLargeCornerRadius() const;
+
+  // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the
+  // last_ripple_triggering_event().
+  //
+  // *** NOTE ***: |event| has been plumbed through on a best effort basis for
+  // the purposes of centering ink drop ripples on located Events.  Thus nullptr
+  // has been used by clients who do not have an Event instance available to
+  // them.
+  void AnimateToState(InkDropState state, const ui::LocatedEvent* event);
+
+  // Returns true if an ink drop instance has been created.
+  bool HasInkDrop() const;
+
+  // Provides public access to |ink_drop_| so that factory methods can configure
+  // the inkdrop. Implements lazy initialization of |ink_drop_| so as to avoid
+  // virtual method calls during construction since subclasses should be able to
+  // call SetMode() during construction.
+  InkDrop* GetInkDrop();
+
+  // Returns whether the ink drop should be considered "highlighted" (in or
+  // animating into "highlight visible" steady state).
+  bool GetHighlighted() const;
+
+  base::CallbackListSubscription AddHighlightedChangedCallback(
+      base::RepeatingClosure callback);
+
+  // Should be called by InkDrop implementations when their highlight state
+  // changes, to trigger the corresponding property change notification here.
+  void OnInkDropHighlightedChanged();
+
+  // Methods called by InkDrop for attaching its layer.
+  // TODO(pbos): Investigate using direct calls on View::AddLayerToRegion.
+  void AddInkDropLayer(ui::Layer* ink_drop_layer);
+  void RemoveInkDropLayer(ui::Layer* ink_drop_layer);
+
+  // Size used by default for the SquareInkDropRipple.
+  static constexpr gfx::Size kDefaultSquareInkDropSize = gfx::Size(24, 24);
+
+  // Returns a large scaled size used by SquareInkDropRipple and Highlight.
+  static gfx::Size GetLargeSize(gfx::Size small_size);
+
+  // Creates a SquareInkDropRipple centered on |center_point|.
+  std::unique_ptr<InkDropRipple> CreateSquareRipple(
+      const gfx::Point& center_point,
+      const gfx::Size& size = kDefaultSquareInkDropSize) const;
+
+  View* host_view() { return host_view_; }
+  const View* host_view() const { return host_view_; }
+
+ private:
+  friend class test::InkDropHostTestApi;
+
+  class ViewLayerTransformObserver : public ViewObserver {
+   public:
+    ViewLayerTransformObserver(InkDropHost* ink_drop_host, View* host);
+    ~ViewLayerTransformObserver() override;
+
+    void OnViewLayerTransformed(View* observed_view) override;
+
+   private:
+    base::ScopedObservation<View, ViewObserver> observation_{this};
+    const raw_ptr<InkDropHost> ink_drop_host_;
+  };
+
+  class InkDropHostEventHandlerDelegate : public InkDropEventHandler::Delegate {
+   public:
+    explicit InkDropHostEventHandlerDelegate(InkDropHost* host);
+
+    // InkDropEventHandler::Delegate:
+    InkDrop* GetInkDrop() override;
+    bool HasInkDrop() const override;
+
+    bool SupportsGestureEvents() const override;
+
+   private:
+    // The host.
+    const raw_ptr<InkDropHost> ink_drop_host_;
+  };
+
+  const InkDropEventHandler* GetEventHandler() const;
+  InkDropEventHandler* GetEventHandler();
+
+  // This generates a mask for the InkDrop.
+  std::unique_ptr<views::InkDropMask> CreateInkDropMask() const;
+
+  // Adds a clip rect on the root layer of the ink drop impl. This is a more
+  // performant alternative to using circles or rectangle mask layers. Returns
+  // true if a clip was added.
+  bool AddInkDropClip(ui::Layer* ink_drop_layer);
+
+  // Initializes and sets a mask on `ink_drop_layer`. This will not run if
+  // AddInkDropClip() succeeds in the default implementation of
+  // AddInkDropLayer().
+  void InstallInkDropMask(ui::Layer* ink_drop_layer);
+
+  const raw_ptr<View> host_view_;
+
+  // Defines what type of |ink_drop_| to create.
+  InkDropMode ink_drop_mode_ = views::InkDropHost::InkDropMode::OFF;
+
+  // Into which region should the ink drop layers be placed.
+  LayerRegion layer_region_ = LayerRegion::kBelow;
+
+  // Used to observe View and inform the InkDrop of host-transform changes.
+  ViewLayerTransformObserver host_view_transform_observer_;
+
+  // Should not be accessed directly. Use GetInkDrop() instead.
+  std::unique_ptr<InkDrop> ink_drop_;
+
+  // Intentionally declared after |ink_drop_| so that it doesn't access a
+  // destroyed |ink_drop_| during destruction.
+  InkDropHostEventHandlerDelegate ink_drop_event_handler_delegate_;
+  InkDropEventHandler ink_drop_event_handler_;
+
+  float ink_drop_visible_opacity_ = 0.175f;
+
+  // The color of the ripple and hover.
+  absl::variant<SkColor, ui::ColorId, base::RepeatingCallback<SkColor()>>
+      ink_drop_base_color_ = gfx::kPlaceholderColor;
+
+  // TODO(pbos): Audit call sites to make sure highlight opacity is either
+  // always set or using the default value. Then make this a non-optional float.
+  absl::optional<float> ink_drop_highlight_opacity_;
+
+  // Radii used for the SquareInkDropRipple.
+  int ink_drop_small_corner_radius_ = 2;
+  int ink_drop_large_corner_radius_ = 4;
+
+  std::unique_ptr<views::InkDropMask> ink_drop_mask_;
+
+  base::RepeatingCallback<std::unique_ptr<InkDrop>()> create_ink_drop_callback_;
+  base::RepeatingCallback<std::unique_ptr<InkDropRipple>()>
+      create_ink_drop_ripple_callback_;
+  base::RepeatingCallback<std::unique_ptr<InkDropHighlight>()>
+      create_ink_drop_highlight_callback_;
+
+  base::RepeatingCallback<std::unique_ptr<InkDropMask>()>
+      create_ink_drop_mask_callback_;
+
+  base::RepeatingClosureList highlighted_changed_callbacks_;
+
+  // Attention is a state we apply on Buttons' ink drop when we want to draw
+  // users' attention to this button and prompt users' interaction.
+  // It consists of two visual effects: a default light blue color and a pulsing
+  // effect. Current use case is IPH. Go to chrome://internals/user-education
+  // and press e.g. IPH_TabSearch to see the effects.
+  bool in_attention_state_ = false;
+};
+
+}  // namespace views
+
+#endif  // UI_VIEWS_ANIMATION_INK_DROP_HOST_H_
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-oauth2-default.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/src/google_apis/google_api_keys.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/src/google_apis/google_api_keys.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/src/google_apis/google_api_keys.cc	(revision 192)
@@ -0,0 +1,451 @@
+// Copyright 2012 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "google_apis/google_api_keys.h"
+
+// If you add more includes to this list, you also need to add them to
+// google_api_keys_unittest.cc and google_api_keys_mac_unittest.mm.
+
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+
+#include "base/command_line.h"
+#include "base/environment.h"
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "base/strings/stringize_macros.h"
+#include "build/branding_buildflags.h"
+#include "build/chromeos_buildflags.h"
+#include "google_apis/buildflags.h"
+#include "google_apis/gaia/gaia_config.h"
+#include "google_apis/gaia/gaia_switches.h"
+
+#if BUILDFLAG(IS_APPLE)
+#include "google_apis/google_api_keys_mac.h"
+#endif
+
+#if defined(USE_OFFICIAL_GOOGLE_API_KEYS)
+#include "google_apis/internal/google_chrome_api_keys.h"
+#include "google_apis/internal/metrics_signing_key.h"
+#endif
+
+// Used to indicate an unset key/id/secret.  This works better with
+// various unit tests than leaving the token empty.
+#define DUMMY_API_TOKEN "dummytoken"
+
+#if !defined(GOOGLE_API_KEY)
+#define GOOGLE_API_KEY DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_METRICS_SIGNING_KEY)
+#define GOOGLE_METRICS_SIGNING_KEY DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_ID_MAIN)
+#define GOOGLE_CLIENT_ID_MAIN DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_MAIN)
+#define GOOGLE_CLIENT_SECRET_MAIN DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_ID_REMOTING)
+#define GOOGLE_CLIENT_ID_REMOTING DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_REMOTING)
+#define GOOGLE_CLIENT_SECRET_REMOTING DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_ID_REMOTING_HOST)
+#define GOOGLE_CLIENT_ID_REMOTING_HOST DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_REMOTING_HOST)
+#define GOOGLE_CLIENT_SECRET_REMOTING_HOST DUMMY_API_TOKEN
+#endif
+
+#if BUILDFLAG(IS_ANDROID)
+#if !defined(GOOGLE_API_KEY_ANDROID_NON_STABLE)
+#define GOOGLE_API_KEY_ANDROID_NON_STABLE DUMMY_API_TOKEN
+#endif
+#endif
+
+#if !defined(GOOGLE_API_KEY_REMOTING)
+#define GOOGLE_API_KEY_REMOTING DUMMY_API_TOKEN
+#endif
+
+// API key for the Speech On-Device API (SODA).
+#if !defined(GOOGLE_API_KEY_SODA)
+#define GOOGLE_API_KEY_SODA DUMMY_API_TOKEN
+#endif
+
+#if !BUILDFLAG(IS_ANDROID)
+// API key for the HaTS API.
+#if !defined(GOOGLE_API_KEY_HATS)
+#define GOOGLE_API_KEY_HATS DUMMY_API_TOKEN
+#endif
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+// API key for the Nearby Sharing Service.
+#if !defined(GOOGLE_API_KEY_SHARING)
+#define GOOGLE_API_KEY_SHARING DUMMY_API_TOKEN
+#endif
+
+// API key for the ReadAloud API.
+#if !defined(GOOGLE_API_KEY_READ_ALOUD)
+#define GOOGLE_API_KEY_READ_ALOUD DUMMY_API_TOKEN
+#endif
+
+// API key for the Fresnel API.
+#if !defined(GOOGLE_API_KEY_FRESNEL)
+#define GOOGLE_API_KEY_FRESNEL DUMMY_API_TOKEN
+#endif
+#endif  // BUILDFLAG(IS_CHROMEOS_ASH)
+
+// These are used as shortcuts for developers and users providing
+// OAuth credentials via preprocessor defines or environment
+// variables.  If set, they will be used to replace any of the client
+// IDs and secrets above that have not been set (and only those; they
+// will not override already-set values).
+#if !defined(GOOGLE_DEFAULT_CLIENT_ID)
+#define GOOGLE_DEFAULT_CLIENT_ID ""
+#endif
+#if !defined(GOOGLE_DEFAULT_CLIENT_SECRET)
+#define GOOGLE_DEFAULT_CLIENT_SECRET ""
+#endif
+
+namespace google_apis {
+
+const char kAPIKeysDevelopersHowToURL[] =
+    "https://www.chromium.org/developers/how-tos/api-keys";
+
+// This is used as a lazy instance to determine keys once and cache them.
+class APIKeyCache {
+ public:
+  APIKeyCache() {
+    std::unique_ptr<base::Environment> environment(base::Environment::Create());
+    base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+    GaiaConfig* gaia_config = GaiaConfig::GetInstance();
+
+    api_key_ = CalculateKeyValue(
+        GOOGLE_API_KEY, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+
+// A special non-stable key is at the moment defined only for Android Chrome.
+#if BUILDFLAG(IS_ANDROID)
+    api_key_non_stable_ = CalculateKeyValue(
+        GOOGLE_API_KEY_ANDROID_NON_STABLE,
+        STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_ANDROID_NON_STABLE), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+#else
+    api_key_non_stable_ = api_key_;
+#endif
+
+    api_key_remoting_ = CalculateKeyValue(
+        GOOGLE_API_KEY_REMOTING,
+        STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_REMOTING), nullptr, std::string(),
+        environment.get(), command_line, gaia_config);
+
+    api_key_soda_ = CalculateKeyValue(
+        GOOGLE_API_KEY_SODA, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_SODA),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+#if !BUILDFLAG(IS_ANDROID)
+    api_key_hats_ = CalculateKeyValue(
+        GOOGLE_API_KEY_HATS, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_HATS),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+    api_key_sharing_ = CalculateKeyValue(
+        GOOGLE_API_KEY_SHARING, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_SHARING),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+
+    api_key_read_aloud_ = CalculateKeyValue(
+        GOOGLE_API_KEY_READ_ALOUD,
+        STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_READ_ALOUD), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+
+    api_key_fresnel_ = CalculateKeyValue(
+        GOOGLE_API_KEY_FRESNEL, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_FRESNEL),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+#endif
+
+    metrics_key_ = CalculateKeyValue(
+        GOOGLE_METRICS_SIGNING_KEY,
+        STRINGIZE_NO_EXPANSION(GOOGLE_METRICS_SIGNING_KEY), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+
+    std::string default_client_id = CalculateKeyValue(
+        GOOGLE_DEFAULT_CLIENT_ID,
+        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), ::switches::kOAuth2ClientSecret,
+        std::string(), environment.get(), command_line, gaia_config);
+
+    // We currently only allow overriding the baked-in values for the
+    // default OAuth2 client ID and secret using a command-line
+    // argument and gaia config, since that is useful to enable testing against
+    // staging servers, and since that was what was possible and
+    // likely practiced by the QA team before this implementation was
+    // written.
+    client_ids_[CLIENT_MAIN] = CalculateKeyValue(
+        GOOGLE_CLIENT_ID_MAIN, STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_MAIN),
+        ::switches::kOAuth2ClientID, default_client_id, environment.get(),
+        command_line, gaia_config);
+    client_secrets_[CLIENT_MAIN] = CalculateKeyValue(
+        GOOGLE_CLIENT_SECRET_MAIN,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_MAIN),
+        ::switches::kOAuth2ClientSecret, default_client_secret,
+        environment.get(), command_line, gaia_config);
+
+    client_ids_[CLIENT_REMOTING] = CalculateKeyValue(
+        GOOGLE_CLIENT_ID_REMOTING,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_REMOTING), nullptr,
+        default_client_id, environment.get(), command_line, gaia_config);
+    client_secrets_[CLIENT_REMOTING] = CalculateKeyValue(
+        GOOGLE_CLIENT_SECRET_REMOTING,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING), nullptr,
+        default_client_secret, environment.get(), command_line, gaia_config);
+
+    client_ids_[CLIENT_REMOTING_HOST] = CalculateKeyValue(
+        GOOGLE_CLIENT_ID_REMOTING_HOST,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_REMOTING_HOST), nullptr,
+        default_client_id, environment.get(), command_line, gaia_config);
+    client_secrets_[CLIENT_REMOTING_HOST] = CalculateKeyValue(
+        GOOGLE_CLIENT_SECRET_REMOTING_HOST,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING_HOST), nullptr,
+        default_client_secret, environment.get(), command_line, gaia_config);
+  }
+
+  std::string api_key() const { return api_key_; }
+#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
+  void set_api_key(const std::string& api_key) { api_key_ = api_key; }
+#endif
+  std::string api_key_non_stable() const { return api_key_non_stable_; }
+  std::string api_key_remoting() const { return api_key_remoting_; }
+  std::string api_key_soda() const { return api_key_soda_; }
+#if !BUILDFLAG(IS_ANDROID)
+  std::string api_key_hats() const { return api_key_hats_; }
+#endif
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+  std::string api_key_sharing() const { return api_key_sharing_; }
+  std::string api_key_read_aloud() const { return api_key_read_aloud_; }
+  std::string api_key_fresnel() const { return api_key_fresnel_; }
+#endif
+
+  std::string metrics_key() const { return metrics_key_; }
+
+  std::string GetClientID(OAuth2Client client) const {
+    DCHECK_LT(client, CLIENT_NUM_ITEMS);
+    return client_ids_[client];
+  }
+
+#if BUILDFLAG(IS_IOS)
+  void SetClientID(OAuth2Client client, const std::string& client_id) {
+    client_ids_[client] = client_id;
+  }
+#endif
+
+  std::string GetClientSecret(OAuth2Client client) const {
+    DCHECK_LT(client, CLIENT_NUM_ITEMS);
+    return client_secrets_[client];
+  }
+
+#if BUILDFLAG(IS_IOS)
+  void SetClientSecret(OAuth2Client client, const std::string& client_secret) {
+    client_secrets_[client] = client_secret;
+  }
+#endif
+
+ private:
+  // Gets a value for a key.  In priority order, this will be the value
+  // provided via:
+  // 1. Command-line switch
+  // 2. Config file
+  // 3. Environment variable
+  // 4. Baked into the build
+  // |command_line_switch| may be NULL. Official Google Chrome builds will not
+  // use the value provided by an environment variable.
+  static std::string CalculateKeyValue(const char* baked_in_value,
+                                       const char* environment_variable_name,
+                                       const char* command_line_switch,
+                                       const std::string& default_if_unset,
+                                       base::Environment* environment,
+                                       base::CommandLine* command_line,
+                                       GaiaConfig* gaia_config) {
+    std::string key_value = baked_in_value;
+    std::string temp;
+#if BUILDFLAG(IS_APPLE)
+    // macOS and iOS can also override the API key with a value from the
+    // Info.plist.
+    temp = ::google_apis::GetAPIKeyFromInfoPlist(environment_variable_name);
+    if (!temp.empty()) {
+      key_value = temp;
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from Info.plist.";
+    }
+#endif
+
+#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
+    // Don't allow using the environment to override API keys for official
+    // Google Chrome builds. There have been reports of mangled environments
+    // affecting users (crbug.com/710575).
+    if (environment->GetVar(environment_variable_name, &temp)) {
+      key_value = temp;
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from environment variable.";
+    }
+#endif
+
+    if (gaia_config &&
+        gaia_config->GetAPIKeyIfExists(environment_variable_name, &temp)) {
+      key_value = temp;
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from gaia config.";
+    }
+
+    if (command_line_switch && command_line->HasSwitch(command_line_switch)) {
+      key_value = command_line->GetSwitchValueASCII(command_line_switch);
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from command-line switch.";
+    }
+
+    if (key_value == DUMMY_API_TOKEN) {
+// TODO(crbug.com/1294915): Rewrite this condition using
+// BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY).
+#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_FUCHSIA)
+      // No key should be unset in an official build except the
+      // GOOGLE_DEFAULT_* keys.  The default keys don't trigger this
+      // check as their "unset" value is not DUMMY_API_TOKEN.
+      CHECK(false);
+#endif
+      if (default_if_unset.size() > 0) {
+        VLOG(1) << "Using default value \"" << default_if_unset
+                << "\" for API key " << environment_variable_name;
+        key_value = default_if_unset;
+      }
+    }
+
+    // This should remain a debug-only log.
+    DVLOG(1) << "API key " << environment_variable_name << "=" << key_value;
+
+    return key_value;
+  }
+
+  std::string api_key_;
+  std::string api_key_non_stable_;
+  std::string api_key_remoting_;
+  std::string api_key_soda_;
+#if !BUILDFLAG(IS_ANDROID)
+  std::string api_key_hats_;
+#endif
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+  std::string api_key_sharing_;
+  std::string api_key_read_aloud_;
+  std::string api_key_fresnel_;
+#endif
+  std::string metrics_key_;
+  std::string client_ids_[CLIENT_NUM_ITEMS];
+  std::string client_secrets_[CLIENT_NUM_ITEMS];
+};
+
+static base::LazyInstance<APIKeyCache>::DestructorAtExit g_api_key_cache =
+    LAZY_INSTANCE_INITIALIZER;
+
+bool HasAPIKeyConfigured() {
+  return GetAPIKey() != DUMMY_API_TOKEN;
+}
+
+std::string GetAPIKey() {
+  return g_api_key_cache.Get().api_key();
+}
+
+std::string GetNonStableAPIKey() {
+  return g_api_key_cache.Get().api_key_non_stable();
+}
+
+std::string GetRemotingAPIKey() {
+  return g_api_key_cache.Get().api_key_remoting();
+}
+
+std::string GetSodaAPIKey() {
+  return g_api_key_cache.Get().api_key_soda();
+}
+
+#if !BUILDFLAG(IS_ANDROID)
+std::string GetHatsAPIKey() {
+  return g_api_key_cache.Get().api_key_hats();
+}
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+std::string GetSharingAPIKey() {
+  return g_api_key_cache.Get().api_key_sharing();
+}
+
+std::string GetReadAloudAPIKey() {
+  return g_api_key_cache.Get().api_key_read_aloud();
+}
+
+std::string GetFresnelAPIKey() {
+  return g_api_key_cache.Get().api_key_fresnel();
+}
+#endif
+
+#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
+void SetAPIKey(const std::string& api_key) {
+  g_api_key_cache.Get().set_api_key(api_key);
+}
+#endif
+
+std::string GetMetricsKey() {
+  return g_api_key_cache.Get().metrics_key();
+}
+
+bool HasOAuthClientConfigured() {
+  for (size_t client_id = 0; client_id < CLIENT_NUM_ITEMS; ++client_id) {
+    OAuth2Client client = static_cast<OAuth2Client>(client_id);
+    if (GetOAuth2ClientID(client) == DUMMY_API_TOKEN ||
+        GetOAuth2ClientSecret(client) == DUMMY_API_TOKEN) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+std::string GetOAuth2ClientID(OAuth2Client client) {
+  return g_api_key_cache.Get().GetClientID(client);
+}
+
+std::string GetOAuth2ClientSecret(OAuth2Client client) {
+  return g_api_key_cache.Get().GetClientSecret(client);
+}
+
+#if BUILDFLAG(IS_IOS)
+void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id) {
+  g_api_key_cache.Get().SetClientID(client, client_id);
+}
+
+void SetOAuth2ClientSecret(OAuth2Client client,
+                           const std::string& client_secret) {
+  g_api_key_cache.Get().SetClientSecret(client, client_secret);
+}
+#endif
+
+bool IsGoogleChromeAPIKeyUsed() {
+#if defined(USE_OFFICIAL_GOOGLE_API_KEYS)
+  return true;
+#else
+  return false;
+#endif
+}
+
+}  // namespace google_apis
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/src-orig/google_apis/google_api_keys.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/src-orig/google_apis/google_api_keys.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-oauth2-default-patch/src-orig/google_apis/google_api_keys.cc	(revision 192)
@@ -0,0 +1,451 @@
+// Copyright 2012 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "google_apis/google_api_keys.h"
+
+// If you add more includes to this list, you also need to add them to
+// google_api_keys_unittest.cc and google_api_keys_mac_unittest.mm.
+
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+
+#include "base/command_line.h"
+#include "base/environment.h"
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "base/strings/stringize_macros.h"
+#include "build/branding_buildflags.h"
+#include "build/chromeos_buildflags.h"
+#include "google_apis/buildflags.h"
+#include "google_apis/gaia/gaia_config.h"
+#include "google_apis/gaia/gaia_switches.h"
+
+#if BUILDFLAG(IS_APPLE)
+#include "google_apis/google_api_keys_mac.h"
+#endif
+
+#if defined(USE_OFFICIAL_GOOGLE_API_KEYS)
+#include "google_apis/internal/google_chrome_api_keys.h"
+#include "google_apis/internal/metrics_signing_key.h"
+#endif
+
+// Used to indicate an unset key/id/secret.  This works better with
+// various unit tests than leaving the token empty.
+#define DUMMY_API_TOKEN "dummytoken"
+
+#if !defined(GOOGLE_API_KEY)
+#define GOOGLE_API_KEY DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_METRICS_SIGNING_KEY)
+#define GOOGLE_METRICS_SIGNING_KEY DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_ID_MAIN)
+#define GOOGLE_CLIENT_ID_MAIN DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_MAIN)
+#define GOOGLE_CLIENT_SECRET_MAIN DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_ID_REMOTING)
+#define GOOGLE_CLIENT_ID_REMOTING DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_REMOTING)
+#define GOOGLE_CLIENT_SECRET_REMOTING DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_ID_REMOTING_HOST)
+#define GOOGLE_CLIENT_ID_REMOTING_HOST DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_REMOTING_HOST)
+#define GOOGLE_CLIENT_SECRET_REMOTING_HOST DUMMY_API_TOKEN
+#endif
+
+#if BUILDFLAG(IS_ANDROID)
+#if !defined(GOOGLE_API_KEY_ANDROID_NON_STABLE)
+#define GOOGLE_API_KEY_ANDROID_NON_STABLE DUMMY_API_TOKEN
+#endif
+#endif
+
+#if !defined(GOOGLE_API_KEY_REMOTING)
+#define GOOGLE_API_KEY_REMOTING DUMMY_API_TOKEN
+#endif
+
+// API key for the Speech On-Device API (SODA).
+#if !defined(GOOGLE_API_KEY_SODA)
+#define GOOGLE_API_KEY_SODA DUMMY_API_TOKEN
+#endif
+
+#if !BUILDFLAG(IS_ANDROID)
+// API key for the HaTS API.
+#if !defined(GOOGLE_API_KEY_HATS)
+#define GOOGLE_API_KEY_HATS DUMMY_API_TOKEN
+#endif
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+// API key for the Nearby Sharing Service.
+#if !defined(GOOGLE_API_KEY_SHARING)
+#define GOOGLE_API_KEY_SHARING DUMMY_API_TOKEN
+#endif
+
+// API key for the ReadAloud API.
+#if !defined(GOOGLE_API_KEY_READ_ALOUD)
+#define GOOGLE_API_KEY_READ_ALOUD DUMMY_API_TOKEN
+#endif
+
+// API key for the Fresnel API.
+#if !defined(GOOGLE_API_KEY_FRESNEL)
+#define GOOGLE_API_KEY_FRESNEL DUMMY_API_TOKEN
+#endif
+#endif  // BUILDFLAG(IS_CHROMEOS_ASH)
+
+// These are used as shortcuts for developers and users providing
+// OAuth credentials via preprocessor defines or environment
+// variables.  If set, they will be used to replace any of the client
+// IDs and secrets above that have not been set (and only those; they
+// will not override already-set values).
+#if !defined(GOOGLE_DEFAULT_CLIENT_ID)
+#define GOOGLE_DEFAULT_CLIENT_ID ""
+#endif
+#if !defined(GOOGLE_DEFAULT_CLIENT_SECRET)
+#define GOOGLE_DEFAULT_CLIENT_SECRET ""
+#endif
+
+namespace google_apis {
+
+const char kAPIKeysDevelopersHowToURL[] =
+    "https://www.chromium.org/developers/how-tos/api-keys";
+
+// This is used as a lazy instance to determine keys once and cache them.
+class APIKeyCache {
+ public:
+  APIKeyCache() {
+    std::unique_ptr<base::Environment> environment(base::Environment::Create());
+    base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+    GaiaConfig* gaia_config = GaiaConfig::GetInstance();
+
+    api_key_ = CalculateKeyValue(
+        GOOGLE_API_KEY, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+
+// A special non-stable key is at the moment defined only for Android Chrome.
+#if BUILDFLAG(IS_ANDROID)
+    api_key_non_stable_ = CalculateKeyValue(
+        GOOGLE_API_KEY_ANDROID_NON_STABLE,
+        STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_ANDROID_NON_STABLE), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+#else
+    api_key_non_stable_ = api_key_;
+#endif
+
+    api_key_remoting_ = CalculateKeyValue(
+        GOOGLE_API_KEY_REMOTING,
+        STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_REMOTING), nullptr, std::string(),
+        environment.get(), command_line, gaia_config);
+
+    api_key_soda_ = CalculateKeyValue(
+        GOOGLE_API_KEY_SODA, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_SODA),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+#if !BUILDFLAG(IS_ANDROID)
+    api_key_hats_ = CalculateKeyValue(
+        GOOGLE_API_KEY_HATS, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_HATS),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+    api_key_sharing_ = CalculateKeyValue(
+        GOOGLE_API_KEY_SHARING, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_SHARING),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+
+    api_key_read_aloud_ = CalculateKeyValue(
+        GOOGLE_API_KEY_READ_ALOUD,
+        STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_READ_ALOUD), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+
+    api_key_fresnel_ = CalculateKeyValue(
+        GOOGLE_API_KEY_FRESNEL, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_FRESNEL),
+        nullptr, std::string(), environment.get(), command_line, gaia_config);
+#endif
+
+    metrics_key_ = CalculateKeyValue(
+        GOOGLE_METRICS_SIGNING_KEY,
+        STRINGIZE_NO_EXPANSION(GOOGLE_METRICS_SIGNING_KEY), nullptr,
+        std::string(), environment.get(), command_line, gaia_config);
+
+    std::string default_client_id = CalculateKeyValue(
+        GOOGLE_DEFAULT_CLIENT_ID,
+        STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), nullptr,
+        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,
+        std::string(), environment.get(), command_line, gaia_config);
+
+    // We currently only allow overriding the baked-in values for the
+    // default OAuth2 client ID and secret using a command-line
+    // argument and gaia config, since that is useful to enable testing against
+    // staging servers, and since that was what was possible and
+    // likely practiced by the QA team before this implementation was
+    // written.
+    client_ids_[CLIENT_MAIN] = CalculateKeyValue(
+        GOOGLE_CLIENT_ID_MAIN, STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_MAIN),
+        ::switches::kOAuth2ClientID, default_client_id, environment.get(),
+        command_line, gaia_config);
+    client_secrets_[CLIENT_MAIN] = CalculateKeyValue(
+        GOOGLE_CLIENT_SECRET_MAIN,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_MAIN),
+        ::switches::kOAuth2ClientSecret, default_client_secret,
+        environment.get(), command_line, gaia_config);
+
+    client_ids_[CLIENT_REMOTING] = CalculateKeyValue(
+        GOOGLE_CLIENT_ID_REMOTING,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_REMOTING), nullptr,
+        default_client_id, environment.get(), command_line, gaia_config);
+    client_secrets_[CLIENT_REMOTING] = CalculateKeyValue(
+        GOOGLE_CLIENT_SECRET_REMOTING,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING), nullptr,
+        default_client_secret, environment.get(), command_line, gaia_config);
+
+    client_ids_[CLIENT_REMOTING_HOST] = CalculateKeyValue(
+        GOOGLE_CLIENT_ID_REMOTING_HOST,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_REMOTING_HOST), nullptr,
+        default_client_id, environment.get(), command_line, gaia_config);
+    client_secrets_[CLIENT_REMOTING_HOST] = CalculateKeyValue(
+        GOOGLE_CLIENT_SECRET_REMOTING_HOST,
+        STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING_HOST), nullptr,
+        default_client_secret, environment.get(), command_line, gaia_config);
+  }
+
+  std::string api_key() const { return api_key_; }
+#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
+  void set_api_key(const std::string& api_key) { api_key_ = api_key; }
+#endif
+  std::string api_key_non_stable() const { return api_key_non_stable_; }
+  std::string api_key_remoting() const { return api_key_remoting_; }
+  std::string api_key_soda() const { return api_key_soda_; }
+#if !BUILDFLAG(IS_ANDROID)
+  std::string api_key_hats() const { return api_key_hats_; }
+#endif
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+  std::string api_key_sharing() const { return api_key_sharing_; }
+  std::string api_key_read_aloud() const { return api_key_read_aloud_; }
+  std::string api_key_fresnel() const { return api_key_fresnel_; }
+#endif
+
+  std::string metrics_key() const { return metrics_key_; }
+
+  std::string GetClientID(OAuth2Client client) const {
+    DCHECK_LT(client, CLIENT_NUM_ITEMS);
+    return client_ids_[client];
+  }
+
+#if BUILDFLAG(IS_IOS)
+  void SetClientID(OAuth2Client client, const std::string& client_id) {
+    client_ids_[client] = client_id;
+  }
+#endif
+
+  std::string GetClientSecret(OAuth2Client client) const {
+    DCHECK_LT(client, CLIENT_NUM_ITEMS);
+    return client_secrets_[client];
+  }
+
+#if BUILDFLAG(IS_IOS)
+  void SetClientSecret(OAuth2Client client, const std::string& client_secret) {
+    client_secrets_[client] = client_secret;
+  }
+#endif
+
+ private:
+  // Gets a value for a key.  In priority order, this will be the value
+  // provided via:
+  // 1. Command-line switch
+  // 2. Config file
+  // 3. Environment variable
+  // 4. Baked into the build
+  // |command_line_switch| may be NULL. Official Google Chrome builds will not
+  // use the value provided by an environment variable.
+  static std::string CalculateKeyValue(const char* baked_in_value,
+                                       const char* environment_variable_name,
+                                       const char* command_line_switch,
+                                       const std::string& default_if_unset,
+                                       base::Environment* environment,
+                                       base::CommandLine* command_line,
+                                       GaiaConfig* gaia_config) {
+    std::string key_value = baked_in_value;
+    std::string temp;
+#if BUILDFLAG(IS_APPLE)
+    // macOS and iOS can also override the API key with a value from the
+    // Info.plist.
+    temp = ::google_apis::GetAPIKeyFromInfoPlist(environment_variable_name);
+    if (!temp.empty()) {
+      key_value = temp;
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from Info.plist.";
+    }
+#endif
+
+#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
+    // Don't allow using the environment to override API keys for official
+    // Google Chrome builds. There have been reports of mangled environments
+    // affecting users (crbug.com/710575).
+    if (environment->GetVar(environment_variable_name, &temp)) {
+      key_value = temp;
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from environment variable.";
+    }
+#endif
+
+    if (gaia_config &&
+        gaia_config->GetAPIKeyIfExists(environment_variable_name, &temp)) {
+      key_value = temp;
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from gaia config.";
+    }
+
+    if (command_line_switch && command_line->HasSwitch(command_line_switch)) {
+      key_value = command_line->GetSwitchValueASCII(command_line_switch);
+      VLOG(1) << "Overriding API key " << environment_variable_name
+              << " with value " << key_value << " from command-line switch.";
+    }
+
+    if (key_value == DUMMY_API_TOKEN) {
+// TODO(crbug.com/1294915): Rewrite this condition using
+// BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY).
+#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_FUCHSIA)
+      // No key should be unset in an official build except the
+      // GOOGLE_DEFAULT_* keys.  The default keys don't trigger this
+      // check as their "unset" value is not DUMMY_API_TOKEN.
+      CHECK(false);
+#endif
+      if (default_if_unset.size() > 0) {
+        VLOG(1) << "Using default value \"" << default_if_unset
+                << "\" for API key " << environment_variable_name;
+        key_value = default_if_unset;
+      }
+    }
+
+    // This should remain a debug-only log.
+    DVLOG(1) << "API key " << environment_variable_name << "=" << key_value;
+
+    return key_value;
+  }
+
+  std::string api_key_;
+  std::string api_key_non_stable_;
+  std::string api_key_remoting_;
+  std::string api_key_soda_;
+#if !BUILDFLAG(IS_ANDROID)
+  std::string api_key_hats_;
+#endif
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+  std::string api_key_sharing_;
+  std::string api_key_read_aloud_;
+  std::string api_key_fresnel_;
+#endif
+  std::string metrics_key_;
+  std::string client_ids_[CLIENT_NUM_ITEMS];
+  std::string client_secrets_[CLIENT_NUM_ITEMS];
+};
+
+static base::LazyInstance<APIKeyCache>::DestructorAtExit g_api_key_cache =
+    LAZY_INSTANCE_INITIALIZER;
+
+bool HasAPIKeyConfigured() {
+  return GetAPIKey() != DUMMY_API_TOKEN;
+}
+
+std::string GetAPIKey() {
+  return g_api_key_cache.Get().api_key();
+}
+
+std::string GetNonStableAPIKey() {
+  return g_api_key_cache.Get().api_key_non_stable();
+}
+
+std::string GetRemotingAPIKey() {
+  return g_api_key_cache.Get().api_key_remoting();
+}
+
+std::string GetSodaAPIKey() {
+  return g_api_key_cache.Get().api_key_soda();
+}
+
+#if !BUILDFLAG(IS_ANDROID)
+std::string GetHatsAPIKey() {
+  return g_api_key_cache.Get().api_key_hats();
+}
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+std::string GetSharingAPIKey() {
+  return g_api_key_cache.Get().api_key_sharing();
+}
+
+std::string GetReadAloudAPIKey() {
+  return g_api_key_cache.Get().api_key_read_aloud();
+}
+
+std::string GetFresnelAPIKey() {
+  return g_api_key_cache.Get().api_key_fresnel();
+}
+#endif
+
+#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
+void SetAPIKey(const std::string& api_key) {
+  g_api_key_cache.Get().set_api_key(api_key);
+}
+#endif
+
+std::string GetMetricsKey() {
+  return g_api_key_cache.Get().metrics_key();
+}
+
+bool HasOAuthClientConfigured() {
+  for (size_t client_id = 0; client_id < CLIENT_NUM_ITEMS; ++client_id) {
+    OAuth2Client client = static_cast<OAuth2Client>(client_id);
+    if (GetOAuth2ClientID(client) == DUMMY_API_TOKEN ||
+        GetOAuth2ClientSecret(client) == DUMMY_API_TOKEN) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+std::string GetOAuth2ClientID(OAuth2Client client) {
+  return g_api_key_cache.Get().GetClientID(client);
+}
+
+std::string GetOAuth2ClientSecret(OAuth2Client client) {
+  return g_api_key_cache.Get().GetClientSecret(client);
+}
+
+#if BUILDFLAG(IS_IOS)
+void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id) {
+  g_api_key_cache.Get().SetClientID(client, client_id);
+}
+
+void SetOAuth2ClientSecret(OAuth2Client client,
+                           const std::string& client_secret) {
+  g_api_key_cache.Get().SetClientSecret(client, client_secret);
+}
+#endif
+
+bool IsGoogleChromeAPIKeyUsed() {
+#if defined(USE_OFFICIAL_GOOGLE_API_KEYS)
+  return true;
+#else
+  return false;
+#endif
+}
+
+}  // namespace google_apis
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-target-aarch64.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/src/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/src/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/src/build/config/compiler/BUILD.gn	(revision 192)
@@ -0,0 +1,2932 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/buildflag_header.gni")
+import("//build/config/android/config.gni")
+import("//build/config/c++/c++.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/coverage/coverage.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/host_byteorder.gni")
+import("//build/config/rust.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/rbe.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+  import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el" ||
+    current_cpu == "mips" || current_cpu == "mips64") {
+  import("//build/config/mips.gni")
+}
+if (is_mac) {
+  import("//build/config/apple/symbols.gni")
+}
+if (is_ios) {
+  import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+  # To keep NaCl variables out of builds that don't include NaCl, all
+  # variables defined in nacl/config.gni referenced here should be protected by
+  # is_nacl conditions.
+  import("//build/config/nacl/config.gni")
+}
+
+lld_path = ""
+if (!is_clang) {
+  declare_args() {
+    # This allows overriding the location of lld.
+    lld_path = rebase_path("$clang_base_path/bin", root_build_dir)
+  }
+} else {
+  # clang looks for lld next to it, no need for -B.
+  lld_path = ""
+}
+
+declare_args() {
+  # Normally, Android builds are lightly optimized, even for debug builds, to
+  # keep binary size down. Setting this flag to true disables such optimization
+  android_full_debug = false
+
+  # Compile in such a way as to make it possible for the profiler to unwind full
+  # stack frames. Setting this flag has a large effect on the performance of the
+  # generated code than just setting profiling, but gives the profiler more
+  # information to analyze.
+  # Requires profiling to be set to true.
+  enable_full_stack_frames_for_profiling = false
+
+  # When we are going to use gold we need to find it.
+  # This is initialized below, after use_gold might have been overridden.
+  gold_path = ""
+
+  # Enable fatal linker warnings. Building Chromium with certain versions
+  # of binutils can cause linker warning.
+  fatal_linker_warnings = true
+
+  # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+  # but some sanitizers are known to require it, like CFI diagnostics
+  # and UBsan variants.
+  use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+  # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+  # optimization that GCC supports. It used by ChromeOS in their official
+  # builds. To use it, set auto_profile_path to the path to a file containing
+  # the needed gcov profiling data.
+  auto_profile_path = ""
+
+  # Path to an AFDO profile to use while building with clang, if any. Empty
+  # implies none.
+  clang_sample_profile_path = ""
+
+  # Some configurations have default sample profiles. If this is true and
+  # clang_sample_profile_path is empty, we'll fall back to the default.
+  #
+  # We currently only have default profiles for Chromium in-tree, so we disable
+  # this by default for all downstream projects, since these profiles are likely
+  # nonsensical for said projects.
+  clang_use_default_sample_profile =
+      chrome_pgo_phase == 0 && build_with_chromium && is_official_build &&
+      (is_android || chromeos_is_browser_only)
+
+  # This configuration is used to select a default profile in Chrome OS based on
+  # the microarchitectures we are using. This is only used if
+  # clang_use_default_sample_profile is true and clang_sample_profile_path is
+  # empty.
+  chromeos_afdo_platform = "atom"
+
+  # Emit debug information for profiling wile building with clang.
+  # Only enable this for ChromeOS official builds for AFDO.
+  clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
+
+  # Turn this on to have the compiler output extra timing information.
+  compiler_timing = false
+
+  # Turn this on to use ghash feature of lld for faster debug link on Windows.
+  # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
+  use_ghash = true
+
+  # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on
+  # can substantially increase link time and binary size, but they generally
+  # also make binaries a fair bit faster.
+  #
+  # TODO(gbiv): We disable optimizations by default on most platforms because
+  # the space overhead is too great. We should use some mixture of profiles and
+  # optimization settings to better tune the size increase.
+  thin_lto_enable_optimizations =
+      (is_chromeos || is_android || is_win || is_linux || is_mac ||
+       (is_ios && use_lld)) && is_official_build
+
+  # Initialize all local variables with a pattern. This flag will fill
+  # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
+  # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
+  # recognizable in the debugger, and crashes on memory accesses through
+  # uninitialized pointers.
+  #
+  # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and
+  # needs to be evaluated before enabling it there as well.
+  init_stack_vars = !(is_android && is_official_build)
+
+  # Zero init has favorable performance/size tradeoffs for Chrome OS
+  # but was not evaluated for other platforms.
+  init_stack_vars_zero = is_chromeos
+
+  # This argument is to control whether enabling text section splitting in the
+  # final binary. When enabled, the separated text sections with prefix
+  # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be
+  # merged to '.text' section. This allows us to identify the hot code section
+  # ('.text.hot') in the binary, which allows our data collection pipelines to
+  # more easily identify code that we assume to be hot/cold that doesn't turn
+  # out to be such in the field.
+  use_text_section_splitting = is_chromeos
+
+  # Enable DWARF v5.
+  use_dwarf5 = false
+
+  # Override this to put full paths to PDBs in Windows PE files. This helps
+  # windbg and Windows Performance Analyzer with finding the PDBs in some local-
+  # build scenarios. This is never needed for bots or official builds. Because
+  # this puts the output directory in the DLLs/EXEs it breaks build determinism.
+  # Bugs have been reported to the windbg/WPA teams and this workaround will be
+  # removed when they are fixed.
+  use_full_pdb_paths = false
+
+  # Enable -H, which prints the include tree during compilation.
+  # For use by tools/clang/scripts/analyze_includes.py
+  show_includes = false
+
+  # Enable Profi algorithm. Profi can infer block and edge counts.
+  # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
+  # TODO(crbug.com/1375958i:) Possibly enable this for Android too.
+  use_profi = is_chromeos
+
+  # If true, linker crashes will be rerun with `--reproduce` which causes
+  # a reproducer file to be saved.
+  save_reproducers_on_lld_crash = false
+
+  # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
+  # shadow call stack in register x18. Hence, x18 must not be used by the OS
+  # or libraries. We assume that to be the case for high end Android
+  # configurations. For more details see
+  # https://clang.llvm.org/docs/ShadowCallStack.html
+  enable_shadow_call_stack = false
+
+  # Use DWARF simple template names, with the following exceptions:
+  #
+  # * Windows is not supported as it doesn't use DWARF.
+  # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
+  #   lldb doesn't have the needed changes yet.
+  # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
+  #
+  # This greatly reduces the size of debug builds, at the cost of
+  # debugging information which is required by some specialized
+  # debugging tools.
+  simple_template_names = is_clang && !is_nacl && !is_win && !is_apple
+}
+
+declare_args() {
+  # Set to true to use icf, Identical Code Folding.
+  #
+  # icf=all is broken in older golds, see
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+  # chromeos binutils has been patched with the fix, so always use icf there.
+  # The bug only affects x86 and x64, so we can still use ICF when targeting
+  # other architectures.
+  #
+  # lld doesn't have the bug.
+  use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer &&
+            !use_clang_coverage && current_os != "zos" &&
+            !(is_android && use_order_profiling) &&
+            (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" ||
+                                                       current_cpu == "x64"))))
+}
+
+if (is_android) {
+  # Set the path to use orderfile for linking Chrome
+  # Note that this is for using only one orderfile for linking
+  # the Chrome binary/library.
+  declare_args() {
+    chrome_orderfile_path = ""
+
+    if (defined(default_chrome_orderfile)) {
+      # Allow downstream tools to set orderfile path with
+      # another variable.
+      chrome_orderfile_path = default_chrome_orderfile
+    }
+  }
+}
+
+declare_args() {
+  # Turn off the --call-graph-profile-sort flag for lld by default. Enable
+  # selectively for targets where it's beneficial.
+  enable_call_graph_profile_sort =
+      chrome_pgo_phase == 2 ||
+      (is_chromeos &&
+       (clang_use_default_sample_profile || clang_sample_profile_path != ""))
+}
+
+assert(!(llvm_force_head_revision && use_goma),
+       "can't use goma with trunk clang")
+assert(!(llvm_force_head_revision && use_remoteexec),
+       "can't use rbe with trunk clang")
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+  include_dirs = [
+    "//",
+    root_gen_dir,
+  ]
+}
+
+# Compiler instrumentation can introduce dependencies in DSOs to symbols in
+# the executable they are loaded into, so they are unresolved at link-time.
+config("no_unresolved_symbols") {
+  if (!using_sanitizer &&
+      (is_linux || is_chromeos || is_android || is_fuchsia)) {
+    ldflags = [
+      "-Wl,-z,defs",
+      "-Wl,--as-needed",
+    ]
+  }
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  cflags_objc = []
+  cflags_objcc = []
+  rustflags = []
+  ldflags = []
+  defines = []
+  configs = []
+  rustflags = []
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:compiler" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:compiler" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:compiler" ]
+  } else if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:compiler" ]
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:compiler" ]
+  } else if (is_fuchsia) {
+    configs += [ "//build/config/fuchsia:compiler" ]
+  } else if (current_os == "aix") {
+    configs += [ "//build/config/aix:compiler" ]
+  } else if (current_os == "zos") {
+    configs += [ "//build/config/zos:compiler" ]
+  }
+
+  configs += [
+    # See the definitions below.
+    ":clang_revision",
+    ":rustc_revision",
+    ":compiler_cpu_abi",
+    ":compiler_codegen",
+    ":compiler_deterministic",
+  ]
+
+  # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
+  # operations (e.g. dereferencing) into defined behavior. This avoids deletion
+  # of some security-critical code: see https://crbug.com/1139129.
+  # Nacl does not support the flag. And, we still want UBSAN to catch undefined
+  # behavior related to nullptrs, so do not add this flag if UBSAN is enabled.
+  # GCC seems to have some bugs compiling constexpr code when this is defined,
+  # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
+  # TODO(mpdenton): remove is_clang once GCC bug is fixed.
+  if (!is_nacl && !is_ubsan && is_clang) {
+    cflags += [ "-fno-delete-null-pointer-checks" ]
+  }
+
+  # Don't emit the GCC version ident directives, they just end up in the
+  # .comment section or debug info taking up binary size, and makes comparing
+  # .o files built with different compiler versions harder.
+  if (!is_win || is_clang) {
+    cflags += [ "-fno-ident" ]
+  }
+
+  # In general, Windows is totally different, but all the other builds share
+  # some common compiler and linker configuration.
+  if (!is_win) {
+    # Common POSIX compiler flags setup.
+    # --------------------------------
+    cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204
+
+    # Stack protection. ShadowCallStack and Stack protector address the same
+    # problems. Therefore, we only enable one or the other. Clang advertises SCS as
+    # a stronger alternative to StackProtector, so we give SCS precedence over SP.
+    if (enable_shadow_call_stack) {
+      # On Aarch64, SCS requires the x18 register to be unused because it will hold
+      # a pointer to the shadow stack. For Android we know that Clang doesn't use
+      # x18 by default. On other OSs adding "-ffixed-x18" might be required.
+      assert(is_android)
+
+      scs_parameters = [
+        "-fsanitize=shadow-call-stack",
+        "-fno-stack-protector",
+      ]
+      cflags += scs_parameters
+      ldflags += scs_parameters
+    } else {
+      if (is_apple) {
+        # The strong variant of the stack protector significantly increases
+        # binary size, so only enable it in debug mode.
+        if (is_debug) {
+          cflags += [ "-fstack-protector-strong" ]
+        } else {
+          cflags += [ "-fstack-protector" ]
+        }
+      } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
+        # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+        # See also https://crbug.com/533294
+        # The x86 toolchain currently has problems with stack-protector.
+        if (is_android && current_cpu == "x86") {
+          cflags += [ "-fno-stack-protector" ]
+        } else if (current_os != "aix") {
+          # Not available on aix.
+          cflags += [ "-fstack-protector" ]
+        }
+      }
+    }
+
+    if (use_lld) {
+      ldflags += [ "-fuse-ld=lld" ]
+      if (lld_path != "") {
+        ldflags += [ "-B$lld_path" ]
+      }
+    }
+
+    # Linker warnings.
+    if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
+        current_os != "zos") {
+      ldflags += [ "-Wl,--fatal-warnings" ]
+    }
+    if (fatal_linker_warnings && is_apple) {
+      ldflags += [ "-Wl,-fatal_warnings" ]
+    }
+  }
+
+  if (is_clang && is_debug) {
+    # Allow comparing the address of references and 'this' against 0
+    # in debug builds. Technically, these can never be null in
+    # well-defined C/C++ and Clang can optimize such checks away in
+    # release builds, but they may be used in asserts in debug builds.
+    cflags_cc += [
+      "-Wno-undefined-bool-conversion",
+      "-Wno-tautological-undefined-compare",
+    ]
+  }
+
+  # Non-Apple Posix and Fuchsia compiler flags setup.
+  # -----------------------------------
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    if (enable_profiling) {
+      if (!is_debug) {
+        cflags += [ "-g" ]
+
+        if (enable_full_stack_frames_for_profiling) {
+          cflags += [
+            "-fno-inline",
+            "-fno-optimize-sibling-calls",
+          ]
+        }
+      }
+    }
+
+    # Explicitly pass --build-id to ld. Compilers used to always pass this
+    # implicitly but don't any more (in particular clang when built without
+    # ENABLE_LINKER_BUILD_ID=ON).
+    if (is_official_build) {
+      # The sha1 build id has lower risk of collision but is more expensive to
+      # compute, so only use it in the official build to avoid slowing down
+      # links.
+      ldflags += [ "-Wl,--build-id=sha1" ]
+    } else if (current_os != "aix" && current_os != "zos") {
+      ldflags += [ "-Wl,--build-id" ]
+    }
+
+    if (!is_android) {
+      defines += [
+        # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
+        # the behavior of the Android NDK from earlier versions.
+        # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
+        "_FILE_OFFSET_BITS=64",
+        "_LARGEFILE_SOURCE",
+        "_LARGEFILE64_SOURCE",
+      ]
+    }
+
+    if (!is_nacl) {
+      if (exclude_unwind_tables) {
+        cflags += [
+          "-fno-unwind-tables",
+          "-fno-asynchronous-unwind-tables",
+        ]
+        rustflags += [ "-Cforce-unwind-tables=no" ]
+        defines += [ "NO_UNWIND_TABLES" ]
+      } else {
+        cflags += [ "-funwind-tables" ]
+        rustflags += [ "-Cforce-unwind-tables=yes" ]
+      }
+    }
+  }
+
+  # Apple compiler flags setup.
+  # ---------------------------------
+  if (is_apple) {
+    # On Intel, clang emits both Apple's "compact unwind" information and
+    # DWARF eh_frame unwind information by default, for compatibility reasons.
+    # This flag limits emission of eh_frame information to functions
+    # whose unwind information can't be expressed in the compact unwind format
+    # (which in practice means almost everything gets only compact unwind
+    # entries). This reduces object file size a bit and makes linking a bit
+    # faster.
+    # On arm64, this is already the default behavior.
+    if (current_cpu == "x64") {
+      asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+      cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+    }
+  }
+
+  # Linux/Android/Fuchsia common flags setup.
+  # ---------------------------------
+  if (is_linux || is_chromeos || is_android || is_fuchsia) {
+    asmflags += [ "-fPIC" ]
+    cflags += [ "-fPIC" ]
+    ldflags += [ "-fPIC" ]
+    rustflags += [ "-Crelocation-model=pic" ]
+
+    if (!is_clang) {
+      # Use pipes for communicating between sub-processes. Faster.
+      # (This flag doesn't do anything with Clang.)
+      cflags += [ "-pipe" ]
+    }
+
+    ldflags += [
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+    ]
+
+    if (!is_component_build) {
+      ldflags += [ "-Wl,-z,now" ]
+    }
+  }
+
+  # Linux-specific compiler flags setup.
+  # ------------------------------------
+  if (use_gold) {
+    ldflags += [ "-fuse-ld=gold" ]
+    if (!is_android) {
+      # On Android, this isn't needed.  gcc in the NDK knows to look next to
+      # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+      # above.
+      if (gold_path != "") {
+        ldflags += [ "-B$gold_path" ]
+      }
+
+      ldflags += [
+        # Experimentation found that using four linking threads
+        # saved ~20% of link time.
+        # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+        # Only apply this to the target linker, since the host
+        # linker might not be gold, but isn't used much anyway.
+        "-Wl,--threads",
+        "-Wl,--thread-count=4",
+      ]
+    }
+
+    # TODO(thestig): Make this flag work with GN.
+    #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+    #  ldflags += [
+    #    "-Wl,--detect-odr-violations",
+    #  ]
+    #}
+  }
+
+  if (use_icf && (!is_apple || use_lld)) {
+    ldflags += [ "-Wl,--icf=all" ]
+  }
+
+  if (is_linux || is_chromeos) {
+    cflags += [ "-pthread" ]
+    # Do not use the -pthread ldflag here since it becomes a no-op
+    # when using -nodefaultlibs, which would cause an unused argument
+    # error.  "-lpthread" is added in //build/config:default_libs.
+  }
+
+  # Clang-specific compiler flags setup.
+  # ------------------------------------
+  if (is_clang) {
+    cflags += [ "-fcolor-diagnostics" ]
+
+    # Enable -fmerge-all-constants. This used to be the default in clang
+    # for over a decade. It makes clang non-conforming, but is fairly safe
+    # in practice and saves some binary size. We might want to consider
+    # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13),
+    # but for now it looks like our build might rely on it
+    # (https://crbug.com/829795).
+    cflags += [ "-fmerge-all-constants" ]
+  }
+
+  if (use_lld) {
+    # TODO(thakis): Make the driver pass --color-diagnostics to the linker
+    # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
+    # in ldflags instead.
+    if (is_win) {
+      # On Windows, we call the linker directly, instead of calling it through
+      # the driver.
+      ldflags += [ "--color-diagnostics" ]
+    } else {
+      ldflags += [ "-Wl,--color-diagnostics" ]
+    }
+  }
+
+  # Enable text section splitting only on linux when using lld for now. Other
+  # platforms can be added later if needed.
+  if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) {
+    ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
+  }
+
+  if (is_clang && !is_nacl && current_os != "zos") {
+    cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
+    if (save_reproducers_on_lld_crash && use_lld) {
+      ldflags += [
+        "-fcrash-diagnostics=all",
+        "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
+      ]
+    }
+
+    # TODO(hans): Remove this once Clang generates better optimized debug info
+    # by default. https://crbug.com/765793
+    cflags += [
+      "-mllvm",
+      "-instcombine-lower-dbg-declare=0",
+    ]
+    if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+      if (is_win) {
+        ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
+      } else {
+        ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
+      }
+    }
+
+    # TODO(crbug.com/1235145): Investigate why/if this should be needed.
+    if (is_win) {
+      cflags += [ "/clang:-ffp-contract=off" ]
+    } else {
+      cflags += [ "-ffp-contract=off" ]
+    }
+  }
+
+  # C11/C++11 compiler flags setup.
+  # ---------------------------
+  if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
+      current_os == "aix") {
+    if (is_clang) {
+      standard_prefix = "c"
+
+      # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
+      # defined by the compiler.  However, lots of code relies on the
+      # non-standard features that _GNU_SOURCE enables, so define it manually.
+      defines += [ "_GNU_SOURCE" ]
+
+      if (is_nacl) {
+        # Undefine __STRICT_ANSI__ to get non-standard features which would
+        # otherwise not be enabled by NaCl's sysroots.
+        cflags += [ "-U__STRICT_ANSI__" ]
+      }
+    } else {
+      # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
+      # but we use this feature in several places in Chromium.
+      # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the
+      # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
+      # to -std=c*.
+      standard_prefix = "gnu"
+    }
+
+    cflags_c += [ "-std=${standard_prefix}11" ]
+    if (is_nacl && !is_nacl_saigo) {
+      # This is for the pnacl_newlib toolchain. It's only used to build
+      # a few independent ppapi test files that don't pull in any other
+      # dependencies.
+      cflags_cc += [ "-std=${standard_prefix}++14" ]
+      if (is_clang) {
+        cflags_cc += [ "-fno-trigraphs" ]
+      }
+    } else if (is_clang) {
+      if (defined(use_cxx17) && use_cxx17) {
+        cflags_cc += [ "-std=${standard_prefix}++17" ]
+      } else {
+        cflags_cc += [ "-std=${standard_prefix}++20" ]
+      }
+    } else {
+      # The gcc bots are currently using GCC 9, which is not new enough to
+      # support "c++20"/"gnu++20".
+      cflags_cc += [ "-std=${standard_prefix}++2a" ]
+    }
+  } else if (is_win) {
+    cflags_c += [ "/std:c11" ]
+    if ((defined(use_cxx17) && use_cxx17) ||
+        (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) {
+      cflags_cc += [ "/std:c++17" ]
+    } else {
+      cflags_cc += [ "/std:c++20" ]
+    }
+  } else if (!is_nacl) {
+    # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
+    # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
+    # more, but there are still a few buildbots using it, so until those are
+    # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
+    # clause, above.
+    cflags_c += [ "-std=c11" ]
+
+    if (defined(use_cxx17) && use_cxx17) {
+      cflags_cc += [ "-std=c++17" ]
+    } else {
+      cflags_cc += [ "-std=c++20" ]
+    }
+  }
+
+  if (is_clang && current_os != "zos") {
+    # C++17 removes trigraph support, but clang still warns that it ignores
+    # them when seeing them.  Don't.
+    cflags_cc += [ "-Wno-trigraphs" ]
+  }
+
+  if (use_relative_vtables_abi) {
+    cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
+    ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
+  }
+
+  # Add flags for link-time optimization. These flags enable
+  # optimizations/transformations that require whole-program visibility at link
+  # time, so they need to be applied to all translation units, and we may end up
+  # with miscompiles if only part of the program is compiled with LTO flags. For
+  # that reason, we cannot allow targets to enable or disable these flags, for
+  # example by disabling the optimize configuration.
+  # TODO(pcc): Make this conditional on is_official_build rather than on gn
+  # flags for specific features.
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    assert(use_lld, "LTO is only supported with lld")
+
+    cflags += [
+      "-flto=thin",
+      "-fsplit-lto-unit",
+    ]
+
+    # Limit the size of the ThinLTO cache to the lesser of 10% of
+    # available disk space, 40GB and 100000 files.
+    cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000"
+
+    # An import limit of 30 has better performance (per speedometer) and lower
+    # binary size than the default setting of 100.
+    # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
+    # should be able to better manage binary size increases on its own.
+    import_instr_limit = 30
+
+    if (is_win) {
+      ldflags += [
+        "/opt:lldltojobs=all",
+        "-mllvm:-import-instr-limit=$import_instr_limit",
+        "/lldltocache:" +
+            rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+        "/lldltocachepolicy:$cache_policy",
+        "-mllvm:-disable-auto-upgrade-debug-info",
+      ]
+    } else {
+      ldflags += [ "-flto=thin" ]
+
+      # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory
+      # usage in crbug.com/1038040. Note this will increase build time in
+      # Chrome OS.
+
+      # In ThinLTO builds, we run at most one link process at a time,
+      # and let it use all cores.
+      # TODO(thakis): Check if '=0' (that is, number of cores, instead
+      # of "all" which means number of hardware threads) is faster.
+      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_apple) {
+        ldflags += [
+          "-Wl,-cache_path_lto," +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+          "-Wcrl,object_path_lto",
+        ]
+      } else {
+        ldflags +=
+            [ "-Wl,--thinlto-cache-dir=" +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ]
+      }
+
+      ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+
+      if (is_chromeos) {
+        # ARM was originally set lower than x86 to keep the size
+        # bloat of ThinLTO to <10%, but that's potentially no longer true.
+        # FIXME(inglorion): maybe tune these?
+        # TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
+        import_instr_limit = 20
+      } else if (is_android) {
+        # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win
+        # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB.
+        import_instr_limit = 5
+      }
+
+      ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
+
+      if (!is_chromeos) {
+        # TODO(https://crbug.com/972449): turn on for ChromeOS when that
+        # toolchain has this flag.
+        # We only use one version of LLVM within a build so there's no need to
+        # upgrade debug info, which can be expensive since it runs the verifier.
+        ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
+      }
+    }
+
+    # TODO(https://crbug.com/1211155): investigate why this isn't effective on
+    # arm32.
+    if (!is_android || current_cpu == "arm64") {
+      cflags += [ "-fwhole-program-vtables" ]
+
+      if (toolchain_supports_rust_thin_lto) {
+        # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
+        # behaviour. Rust needs to know the linker will be doing LTO in this case
+        # or it rejects the Zsplit-lto-unit flag.
+        rustflags += [
+          "-Zsplit-lto-unit",
+          "-Clinker-plugin-lto=yes",
+        ]
+      } else {
+        # Don't include bitcode if it won't be used.
+        rustflags += [ "-Cembed-bitcode=no" ]
+      }
+
+      if (!is_win) {
+        ldflags += [ "-fwhole-program-vtables" ]
+      }
+    }
+
+    # This flag causes LTO to create an .ARM.attributes section with the correct
+    # architecture. This is necessary because LLD will refuse to link a program
+    # unless the architecture revision in .ARM.attributes is sufficiently new.
+    # TODO(pcc): The contents of .ARM.attributes should be based on the
+    # -march flag passed at compile time (see llvm.org/pr36291).
+    if (current_cpu == "arm") {
+      ldflags += [ "-march=$arm_arch" ]
+    }
+  }
+
+  if (compiler_timing) {
+    if (is_clang && !is_nacl) {
+      cflags += [ "-ftime-trace" ]
+    } else if (is_win) {
+      cflags += [
+        # "Documented" here:
+        # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
+        "/d2cgsummary",
+      ]
+    }
+  }
+
+  # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize
+  # stack crashes (http://crbug.com/919499).
+  if (use_lld && is_android) {
+    ldflags += [ "-Wl,--no-rosegment" ]
+  }
+
+  # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+  # --no-undefined-version.
+  if (use_lld && !is_win && !is_mac && !is_ios) {
+    ldflags += [ "-Wl,--undefined-version" ]
+  }
+
+  if (use_lld && is_apple) {
+    ldflags += [ "-Wl,--strict-auto-link" ]
+  }
+
+  # LLD does call-graph-sorted binary layout by default when profile data is
+  # present. On Android this increases binary size due to more thinks for long
+  # jumps. Turn it off by default and enable selectively for targets where it's
+  # beneficial.
+  if (use_lld && !enable_call_graph_profile_sort) {
+    if (is_win) {
+      ldflags += [ "/call-graph-profile-sort:no" ]
+    } else {
+      ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
+    }
+  }
+
+  if (is_clang && !is_nacl && show_includes) {
+    if (is_win) {
+      # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
+      assert(!use_goma, "show_includes on Windows is not reliable with goma")
+      cflags += [
+        "/clang:-H",
+        "/clang:-fshow-skipped-includes",
+      ]
+    } else {
+      cflags += [
+        "-H",
+        "-fshow-skipped-includes",
+      ]
+    }
+  }
+
+  # This flag enforces that member pointer base types are complete. It helps
+  # prevent us from running into problems in the Microsoft C++ ABI (see
+  # https://crbug.com/847724).
+  if (is_clang && !is_nacl && target_os != "chromeos" &&
+      (is_win || use_custom_libcxx)) {
+    cflags += [ "-fcomplete-member-pointers" ]
+  }
+
+  # Use DWARF simple template names.
+  if (simple_template_names) {
+    cflags_cc += [ "-gsimple-template-names" ]
+  }
+
+  # MLGO specific flags. These flags enable an ML-based inliner trained on
+  # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
+  # The "release" ML model is embedded into clang as part of its build.
+  # Currently, the ML inliner is only enabled when targeting Android due to:
+  # a) Android is where size matters the most.
+  # b) MLGO presently has the limitation of only being able to embed one model
+  #    at a time; It is unclear if the embedded model is beneficial for
+  #    non-Android targets.
+  # MLGO is only officially supported on linux.
+  if (use_ml_inliner && is_a_target_toolchain) {
+    assert(
+        is_android && host_os == "linux",
+        "MLGO is currently only supported for targeting Android on a linux host")
+    if (use_thin_lto) {
+      ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
+    }
+  }
+
+  if (clang_embed_bitcode) {
+    assert(!use_thin_lto,
+           "clang_embed_bitcode is only supported in non-ThinLTO builds")
+    cflags += [
+      "-Xclang",
+      "-fembed-bitcode=all",
+    ]
+  }
+
+  if (lld_emit_indexes_and_imports) {
+    assert(use_thin_lto,
+           "lld_emit_indexes_and_imports is only supported with ThinLTO builds")
+    ldflags += [
+      "-Wl,--save-temps=import",
+      "-Wl,--thinlto-emit-index-files",
+    ]
+  }
+
+  # Pass the same C/C++ flags to the objective C/C++ compiler.
+  cflags_objc += cflags_c
+  cflags_objcc += cflags_cc
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler. The Windows assembler takes different types of flags
+  # so only do so for posix platforms.
+  if (is_posix || is_fuchsia) {
+    asmflags += cflags
+    asmflags += cflags_c
+  }
+
+  if (is_chromeos_device && !is_nacl) {
+    # On ChromeOS devices, we want to ensure we're using Chrome's allocator
+    # symbols for all C++ new/delete operator overloads. PartitionAlloc
+    # and other local allocators should always take precedence over system or
+    # preloaded allocators. These are the mangled symbol names.
+    # See b/280115910 for details.
+    ldflags += [
+      "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
+      "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
+      "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
+      "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
+      "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
+      "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
+    ]
+  }
+
+  # Rust compiler flags setup.
+  # ---------------------------
+  rustflags += [
+    # Overflow checks are optional in Rust, but even if switched
+    # off they do not cause undefined behavior (the overflowing
+    # behavior is defined). Because containers are bounds-checked
+    # in safe Rust, they also can't provoke buffer overflows.
+    # As such these checks may be less important in Rust than C++.
+    # But in (simplistic) testing they have negligible performance
+    # overhead, and this helps to provide consistent behavior
+    # between different configurations, so we'll keep them on until
+    # we discover a reason to turn them off.
+    "-Coverflow-checks=on",
+
+    # By default Rust passes `-nodefaultlibs` to the linker, however this
+    # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
+    # is then unused and produces a warning/error. So this removes the
+    # `-nodefaultlibs` from the linker invocation from Rust, which would be used
+    # to compile dylibs on Android, such as for constructing unit test APKs.
+    "-Cdefault-linker-libraries",
+
+    # To make Rust .d files compatible with ninja
+    "-Zdep-info-omit-d-target",
+
+    # If a macro panics during compilation, show which macro and where it is
+    # defined.
+    "-Zmacro-backtrace",
+
+    # For deterministic builds, keep the local machine's current working
+    # directory from appearing in build outputs.
+    "-Zremap-cwd-prefix=.",
+  ]
+
+  if (!is_win || force_rustc_color_output) {
+    # Colorize error output. The analogous flag is passed for clang. This must
+    # be platform-gated since rustc will unconditionally output ANSI escape
+    # sequences, ignoring the platform, when stderr is not a terminal.
+    rustflags += [ "--color=always" ]
+  }
+  if (rust_abi_target != "") {
+    rustflags += [ "--target=$rust_abi_target" ]
+  }
+  if (!use_thin_lto) {
+    # Don't include bitcode if it won't be used.
+    rustflags += [ "-Cembed-bitcode=no" ]
+  }
+  if (is_official_build) {
+    rustflags += [ "-Ccodegen-units=1" ]
+  }
+  if (!rust_prebuilt_stdlib) {
+    # When building against the Chromium Rust stdlib (which we compile) always
+    # abort instead of unwinding when panic occurs. In official builds, panics
+    # abort immediately (this is configured in the stdlib) to keep binary size
+    # down. So we unconditionally match behaviour in unofficial too.
+    rustflags += [
+      "-Cpanic=abort",
+      "-Zpanic_abort_tests",
+    ]
+  }
+
+  # Normally, this would be defined in the `runtime_library` config but NaCl
+  # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there
+  # isn't really a better config to add this define for the define to
+  # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
+  # and NaCl code.
+  #
+  # TODO(https://crbug.com/702997): Move this back to the `runtime_library`
+  # config when NaCl is removed.
+  if (use_safe_libcxx) {
+    # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once
+    # it's rolled in.
+    if (is_nacl_saigo) {
+      defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
+    } else {
+      defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ]
+    }
+  }
+}
+
+# The BUILDCONFIG file sets this config on targets by default, which means when
+# building with ThinLTO, no optimization is performed in the link step.
+config("thinlto_optimize_default") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    lto_opt_level = 0
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# Use this to enable optimization in the ThinLTO link step for select targets
+# when thin_lto_enable_optimizations is set by doing:
+#
+#   configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
+#   configs += [ "//build/config/compiler:thinlto_optimize_max" ]
+#
+# Since it makes linking significantly slower and more resource intensive, only
+# use it on important targets such as the main browser executable or dll.
+config("thinlto_optimize_max") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    if (thin_lto_enable_optimizations) {
+      lto_opt_level = 2
+    } else {
+      lto_opt_level = 0
+    }
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+  defines = []
+
+  configs = []
+  if (is_chromeos) {
+    configs += [ "//build/config/chromeos:compiler_cpu_abi" ]
+  }
+
+  # TODO(https://crbug.com/1383873): Remove this once figured out.
+  if (is_apple && current_cpu == "arm64") {
+    cflags += [ "-fno-global-isel" ]
+    ldflags += [ "-fno-global-isel" ]
+  }
+
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "-m64",
+        "-msse3",
+      ]
+      ldflags += [ "-m64" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+      if (!is_nacl) {
+        cflags += [
+          "-mfpmath=sse",
+          "-msse3",
+        ]
+      }
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=arm-linux-gnueabihf" ]
+        ldflags += [ "--target=arm-linux-gnueabihf" ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "arm64") {
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=@AARCH64_TARGET@" ]
+        ldflags += [ "--target=@AARCH64_TARGET@" ]
+      }
+    } else if (current_cpu == "mipsel" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mipsel-linux-android" ]
+            ldflags += [ "--target=mipsel-linux-android" ]
+          } else {
+            cflags += [ "--target=mipsel-linux-gnu" ]
+            ldflags += [ "--target=mipsel-linux-gnu" ]
+          }
+        } else {
+          cflags += [ "-EL" ]
+          ldflags += [ "-EL" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [ "-mno-odd-spreg" ]
+        ldflags += [ "-mips32r6" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r6",
+          ]
+        } else {
+          cflags += [
+            "-mips32r6",
+            "-Wa,-mips32r6",
+          ]
+          if (is_android) {
+            ldflags += [ "-Wl,-melf32ltsmip" ]
+          }
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips32r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r2",
+          ]
+        } else {
+          cflags += [
+            "-mips32r2",
+            "-Wa,-mips32r2",
+          ]
+          if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+            cflags += [ "-m$mips_fpu_mode" ]
+          }
+        }
+      } else if (mips_arch_variant == "r1") {
+        ldflags += [ "-mips32" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32",
+          ]
+        } else {
+          cflags += [
+            "-mips32",
+            "-Wa,-mips32",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips-linux-gnu" ]
+          ldflags += [ "--target=mips-linux-gnu" ]
+        } else {
+          cflags += [ "-EB" ]
+          ldflags += [ "-EB" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mips64el-linux-android" ]
+            ldflags += [ "--target=mips64el-linux-android" ]
+          } else {
+            cflags += [ "--target=mips64el-linux-gnuabi64" ]
+            ldflags += [ "--target=mips64el-linux-gnuabi64" ]
+          }
+        } else {
+          cflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r6",
+          ]
+        } else {
+          cflags += [
+            "-mips64r6",
+            "-Wa,-mips64r6",
+          ]
+          ldflags += [ "-mips64r6" ]
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips64r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r2",
+          ]
+        } else {
+          cflags += [
+            "-mips64r2",
+            "-Wa,-mips64r2",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+    } else if (current_cpu == "mips64") {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips64-linux-gnuabi64" ]
+          ldflags += [ "--target=mips64-linux-gnuabi64" ]
+        } else {
+          cflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    } else if (current_cpu == "ppc64") {
+      if (current_os == "aix") {
+        cflags += [ "-maix64" ]
+        ldflags += [ "-maix64" ]
+      } else {
+        cflags += [ "-m64" ]
+        ldflags += [ "-m64" ]
+      }
+    } else if (current_cpu == "riscv64") {
+      if (is_clang && !is_android) {
+        cflags += [ "--target=riscv64-linux-gnu" ]
+        ldflags += [ "--target=riscv64-linux-gnu" ]
+      }
+      cflags += [ "-mabi=lp64d" ]
+    } else if (current_cpu == "loong64") {
+      if (is_clang) {
+        cflags += [ "--target=loongarch64-linux-gnu" ]
+        ldflags += [ "--target=loongarch64-linux-gnu" ]
+      }
+      cflags += [
+        "-mabi=lp64d",
+        "-mcmodel=medium",
+      ]
+    } else if (current_cpu == "s390x") {
+      cflags += [ "-m64" ]
+      ldflags += [ "-m64" ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+  configs = []
+  cflags = []
+  ldflags = []
+
+  if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler_codegen" ]
+  }
+
+  if (current_cpu == "arm64" && !is_win && is_clang) {
+    # Disable outlining everywhere on arm64 except Win. For more information see
+    # crbug.com/931297 for Android and crbug.com/1410297 for iOS.
+    # TODO(crbug.com/1411363): Enable this on Windows if possible.
+    cflags += [ "-mno-outline" ]
+
+    # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
+    # has been resolved, and -mno-outline is obeyed by the linker during
+    # ThinLTO.
+    ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
+  }
+
+  asmflags = cflags
+}
+
+# This provides options that make the build deterministic, so that the same
+# revision produces the same output, independent of the name of the build
+# directory and of the computer the build is done on.
+# The relative path from build dir to source dir makes it into the build
+# outputs, so it's recommended that you use a build dir two levels deep
+# (e.g. "out/Release") so that you get the same "../.." path as all the bots
+# in your build outputs.
+config("compiler_deterministic") {
+  cflags = []
+  ldflags = []
+  swiftflags = []
+
+  # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+  # deterministic build.  See https://crbug.com/314403
+  if (!is_official_build) {
+    if (is_win && !is_clang) {
+      cflags += [
+        "/wd4117",  # Trying to define or undefine a predefined macro.
+        "/D__DATE__=",
+        "/D__TIME__=",
+        "/D__TIMESTAMP__=",
+      ]
+    } else {
+      cflags += [
+        "-Wno-builtin-macro-redefined",
+        "-D__DATE__=",
+        "-D__TIME__=",
+        "-D__TIMESTAMP__=",
+      ]
+    }
+  }
+
+  # Makes builds independent of absolute file path.
+  if (is_clang && strip_absolute_paths_from_debug_symbols) {
+    # If debug option is given, clang includes $cwd in debug info by default.
+    # For such build, this flag generates reproducible obj files even we use
+    # 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=." ]
+      swiftflags += [ "-file-compilation-dir=." ]
+    }
+    if (!is_win) {
+      # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+      asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+    }
+
+    if (is_win && use_lld) {
+      if (symbol_level == 2 || (is_clang && using_sanitizer)) {
+        # Absolutize source file paths for PDB. Pass the real build directory
+        # if the pdb contains source-level debug information and if linker
+        # reproducibility is not critical.
+        ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ]
+      } else {
+        # Use a fake fixed base directory for paths in the pdb to make the pdb
+        # output fully deterministic and independent of the build directory.
+        ldflags += [ "/PDBSourcePath:o:\fake\prefix" ]
+      }
+    }
+  }
+
+  # Tells the compiler not to use absolute paths when passing the default
+  # paths to the tools it invokes. We don't want this because we don't
+  # really need it and it can mess up the goma cache entries.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags += [ "-no-canonical-prefixes" ]
+
+    # Same for links: Let the compiler driver invoke the linker
+    # with a relative path and pass relative paths to built-in
+    # libraries. Not needed on Windows because we call the linker
+    # directly there, not through the compiler driver.
+    # We don't link on goma, so this change is just for cleaner
+    # internal linker invocations, for people who work on the build.
+    if (!is_win) {
+      ldflags += [ "-no-canonical-prefixes" ]
+    }
+  }
+}
+
+config("clang_revision") {
+  if (is_clang && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
+config("rustc_revision") {
+  if (rustc_revision != "") {
+    # Similar to the above config, this is here so that all files get recompiled
+    # after a rustc roll. Nothing should ever read this cfg. This will not be
+    # set if a custom toolchain is used.
+    rustflags = [
+      "--cfg",
+      "cr_rustc_revision=\"$rustc_revision\"",
+    ]
+  }
+}
+
+config("compiler_arm_fpu") {
+  if (current_cpu == "arm" && !is_ios && !is_nacl) {
+    cflags = [ "-mfpu=$arm_fpu" ]
+    if (!arm_use_thumb) {
+      cflags += [ "-marm" ]
+    }
+    asmflags = cflags
+  }
+}
+
+config("compiler_arm_thumb") {
+  if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+      !(is_apple || is_nacl)) {
+    cflags = [ "-mthumb" ]
+  }
+}
+
+config("compiler_arm") {
+  if (current_cpu == "arm" && is_chromeos) {
+    # arm is normally the default mode for clang, but on chromeos a wrapper
+    # is used to pass -mthumb, and therefor change the default.
+    cflags = [ "-marm" ]
+  }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+  configs = []
+
+  # The order of this config is important: it must appear before
+  # android:runtime_library.  This is to ensure libc++ appears before
+  # libandroid_support in the -isystem include order.  Otherwise, there will be
+  # build errors related to symbols declared in math.h.
+  if (use_custom_libcxx) {
+    configs += [ "//build/config/c++:runtime_library" ]
+  }
+
+  # Rust and C++ both provide intrinsics for LLVM to call for math operations. We
+  # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins
+  # library. The Rust symbols are marked as weak, so that they can be replaced by
+  # the C++ symbols. This config ensures the C++ symbols exist and are strong in
+  # order to cause that replacement to occur by explicitly linking in clang's
+  # compiler-rt library.
+  if (is_clang && toolchain_has_rust) {
+    configs += [ "//build/config/clang:compiler_builtins" ]
+  }
+
+  # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia
+  # configuration.
+  if (is_posix || is_fuchsia) {
+    configs += [ "//build/config/posix:runtime_library" ]
+
+    if (use_custom_libunwind) {
+      # Instead of using an unwind lib from the toolchain,
+      # buildtools/third_party/libunwind will be built and used directly.
+      ldflags = [ "--unwindlib=none" ]
+    }
+  }
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:runtime_library" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:runtime_library" ]
+    if (is_chromeos) {
+      configs += [ "//build/config/chromeos:runtime_library" ]
+    }
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:runtime_library" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:runtime_library" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:runtime_library" ]
+  }
+
+  if (is_component_build) {
+    defines = [ "COMPONENT_BUILD" ]
+  }
+}
+
+# treat_warnings_as_errors ----------------------------------------------------
+#
+# Adding this config causes the compiler to treat warnings as fatal errors.
+# This is used as a subconfig of both chromium_code and no_chromium_code, and
+# is broken out separately so nocompile tests can force-enable this setting
+# independently of the default warning flags.
+config("treat_warnings_as_errors") {
+  if (is_win) {
+    cflags = [ "/WX" ]
+  } else {
+    cflags = [ "-Werror" ]
+
+    # The compiler driver can sometimes (rarely) emit warnings before calling
+    # the actual linker.  Make sure these warnings are treated as errors as
+    # well.
+    ldflags = [ "-Werror" ]
+  }
+
+  # Turn rustc warnings into the "deny" lint level, which produce compiler
+  # errors. The equivalent of -Werror for clang/gcc.
+  #
+  # Note we apply the actual lint flags in config("compiler"). All warnings
+  # are suppressed in third-party crates.
+  rustflags = [ "-Dwarnings" ]
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default.  This is used as a
+# subconfig of both chromium_code and no_chromium_code.  This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  ldflags = []
+  configs = []
+
+  if (is_win) {
+    if (fatal_linker_warnings) {
+      arflags = [ "/WX" ]
+      ldflags = [ "/WX" ]
+    }
+    defines = [
+      # Without this, Windows headers warn that functions like wcsnicmp
+      # should be spelled _wcsnicmp. But all other platforms keep spelling
+      # it wcsnicmp, making this warning unhelpful. We don't want it.
+      "_CRT_NONSTDC_NO_WARNINGS",
+
+      # TODO(thakis): winsock wants us to use getaddrinfo instead of
+      # gethostbyname. Fires mostly in non-Chromium code. We probably
+      # want to remove this define eventually.
+      "_WINSOCK_DEPRECATED_NO_WARNINGS",
+    ]
+    if (!is_clang) {
+      # TODO(thakis): Remove this once
+      # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
+      # rolled into angle.
+      cflags += [ "/wd4244" ]
+    }
+  } else {
+    if (is_apple && !is_nacl) {
+      # When compiling Objective-C, warns if a method is used whose
+      # availability is newer than the deployment target.
+      cflags += [ "-Wunguarded-availability" ]
+    }
+
+    if (is_ios) {
+      # When compiling Objective-C, warns if a selector named via @selector has
+      # not been defined in any visible interface.
+      cflags += [ "-Wundeclared-selector" ]
+    }
+
+    # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+    # warning).
+    if (current_cpu == "arm" && !is_clang) {
+      cflags += [ "-Wno-psabi" ]
+    }
+
+    if (!is_clang) {
+      cflags_cc += [
+        # See comment for -Wno-c++11-narrowing.
+        "-Wno-narrowing",
+      ]
+
+      # -Wno-class-memaccess warns about hash table and vector in blink.
+      # But the violation is intentional.
+      if (!is_nacl) {
+        cflags_cc += [ "-Wno-class-memaccess" ]
+      }
+
+      # -Wunused-local-typedefs is broken in gcc,
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
+      cflags += [ "-Wno-unused-local-typedefs" ]
+
+      # Don't warn about "maybe" uninitialized. Clang doesn't include this
+      # in -Wall but gcc does, and it gives false positives.
+      cflags += [ "-Wno-maybe-uninitialized" ]
+      cflags += [ "-Wno-deprecated-declarations" ]
+
+      # -Wcomment gives too many false positives in the case a
+      # backslash ended comment line is followed by a new line of
+      # comments
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
+      cflags += [ "-Wno-comments" ]
+
+      # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
+      # files.
+      cflags += [ "-Wno-packed-not-aligned" ]
+    }
+  }
+
+  # Common Clang and GCC warning setup.
+  if (!is_win || is_clang) {
+    cflags += [
+      # Disables.
+      "-Wno-missing-field-initializers",  # "struct foo f = {0};"
+      "-Wno-unused-parameter",  # Unused function parameters.
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # An ABI compat warning we don't care about, https://crbug.com/1102157
+        # TODO(thakis): Push this to the (few) targets that need it,
+        # instead of having a global flag.
+        "-Wno-psabi",
+      ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      "-Wloop-analysis",
+
+      # TODO(thakis): This used to be implied by -Wno-unused-function,
+      # which we no longer use. Check if it makes sense to remove
+      # this as well. http://crbug.com/316352
+      "-Wno-unneeded-internal-declaration",
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      if (is_win) {
+        # TODO(thakis): https://crbug.com/617318
+        # Currently goma can not handle case sensitiveness for windows well.
+        cflags += [ "-Wno-nonportable-include-path" ]
+      }
+
+      if (is_fuchsia) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1474434): fix and reenable
+          "-Wno-missing-field-initializers",
+        ]
+      }
+
+      cflags += [
+        "-Wenum-compare-conditional",
+
+        # Ignore warnings about MSVC optimization pragmas.
+        # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
+        "-Wno-ignored-pragma-optimize",
+      ]
+
+      if (!is_nacl) {
+        cflags += [
+          # TODO(crbug.com/1343975) Evaluate and possibly enable.
+          "-Wno-deprecated-builtins",
+
+          # TODO(crbug.com/1352183) Evaluate and possibly enable.
+          "-Wno-bitfield-constant-conversion",
+
+          # TODO(crbug.com/1412713) Evaluate and possibly enable.
+          "-Wno-deprecated-this-capture",
+        ]
+      }
+    }
+
+    # Some builders, such as Cronet, use a different version of Clang than
+    # Chromium. This can cause minor errors when compiling Chromium changes. We
+    # want to avoid these errors.
+    if (llvm_android_mainline) {
+      cflags += [
+        "-Wno-error=unknown-warning-option",
+        "-Wno-error=unused-command-line-argument",
+      ]
+    }
+  }
+
+  # Rust warnings
+
+  # Require `unsafe` blocks even in `unsafe` fns. This is intended to become
+  # an error by default eventually; see
+  # https://github.com/rust-lang/rust/issues/71668
+  rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
+}
+
+# prevent_unsafe_narrowing ----------------------------------------------------
+#
+# Warnings that prevent narrowing or comparisons of integer types that are
+# likely to cause out-of-bound read/writes or Undefined Behaviour. In
+# particular, size_t is used for memory sizes, allocation, indexing, and
+# offsets. Using other integer types along with size_t produces risk of
+# memory-safety bugs and thus security exploits.
+#
+# In order to prevent these bugs, allocation sizes were historically limited to
+# sizes that can be represented within 31 bits of information, allowing `int` to
+# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
+# support increasing the allocation limit we require strictly adherence to
+# using the correct types, avoiding lossy conversions, and preventing overflow.
+# To do so, enable this config and fix errors by converting types to be
+# `size_t`, which is both large enough and unsigned, when dealing with memory
+# sizes, allocations, indices, or offsets.In cases where type conversion is not
+# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
+# to convert to size_t as needed.
+# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
+#
+# To enable in a GN target, use:
+#   configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
+
+config("prevent_unsafe_narrowing") {
+  if (is_clang) {
+    cflags = [
+      "-Wshorten-64-to-32",
+      "-Wimplicit-int-conversion",
+      "-Wsign-compare",
+      "-Wsign-conversion",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
+        # fixing types to be sign-correct.
+        "-Wtautological-unsigned-zero-compare",
+      ]
+    }
+  }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+  if (is_win) {
+    if (is_clang) {
+      cflags = [ "/W4" ]  # Warning level 4.
+
+      # Opt in to additional [[nodiscard]] on standard library methods.
+      defines = [ "_HAS_NODISCARD" ]
+    }
+  } else {
+    cflags = [ "-Wall" ]
+    if (is_clang) {
+      # Enable extra warnings for chromium_code when we control the compiler.
+      cflags += [ "-Wextra" ]
+    }
+
+    # In Chromium code, we define __STDC_foo_MACROS in order to get the
+    # C99 macros on Mac and Linux.
+    defines = [
+      "__STDC_CONSTANT_MACROS",
+      "__STDC_FORMAT_MACROS",
+    ]
+
+    if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+        current_cpu != "s390" && current_cpu != "ppc64" &&
+        current_cpu != "mips" && current_cpu != "mips64" &&
+        current_cpu != "riscv64" && current_cpu != "loong64") {
+      # Non-chromium code is not guaranteed to compile cleanly with
+      # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+      # disabled, so only do that for Release build.
+      fortify_level = "2"
+
+      # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation
+      # with a few custom glibc patches. Use that if it's available.
+      if (is_chromeos_ash) {
+        fortify_level = "3"
+      }
+      defines += [ "_FORTIFY_SOURCE=" + fortify_level ]
+    }
+
+    if (is_apple) {
+      cflags_objc = [ "-Wimplicit-retain-self" ]
+      cflags_objcc = [ "-Wimplicit-retain-self" ]
+    }
+
+    if (is_mac) {
+      cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
+      cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Warn on missing break statements at the end of switch cases.
+      # For intentional fallthrough, use [[fallthrough]].
+      "-Wimplicit-fallthrough",
+
+      # Warn on unnecessary extra semicolons outside of function definitions.
+      "-Wextra-semi",
+
+      # Warn on unreachable code, including unreachable breaks and returns.
+      # See https://crbug.com/346399#c148 for suppression strategies.
+      "-Wunreachable-code-aggressive",
+    ]
+
+    # Thread safety analysis is broken under nacl: https://crbug.com/982423.
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # Thread safety analysis. See base/thread_annotations.h and
+        # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
+        "-Wthread-safety",
+      ]
+    }
+  }
+
+  configs = [
+    ":default_warnings",
+    ":noshadowing",
+  ]
+  if (treat_warnings_as_errors) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
+  if (is_win) {
+    if (is_clang) {
+      cflags += [ "/W3" ]  # Warning level 3.
+    }
+    cflags += [
+      "/wd4800",  # Disable warning when forcing value to bool.
+      "/wd4267",  # TODO(jschuh): size_t to int.
+    ]
+  } else {
+    if (is_clang && !is_nacl) {
+      # TODO(thakis): Remove !is_nacl once
+      # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+      cflags += [ "-Wall" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Lots of third-party libraries have unused variables. Instead of
+      # suppressing them individually, we just blanket suppress them here.
+      "-Wno-unused-variable",
+
+      # Similarly, we're not going to fix all the C++11 narrowing issues in
+      # third-party libraries.
+      "-Wno-c++11-narrowing",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Disabled for similar reasons as -Wunused-variable.
+        "-Wno-unused-but-set-variable",
+
+        # TODO(https://crbug.com/1202159): Clean up and enable.
+        "-Wno-misleading-indentation",
+      ]
+    }
+  }
+
+  # Suppress all warnings in third party, as Cargo does:
+  # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
+  rustflags = [ "--cap-lints=allow" ]
+
+  configs = [ ":default_warnings" ]
+
+  # GCC may emit unsuppressible warnings so only apply this config when
+  # building with clang. crbug.com/589724
+  if (treat_warnings_as_errors && is_clang) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+# noshadowing -----------------------------------------------------------------
+#
+# Allows turning -Wshadow on.
+
+config("noshadowing") {
+  # This flag has to be disabled for nacl because the nacl compiler is too
+  # strict about shadowing.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags = [ "-Wshadow" ]
+  }
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+  if (is_win) {
+    cflags_cc = [ "/GR" ]
+  } else {
+    cflags_cc = [ "-frtti" ]
+  }
+}
+
+config("no_rtti") {
+  # Some sanitizer configs may require RTTI to be left enabled globally
+  if (!use_rtti) {
+    if (is_win) {
+      cflags_cc = [ "/GR-" ]
+    } else {
+      cflags_cc = [ "-fno-rtti" ]
+      cflags_objcc = cflags_cc
+    }
+  }
+}
+
+# export_dynamic ---------------------------------------------------------------
+#
+# Ensures all exported symbols are added to the dynamic symbol table.  This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries.  Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+  # TODO(crbug.com/1052397): Revisit after target_os flip is completed.
+  if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) {
+    ldflags = [ "-rdynamic" ]
+  }
+}
+
+# thin_archive -----------------------------------------------------------------
+#
+# Enables thin archives on posix, and on windows when the lld linker is used.
+# Regular archives directly include the object files used to generate it.
+# Thin archives merely reference the object files.
+# This makes building them faster since it requires less disk IO, but is
+# inappropriate if you wish to redistribute your static library.
+# This config is added to the global config, so thin archives should already be
+# enabled.  If you want to make a distributable static library, you need to do 2
+# things:
+# 1. Set complete_static_lib so that all dependencies of the library make it
+#    into the library. See `gn help complete_static_lib` for details.
+# 2. Remove the thin_archive config, so that the .a file actually contains all
+#    .o files, instead of just references to .o files in the build directoy
+config("thin_archive") {
+  # The macOS and iOS default linker ld64 does not support reading thin
+  # archives.
+  # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
+  # confuses lldb.
+  if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
+    arflags = [ "-T" ]
+  } else if (is_win && use_lld) {
+    arflags = [ "/llvmlibthin" ]
+  }
+}
+
+# exceptions -------------------------------------------------------------------
+#
+# Allows turning Exceptions on or off.
+# Note: exceptions are disallowed in Google code.
+
+config("exceptions") {
+  if (is_win) {
+    # Enables exceptions in the STL.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=1" ]
+    }
+    cflags_cc = [ "/EHsc" ]
+  } else {
+    cflags_cc = [ "-fexceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+config("no_exceptions") {
+  if (is_win) {
+    # Disables exceptions in the STL.
+    # libc++ uses the __has_feature macro to control whether to use exceptions,
+    # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+    # breaks libc++ because it depends on MSVC headers that only provide certain
+    # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use
+    # exceptions, despite being conditional on _HAS_EXCEPTIONS.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=0" ]
+    }
+  } else {
+    cflags_cc = [ "-fno-exceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# Generate a warning for code that might emit a static initializer.
+# See: //docs/static_initializers.md
+# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
+config("wglobal_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wglobal-constructors" ]
+  }
+}
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wexit-time-destructors" ]
+  }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# suppressing the rest of them.  Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+  cflags = []
+  if (is_clang) {
+    cflags += [ "-Wno-incompatible-pointer-types" ]
+  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+    cflags += [ "-w" ]
+  } else if (is_chromeos_ash && current_cpu == "arm") {
+    cflags += [ "-w" ]
+  }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_optimization" ]
+#   configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+  common_optimize_on_cflags = [
+    "/Ob2",  # Both explicit and auto inlining.
+    "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+    "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+  ]
+  if (!is_asan) {
+    common_optimize_on_cflags += [
+      # Put data in separate COMDATs. This allows the linker
+      # to put bit-identical constants at the same address even if
+      # they're unrelated constants, which saves binary size.
+      # This optimization can't be used when ASan is enabled because
+      # it is not compatible with the ASan ODR checker.
+      "/Gw",
+    ]
+  }
+  common_optimize_on_ldflags = []
+
+  # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+  # misleading symbols in stack traces.
+  if (!is_debug && !is_component_build) {
+    common_optimize_on_ldflags += [ "/OPT:ICF" ]  # Redundant COMDAT folding.
+  }
+
+  if (is_official_build) {
+    common_optimize_on_ldflags += [ "/OPT:REF" ]  # Remove unreferenced data.
+    # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
+  }
+} else {
+  common_optimize_on_cflags = []
+  common_optimize_on_ldflags = []
+
+  if (is_android) {
+    # TODO(jdduke) Re-enable on mips after resolving linking
+    # issues with libc++ (crbug.com/456380).
+    if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+      common_optimize_on_ldflags += [
+        # Warn in case of text relocations.
+        "-Wl,--warn-shared-textrel",
+      ]
+    }
+  }
+
+  if (is_apple) {
+    common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+
+    if (is_official_build) {
+      common_optimize_on_ldflags += [
+        "-Wl,-no_data_in_code_info",
+        "-Wl,-no_function_starts",
+      ]
+    }
+  } else if (current_os != "aix" && current_os != "zos") {
+    # Non-Mac Posix flags.
+    # Aix does not support these.
+
+    common_optimize_on_cflags += [
+      # Put data and code in their own sections, so that unused symbols
+      # can be removed at link time with --gc-sections.
+      "-fdata-sections",
+      "-ffunction-sections",
+    ]
+    if ((!is_nacl || is_nacl_saigo) && is_clang) {
+      # We don't care about unique section names, this makes object files a bit
+      # smaller.
+      common_optimize_on_cflags += [ "-fno-unique-section-names" ]
+    }
+
+    common_optimize_on_ldflags += [
+      # Specifically tell the linker to perform optimizations.
+      # See http://lwn.net/Articles/192624/ .
+      # -O2 enables string tail merge optimization in gold and lld.
+      "-Wl,-O2",
+      "-Wl,--gc-sections",
+    ]
+  }
+}
+
+config("default_stack_frames") {
+  if (!is_win) {
+    if (enable_frame_pointers) {
+      cflags = [ "-fno-omit-frame-pointer" ]
+
+      # Omit frame pointers for leaf functions on x86, otherwise building libyuv
+      # gives clang's register allocator issues, see llvm.org/PR15798 /
+      # crbug.com/233709
+      if (is_clang && current_cpu == "x86" && !is_apple) {
+        cflags += [ "-momit-leaf-frame-pointer" ]
+      }
+    } else {
+      cflags = [ "-fomit-frame-pointer" ]
+    }
+  }
+  # On Windows, the flag to enable framepointers "/Oy-" must always come after
+  # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+  # the "optimize" configs, see rest of this file. The ordering that cflags are
+  # applied is well-defined by the GN spec, and there is no way to ensure that
+  # cflags set by "default_stack_frames" is applied after those set by an
+  # "optimize" config. Similarly, there is no way to propagate state from this
+  # config into the "optimize" config. We always apply the "/Oy-" config in the
+  # definition for common_optimize_on_cflags definition, even though this may
+  # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+  if (is_win) {
+    if (chrome_pgo_phase != 2) {
+      # Favor size over speed, /O1 must be before the common flags.
+      # /O1 implies /Os and /GF.
+      cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+      rustflags = [ "-Copt-level=s" ]
+    } else {
+      # PGO requires all translation units to be compiled with /O2. The actual
+      # optimization level will be decided based on the profiling data.
+      cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
+
+      # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
+      # suggests not using an explicit `-Copt-level` at all, and the default is
+      # to optimize for performance like `/O2` for clang.
+      rustflags = []
+    }
+  } else if (optimize_for_size) {
+    # Favor size over speed.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+
+      if (use_ml_inliner && is_a_target_toolchain) {
+        cflags += [
+          "-mllvm",
+          "-enable-ml-inliner=release",
+        ]
+      }
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
+    # vectorization.
+    rustflags = [ "-Copt-level=z" ]
+  } else if (is_chromeos) {
+    # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+    # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+    # any cost" (AKA -Oz). It'd be nice to:
+    # - Make `optimize_for_size` apply to all platforms where we're optimizing
+    #   for size by default (so, also Windows)
+    # - Investigate -Oz here, maybe just for ARM?
+    cflags = [ "-Os" ] + common_optimize_on_cflags
+
+    # Similar to clang, we optimize with `-Copt-level=s` to keep loop
+    # vectorization while otherwise optimizing for size.
+    rustflags = [ "-Copt-level=s" ]
+  } else {
+    cflags = [ "-O2" ] + common_optimize_on_cflags
+
+    # The `-O3` for clang turns on extra optimizations compared to the standard
+    # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
+    # to use.
+    rustflags = [ "-Copt-level=3" ]
+  }
+  ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+  if (is_win) {
+    cflags = [
+      "/Od",  # Disable optimization.
+      "/Ob0",  # Disable all inlining (on by default).
+      "/GF",  # Enable string pooling (off by default).
+    ]
+
+    if (target_cpu == "arm64") {
+      # Disable omitting frame pointers for no_optimize build because stack
+      # traces on Windows ARM64 rely on it.
+      cflags += [ "/Oy-" ]
+    }
+  } else if (is_android && !android_full_debug) {
+    # On Android we kind of optimize some things that don't affect debugging
+    # much even when optimization is disabled to get the binary size down.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    if (!is_component_build) {
+      # Required for library partitions. Without this all symbols just end up
+      # in the base partition.
+      ldflags = [ "-Wl,--gc-sections" ]
+    }
+  } else if (is_fuchsia) {
+    # On Fuchsia, we optimize for size here to reduce the size of debug build
+    # packages so they can be run in a KVM. See crbug.com/910243 for details.
+    cflags = [ "-Og" ]
+  } else {
+    cflags = [ "-O0" ]
+    ldflags = []
+  }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O2" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O3" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+config("optimize_fuzzing") {
+  cflags = [ "-O1" ] + common_optimize_on_cflags
+  rustflags = [ "-Copt-level=1" ]
+  ldflags = common_optimize_on_ldflags
+  visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else if (optimize_for_fuzzing) {
+    assert(!is_win, "Fuzzing optimize level not supported on Windows")
+
+    # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even
+    # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
+    assert(!use_clang_coverage,
+           "optimize_for_fuzzing=true should not be used with " +
+               "use_clang_coverage=true.")
+    configs = [ ":optimize_fuzzing" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
+_clang_sample_profile = ""
+if (is_clang && is_a_target_toolchain) {
+  if (clang_sample_profile_path != "") {
+    _clang_sample_profile = clang_sample_profile_path
+  } else if (clang_use_default_sample_profile) {
+    assert(build_with_chromium,
+           "Our default profiles currently only apply to Chromium")
+    assert(is_android || is_chromeos || is_castos,
+           "The current platform has no default profile")
+    if (is_android || is_castos) {
+      _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+    } else {
+      assert(
+          chromeos_afdo_platform == "atom" ||
+              chromeos_afdo_platform == "bigcore" ||
+              chromeos_afdo_platform == "arm" ||
+              chromeos_afdo_platform == "arm-exp",
+          "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
+      _clang_sample_profile =
+          "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+    }
+  }
+}
+
+# Clang offers a way to assert that AFDO profiles are accurate, which causes it
+# to optimize functions not represented in a profile more aggressively for size.
+# This config can be toggled in cases where shaving off binary size hurts
+# performance too much.
+config("afdo_optimize_size") {
+  if (_clang_sample_profile != "" && sample_profile_is_accurate) {
+    cflags = [ "-fprofile-sample-accurate" ]
+  }
+}
+
+# GCC and clang support a form of profile-guided optimization called AFDO.
+# There are some targeted places that AFDO regresses, so we provide a separate
+# config to allow AFDO to be disabled per-target.
+config("afdo") {
+  if (is_clang) {
+    cflags = []
+    if (clang_emit_debug_info_for_profiling) {
+      # Add the following flags to generate debug info for profiling.
+      cflags += [ "-gline-tables-only" ]
+      if (!is_nacl) {
+        cflags += [ "-fdebug-info-for-profiling" ]
+      }
+    }
+    if (_clang_sample_profile != "") {
+      assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
+      rebased_clang_sample_profile =
+          rebase_path(_clang_sample_profile, root_build_dir)
+      cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+      if (use_profi) {
+        cflags += [ "-fsample-profile-use-profi" ]
+      }
+
+      # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
+      # These seem to be false positives - the complaints are about functions
+      # marked with `__nodebug__` not having associated debuginfo. In the case
+      # where this was observed, the `__nodebug__` function was also marked
+      # `__always_inline__` and had no branches, so AFDO info is likely useless
+      # there.
+      cflags += [ "-Wno-backend-plugin" ]
+      inputs = [ _clang_sample_profile ]
+    }
+  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+    cflags = [ "-fauto-profile=${auto_profile_path}" ]
+    inputs = [ auto_profile_path ]
+  }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_symbols" ]
+#   configs += [ "//build/config/compiler:symbols" ]
+
+# A helper config that all configs passing /DEBUG to the linker should
+# include as sub-config.
+config("win_pdbaltpath") {
+  visibility = [
+    ":minimal_symbols",
+    ":symbols",
+  ]
+
+  # /DEBUG causes the linker to generate a pdb file, and to write the absolute
+  # path to it in the executable file it generates.  This flag turns that
+  # absolute path into just the basename of the pdb file, which helps with
+  # build reproducibility. Debuggers look for pdb files next to executables,
+  # so there's minimal downside to always using this. However, post-mortem
+  # debugging of Chromium crash dumps and ETW tracing can be complicated by this
+  # switch so an option to omit it is important.
+  if (!use_full_pdb_paths) {
+    ldflags = [ "/pdbaltpath:%_PDB%" ]
+  }
+}
+
+# Full symbols.
+config("symbols") {
+  rustflags = []
+  if (is_win) {
+    if (is_clang) {
+      cflags = [
+        # Debug information in the .obj files.
+        "/Z7",
+
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    } else {
+      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.
+    }
+
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = []
+    if (is_mac && enable_dsyms) {
+      # If generating dSYMs, specify -fno-standalone-debug. This was
+      # originally specified for https://crbug.com/479841 because dsymutil
+      # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+      # version 7 also produces debug data that is incompatible with Breakpad
+      # dump_syms, so this is still required (https://crbug.com/622406).
+      cflags += [ "-fno-standalone-debug" ]
+    }
+
+    # On aix -gdwarf causes linker failures due to thread_local variables.
+    if (!is_nacl && current_os != "aix") {
+      if (use_dwarf5) {
+        cflags += [ "-gdwarf-5" ]
+        rustflags += [ "-Zdwarf-version=5" ]
+      } else {
+        # Recent clang versions default to DWARF5 on Linux, and Android is about
+        # to switch. TODO: Adopt that in controlled way. For now, keep DWARF4.
+        # Apple platforms still default to 4 in clang, so they don't need the
+        # cflags.
+        if (!is_apple) {
+          cflags += [ "-gdwarf-4" ]
+        }
+
+        # On Apple, rustc defaults to DWARF2 so it needs to be told how to
+        # match clang.
+        rustflags += [ "-Zdwarf-version=4" ]
+      }
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if ((!is_nacl || is_nacl_saigo) && current_os != "zos") {
+      cflags += [ "-g2" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
+      # to be manually enabled.
+      #
+      # It is skipped in tsan and asan because enabling it causes some
+      # formatting changes in the output which would require fixing bunches
+      # of expectation regexps.
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    if (is_apple) {
+      swiftflags = [ "-g" ]
+    }
+
+    if (use_debug_fission) {
+      cflags += [ "-gsplit-dwarf" ]
+    }
+    asmflags = cflags
+    ldflags = []
+
+    # Split debug info with all thinlto builds except nacl and apple.
+    # thinlto requires -gsplit-dwarf in ldflags.
+    if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) {
+      ldflags += [ "-gsplit-dwarf" ]
+    }
+
+    # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+    # currently we get "warning:
+    # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+    # DWARF info may be corrupt; offsets in a range list entry are in different
+    # sections" there.  Maybe just a bug in nacl_switch_32.S.
+    _enable_gdb_index =
+        symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" &&
+        current_os != "zos" && (use_gold || use_lld) &&
+        # Disable on non-fission 32-bit Android because it pushes
+        # libcomponents_unittests over the 4gb size limit.
+        !(is_android && !use_debug_fission && current_cpu != "x64" &&
+          current_cpu != "arm64")
+    if (_enable_gdb_index) {
+      if (is_clang) {
+        # This flag enables the GNU-format pubnames and pubtypes sections,
+        # which lld needs in order to generate a correct GDB index.
+        # TODO(pcc): Try to make lld understand non-GNU-format pubnames
+        # sections (llvm.org/PR34820).
+        cflags += [ "-ggnu-pubnames" ]
+      }
+      ldflags += [ "-Wl,--gdb-index" ]
+    }
+  }
+
+  configs = []
+
+  # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
+  # https://b/243982712.
+  if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
+      !is_nacl && current_cpu == "arm") {
+    configs += [ "//build/config:compress_debug_sections" ]
+  }
+
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+    if (is_apple) {
+      # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+      # Make sure we don't use constructor homing on mac.
+      cflags += [
+        "-Xclang",
+        "-debug-info-kind=limited",
+      ]
+    } else {
+      # Use constructor homing for debug info. This option reduces debug info
+      # by emitting class type info only when constructors are emitted.
+      cflags += [
+        "-Xclang",
+        "-fuse-ctor-homing",
+      ]
+    }
+  }
+  rustflags += [ "-g" ]
+}
+
+# Minimal symbols.
+# This config guarantees to hold symbol for stack trace which are shown to user
+# when crash happens in unittests running on buildbot.
+config("minimal_symbols") {
+  rustflags = []
+  if (is_win) {
+    # Functions, files, and line tables only.
+    cflags = []
+
+    if (is_clang) {
+      cflags += [
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    }
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+
+    # Enable line tables for clang. MSVC doesn't have an equivalent option.
+    if (is_clang) {
+      # -gline-tables-only is the same as -g1, but clang-cl only exposes the
+      # former.
+      cflags += [ "-gline-tables-only" ]
+    }
+  } else {
+    cflags = []
+    if (is_mac && !use_dwarf5) {
+      # clang defaults to DWARF2 on macOS unless mac_deployment_target is
+      # at least 10.11.
+      # TODO(thakis): Remove this once mac_deployment_target is 10.11.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    } else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
+      # On aix -gdwarf causes linker failures due to thread_local variables.
+      # Recent clang versions default to DWARF5 on Linux, and Android is about
+      # to switch. TODO: Adopt that in controlled way.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    }
+
+    if (use_dwarf5 && !is_nacl) {
+      cflags += [ "-gdwarf-5" ]
+      rustflags += [ "-Zdwarf-version=5" ]
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [ "-g1" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # See comment for -gdwarf-aranges in config("symbols").
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    ldflags = []
+    if (is_android && is_clang) {
+      # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
+      # doesn't emit DW_AT_linkage_name in -g1 builds.
+      # -fdebug-info-for-profiling enables that (and a bunch of other things we
+      # don't need), so that we get qualified names in stacks.
+      # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
+      #               failing that consider doing this on non-Android too.
+      cflags += [ "-fdebug-info-for-profiling" ]
+    }
+
+    asmflags = cflags
+  }
+  rustflags += [ "-Cdebuginfo=1" ]
+}
+
+# This configuration contains function names only. That is, the compiler is
+# told to not generate debug information and the linker then just puts function
+# names in the final debug information.
+config("no_symbols") {
+  if (is_win) {
+    ldflags = [ "/DEBUG" ]
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
+  }
+
+  # This config is removed by base unittests apk.
+  if (is_android && is_clang && strip_debug_info) {
+    configs += [ ":strip_debug" ]
+  }
+}
+
+config("strip_debug") {
+  if (!defined(ldflags)) {
+    ldflags = []
+  }
+  ldflags += [ "-Wl,--strip-debug" ]
+}
+
+if (is_apple) {
+  # On macOS and iOS, this enables support for ARC (automatic reference
+  # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+  #
+  # -fobjc-arc enables ARC overall.
+  #
+  # ARC does not add exception handlers to pure Objective-C code, but does add
+  # them to Objective-C++ code with the rationale that C++ pervasively adds them
+  # in for exception safety. However, exceptions are banned in Chromium code for
+  # C++ and exceptions in Objective-C code are intended to be fatal, so
+  # -fno-objc-arc-exceptions is specified to disable these unwanted exception
+  # handlers.
+  config("enable_arc") {
+    common_flags = [
+      "-fobjc-arc",
+      "-fno-objc-arc-exceptions",
+    ]
+    cflags_objc = common_flags
+    cflags_objcc = common_flags
+  }
+}
+
+if (is_android) {
+  # Use orderfile for linking Chrome on Android.
+  # This config enables using an orderfile for linking in LLD.
+  config("chrome_orderfile_config") {
+    # Don't try to use an orderfile with call graph sorting, except on Android,
+    # where we care about memory used by code, so we still want to mandate
+    # ordering.
+    if (chrome_orderfile_path != "") {
+      assert(use_lld)
+      _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
+      ldflags = [
+        "-Wl,--symbol-ordering-file",
+        "-Wl,$_rebased_orderfile",
+        "-Wl,--no-warn-symbol-ordering",
+      ]
+      inputs = [ chrome_orderfile_path ]
+    }
+  }
+}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+  cflags = []
+  if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+    if (init_stack_vars_zero) {
+      cflags += [ "-ftrivial-auto-var-init=zero" ]
+    } else {
+      cflags += [ "-ftrivial-auto-var-init=pattern" ]
+    }
+  }
+}
+
+buildflag_header("compiler_buildflags") {
+  header = "compiler_buildflags.h"
+
+  flags = [
+    "CLANG_PGO=$chrome_pgo_phase",
+    "SYMBOL_LEVEL=$symbol_level",
+  ]
+}
+
+config("cet_shadow_stack") {
+  if (enable_cet_shadow_stack && is_win) {
+    assert(target_cpu == "x64")
+    ldflags = [ "/CETCOMPAT" ]
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/src-orig/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/src-orig/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-aarch64-patch/src-orig/build/config/compiler/BUILD.gn	(revision 192)
@@ -0,0 +1,2932 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/buildflag_header.gni")
+import("//build/config/android/config.gni")
+import("//build/config/c++/c++.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/coverage/coverage.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/host_byteorder.gni")
+import("//build/config/rust.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/rbe.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+  import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el" ||
+    current_cpu == "mips" || current_cpu == "mips64") {
+  import("//build/config/mips.gni")
+}
+if (is_mac) {
+  import("//build/config/apple/symbols.gni")
+}
+if (is_ios) {
+  import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+  # To keep NaCl variables out of builds that don't include NaCl, all
+  # variables defined in nacl/config.gni referenced here should be protected by
+  # is_nacl conditions.
+  import("//build/config/nacl/config.gni")
+}
+
+lld_path = ""
+if (!is_clang) {
+  declare_args() {
+    # This allows overriding the location of lld.
+    lld_path = rebase_path("$clang_base_path/bin", root_build_dir)
+  }
+} else {
+  # clang looks for lld next to it, no need for -B.
+  lld_path = ""
+}
+
+declare_args() {
+  # Normally, Android builds are lightly optimized, even for debug builds, to
+  # keep binary size down. Setting this flag to true disables such optimization
+  android_full_debug = false
+
+  # Compile in such a way as to make it possible for the profiler to unwind full
+  # stack frames. Setting this flag has a large effect on the performance of the
+  # generated code than just setting profiling, but gives the profiler more
+  # information to analyze.
+  # Requires profiling to be set to true.
+  enable_full_stack_frames_for_profiling = false
+
+  # When we are going to use gold we need to find it.
+  # This is initialized below, after use_gold might have been overridden.
+  gold_path = ""
+
+  # Enable fatal linker warnings. Building Chromium with certain versions
+  # of binutils can cause linker warning.
+  fatal_linker_warnings = true
+
+  # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+  # but some sanitizers are known to require it, like CFI diagnostics
+  # and UBsan variants.
+  use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+  # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+  # optimization that GCC supports. It used by ChromeOS in their official
+  # builds. To use it, set auto_profile_path to the path to a file containing
+  # the needed gcov profiling data.
+  auto_profile_path = ""
+
+  # Path to an AFDO profile to use while building with clang, if any. Empty
+  # implies none.
+  clang_sample_profile_path = ""
+
+  # Some configurations have default sample profiles. If this is true and
+  # clang_sample_profile_path is empty, we'll fall back to the default.
+  #
+  # We currently only have default profiles for Chromium in-tree, so we disable
+  # this by default for all downstream projects, since these profiles are likely
+  # nonsensical for said projects.
+  clang_use_default_sample_profile =
+      chrome_pgo_phase == 0 && build_with_chromium && is_official_build &&
+      (is_android || chromeos_is_browser_only)
+
+  # This configuration is used to select a default profile in Chrome OS based on
+  # the microarchitectures we are using. This is only used if
+  # clang_use_default_sample_profile is true and clang_sample_profile_path is
+  # empty.
+  chromeos_afdo_platform = "atom"
+
+  # Emit debug information for profiling wile building with clang.
+  # Only enable this for ChromeOS official builds for AFDO.
+  clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
+
+  # Turn this on to have the compiler output extra timing information.
+  compiler_timing = false
+
+  # Turn this on to use ghash feature of lld for faster debug link on Windows.
+  # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
+  use_ghash = true
+
+  # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on
+  # can substantially increase link time and binary size, but they generally
+  # also make binaries a fair bit faster.
+  #
+  # TODO(gbiv): We disable optimizations by default on most platforms because
+  # the space overhead is too great. We should use some mixture of profiles and
+  # optimization settings to better tune the size increase.
+  thin_lto_enable_optimizations =
+      (is_chromeos || is_android || is_win || is_linux || is_mac ||
+       (is_ios && use_lld)) && is_official_build
+
+  # Initialize all local variables with a pattern. This flag will fill
+  # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
+  # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
+  # recognizable in the debugger, and crashes on memory accesses through
+  # uninitialized pointers.
+  #
+  # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and
+  # needs to be evaluated before enabling it there as well.
+  init_stack_vars = !(is_android && is_official_build)
+
+  # Zero init has favorable performance/size tradeoffs for Chrome OS
+  # but was not evaluated for other platforms.
+  init_stack_vars_zero = is_chromeos
+
+  # This argument is to control whether enabling text section splitting in the
+  # final binary. When enabled, the separated text sections with prefix
+  # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be
+  # merged to '.text' section. This allows us to identify the hot code section
+  # ('.text.hot') in the binary, which allows our data collection pipelines to
+  # more easily identify code that we assume to be hot/cold that doesn't turn
+  # out to be such in the field.
+  use_text_section_splitting = is_chromeos
+
+  # Enable DWARF v5.
+  use_dwarf5 = false
+
+  # Override this to put full paths to PDBs in Windows PE files. This helps
+  # windbg and Windows Performance Analyzer with finding the PDBs in some local-
+  # build scenarios. This is never needed for bots or official builds. Because
+  # this puts the output directory in the DLLs/EXEs it breaks build determinism.
+  # Bugs have been reported to the windbg/WPA teams and this workaround will be
+  # removed when they are fixed.
+  use_full_pdb_paths = false
+
+  # Enable -H, which prints the include tree during compilation.
+  # For use by tools/clang/scripts/analyze_includes.py
+  show_includes = false
+
+  # Enable Profi algorithm. Profi can infer block and edge counts.
+  # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
+  # TODO(crbug.com/1375958i:) Possibly enable this for Android too.
+  use_profi = is_chromeos
+
+  # If true, linker crashes will be rerun with `--reproduce` which causes
+  # a reproducer file to be saved.
+  save_reproducers_on_lld_crash = false
+
+  # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
+  # shadow call stack in register x18. Hence, x18 must not be used by the OS
+  # or libraries. We assume that to be the case for high end Android
+  # configurations. For more details see
+  # https://clang.llvm.org/docs/ShadowCallStack.html
+  enable_shadow_call_stack = false
+
+  # Use DWARF simple template names, with the following exceptions:
+  #
+  # * Windows is not supported as it doesn't use DWARF.
+  # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
+  #   lldb doesn't have the needed changes yet.
+  # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
+  #
+  # This greatly reduces the size of debug builds, at the cost of
+  # debugging information which is required by some specialized
+  # debugging tools.
+  simple_template_names = is_clang && !is_nacl && !is_win && !is_apple
+}
+
+declare_args() {
+  # Set to true to use icf, Identical Code Folding.
+  #
+  # icf=all is broken in older golds, see
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+  # chromeos binutils has been patched with the fix, so always use icf there.
+  # The bug only affects x86 and x64, so we can still use ICF when targeting
+  # other architectures.
+  #
+  # lld doesn't have the bug.
+  use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer &&
+            !use_clang_coverage && current_os != "zos" &&
+            !(is_android && use_order_profiling) &&
+            (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" ||
+                                                       current_cpu == "x64"))))
+}
+
+if (is_android) {
+  # Set the path to use orderfile for linking Chrome
+  # Note that this is for using only one orderfile for linking
+  # the Chrome binary/library.
+  declare_args() {
+    chrome_orderfile_path = ""
+
+    if (defined(default_chrome_orderfile)) {
+      # Allow downstream tools to set orderfile path with
+      # another variable.
+      chrome_orderfile_path = default_chrome_orderfile
+    }
+  }
+}
+
+declare_args() {
+  # Turn off the --call-graph-profile-sort flag for lld by default. Enable
+  # selectively for targets where it's beneficial.
+  enable_call_graph_profile_sort =
+      chrome_pgo_phase == 2 ||
+      (is_chromeos &&
+       (clang_use_default_sample_profile || clang_sample_profile_path != ""))
+}
+
+assert(!(llvm_force_head_revision && use_goma),
+       "can't use goma with trunk clang")
+assert(!(llvm_force_head_revision && use_remoteexec),
+       "can't use rbe with trunk clang")
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+  include_dirs = [
+    "//",
+    root_gen_dir,
+  ]
+}
+
+# Compiler instrumentation can introduce dependencies in DSOs to symbols in
+# the executable they are loaded into, so they are unresolved at link-time.
+config("no_unresolved_symbols") {
+  if (!using_sanitizer &&
+      (is_linux || is_chromeos || is_android || is_fuchsia)) {
+    ldflags = [
+      "-Wl,-z,defs",
+      "-Wl,--as-needed",
+    ]
+  }
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  cflags_objc = []
+  cflags_objcc = []
+  rustflags = []
+  ldflags = []
+  defines = []
+  configs = []
+  rustflags = []
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:compiler" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:compiler" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:compiler" ]
+  } else if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:compiler" ]
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:compiler" ]
+  } else if (is_fuchsia) {
+    configs += [ "//build/config/fuchsia:compiler" ]
+  } else if (current_os == "aix") {
+    configs += [ "//build/config/aix:compiler" ]
+  } else if (current_os == "zos") {
+    configs += [ "//build/config/zos:compiler" ]
+  }
+
+  configs += [
+    # See the definitions below.
+    ":clang_revision",
+    ":rustc_revision",
+    ":compiler_cpu_abi",
+    ":compiler_codegen",
+    ":compiler_deterministic",
+  ]
+
+  # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
+  # operations (e.g. dereferencing) into defined behavior. This avoids deletion
+  # of some security-critical code: see https://crbug.com/1139129.
+  # Nacl does not support the flag. And, we still want UBSAN to catch undefined
+  # behavior related to nullptrs, so do not add this flag if UBSAN is enabled.
+  # GCC seems to have some bugs compiling constexpr code when this is defined,
+  # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
+  # TODO(mpdenton): remove is_clang once GCC bug is fixed.
+  if (!is_nacl && !is_ubsan && is_clang) {
+    cflags += [ "-fno-delete-null-pointer-checks" ]
+  }
+
+  # Don't emit the GCC version ident directives, they just end up in the
+  # .comment section or debug info taking up binary size, and makes comparing
+  # .o files built with different compiler versions harder.
+  if (!is_win || is_clang) {
+    cflags += [ "-fno-ident" ]
+  }
+
+  # In general, Windows is totally different, but all the other builds share
+  # some common compiler and linker configuration.
+  if (!is_win) {
+    # Common POSIX compiler flags setup.
+    # --------------------------------
+    cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204
+
+    # Stack protection. ShadowCallStack and Stack protector address the same
+    # problems. Therefore, we only enable one or the other. Clang advertises SCS as
+    # a stronger alternative to StackProtector, so we give SCS precedence over SP.
+    if (enable_shadow_call_stack) {
+      # On Aarch64, SCS requires the x18 register to be unused because it will hold
+      # a pointer to the shadow stack. For Android we know that Clang doesn't use
+      # x18 by default. On other OSs adding "-ffixed-x18" might be required.
+      assert(is_android)
+
+      scs_parameters = [
+        "-fsanitize=shadow-call-stack",
+        "-fno-stack-protector",
+      ]
+      cflags += scs_parameters
+      ldflags += scs_parameters
+    } else {
+      if (is_apple) {
+        # The strong variant of the stack protector significantly increases
+        # binary size, so only enable it in debug mode.
+        if (is_debug) {
+          cflags += [ "-fstack-protector-strong" ]
+        } else {
+          cflags += [ "-fstack-protector" ]
+        }
+      } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
+        # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+        # See also https://crbug.com/533294
+        # The x86 toolchain currently has problems with stack-protector.
+        if (is_android && current_cpu == "x86") {
+          cflags += [ "-fno-stack-protector" ]
+        } else if (current_os != "aix") {
+          # Not available on aix.
+          cflags += [ "-fstack-protector" ]
+        }
+      }
+    }
+
+    if (use_lld) {
+      ldflags += [ "-fuse-ld=lld" ]
+      if (lld_path != "") {
+        ldflags += [ "-B$lld_path" ]
+      }
+    }
+
+    # Linker warnings.
+    if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
+        current_os != "zos") {
+      ldflags += [ "-Wl,--fatal-warnings" ]
+    }
+    if (fatal_linker_warnings && is_apple) {
+      ldflags += [ "-Wl,-fatal_warnings" ]
+    }
+  }
+
+  if (is_clang && is_debug) {
+    # Allow comparing the address of references and 'this' against 0
+    # in debug builds. Technically, these can never be null in
+    # well-defined C/C++ and Clang can optimize such checks away in
+    # release builds, but they may be used in asserts in debug builds.
+    cflags_cc += [
+      "-Wno-undefined-bool-conversion",
+      "-Wno-tautological-undefined-compare",
+    ]
+  }
+
+  # Non-Apple Posix and Fuchsia compiler flags setup.
+  # -----------------------------------
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    if (enable_profiling) {
+      if (!is_debug) {
+        cflags += [ "-g" ]
+
+        if (enable_full_stack_frames_for_profiling) {
+          cflags += [
+            "-fno-inline",
+            "-fno-optimize-sibling-calls",
+          ]
+        }
+      }
+    }
+
+    # Explicitly pass --build-id to ld. Compilers used to always pass this
+    # implicitly but don't any more (in particular clang when built without
+    # ENABLE_LINKER_BUILD_ID=ON).
+    if (is_official_build) {
+      # The sha1 build id has lower risk of collision but is more expensive to
+      # compute, so only use it in the official build to avoid slowing down
+      # links.
+      ldflags += [ "-Wl,--build-id=sha1" ]
+    } else if (current_os != "aix" && current_os != "zos") {
+      ldflags += [ "-Wl,--build-id" ]
+    }
+
+    if (!is_android) {
+      defines += [
+        # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
+        # the behavior of the Android NDK from earlier versions.
+        # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
+        "_FILE_OFFSET_BITS=64",
+        "_LARGEFILE_SOURCE",
+        "_LARGEFILE64_SOURCE",
+      ]
+    }
+
+    if (!is_nacl) {
+      if (exclude_unwind_tables) {
+        cflags += [
+          "-fno-unwind-tables",
+          "-fno-asynchronous-unwind-tables",
+        ]
+        rustflags += [ "-Cforce-unwind-tables=no" ]
+        defines += [ "NO_UNWIND_TABLES" ]
+      } else {
+        cflags += [ "-funwind-tables" ]
+        rustflags += [ "-Cforce-unwind-tables=yes" ]
+      }
+    }
+  }
+
+  # Apple compiler flags setup.
+  # ---------------------------------
+  if (is_apple) {
+    # On Intel, clang emits both Apple's "compact unwind" information and
+    # DWARF eh_frame unwind information by default, for compatibility reasons.
+    # This flag limits emission of eh_frame information to functions
+    # whose unwind information can't be expressed in the compact unwind format
+    # (which in practice means almost everything gets only compact unwind
+    # entries). This reduces object file size a bit and makes linking a bit
+    # faster.
+    # On arm64, this is already the default behavior.
+    if (current_cpu == "x64") {
+      asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+      cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+    }
+  }
+
+  # Linux/Android/Fuchsia common flags setup.
+  # ---------------------------------
+  if (is_linux || is_chromeos || is_android || is_fuchsia) {
+    asmflags += [ "-fPIC" ]
+    cflags += [ "-fPIC" ]
+    ldflags += [ "-fPIC" ]
+    rustflags += [ "-Crelocation-model=pic" ]
+
+    if (!is_clang) {
+      # Use pipes for communicating between sub-processes. Faster.
+      # (This flag doesn't do anything with Clang.)
+      cflags += [ "-pipe" ]
+    }
+
+    ldflags += [
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+    ]
+
+    if (!is_component_build) {
+      ldflags += [ "-Wl,-z,now" ]
+    }
+  }
+
+  # Linux-specific compiler flags setup.
+  # ------------------------------------
+  if (use_gold) {
+    ldflags += [ "-fuse-ld=gold" ]
+    if (!is_android) {
+      # On Android, this isn't needed.  gcc in the NDK knows to look next to
+      # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+      # above.
+      if (gold_path != "") {
+        ldflags += [ "-B$gold_path" ]
+      }
+
+      ldflags += [
+        # Experimentation found that using four linking threads
+        # saved ~20% of link time.
+        # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+        # Only apply this to the target linker, since the host
+        # linker might not be gold, but isn't used much anyway.
+        "-Wl,--threads",
+        "-Wl,--thread-count=4",
+      ]
+    }
+
+    # TODO(thestig): Make this flag work with GN.
+    #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+    #  ldflags += [
+    #    "-Wl,--detect-odr-violations",
+    #  ]
+    #}
+  }
+
+  if (use_icf && (!is_apple || use_lld)) {
+    ldflags += [ "-Wl,--icf=all" ]
+  }
+
+  if (is_linux || is_chromeos) {
+    cflags += [ "-pthread" ]
+    # Do not use the -pthread ldflag here since it becomes a no-op
+    # when using -nodefaultlibs, which would cause an unused argument
+    # error.  "-lpthread" is added in //build/config:default_libs.
+  }
+
+  # Clang-specific compiler flags setup.
+  # ------------------------------------
+  if (is_clang) {
+    cflags += [ "-fcolor-diagnostics" ]
+
+    # Enable -fmerge-all-constants. This used to be the default in clang
+    # for over a decade. It makes clang non-conforming, but is fairly safe
+    # in practice and saves some binary size. We might want to consider
+    # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13),
+    # but for now it looks like our build might rely on it
+    # (https://crbug.com/829795).
+    cflags += [ "-fmerge-all-constants" ]
+  }
+
+  if (use_lld) {
+    # TODO(thakis): Make the driver pass --color-diagnostics to the linker
+    # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
+    # in ldflags instead.
+    if (is_win) {
+      # On Windows, we call the linker directly, instead of calling it through
+      # the driver.
+      ldflags += [ "--color-diagnostics" ]
+    } else {
+      ldflags += [ "-Wl,--color-diagnostics" ]
+    }
+  }
+
+  # Enable text section splitting only on linux when using lld for now. Other
+  # platforms can be added later if needed.
+  if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) {
+    ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
+  }
+
+  if (is_clang && !is_nacl && current_os != "zos") {
+    cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
+    if (save_reproducers_on_lld_crash && use_lld) {
+      ldflags += [
+        "-fcrash-diagnostics=all",
+        "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
+      ]
+    }
+
+    # TODO(hans): Remove this once Clang generates better optimized debug info
+    # by default. https://crbug.com/765793
+    cflags += [
+      "-mllvm",
+      "-instcombine-lower-dbg-declare=0",
+    ]
+    if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+      if (is_win) {
+        ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
+      } else {
+        ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
+      }
+    }
+
+    # TODO(crbug.com/1235145): Investigate why/if this should be needed.
+    if (is_win) {
+      cflags += [ "/clang:-ffp-contract=off" ]
+    } else {
+      cflags += [ "-ffp-contract=off" ]
+    }
+  }
+
+  # C11/C++11 compiler flags setup.
+  # ---------------------------
+  if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
+      current_os == "aix") {
+    if (is_clang) {
+      standard_prefix = "c"
+
+      # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
+      # defined by the compiler.  However, lots of code relies on the
+      # non-standard features that _GNU_SOURCE enables, so define it manually.
+      defines += [ "_GNU_SOURCE" ]
+
+      if (is_nacl) {
+        # Undefine __STRICT_ANSI__ to get non-standard features which would
+        # otherwise not be enabled by NaCl's sysroots.
+        cflags += [ "-U__STRICT_ANSI__" ]
+      }
+    } else {
+      # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
+      # but we use this feature in several places in Chromium.
+      # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the
+      # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
+      # to -std=c*.
+      standard_prefix = "gnu"
+    }
+
+    cflags_c += [ "-std=${standard_prefix}11" ]
+    if (is_nacl && !is_nacl_saigo) {
+      # This is for the pnacl_newlib toolchain. It's only used to build
+      # a few independent ppapi test files that don't pull in any other
+      # dependencies.
+      cflags_cc += [ "-std=${standard_prefix}++14" ]
+      if (is_clang) {
+        cflags_cc += [ "-fno-trigraphs" ]
+      }
+    } else if (is_clang) {
+      if (defined(use_cxx17) && use_cxx17) {
+        cflags_cc += [ "-std=${standard_prefix}++17" ]
+      } else {
+        cflags_cc += [ "-std=${standard_prefix}++20" ]
+      }
+    } else {
+      # The gcc bots are currently using GCC 9, which is not new enough to
+      # support "c++20"/"gnu++20".
+      cflags_cc += [ "-std=${standard_prefix}++2a" ]
+    }
+  } else if (is_win) {
+    cflags_c += [ "/std:c11" ]
+    if ((defined(use_cxx17) && use_cxx17) ||
+        (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) {
+      cflags_cc += [ "/std:c++17" ]
+    } else {
+      cflags_cc += [ "/std:c++20" ]
+    }
+  } else if (!is_nacl) {
+    # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
+    # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
+    # more, but there are still a few buildbots using it, so until those are
+    # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
+    # clause, above.
+    cflags_c += [ "-std=c11" ]
+
+    if (defined(use_cxx17) && use_cxx17) {
+      cflags_cc += [ "-std=c++17" ]
+    } else {
+      cflags_cc += [ "-std=c++20" ]
+    }
+  }
+
+  if (is_clang && current_os != "zos") {
+    # C++17 removes trigraph support, but clang still warns that it ignores
+    # them when seeing them.  Don't.
+    cflags_cc += [ "-Wno-trigraphs" ]
+  }
+
+  if (use_relative_vtables_abi) {
+    cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
+    ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
+  }
+
+  # Add flags for link-time optimization. These flags enable
+  # optimizations/transformations that require whole-program visibility at link
+  # time, so they need to be applied to all translation units, and we may end up
+  # with miscompiles if only part of the program is compiled with LTO flags. For
+  # that reason, we cannot allow targets to enable or disable these flags, for
+  # example by disabling the optimize configuration.
+  # TODO(pcc): Make this conditional on is_official_build rather than on gn
+  # flags for specific features.
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    assert(use_lld, "LTO is only supported with lld")
+
+    cflags += [
+      "-flto=thin",
+      "-fsplit-lto-unit",
+    ]
+
+    # Limit the size of the ThinLTO cache to the lesser of 10% of
+    # available disk space, 40GB and 100000 files.
+    cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000"
+
+    # An import limit of 30 has better performance (per speedometer) and lower
+    # binary size than the default setting of 100.
+    # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
+    # should be able to better manage binary size increases on its own.
+    import_instr_limit = 30
+
+    if (is_win) {
+      ldflags += [
+        "/opt:lldltojobs=all",
+        "-mllvm:-import-instr-limit=$import_instr_limit",
+        "/lldltocache:" +
+            rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+        "/lldltocachepolicy:$cache_policy",
+        "-mllvm:-disable-auto-upgrade-debug-info",
+      ]
+    } else {
+      ldflags += [ "-flto=thin" ]
+
+      # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory
+      # usage in crbug.com/1038040. Note this will increase build time in
+      # Chrome OS.
+
+      # In ThinLTO builds, we run at most one link process at a time,
+      # and let it use all cores.
+      # TODO(thakis): Check if '=0' (that is, number of cores, instead
+      # of "all" which means number of hardware threads) is faster.
+      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_apple) {
+        ldflags += [
+          "-Wl,-cache_path_lto," +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+          "-Wcrl,object_path_lto",
+        ]
+      } else {
+        ldflags +=
+            [ "-Wl,--thinlto-cache-dir=" +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ]
+      }
+
+      ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+
+      if (is_chromeos) {
+        # ARM was originally set lower than x86 to keep the size
+        # bloat of ThinLTO to <10%, but that's potentially no longer true.
+        # FIXME(inglorion): maybe tune these?
+        # TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
+        import_instr_limit = 20
+      } else if (is_android) {
+        # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win
+        # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB.
+        import_instr_limit = 5
+      }
+
+      ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
+
+      if (!is_chromeos) {
+        # TODO(https://crbug.com/972449): turn on for ChromeOS when that
+        # toolchain has this flag.
+        # We only use one version of LLVM within a build so there's no need to
+        # upgrade debug info, which can be expensive since it runs the verifier.
+        ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
+      }
+    }
+
+    # TODO(https://crbug.com/1211155): investigate why this isn't effective on
+    # arm32.
+    if (!is_android || current_cpu == "arm64") {
+      cflags += [ "-fwhole-program-vtables" ]
+
+      if (toolchain_supports_rust_thin_lto) {
+        # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
+        # behaviour. Rust needs to know the linker will be doing LTO in this case
+        # or it rejects the Zsplit-lto-unit flag.
+        rustflags += [
+          "-Zsplit-lto-unit",
+          "-Clinker-plugin-lto=yes",
+        ]
+      } else {
+        # Don't include bitcode if it won't be used.
+        rustflags += [ "-Cembed-bitcode=no" ]
+      }
+
+      if (!is_win) {
+        ldflags += [ "-fwhole-program-vtables" ]
+      }
+    }
+
+    # This flag causes LTO to create an .ARM.attributes section with the correct
+    # architecture. This is necessary because LLD will refuse to link a program
+    # unless the architecture revision in .ARM.attributes is sufficiently new.
+    # TODO(pcc): The contents of .ARM.attributes should be based on the
+    # -march flag passed at compile time (see llvm.org/pr36291).
+    if (current_cpu == "arm") {
+      ldflags += [ "-march=$arm_arch" ]
+    }
+  }
+
+  if (compiler_timing) {
+    if (is_clang && !is_nacl) {
+      cflags += [ "-ftime-trace" ]
+    } else if (is_win) {
+      cflags += [
+        # "Documented" here:
+        # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
+        "/d2cgsummary",
+      ]
+    }
+  }
+
+  # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize
+  # stack crashes (http://crbug.com/919499).
+  if (use_lld && is_android) {
+    ldflags += [ "-Wl,--no-rosegment" ]
+  }
+
+  # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+  # --no-undefined-version.
+  if (use_lld && !is_win && !is_mac && !is_ios) {
+    ldflags += [ "-Wl,--undefined-version" ]
+  }
+
+  if (use_lld && is_apple) {
+    ldflags += [ "-Wl,--strict-auto-link" ]
+  }
+
+  # LLD does call-graph-sorted binary layout by default when profile data is
+  # present. On Android this increases binary size due to more thinks for long
+  # jumps. Turn it off by default and enable selectively for targets where it's
+  # beneficial.
+  if (use_lld && !enable_call_graph_profile_sort) {
+    if (is_win) {
+      ldflags += [ "/call-graph-profile-sort:no" ]
+    } else {
+      ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
+    }
+  }
+
+  if (is_clang && !is_nacl && show_includes) {
+    if (is_win) {
+      # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
+      assert(!use_goma, "show_includes on Windows is not reliable with goma")
+      cflags += [
+        "/clang:-H",
+        "/clang:-fshow-skipped-includes",
+      ]
+    } else {
+      cflags += [
+        "-H",
+        "-fshow-skipped-includes",
+      ]
+    }
+  }
+
+  # This flag enforces that member pointer base types are complete. It helps
+  # prevent us from running into problems in the Microsoft C++ ABI (see
+  # https://crbug.com/847724).
+  if (is_clang && !is_nacl && target_os != "chromeos" &&
+      (is_win || use_custom_libcxx)) {
+    cflags += [ "-fcomplete-member-pointers" ]
+  }
+
+  # Use DWARF simple template names.
+  if (simple_template_names) {
+    cflags_cc += [ "-gsimple-template-names" ]
+  }
+
+  # MLGO specific flags. These flags enable an ML-based inliner trained on
+  # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
+  # The "release" ML model is embedded into clang as part of its build.
+  # Currently, the ML inliner is only enabled when targeting Android due to:
+  # a) Android is where size matters the most.
+  # b) MLGO presently has the limitation of only being able to embed one model
+  #    at a time; It is unclear if the embedded model is beneficial for
+  #    non-Android targets.
+  # MLGO is only officially supported on linux.
+  if (use_ml_inliner && is_a_target_toolchain) {
+    assert(
+        is_android && host_os == "linux",
+        "MLGO is currently only supported for targeting Android on a linux host")
+    if (use_thin_lto) {
+      ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
+    }
+  }
+
+  if (clang_embed_bitcode) {
+    assert(!use_thin_lto,
+           "clang_embed_bitcode is only supported in non-ThinLTO builds")
+    cflags += [
+      "-Xclang",
+      "-fembed-bitcode=all",
+    ]
+  }
+
+  if (lld_emit_indexes_and_imports) {
+    assert(use_thin_lto,
+           "lld_emit_indexes_and_imports is only supported with ThinLTO builds")
+    ldflags += [
+      "-Wl,--save-temps=import",
+      "-Wl,--thinlto-emit-index-files",
+    ]
+  }
+
+  # Pass the same C/C++ flags to the objective C/C++ compiler.
+  cflags_objc += cflags_c
+  cflags_objcc += cflags_cc
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler. The Windows assembler takes different types of flags
+  # so only do so for posix platforms.
+  if (is_posix || is_fuchsia) {
+    asmflags += cflags
+    asmflags += cflags_c
+  }
+
+  if (is_chromeos_device && !is_nacl) {
+    # On ChromeOS devices, we want to ensure we're using Chrome's allocator
+    # symbols for all C++ new/delete operator overloads. PartitionAlloc
+    # and other local allocators should always take precedence over system or
+    # preloaded allocators. These are the mangled symbol names.
+    # See b/280115910 for details.
+    ldflags += [
+      "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
+      "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
+      "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
+      "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
+      "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
+      "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
+    ]
+  }
+
+  # Rust compiler flags setup.
+  # ---------------------------
+  rustflags += [
+    # Overflow checks are optional in Rust, but even if switched
+    # off they do not cause undefined behavior (the overflowing
+    # behavior is defined). Because containers are bounds-checked
+    # in safe Rust, they also can't provoke buffer overflows.
+    # As such these checks may be less important in Rust than C++.
+    # But in (simplistic) testing they have negligible performance
+    # overhead, and this helps to provide consistent behavior
+    # between different configurations, so we'll keep them on until
+    # we discover a reason to turn them off.
+    "-Coverflow-checks=on",
+
+    # By default Rust passes `-nodefaultlibs` to the linker, however this
+    # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
+    # is then unused and produces a warning/error. So this removes the
+    # `-nodefaultlibs` from the linker invocation from Rust, which would be used
+    # to compile dylibs on Android, such as for constructing unit test APKs.
+    "-Cdefault-linker-libraries",
+
+    # To make Rust .d files compatible with ninja
+    "-Zdep-info-omit-d-target",
+
+    # If a macro panics during compilation, show which macro and where it is
+    # defined.
+    "-Zmacro-backtrace",
+
+    # For deterministic builds, keep the local machine's current working
+    # directory from appearing in build outputs.
+    "-Zremap-cwd-prefix=.",
+  ]
+
+  if (!is_win || force_rustc_color_output) {
+    # Colorize error output. The analogous flag is passed for clang. This must
+    # be platform-gated since rustc will unconditionally output ANSI escape
+    # sequences, ignoring the platform, when stderr is not a terminal.
+    rustflags += [ "--color=always" ]
+  }
+  if (rust_abi_target != "") {
+    rustflags += [ "--target=$rust_abi_target" ]
+  }
+  if (!use_thin_lto) {
+    # Don't include bitcode if it won't be used.
+    rustflags += [ "-Cembed-bitcode=no" ]
+  }
+  if (is_official_build) {
+    rustflags += [ "-Ccodegen-units=1" ]
+  }
+  if (!rust_prebuilt_stdlib) {
+    # When building against the Chromium Rust stdlib (which we compile) always
+    # abort instead of unwinding when panic occurs. In official builds, panics
+    # abort immediately (this is configured in the stdlib) to keep binary size
+    # down. So we unconditionally match behaviour in unofficial too.
+    rustflags += [
+      "-Cpanic=abort",
+      "-Zpanic_abort_tests",
+    ]
+  }
+
+  # Normally, this would be defined in the `runtime_library` config but NaCl
+  # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there
+  # isn't really a better config to add this define for the define to
+  # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
+  # and NaCl code.
+  #
+  # TODO(https://crbug.com/702997): Move this back to the `runtime_library`
+  # config when NaCl is removed.
+  if (use_safe_libcxx) {
+    # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once
+    # it's rolled in.
+    if (is_nacl_saigo) {
+      defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
+    } else {
+      defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ]
+    }
+  }
+}
+
+# The BUILDCONFIG file sets this config on targets by default, which means when
+# building with ThinLTO, no optimization is performed in the link step.
+config("thinlto_optimize_default") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    lto_opt_level = 0
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# Use this to enable optimization in the ThinLTO link step for select targets
+# when thin_lto_enable_optimizations is set by doing:
+#
+#   configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
+#   configs += [ "//build/config/compiler:thinlto_optimize_max" ]
+#
+# Since it makes linking significantly slower and more resource intensive, only
+# use it on important targets such as the main browser executable or dll.
+config("thinlto_optimize_max") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    if (thin_lto_enable_optimizations) {
+      lto_opt_level = 2
+    } else {
+      lto_opt_level = 0
+    }
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+  defines = []
+
+  configs = []
+  if (is_chromeos) {
+    configs += [ "//build/config/chromeos:compiler_cpu_abi" ]
+  }
+
+  # TODO(https://crbug.com/1383873): Remove this once figured out.
+  if (is_apple && current_cpu == "arm64") {
+    cflags += [ "-fno-global-isel" ]
+    ldflags += [ "-fno-global-isel" ]
+  }
+
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "-m64",
+        "-msse3",
+      ]
+      ldflags += [ "-m64" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+      if (!is_nacl) {
+        cflags += [
+          "-mfpmath=sse",
+          "-msse3",
+        ]
+      }
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=arm-linux-gnueabihf" ]
+        ldflags += [ "--target=arm-linux-gnueabihf" ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "arm64") {
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=aarch64-linux-gnu" ]
+        ldflags += [ "--target=aarch64-linux-gnu" ]
+      }
+    } else if (current_cpu == "mipsel" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mipsel-linux-android" ]
+            ldflags += [ "--target=mipsel-linux-android" ]
+          } else {
+            cflags += [ "--target=mipsel-linux-gnu" ]
+            ldflags += [ "--target=mipsel-linux-gnu" ]
+          }
+        } else {
+          cflags += [ "-EL" ]
+          ldflags += [ "-EL" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [ "-mno-odd-spreg" ]
+        ldflags += [ "-mips32r6" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r6",
+          ]
+        } else {
+          cflags += [
+            "-mips32r6",
+            "-Wa,-mips32r6",
+          ]
+          if (is_android) {
+            ldflags += [ "-Wl,-melf32ltsmip" ]
+          }
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips32r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r2",
+          ]
+        } else {
+          cflags += [
+            "-mips32r2",
+            "-Wa,-mips32r2",
+          ]
+          if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+            cflags += [ "-m$mips_fpu_mode" ]
+          }
+        }
+      } else if (mips_arch_variant == "r1") {
+        ldflags += [ "-mips32" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32",
+          ]
+        } else {
+          cflags += [
+            "-mips32",
+            "-Wa,-mips32",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips-linux-gnu" ]
+          ldflags += [ "--target=mips-linux-gnu" ]
+        } else {
+          cflags += [ "-EB" ]
+          ldflags += [ "-EB" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mips64el-linux-android" ]
+            ldflags += [ "--target=mips64el-linux-android" ]
+          } else {
+            cflags += [ "--target=mips64el-linux-gnuabi64" ]
+            ldflags += [ "--target=mips64el-linux-gnuabi64" ]
+          }
+        } else {
+          cflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r6",
+          ]
+        } else {
+          cflags += [
+            "-mips64r6",
+            "-Wa,-mips64r6",
+          ]
+          ldflags += [ "-mips64r6" ]
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips64r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r2",
+          ]
+        } else {
+          cflags += [
+            "-mips64r2",
+            "-Wa,-mips64r2",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+    } else if (current_cpu == "mips64") {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips64-linux-gnuabi64" ]
+          ldflags += [ "--target=mips64-linux-gnuabi64" ]
+        } else {
+          cflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    } else if (current_cpu == "ppc64") {
+      if (current_os == "aix") {
+        cflags += [ "-maix64" ]
+        ldflags += [ "-maix64" ]
+      } else {
+        cflags += [ "-m64" ]
+        ldflags += [ "-m64" ]
+      }
+    } else if (current_cpu == "riscv64") {
+      if (is_clang && !is_android) {
+        cflags += [ "--target=riscv64-linux-gnu" ]
+        ldflags += [ "--target=riscv64-linux-gnu" ]
+      }
+      cflags += [ "-mabi=lp64d" ]
+    } else if (current_cpu == "loong64") {
+      if (is_clang) {
+        cflags += [ "--target=loongarch64-linux-gnu" ]
+        ldflags += [ "--target=loongarch64-linux-gnu" ]
+      }
+      cflags += [
+        "-mabi=lp64d",
+        "-mcmodel=medium",
+      ]
+    } else if (current_cpu == "s390x") {
+      cflags += [ "-m64" ]
+      ldflags += [ "-m64" ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+  configs = []
+  cflags = []
+  ldflags = []
+
+  if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler_codegen" ]
+  }
+
+  if (current_cpu == "arm64" && !is_win && is_clang) {
+    # Disable outlining everywhere on arm64 except Win. For more information see
+    # crbug.com/931297 for Android and crbug.com/1410297 for iOS.
+    # TODO(crbug.com/1411363): Enable this on Windows if possible.
+    cflags += [ "-mno-outline" ]
+
+    # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
+    # has been resolved, and -mno-outline is obeyed by the linker during
+    # ThinLTO.
+    ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
+  }
+
+  asmflags = cflags
+}
+
+# This provides options that make the build deterministic, so that the same
+# revision produces the same output, independent of the name of the build
+# directory and of the computer the build is done on.
+# The relative path from build dir to source dir makes it into the build
+# outputs, so it's recommended that you use a build dir two levels deep
+# (e.g. "out/Release") so that you get the same "../.." path as all the bots
+# in your build outputs.
+config("compiler_deterministic") {
+  cflags = []
+  ldflags = []
+  swiftflags = []
+
+  # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+  # deterministic build.  See https://crbug.com/314403
+  if (!is_official_build) {
+    if (is_win && !is_clang) {
+      cflags += [
+        "/wd4117",  # Trying to define or undefine a predefined macro.
+        "/D__DATE__=",
+        "/D__TIME__=",
+        "/D__TIMESTAMP__=",
+      ]
+    } else {
+      cflags += [
+        "-Wno-builtin-macro-redefined",
+        "-D__DATE__=",
+        "-D__TIME__=",
+        "-D__TIMESTAMP__=",
+      ]
+    }
+  }
+
+  # Makes builds independent of absolute file path.
+  if (is_clang && strip_absolute_paths_from_debug_symbols) {
+    # If debug option is given, clang includes $cwd in debug info by default.
+    # For such build, this flag generates reproducible obj files even we use
+    # 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=." ]
+      swiftflags += [ "-file-compilation-dir=." ]
+    }
+    if (!is_win) {
+      # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+      asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+    }
+
+    if (is_win && use_lld) {
+      if (symbol_level == 2 || (is_clang && using_sanitizer)) {
+        # Absolutize source file paths for PDB. Pass the real build directory
+        # if the pdb contains source-level debug information and if linker
+        # reproducibility is not critical.
+        ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ]
+      } else {
+        # Use a fake fixed base directory for paths in the pdb to make the pdb
+        # output fully deterministic and independent of the build directory.
+        ldflags += [ "/PDBSourcePath:o:\fake\prefix" ]
+      }
+    }
+  }
+
+  # Tells the compiler not to use absolute paths when passing the default
+  # paths to the tools it invokes. We don't want this because we don't
+  # really need it and it can mess up the goma cache entries.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags += [ "-no-canonical-prefixes" ]
+
+    # Same for links: Let the compiler driver invoke the linker
+    # with a relative path and pass relative paths to built-in
+    # libraries. Not needed on Windows because we call the linker
+    # directly there, not through the compiler driver.
+    # We don't link on goma, so this change is just for cleaner
+    # internal linker invocations, for people who work on the build.
+    if (!is_win) {
+      ldflags += [ "-no-canonical-prefixes" ]
+    }
+  }
+}
+
+config("clang_revision") {
+  if (is_clang && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
+config("rustc_revision") {
+  if (rustc_revision != "") {
+    # Similar to the above config, this is here so that all files get recompiled
+    # after a rustc roll. Nothing should ever read this cfg. This will not be
+    # set if a custom toolchain is used.
+    rustflags = [
+      "--cfg",
+      "cr_rustc_revision=\"$rustc_revision\"",
+    ]
+  }
+}
+
+config("compiler_arm_fpu") {
+  if (current_cpu == "arm" && !is_ios && !is_nacl) {
+    cflags = [ "-mfpu=$arm_fpu" ]
+    if (!arm_use_thumb) {
+      cflags += [ "-marm" ]
+    }
+    asmflags = cflags
+  }
+}
+
+config("compiler_arm_thumb") {
+  if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+      !(is_apple || is_nacl)) {
+    cflags = [ "-mthumb" ]
+  }
+}
+
+config("compiler_arm") {
+  if (current_cpu == "arm" && is_chromeos) {
+    # arm is normally the default mode for clang, but on chromeos a wrapper
+    # is used to pass -mthumb, and therefor change the default.
+    cflags = [ "-marm" ]
+  }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+  configs = []
+
+  # The order of this config is important: it must appear before
+  # android:runtime_library.  This is to ensure libc++ appears before
+  # libandroid_support in the -isystem include order.  Otherwise, there will be
+  # build errors related to symbols declared in math.h.
+  if (use_custom_libcxx) {
+    configs += [ "//build/config/c++:runtime_library" ]
+  }
+
+  # Rust and C++ both provide intrinsics for LLVM to call for math operations. We
+  # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins
+  # library. The Rust symbols are marked as weak, so that they can be replaced by
+  # the C++ symbols. This config ensures the C++ symbols exist and are strong in
+  # order to cause that replacement to occur by explicitly linking in clang's
+  # compiler-rt library.
+  if (is_clang && toolchain_has_rust) {
+    configs += [ "//build/config/clang:compiler_builtins" ]
+  }
+
+  # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia
+  # configuration.
+  if (is_posix || is_fuchsia) {
+    configs += [ "//build/config/posix:runtime_library" ]
+
+    if (use_custom_libunwind) {
+      # Instead of using an unwind lib from the toolchain,
+      # buildtools/third_party/libunwind will be built and used directly.
+      ldflags = [ "--unwindlib=none" ]
+    }
+  }
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:runtime_library" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:runtime_library" ]
+    if (is_chromeos) {
+      configs += [ "//build/config/chromeos:runtime_library" ]
+    }
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:runtime_library" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:runtime_library" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:runtime_library" ]
+  }
+
+  if (is_component_build) {
+    defines = [ "COMPONENT_BUILD" ]
+  }
+}
+
+# treat_warnings_as_errors ----------------------------------------------------
+#
+# Adding this config causes the compiler to treat warnings as fatal errors.
+# This is used as a subconfig of both chromium_code and no_chromium_code, and
+# is broken out separately so nocompile tests can force-enable this setting
+# independently of the default warning flags.
+config("treat_warnings_as_errors") {
+  if (is_win) {
+    cflags = [ "/WX" ]
+  } else {
+    cflags = [ "-Werror" ]
+
+    # The compiler driver can sometimes (rarely) emit warnings before calling
+    # the actual linker.  Make sure these warnings are treated as errors as
+    # well.
+    ldflags = [ "-Werror" ]
+  }
+
+  # Turn rustc warnings into the "deny" lint level, which produce compiler
+  # errors. The equivalent of -Werror for clang/gcc.
+  #
+  # Note we apply the actual lint flags in config("compiler"). All warnings
+  # are suppressed in third-party crates.
+  rustflags = [ "-Dwarnings" ]
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default.  This is used as a
+# subconfig of both chromium_code and no_chromium_code.  This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  ldflags = []
+  configs = []
+
+  if (is_win) {
+    if (fatal_linker_warnings) {
+      arflags = [ "/WX" ]
+      ldflags = [ "/WX" ]
+    }
+    defines = [
+      # Without this, Windows headers warn that functions like wcsnicmp
+      # should be spelled _wcsnicmp. But all other platforms keep spelling
+      # it wcsnicmp, making this warning unhelpful. We don't want it.
+      "_CRT_NONSTDC_NO_WARNINGS",
+
+      # TODO(thakis): winsock wants us to use getaddrinfo instead of
+      # gethostbyname. Fires mostly in non-Chromium code. We probably
+      # want to remove this define eventually.
+      "_WINSOCK_DEPRECATED_NO_WARNINGS",
+    ]
+    if (!is_clang) {
+      # TODO(thakis): Remove this once
+      # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
+      # rolled into angle.
+      cflags += [ "/wd4244" ]
+    }
+  } else {
+    if (is_apple && !is_nacl) {
+      # When compiling Objective-C, warns if a method is used whose
+      # availability is newer than the deployment target.
+      cflags += [ "-Wunguarded-availability" ]
+    }
+
+    if (is_ios) {
+      # When compiling Objective-C, warns if a selector named via @selector has
+      # not been defined in any visible interface.
+      cflags += [ "-Wundeclared-selector" ]
+    }
+
+    # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+    # warning).
+    if (current_cpu == "arm" && !is_clang) {
+      cflags += [ "-Wno-psabi" ]
+    }
+
+    if (!is_clang) {
+      cflags_cc += [
+        # See comment for -Wno-c++11-narrowing.
+        "-Wno-narrowing",
+      ]
+
+      # -Wno-class-memaccess warns about hash table and vector in blink.
+      # But the violation is intentional.
+      if (!is_nacl) {
+        cflags_cc += [ "-Wno-class-memaccess" ]
+      }
+
+      # -Wunused-local-typedefs is broken in gcc,
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
+      cflags += [ "-Wno-unused-local-typedefs" ]
+
+      # Don't warn about "maybe" uninitialized. Clang doesn't include this
+      # in -Wall but gcc does, and it gives false positives.
+      cflags += [ "-Wno-maybe-uninitialized" ]
+      cflags += [ "-Wno-deprecated-declarations" ]
+
+      # -Wcomment gives too many false positives in the case a
+      # backslash ended comment line is followed by a new line of
+      # comments
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
+      cflags += [ "-Wno-comments" ]
+
+      # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
+      # files.
+      cflags += [ "-Wno-packed-not-aligned" ]
+    }
+  }
+
+  # Common Clang and GCC warning setup.
+  if (!is_win || is_clang) {
+    cflags += [
+      # Disables.
+      "-Wno-missing-field-initializers",  # "struct foo f = {0};"
+      "-Wno-unused-parameter",  # Unused function parameters.
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # An ABI compat warning we don't care about, https://crbug.com/1102157
+        # TODO(thakis): Push this to the (few) targets that need it,
+        # instead of having a global flag.
+        "-Wno-psabi",
+      ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      "-Wloop-analysis",
+
+      # TODO(thakis): This used to be implied by -Wno-unused-function,
+      # which we no longer use. Check if it makes sense to remove
+      # this as well. http://crbug.com/316352
+      "-Wno-unneeded-internal-declaration",
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      if (is_win) {
+        # TODO(thakis): https://crbug.com/617318
+        # Currently goma can not handle case sensitiveness for windows well.
+        cflags += [ "-Wno-nonportable-include-path" ]
+      }
+
+      if (is_fuchsia) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1474434): fix and reenable
+          "-Wno-missing-field-initializers",
+        ]
+      }
+
+      cflags += [
+        "-Wenum-compare-conditional",
+
+        # Ignore warnings about MSVC optimization pragmas.
+        # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
+        "-Wno-ignored-pragma-optimize",
+      ]
+
+      if (!is_nacl) {
+        cflags += [
+          # TODO(crbug.com/1343975) Evaluate and possibly enable.
+          "-Wno-deprecated-builtins",
+
+          # TODO(crbug.com/1352183) Evaluate and possibly enable.
+          "-Wno-bitfield-constant-conversion",
+
+          # TODO(crbug.com/1412713) Evaluate and possibly enable.
+          "-Wno-deprecated-this-capture",
+        ]
+      }
+    }
+
+    # Some builders, such as Cronet, use a different version of Clang than
+    # Chromium. This can cause minor errors when compiling Chromium changes. We
+    # want to avoid these errors.
+    if (llvm_android_mainline) {
+      cflags += [
+        "-Wno-error=unknown-warning-option",
+        "-Wno-error=unused-command-line-argument",
+      ]
+    }
+  }
+
+  # Rust warnings
+
+  # Require `unsafe` blocks even in `unsafe` fns. This is intended to become
+  # an error by default eventually; see
+  # https://github.com/rust-lang/rust/issues/71668
+  rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
+}
+
+# prevent_unsafe_narrowing ----------------------------------------------------
+#
+# Warnings that prevent narrowing or comparisons of integer types that are
+# likely to cause out-of-bound read/writes or Undefined Behaviour. In
+# particular, size_t is used for memory sizes, allocation, indexing, and
+# offsets. Using other integer types along with size_t produces risk of
+# memory-safety bugs and thus security exploits.
+#
+# In order to prevent these bugs, allocation sizes were historically limited to
+# sizes that can be represented within 31 bits of information, allowing `int` to
+# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
+# support increasing the allocation limit we require strictly adherence to
+# using the correct types, avoiding lossy conversions, and preventing overflow.
+# To do so, enable this config and fix errors by converting types to be
+# `size_t`, which is both large enough and unsigned, when dealing with memory
+# sizes, allocations, indices, or offsets.In cases where type conversion is not
+# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
+# to convert to size_t as needed.
+# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
+#
+# To enable in a GN target, use:
+#   configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
+
+config("prevent_unsafe_narrowing") {
+  if (is_clang) {
+    cflags = [
+      "-Wshorten-64-to-32",
+      "-Wimplicit-int-conversion",
+      "-Wsign-compare",
+      "-Wsign-conversion",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
+        # fixing types to be sign-correct.
+        "-Wtautological-unsigned-zero-compare",
+      ]
+    }
+  }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+  if (is_win) {
+    if (is_clang) {
+      cflags = [ "/W4" ]  # Warning level 4.
+
+      # Opt in to additional [[nodiscard]] on standard library methods.
+      defines = [ "_HAS_NODISCARD" ]
+    }
+  } else {
+    cflags = [ "-Wall" ]
+    if (is_clang) {
+      # Enable extra warnings for chromium_code when we control the compiler.
+      cflags += [ "-Wextra" ]
+    }
+
+    # In Chromium code, we define __STDC_foo_MACROS in order to get the
+    # C99 macros on Mac and Linux.
+    defines = [
+      "__STDC_CONSTANT_MACROS",
+      "__STDC_FORMAT_MACROS",
+    ]
+
+    if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+        current_cpu != "s390" && current_cpu != "ppc64" &&
+        current_cpu != "mips" && current_cpu != "mips64" &&
+        current_cpu != "riscv64" && current_cpu != "loong64") {
+      # Non-chromium code is not guaranteed to compile cleanly with
+      # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+      # disabled, so only do that for Release build.
+      fortify_level = "2"
+
+      # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation
+      # with a few custom glibc patches. Use that if it's available.
+      if (is_chromeos_ash) {
+        fortify_level = "3"
+      }
+      defines += [ "_FORTIFY_SOURCE=" + fortify_level ]
+    }
+
+    if (is_apple) {
+      cflags_objc = [ "-Wimplicit-retain-self" ]
+      cflags_objcc = [ "-Wimplicit-retain-self" ]
+    }
+
+    if (is_mac) {
+      cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
+      cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Warn on missing break statements at the end of switch cases.
+      # For intentional fallthrough, use [[fallthrough]].
+      "-Wimplicit-fallthrough",
+
+      # Warn on unnecessary extra semicolons outside of function definitions.
+      "-Wextra-semi",
+
+      # Warn on unreachable code, including unreachable breaks and returns.
+      # See https://crbug.com/346399#c148 for suppression strategies.
+      "-Wunreachable-code-aggressive",
+    ]
+
+    # Thread safety analysis is broken under nacl: https://crbug.com/982423.
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # Thread safety analysis. See base/thread_annotations.h and
+        # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
+        "-Wthread-safety",
+      ]
+    }
+  }
+
+  configs = [
+    ":default_warnings",
+    ":noshadowing",
+  ]
+  if (treat_warnings_as_errors) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
+  if (is_win) {
+    if (is_clang) {
+      cflags += [ "/W3" ]  # Warning level 3.
+    }
+    cflags += [
+      "/wd4800",  # Disable warning when forcing value to bool.
+      "/wd4267",  # TODO(jschuh): size_t to int.
+    ]
+  } else {
+    if (is_clang && !is_nacl) {
+      # TODO(thakis): Remove !is_nacl once
+      # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+      cflags += [ "-Wall" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Lots of third-party libraries have unused variables. Instead of
+      # suppressing them individually, we just blanket suppress them here.
+      "-Wno-unused-variable",
+
+      # Similarly, we're not going to fix all the C++11 narrowing issues in
+      # third-party libraries.
+      "-Wno-c++11-narrowing",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Disabled for similar reasons as -Wunused-variable.
+        "-Wno-unused-but-set-variable",
+
+        # TODO(https://crbug.com/1202159): Clean up and enable.
+        "-Wno-misleading-indentation",
+      ]
+    }
+  }
+
+  # Suppress all warnings in third party, as Cargo does:
+  # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
+  rustflags = [ "--cap-lints=allow" ]
+
+  configs = [ ":default_warnings" ]
+
+  # GCC may emit unsuppressible warnings so only apply this config when
+  # building with clang. crbug.com/589724
+  if (treat_warnings_as_errors && is_clang) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+# noshadowing -----------------------------------------------------------------
+#
+# Allows turning -Wshadow on.
+
+config("noshadowing") {
+  # This flag has to be disabled for nacl because the nacl compiler is too
+  # strict about shadowing.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags = [ "-Wshadow" ]
+  }
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+  if (is_win) {
+    cflags_cc = [ "/GR" ]
+  } else {
+    cflags_cc = [ "-frtti" ]
+  }
+}
+
+config("no_rtti") {
+  # Some sanitizer configs may require RTTI to be left enabled globally
+  if (!use_rtti) {
+    if (is_win) {
+      cflags_cc = [ "/GR-" ]
+    } else {
+      cflags_cc = [ "-fno-rtti" ]
+      cflags_objcc = cflags_cc
+    }
+  }
+}
+
+# export_dynamic ---------------------------------------------------------------
+#
+# Ensures all exported symbols are added to the dynamic symbol table.  This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries.  Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+  # TODO(crbug.com/1052397): Revisit after target_os flip is completed.
+  if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) {
+    ldflags = [ "-rdynamic" ]
+  }
+}
+
+# thin_archive -----------------------------------------------------------------
+#
+# Enables thin archives on posix, and on windows when the lld linker is used.
+# Regular archives directly include the object files used to generate it.
+# Thin archives merely reference the object files.
+# This makes building them faster since it requires less disk IO, but is
+# inappropriate if you wish to redistribute your static library.
+# This config is added to the global config, so thin archives should already be
+# enabled.  If you want to make a distributable static library, you need to do 2
+# things:
+# 1. Set complete_static_lib so that all dependencies of the library make it
+#    into the library. See `gn help complete_static_lib` for details.
+# 2. Remove the thin_archive config, so that the .a file actually contains all
+#    .o files, instead of just references to .o files in the build directoy
+config("thin_archive") {
+  # The macOS and iOS default linker ld64 does not support reading thin
+  # archives.
+  # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
+  # confuses lldb.
+  if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
+    arflags = [ "-T" ]
+  } else if (is_win && use_lld) {
+    arflags = [ "/llvmlibthin" ]
+  }
+}
+
+# exceptions -------------------------------------------------------------------
+#
+# Allows turning Exceptions on or off.
+# Note: exceptions are disallowed in Google code.
+
+config("exceptions") {
+  if (is_win) {
+    # Enables exceptions in the STL.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=1" ]
+    }
+    cflags_cc = [ "/EHsc" ]
+  } else {
+    cflags_cc = [ "-fexceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+config("no_exceptions") {
+  if (is_win) {
+    # Disables exceptions in the STL.
+    # libc++ uses the __has_feature macro to control whether to use exceptions,
+    # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+    # breaks libc++ because it depends on MSVC headers that only provide certain
+    # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use
+    # exceptions, despite being conditional on _HAS_EXCEPTIONS.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=0" ]
+    }
+  } else {
+    cflags_cc = [ "-fno-exceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# Generate a warning for code that might emit a static initializer.
+# See: //docs/static_initializers.md
+# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
+config("wglobal_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wglobal-constructors" ]
+  }
+}
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wexit-time-destructors" ]
+  }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# suppressing the rest of them.  Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+  cflags = []
+  if (is_clang) {
+    cflags += [ "-Wno-incompatible-pointer-types" ]
+  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+    cflags += [ "-w" ]
+  } else if (is_chromeos_ash && current_cpu == "arm") {
+    cflags += [ "-w" ]
+  }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_optimization" ]
+#   configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+  common_optimize_on_cflags = [
+    "/Ob2",  # Both explicit and auto inlining.
+    "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+    "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+  ]
+  if (!is_asan) {
+    common_optimize_on_cflags += [
+      # Put data in separate COMDATs. This allows the linker
+      # to put bit-identical constants at the same address even if
+      # they're unrelated constants, which saves binary size.
+      # This optimization can't be used when ASan is enabled because
+      # it is not compatible with the ASan ODR checker.
+      "/Gw",
+    ]
+  }
+  common_optimize_on_ldflags = []
+
+  # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+  # misleading symbols in stack traces.
+  if (!is_debug && !is_component_build) {
+    common_optimize_on_ldflags += [ "/OPT:ICF" ]  # Redundant COMDAT folding.
+  }
+
+  if (is_official_build) {
+    common_optimize_on_ldflags += [ "/OPT:REF" ]  # Remove unreferenced data.
+    # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
+  }
+} else {
+  common_optimize_on_cflags = []
+  common_optimize_on_ldflags = []
+
+  if (is_android) {
+    # TODO(jdduke) Re-enable on mips after resolving linking
+    # issues with libc++ (crbug.com/456380).
+    if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+      common_optimize_on_ldflags += [
+        # Warn in case of text relocations.
+        "-Wl,--warn-shared-textrel",
+      ]
+    }
+  }
+
+  if (is_apple) {
+    common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+
+    if (is_official_build) {
+      common_optimize_on_ldflags += [
+        "-Wl,-no_data_in_code_info",
+        "-Wl,-no_function_starts",
+      ]
+    }
+  } else if (current_os != "aix" && current_os != "zos") {
+    # Non-Mac Posix flags.
+    # Aix does not support these.
+
+    common_optimize_on_cflags += [
+      # Put data and code in their own sections, so that unused symbols
+      # can be removed at link time with --gc-sections.
+      "-fdata-sections",
+      "-ffunction-sections",
+    ]
+    if ((!is_nacl || is_nacl_saigo) && is_clang) {
+      # We don't care about unique section names, this makes object files a bit
+      # smaller.
+      common_optimize_on_cflags += [ "-fno-unique-section-names" ]
+    }
+
+    common_optimize_on_ldflags += [
+      # Specifically tell the linker to perform optimizations.
+      # See http://lwn.net/Articles/192624/ .
+      # -O2 enables string tail merge optimization in gold and lld.
+      "-Wl,-O2",
+      "-Wl,--gc-sections",
+    ]
+  }
+}
+
+config("default_stack_frames") {
+  if (!is_win) {
+    if (enable_frame_pointers) {
+      cflags = [ "-fno-omit-frame-pointer" ]
+
+      # Omit frame pointers for leaf functions on x86, otherwise building libyuv
+      # gives clang's register allocator issues, see llvm.org/PR15798 /
+      # crbug.com/233709
+      if (is_clang && current_cpu == "x86" && !is_apple) {
+        cflags += [ "-momit-leaf-frame-pointer" ]
+      }
+    } else {
+      cflags = [ "-fomit-frame-pointer" ]
+    }
+  }
+  # On Windows, the flag to enable framepointers "/Oy-" must always come after
+  # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+  # the "optimize" configs, see rest of this file. The ordering that cflags are
+  # applied is well-defined by the GN spec, and there is no way to ensure that
+  # cflags set by "default_stack_frames" is applied after those set by an
+  # "optimize" config. Similarly, there is no way to propagate state from this
+  # config into the "optimize" config. We always apply the "/Oy-" config in the
+  # definition for common_optimize_on_cflags definition, even though this may
+  # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+  if (is_win) {
+    if (chrome_pgo_phase != 2) {
+      # Favor size over speed, /O1 must be before the common flags.
+      # /O1 implies /Os and /GF.
+      cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+      rustflags = [ "-Copt-level=s" ]
+    } else {
+      # PGO requires all translation units to be compiled with /O2. The actual
+      # optimization level will be decided based on the profiling data.
+      cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
+
+      # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
+      # suggests not using an explicit `-Copt-level` at all, and the default is
+      # to optimize for performance like `/O2` for clang.
+      rustflags = []
+    }
+  } else if (optimize_for_size) {
+    # Favor size over speed.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+
+      if (use_ml_inliner && is_a_target_toolchain) {
+        cflags += [
+          "-mllvm",
+          "-enable-ml-inliner=release",
+        ]
+      }
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
+    # vectorization.
+    rustflags = [ "-Copt-level=z" ]
+  } else if (is_chromeos) {
+    # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+    # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+    # any cost" (AKA -Oz). It'd be nice to:
+    # - Make `optimize_for_size` apply to all platforms where we're optimizing
+    #   for size by default (so, also Windows)
+    # - Investigate -Oz here, maybe just for ARM?
+    cflags = [ "-Os" ] + common_optimize_on_cflags
+
+    # Similar to clang, we optimize with `-Copt-level=s` to keep loop
+    # vectorization while otherwise optimizing for size.
+    rustflags = [ "-Copt-level=s" ]
+  } else {
+    cflags = [ "-O2" ] + common_optimize_on_cflags
+
+    # The `-O3` for clang turns on extra optimizations compared to the standard
+    # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
+    # to use.
+    rustflags = [ "-Copt-level=3" ]
+  }
+  ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+  if (is_win) {
+    cflags = [
+      "/Od",  # Disable optimization.
+      "/Ob0",  # Disable all inlining (on by default).
+      "/GF",  # Enable string pooling (off by default).
+    ]
+
+    if (target_cpu == "arm64") {
+      # Disable omitting frame pointers for no_optimize build because stack
+      # traces on Windows ARM64 rely on it.
+      cflags += [ "/Oy-" ]
+    }
+  } else if (is_android && !android_full_debug) {
+    # On Android we kind of optimize some things that don't affect debugging
+    # much even when optimization is disabled to get the binary size down.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    if (!is_component_build) {
+      # Required for library partitions. Without this all symbols just end up
+      # in the base partition.
+      ldflags = [ "-Wl,--gc-sections" ]
+    }
+  } else if (is_fuchsia) {
+    # On Fuchsia, we optimize for size here to reduce the size of debug build
+    # packages so they can be run in a KVM. See crbug.com/910243 for details.
+    cflags = [ "-Og" ]
+  } else {
+    cflags = [ "-O0" ]
+    ldflags = []
+  }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O2" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O3" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+config("optimize_fuzzing") {
+  cflags = [ "-O1" ] + common_optimize_on_cflags
+  rustflags = [ "-Copt-level=1" ]
+  ldflags = common_optimize_on_ldflags
+  visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else if (optimize_for_fuzzing) {
+    assert(!is_win, "Fuzzing optimize level not supported on Windows")
+
+    # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even
+    # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
+    assert(!use_clang_coverage,
+           "optimize_for_fuzzing=true should not be used with " +
+               "use_clang_coverage=true.")
+    configs = [ ":optimize_fuzzing" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
+_clang_sample_profile = ""
+if (is_clang && is_a_target_toolchain) {
+  if (clang_sample_profile_path != "") {
+    _clang_sample_profile = clang_sample_profile_path
+  } else if (clang_use_default_sample_profile) {
+    assert(build_with_chromium,
+           "Our default profiles currently only apply to Chromium")
+    assert(is_android || is_chromeos || is_castos,
+           "The current platform has no default profile")
+    if (is_android || is_castos) {
+      _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+    } else {
+      assert(
+          chromeos_afdo_platform == "atom" ||
+              chromeos_afdo_platform == "bigcore" ||
+              chromeos_afdo_platform == "arm" ||
+              chromeos_afdo_platform == "arm-exp",
+          "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
+      _clang_sample_profile =
+          "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+    }
+  }
+}
+
+# Clang offers a way to assert that AFDO profiles are accurate, which causes it
+# to optimize functions not represented in a profile more aggressively for size.
+# This config can be toggled in cases where shaving off binary size hurts
+# performance too much.
+config("afdo_optimize_size") {
+  if (_clang_sample_profile != "" && sample_profile_is_accurate) {
+    cflags = [ "-fprofile-sample-accurate" ]
+  }
+}
+
+# GCC and clang support a form of profile-guided optimization called AFDO.
+# There are some targeted places that AFDO regresses, so we provide a separate
+# config to allow AFDO to be disabled per-target.
+config("afdo") {
+  if (is_clang) {
+    cflags = []
+    if (clang_emit_debug_info_for_profiling) {
+      # Add the following flags to generate debug info for profiling.
+      cflags += [ "-gline-tables-only" ]
+      if (!is_nacl) {
+        cflags += [ "-fdebug-info-for-profiling" ]
+      }
+    }
+    if (_clang_sample_profile != "") {
+      assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
+      rebased_clang_sample_profile =
+          rebase_path(_clang_sample_profile, root_build_dir)
+      cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+      if (use_profi) {
+        cflags += [ "-fsample-profile-use-profi" ]
+      }
+
+      # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
+      # These seem to be false positives - the complaints are about functions
+      # marked with `__nodebug__` not having associated debuginfo. In the case
+      # where this was observed, the `__nodebug__` function was also marked
+      # `__always_inline__` and had no branches, so AFDO info is likely useless
+      # there.
+      cflags += [ "-Wno-backend-plugin" ]
+      inputs = [ _clang_sample_profile ]
+    }
+  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+    cflags = [ "-fauto-profile=${auto_profile_path}" ]
+    inputs = [ auto_profile_path ]
+  }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_symbols" ]
+#   configs += [ "//build/config/compiler:symbols" ]
+
+# A helper config that all configs passing /DEBUG to the linker should
+# include as sub-config.
+config("win_pdbaltpath") {
+  visibility = [
+    ":minimal_symbols",
+    ":symbols",
+  ]
+
+  # /DEBUG causes the linker to generate a pdb file, and to write the absolute
+  # path to it in the executable file it generates.  This flag turns that
+  # absolute path into just the basename of the pdb file, which helps with
+  # build reproducibility. Debuggers look for pdb files next to executables,
+  # so there's minimal downside to always using this. However, post-mortem
+  # debugging of Chromium crash dumps and ETW tracing can be complicated by this
+  # switch so an option to omit it is important.
+  if (!use_full_pdb_paths) {
+    ldflags = [ "/pdbaltpath:%_PDB%" ]
+  }
+}
+
+# Full symbols.
+config("symbols") {
+  rustflags = []
+  if (is_win) {
+    if (is_clang) {
+      cflags = [
+        # Debug information in the .obj files.
+        "/Z7",
+
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    } else {
+      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.
+    }
+
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = []
+    if (is_mac && enable_dsyms) {
+      # If generating dSYMs, specify -fno-standalone-debug. This was
+      # originally specified for https://crbug.com/479841 because dsymutil
+      # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+      # version 7 also produces debug data that is incompatible with Breakpad
+      # dump_syms, so this is still required (https://crbug.com/622406).
+      cflags += [ "-fno-standalone-debug" ]
+    }
+
+    # On aix -gdwarf causes linker failures due to thread_local variables.
+    if (!is_nacl && current_os != "aix") {
+      if (use_dwarf5) {
+        cflags += [ "-gdwarf-5" ]
+        rustflags += [ "-Zdwarf-version=5" ]
+      } else {
+        # Recent clang versions default to DWARF5 on Linux, and Android is about
+        # to switch. TODO: Adopt that in controlled way. For now, keep DWARF4.
+        # Apple platforms still default to 4 in clang, so they don't need the
+        # cflags.
+        if (!is_apple) {
+          cflags += [ "-gdwarf-4" ]
+        }
+
+        # On Apple, rustc defaults to DWARF2 so it needs to be told how to
+        # match clang.
+        rustflags += [ "-Zdwarf-version=4" ]
+      }
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if ((!is_nacl || is_nacl_saigo) && current_os != "zos") {
+      cflags += [ "-g2" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
+      # to be manually enabled.
+      #
+      # It is skipped in tsan and asan because enabling it causes some
+      # formatting changes in the output which would require fixing bunches
+      # of expectation regexps.
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    if (is_apple) {
+      swiftflags = [ "-g" ]
+    }
+
+    if (use_debug_fission) {
+      cflags += [ "-gsplit-dwarf" ]
+    }
+    asmflags = cflags
+    ldflags = []
+
+    # Split debug info with all thinlto builds except nacl and apple.
+    # thinlto requires -gsplit-dwarf in ldflags.
+    if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) {
+      ldflags += [ "-gsplit-dwarf" ]
+    }
+
+    # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+    # currently we get "warning:
+    # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+    # DWARF info may be corrupt; offsets in a range list entry are in different
+    # sections" there.  Maybe just a bug in nacl_switch_32.S.
+    _enable_gdb_index =
+        symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" &&
+        current_os != "zos" && (use_gold || use_lld) &&
+        # Disable on non-fission 32-bit Android because it pushes
+        # libcomponents_unittests over the 4gb size limit.
+        !(is_android && !use_debug_fission && current_cpu != "x64" &&
+          current_cpu != "arm64")
+    if (_enable_gdb_index) {
+      if (is_clang) {
+        # This flag enables the GNU-format pubnames and pubtypes sections,
+        # which lld needs in order to generate a correct GDB index.
+        # TODO(pcc): Try to make lld understand non-GNU-format pubnames
+        # sections (llvm.org/PR34820).
+        cflags += [ "-ggnu-pubnames" ]
+      }
+      ldflags += [ "-Wl,--gdb-index" ]
+    }
+  }
+
+  configs = []
+
+  # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
+  # https://b/243982712.
+  if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
+      !is_nacl && current_cpu == "arm") {
+    configs += [ "//build/config:compress_debug_sections" ]
+  }
+
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+    if (is_apple) {
+      # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+      # Make sure we don't use constructor homing on mac.
+      cflags += [
+        "-Xclang",
+        "-debug-info-kind=limited",
+      ]
+    } else {
+      # Use constructor homing for debug info. This option reduces debug info
+      # by emitting class type info only when constructors are emitted.
+      cflags += [
+        "-Xclang",
+        "-fuse-ctor-homing",
+      ]
+    }
+  }
+  rustflags += [ "-g" ]
+}
+
+# Minimal symbols.
+# This config guarantees to hold symbol for stack trace which are shown to user
+# when crash happens in unittests running on buildbot.
+config("minimal_symbols") {
+  rustflags = []
+  if (is_win) {
+    # Functions, files, and line tables only.
+    cflags = []
+
+    if (is_clang) {
+      cflags += [
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    }
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+
+    # Enable line tables for clang. MSVC doesn't have an equivalent option.
+    if (is_clang) {
+      # -gline-tables-only is the same as -g1, but clang-cl only exposes the
+      # former.
+      cflags += [ "-gline-tables-only" ]
+    }
+  } else {
+    cflags = []
+    if (is_mac && !use_dwarf5) {
+      # clang defaults to DWARF2 on macOS unless mac_deployment_target is
+      # at least 10.11.
+      # TODO(thakis): Remove this once mac_deployment_target is 10.11.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    } else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
+      # On aix -gdwarf causes linker failures due to thread_local variables.
+      # Recent clang versions default to DWARF5 on Linux, and Android is about
+      # to switch. TODO: Adopt that in controlled way.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    }
+
+    if (use_dwarf5 && !is_nacl) {
+      cflags += [ "-gdwarf-5" ]
+      rustflags += [ "-Zdwarf-version=5" ]
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [ "-g1" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # See comment for -gdwarf-aranges in config("symbols").
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    ldflags = []
+    if (is_android && is_clang) {
+      # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
+      # doesn't emit DW_AT_linkage_name in -g1 builds.
+      # -fdebug-info-for-profiling enables that (and a bunch of other things we
+      # don't need), so that we get qualified names in stacks.
+      # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
+      #               failing that consider doing this on non-Android too.
+      cflags += [ "-fdebug-info-for-profiling" ]
+    }
+
+    asmflags = cflags
+  }
+  rustflags += [ "-Cdebuginfo=1" ]
+}
+
+# This configuration contains function names only. That is, the compiler is
+# told to not generate debug information and the linker then just puts function
+# names in the final debug information.
+config("no_symbols") {
+  if (is_win) {
+    ldflags = [ "/DEBUG" ]
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
+  }
+
+  # This config is removed by base unittests apk.
+  if (is_android && is_clang && strip_debug_info) {
+    configs += [ ":strip_debug" ]
+  }
+}
+
+config("strip_debug") {
+  if (!defined(ldflags)) {
+    ldflags = []
+  }
+  ldflags += [ "-Wl,--strip-debug" ]
+}
+
+if (is_apple) {
+  # On macOS and iOS, this enables support for ARC (automatic reference
+  # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+  #
+  # -fobjc-arc enables ARC overall.
+  #
+  # ARC does not add exception handlers to pure Objective-C code, but does add
+  # them to Objective-C++ code with the rationale that C++ pervasively adds them
+  # in for exception safety. However, exceptions are banned in Chromium code for
+  # C++ and exceptions in Objective-C code are intended to be fatal, so
+  # -fno-objc-arc-exceptions is specified to disable these unwanted exception
+  # handlers.
+  config("enable_arc") {
+    common_flags = [
+      "-fobjc-arc",
+      "-fno-objc-arc-exceptions",
+    ]
+    cflags_objc = common_flags
+    cflags_objcc = common_flags
+  }
+}
+
+if (is_android) {
+  # Use orderfile for linking Chrome on Android.
+  # This config enables using an orderfile for linking in LLD.
+  config("chrome_orderfile_config") {
+    # Don't try to use an orderfile with call graph sorting, except on Android,
+    # where we care about memory used by code, so we still want to mandate
+    # ordering.
+    if (chrome_orderfile_path != "") {
+      assert(use_lld)
+      _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
+      ldflags = [
+        "-Wl,--symbol-ordering-file",
+        "-Wl,$_rebased_orderfile",
+        "-Wl,--no-warn-symbol-ordering",
+      ]
+      inputs = [ chrome_orderfile_path ]
+    }
+  }
+}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+  cflags = []
+  if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+    if (init_stack_vars_zero) {
+      cflags += [ "-ftrivial-auto-var-init=zero" ]
+    } else {
+      cflags += [ "-ftrivial-auto-var-init=pattern" ]
+    }
+  }
+}
+
+buildflag_header("compiler_buildflags") {
+  header = "compiler_buildflags.h"
+
+  flags = [
+    "CLANG_PGO=$chrome_pgo_phase",
+    "SYMBOL_LEVEL=$symbol_level",
+  ]
+}
+
+config("cet_shadow_stack") {
+  if (enable_cet_shadow_stack && is_win) {
+    assert(target_cpu == "x64")
+    ldflags = [ "/CETCOMPAT" ]
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-target-arm.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/src/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/src/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/src/build/config/compiler/BUILD.gn	(revision 192)
@@ -0,0 +1,2932 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/buildflag_header.gni")
+import("//build/config/android/config.gni")
+import("//build/config/c++/c++.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/coverage/coverage.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/host_byteorder.gni")
+import("//build/config/rust.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/rbe.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+  import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el" ||
+    current_cpu == "mips" || current_cpu == "mips64") {
+  import("//build/config/mips.gni")
+}
+if (is_mac) {
+  import("//build/config/apple/symbols.gni")
+}
+if (is_ios) {
+  import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+  # To keep NaCl variables out of builds that don't include NaCl, all
+  # variables defined in nacl/config.gni referenced here should be protected by
+  # is_nacl conditions.
+  import("//build/config/nacl/config.gni")
+}
+
+lld_path = ""
+if (!is_clang) {
+  declare_args() {
+    # This allows overriding the location of lld.
+    lld_path = rebase_path("$clang_base_path/bin", root_build_dir)
+  }
+} else {
+  # clang looks for lld next to it, no need for -B.
+  lld_path = ""
+}
+
+declare_args() {
+  # Normally, Android builds are lightly optimized, even for debug builds, to
+  # keep binary size down. Setting this flag to true disables such optimization
+  android_full_debug = false
+
+  # Compile in such a way as to make it possible for the profiler to unwind full
+  # stack frames. Setting this flag has a large effect on the performance of the
+  # generated code than just setting profiling, but gives the profiler more
+  # information to analyze.
+  # Requires profiling to be set to true.
+  enable_full_stack_frames_for_profiling = false
+
+  # When we are going to use gold we need to find it.
+  # This is initialized below, after use_gold might have been overridden.
+  gold_path = ""
+
+  # Enable fatal linker warnings. Building Chromium with certain versions
+  # of binutils can cause linker warning.
+  fatal_linker_warnings = true
+
+  # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+  # but some sanitizers are known to require it, like CFI diagnostics
+  # and UBsan variants.
+  use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+  # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+  # optimization that GCC supports. It used by ChromeOS in their official
+  # builds. To use it, set auto_profile_path to the path to a file containing
+  # the needed gcov profiling data.
+  auto_profile_path = ""
+
+  # Path to an AFDO profile to use while building with clang, if any. Empty
+  # implies none.
+  clang_sample_profile_path = ""
+
+  # Some configurations have default sample profiles. If this is true and
+  # clang_sample_profile_path is empty, we'll fall back to the default.
+  #
+  # We currently only have default profiles for Chromium in-tree, so we disable
+  # this by default for all downstream projects, since these profiles are likely
+  # nonsensical for said projects.
+  clang_use_default_sample_profile =
+      chrome_pgo_phase == 0 && build_with_chromium && is_official_build &&
+      (is_android || chromeos_is_browser_only)
+
+  # This configuration is used to select a default profile in Chrome OS based on
+  # the microarchitectures we are using. This is only used if
+  # clang_use_default_sample_profile is true and clang_sample_profile_path is
+  # empty.
+  chromeos_afdo_platform = "atom"
+
+  # Emit debug information for profiling wile building with clang.
+  # Only enable this for ChromeOS official builds for AFDO.
+  clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
+
+  # Turn this on to have the compiler output extra timing information.
+  compiler_timing = false
+
+  # Turn this on to use ghash feature of lld for faster debug link on Windows.
+  # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
+  use_ghash = true
+
+  # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on
+  # can substantially increase link time and binary size, but they generally
+  # also make binaries a fair bit faster.
+  #
+  # TODO(gbiv): We disable optimizations by default on most platforms because
+  # the space overhead is too great. We should use some mixture of profiles and
+  # optimization settings to better tune the size increase.
+  thin_lto_enable_optimizations =
+      (is_chromeos || is_android || is_win || is_linux || is_mac ||
+       (is_ios && use_lld)) && is_official_build
+
+  # Initialize all local variables with a pattern. This flag will fill
+  # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
+  # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
+  # recognizable in the debugger, and crashes on memory accesses through
+  # uninitialized pointers.
+  #
+  # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and
+  # needs to be evaluated before enabling it there as well.
+  init_stack_vars = !(is_android && is_official_build)
+
+  # Zero init has favorable performance/size tradeoffs for Chrome OS
+  # but was not evaluated for other platforms.
+  init_stack_vars_zero = is_chromeos
+
+  # This argument is to control whether enabling text section splitting in the
+  # final binary. When enabled, the separated text sections with prefix
+  # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be
+  # merged to '.text' section. This allows us to identify the hot code section
+  # ('.text.hot') in the binary, which allows our data collection pipelines to
+  # more easily identify code that we assume to be hot/cold that doesn't turn
+  # out to be such in the field.
+  use_text_section_splitting = is_chromeos
+
+  # Enable DWARF v5.
+  use_dwarf5 = false
+
+  # Override this to put full paths to PDBs in Windows PE files. This helps
+  # windbg and Windows Performance Analyzer with finding the PDBs in some local-
+  # build scenarios. This is never needed for bots or official builds. Because
+  # this puts the output directory in the DLLs/EXEs it breaks build determinism.
+  # Bugs have been reported to the windbg/WPA teams and this workaround will be
+  # removed when they are fixed.
+  use_full_pdb_paths = false
+
+  # Enable -H, which prints the include tree during compilation.
+  # For use by tools/clang/scripts/analyze_includes.py
+  show_includes = false
+
+  # Enable Profi algorithm. Profi can infer block and edge counts.
+  # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
+  # TODO(crbug.com/1375958i:) Possibly enable this for Android too.
+  use_profi = is_chromeos
+
+  # If true, linker crashes will be rerun with `--reproduce` which causes
+  # a reproducer file to be saved.
+  save_reproducers_on_lld_crash = false
+
+  # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
+  # shadow call stack in register x18. Hence, x18 must not be used by the OS
+  # or libraries. We assume that to be the case for high end Android
+  # configurations. For more details see
+  # https://clang.llvm.org/docs/ShadowCallStack.html
+  enable_shadow_call_stack = false
+
+  # Use DWARF simple template names, with the following exceptions:
+  #
+  # * Windows is not supported as it doesn't use DWARF.
+  # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
+  #   lldb doesn't have the needed changes yet.
+  # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
+  #
+  # This greatly reduces the size of debug builds, at the cost of
+  # debugging information which is required by some specialized
+  # debugging tools.
+  simple_template_names = is_clang && !is_nacl && !is_win && !is_apple
+}
+
+declare_args() {
+  # Set to true to use icf, Identical Code Folding.
+  #
+  # icf=all is broken in older golds, see
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+  # chromeos binutils has been patched with the fix, so always use icf there.
+  # The bug only affects x86 and x64, so we can still use ICF when targeting
+  # other architectures.
+  #
+  # lld doesn't have the bug.
+  use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer &&
+            !use_clang_coverage && current_os != "zos" &&
+            !(is_android && use_order_profiling) &&
+            (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" ||
+                                                       current_cpu == "x64"))))
+}
+
+if (is_android) {
+  # Set the path to use orderfile for linking Chrome
+  # Note that this is for using only one orderfile for linking
+  # the Chrome binary/library.
+  declare_args() {
+    chrome_orderfile_path = ""
+
+    if (defined(default_chrome_orderfile)) {
+      # Allow downstream tools to set orderfile path with
+      # another variable.
+      chrome_orderfile_path = default_chrome_orderfile
+    }
+  }
+}
+
+declare_args() {
+  # Turn off the --call-graph-profile-sort flag for lld by default. Enable
+  # selectively for targets where it's beneficial.
+  enable_call_graph_profile_sort =
+      chrome_pgo_phase == 2 ||
+      (is_chromeos &&
+       (clang_use_default_sample_profile || clang_sample_profile_path != ""))
+}
+
+assert(!(llvm_force_head_revision && use_goma),
+       "can't use goma with trunk clang")
+assert(!(llvm_force_head_revision && use_remoteexec),
+       "can't use rbe with trunk clang")
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+  include_dirs = [
+    "//",
+    root_gen_dir,
+  ]
+}
+
+# Compiler instrumentation can introduce dependencies in DSOs to symbols in
+# the executable they are loaded into, so they are unresolved at link-time.
+config("no_unresolved_symbols") {
+  if (!using_sanitizer &&
+      (is_linux || is_chromeos || is_android || is_fuchsia)) {
+    ldflags = [
+      "-Wl,-z,defs",
+      "-Wl,--as-needed",
+    ]
+  }
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  cflags_objc = []
+  cflags_objcc = []
+  rustflags = []
+  ldflags = []
+  defines = []
+  configs = []
+  rustflags = []
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:compiler" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:compiler" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:compiler" ]
+  } else if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:compiler" ]
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:compiler" ]
+  } else if (is_fuchsia) {
+    configs += [ "//build/config/fuchsia:compiler" ]
+  } else if (current_os == "aix") {
+    configs += [ "//build/config/aix:compiler" ]
+  } else if (current_os == "zos") {
+    configs += [ "//build/config/zos:compiler" ]
+  }
+
+  configs += [
+    # See the definitions below.
+    ":clang_revision",
+    ":rustc_revision",
+    ":compiler_cpu_abi",
+    ":compiler_codegen",
+    ":compiler_deterministic",
+  ]
+
+  # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
+  # operations (e.g. dereferencing) into defined behavior. This avoids deletion
+  # of some security-critical code: see https://crbug.com/1139129.
+  # Nacl does not support the flag. And, we still want UBSAN to catch undefined
+  # behavior related to nullptrs, so do not add this flag if UBSAN is enabled.
+  # GCC seems to have some bugs compiling constexpr code when this is defined,
+  # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
+  # TODO(mpdenton): remove is_clang once GCC bug is fixed.
+  if (!is_nacl && !is_ubsan && is_clang) {
+    cflags += [ "-fno-delete-null-pointer-checks" ]
+  }
+
+  # Don't emit the GCC version ident directives, they just end up in the
+  # .comment section or debug info taking up binary size, and makes comparing
+  # .o files built with different compiler versions harder.
+  if (!is_win || is_clang) {
+    cflags += [ "-fno-ident" ]
+  }
+
+  # In general, Windows is totally different, but all the other builds share
+  # some common compiler and linker configuration.
+  if (!is_win) {
+    # Common POSIX compiler flags setup.
+    # --------------------------------
+    cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204
+
+    # Stack protection. ShadowCallStack and Stack protector address the same
+    # problems. Therefore, we only enable one or the other. Clang advertises SCS as
+    # a stronger alternative to StackProtector, so we give SCS precedence over SP.
+    if (enable_shadow_call_stack) {
+      # On Aarch64, SCS requires the x18 register to be unused because it will hold
+      # a pointer to the shadow stack. For Android we know that Clang doesn't use
+      # x18 by default. On other OSs adding "-ffixed-x18" might be required.
+      assert(is_android)
+
+      scs_parameters = [
+        "-fsanitize=shadow-call-stack",
+        "-fno-stack-protector",
+      ]
+      cflags += scs_parameters
+      ldflags += scs_parameters
+    } else {
+      if (is_apple) {
+        # The strong variant of the stack protector significantly increases
+        # binary size, so only enable it in debug mode.
+        if (is_debug) {
+          cflags += [ "-fstack-protector-strong" ]
+        } else {
+          cflags += [ "-fstack-protector" ]
+        }
+      } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
+        # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+        # See also https://crbug.com/533294
+        # The x86 toolchain currently has problems with stack-protector.
+        if (is_android && current_cpu == "x86") {
+          cflags += [ "-fno-stack-protector" ]
+        } else if (current_os != "aix") {
+          # Not available on aix.
+          cflags += [ "-fstack-protector" ]
+        }
+      }
+    }
+
+    if (use_lld) {
+      ldflags += [ "-fuse-ld=lld" ]
+      if (lld_path != "") {
+        ldflags += [ "-B$lld_path" ]
+      }
+    }
+
+    # Linker warnings.
+    if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
+        current_os != "zos") {
+      ldflags += [ "-Wl,--fatal-warnings" ]
+    }
+    if (fatal_linker_warnings && is_apple) {
+      ldflags += [ "-Wl,-fatal_warnings" ]
+    }
+  }
+
+  if (is_clang && is_debug) {
+    # Allow comparing the address of references and 'this' against 0
+    # in debug builds. Technically, these can never be null in
+    # well-defined C/C++ and Clang can optimize such checks away in
+    # release builds, but they may be used in asserts in debug builds.
+    cflags_cc += [
+      "-Wno-undefined-bool-conversion",
+      "-Wno-tautological-undefined-compare",
+    ]
+  }
+
+  # Non-Apple Posix and Fuchsia compiler flags setup.
+  # -----------------------------------
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    if (enable_profiling) {
+      if (!is_debug) {
+        cflags += [ "-g" ]
+
+        if (enable_full_stack_frames_for_profiling) {
+          cflags += [
+            "-fno-inline",
+            "-fno-optimize-sibling-calls",
+          ]
+        }
+      }
+    }
+
+    # Explicitly pass --build-id to ld. Compilers used to always pass this
+    # implicitly but don't any more (in particular clang when built without
+    # ENABLE_LINKER_BUILD_ID=ON).
+    if (is_official_build) {
+      # The sha1 build id has lower risk of collision but is more expensive to
+      # compute, so only use it in the official build to avoid slowing down
+      # links.
+      ldflags += [ "-Wl,--build-id=sha1" ]
+    } else if (current_os != "aix" && current_os != "zos") {
+      ldflags += [ "-Wl,--build-id" ]
+    }
+
+    if (!is_android) {
+      defines += [
+        # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
+        # the behavior of the Android NDK from earlier versions.
+        # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
+        "_FILE_OFFSET_BITS=64",
+        "_LARGEFILE_SOURCE",
+        "_LARGEFILE64_SOURCE",
+      ]
+    }
+
+    if (!is_nacl) {
+      if (exclude_unwind_tables) {
+        cflags += [
+          "-fno-unwind-tables",
+          "-fno-asynchronous-unwind-tables",
+        ]
+        rustflags += [ "-Cforce-unwind-tables=no" ]
+        defines += [ "NO_UNWIND_TABLES" ]
+      } else {
+        cflags += [ "-funwind-tables" ]
+        rustflags += [ "-Cforce-unwind-tables=yes" ]
+      }
+    }
+  }
+
+  # Apple compiler flags setup.
+  # ---------------------------------
+  if (is_apple) {
+    # On Intel, clang emits both Apple's "compact unwind" information and
+    # DWARF eh_frame unwind information by default, for compatibility reasons.
+    # This flag limits emission of eh_frame information to functions
+    # whose unwind information can't be expressed in the compact unwind format
+    # (which in practice means almost everything gets only compact unwind
+    # entries). This reduces object file size a bit and makes linking a bit
+    # faster.
+    # On arm64, this is already the default behavior.
+    if (current_cpu == "x64") {
+      asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+      cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+    }
+  }
+
+  # Linux/Android/Fuchsia common flags setup.
+  # ---------------------------------
+  if (is_linux || is_chromeos || is_android || is_fuchsia) {
+    asmflags += [ "-fPIC" ]
+    cflags += [ "-fPIC" ]
+    ldflags += [ "-fPIC" ]
+    rustflags += [ "-Crelocation-model=pic" ]
+
+    if (!is_clang) {
+      # Use pipes for communicating between sub-processes. Faster.
+      # (This flag doesn't do anything with Clang.)
+      cflags += [ "-pipe" ]
+    }
+
+    ldflags += [
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+    ]
+
+    if (!is_component_build) {
+      ldflags += [ "-Wl,-z,now" ]
+    }
+  }
+
+  # Linux-specific compiler flags setup.
+  # ------------------------------------
+  if (use_gold) {
+    ldflags += [ "-fuse-ld=gold" ]
+    if (!is_android) {
+      # On Android, this isn't needed.  gcc in the NDK knows to look next to
+      # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+      # above.
+      if (gold_path != "") {
+        ldflags += [ "-B$gold_path" ]
+      }
+
+      ldflags += [
+        # Experimentation found that using four linking threads
+        # saved ~20% of link time.
+        # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+        # Only apply this to the target linker, since the host
+        # linker might not be gold, but isn't used much anyway.
+        "-Wl,--threads",
+        "-Wl,--thread-count=4",
+      ]
+    }
+
+    # TODO(thestig): Make this flag work with GN.
+    #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+    #  ldflags += [
+    #    "-Wl,--detect-odr-violations",
+    #  ]
+    #}
+  }
+
+  if (use_icf && (!is_apple || use_lld)) {
+    ldflags += [ "-Wl,--icf=all" ]
+  }
+
+  if (is_linux || is_chromeos) {
+    cflags += [ "-pthread" ]
+    # Do not use the -pthread ldflag here since it becomes a no-op
+    # when using -nodefaultlibs, which would cause an unused argument
+    # error.  "-lpthread" is added in //build/config:default_libs.
+  }
+
+  # Clang-specific compiler flags setup.
+  # ------------------------------------
+  if (is_clang) {
+    cflags += [ "-fcolor-diagnostics" ]
+
+    # Enable -fmerge-all-constants. This used to be the default in clang
+    # for over a decade. It makes clang non-conforming, but is fairly safe
+    # in practice and saves some binary size. We might want to consider
+    # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13),
+    # but for now it looks like our build might rely on it
+    # (https://crbug.com/829795).
+    cflags += [ "-fmerge-all-constants" ]
+  }
+
+  if (use_lld) {
+    # TODO(thakis): Make the driver pass --color-diagnostics to the linker
+    # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
+    # in ldflags instead.
+    if (is_win) {
+      # On Windows, we call the linker directly, instead of calling it through
+      # the driver.
+      ldflags += [ "--color-diagnostics" ]
+    } else {
+      ldflags += [ "-Wl,--color-diagnostics" ]
+    }
+  }
+
+  # Enable text section splitting only on linux when using lld for now. Other
+  # platforms can be added later if needed.
+  if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) {
+    ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
+  }
+
+  if (is_clang && !is_nacl && current_os != "zos") {
+    cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
+    if (save_reproducers_on_lld_crash && use_lld) {
+      ldflags += [
+        "-fcrash-diagnostics=all",
+        "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
+      ]
+    }
+
+    # TODO(hans): Remove this once Clang generates better optimized debug info
+    # by default. https://crbug.com/765793
+    cflags += [
+      "-mllvm",
+      "-instcombine-lower-dbg-declare=0",
+    ]
+    if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+      if (is_win) {
+        ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
+      } else {
+        ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
+      }
+    }
+
+    # TODO(crbug.com/1235145): Investigate why/if this should be needed.
+    if (is_win) {
+      cflags += [ "/clang:-ffp-contract=off" ]
+    } else {
+      cflags += [ "-ffp-contract=off" ]
+    }
+  }
+
+  # C11/C++11 compiler flags setup.
+  # ---------------------------
+  if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
+      current_os == "aix") {
+    if (is_clang) {
+      standard_prefix = "c"
+
+      # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
+      # defined by the compiler.  However, lots of code relies on the
+      # non-standard features that _GNU_SOURCE enables, so define it manually.
+      defines += [ "_GNU_SOURCE" ]
+
+      if (is_nacl) {
+        # Undefine __STRICT_ANSI__ to get non-standard features which would
+        # otherwise not be enabled by NaCl's sysroots.
+        cflags += [ "-U__STRICT_ANSI__" ]
+      }
+    } else {
+      # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
+      # but we use this feature in several places in Chromium.
+      # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the
+      # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
+      # to -std=c*.
+      standard_prefix = "gnu"
+    }
+
+    cflags_c += [ "-std=${standard_prefix}11" ]
+    if (is_nacl && !is_nacl_saigo) {
+      # This is for the pnacl_newlib toolchain. It's only used to build
+      # a few independent ppapi test files that don't pull in any other
+      # dependencies.
+      cflags_cc += [ "-std=${standard_prefix}++14" ]
+      if (is_clang) {
+        cflags_cc += [ "-fno-trigraphs" ]
+      }
+    } else if (is_clang) {
+      if (defined(use_cxx17) && use_cxx17) {
+        cflags_cc += [ "-std=${standard_prefix}++17" ]
+      } else {
+        cflags_cc += [ "-std=${standard_prefix}++20" ]
+      }
+    } else {
+      # The gcc bots are currently using GCC 9, which is not new enough to
+      # support "c++20"/"gnu++20".
+      cflags_cc += [ "-std=${standard_prefix}++2a" ]
+    }
+  } else if (is_win) {
+    cflags_c += [ "/std:c11" ]
+    if ((defined(use_cxx17) && use_cxx17) ||
+        (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) {
+      cflags_cc += [ "/std:c++17" ]
+    } else {
+      cflags_cc += [ "/std:c++20" ]
+    }
+  } else if (!is_nacl) {
+    # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
+    # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
+    # more, but there are still a few buildbots using it, so until those are
+    # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
+    # clause, above.
+    cflags_c += [ "-std=c11" ]
+
+    if (defined(use_cxx17) && use_cxx17) {
+      cflags_cc += [ "-std=c++17" ]
+    } else {
+      cflags_cc += [ "-std=c++20" ]
+    }
+  }
+
+  if (is_clang && current_os != "zos") {
+    # C++17 removes trigraph support, but clang still warns that it ignores
+    # them when seeing them.  Don't.
+    cflags_cc += [ "-Wno-trigraphs" ]
+  }
+
+  if (use_relative_vtables_abi) {
+    cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
+    ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
+  }
+
+  # Add flags for link-time optimization. These flags enable
+  # optimizations/transformations that require whole-program visibility at link
+  # time, so they need to be applied to all translation units, and we may end up
+  # with miscompiles if only part of the program is compiled with LTO flags. For
+  # that reason, we cannot allow targets to enable or disable these flags, for
+  # example by disabling the optimize configuration.
+  # TODO(pcc): Make this conditional on is_official_build rather than on gn
+  # flags for specific features.
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    assert(use_lld, "LTO is only supported with lld")
+
+    cflags += [
+      "-flto=thin",
+      "-fsplit-lto-unit",
+    ]
+
+    # Limit the size of the ThinLTO cache to the lesser of 10% of
+    # available disk space, 40GB and 100000 files.
+    cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000"
+
+    # An import limit of 30 has better performance (per speedometer) and lower
+    # binary size than the default setting of 100.
+    # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
+    # should be able to better manage binary size increases on its own.
+    import_instr_limit = 30
+
+    if (is_win) {
+      ldflags += [
+        "/opt:lldltojobs=all",
+        "-mllvm:-import-instr-limit=$import_instr_limit",
+        "/lldltocache:" +
+            rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+        "/lldltocachepolicy:$cache_policy",
+        "-mllvm:-disable-auto-upgrade-debug-info",
+      ]
+    } else {
+      ldflags += [ "-flto=thin" ]
+
+      # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory
+      # usage in crbug.com/1038040. Note this will increase build time in
+      # Chrome OS.
+
+      # In ThinLTO builds, we run at most one link process at a time,
+      # and let it use all cores.
+      # TODO(thakis): Check if '=0' (that is, number of cores, instead
+      # of "all" which means number of hardware threads) is faster.
+      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_apple) {
+        ldflags += [
+          "-Wl,-cache_path_lto," +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+          "-Wcrl,object_path_lto",
+        ]
+      } else {
+        ldflags +=
+            [ "-Wl,--thinlto-cache-dir=" +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ]
+      }
+
+      ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+
+      if (is_chromeos) {
+        # ARM was originally set lower than x86 to keep the size
+        # bloat of ThinLTO to <10%, but that's potentially no longer true.
+        # FIXME(inglorion): maybe tune these?
+        # TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
+        import_instr_limit = 20
+      } else if (is_android) {
+        # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win
+        # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB.
+        import_instr_limit = 5
+      }
+
+      ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
+
+      if (!is_chromeos) {
+        # TODO(https://crbug.com/972449): turn on for ChromeOS when that
+        # toolchain has this flag.
+        # We only use one version of LLVM within a build so there's no need to
+        # upgrade debug info, which can be expensive since it runs the verifier.
+        ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
+      }
+    }
+
+    # TODO(https://crbug.com/1211155): investigate why this isn't effective on
+    # arm32.
+    if (!is_android || current_cpu == "arm64") {
+      cflags += [ "-fwhole-program-vtables" ]
+
+      if (toolchain_supports_rust_thin_lto) {
+        # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
+        # behaviour. Rust needs to know the linker will be doing LTO in this case
+        # or it rejects the Zsplit-lto-unit flag.
+        rustflags += [
+          "-Zsplit-lto-unit",
+          "-Clinker-plugin-lto=yes",
+        ]
+      } else {
+        # Don't include bitcode if it won't be used.
+        rustflags += [ "-Cembed-bitcode=no" ]
+      }
+
+      if (!is_win) {
+        ldflags += [ "-fwhole-program-vtables" ]
+      }
+    }
+
+    # This flag causes LTO to create an .ARM.attributes section with the correct
+    # architecture. This is necessary because LLD will refuse to link a program
+    # unless the architecture revision in .ARM.attributes is sufficiently new.
+    # TODO(pcc): The contents of .ARM.attributes should be based on the
+    # -march flag passed at compile time (see llvm.org/pr36291).
+    if (current_cpu == "arm") {
+      ldflags += [ "-march=$arm_arch" ]
+    }
+  }
+
+  if (compiler_timing) {
+    if (is_clang && !is_nacl) {
+      cflags += [ "-ftime-trace" ]
+    } else if (is_win) {
+      cflags += [
+        # "Documented" here:
+        # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
+        "/d2cgsummary",
+      ]
+    }
+  }
+
+  # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize
+  # stack crashes (http://crbug.com/919499).
+  if (use_lld && is_android) {
+    ldflags += [ "-Wl,--no-rosegment" ]
+  }
+
+  # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+  # --no-undefined-version.
+  if (use_lld && !is_win && !is_mac && !is_ios) {
+    ldflags += [ "-Wl,--undefined-version" ]
+  }
+
+  if (use_lld && is_apple) {
+    ldflags += [ "-Wl,--strict-auto-link" ]
+  }
+
+  # LLD does call-graph-sorted binary layout by default when profile data is
+  # present. On Android this increases binary size due to more thinks for long
+  # jumps. Turn it off by default and enable selectively for targets where it's
+  # beneficial.
+  if (use_lld && !enable_call_graph_profile_sort) {
+    if (is_win) {
+      ldflags += [ "/call-graph-profile-sort:no" ]
+    } else {
+      ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
+    }
+  }
+
+  if (is_clang && !is_nacl && show_includes) {
+    if (is_win) {
+      # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
+      assert(!use_goma, "show_includes on Windows is not reliable with goma")
+      cflags += [
+        "/clang:-H",
+        "/clang:-fshow-skipped-includes",
+      ]
+    } else {
+      cflags += [
+        "-H",
+        "-fshow-skipped-includes",
+      ]
+    }
+  }
+
+  # This flag enforces that member pointer base types are complete. It helps
+  # prevent us from running into problems in the Microsoft C++ ABI (see
+  # https://crbug.com/847724).
+  if (is_clang && !is_nacl && target_os != "chromeos" &&
+      (is_win || use_custom_libcxx)) {
+    cflags += [ "-fcomplete-member-pointers" ]
+  }
+
+  # Use DWARF simple template names.
+  if (simple_template_names) {
+    cflags_cc += [ "-gsimple-template-names" ]
+  }
+
+  # MLGO specific flags. These flags enable an ML-based inliner trained on
+  # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
+  # The "release" ML model is embedded into clang as part of its build.
+  # Currently, the ML inliner is only enabled when targeting Android due to:
+  # a) Android is where size matters the most.
+  # b) MLGO presently has the limitation of only being able to embed one model
+  #    at a time; It is unclear if the embedded model is beneficial for
+  #    non-Android targets.
+  # MLGO is only officially supported on linux.
+  if (use_ml_inliner && is_a_target_toolchain) {
+    assert(
+        is_android && host_os == "linux",
+        "MLGO is currently only supported for targeting Android on a linux host")
+    if (use_thin_lto) {
+      ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
+    }
+  }
+
+  if (clang_embed_bitcode) {
+    assert(!use_thin_lto,
+           "clang_embed_bitcode is only supported in non-ThinLTO builds")
+    cflags += [
+      "-Xclang",
+      "-fembed-bitcode=all",
+    ]
+  }
+
+  if (lld_emit_indexes_and_imports) {
+    assert(use_thin_lto,
+           "lld_emit_indexes_and_imports is only supported with ThinLTO builds")
+    ldflags += [
+      "-Wl,--save-temps=import",
+      "-Wl,--thinlto-emit-index-files",
+    ]
+  }
+
+  # Pass the same C/C++ flags to the objective C/C++ compiler.
+  cflags_objc += cflags_c
+  cflags_objcc += cflags_cc
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler. The Windows assembler takes different types of flags
+  # so only do so for posix platforms.
+  if (is_posix || is_fuchsia) {
+    asmflags += cflags
+    asmflags += cflags_c
+  }
+
+  if (is_chromeos_device && !is_nacl) {
+    # On ChromeOS devices, we want to ensure we're using Chrome's allocator
+    # symbols for all C++ new/delete operator overloads. PartitionAlloc
+    # and other local allocators should always take precedence over system or
+    # preloaded allocators. These are the mangled symbol names.
+    # See b/280115910 for details.
+    ldflags += [
+      "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
+      "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
+      "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
+      "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
+      "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
+      "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
+    ]
+  }
+
+  # Rust compiler flags setup.
+  # ---------------------------
+  rustflags += [
+    # Overflow checks are optional in Rust, but even if switched
+    # off they do not cause undefined behavior (the overflowing
+    # behavior is defined). Because containers are bounds-checked
+    # in safe Rust, they also can't provoke buffer overflows.
+    # As such these checks may be less important in Rust than C++.
+    # But in (simplistic) testing they have negligible performance
+    # overhead, and this helps to provide consistent behavior
+    # between different configurations, so we'll keep them on until
+    # we discover a reason to turn them off.
+    "-Coverflow-checks=on",
+
+    # By default Rust passes `-nodefaultlibs` to the linker, however this
+    # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
+    # is then unused and produces a warning/error. So this removes the
+    # `-nodefaultlibs` from the linker invocation from Rust, which would be used
+    # to compile dylibs on Android, such as for constructing unit test APKs.
+    "-Cdefault-linker-libraries",
+
+    # To make Rust .d files compatible with ninja
+    "-Zdep-info-omit-d-target",
+
+    # If a macro panics during compilation, show which macro and where it is
+    # defined.
+    "-Zmacro-backtrace",
+
+    # For deterministic builds, keep the local machine's current working
+    # directory from appearing in build outputs.
+    "-Zremap-cwd-prefix=.",
+  ]
+
+  if (!is_win || force_rustc_color_output) {
+    # Colorize error output. The analogous flag is passed for clang. This must
+    # be platform-gated since rustc will unconditionally output ANSI escape
+    # sequences, ignoring the platform, when stderr is not a terminal.
+    rustflags += [ "--color=always" ]
+  }
+  if (rust_abi_target != "") {
+    rustflags += [ "--target=$rust_abi_target" ]
+  }
+  if (!use_thin_lto) {
+    # Don't include bitcode if it won't be used.
+    rustflags += [ "-Cembed-bitcode=no" ]
+  }
+  if (is_official_build) {
+    rustflags += [ "-Ccodegen-units=1" ]
+  }
+  if (!rust_prebuilt_stdlib) {
+    # When building against the Chromium Rust stdlib (which we compile) always
+    # abort instead of unwinding when panic occurs. In official builds, panics
+    # abort immediately (this is configured in the stdlib) to keep binary size
+    # down. So we unconditionally match behaviour in unofficial too.
+    rustflags += [
+      "-Cpanic=abort",
+      "-Zpanic_abort_tests",
+    ]
+  }
+
+  # Normally, this would be defined in the `runtime_library` config but NaCl
+  # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there
+  # isn't really a better config to add this define for the define to
+  # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
+  # and NaCl code.
+  #
+  # TODO(https://crbug.com/702997): Move this back to the `runtime_library`
+  # config when NaCl is removed.
+  if (use_safe_libcxx) {
+    # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once
+    # it's rolled in.
+    if (is_nacl_saigo) {
+      defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
+    } else {
+      defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ]
+    }
+  }
+}
+
+# The BUILDCONFIG file sets this config on targets by default, which means when
+# building with ThinLTO, no optimization is performed in the link step.
+config("thinlto_optimize_default") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    lto_opt_level = 0
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# Use this to enable optimization in the ThinLTO link step for select targets
+# when thin_lto_enable_optimizations is set by doing:
+#
+#   configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
+#   configs += [ "//build/config/compiler:thinlto_optimize_max" ]
+#
+# Since it makes linking significantly slower and more resource intensive, only
+# use it on important targets such as the main browser executable or dll.
+config("thinlto_optimize_max") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    if (thin_lto_enable_optimizations) {
+      lto_opt_level = 2
+    } else {
+      lto_opt_level = 0
+    }
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+  defines = []
+
+  configs = []
+  if (is_chromeos) {
+    configs += [ "//build/config/chromeos:compiler_cpu_abi" ]
+  }
+
+  # TODO(https://crbug.com/1383873): Remove this once figured out.
+  if (is_apple && current_cpu == "arm64") {
+    cflags += [ "-fno-global-isel" ]
+    ldflags += [ "-fno-global-isel" ]
+  }
+
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "-m64",
+        "-msse3",
+      ]
+      ldflags += [ "-m64" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+      if (!is_nacl) {
+        cflags += [
+          "-mfpmath=sse",
+          "-msse3",
+        ]
+      }
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=@ARM_TARGET@" ]
+        ldflags += [ "--target=@ARM_TARGET@" ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "arm64") {
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=aarch64-linux-gnu" ]
+        ldflags += [ "--target=aarch64-linux-gnu" ]
+      }
+    } else if (current_cpu == "mipsel" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mipsel-linux-android" ]
+            ldflags += [ "--target=mipsel-linux-android" ]
+          } else {
+            cflags += [ "--target=mipsel-linux-gnu" ]
+            ldflags += [ "--target=mipsel-linux-gnu" ]
+          }
+        } else {
+          cflags += [ "-EL" ]
+          ldflags += [ "-EL" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [ "-mno-odd-spreg" ]
+        ldflags += [ "-mips32r6" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r6",
+          ]
+        } else {
+          cflags += [
+            "-mips32r6",
+            "-Wa,-mips32r6",
+          ]
+          if (is_android) {
+            ldflags += [ "-Wl,-melf32ltsmip" ]
+          }
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips32r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r2",
+          ]
+        } else {
+          cflags += [
+            "-mips32r2",
+            "-Wa,-mips32r2",
+          ]
+          if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+            cflags += [ "-m$mips_fpu_mode" ]
+          }
+        }
+      } else if (mips_arch_variant == "r1") {
+        ldflags += [ "-mips32" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32",
+          ]
+        } else {
+          cflags += [
+            "-mips32",
+            "-Wa,-mips32",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips-linux-gnu" ]
+          ldflags += [ "--target=mips-linux-gnu" ]
+        } else {
+          cflags += [ "-EB" ]
+          ldflags += [ "-EB" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mips64el-linux-android" ]
+            ldflags += [ "--target=mips64el-linux-android" ]
+          } else {
+            cflags += [ "--target=mips64el-linux-gnuabi64" ]
+            ldflags += [ "--target=mips64el-linux-gnuabi64" ]
+          }
+        } else {
+          cflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r6",
+          ]
+        } else {
+          cflags += [
+            "-mips64r6",
+            "-Wa,-mips64r6",
+          ]
+          ldflags += [ "-mips64r6" ]
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips64r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r2",
+          ]
+        } else {
+          cflags += [
+            "-mips64r2",
+            "-Wa,-mips64r2",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+    } else if (current_cpu == "mips64") {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips64-linux-gnuabi64" ]
+          ldflags += [ "--target=mips64-linux-gnuabi64" ]
+        } else {
+          cflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    } else if (current_cpu == "ppc64") {
+      if (current_os == "aix") {
+        cflags += [ "-maix64" ]
+        ldflags += [ "-maix64" ]
+      } else {
+        cflags += [ "-m64" ]
+        ldflags += [ "-m64" ]
+      }
+    } else if (current_cpu == "riscv64") {
+      if (is_clang && !is_android) {
+        cflags += [ "--target=riscv64-linux-gnu" ]
+        ldflags += [ "--target=riscv64-linux-gnu" ]
+      }
+      cflags += [ "-mabi=lp64d" ]
+    } else if (current_cpu == "loong64") {
+      if (is_clang) {
+        cflags += [ "--target=loongarch64-linux-gnu" ]
+        ldflags += [ "--target=loongarch64-linux-gnu" ]
+      }
+      cflags += [
+        "-mabi=lp64d",
+        "-mcmodel=medium",
+      ]
+    } else if (current_cpu == "s390x") {
+      cflags += [ "-m64" ]
+      ldflags += [ "-m64" ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+  configs = []
+  cflags = []
+  ldflags = []
+
+  if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler_codegen" ]
+  }
+
+  if (current_cpu == "arm64" && !is_win && is_clang) {
+    # Disable outlining everywhere on arm64 except Win. For more information see
+    # crbug.com/931297 for Android and crbug.com/1410297 for iOS.
+    # TODO(crbug.com/1411363): Enable this on Windows if possible.
+    cflags += [ "-mno-outline" ]
+
+    # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
+    # has been resolved, and -mno-outline is obeyed by the linker during
+    # ThinLTO.
+    ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
+  }
+
+  asmflags = cflags
+}
+
+# This provides options that make the build deterministic, so that the same
+# revision produces the same output, independent of the name of the build
+# directory and of the computer the build is done on.
+# The relative path from build dir to source dir makes it into the build
+# outputs, so it's recommended that you use a build dir two levels deep
+# (e.g. "out/Release") so that you get the same "../.." path as all the bots
+# in your build outputs.
+config("compiler_deterministic") {
+  cflags = []
+  ldflags = []
+  swiftflags = []
+
+  # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+  # deterministic build.  See https://crbug.com/314403
+  if (!is_official_build) {
+    if (is_win && !is_clang) {
+      cflags += [
+        "/wd4117",  # Trying to define or undefine a predefined macro.
+        "/D__DATE__=",
+        "/D__TIME__=",
+        "/D__TIMESTAMP__=",
+      ]
+    } else {
+      cflags += [
+        "-Wno-builtin-macro-redefined",
+        "-D__DATE__=",
+        "-D__TIME__=",
+        "-D__TIMESTAMP__=",
+      ]
+    }
+  }
+
+  # Makes builds independent of absolute file path.
+  if (is_clang && strip_absolute_paths_from_debug_symbols) {
+    # If debug option is given, clang includes $cwd in debug info by default.
+    # For such build, this flag generates reproducible obj files even we use
+    # 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=." ]
+      swiftflags += [ "-file-compilation-dir=." ]
+    }
+    if (!is_win) {
+      # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+      asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+    }
+
+    if (is_win && use_lld) {
+      if (symbol_level == 2 || (is_clang && using_sanitizer)) {
+        # Absolutize source file paths for PDB. Pass the real build directory
+        # if the pdb contains source-level debug information and if linker
+        # reproducibility is not critical.
+        ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ]
+      } else {
+        # Use a fake fixed base directory for paths in the pdb to make the pdb
+        # output fully deterministic and independent of the build directory.
+        ldflags += [ "/PDBSourcePath:o:\fake\prefix" ]
+      }
+    }
+  }
+
+  # Tells the compiler not to use absolute paths when passing the default
+  # paths to the tools it invokes. We don't want this because we don't
+  # really need it and it can mess up the goma cache entries.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags += [ "-no-canonical-prefixes" ]
+
+    # Same for links: Let the compiler driver invoke the linker
+    # with a relative path and pass relative paths to built-in
+    # libraries. Not needed on Windows because we call the linker
+    # directly there, not through the compiler driver.
+    # We don't link on goma, so this change is just for cleaner
+    # internal linker invocations, for people who work on the build.
+    if (!is_win) {
+      ldflags += [ "-no-canonical-prefixes" ]
+    }
+  }
+}
+
+config("clang_revision") {
+  if (is_clang && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
+config("rustc_revision") {
+  if (rustc_revision != "") {
+    # Similar to the above config, this is here so that all files get recompiled
+    # after a rustc roll. Nothing should ever read this cfg. This will not be
+    # set if a custom toolchain is used.
+    rustflags = [
+      "--cfg",
+      "cr_rustc_revision=\"$rustc_revision\"",
+    ]
+  }
+}
+
+config("compiler_arm_fpu") {
+  if (current_cpu == "arm" && !is_ios && !is_nacl) {
+    cflags = [ "-mfpu=$arm_fpu" ]
+    if (!arm_use_thumb) {
+      cflags += [ "-marm" ]
+    }
+    asmflags = cflags
+  }
+}
+
+config("compiler_arm_thumb") {
+  if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+      !(is_apple || is_nacl)) {
+    cflags = [ "-mthumb" ]
+  }
+}
+
+config("compiler_arm") {
+  if (current_cpu == "arm" && is_chromeos) {
+    # arm is normally the default mode for clang, but on chromeos a wrapper
+    # is used to pass -mthumb, and therefor change the default.
+    cflags = [ "-marm" ]
+  }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+  configs = []
+
+  # The order of this config is important: it must appear before
+  # android:runtime_library.  This is to ensure libc++ appears before
+  # libandroid_support in the -isystem include order.  Otherwise, there will be
+  # build errors related to symbols declared in math.h.
+  if (use_custom_libcxx) {
+    configs += [ "//build/config/c++:runtime_library" ]
+  }
+
+  # Rust and C++ both provide intrinsics for LLVM to call for math operations. We
+  # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins
+  # library. The Rust symbols are marked as weak, so that they can be replaced by
+  # the C++ symbols. This config ensures the C++ symbols exist and are strong in
+  # order to cause that replacement to occur by explicitly linking in clang's
+  # compiler-rt library.
+  if (is_clang && toolchain_has_rust) {
+    configs += [ "//build/config/clang:compiler_builtins" ]
+  }
+
+  # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia
+  # configuration.
+  if (is_posix || is_fuchsia) {
+    configs += [ "//build/config/posix:runtime_library" ]
+
+    if (use_custom_libunwind) {
+      # Instead of using an unwind lib from the toolchain,
+      # buildtools/third_party/libunwind will be built and used directly.
+      ldflags = [ "--unwindlib=none" ]
+    }
+  }
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:runtime_library" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:runtime_library" ]
+    if (is_chromeos) {
+      configs += [ "//build/config/chromeos:runtime_library" ]
+    }
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:runtime_library" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:runtime_library" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:runtime_library" ]
+  }
+
+  if (is_component_build) {
+    defines = [ "COMPONENT_BUILD" ]
+  }
+}
+
+# treat_warnings_as_errors ----------------------------------------------------
+#
+# Adding this config causes the compiler to treat warnings as fatal errors.
+# This is used as a subconfig of both chromium_code and no_chromium_code, and
+# is broken out separately so nocompile tests can force-enable this setting
+# independently of the default warning flags.
+config("treat_warnings_as_errors") {
+  if (is_win) {
+    cflags = [ "/WX" ]
+  } else {
+    cflags = [ "-Werror" ]
+
+    # The compiler driver can sometimes (rarely) emit warnings before calling
+    # the actual linker.  Make sure these warnings are treated as errors as
+    # well.
+    ldflags = [ "-Werror" ]
+  }
+
+  # Turn rustc warnings into the "deny" lint level, which produce compiler
+  # errors. The equivalent of -Werror for clang/gcc.
+  #
+  # Note we apply the actual lint flags in config("compiler"). All warnings
+  # are suppressed in third-party crates.
+  rustflags = [ "-Dwarnings" ]
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default.  This is used as a
+# subconfig of both chromium_code and no_chromium_code.  This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  ldflags = []
+  configs = []
+
+  if (is_win) {
+    if (fatal_linker_warnings) {
+      arflags = [ "/WX" ]
+      ldflags = [ "/WX" ]
+    }
+    defines = [
+      # Without this, Windows headers warn that functions like wcsnicmp
+      # should be spelled _wcsnicmp. But all other platforms keep spelling
+      # it wcsnicmp, making this warning unhelpful. We don't want it.
+      "_CRT_NONSTDC_NO_WARNINGS",
+
+      # TODO(thakis): winsock wants us to use getaddrinfo instead of
+      # gethostbyname. Fires mostly in non-Chromium code. We probably
+      # want to remove this define eventually.
+      "_WINSOCK_DEPRECATED_NO_WARNINGS",
+    ]
+    if (!is_clang) {
+      # TODO(thakis): Remove this once
+      # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
+      # rolled into angle.
+      cflags += [ "/wd4244" ]
+    }
+  } else {
+    if (is_apple && !is_nacl) {
+      # When compiling Objective-C, warns if a method is used whose
+      # availability is newer than the deployment target.
+      cflags += [ "-Wunguarded-availability" ]
+    }
+
+    if (is_ios) {
+      # When compiling Objective-C, warns if a selector named via @selector has
+      # not been defined in any visible interface.
+      cflags += [ "-Wundeclared-selector" ]
+    }
+
+    # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+    # warning).
+    if (current_cpu == "arm" && !is_clang) {
+      cflags += [ "-Wno-psabi" ]
+    }
+
+    if (!is_clang) {
+      cflags_cc += [
+        # See comment for -Wno-c++11-narrowing.
+        "-Wno-narrowing",
+      ]
+
+      # -Wno-class-memaccess warns about hash table and vector in blink.
+      # But the violation is intentional.
+      if (!is_nacl) {
+        cflags_cc += [ "-Wno-class-memaccess" ]
+      }
+
+      # -Wunused-local-typedefs is broken in gcc,
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
+      cflags += [ "-Wno-unused-local-typedefs" ]
+
+      # Don't warn about "maybe" uninitialized. Clang doesn't include this
+      # in -Wall but gcc does, and it gives false positives.
+      cflags += [ "-Wno-maybe-uninitialized" ]
+      cflags += [ "-Wno-deprecated-declarations" ]
+
+      # -Wcomment gives too many false positives in the case a
+      # backslash ended comment line is followed by a new line of
+      # comments
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
+      cflags += [ "-Wno-comments" ]
+
+      # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
+      # files.
+      cflags += [ "-Wno-packed-not-aligned" ]
+    }
+  }
+
+  # Common Clang and GCC warning setup.
+  if (!is_win || is_clang) {
+    cflags += [
+      # Disables.
+      "-Wno-missing-field-initializers",  # "struct foo f = {0};"
+      "-Wno-unused-parameter",  # Unused function parameters.
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # An ABI compat warning we don't care about, https://crbug.com/1102157
+        # TODO(thakis): Push this to the (few) targets that need it,
+        # instead of having a global flag.
+        "-Wno-psabi",
+      ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      "-Wloop-analysis",
+
+      # TODO(thakis): This used to be implied by -Wno-unused-function,
+      # which we no longer use. Check if it makes sense to remove
+      # this as well. http://crbug.com/316352
+      "-Wno-unneeded-internal-declaration",
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      if (is_win) {
+        # TODO(thakis): https://crbug.com/617318
+        # Currently goma can not handle case sensitiveness for windows well.
+        cflags += [ "-Wno-nonportable-include-path" ]
+      }
+
+      if (is_fuchsia) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1474434): fix and reenable
+          "-Wno-missing-field-initializers",
+        ]
+      }
+
+      cflags += [
+        "-Wenum-compare-conditional",
+
+        # Ignore warnings about MSVC optimization pragmas.
+        # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
+        "-Wno-ignored-pragma-optimize",
+      ]
+
+      if (!is_nacl) {
+        cflags += [
+          # TODO(crbug.com/1343975) Evaluate and possibly enable.
+          "-Wno-deprecated-builtins",
+
+          # TODO(crbug.com/1352183) Evaluate and possibly enable.
+          "-Wno-bitfield-constant-conversion",
+
+          # TODO(crbug.com/1412713) Evaluate and possibly enable.
+          "-Wno-deprecated-this-capture",
+        ]
+      }
+    }
+
+    # Some builders, such as Cronet, use a different version of Clang than
+    # Chromium. This can cause minor errors when compiling Chromium changes. We
+    # want to avoid these errors.
+    if (llvm_android_mainline) {
+      cflags += [
+        "-Wno-error=unknown-warning-option",
+        "-Wno-error=unused-command-line-argument",
+      ]
+    }
+  }
+
+  # Rust warnings
+
+  # Require `unsafe` blocks even in `unsafe` fns. This is intended to become
+  # an error by default eventually; see
+  # https://github.com/rust-lang/rust/issues/71668
+  rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
+}
+
+# prevent_unsafe_narrowing ----------------------------------------------------
+#
+# Warnings that prevent narrowing or comparisons of integer types that are
+# likely to cause out-of-bound read/writes or Undefined Behaviour. In
+# particular, size_t is used for memory sizes, allocation, indexing, and
+# offsets. Using other integer types along with size_t produces risk of
+# memory-safety bugs and thus security exploits.
+#
+# In order to prevent these bugs, allocation sizes were historically limited to
+# sizes that can be represented within 31 bits of information, allowing `int` to
+# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
+# support increasing the allocation limit we require strictly adherence to
+# using the correct types, avoiding lossy conversions, and preventing overflow.
+# To do so, enable this config and fix errors by converting types to be
+# `size_t`, which is both large enough and unsigned, when dealing with memory
+# sizes, allocations, indices, or offsets.In cases where type conversion is not
+# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
+# to convert to size_t as needed.
+# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
+#
+# To enable in a GN target, use:
+#   configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
+
+config("prevent_unsafe_narrowing") {
+  if (is_clang) {
+    cflags = [
+      "-Wshorten-64-to-32",
+      "-Wimplicit-int-conversion",
+      "-Wsign-compare",
+      "-Wsign-conversion",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
+        # fixing types to be sign-correct.
+        "-Wtautological-unsigned-zero-compare",
+      ]
+    }
+  }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+  if (is_win) {
+    if (is_clang) {
+      cflags = [ "/W4" ]  # Warning level 4.
+
+      # Opt in to additional [[nodiscard]] on standard library methods.
+      defines = [ "_HAS_NODISCARD" ]
+    }
+  } else {
+    cflags = [ "-Wall" ]
+    if (is_clang) {
+      # Enable extra warnings for chromium_code when we control the compiler.
+      cflags += [ "-Wextra" ]
+    }
+
+    # In Chromium code, we define __STDC_foo_MACROS in order to get the
+    # C99 macros on Mac and Linux.
+    defines = [
+      "__STDC_CONSTANT_MACROS",
+      "__STDC_FORMAT_MACROS",
+    ]
+
+    if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+        current_cpu != "s390" && current_cpu != "ppc64" &&
+        current_cpu != "mips" && current_cpu != "mips64" &&
+        current_cpu != "riscv64" && current_cpu != "loong64") {
+      # Non-chromium code is not guaranteed to compile cleanly with
+      # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+      # disabled, so only do that for Release build.
+      fortify_level = "2"
+
+      # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation
+      # with a few custom glibc patches. Use that if it's available.
+      if (is_chromeos_ash) {
+        fortify_level = "3"
+      }
+      defines += [ "_FORTIFY_SOURCE=" + fortify_level ]
+    }
+
+    if (is_apple) {
+      cflags_objc = [ "-Wimplicit-retain-self" ]
+      cflags_objcc = [ "-Wimplicit-retain-self" ]
+    }
+
+    if (is_mac) {
+      cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
+      cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Warn on missing break statements at the end of switch cases.
+      # For intentional fallthrough, use [[fallthrough]].
+      "-Wimplicit-fallthrough",
+
+      # Warn on unnecessary extra semicolons outside of function definitions.
+      "-Wextra-semi",
+
+      # Warn on unreachable code, including unreachable breaks and returns.
+      # See https://crbug.com/346399#c148 for suppression strategies.
+      "-Wunreachable-code-aggressive",
+    ]
+
+    # Thread safety analysis is broken under nacl: https://crbug.com/982423.
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # Thread safety analysis. See base/thread_annotations.h and
+        # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
+        "-Wthread-safety",
+      ]
+    }
+  }
+
+  configs = [
+    ":default_warnings",
+    ":noshadowing",
+  ]
+  if (treat_warnings_as_errors) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
+  if (is_win) {
+    if (is_clang) {
+      cflags += [ "/W3" ]  # Warning level 3.
+    }
+    cflags += [
+      "/wd4800",  # Disable warning when forcing value to bool.
+      "/wd4267",  # TODO(jschuh): size_t to int.
+    ]
+  } else {
+    if (is_clang && !is_nacl) {
+      # TODO(thakis): Remove !is_nacl once
+      # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+      cflags += [ "-Wall" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Lots of third-party libraries have unused variables. Instead of
+      # suppressing them individually, we just blanket suppress them here.
+      "-Wno-unused-variable",
+
+      # Similarly, we're not going to fix all the C++11 narrowing issues in
+      # third-party libraries.
+      "-Wno-c++11-narrowing",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Disabled for similar reasons as -Wunused-variable.
+        "-Wno-unused-but-set-variable",
+
+        # TODO(https://crbug.com/1202159): Clean up and enable.
+        "-Wno-misleading-indentation",
+      ]
+    }
+  }
+
+  # Suppress all warnings in third party, as Cargo does:
+  # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
+  rustflags = [ "--cap-lints=allow" ]
+
+  configs = [ ":default_warnings" ]
+
+  # GCC may emit unsuppressible warnings so only apply this config when
+  # building with clang. crbug.com/589724
+  if (treat_warnings_as_errors && is_clang) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+# noshadowing -----------------------------------------------------------------
+#
+# Allows turning -Wshadow on.
+
+config("noshadowing") {
+  # This flag has to be disabled for nacl because the nacl compiler is too
+  # strict about shadowing.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags = [ "-Wshadow" ]
+  }
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+  if (is_win) {
+    cflags_cc = [ "/GR" ]
+  } else {
+    cflags_cc = [ "-frtti" ]
+  }
+}
+
+config("no_rtti") {
+  # Some sanitizer configs may require RTTI to be left enabled globally
+  if (!use_rtti) {
+    if (is_win) {
+      cflags_cc = [ "/GR-" ]
+    } else {
+      cflags_cc = [ "-fno-rtti" ]
+      cflags_objcc = cflags_cc
+    }
+  }
+}
+
+# export_dynamic ---------------------------------------------------------------
+#
+# Ensures all exported symbols are added to the dynamic symbol table.  This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries.  Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+  # TODO(crbug.com/1052397): Revisit after target_os flip is completed.
+  if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) {
+    ldflags = [ "-rdynamic" ]
+  }
+}
+
+# thin_archive -----------------------------------------------------------------
+#
+# Enables thin archives on posix, and on windows when the lld linker is used.
+# Regular archives directly include the object files used to generate it.
+# Thin archives merely reference the object files.
+# This makes building them faster since it requires less disk IO, but is
+# inappropriate if you wish to redistribute your static library.
+# This config is added to the global config, so thin archives should already be
+# enabled.  If you want to make a distributable static library, you need to do 2
+# things:
+# 1. Set complete_static_lib so that all dependencies of the library make it
+#    into the library. See `gn help complete_static_lib` for details.
+# 2. Remove the thin_archive config, so that the .a file actually contains all
+#    .o files, instead of just references to .o files in the build directoy
+config("thin_archive") {
+  # The macOS and iOS default linker ld64 does not support reading thin
+  # archives.
+  # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
+  # confuses lldb.
+  if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
+    arflags = [ "-T" ]
+  } else if (is_win && use_lld) {
+    arflags = [ "/llvmlibthin" ]
+  }
+}
+
+# exceptions -------------------------------------------------------------------
+#
+# Allows turning Exceptions on or off.
+# Note: exceptions are disallowed in Google code.
+
+config("exceptions") {
+  if (is_win) {
+    # Enables exceptions in the STL.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=1" ]
+    }
+    cflags_cc = [ "/EHsc" ]
+  } else {
+    cflags_cc = [ "-fexceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+config("no_exceptions") {
+  if (is_win) {
+    # Disables exceptions in the STL.
+    # libc++ uses the __has_feature macro to control whether to use exceptions,
+    # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+    # breaks libc++ because it depends on MSVC headers that only provide certain
+    # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use
+    # exceptions, despite being conditional on _HAS_EXCEPTIONS.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=0" ]
+    }
+  } else {
+    cflags_cc = [ "-fno-exceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# Generate a warning for code that might emit a static initializer.
+# See: //docs/static_initializers.md
+# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
+config("wglobal_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wglobal-constructors" ]
+  }
+}
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wexit-time-destructors" ]
+  }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# suppressing the rest of them.  Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+  cflags = []
+  if (is_clang) {
+    cflags += [ "-Wno-incompatible-pointer-types" ]
+  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+    cflags += [ "-w" ]
+  } else if (is_chromeos_ash && current_cpu == "arm") {
+    cflags += [ "-w" ]
+  }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_optimization" ]
+#   configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+  common_optimize_on_cflags = [
+    "/Ob2",  # Both explicit and auto inlining.
+    "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+    "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+  ]
+  if (!is_asan) {
+    common_optimize_on_cflags += [
+      # Put data in separate COMDATs. This allows the linker
+      # to put bit-identical constants at the same address even if
+      # they're unrelated constants, which saves binary size.
+      # This optimization can't be used when ASan is enabled because
+      # it is not compatible with the ASan ODR checker.
+      "/Gw",
+    ]
+  }
+  common_optimize_on_ldflags = []
+
+  # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+  # misleading symbols in stack traces.
+  if (!is_debug && !is_component_build) {
+    common_optimize_on_ldflags += [ "/OPT:ICF" ]  # Redundant COMDAT folding.
+  }
+
+  if (is_official_build) {
+    common_optimize_on_ldflags += [ "/OPT:REF" ]  # Remove unreferenced data.
+    # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
+  }
+} else {
+  common_optimize_on_cflags = []
+  common_optimize_on_ldflags = []
+
+  if (is_android) {
+    # TODO(jdduke) Re-enable on mips after resolving linking
+    # issues with libc++ (crbug.com/456380).
+    if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+      common_optimize_on_ldflags += [
+        # Warn in case of text relocations.
+        "-Wl,--warn-shared-textrel",
+      ]
+    }
+  }
+
+  if (is_apple) {
+    common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+
+    if (is_official_build) {
+      common_optimize_on_ldflags += [
+        "-Wl,-no_data_in_code_info",
+        "-Wl,-no_function_starts",
+      ]
+    }
+  } else if (current_os != "aix" && current_os != "zos") {
+    # Non-Mac Posix flags.
+    # Aix does not support these.
+
+    common_optimize_on_cflags += [
+      # Put data and code in their own sections, so that unused symbols
+      # can be removed at link time with --gc-sections.
+      "-fdata-sections",
+      "-ffunction-sections",
+    ]
+    if ((!is_nacl || is_nacl_saigo) && is_clang) {
+      # We don't care about unique section names, this makes object files a bit
+      # smaller.
+      common_optimize_on_cflags += [ "-fno-unique-section-names" ]
+    }
+
+    common_optimize_on_ldflags += [
+      # Specifically tell the linker to perform optimizations.
+      # See http://lwn.net/Articles/192624/ .
+      # -O2 enables string tail merge optimization in gold and lld.
+      "-Wl,-O2",
+      "-Wl,--gc-sections",
+    ]
+  }
+}
+
+config("default_stack_frames") {
+  if (!is_win) {
+    if (enable_frame_pointers) {
+      cflags = [ "-fno-omit-frame-pointer" ]
+
+      # Omit frame pointers for leaf functions on x86, otherwise building libyuv
+      # gives clang's register allocator issues, see llvm.org/PR15798 /
+      # crbug.com/233709
+      if (is_clang && current_cpu == "x86" && !is_apple) {
+        cflags += [ "-momit-leaf-frame-pointer" ]
+      }
+    } else {
+      cflags = [ "-fomit-frame-pointer" ]
+    }
+  }
+  # On Windows, the flag to enable framepointers "/Oy-" must always come after
+  # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+  # the "optimize" configs, see rest of this file. The ordering that cflags are
+  # applied is well-defined by the GN spec, and there is no way to ensure that
+  # cflags set by "default_stack_frames" is applied after those set by an
+  # "optimize" config. Similarly, there is no way to propagate state from this
+  # config into the "optimize" config. We always apply the "/Oy-" config in the
+  # definition for common_optimize_on_cflags definition, even though this may
+  # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+  if (is_win) {
+    if (chrome_pgo_phase != 2) {
+      # Favor size over speed, /O1 must be before the common flags.
+      # /O1 implies /Os and /GF.
+      cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+      rustflags = [ "-Copt-level=s" ]
+    } else {
+      # PGO requires all translation units to be compiled with /O2. The actual
+      # optimization level will be decided based on the profiling data.
+      cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
+
+      # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
+      # suggests not using an explicit `-Copt-level` at all, and the default is
+      # to optimize for performance like `/O2` for clang.
+      rustflags = []
+    }
+  } else if (optimize_for_size) {
+    # Favor size over speed.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+
+      if (use_ml_inliner && is_a_target_toolchain) {
+        cflags += [
+          "-mllvm",
+          "-enable-ml-inliner=release",
+        ]
+      }
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
+    # vectorization.
+    rustflags = [ "-Copt-level=z" ]
+  } else if (is_chromeos) {
+    # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+    # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+    # any cost" (AKA -Oz). It'd be nice to:
+    # - Make `optimize_for_size` apply to all platforms where we're optimizing
+    #   for size by default (so, also Windows)
+    # - Investigate -Oz here, maybe just for ARM?
+    cflags = [ "-Os" ] + common_optimize_on_cflags
+
+    # Similar to clang, we optimize with `-Copt-level=s` to keep loop
+    # vectorization while otherwise optimizing for size.
+    rustflags = [ "-Copt-level=s" ]
+  } else {
+    cflags = [ "-O2" ] + common_optimize_on_cflags
+
+    # The `-O3` for clang turns on extra optimizations compared to the standard
+    # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
+    # to use.
+    rustflags = [ "-Copt-level=3" ]
+  }
+  ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+  if (is_win) {
+    cflags = [
+      "/Od",  # Disable optimization.
+      "/Ob0",  # Disable all inlining (on by default).
+      "/GF",  # Enable string pooling (off by default).
+    ]
+
+    if (target_cpu == "arm64") {
+      # Disable omitting frame pointers for no_optimize build because stack
+      # traces on Windows ARM64 rely on it.
+      cflags += [ "/Oy-" ]
+    }
+  } else if (is_android && !android_full_debug) {
+    # On Android we kind of optimize some things that don't affect debugging
+    # much even when optimization is disabled to get the binary size down.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    if (!is_component_build) {
+      # Required for library partitions. Without this all symbols just end up
+      # in the base partition.
+      ldflags = [ "-Wl,--gc-sections" ]
+    }
+  } else if (is_fuchsia) {
+    # On Fuchsia, we optimize for size here to reduce the size of debug build
+    # packages so they can be run in a KVM. See crbug.com/910243 for details.
+    cflags = [ "-Og" ]
+  } else {
+    cflags = [ "-O0" ]
+    ldflags = []
+  }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O2" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O3" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+config("optimize_fuzzing") {
+  cflags = [ "-O1" ] + common_optimize_on_cflags
+  rustflags = [ "-Copt-level=1" ]
+  ldflags = common_optimize_on_ldflags
+  visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else if (optimize_for_fuzzing) {
+    assert(!is_win, "Fuzzing optimize level not supported on Windows")
+
+    # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even
+    # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
+    assert(!use_clang_coverage,
+           "optimize_for_fuzzing=true should not be used with " +
+               "use_clang_coverage=true.")
+    configs = [ ":optimize_fuzzing" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
+_clang_sample_profile = ""
+if (is_clang && is_a_target_toolchain) {
+  if (clang_sample_profile_path != "") {
+    _clang_sample_profile = clang_sample_profile_path
+  } else if (clang_use_default_sample_profile) {
+    assert(build_with_chromium,
+           "Our default profiles currently only apply to Chromium")
+    assert(is_android || is_chromeos || is_castos,
+           "The current platform has no default profile")
+    if (is_android || is_castos) {
+      _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+    } else {
+      assert(
+          chromeos_afdo_platform == "atom" ||
+              chromeos_afdo_platform == "bigcore" ||
+              chromeos_afdo_platform == "arm" ||
+              chromeos_afdo_platform == "arm-exp",
+          "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
+      _clang_sample_profile =
+          "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+    }
+  }
+}
+
+# Clang offers a way to assert that AFDO profiles are accurate, which causes it
+# to optimize functions not represented in a profile more aggressively for size.
+# This config can be toggled in cases where shaving off binary size hurts
+# performance too much.
+config("afdo_optimize_size") {
+  if (_clang_sample_profile != "" && sample_profile_is_accurate) {
+    cflags = [ "-fprofile-sample-accurate" ]
+  }
+}
+
+# GCC and clang support a form of profile-guided optimization called AFDO.
+# There are some targeted places that AFDO regresses, so we provide a separate
+# config to allow AFDO to be disabled per-target.
+config("afdo") {
+  if (is_clang) {
+    cflags = []
+    if (clang_emit_debug_info_for_profiling) {
+      # Add the following flags to generate debug info for profiling.
+      cflags += [ "-gline-tables-only" ]
+      if (!is_nacl) {
+        cflags += [ "-fdebug-info-for-profiling" ]
+      }
+    }
+    if (_clang_sample_profile != "") {
+      assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
+      rebased_clang_sample_profile =
+          rebase_path(_clang_sample_profile, root_build_dir)
+      cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+      if (use_profi) {
+        cflags += [ "-fsample-profile-use-profi" ]
+      }
+
+      # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
+      # These seem to be false positives - the complaints are about functions
+      # marked with `__nodebug__` not having associated debuginfo. In the case
+      # where this was observed, the `__nodebug__` function was also marked
+      # `__always_inline__` and had no branches, so AFDO info is likely useless
+      # there.
+      cflags += [ "-Wno-backend-plugin" ]
+      inputs = [ _clang_sample_profile ]
+    }
+  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+    cflags = [ "-fauto-profile=${auto_profile_path}" ]
+    inputs = [ auto_profile_path ]
+  }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_symbols" ]
+#   configs += [ "//build/config/compiler:symbols" ]
+
+# A helper config that all configs passing /DEBUG to the linker should
+# include as sub-config.
+config("win_pdbaltpath") {
+  visibility = [
+    ":minimal_symbols",
+    ":symbols",
+  ]
+
+  # /DEBUG causes the linker to generate a pdb file, and to write the absolute
+  # path to it in the executable file it generates.  This flag turns that
+  # absolute path into just the basename of the pdb file, which helps with
+  # build reproducibility. Debuggers look for pdb files next to executables,
+  # so there's minimal downside to always using this. However, post-mortem
+  # debugging of Chromium crash dumps and ETW tracing can be complicated by this
+  # switch so an option to omit it is important.
+  if (!use_full_pdb_paths) {
+    ldflags = [ "/pdbaltpath:%_PDB%" ]
+  }
+}
+
+# Full symbols.
+config("symbols") {
+  rustflags = []
+  if (is_win) {
+    if (is_clang) {
+      cflags = [
+        # Debug information in the .obj files.
+        "/Z7",
+
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    } else {
+      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.
+    }
+
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = []
+    if (is_mac && enable_dsyms) {
+      # If generating dSYMs, specify -fno-standalone-debug. This was
+      # originally specified for https://crbug.com/479841 because dsymutil
+      # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+      # version 7 also produces debug data that is incompatible with Breakpad
+      # dump_syms, so this is still required (https://crbug.com/622406).
+      cflags += [ "-fno-standalone-debug" ]
+    }
+
+    # On aix -gdwarf causes linker failures due to thread_local variables.
+    if (!is_nacl && current_os != "aix") {
+      if (use_dwarf5) {
+        cflags += [ "-gdwarf-5" ]
+        rustflags += [ "-Zdwarf-version=5" ]
+      } else {
+        # Recent clang versions default to DWARF5 on Linux, and Android is about
+        # to switch. TODO: Adopt that in controlled way. For now, keep DWARF4.
+        # Apple platforms still default to 4 in clang, so they don't need the
+        # cflags.
+        if (!is_apple) {
+          cflags += [ "-gdwarf-4" ]
+        }
+
+        # On Apple, rustc defaults to DWARF2 so it needs to be told how to
+        # match clang.
+        rustflags += [ "-Zdwarf-version=4" ]
+      }
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if ((!is_nacl || is_nacl_saigo) && current_os != "zos") {
+      cflags += [ "-g2" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
+      # to be manually enabled.
+      #
+      # It is skipped in tsan and asan because enabling it causes some
+      # formatting changes in the output which would require fixing bunches
+      # of expectation regexps.
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    if (is_apple) {
+      swiftflags = [ "-g" ]
+    }
+
+    if (use_debug_fission) {
+      cflags += [ "-gsplit-dwarf" ]
+    }
+    asmflags = cflags
+    ldflags = []
+
+    # Split debug info with all thinlto builds except nacl and apple.
+    # thinlto requires -gsplit-dwarf in ldflags.
+    if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) {
+      ldflags += [ "-gsplit-dwarf" ]
+    }
+
+    # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+    # currently we get "warning:
+    # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+    # DWARF info may be corrupt; offsets in a range list entry are in different
+    # sections" there.  Maybe just a bug in nacl_switch_32.S.
+    _enable_gdb_index =
+        symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" &&
+        current_os != "zos" && (use_gold || use_lld) &&
+        # Disable on non-fission 32-bit Android because it pushes
+        # libcomponents_unittests over the 4gb size limit.
+        !(is_android && !use_debug_fission && current_cpu != "x64" &&
+          current_cpu != "arm64")
+    if (_enable_gdb_index) {
+      if (is_clang) {
+        # This flag enables the GNU-format pubnames and pubtypes sections,
+        # which lld needs in order to generate a correct GDB index.
+        # TODO(pcc): Try to make lld understand non-GNU-format pubnames
+        # sections (llvm.org/PR34820).
+        cflags += [ "-ggnu-pubnames" ]
+      }
+      ldflags += [ "-Wl,--gdb-index" ]
+    }
+  }
+
+  configs = []
+
+  # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
+  # https://b/243982712.
+  if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
+      !is_nacl && current_cpu == "arm") {
+    configs += [ "//build/config:compress_debug_sections" ]
+  }
+
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+    if (is_apple) {
+      # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+      # Make sure we don't use constructor homing on mac.
+      cflags += [
+        "-Xclang",
+        "-debug-info-kind=limited",
+      ]
+    } else {
+      # Use constructor homing for debug info. This option reduces debug info
+      # by emitting class type info only when constructors are emitted.
+      cflags += [
+        "-Xclang",
+        "-fuse-ctor-homing",
+      ]
+    }
+  }
+  rustflags += [ "-g" ]
+}
+
+# Minimal symbols.
+# This config guarantees to hold symbol for stack trace which are shown to user
+# when crash happens in unittests running on buildbot.
+config("minimal_symbols") {
+  rustflags = []
+  if (is_win) {
+    # Functions, files, and line tables only.
+    cflags = []
+
+    if (is_clang) {
+      cflags += [
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    }
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+
+    # Enable line tables for clang. MSVC doesn't have an equivalent option.
+    if (is_clang) {
+      # -gline-tables-only is the same as -g1, but clang-cl only exposes the
+      # former.
+      cflags += [ "-gline-tables-only" ]
+    }
+  } else {
+    cflags = []
+    if (is_mac && !use_dwarf5) {
+      # clang defaults to DWARF2 on macOS unless mac_deployment_target is
+      # at least 10.11.
+      # TODO(thakis): Remove this once mac_deployment_target is 10.11.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    } else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
+      # On aix -gdwarf causes linker failures due to thread_local variables.
+      # Recent clang versions default to DWARF5 on Linux, and Android is about
+      # to switch. TODO: Adopt that in controlled way.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    }
+
+    if (use_dwarf5 && !is_nacl) {
+      cflags += [ "-gdwarf-5" ]
+      rustflags += [ "-Zdwarf-version=5" ]
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [ "-g1" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # See comment for -gdwarf-aranges in config("symbols").
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    ldflags = []
+    if (is_android && is_clang) {
+      # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
+      # doesn't emit DW_AT_linkage_name in -g1 builds.
+      # -fdebug-info-for-profiling enables that (and a bunch of other things we
+      # don't need), so that we get qualified names in stacks.
+      # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
+      #               failing that consider doing this on non-Android too.
+      cflags += [ "-fdebug-info-for-profiling" ]
+    }
+
+    asmflags = cflags
+  }
+  rustflags += [ "-Cdebuginfo=1" ]
+}
+
+# This configuration contains function names only. That is, the compiler is
+# told to not generate debug information and the linker then just puts function
+# names in the final debug information.
+config("no_symbols") {
+  if (is_win) {
+    ldflags = [ "/DEBUG" ]
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
+  }
+
+  # This config is removed by base unittests apk.
+  if (is_android && is_clang && strip_debug_info) {
+    configs += [ ":strip_debug" ]
+  }
+}
+
+config("strip_debug") {
+  if (!defined(ldflags)) {
+    ldflags = []
+  }
+  ldflags += [ "-Wl,--strip-debug" ]
+}
+
+if (is_apple) {
+  # On macOS and iOS, this enables support for ARC (automatic reference
+  # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+  #
+  # -fobjc-arc enables ARC overall.
+  #
+  # ARC does not add exception handlers to pure Objective-C code, but does add
+  # them to Objective-C++ code with the rationale that C++ pervasively adds them
+  # in for exception safety. However, exceptions are banned in Chromium code for
+  # C++ and exceptions in Objective-C code are intended to be fatal, so
+  # -fno-objc-arc-exceptions is specified to disable these unwanted exception
+  # handlers.
+  config("enable_arc") {
+    common_flags = [
+      "-fobjc-arc",
+      "-fno-objc-arc-exceptions",
+    ]
+    cflags_objc = common_flags
+    cflags_objcc = common_flags
+  }
+}
+
+if (is_android) {
+  # Use orderfile for linking Chrome on Android.
+  # This config enables using an orderfile for linking in LLD.
+  config("chrome_orderfile_config") {
+    # Don't try to use an orderfile with call graph sorting, except on Android,
+    # where we care about memory used by code, so we still want to mandate
+    # ordering.
+    if (chrome_orderfile_path != "") {
+      assert(use_lld)
+      _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
+      ldflags = [
+        "-Wl,--symbol-ordering-file",
+        "-Wl,$_rebased_orderfile",
+        "-Wl,--no-warn-symbol-ordering",
+      ]
+      inputs = [ chrome_orderfile_path ]
+    }
+  }
+}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+  cflags = []
+  if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+    if (init_stack_vars_zero) {
+      cflags += [ "-ftrivial-auto-var-init=zero" ]
+    } else {
+      cflags += [ "-ftrivial-auto-var-init=pattern" ]
+    }
+  }
+}
+
+buildflag_header("compiler_buildflags") {
+  header = "compiler_buildflags.h"
+
+  flags = [
+    "CLANG_PGO=$chrome_pgo_phase",
+    "SYMBOL_LEVEL=$symbol_level",
+  ]
+}
+
+config("cet_shadow_stack") {
+  if (enable_cet_shadow_stack && is_win) {
+    assert(target_cpu == "x64")
+    ldflags = [ "/CETCOMPAT" ]
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/src-orig/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/src-orig/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-arm-patch/src-orig/build/config/compiler/BUILD.gn	(revision 192)
@@ -0,0 +1,2932 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/buildflag_header.gni")
+import("//build/config/android/config.gni")
+import("//build/config/c++/c++.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/coverage/coverage.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/host_byteorder.gni")
+import("//build/config/rust.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/rbe.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+  import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el" ||
+    current_cpu == "mips" || current_cpu == "mips64") {
+  import("//build/config/mips.gni")
+}
+if (is_mac) {
+  import("//build/config/apple/symbols.gni")
+}
+if (is_ios) {
+  import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+  # To keep NaCl variables out of builds that don't include NaCl, all
+  # variables defined in nacl/config.gni referenced here should be protected by
+  # is_nacl conditions.
+  import("//build/config/nacl/config.gni")
+}
+
+lld_path = ""
+if (!is_clang) {
+  declare_args() {
+    # This allows overriding the location of lld.
+    lld_path = rebase_path("$clang_base_path/bin", root_build_dir)
+  }
+} else {
+  # clang looks for lld next to it, no need for -B.
+  lld_path = ""
+}
+
+declare_args() {
+  # Normally, Android builds are lightly optimized, even for debug builds, to
+  # keep binary size down. Setting this flag to true disables such optimization
+  android_full_debug = false
+
+  # Compile in such a way as to make it possible for the profiler to unwind full
+  # stack frames. Setting this flag has a large effect on the performance of the
+  # generated code than just setting profiling, but gives the profiler more
+  # information to analyze.
+  # Requires profiling to be set to true.
+  enable_full_stack_frames_for_profiling = false
+
+  # When we are going to use gold we need to find it.
+  # This is initialized below, after use_gold might have been overridden.
+  gold_path = ""
+
+  # Enable fatal linker warnings. Building Chromium with certain versions
+  # of binutils can cause linker warning.
+  fatal_linker_warnings = true
+
+  # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+  # but some sanitizers are known to require it, like CFI diagnostics
+  # and UBsan variants.
+  use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+  # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+  # optimization that GCC supports. It used by ChromeOS in their official
+  # builds. To use it, set auto_profile_path to the path to a file containing
+  # the needed gcov profiling data.
+  auto_profile_path = ""
+
+  # Path to an AFDO profile to use while building with clang, if any. Empty
+  # implies none.
+  clang_sample_profile_path = ""
+
+  # Some configurations have default sample profiles. If this is true and
+  # clang_sample_profile_path is empty, we'll fall back to the default.
+  #
+  # We currently only have default profiles for Chromium in-tree, so we disable
+  # this by default for all downstream projects, since these profiles are likely
+  # nonsensical for said projects.
+  clang_use_default_sample_profile =
+      chrome_pgo_phase == 0 && build_with_chromium && is_official_build &&
+      (is_android || chromeos_is_browser_only)
+
+  # This configuration is used to select a default profile in Chrome OS based on
+  # the microarchitectures we are using. This is only used if
+  # clang_use_default_sample_profile is true and clang_sample_profile_path is
+  # empty.
+  chromeos_afdo_platform = "atom"
+
+  # Emit debug information for profiling wile building with clang.
+  # Only enable this for ChromeOS official builds for AFDO.
+  clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
+
+  # Turn this on to have the compiler output extra timing information.
+  compiler_timing = false
+
+  # Turn this on to use ghash feature of lld for faster debug link on Windows.
+  # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
+  use_ghash = true
+
+  # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on
+  # can substantially increase link time and binary size, but they generally
+  # also make binaries a fair bit faster.
+  #
+  # TODO(gbiv): We disable optimizations by default on most platforms because
+  # the space overhead is too great. We should use some mixture of profiles and
+  # optimization settings to better tune the size increase.
+  thin_lto_enable_optimizations =
+      (is_chromeos || is_android || is_win || is_linux || is_mac ||
+       (is_ios && use_lld)) && is_official_build
+
+  # Initialize all local variables with a pattern. This flag will fill
+  # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
+  # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
+  # recognizable in the debugger, and crashes on memory accesses through
+  # uninitialized pointers.
+  #
+  # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and
+  # needs to be evaluated before enabling it there as well.
+  init_stack_vars = !(is_android && is_official_build)
+
+  # Zero init has favorable performance/size tradeoffs for Chrome OS
+  # but was not evaluated for other platforms.
+  init_stack_vars_zero = is_chromeos
+
+  # This argument is to control whether enabling text section splitting in the
+  # final binary. When enabled, the separated text sections with prefix
+  # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be
+  # merged to '.text' section. This allows us to identify the hot code section
+  # ('.text.hot') in the binary, which allows our data collection pipelines to
+  # more easily identify code that we assume to be hot/cold that doesn't turn
+  # out to be such in the field.
+  use_text_section_splitting = is_chromeos
+
+  # Enable DWARF v5.
+  use_dwarf5 = false
+
+  # Override this to put full paths to PDBs in Windows PE files. This helps
+  # windbg and Windows Performance Analyzer with finding the PDBs in some local-
+  # build scenarios. This is never needed for bots or official builds. Because
+  # this puts the output directory in the DLLs/EXEs it breaks build determinism.
+  # Bugs have been reported to the windbg/WPA teams and this workaround will be
+  # removed when they are fixed.
+  use_full_pdb_paths = false
+
+  # Enable -H, which prints the include tree during compilation.
+  # For use by tools/clang/scripts/analyze_includes.py
+  show_includes = false
+
+  # Enable Profi algorithm. Profi can infer block and edge counts.
+  # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
+  # TODO(crbug.com/1375958i:) Possibly enable this for Android too.
+  use_profi = is_chromeos
+
+  # If true, linker crashes will be rerun with `--reproduce` which causes
+  # a reproducer file to be saved.
+  save_reproducers_on_lld_crash = false
+
+  # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
+  # shadow call stack in register x18. Hence, x18 must not be used by the OS
+  # or libraries. We assume that to be the case for high end Android
+  # configurations. For more details see
+  # https://clang.llvm.org/docs/ShadowCallStack.html
+  enable_shadow_call_stack = false
+
+  # Use DWARF simple template names, with the following exceptions:
+  #
+  # * Windows is not supported as it doesn't use DWARF.
+  # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
+  #   lldb doesn't have the needed changes yet.
+  # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
+  #
+  # This greatly reduces the size of debug builds, at the cost of
+  # debugging information which is required by some specialized
+  # debugging tools.
+  simple_template_names = is_clang && !is_nacl && !is_win && !is_apple
+}
+
+declare_args() {
+  # Set to true to use icf, Identical Code Folding.
+  #
+  # icf=all is broken in older golds, see
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+  # chromeos binutils has been patched with the fix, so always use icf there.
+  # The bug only affects x86 and x64, so we can still use ICF when targeting
+  # other architectures.
+  #
+  # lld doesn't have the bug.
+  use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer &&
+            !use_clang_coverage && current_os != "zos" &&
+            !(is_android && use_order_profiling) &&
+            (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" ||
+                                                       current_cpu == "x64"))))
+}
+
+if (is_android) {
+  # Set the path to use orderfile for linking Chrome
+  # Note that this is for using only one orderfile for linking
+  # the Chrome binary/library.
+  declare_args() {
+    chrome_orderfile_path = ""
+
+    if (defined(default_chrome_orderfile)) {
+      # Allow downstream tools to set orderfile path with
+      # another variable.
+      chrome_orderfile_path = default_chrome_orderfile
+    }
+  }
+}
+
+declare_args() {
+  # Turn off the --call-graph-profile-sort flag for lld by default. Enable
+  # selectively for targets where it's beneficial.
+  enable_call_graph_profile_sort =
+      chrome_pgo_phase == 2 ||
+      (is_chromeos &&
+       (clang_use_default_sample_profile || clang_sample_profile_path != ""))
+}
+
+assert(!(llvm_force_head_revision && use_goma),
+       "can't use goma with trunk clang")
+assert(!(llvm_force_head_revision && use_remoteexec),
+       "can't use rbe with trunk clang")
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+  include_dirs = [
+    "//",
+    root_gen_dir,
+  ]
+}
+
+# Compiler instrumentation can introduce dependencies in DSOs to symbols in
+# the executable they are loaded into, so they are unresolved at link-time.
+config("no_unresolved_symbols") {
+  if (!using_sanitizer &&
+      (is_linux || is_chromeos || is_android || is_fuchsia)) {
+    ldflags = [
+      "-Wl,-z,defs",
+      "-Wl,--as-needed",
+    ]
+  }
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  cflags_objc = []
+  cflags_objcc = []
+  rustflags = []
+  ldflags = []
+  defines = []
+  configs = []
+  rustflags = []
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:compiler" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:compiler" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:compiler" ]
+  } else if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:compiler" ]
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:compiler" ]
+  } else if (is_fuchsia) {
+    configs += [ "//build/config/fuchsia:compiler" ]
+  } else if (current_os == "aix") {
+    configs += [ "//build/config/aix:compiler" ]
+  } else if (current_os == "zos") {
+    configs += [ "//build/config/zos:compiler" ]
+  }
+
+  configs += [
+    # See the definitions below.
+    ":clang_revision",
+    ":rustc_revision",
+    ":compiler_cpu_abi",
+    ":compiler_codegen",
+    ":compiler_deterministic",
+  ]
+
+  # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
+  # operations (e.g. dereferencing) into defined behavior. This avoids deletion
+  # of some security-critical code: see https://crbug.com/1139129.
+  # Nacl does not support the flag. And, we still want UBSAN to catch undefined
+  # behavior related to nullptrs, so do not add this flag if UBSAN is enabled.
+  # GCC seems to have some bugs compiling constexpr code when this is defined,
+  # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
+  # TODO(mpdenton): remove is_clang once GCC bug is fixed.
+  if (!is_nacl && !is_ubsan && is_clang) {
+    cflags += [ "-fno-delete-null-pointer-checks" ]
+  }
+
+  # Don't emit the GCC version ident directives, they just end up in the
+  # .comment section or debug info taking up binary size, and makes comparing
+  # .o files built with different compiler versions harder.
+  if (!is_win || is_clang) {
+    cflags += [ "-fno-ident" ]
+  }
+
+  # In general, Windows is totally different, but all the other builds share
+  # some common compiler and linker configuration.
+  if (!is_win) {
+    # Common POSIX compiler flags setup.
+    # --------------------------------
+    cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204
+
+    # Stack protection. ShadowCallStack and Stack protector address the same
+    # problems. Therefore, we only enable one or the other. Clang advertises SCS as
+    # a stronger alternative to StackProtector, so we give SCS precedence over SP.
+    if (enable_shadow_call_stack) {
+      # On Aarch64, SCS requires the x18 register to be unused because it will hold
+      # a pointer to the shadow stack. For Android we know that Clang doesn't use
+      # x18 by default. On other OSs adding "-ffixed-x18" might be required.
+      assert(is_android)
+
+      scs_parameters = [
+        "-fsanitize=shadow-call-stack",
+        "-fno-stack-protector",
+      ]
+      cflags += scs_parameters
+      ldflags += scs_parameters
+    } else {
+      if (is_apple) {
+        # The strong variant of the stack protector significantly increases
+        # binary size, so only enable it in debug mode.
+        if (is_debug) {
+          cflags += [ "-fstack-protector-strong" ]
+        } else {
+          cflags += [ "-fstack-protector" ]
+        }
+      } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
+        # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+        # See also https://crbug.com/533294
+        # The x86 toolchain currently has problems with stack-protector.
+        if (is_android && current_cpu == "x86") {
+          cflags += [ "-fno-stack-protector" ]
+        } else if (current_os != "aix") {
+          # Not available on aix.
+          cflags += [ "-fstack-protector" ]
+        }
+      }
+    }
+
+    if (use_lld) {
+      ldflags += [ "-fuse-ld=lld" ]
+      if (lld_path != "") {
+        ldflags += [ "-B$lld_path" ]
+      }
+    }
+
+    # Linker warnings.
+    if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
+        current_os != "zos") {
+      ldflags += [ "-Wl,--fatal-warnings" ]
+    }
+    if (fatal_linker_warnings && is_apple) {
+      ldflags += [ "-Wl,-fatal_warnings" ]
+    }
+  }
+
+  if (is_clang && is_debug) {
+    # Allow comparing the address of references and 'this' against 0
+    # in debug builds. Technically, these can never be null in
+    # well-defined C/C++ and Clang can optimize such checks away in
+    # release builds, but they may be used in asserts in debug builds.
+    cflags_cc += [
+      "-Wno-undefined-bool-conversion",
+      "-Wno-tautological-undefined-compare",
+    ]
+  }
+
+  # Non-Apple Posix and Fuchsia compiler flags setup.
+  # -----------------------------------
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    if (enable_profiling) {
+      if (!is_debug) {
+        cflags += [ "-g" ]
+
+        if (enable_full_stack_frames_for_profiling) {
+          cflags += [
+            "-fno-inline",
+            "-fno-optimize-sibling-calls",
+          ]
+        }
+      }
+    }
+
+    # Explicitly pass --build-id to ld. Compilers used to always pass this
+    # implicitly but don't any more (in particular clang when built without
+    # ENABLE_LINKER_BUILD_ID=ON).
+    if (is_official_build) {
+      # The sha1 build id has lower risk of collision but is more expensive to
+      # compute, so only use it in the official build to avoid slowing down
+      # links.
+      ldflags += [ "-Wl,--build-id=sha1" ]
+    } else if (current_os != "aix" && current_os != "zos") {
+      ldflags += [ "-Wl,--build-id" ]
+    }
+
+    if (!is_android) {
+      defines += [
+        # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
+        # the behavior of the Android NDK from earlier versions.
+        # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
+        "_FILE_OFFSET_BITS=64",
+        "_LARGEFILE_SOURCE",
+        "_LARGEFILE64_SOURCE",
+      ]
+    }
+
+    if (!is_nacl) {
+      if (exclude_unwind_tables) {
+        cflags += [
+          "-fno-unwind-tables",
+          "-fno-asynchronous-unwind-tables",
+        ]
+        rustflags += [ "-Cforce-unwind-tables=no" ]
+        defines += [ "NO_UNWIND_TABLES" ]
+      } else {
+        cflags += [ "-funwind-tables" ]
+        rustflags += [ "-Cforce-unwind-tables=yes" ]
+      }
+    }
+  }
+
+  # Apple compiler flags setup.
+  # ---------------------------------
+  if (is_apple) {
+    # On Intel, clang emits both Apple's "compact unwind" information and
+    # DWARF eh_frame unwind information by default, for compatibility reasons.
+    # This flag limits emission of eh_frame information to functions
+    # whose unwind information can't be expressed in the compact unwind format
+    # (which in practice means almost everything gets only compact unwind
+    # entries). This reduces object file size a bit and makes linking a bit
+    # faster.
+    # On arm64, this is already the default behavior.
+    if (current_cpu == "x64") {
+      asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+      cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+    }
+  }
+
+  # Linux/Android/Fuchsia common flags setup.
+  # ---------------------------------
+  if (is_linux || is_chromeos || is_android || is_fuchsia) {
+    asmflags += [ "-fPIC" ]
+    cflags += [ "-fPIC" ]
+    ldflags += [ "-fPIC" ]
+    rustflags += [ "-Crelocation-model=pic" ]
+
+    if (!is_clang) {
+      # Use pipes for communicating between sub-processes. Faster.
+      # (This flag doesn't do anything with Clang.)
+      cflags += [ "-pipe" ]
+    }
+
+    ldflags += [
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+    ]
+
+    if (!is_component_build) {
+      ldflags += [ "-Wl,-z,now" ]
+    }
+  }
+
+  # Linux-specific compiler flags setup.
+  # ------------------------------------
+  if (use_gold) {
+    ldflags += [ "-fuse-ld=gold" ]
+    if (!is_android) {
+      # On Android, this isn't needed.  gcc in the NDK knows to look next to
+      # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+      # above.
+      if (gold_path != "") {
+        ldflags += [ "-B$gold_path" ]
+      }
+
+      ldflags += [
+        # Experimentation found that using four linking threads
+        # saved ~20% of link time.
+        # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+        # Only apply this to the target linker, since the host
+        # linker might not be gold, but isn't used much anyway.
+        "-Wl,--threads",
+        "-Wl,--thread-count=4",
+      ]
+    }
+
+    # TODO(thestig): Make this flag work with GN.
+    #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+    #  ldflags += [
+    #    "-Wl,--detect-odr-violations",
+    #  ]
+    #}
+  }
+
+  if (use_icf && (!is_apple || use_lld)) {
+    ldflags += [ "-Wl,--icf=all" ]
+  }
+
+  if (is_linux || is_chromeos) {
+    cflags += [ "-pthread" ]
+    # Do not use the -pthread ldflag here since it becomes a no-op
+    # when using -nodefaultlibs, which would cause an unused argument
+    # error.  "-lpthread" is added in //build/config:default_libs.
+  }
+
+  # Clang-specific compiler flags setup.
+  # ------------------------------------
+  if (is_clang) {
+    cflags += [ "-fcolor-diagnostics" ]
+
+    # Enable -fmerge-all-constants. This used to be the default in clang
+    # for over a decade. It makes clang non-conforming, but is fairly safe
+    # in practice and saves some binary size. We might want to consider
+    # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13),
+    # but for now it looks like our build might rely on it
+    # (https://crbug.com/829795).
+    cflags += [ "-fmerge-all-constants" ]
+  }
+
+  if (use_lld) {
+    # TODO(thakis): Make the driver pass --color-diagnostics to the linker
+    # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
+    # in ldflags instead.
+    if (is_win) {
+      # On Windows, we call the linker directly, instead of calling it through
+      # the driver.
+      ldflags += [ "--color-diagnostics" ]
+    } else {
+      ldflags += [ "-Wl,--color-diagnostics" ]
+    }
+  }
+
+  # Enable text section splitting only on linux when using lld for now. Other
+  # platforms can be added later if needed.
+  if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) {
+    ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
+  }
+
+  if (is_clang && !is_nacl && current_os != "zos") {
+    cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
+    if (save_reproducers_on_lld_crash && use_lld) {
+      ldflags += [
+        "-fcrash-diagnostics=all",
+        "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
+      ]
+    }
+
+    # TODO(hans): Remove this once Clang generates better optimized debug info
+    # by default. https://crbug.com/765793
+    cflags += [
+      "-mllvm",
+      "-instcombine-lower-dbg-declare=0",
+    ]
+    if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+      if (is_win) {
+        ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
+      } else {
+        ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
+      }
+    }
+
+    # TODO(crbug.com/1235145): Investigate why/if this should be needed.
+    if (is_win) {
+      cflags += [ "/clang:-ffp-contract=off" ]
+    } else {
+      cflags += [ "-ffp-contract=off" ]
+    }
+  }
+
+  # C11/C++11 compiler flags setup.
+  # ---------------------------
+  if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
+      current_os == "aix") {
+    if (is_clang) {
+      standard_prefix = "c"
+
+      # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
+      # defined by the compiler.  However, lots of code relies on the
+      # non-standard features that _GNU_SOURCE enables, so define it manually.
+      defines += [ "_GNU_SOURCE" ]
+
+      if (is_nacl) {
+        # Undefine __STRICT_ANSI__ to get non-standard features which would
+        # otherwise not be enabled by NaCl's sysroots.
+        cflags += [ "-U__STRICT_ANSI__" ]
+      }
+    } else {
+      # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
+      # but we use this feature in several places in Chromium.
+      # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the
+      # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
+      # to -std=c*.
+      standard_prefix = "gnu"
+    }
+
+    cflags_c += [ "-std=${standard_prefix}11" ]
+    if (is_nacl && !is_nacl_saigo) {
+      # This is for the pnacl_newlib toolchain. It's only used to build
+      # a few independent ppapi test files that don't pull in any other
+      # dependencies.
+      cflags_cc += [ "-std=${standard_prefix}++14" ]
+      if (is_clang) {
+        cflags_cc += [ "-fno-trigraphs" ]
+      }
+    } else if (is_clang) {
+      if (defined(use_cxx17) && use_cxx17) {
+        cflags_cc += [ "-std=${standard_prefix}++17" ]
+      } else {
+        cflags_cc += [ "-std=${standard_prefix}++20" ]
+      }
+    } else {
+      # The gcc bots are currently using GCC 9, which is not new enough to
+      # support "c++20"/"gnu++20".
+      cflags_cc += [ "-std=${standard_prefix}++2a" ]
+    }
+  } else if (is_win) {
+    cflags_c += [ "/std:c11" ]
+    if ((defined(use_cxx17) && use_cxx17) ||
+        (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) {
+      cflags_cc += [ "/std:c++17" ]
+    } else {
+      cflags_cc += [ "/std:c++20" ]
+    }
+  } else if (!is_nacl) {
+    # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
+    # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
+    # more, but there are still a few buildbots using it, so until those are
+    # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
+    # clause, above.
+    cflags_c += [ "-std=c11" ]
+
+    if (defined(use_cxx17) && use_cxx17) {
+      cflags_cc += [ "-std=c++17" ]
+    } else {
+      cflags_cc += [ "-std=c++20" ]
+    }
+  }
+
+  if (is_clang && current_os != "zos") {
+    # C++17 removes trigraph support, but clang still warns that it ignores
+    # them when seeing them.  Don't.
+    cflags_cc += [ "-Wno-trigraphs" ]
+  }
+
+  if (use_relative_vtables_abi) {
+    cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
+    ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
+  }
+
+  # Add flags for link-time optimization. These flags enable
+  # optimizations/transformations that require whole-program visibility at link
+  # time, so they need to be applied to all translation units, and we may end up
+  # with miscompiles if only part of the program is compiled with LTO flags. For
+  # that reason, we cannot allow targets to enable or disable these flags, for
+  # example by disabling the optimize configuration.
+  # TODO(pcc): Make this conditional on is_official_build rather than on gn
+  # flags for specific features.
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    assert(use_lld, "LTO is only supported with lld")
+
+    cflags += [
+      "-flto=thin",
+      "-fsplit-lto-unit",
+    ]
+
+    # Limit the size of the ThinLTO cache to the lesser of 10% of
+    # available disk space, 40GB and 100000 files.
+    cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000"
+
+    # An import limit of 30 has better performance (per speedometer) and lower
+    # binary size than the default setting of 100.
+    # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
+    # should be able to better manage binary size increases on its own.
+    import_instr_limit = 30
+
+    if (is_win) {
+      ldflags += [
+        "/opt:lldltojobs=all",
+        "-mllvm:-import-instr-limit=$import_instr_limit",
+        "/lldltocache:" +
+            rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+        "/lldltocachepolicy:$cache_policy",
+        "-mllvm:-disable-auto-upgrade-debug-info",
+      ]
+    } else {
+      ldflags += [ "-flto=thin" ]
+
+      # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory
+      # usage in crbug.com/1038040. Note this will increase build time in
+      # Chrome OS.
+
+      # In ThinLTO builds, we run at most one link process at a time,
+      # and let it use all cores.
+      # TODO(thakis): Check if '=0' (that is, number of cores, instead
+      # of "all" which means number of hardware threads) is faster.
+      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_apple) {
+        ldflags += [
+          "-Wl,-cache_path_lto," +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+          "-Wcrl,object_path_lto",
+        ]
+      } else {
+        ldflags +=
+            [ "-Wl,--thinlto-cache-dir=" +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ]
+      }
+
+      ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+
+      if (is_chromeos) {
+        # ARM was originally set lower than x86 to keep the size
+        # bloat of ThinLTO to <10%, but that's potentially no longer true.
+        # FIXME(inglorion): maybe tune these?
+        # TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
+        import_instr_limit = 20
+      } else if (is_android) {
+        # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win
+        # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB.
+        import_instr_limit = 5
+      }
+
+      ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
+
+      if (!is_chromeos) {
+        # TODO(https://crbug.com/972449): turn on for ChromeOS when that
+        # toolchain has this flag.
+        # We only use one version of LLVM within a build so there's no need to
+        # upgrade debug info, which can be expensive since it runs the verifier.
+        ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
+      }
+    }
+
+    # TODO(https://crbug.com/1211155): investigate why this isn't effective on
+    # arm32.
+    if (!is_android || current_cpu == "arm64") {
+      cflags += [ "-fwhole-program-vtables" ]
+
+      if (toolchain_supports_rust_thin_lto) {
+        # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
+        # behaviour. Rust needs to know the linker will be doing LTO in this case
+        # or it rejects the Zsplit-lto-unit flag.
+        rustflags += [
+          "-Zsplit-lto-unit",
+          "-Clinker-plugin-lto=yes",
+        ]
+      } else {
+        # Don't include bitcode if it won't be used.
+        rustflags += [ "-Cembed-bitcode=no" ]
+      }
+
+      if (!is_win) {
+        ldflags += [ "-fwhole-program-vtables" ]
+      }
+    }
+
+    # This flag causes LTO to create an .ARM.attributes section with the correct
+    # architecture. This is necessary because LLD will refuse to link a program
+    # unless the architecture revision in .ARM.attributes is sufficiently new.
+    # TODO(pcc): The contents of .ARM.attributes should be based on the
+    # -march flag passed at compile time (see llvm.org/pr36291).
+    if (current_cpu == "arm") {
+      ldflags += [ "-march=$arm_arch" ]
+    }
+  }
+
+  if (compiler_timing) {
+    if (is_clang && !is_nacl) {
+      cflags += [ "-ftime-trace" ]
+    } else if (is_win) {
+      cflags += [
+        # "Documented" here:
+        # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
+        "/d2cgsummary",
+      ]
+    }
+  }
+
+  # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize
+  # stack crashes (http://crbug.com/919499).
+  if (use_lld && is_android) {
+    ldflags += [ "-Wl,--no-rosegment" ]
+  }
+
+  # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+  # --no-undefined-version.
+  if (use_lld && !is_win && !is_mac && !is_ios) {
+    ldflags += [ "-Wl,--undefined-version" ]
+  }
+
+  if (use_lld && is_apple) {
+    ldflags += [ "-Wl,--strict-auto-link" ]
+  }
+
+  # LLD does call-graph-sorted binary layout by default when profile data is
+  # present. On Android this increases binary size due to more thinks for long
+  # jumps. Turn it off by default and enable selectively for targets where it's
+  # beneficial.
+  if (use_lld && !enable_call_graph_profile_sort) {
+    if (is_win) {
+      ldflags += [ "/call-graph-profile-sort:no" ]
+    } else {
+      ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
+    }
+  }
+
+  if (is_clang && !is_nacl && show_includes) {
+    if (is_win) {
+      # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
+      assert(!use_goma, "show_includes on Windows is not reliable with goma")
+      cflags += [
+        "/clang:-H",
+        "/clang:-fshow-skipped-includes",
+      ]
+    } else {
+      cflags += [
+        "-H",
+        "-fshow-skipped-includes",
+      ]
+    }
+  }
+
+  # This flag enforces that member pointer base types are complete. It helps
+  # prevent us from running into problems in the Microsoft C++ ABI (see
+  # https://crbug.com/847724).
+  if (is_clang && !is_nacl && target_os != "chromeos" &&
+      (is_win || use_custom_libcxx)) {
+    cflags += [ "-fcomplete-member-pointers" ]
+  }
+
+  # Use DWARF simple template names.
+  if (simple_template_names) {
+    cflags_cc += [ "-gsimple-template-names" ]
+  }
+
+  # MLGO specific flags. These flags enable an ML-based inliner trained on
+  # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
+  # The "release" ML model is embedded into clang as part of its build.
+  # Currently, the ML inliner is only enabled when targeting Android due to:
+  # a) Android is where size matters the most.
+  # b) MLGO presently has the limitation of only being able to embed one model
+  #    at a time; It is unclear if the embedded model is beneficial for
+  #    non-Android targets.
+  # MLGO is only officially supported on linux.
+  if (use_ml_inliner && is_a_target_toolchain) {
+    assert(
+        is_android && host_os == "linux",
+        "MLGO is currently only supported for targeting Android on a linux host")
+    if (use_thin_lto) {
+      ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
+    }
+  }
+
+  if (clang_embed_bitcode) {
+    assert(!use_thin_lto,
+           "clang_embed_bitcode is only supported in non-ThinLTO builds")
+    cflags += [
+      "-Xclang",
+      "-fembed-bitcode=all",
+    ]
+  }
+
+  if (lld_emit_indexes_and_imports) {
+    assert(use_thin_lto,
+           "lld_emit_indexes_and_imports is only supported with ThinLTO builds")
+    ldflags += [
+      "-Wl,--save-temps=import",
+      "-Wl,--thinlto-emit-index-files",
+    ]
+  }
+
+  # Pass the same C/C++ flags to the objective C/C++ compiler.
+  cflags_objc += cflags_c
+  cflags_objcc += cflags_cc
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler. The Windows assembler takes different types of flags
+  # so only do so for posix platforms.
+  if (is_posix || is_fuchsia) {
+    asmflags += cflags
+    asmflags += cflags_c
+  }
+
+  if (is_chromeos_device && !is_nacl) {
+    # On ChromeOS devices, we want to ensure we're using Chrome's allocator
+    # symbols for all C++ new/delete operator overloads. PartitionAlloc
+    # and other local allocators should always take precedence over system or
+    # preloaded allocators. These are the mangled symbol names.
+    # See b/280115910 for details.
+    ldflags += [
+      "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
+      "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
+      "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
+      "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
+      "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
+      "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
+    ]
+  }
+
+  # Rust compiler flags setup.
+  # ---------------------------
+  rustflags += [
+    # Overflow checks are optional in Rust, but even if switched
+    # off they do not cause undefined behavior (the overflowing
+    # behavior is defined). Because containers are bounds-checked
+    # in safe Rust, they also can't provoke buffer overflows.
+    # As such these checks may be less important in Rust than C++.
+    # But in (simplistic) testing they have negligible performance
+    # overhead, and this helps to provide consistent behavior
+    # between different configurations, so we'll keep them on until
+    # we discover a reason to turn them off.
+    "-Coverflow-checks=on",
+
+    # By default Rust passes `-nodefaultlibs` to the linker, however this
+    # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
+    # is then unused and produces a warning/error. So this removes the
+    # `-nodefaultlibs` from the linker invocation from Rust, which would be used
+    # to compile dylibs on Android, such as for constructing unit test APKs.
+    "-Cdefault-linker-libraries",
+
+    # To make Rust .d files compatible with ninja
+    "-Zdep-info-omit-d-target",
+
+    # If a macro panics during compilation, show which macro and where it is
+    # defined.
+    "-Zmacro-backtrace",
+
+    # For deterministic builds, keep the local machine's current working
+    # directory from appearing in build outputs.
+    "-Zremap-cwd-prefix=.",
+  ]
+
+  if (!is_win || force_rustc_color_output) {
+    # Colorize error output. The analogous flag is passed for clang. This must
+    # be platform-gated since rustc will unconditionally output ANSI escape
+    # sequences, ignoring the platform, when stderr is not a terminal.
+    rustflags += [ "--color=always" ]
+  }
+  if (rust_abi_target != "") {
+    rustflags += [ "--target=$rust_abi_target" ]
+  }
+  if (!use_thin_lto) {
+    # Don't include bitcode if it won't be used.
+    rustflags += [ "-Cembed-bitcode=no" ]
+  }
+  if (is_official_build) {
+    rustflags += [ "-Ccodegen-units=1" ]
+  }
+  if (!rust_prebuilt_stdlib) {
+    # When building against the Chromium Rust stdlib (which we compile) always
+    # abort instead of unwinding when panic occurs. In official builds, panics
+    # abort immediately (this is configured in the stdlib) to keep binary size
+    # down. So we unconditionally match behaviour in unofficial too.
+    rustflags += [
+      "-Cpanic=abort",
+      "-Zpanic_abort_tests",
+    ]
+  }
+
+  # Normally, this would be defined in the `runtime_library` config but NaCl
+  # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there
+  # isn't really a better config to add this define for the define to
+  # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
+  # and NaCl code.
+  #
+  # TODO(https://crbug.com/702997): Move this back to the `runtime_library`
+  # config when NaCl is removed.
+  if (use_safe_libcxx) {
+    # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once
+    # it's rolled in.
+    if (is_nacl_saigo) {
+      defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
+    } else {
+      defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ]
+    }
+  }
+}
+
+# The BUILDCONFIG file sets this config on targets by default, which means when
+# building with ThinLTO, no optimization is performed in the link step.
+config("thinlto_optimize_default") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    lto_opt_level = 0
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# Use this to enable optimization in the ThinLTO link step for select targets
+# when thin_lto_enable_optimizations is set by doing:
+#
+#   configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
+#   configs += [ "//build/config/compiler:thinlto_optimize_max" ]
+#
+# Since it makes linking significantly slower and more resource intensive, only
+# use it on important targets such as the main browser executable or dll.
+config("thinlto_optimize_max") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    if (thin_lto_enable_optimizations) {
+      lto_opt_level = 2
+    } else {
+      lto_opt_level = 0
+    }
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+  defines = []
+
+  configs = []
+  if (is_chromeos) {
+    configs += [ "//build/config/chromeos:compiler_cpu_abi" ]
+  }
+
+  # TODO(https://crbug.com/1383873): Remove this once figured out.
+  if (is_apple && current_cpu == "arm64") {
+    cflags += [ "-fno-global-isel" ]
+    ldflags += [ "-fno-global-isel" ]
+  }
+
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "-m64",
+        "-msse3",
+      ]
+      ldflags += [ "-m64" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+      if (!is_nacl) {
+        cflags += [
+          "-mfpmath=sse",
+          "-msse3",
+        ]
+      }
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=arm-linux-gnueabihf" ]
+        ldflags += [ "--target=arm-linux-gnueabihf" ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "arm64") {
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=aarch64-linux-gnu" ]
+        ldflags += [ "--target=aarch64-linux-gnu" ]
+      }
+    } else if (current_cpu == "mipsel" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mipsel-linux-android" ]
+            ldflags += [ "--target=mipsel-linux-android" ]
+          } else {
+            cflags += [ "--target=mipsel-linux-gnu" ]
+            ldflags += [ "--target=mipsel-linux-gnu" ]
+          }
+        } else {
+          cflags += [ "-EL" ]
+          ldflags += [ "-EL" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [ "-mno-odd-spreg" ]
+        ldflags += [ "-mips32r6" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r6",
+          ]
+        } else {
+          cflags += [
+            "-mips32r6",
+            "-Wa,-mips32r6",
+          ]
+          if (is_android) {
+            ldflags += [ "-Wl,-melf32ltsmip" ]
+          }
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips32r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r2",
+          ]
+        } else {
+          cflags += [
+            "-mips32r2",
+            "-Wa,-mips32r2",
+          ]
+          if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+            cflags += [ "-m$mips_fpu_mode" ]
+          }
+        }
+      } else if (mips_arch_variant == "r1") {
+        ldflags += [ "-mips32" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32",
+          ]
+        } else {
+          cflags += [
+            "-mips32",
+            "-Wa,-mips32",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips-linux-gnu" ]
+          ldflags += [ "--target=mips-linux-gnu" ]
+        } else {
+          cflags += [ "-EB" ]
+          ldflags += [ "-EB" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mips64el-linux-android" ]
+            ldflags += [ "--target=mips64el-linux-android" ]
+          } else {
+            cflags += [ "--target=mips64el-linux-gnuabi64" ]
+            ldflags += [ "--target=mips64el-linux-gnuabi64" ]
+          }
+        } else {
+          cflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r6",
+          ]
+        } else {
+          cflags += [
+            "-mips64r6",
+            "-Wa,-mips64r6",
+          ]
+          ldflags += [ "-mips64r6" ]
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips64r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r2",
+          ]
+        } else {
+          cflags += [
+            "-mips64r2",
+            "-Wa,-mips64r2",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+    } else if (current_cpu == "mips64") {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips64-linux-gnuabi64" ]
+          ldflags += [ "--target=mips64-linux-gnuabi64" ]
+        } else {
+          cflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    } else if (current_cpu == "ppc64") {
+      if (current_os == "aix") {
+        cflags += [ "-maix64" ]
+        ldflags += [ "-maix64" ]
+      } else {
+        cflags += [ "-m64" ]
+        ldflags += [ "-m64" ]
+      }
+    } else if (current_cpu == "riscv64") {
+      if (is_clang && !is_android) {
+        cflags += [ "--target=riscv64-linux-gnu" ]
+        ldflags += [ "--target=riscv64-linux-gnu" ]
+      }
+      cflags += [ "-mabi=lp64d" ]
+    } else if (current_cpu == "loong64") {
+      if (is_clang) {
+        cflags += [ "--target=loongarch64-linux-gnu" ]
+        ldflags += [ "--target=loongarch64-linux-gnu" ]
+      }
+      cflags += [
+        "-mabi=lp64d",
+        "-mcmodel=medium",
+      ]
+    } else if (current_cpu == "s390x") {
+      cflags += [ "-m64" ]
+      ldflags += [ "-m64" ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+  configs = []
+  cflags = []
+  ldflags = []
+
+  if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler_codegen" ]
+  }
+
+  if (current_cpu == "arm64" && !is_win && is_clang) {
+    # Disable outlining everywhere on arm64 except Win. For more information see
+    # crbug.com/931297 for Android and crbug.com/1410297 for iOS.
+    # TODO(crbug.com/1411363): Enable this on Windows if possible.
+    cflags += [ "-mno-outline" ]
+
+    # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
+    # has been resolved, and -mno-outline is obeyed by the linker during
+    # ThinLTO.
+    ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
+  }
+
+  asmflags = cflags
+}
+
+# This provides options that make the build deterministic, so that the same
+# revision produces the same output, independent of the name of the build
+# directory and of the computer the build is done on.
+# The relative path from build dir to source dir makes it into the build
+# outputs, so it's recommended that you use a build dir two levels deep
+# (e.g. "out/Release") so that you get the same "../.." path as all the bots
+# in your build outputs.
+config("compiler_deterministic") {
+  cflags = []
+  ldflags = []
+  swiftflags = []
+
+  # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+  # deterministic build.  See https://crbug.com/314403
+  if (!is_official_build) {
+    if (is_win && !is_clang) {
+      cflags += [
+        "/wd4117",  # Trying to define or undefine a predefined macro.
+        "/D__DATE__=",
+        "/D__TIME__=",
+        "/D__TIMESTAMP__=",
+      ]
+    } else {
+      cflags += [
+        "-Wno-builtin-macro-redefined",
+        "-D__DATE__=",
+        "-D__TIME__=",
+        "-D__TIMESTAMP__=",
+      ]
+    }
+  }
+
+  # Makes builds independent of absolute file path.
+  if (is_clang && strip_absolute_paths_from_debug_symbols) {
+    # If debug option is given, clang includes $cwd in debug info by default.
+    # For such build, this flag generates reproducible obj files even we use
+    # 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=." ]
+      swiftflags += [ "-file-compilation-dir=." ]
+    }
+    if (!is_win) {
+      # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+      asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+    }
+
+    if (is_win && use_lld) {
+      if (symbol_level == 2 || (is_clang && using_sanitizer)) {
+        # Absolutize source file paths for PDB. Pass the real build directory
+        # if the pdb contains source-level debug information and if linker
+        # reproducibility is not critical.
+        ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ]
+      } else {
+        # Use a fake fixed base directory for paths in the pdb to make the pdb
+        # output fully deterministic and independent of the build directory.
+        ldflags += [ "/PDBSourcePath:o:\fake\prefix" ]
+      }
+    }
+  }
+
+  # Tells the compiler not to use absolute paths when passing the default
+  # paths to the tools it invokes. We don't want this because we don't
+  # really need it and it can mess up the goma cache entries.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags += [ "-no-canonical-prefixes" ]
+
+    # Same for links: Let the compiler driver invoke the linker
+    # with a relative path and pass relative paths to built-in
+    # libraries. Not needed on Windows because we call the linker
+    # directly there, not through the compiler driver.
+    # We don't link on goma, so this change is just for cleaner
+    # internal linker invocations, for people who work on the build.
+    if (!is_win) {
+      ldflags += [ "-no-canonical-prefixes" ]
+    }
+  }
+}
+
+config("clang_revision") {
+  if (is_clang && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
+config("rustc_revision") {
+  if (rustc_revision != "") {
+    # Similar to the above config, this is here so that all files get recompiled
+    # after a rustc roll. Nothing should ever read this cfg. This will not be
+    # set if a custom toolchain is used.
+    rustflags = [
+      "--cfg",
+      "cr_rustc_revision=\"$rustc_revision\"",
+    ]
+  }
+}
+
+config("compiler_arm_fpu") {
+  if (current_cpu == "arm" && !is_ios && !is_nacl) {
+    cflags = [ "-mfpu=$arm_fpu" ]
+    if (!arm_use_thumb) {
+      cflags += [ "-marm" ]
+    }
+    asmflags = cflags
+  }
+}
+
+config("compiler_arm_thumb") {
+  if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+      !(is_apple || is_nacl)) {
+    cflags = [ "-mthumb" ]
+  }
+}
+
+config("compiler_arm") {
+  if (current_cpu == "arm" && is_chromeos) {
+    # arm is normally the default mode for clang, but on chromeos a wrapper
+    # is used to pass -mthumb, and therefor change the default.
+    cflags = [ "-marm" ]
+  }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+  configs = []
+
+  # The order of this config is important: it must appear before
+  # android:runtime_library.  This is to ensure libc++ appears before
+  # libandroid_support in the -isystem include order.  Otherwise, there will be
+  # build errors related to symbols declared in math.h.
+  if (use_custom_libcxx) {
+    configs += [ "//build/config/c++:runtime_library" ]
+  }
+
+  # Rust and C++ both provide intrinsics for LLVM to call for math operations. We
+  # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins
+  # library. The Rust symbols are marked as weak, so that they can be replaced by
+  # the C++ symbols. This config ensures the C++ symbols exist and are strong in
+  # order to cause that replacement to occur by explicitly linking in clang's
+  # compiler-rt library.
+  if (is_clang && toolchain_has_rust) {
+    configs += [ "//build/config/clang:compiler_builtins" ]
+  }
+
+  # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia
+  # configuration.
+  if (is_posix || is_fuchsia) {
+    configs += [ "//build/config/posix:runtime_library" ]
+
+    if (use_custom_libunwind) {
+      # Instead of using an unwind lib from the toolchain,
+      # buildtools/third_party/libunwind will be built and used directly.
+      ldflags = [ "--unwindlib=none" ]
+    }
+  }
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:runtime_library" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:runtime_library" ]
+    if (is_chromeos) {
+      configs += [ "//build/config/chromeos:runtime_library" ]
+    }
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:runtime_library" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:runtime_library" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:runtime_library" ]
+  }
+
+  if (is_component_build) {
+    defines = [ "COMPONENT_BUILD" ]
+  }
+}
+
+# treat_warnings_as_errors ----------------------------------------------------
+#
+# Adding this config causes the compiler to treat warnings as fatal errors.
+# This is used as a subconfig of both chromium_code and no_chromium_code, and
+# is broken out separately so nocompile tests can force-enable this setting
+# independently of the default warning flags.
+config("treat_warnings_as_errors") {
+  if (is_win) {
+    cflags = [ "/WX" ]
+  } else {
+    cflags = [ "-Werror" ]
+
+    # The compiler driver can sometimes (rarely) emit warnings before calling
+    # the actual linker.  Make sure these warnings are treated as errors as
+    # well.
+    ldflags = [ "-Werror" ]
+  }
+
+  # Turn rustc warnings into the "deny" lint level, which produce compiler
+  # errors. The equivalent of -Werror for clang/gcc.
+  #
+  # Note we apply the actual lint flags in config("compiler"). All warnings
+  # are suppressed in third-party crates.
+  rustflags = [ "-Dwarnings" ]
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default.  This is used as a
+# subconfig of both chromium_code and no_chromium_code.  This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  ldflags = []
+  configs = []
+
+  if (is_win) {
+    if (fatal_linker_warnings) {
+      arflags = [ "/WX" ]
+      ldflags = [ "/WX" ]
+    }
+    defines = [
+      # Without this, Windows headers warn that functions like wcsnicmp
+      # should be spelled _wcsnicmp. But all other platforms keep spelling
+      # it wcsnicmp, making this warning unhelpful. We don't want it.
+      "_CRT_NONSTDC_NO_WARNINGS",
+
+      # TODO(thakis): winsock wants us to use getaddrinfo instead of
+      # gethostbyname. Fires mostly in non-Chromium code. We probably
+      # want to remove this define eventually.
+      "_WINSOCK_DEPRECATED_NO_WARNINGS",
+    ]
+    if (!is_clang) {
+      # TODO(thakis): Remove this once
+      # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
+      # rolled into angle.
+      cflags += [ "/wd4244" ]
+    }
+  } else {
+    if (is_apple && !is_nacl) {
+      # When compiling Objective-C, warns if a method is used whose
+      # availability is newer than the deployment target.
+      cflags += [ "-Wunguarded-availability" ]
+    }
+
+    if (is_ios) {
+      # When compiling Objective-C, warns if a selector named via @selector has
+      # not been defined in any visible interface.
+      cflags += [ "-Wundeclared-selector" ]
+    }
+
+    # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+    # warning).
+    if (current_cpu == "arm" && !is_clang) {
+      cflags += [ "-Wno-psabi" ]
+    }
+
+    if (!is_clang) {
+      cflags_cc += [
+        # See comment for -Wno-c++11-narrowing.
+        "-Wno-narrowing",
+      ]
+
+      # -Wno-class-memaccess warns about hash table and vector in blink.
+      # But the violation is intentional.
+      if (!is_nacl) {
+        cflags_cc += [ "-Wno-class-memaccess" ]
+      }
+
+      # -Wunused-local-typedefs is broken in gcc,
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
+      cflags += [ "-Wno-unused-local-typedefs" ]
+
+      # Don't warn about "maybe" uninitialized. Clang doesn't include this
+      # in -Wall but gcc does, and it gives false positives.
+      cflags += [ "-Wno-maybe-uninitialized" ]
+      cflags += [ "-Wno-deprecated-declarations" ]
+
+      # -Wcomment gives too many false positives in the case a
+      # backslash ended comment line is followed by a new line of
+      # comments
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
+      cflags += [ "-Wno-comments" ]
+
+      # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
+      # files.
+      cflags += [ "-Wno-packed-not-aligned" ]
+    }
+  }
+
+  # Common Clang and GCC warning setup.
+  if (!is_win || is_clang) {
+    cflags += [
+      # Disables.
+      "-Wno-missing-field-initializers",  # "struct foo f = {0};"
+      "-Wno-unused-parameter",  # Unused function parameters.
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # An ABI compat warning we don't care about, https://crbug.com/1102157
+        # TODO(thakis): Push this to the (few) targets that need it,
+        # instead of having a global flag.
+        "-Wno-psabi",
+      ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      "-Wloop-analysis",
+
+      # TODO(thakis): This used to be implied by -Wno-unused-function,
+      # which we no longer use. Check if it makes sense to remove
+      # this as well. http://crbug.com/316352
+      "-Wno-unneeded-internal-declaration",
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      if (is_win) {
+        # TODO(thakis): https://crbug.com/617318
+        # Currently goma can not handle case sensitiveness for windows well.
+        cflags += [ "-Wno-nonportable-include-path" ]
+      }
+
+      if (is_fuchsia) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1474434): fix and reenable
+          "-Wno-missing-field-initializers",
+        ]
+      }
+
+      cflags += [
+        "-Wenum-compare-conditional",
+
+        # Ignore warnings about MSVC optimization pragmas.
+        # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
+        "-Wno-ignored-pragma-optimize",
+      ]
+
+      if (!is_nacl) {
+        cflags += [
+          # TODO(crbug.com/1343975) Evaluate and possibly enable.
+          "-Wno-deprecated-builtins",
+
+          # TODO(crbug.com/1352183) Evaluate and possibly enable.
+          "-Wno-bitfield-constant-conversion",
+
+          # TODO(crbug.com/1412713) Evaluate and possibly enable.
+          "-Wno-deprecated-this-capture",
+        ]
+      }
+    }
+
+    # Some builders, such as Cronet, use a different version of Clang than
+    # Chromium. This can cause minor errors when compiling Chromium changes. We
+    # want to avoid these errors.
+    if (llvm_android_mainline) {
+      cflags += [
+        "-Wno-error=unknown-warning-option",
+        "-Wno-error=unused-command-line-argument",
+      ]
+    }
+  }
+
+  # Rust warnings
+
+  # Require `unsafe` blocks even in `unsafe` fns. This is intended to become
+  # an error by default eventually; see
+  # https://github.com/rust-lang/rust/issues/71668
+  rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
+}
+
+# prevent_unsafe_narrowing ----------------------------------------------------
+#
+# Warnings that prevent narrowing or comparisons of integer types that are
+# likely to cause out-of-bound read/writes or Undefined Behaviour. In
+# particular, size_t is used for memory sizes, allocation, indexing, and
+# offsets. Using other integer types along with size_t produces risk of
+# memory-safety bugs and thus security exploits.
+#
+# In order to prevent these bugs, allocation sizes were historically limited to
+# sizes that can be represented within 31 bits of information, allowing `int` to
+# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
+# support increasing the allocation limit we require strictly adherence to
+# using the correct types, avoiding lossy conversions, and preventing overflow.
+# To do so, enable this config and fix errors by converting types to be
+# `size_t`, which is both large enough and unsigned, when dealing with memory
+# sizes, allocations, indices, or offsets.In cases where type conversion is not
+# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
+# to convert to size_t as needed.
+# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
+#
+# To enable in a GN target, use:
+#   configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
+
+config("prevent_unsafe_narrowing") {
+  if (is_clang) {
+    cflags = [
+      "-Wshorten-64-to-32",
+      "-Wimplicit-int-conversion",
+      "-Wsign-compare",
+      "-Wsign-conversion",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
+        # fixing types to be sign-correct.
+        "-Wtautological-unsigned-zero-compare",
+      ]
+    }
+  }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+  if (is_win) {
+    if (is_clang) {
+      cflags = [ "/W4" ]  # Warning level 4.
+
+      # Opt in to additional [[nodiscard]] on standard library methods.
+      defines = [ "_HAS_NODISCARD" ]
+    }
+  } else {
+    cflags = [ "-Wall" ]
+    if (is_clang) {
+      # Enable extra warnings for chromium_code when we control the compiler.
+      cflags += [ "-Wextra" ]
+    }
+
+    # In Chromium code, we define __STDC_foo_MACROS in order to get the
+    # C99 macros on Mac and Linux.
+    defines = [
+      "__STDC_CONSTANT_MACROS",
+      "__STDC_FORMAT_MACROS",
+    ]
+
+    if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+        current_cpu != "s390" && current_cpu != "ppc64" &&
+        current_cpu != "mips" && current_cpu != "mips64" &&
+        current_cpu != "riscv64" && current_cpu != "loong64") {
+      # Non-chromium code is not guaranteed to compile cleanly with
+      # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+      # disabled, so only do that for Release build.
+      fortify_level = "2"
+
+      # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation
+      # with a few custom glibc patches. Use that if it's available.
+      if (is_chromeos_ash) {
+        fortify_level = "3"
+      }
+      defines += [ "_FORTIFY_SOURCE=" + fortify_level ]
+    }
+
+    if (is_apple) {
+      cflags_objc = [ "-Wimplicit-retain-self" ]
+      cflags_objcc = [ "-Wimplicit-retain-self" ]
+    }
+
+    if (is_mac) {
+      cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
+      cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Warn on missing break statements at the end of switch cases.
+      # For intentional fallthrough, use [[fallthrough]].
+      "-Wimplicit-fallthrough",
+
+      # Warn on unnecessary extra semicolons outside of function definitions.
+      "-Wextra-semi",
+
+      # Warn on unreachable code, including unreachable breaks and returns.
+      # See https://crbug.com/346399#c148 for suppression strategies.
+      "-Wunreachable-code-aggressive",
+    ]
+
+    # Thread safety analysis is broken under nacl: https://crbug.com/982423.
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # Thread safety analysis. See base/thread_annotations.h and
+        # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
+        "-Wthread-safety",
+      ]
+    }
+  }
+
+  configs = [
+    ":default_warnings",
+    ":noshadowing",
+  ]
+  if (treat_warnings_as_errors) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
+  if (is_win) {
+    if (is_clang) {
+      cflags += [ "/W3" ]  # Warning level 3.
+    }
+    cflags += [
+      "/wd4800",  # Disable warning when forcing value to bool.
+      "/wd4267",  # TODO(jschuh): size_t to int.
+    ]
+  } else {
+    if (is_clang && !is_nacl) {
+      # TODO(thakis): Remove !is_nacl once
+      # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+      cflags += [ "-Wall" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Lots of third-party libraries have unused variables. Instead of
+      # suppressing them individually, we just blanket suppress them here.
+      "-Wno-unused-variable",
+
+      # Similarly, we're not going to fix all the C++11 narrowing issues in
+      # third-party libraries.
+      "-Wno-c++11-narrowing",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Disabled for similar reasons as -Wunused-variable.
+        "-Wno-unused-but-set-variable",
+
+        # TODO(https://crbug.com/1202159): Clean up and enable.
+        "-Wno-misleading-indentation",
+      ]
+    }
+  }
+
+  # Suppress all warnings in third party, as Cargo does:
+  # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
+  rustflags = [ "--cap-lints=allow" ]
+
+  configs = [ ":default_warnings" ]
+
+  # GCC may emit unsuppressible warnings so only apply this config when
+  # building with clang. crbug.com/589724
+  if (treat_warnings_as_errors && is_clang) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+# noshadowing -----------------------------------------------------------------
+#
+# Allows turning -Wshadow on.
+
+config("noshadowing") {
+  # This flag has to be disabled for nacl because the nacl compiler is too
+  # strict about shadowing.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags = [ "-Wshadow" ]
+  }
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+  if (is_win) {
+    cflags_cc = [ "/GR" ]
+  } else {
+    cflags_cc = [ "-frtti" ]
+  }
+}
+
+config("no_rtti") {
+  # Some sanitizer configs may require RTTI to be left enabled globally
+  if (!use_rtti) {
+    if (is_win) {
+      cflags_cc = [ "/GR-" ]
+    } else {
+      cflags_cc = [ "-fno-rtti" ]
+      cflags_objcc = cflags_cc
+    }
+  }
+}
+
+# export_dynamic ---------------------------------------------------------------
+#
+# Ensures all exported symbols are added to the dynamic symbol table.  This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries.  Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+  # TODO(crbug.com/1052397): Revisit after target_os flip is completed.
+  if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) {
+    ldflags = [ "-rdynamic" ]
+  }
+}
+
+# thin_archive -----------------------------------------------------------------
+#
+# Enables thin archives on posix, and on windows when the lld linker is used.
+# Regular archives directly include the object files used to generate it.
+# Thin archives merely reference the object files.
+# This makes building them faster since it requires less disk IO, but is
+# inappropriate if you wish to redistribute your static library.
+# This config is added to the global config, so thin archives should already be
+# enabled.  If you want to make a distributable static library, you need to do 2
+# things:
+# 1. Set complete_static_lib so that all dependencies of the library make it
+#    into the library. See `gn help complete_static_lib` for details.
+# 2. Remove the thin_archive config, so that the .a file actually contains all
+#    .o files, instead of just references to .o files in the build directoy
+config("thin_archive") {
+  # The macOS and iOS default linker ld64 does not support reading thin
+  # archives.
+  # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
+  # confuses lldb.
+  if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
+    arflags = [ "-T" ]
+  } else if (is_win && use_lld) {
+    arflags = [ "/llvmlibthin" ]
+  }
+}
+
+# exceptions -------------------------------------------------------------------
+#
+# Allows turning Exceptions on or off.
+# Note: exceptions are disallowed in Google code.
+
+config("exceptions") {
+  if (is_win) {
+    # Enables exceptions in the STL.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=1" ]
+    }
+    cflags_cc = [ "/EHsc" ]
+  } else {
+    cflags_cc = [ "-fexceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+config("no_exceptions") {
+  if (is_win) {
+    # Disables exceptions in the STL.
+    # libc++ uses the __has_feature macro to control whether to use exceptions,
+    # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+    # breaks libc++ because it depends on MSVC headers that only provide certain
+    # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use
+    # exceptions, despite being conditional on _HAS_EXCEPTIONS.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=0" ]
+    }
+  } else {
+    cflags_cc = [ "-fno-exceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# Generate a warning for code that might emit a static initializer.
+# See: //docs/static_initializers.md
+# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
+config("wglobal_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wglobal-constructors" ]
+  }
+}
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wexit-time-destructors" ]
+  }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# suppressing the rest of them.  Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+  cflags = []
+  if (is_clang) {
+    cflags += [ "-Wno-incompatible-pointer-types" ]
+  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+    cflags += [ "-w" ]
+  } else if (is_chromeos_ash && current_cpu == "arm") {
+    cflags += [ "-w" ]
+  }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_optimization" ]
+#   configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+  common_optimize_on_cflags = [
+    "/Ob2",  # Both explicit and auto inlining.
+    "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+    "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+  ]
+  if (!is_asan) {
+    common_optimize_on_cflags += [
+      # Put data in separate COMDATs. This allows the linker
+      # to put bit-identical constants at the same address even if
+      # they're unrelated constants, which saves binary size.
+      # This optimization can't be used when ASan is enabled because
+      # it is not compatible with the ASan ODR checker.
+      "/Gw",
+    ]
+  }
+  common_optimize_on_ldflags = []
+
+  # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+  # misleading symbols in stack traces.
+  if (!is_debug && !is_component_build) {
+    common_optimize_on_ldflags += [ "/OPT:ICF" ]  # Redundant COMDAT folding.
+  }
+
+  if (is_official_build) {
+    common_optimize_on_ldflags += [ "/OPT:REF" ]  # Remove unreferenced data.
+    # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
+  }
+} else {
+  common_optimize_on_cflags = []
+  common_optimize_on_ldflags = []
+
+  if (is_android) {
+    # TODO(jdduke) Re-enable on mips after resolving linking
+    # issues with libc++ (crbug.com/456380).
+    if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+      common_optimize_on_ldflags += [
+        # Warn in case of text relocations.
+        "-Wl,--warn-shared-textrel",
+      ]
+    }
+  }
+
+  if (is_apple) {
+    common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+
+    if (is_official_build) {
+      common_optimize_on_ldflags += [
+        "-Wl,-no_data_in_code_info",
+        "-Wl,-no_function_starts",
+      ]
+    }
+  } else if (current_os != "aix" && current_os != "zos") {
+    # Non-Mac Posix flags.
+    # Aix does not support these.
+
+    common_optimize_on_cflags += [
+      # Put data and code in their own sections, so that unused symbols
+      # can be removed at link time with --gc-sections.
+      "-fdata-sections",
+      "-ffunction-sections",
+    ]
+    if ((!is_nacl || is_nacl_saigo) && is_clang) {
+      # We don't care about unique section names, this makes object files a bit
+      # smaller.
+      common_optimize_on_cflags += [ "-fno-unique-section-names" ]
+    }
+
+    common_optimize_on_ldflags += [
+      # Specifically tell the linker to perform optimizations.
+      # See http://lwn.net/Articles/192624/ .
+      # -O2 enables string tail merge optimization in gold and lld.
+      "-Wl,-O2",
+      "-Wl,--gc-sections",
+    ]
+  }
+}
+
+config("default_stack_frames") {
+  if (!is_win) {
+    if (enable_frame_pointers) {
+      cflags = [ "-fno-omit-frame-pointer" ]
+
+      # Omit frame pointers for leaf functions on x86, otherwise building libyuv
+      # gives clang's register allocator issues, see llvm.org/PR15798 /
+      # crbug.com/233709
+      if (is_clang && current_cpu == "x86" && !is_apple) {
+        cflags += [ "-momit-leaf-frame-pointer" ]
+      }
+    } else {
+      cflags = [ "-fomit-frame-pointer" ]
+    }
+  }
+  # On Windows, the flag to enable framepointers "/Oy-" must always come after
+  # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+  # the "optimize" configs, see rest of this file. The ordering that cflags are
+  # applied is well-defined by the GN spec, and there is no way to ensure that
+  # cflags set by "default_stack_frames" is applied after those set by an
+  # "optimize" config. Similarly, there is no way to propagate state from this
+  # config into the "optimize" config. We always apply the "/Oy-" config in the
+  # definition for common_optimize_on_cflags definition, even though this may
+  # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+  if (is_win) {
+    if (chrome_pgo_phase != 2) {
+      # Favor size over speed, /O1 must be before the common flags.
+      # /O1 implies /Os and /GF.
+      cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+      rustflags = [ "-Copt-level=s" ]
+    } else {
+      # PGO requires all translation units to be compiled with /O2. The actual
+      # optimization level will be decided based on the profiling data.
+      cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
+
+      # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
+      # suggests not using an explicit `-Copt-level` at all, and the default is
+      # to optimize for performance like `/O2` for clang.
+      rustflags = []
+    }
+  } else if (optimize_for_size) {
+    # Favor size over speed.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+
+      if (use_ml_inliner && is_a_target_toolchain) {
+        cflags += [
+          "-mllvm",
+          "-enable-ml-inliner=release",
+        ]
+      }
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
+    # vectorization.
+    rustflags = [ "-Copt-level=z" ]
+  } else if (is_chromeos) {
+    # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+    # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+    # any cost" (AKA -Oz). It'd be nice to:
+    # - Make `optimize_for_size` apply to all platforms where we're optimizing
+    #   for size by default (so, also Windows)
+    # - Investigate -Oz here, maybe just for ARM?
+    cflags = [ "-Os" ] + common_optimize_on_cflags
+
+    # Similar to clang, we optimize with `-Copt-level=s` to keep loop
+    # vectorization while otherwise optimizing for size.
+    rustflags = [ "-Copt-level=s" ]
+  } else {
+    cflags = [ "-O2" ] + common_optimize_on_cflags
+
+    # The `-O3` for clang turns on extra optimizations compared to the standard
+    # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
+    # to use.
+    rustflags = [ "-Copt-level=3" ]
+  }
+  ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+  if (is_win) {
+    cflags = [
+      "/Od",  # Disable optimization.
+      "/Ob0",  # Disable all inlining (on by default).
+      "/GF",  # Enable string pooling (off by default).
+    ]
+
+    if (target_cpu == "arm64") {
+      # Disable omitting frame pointers for no_optimize build because stack
+      # traces on Windows ARM64 rely on it.
+      cflags += [ "/Oy-" ]
+    }
+  } else if (is_android && !android_full_debug) {
+    # On Android we kind of optimize some things that don't affect debugging
+    # much even when optimization is disabled to get the binary size down.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    if (!is_component_build) {
+      # Required for library partitions. Without this all symbols just end up
+      # in the base partition.
+      ldflags = [ "-Wl,--gc-sections" ]
+    }
+  } else if (is_fuchsia) {
+    # On Fuchsia, we optimize for size here to reduce the size of debug build
+    # packages so they can be run in a KVM. See crbug.com/910243 for details.
+    cflags = [ "-Og" ]
+  } else {
+    cflags = [ "-O0" ]
+    ldflags = []
+  }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O2" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O3" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+config("optimize_fuzzing") {
+  cflags = [ "-O1" ] + common_optimize_on_cflags
+  rustflags = [ "-Copt-level=1" ]
+  ldflags = common_optimize_on_ldflags
+  visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else if (optimize_for_fuzzing) {
+    assert(!is_win, "Fuzzing optimize level not supported on Windows")
+
+    # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even
+    # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
+    assert(!use_clang_coverage,
+           "optimize_for_fuzzing=true should not be used with " +
+               "use_clang_coverage=true.")
+    configs = [ ":optimize_fuzzing" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
+_clang_sample_profile = ""
+if (is_clang && is_a_target_toolchain) {
+  if (clang_sample_profile_path != "") {
+    _clang_sample_profile = clang_sample_profile_path
+  } else if (clang_use_default_sample_profile) {
+    assert(build_with_chromium,
+           "Our default profiles currently only apply to Chromium")
+    assert(is_android || is_chromeos || is_castos,
+           "The current platform has no default profile")
+    if (is_android || is_castos) {
+      _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+    } else {
+      assert(
+          chromeos_afdo_platform == "atom" ||
+              chromeos_afdo_platform == "bigcore" ||
+              chromeos_afdo_platform == "arm" ||
+              chromeos_afdo_platform == "arm-exp",
+          "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
+      _clang_sample_profile =
+          "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+    }
+  }
+}
+
+# Clang offers a way to assert that AFDO profiles are accurate, which causes it
+# to optimize functions not represented in a profile more aggressively for size.
+# This config can be toggled in cases where shaving off binary size hurts
+# performance too much.
+config("afdo_optimize_size") {
+  if (_clang_sample_profile != "" && sample_profile_is_accurate) {
+    cflags = [ "-fprofile-sample-accurate" ]
+  }
+}
+
+# GCC and clang support a form of profile-guided optimization called AFDO.
+# There are some targeted places that AFDO regresses, so we provide a separate
+# config to allow AFDO to be disabled per-target.
+config("afdo") {
+  if (is_clang) {
+    cflags = []
+    if (clang_emit_debug_info_for_profiling) {
+      # Add the following flags to generate debug info for profiling.
+      cflags += [ "-gline-tables-only" ]
+      if (!is_nacl) {
+        cflags += [ "-fdebug-info-for-profiling" ]
+      }
+    }
+    if (_clang_sample_profile != "") {
+      assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
+      rebased_clang_sample_profile =
+          rebase_path(_clang_sample_profile, root_build_dir)
+      cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+      if (use_profi) {
+        cflags += [ "-fsample-profile-use-profi" ]
+      }
+
+      # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
+      # These seem to be false positives - the complaints are about functions
+      # marked with `__nodebug__` not having associated debuginfo. In the case
+      # where this was observed, the `__nodebug__` function was also marked
+      # `__always_inline__` and had no branches, so AFDO info is likely useless
+      # there.
+      cflags += [ "-Wno-backend-plugin" ]
+      inputs = [ _clang_sample_profile ]
+    }
+  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+    cflags = [ "-fauto-profile=${auto_profile_path}" ]
+    inputs = [ auto_profile_path ]
+  }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_symbols" ]
+#   configs += [ "//build/config/compiler:symbols" ]
+
+# A helper config that all configs passing /DEBUG to the linker should
+# include as sub-config.
+config("win_pdbaltpath") {
+  visibility = [
+    ":minimal_symbols",
+    ":symbols",
+  ]
+
+  # /DEBUG causes the linker to generate a pdb file, and to write the absolute
+  # path to it in the executable file it generates.  This flag turns that
+  # absolute path into just the basename of the pdb file, which helps with
+  # build reproducibility. Debuggers look for pdb files next to executables,
+  # so there's minimal downside to always using this. However, post-mortem
+  # debugging of Chromium crash dumps and ETW tracing can be complicated by this
+  # switch so an option to omit it is important.
+  if (!use_full_pdb_paths) {
+    ldflags = [ "/pdbaltpath:%_PDB%" ]
+  }
+}
+
+# Full symbols.
+config("symbols") {
+  rustflags = []
+  if (is_win) {
+    if (is_clang) {
+      cflags = [
+        # Debug information in the .obj files.
+        "/Z7",
+
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    } else {
+      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.
+    }
+
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = []
+    if (is_mac && enable_dsyms) {
+      # If generating dSYMs, specify -fno-standalone-debug. This was
+      # originally specified for https://crbug.com/479841 because dsymutil
+      # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+      # version 7 also produces debug data that is incompatible with Breakpad
+      # dump_syms, so this is still required (https://crbug.com/622406).
+      cflags += [ "-fno-standalone-debug" ]
+    }
+
+    # On aix -gdwarf causes linker failures due to thread_local variables.
+    if (!is_nacl && current_os != "aix") {
+      if (use_dwarf5) {
+        cflags += [ "-gdwarf-5" ]
+        rustflags += [ "-Zdwarf-version=5" ]
+      } else {
+        # Recent clang versions default to DWARF5 on Linux, and Android is about
+        # to switch. TODO: Adopt that in controlled way. For now, keep DWARF4.
+        # Apple platforms still default to 4 in clang, so they don't need the
+        # cflags.
+        if (!is_apple) {
+          cflags += [ "-gdwarf-4" ]
+        }
+
+        # On Apple, rustc defaults to DWARF2 so it needs to be told how to
+        # match clang.
+        rustflags += [ "-Zdwarf-version=4" ]
+      }
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if ((!is_nacl || is_nacl_saigo) && current_os != "zos") {
+      cflags += [ "-g2" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
+      # to be manually enabled.
+      #
+      # It is skipped in tsan and asan because enabling it causes some
+      # formatting changes in the output which would require fixing bunches
+      # of expectation regexps.
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    if (is_apple) {
+      swiftflags = [ "-g" ]
+    }
+
+    if (use_debug_fission) {
+      cflags += [ "-gsplit-dwarf" ]
+    }
+    asmflags = cflags
+    ldflags = []
+
+    # Split debug info with all thinlto builds except nacl and apple.
+    # thinlto requires -gsplit-dwarf in ldflags.
+    if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) {
+      ldflags += [ "-gsplit-dwarf" ]
+    }
+
+    # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+    # currently we get "warning:
+    # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+    # DWARF info may be corrupt; offsets in a range list entry are in different
+    # sections" there.  Maybe just a bug in nacl_switch_32.S.
+    _enable_gdb_index =
+        symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" &&
+        current_os != "zos" && (use_gold || use_lld) &&
+        # Disable on non-fission 32-bit Android because it pushes
+        # libcomponents_unittests over the 4gb size limit.
+        !(is_android && !use_debug_fission && current_cpu != "x64" &&
+          current_cpu != "arm64")
+    if (_enable_gdb_index) {
+      if (is_clang) {
+        # This flag enables the GNU-format pubnames and pubtypes sections,
+        # which lld needs in order to generate a correct GDB index.
+        # TODO(pcc): Try to make lld understand non-GNU-format pubnames
+        # sections (llvm.org/PR34820).
+        cflags += [ "-ggnu-pubnames" ]
+      }
+      ldflags += [ "-Wl,--gdb-index" ]
+    }
+  }
+
+  configs = []
+
+  # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
+  # https://b/243982712.
+  if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
+      !is_nacl && current_cpu == "arm") {
+    configs += [ "//build/config:compress_debug_sections" ]
+  }
+
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+    if (is_apple) {
+      # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+      # Make sure we don't use constructor homing on mac.
+      cflags += [
+        "-Xclang",
+        "-debug-info-kind=limited",
+      ]
+    } else {
+      # Use constructor homing for debug info. This option reduces debug info
+      # by emitting class type info only when constructors are emitted.
+      cflags += [
+        "-Xclang",
+        "-fuse-ctor-homing",
+      ]
+    }
+  }
+  rustflags += [ "-g" ]
+}
+
+# Minimal symbols.
+# This config guarantees to hold symbol for stack trace which are shown to user
+# when crash happens in unittests running on buildbot.
+config("minimal_symbols") {
+  rustflags = []
+  if (is_win) {
+    # Functions, files, and line tables only.
+    cflags = []
+
+    if (is_clang) {
+      cflags += [
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    }
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+
+    # Enable line tables for clang. MSVC doesn't have an equivalent option.
+    if (is_clang) {
+      # -gline-tables-only is the same as -g1, but clang-cl only exposes the
+      # former.
+      cflags += [ "-gline-tables-only" ]
+    }
+  } else {
+    cflags = []
+    if (is_mac && !use_dwarf5) {
+      # clang defaults to DWARF2 on macOS unless mac_deployment_target is
+      # at least 10.11.
+      # TODO(thakis): Remove this once mac_deployment_target is 10.11.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    } else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
+      # On aix -gdwarf causes linker failures due to thread_local variables.
+      # Recent clang versions default to DWARF5 on Linux, and Android is about
+      # to switch. TODO: Adopt that in controlled way.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    }
+
+    if (use_dwarf5 && !is_nacl) {
+      cflags += [ "-gdwarf-5" ]
+      rustflags += [ "-Zdwarf-version=5" ]
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [ "-g1" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # See comment for -gdwarf-aranges in config("symbols").
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    ldflags = []
+    if (is_android && is_clang) {
+      # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
+      # doesn't emit DW_AT_linkage_name in -g1 builds.
+      # -fdebug-info-for-profiling enables that (and a bunch of other things we
+      # don't need), so that we get qualified names in stacks.
+      # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
+      #               failing that consider doing this on non-Android too.
+      cflags += [ "-fdebug-info-for-profiling" ]
+    }
+
+    asmflags = cflags
+  }
+  rustflags += [ "-Cdebuginfo=1" ]
+}
+
+# This configuration contains function names only. That is, the compiler is
+# told to not generate debug information and the linker then just puts function
+# names in the final debug information.
+config("no_symbols") {
+  if (is_win) {
+    ldflags = [ "/DEBUG" ]
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
+  }
+
+  # This config is removed by base unittests apk.
+  if (is_android && is_clang && strip_debug_info) {
+    configs += [ ":strip_debug" ]
+  }
+}
+
+config("strip_debug") {
+  if (!defined(ldflags)) {
+    ldflags = []
+  }
+  ldflags += [ "-Wl,--strip-debug" ]
+}
+
+if (is_apple) {
+  # On macOS and iOS, this enables support for ARC (automatic reference
+  # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+  #
+  # -fobjc-arc enables ARC overall.
+  #
+  # ARC does not add exception handlers to pure Objective-C code, but does add
+  # them to Objective-C++ code with the rationale that C++ pervasively adds them
+  # in for exception safety. However, exceptions are banned in Chromium code for
+  # C++ and exceptions in Objective-C code are intended to be fatal, so
+  # -fno-objc-arc-exceptions is specified to disable these unwanted exception
+  # handlers.
+  config("enable_arc") {
+    common_flags = [
+      "-fobjc-arc",
+      "-fno-objc-arc-exceptions",
+    ]
+    cflags_objc = common_flags
+    cflags_objcc = common_flags
+  }
+}
+
+if (is_android) {
+  # Use orderfile for linking Chrome on Android.
+  # This config enables using an orderfile for linking in LLD.
+  config("chrome_orderfile_config") {
+    # Don't try to use an orderfile with call graph sorting, except on Android,
+    # where we care about memory used by code, so we still want to mandate
+    # ordering.
+    if (chrome_orderfile_path != "") {
+      assert(use_lld)
+      _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
+      ldflags = [
+        "-Wl,--symbol-ordering-file",
+        "-Wl,$_rebased_orderfile",
+        "-Wl,--no-warn-symbol-ordering",
+      ]
+      inputs = [ chrome_orderfile_path ]
+    }
+  }
+}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+  cflags = []
+  if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+    if (init_stack_vars_zero) {
+      cflags += [ "-ftrivial-auto-var-init=zero" ]
+    } else {
+      cflags += [ "-ftrivial-auto-var-init=pattern" ]
+    }
+  }
+}
+
+buildflag_header("compiler_buildflags") {
+  header = "compiler_buildflags.h"
+
+  flags = [
+    "CLANG_PGO=$chrome_pgo_phase",
+    "SYMBOL_LEVEL=$symbol_level",
+  ]
+}
+
+config("cet_shadow_stack") {
+  if (enable_cet_shadow_stack && is_win) {
+    assert(target_cpu == "x64")
+    ldflags = [ "/CETCOMPAT" ]
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/create.patch.sh	(revision 192)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-119.0.6026.1-target-x86_64.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/src/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/src/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/src/build/config/compiler/BUILD.gn	(revision 192)
@@ -0,0 +1,2933 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/buildflag_header.gni")
+import("//build/config/android/config.gni")
+import("//build/config/c++/c++.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/coverage/coverage.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/host_byteorder.gni")
+import("//build/config/rust.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/rbe.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+  import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el" ||
+    current_cpu == "mips" || current_cpu == "mips64") {
+  import("//build/config/mips.gni")
+}
+if (is_mac) {
+  import("//build/config/apple/symbols.gni")
+}
+if (is_ios) {
+  import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+  # To keep NaCl variables out of builds that don't include NaCl, all
+  # variables defined in nacl/config.gni referenced here should be protected by
+  # is_nacl conditions.
+  import("//build/config/nacl/config.gni")
+}
+
+lld_path = ""
+if (!is_clang) {
+  declare_args() {
+    # This allows overriding the location of lld.
+    lld_path = rebase_path("$clang_base_path/bin", root_build_dir)
+  }
+} else {
+  # clang looks for lld next to it, no need for -B.
+  lld_path = ""
+}
+
+declare_args() {
+  # Normally, Android builds are lightly optimized, even for debug builds, to
+  # keep binary size down. Setting this flag to true disables such optimization
+  android_full_debug = false
+
+  # Compile in such a way as to make it possible for the profiler to unwind full
+  # stack frames. Setting this flag has a large effect on the performance of the
+  # generated code than just setting profiling, but gives the profiler more
+  # information to analyze.
+  # Requires profiling to be set to true.
+  enable_full_stack_frames_for_profiling = false
+
+  # When we are going to use gold we need to find it.
+  # This is initialized below, after use_gold might have been overridden.
+  gold_path = ""
+
+  # Enable fatal linker warnings. Building Chromium with certain versions
+  # of binutils can cause linker warning.
+  fatal_linker_warnings = true
+
+  # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+  # but some sanitizers are known to require it, like CFI diagnostics
+  # and UBsan variants.
+  use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+  # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+  # optimization that GCC supports. It used by ChromeOS in their official
+  # builds. To use it, set auto_profile_path to the path to a file containing
+  # the needed gcov profiling data.
+  auto_profile_path = ""
+
+  # Path to an AFDO profile to use while building with clang, if any. Empty
+  # implies none.
+  clang_sample_profile_path = ""
+
+  # Some configurations have default sample profiles. If this is true and
+  # clang_sample_profile_path is empty, we'll fall back to the default.
+  #
+  # We currently only have default profiles for Chromium in-tree, so we disable
+  # this by default for all downstream projects, since these profiles are likely
+  # nonsensical for said projects.
+  clang_use_default_sample_profile =
+      chrome_pgo_phase == 0 && build_with_chromium && is_official_build &&
+      (is_android || chromeos_is_browser_only)
+
+  # This configuration is used to select a default profile in Chrome OS based on
+  # the microarchitectures we are using. This is only used if
+  # clang_use_default_sample_profile is true and clang_sample_profile_path is
+  # empty.
+  chromeos_afdo_platform = "atom"
+
+  # Emit debug information for profiling wile building with clang.
+  # Only enable this for ChromeOS official builds for AFDO.
+  clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
+
+  # Turn this on to have the compiler output extra timing information.
+  compiler_timing = false
+
+  # Turn this on to use ghash feature of lld for faster debug link on Windows.
+  # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
+  use_ghash = true
+
+  # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on
+  # can substantially increase link time and binary size, but they generally
+  # also make binaries a fair bit faster.
+  #
+  # TODO(gbiv): We disable optimizations by default on most platforms because
+  # the space overhead is too great. We should use some mixture of profiles and
+  # optimization settings to better tune the size increase.
+  thin_lto_enable_optimizations =
+      (is_chromeos || is_android || is_win || is_linux || is_mac ||
+       (is_ios && use_lld)) && is_official_build
+
+  # Initialize all local variables with a pattern. This flag will fill
+  # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
+  # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
+  # recognizable in the debugger, and crashes on memory accesses through
+  # uninitialized pointers.
+  #
+  # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and
+  # needs to be evaluated before enabling it there as well.
+  init_stack_vars = !(is_android && is_official_build)
+
+  # Zero init has favorable performance/size tradeoffs for Chrome OS
+  # but was not evaluated for other platforms.
+  init_stack_vars_zero = is_chromeos
+
+  # This argument is to control whether enabling text section splitting in the
+  # final binary. When enabled, the separated text sections with prefix
+  # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be
+  # merged to '.text' section. This allows us to identify the hot code section
+  # ('.text.hot') in the binary, which allows our data collection pipelines to
+  # more easily identify code that we assume to be hot/cold that doesn't turn
+  # out to be such in the field.
+  use_text_section_splitting = is_chromeos
+
+  # Enable DWARF v5.
+  use_dwarf5 = false
+
+  # Override this to put full paths to PDBs in Windows PE files. This helps
+  # windbg and Windows Performance Analyzer with finding the PDBs in some local-
+  # build scenarios. This is never needed for bots or official builds. Because
+  # this puts the output directory in the DLLs/EXEs it breaks build determinism.
+  # Bugs have been reported to the windbg/WPA teams and this workaround will be
+  # removed when they are fixed.
+  use_full_pdb_paths = false
+
+  # Enable -H, which prints the include tree during compilation.
+  # For use by tools/clang/scripts/analyze_includes.py
+  show_includes = false
+
+  # Enable Profi algorithm. Profi can infer block and edge counts.
+  # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
+  # TODO(crbug.com/1375958i:) Possibly enable this for Android too.
+  use_profi = is_chromeos
+
+  # If true, linker crashes will be rerun with `--reproduce` which causes
+  # a reproducer file to be saved.
+  save_reproducers_on_lld_crash = false
+
+  # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
+  # shadow call stack in register x18. Hence, x18 must not be used by the OS
+  # or libraries. We assume that to be the case for high end Android
+  # configurations. For more details see
+  # https://clang.llvm.org/docs/ShadowCallStack.html
+  enable_shadow_call_stack = false
+
+  # Use DWARF simple template names, with the following exceptions:
+  #
+  # * Windows is not supported as it doesn't use DWARF.
+  # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
+  #   lldb doesn't have the needed changes yet.
+  # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
+  #
+  # This greatly reduces the size of debug builds, at the cost of
+  # debugging information which is required by some specialized
+  # debugging tools.
+  simple_template_names = is_clang && !is_nacl && !is_win && !is_apple
+}
+
+declare_args() {
+  # Set to true to use icf, Identical Code Folding.
+  #
+  # icf=all is broken in older golds, see
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+  # chromeos binutils has been patched with the fix, so always use icf there.
+  # The bug only affects x86 and x64, so we can still use ICF when targeting
+  # other architectures.
+  #
+  # lld doesn't have the bug.
+  use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer &&
+            !use_clang_coverage && current_os != "zos" &&
+            !(is_android && use_order_profiling) &&
+            (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" ||
+                                                       current_cpu == "x64"))))
+}
+
+if (is_android) {
+  # Set the path to use orderfile for linking Chrome
+  # Note that this is for using only one orderfile for linking
+  # the Chrome binary/library.
+  declare_args() {
+    chrome_orderfile_path = ""
+
+    if (defined(default_chrome_orderfile)) {
+      # Allow downstream tools to set orderfile path with
+      # another variable.
+      chrome_orderfile_path = default_chrome_orderfile
+    }
+  }
+}
+
+declare_args() {
+  # Turn off the --call-graph-profile-sort flag for lld by default. Enable
+  # selectively for targets where it's beneficial.
+  enable_call_graph_profile_sort =
+      chrome_pgo_phase == 2 ||
+      (is_chromeos &&
+       (clang_use_default_sample_profile || clang_sample_profile_path != ""))
+}
+
+assert(!(llvm_force_head_revision && use_goma),
+       "can't use goma with trunk clang")
+assert(!(llvm_force_head_revision && use_remoteexec),
+       "can't use rbe with trunk clang")
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+  include_dirs = [
+    "//",
+    root_gen_dir,
+  ]
+}
+
+# Compiler instrumentation can introduce dependencies in DSOs to symbols in
+# the executable they are loaded into, so they are unresolved at link-time.
+config("no_unresolved_symbols") {
+  if (!using_sanitizer &&
+      (is_linux || is_chromeos || is_android || is_fuchsia)) {
+    ldflags = [
+      "-Wl,-z,defs",
+      "-Wl,--as-needed",
+    ]
+  }
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  cflags_objc = []
+  cflags_objcc = []
+  rustflags = []
+  ldflags = []
+  defines = []
+  configs = []
+  rustflags = []
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:compiler" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:compiler" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:compiler" ]
+  } else if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:compiler" ]
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:compiler" ]
+  } else if (is_fuchsia) {
+    configs += [ "//build/config/fuchsia:compiler" ]
+  } else if (current_os == "aix") {
+    configs += [ "//build/config/aix:compiler" ]
+  } else if (current_os == "zos") {
+    configs += [ "//build/config/zos:compiler" ]
+  }
+
+  configs += [
+    # See the definitions below.
+    ":clang_revision",
+    ":rustc_revision",
+    ":compiler_cpu_abi",
+    ":compiler_codegen",
+    ":compiler_deterministic",
+  ]
+
+  # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
+  # operations (e.g. dereferencing) into defined behavior. This avoids deletion
+  # of some security-critical code: see https://crbug.com/1139129.
+  # Nacl does not support the flag. And, we still want UBSAN to catch undefined
+  # behavior related to nullptrs, so do not add this flag if UBSAN is enabled.
+  # GCC seems to have some bugs compiling constexpr code when this is defined,
+  # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
+  # TODO(mpdenton): remove is_clang once GCC bug is fixed.
+  if (!is_nacl && !is_ubsan && is_clang) {
+    cflags += [ "-fno-delete-null-pointer-checks" ]
+  }
+
+  # Don't emit the GCC version ident directives, they just end up in the
+  # .comment section or debug info taking up binary size, and makes comparing
+  # .o files built with different compiler versions harder.
+  if (!is_win || is_clang) {
+    cflags += [ "-fno-ident" ]
+  }
+
+  # In general, Windows is totally different, but all the other builds share
+  # some common compiler and linker configuration.
+  if (!is_win) {
+    # Common POSIX compiler flags setup.
+    # --------------------------------
+    cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204
+
+    # Stack protection. ShadowCallStack and Stack protector address the same
+    # problems. Therefore, we only enable one or the other. Clang advertises SCS as
+    # a stronger alternative to StackProtector, so we give SCS precedence over SP.
+    if (enable_shadow_call_stack) {
+      # On Aarch64, SCS requires the x18 register to be unused because it will hold
+      # a pointer to the shadow stack. For Android we know that Clang doesn't use
+      # x18 by default. On other OSs adding "-ffixed-x18" might be required.
+      assert(is_android)
+
+      scs_parameters = [
+        "-fsanitize=shadow-call-stack",
+        "-fno-stack-protector",
+      ]
+      cflags += scs_parameters
+      ldflags += scs_parameters
+    } else {
+      if (is_apple) {
+        # The strong variant of the stack protector significantly increases
+        # binary size, so only enable it in debug mode.
+        if (is_debug) {
+          cflags += [ "-fstack-protector-strong" ]
+        } else {
+          cflags += [ "-fstack-protector" ]
+        }
+      } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
+        # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+        # See also https://crbug.com/533294
+        # The x86 toolchain currently has problems with stack-protector.
+        if (is_android && current_cpu == "x86") {
+          cflags += [ "-fno-stack-protector" ]
+        } else if (current_os != "aix") {
+          # Not available on aix.
+          cflags += [ "-fstack-protector" ]
+        }
+      }
+    }
+
+    if (use_lld) {
+      ldflags += [ "-fuse-ld=lld" ]
+      if (lld_path != "") {
+        ldflags += [ "-B$lld_path" ]
+      }
+    }
+
+    # Linker warnings.
+    if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
+        current_os != "zos") {
+      ldflags += [ "-Wl,--fatal-warnings" ]
+    }
+    if (fatal_linker_warnings && is_apple) {
+      ldflags += [ "-Wl,-fatal_warnings" ]
+    }
+  }
+
+  if (is_clang && is_debug) {
+    # Allow comparing the address of references and 'this' against 0
+    # in debug builds. Technically, these can never be null in
+    # well-defined C/C++ and Clang can optimize such checks away in
+    # release builds, but they may be used in asserts in debug builds.
+    cflags_cc += [
+      "-Wno-undefined-bool-conversion",
+      "-Wno-tautological-undefined-compare",
+    ]
+  }
+
+  # Non-Apple Posix and Fuchsia compiler flags setup.
+  # -----------------------------------
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    if (enable_profiling) {
+      if (!is_debug) {
+        cflags += [ "-g" ]
+
+        if (enable_full_stack_frames_for_profiling) {
+          cflags += [
+            "-fno-inline",
+            "-fno-optimize-sibling-calls",
+          ]
+        }
+      }
+    }
+
+    # Explicitly pass --build-id to ld. Compilers used to always pass this
+    # implicitly but don't any more (in particular clang when built without
+    # ENABLE_LINKER_BUILD_ID=ON).
+    if (is_official_build) {
+      # The sha1 build id has lower risk of collision but is more expensive to
+      # compute, so only use it in the official build to avoid slowing down
+      # links.
+      ldflags += [ "-Wl,--build-id=sha1" ]
+    } else if (current_os != "aix" && current_os != "zos") {
+      ldflags += [ "-Wl,--build-id" ]
+    }
+
+    if (!is_android) {
+      defines += [
+        # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
+        # the behavior of the Android NDK from earlier versions.
+        # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
+        "_FILE_OFFSET_BITS=64",
+        "_LARGEFILE_SOURCE",
+        "_LARGEFILE64_SOURCE",
+      ]
+    }
+
+    if (!is_nacl) {
+      if (exclude_unwind_tables) {
+        cflags += [
+          "-fno-unwind-tables",
+          "-fno-asynchronous-unwind-tables",
+        ]
+        rustflags += [ "-Cforce-unwind-tables=no" ]
+        defines += [ "NO_UNWIND_TABLES" ]
+      } else {
+        cflags += [ "-funwind-tables" ]
+        rustflags += [ "-Cforce-unwind-tables=yes" ]
+      }
+    }
+  }
+
+  # Apple compiler flags setup.
+  # ---------------------------------
+  if (is_apple) {
+    # On Intel, clang emits both Apple's "compact unwind" information and
+    # DWARF eh_frame unwind information by default, for compatibility reasons.
+    # This flag limits emission of eh_frame information to functions
+    # whose unwind information can't be expressed in the compact unwind format
+    # (which in practice means almost everything gets only compact unwind
+    # entries). This reduces object file size a bit and makes linking a bit
+    # faster.
+    # On arm64, this is already the default behavior.
+    if (current_cpu == "x64") {
+      asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+      cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+    }
+  }
+
+  # Linux/Android/Fuchsia common flags setup.
+  # ---------------------------------
+  if (is_linux || is_chromeos || is_android || is_fuchsia) {
+    asmflags += [ "-fPIC" ]
+    cflags += [ "-fPIC" ]
+    ldflags += [ "-fPIC" ]
+    rustflags += [ "-Crelocation-model=pic" ]
+
+    if (!is_clang) {
+      # Use pipes for communicating between sub-processes. Faster.
+      # (This flag doesn't do anything with Clang.)
+      cflags += [ "-pipe" ]
+    }
+
+    ldflags += [
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+    ]
+
+    if (!is_component_build) {
+      ldflags += [ "-Wl,-z,now" ]
+    }
+  }
+
+  # Linux-specific compiler flags setup.
+  # ------------------------------------
+  if (use_gold) {
+    ldflags += [ "-fuse-ld=gold" ]
+    if (!is_android) {
+      # On Android, this isn't needed.  gcc in the NDK knows to look next to
+      # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+      # above.
+      if (gold_path != "") {
+        ldflags += [ "-B$gold_path" ]
+      }
+
+      ldflags += [
+        # Experimentation found that using four linking threads
+        # saved ~20% of link time.
+        # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+        # Only apply this to the target linker, since the host
+        # linker might not be gold, but isn't used much anyway.
+        "-Wl,--threads",
+        "-Wl,--thread-count=4",
+      ]
+    }
+
+    # TODO(thestig): Make this flag work with GN.
+    #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+    #  ldflags += [
+    #    "-Wl,--detect-odr-violations",
+    #  ]
+    #}
+  }
+
+  if (use_icf && (!is_apple || use_lld)) {
+    ldflags += [ "-Wl,--icf=all" ]
+  }
+
+  if (is_linux || is_chromeos) {
+    cflags += [ "-pthread" ]
+    # Do not use the -pthread ldflag here since it becomes a no-op
+    # when using -nodefaultlibs, which would cause an unused argument
+    # error.  "-lpthread" is added in //build/config:default_libs.
+  }
+
+  # Clang-specific compiler flags setup.
+  # ------------------------------------
+  if (is_clang) {
+    cflags += [ "-fcolor-diagnostics" ]
+
+    # Enable -fmerge-all-constants. This used to be the default in clang
+    # for over a decade. It makes clang non-conforming, but is fairly safe
+    # in practice and saves some binary size. We might want to consider
+    # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13),
+    # but for now it looks like our build might rely on it
+    # (https://crbug.com/829795).
+    cflags += [ "-fmerge-all-constants" ]
+  }
+
+  if (use_lld) {
+    # TODO(thakis): Make the driver pass --color-diagnostics to the linker
+    # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
+    # in ldflags instead.
+    if (is_win) {
+      # On Windows, we call the linker directly, instead of calling it through
+      # the driver.
+      ldflags += [ "--color-diagnostics" ]
+    } else {
+      ldflags += [ "-Wl,--color-diagnostics" ]
+    }
+  }
+
+  # Enable text section splitting only on linux when using lld for now. Other
+  # platforms can be added later if needed.
+  if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) {
+    ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
+  }
+
+  if (is_clang && !is_nacl && current_os != "zos") {
+    cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
+    if (save_reproducers_on_lld_crash && use_lld) {
+      ldflags += [
+        "-fcrash-diagnostics=all",
+        "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
+      ]
+    }
+
+    # TODO(hans): Remove this once Clang generates better optimized debug info
+    # by default. https://crbug.com/765793
+    cflags += [
+      "-mllvm",
+      "-instcombine-lower-dbg-declare=0",
+    ]
+    if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+      if (is_win) {
+        ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
+      } else {
+        ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
+      }
+    }
+
+    # TODO(crbug.com/1235145): Investigate why/if this should be needed.
+    if (is_win) {
+      cflags += [ "/clang:-ffp-contract=off" ]
+    } else {
+      cflags += [ "-ffp-contract=off" ]
+    }
+  }
+
+  # C11/C++11 compiler flags setup.
+  # ---------------------------
+  if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
+      current_os == "aix") {
+    if (is_clang) {
+      standard_prefix = "c"
+
+      # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
+      # defined by the compiler.  However, lots of code relies on the
+      # non-standard features that _GNU_SOURCE enables, so define it manually.
+      defines += [ "_GNU_SOURCE" ]
+
+      if (is_nacl) {
+        # Undefine __STRICT_ANSI__ to get non-standard features which would
+        # otherwise not be enabled by NaCl's sysroots.
+        cflags += [ "-U__STRICT_ANSI__" ]
+      }
+    } else {
+      # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
+      # but we use this feature in several places in Chromium.
+      # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the
+      # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
+      # to -std=c*.
+      standard_prefix = "gnu"
+    }
+
+    cflags_c += [ "-std=${standard_prefix}11" ]
+    if (is_nacl && !is_nacl_saigo) {
+      # This is for the pnacl_newlib toolchain. It's only used to build
+      # a few independent ppapi test files that don't pull in any other
+      # dependencies.
+      cflags_cc += [ "-std=${standard_prefix}++14" ]
+      if (is_clang) {
+        cflags_cc += [ "-fno-trigraphs" ]
+      }
+    } else if (is_clang) {
+      if (defined(use_cxx17) && use_cxx17) {
+        cflags_cc += [ "-std=${standard_prefix}++17" ]
+      } else {
+        cflags_cc += [ "-std=${standard_prefix}++20" ]
+      }
+    } else {
+      # The gcc bots are currently using GCC 9, which is not new enough to
+      # support "c++20"/"gnu++20".
+      cflags_cc += [ "-std=${standard_prefix}++2a" ]
+    }
+  } else if (is_win) {
+    cflags_c += [ "/std:c11" ]
+    if ((defined(use_cxx17) && use_cxx17) ||
+        (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) {
+      cflags_cc += [ "/std:c++17" ]
+    } else {
+      cflags_cc += [ "/std:c++20" ]
+    }
+  } else if (!is_nacl) {
+    # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
+    # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
+    # more, but there are still a few buildbots using it, so until those are
+    # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
+    # clause, above.
+    cflags_c += [ "-std=c11" ]
+
+    if (defined(use_cxx17) && use_cxx17) {
+      cflags_cc += [ "-std=c++17" ]
+    } else {
+      cflags_cc += [ "-std=c++20" ]
+    }
+  }
+
+  if (is_clang && current_os != "zos") {
+    # C++17 removes trigraph support, but clang still warns that it ignores
+    # them when seeing them.  Don't.
+    cflags_cc += [ "-Wno-trigraphs" ]
+  }
+
+  if (use_relative_vtables_abi) {
+    cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
+    ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
+  }
+
+  # Add flags for link-time optimization. These flags enable
+  # optimizations/transformations that require whole-program visibility at link
+  # time, so they need to be applied to all translation units, and we may end up
+  # with miscompiles if only part of the program is compiled with LTO flags. For
+  # that reason, we cannot allow targets to enable or disable these flags, for
+  # example by disabling the optimize configuration.
+  # TODO(pcc): Make this conditional on is_official_build rather than on gn
+  # flags for specific features.
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    assert(use_lld, "LTO is only supported with lld")
+
+    cflags += [
+      "-flto=thin",
+      "-fsplit-lto-unit",
+    ]
+
+    # Limit the size of the ThinLTO cache to the lesser of 10% of
+    # available disk space, 40GB and 100000 files.
+    cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000"
+
+    # An import limit of 30 has better performance (per speedometer) and lower
+    # binary size than the default setting of 100.
+    # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
+    # should be able to better manage binary size increases on its own.
+    import_instr_limit = 30
+
+    if (is_win) {
+      ldflags += [
+        "/opt:lldltojobs=all",
+        "-mllvm:-import-instr-limit=$import_instr_limit",
+        "/lldltocache:" +
+            rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+        "/lldltocachepolicy:$cache_policy",
+        "-mllvm:-disable-auto-upgrade-debug-info",
+      ]
+    } else {
+      ldflags += [ "-flto=thin" ]
+
+      # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory
+      # usage in crbug.com/1038040. Note this will increase build time in
+      # Chrome OS.
+
+      # In ThinLTO builds, we run at most one link process at a time,
+      # and let it use all cores.
+      # TODO(thakis): Check if '=0' (that is, number of cores, instead
+      # of "all" which means number of hardware threads) is faster.
+      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_apple) {
+        ldflags += [
+          "-Wl,-cache_path_lto," +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+          "-Wcrl,object_path_lto",
+        ]
+      } else {
+        ldflags +=
+            [ "-Wl,--thinlto-cache-dir=" +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ]
+      }
+
+      ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+
+      if (is_chromeos) {
+        # ARM was originally set lower than x86 to keep the size
+        # bloat of ThinLTO to <10%, but that's potentially no longer true.
+        # FIXME(inglorion): maybe tune these?
+        # TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
+        import_instr_limit = 20
+      } else if (is_android) {
+        # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win
+        # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB.
+        import_instr_limit = 5
+      }
+
+      ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
+
+      if (!is_chromeos) {
+        # TODO(https://crbug.com/972449): turn on for ChromeOS when that
+        # toolchain has this flag.
+        # We only use one version of LLVM within a build so there's no need to
+        # upgrade debug info, which can be expensive since it runs the verifier.
+        ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
+      }
+    }
+
+    # TODO(https://crbug.com/1211155): investigate why this isn't effective on
+    # arm32.
+    if (!is_android || current_cpu == "arm64") {
+      cflags += [ "-fwhole-program-vtables" ]
+
+      if (toolchain_supports_rust_thin_lto) {
+        # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
+        # behaviour. Rust needs to know the linker will be doing LTO in this case
+        # or it rejects the Zsplit-lto-unit flag.
+        rustflags += [
+          "-Zsplit-lto-unit",
+          "-Clinker-plugin-lto=yes",
+        ]
+      } else {
+        # Don't include bitcode if it won't be used.
+        rustflags += [ "-Cembed-bitcode=no" ]
+      }
+
+      if (!is_win) {
+        ldflags += [ "-fwhole-program-vtables" ]
+      }
+    }
+
+    # This flag causes LTO to create an .ARM.attributes section with the correct
+    # architecture. This is necessary because LLD will refuse to link a program
+    # unless the architecture revision in .ARM.attributes is sufficiently new.
+    # TODO(pcc): The contents of .ARM.attributes should be based on the
+    # -march flag passed at compile time (see llvm.org/pr36291).
+    if (current_cpu == "arm") {
+      ldflags += [ "-march=$arm_arch" ]
+    }
+  }
+
+  if (compiler_timing) {
+    if (is_clang && !is_nacl) {
+      cflags += [ "-ftime-trace" ]
+    } else if (is_win) {
+      cflags += [
+        # "Documented" here:
+        # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
+        "/d2cgsummary",
+      ]
+    }
+  }
+
+  # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize
+  # stack crashes (http://crbug.com/919499).
+  if (use_lld && is_android) {
+    ldflags += [ "-Wl,--no-rosegment" ]
+  }
+
+  # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+  # --no-undefined-version.
+  if (use_lld && !is_win && !is_mac && !is_ios) {
+    ldflags += [ "-Wl,--undefined-version" ]
+  }
+
+  if (use_lld && is_apple) {
+    ldflags += [ "-Wl,--strict-auto-link" ]
+  }
+
+  # LLD does call-graph-sorted binary layout by default when profile data is
+  # present. On Android this increases binary size due to more thinks for long
+  # jumps. Turn it off by default and enable selectively for targets where it's
+  # beneficial.
+  if (use_lld && !enable_call_graph_profile_sort) {
+    if (is_win) {
+      ldflags += [ "/call-graph-profile-sort:no" ]
+    } else {
+      ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
+    }
+  }
+
+  if (is_clang && !is_nacl && show_includes) {
+    if (is_win) {
+      # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
+      assert(!use_goma, "show_includes on Windows is not reliable with goma")
+      cflags += [
+        "/clang:-H",
+        "/clang:-fshow-skipped-includes",
+      ]
+    } else {
+      cflags += [
+        "-H",
+        "-fshow-skipped-includes",
+      ]
+    }
+  }
+
+  # This flag enforces that member pointer base types are complete. It helps
+  # prevent us from running into problems in the Microsoft C++ ABI (see
+  # https://crbug.com/847724).
+  if (is_clang && !is_nacl && target_os != "chromeos" &&
+      (is_win || use_custom_libcxx)) {
+    cflags += [ "-fcomplete-member-pointers" ]
+  }
+
+  # Use DWARF simple template names.
+  if (simple_template_names) {
+    cflags_cc += [ "-gsimple-template-names" ]
+  }
+
+  # MLGO specific flags. These flags enable an ML-based inliner trained on
+  # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
+  # The "release" ML model is embedded into clang as part of its build.
+  # Currently, the ML inliner is only enabled when targeting Android due to:
+  # a) Android is where size matters the most.
+  # b) MLGO presently has the limitation of only being able to embed one model
+  #    at a time; It is unclear if the embedded model is beneficial for
+  #    non-Android targets.
+  # MLGO is only officially supported on linux.
+  if (use_ml_inliner && is_a_target_toolchain) {
+    assert(
+        is_android && host_os == "linux",
+        "MLGO is currently only supported for targeting Android on a linux host")
+    if (use_thin_lto) {
+      ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
+    }
+  }
+
+  if (clang_embed_bitcode) {
+    assert(!use_thin_lto,
+           "clang_embed_bitcode is only supported in non-ThinLTO builds")
+    cflags += [
+      "-Xclang",
+      "-fembed-bitcode=all",
+    ]
+  }
+
+  if (lld_emit_indexes_and_imports) {
+    assert(use_thin_lto,
+           "lld_emit_indexes_and_imports is only supported with ThinLTO builds")
+    ldflags += [
+      "-Wl,--save-temps=import",
+      "-Wl,--thinlto-emit-index-files",
+    ]
+  }
+
+  # Pass the same C/C++ flags to the objective C/C++ compiler.
+  cflags_objc += cflags_c
+  cflags_objcc += cflags_cc
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler. The Windows assembler takes different types of flags
+  # so only do so for posix platforms.
+  if (is_posix || is_fuchsia) {
+    asmflags += cflags
+    asmflags += cflags_c
+  }
+
+  if (is_chromeos_device && !is_nacl) {
+    # On ChromeOS devices, we want to ensure we're using Chrome's allocator
+    # symbols for all C++ new/delete operator overloads. PartitionAlloc
+    # and other local allocators should always take precedence over system or
+    # preloaded allocators. These are the mangled symbol names.
+    # See b/280115910 for details.
+    ldflags += [
+      "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
+      "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
+      "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
+      "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
+      "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
+      "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
+    ]
+  }
+
+  # Rust compiler flags setup.
+  # ---------------------------
+  rustflags += [
+    # Overflow checks are optional in Rust, but even if switched
+    # off they do not cause undefined behavior (the overflowing
+    # behavior is defined). Because containers are bounds-checked
+    # in safe Rust, they also can't provoke buffer overflows.
+    # As such these checks may be less important in Rust than C++.
+    # But in (simplistic) testing they have negligible performance
+    # overhead, and this helps to provide consistent behavior
+    # between different configurations, so we'll keep them on until
+    # we discover a reason to turn them off.
+    "-Coverflow-checks=on",
+
+    # By default Rust passes `-nodefaultlibs` to the linker, however this
+    # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
+    # is then unused and produces a warning/error. So this removes the
+    # `-nodefaultlibs` from the linker invocation from Rust, which would be used
+    # to compile dylibs on Android, such as for constructing unit test APKs.
+    "-Cdefault-linker-libraries",
+
+    # To make Rust .d files compatible with ninja
+    "-Zdep-info-omit-d-target",
+
+    # If a macro panics during compilation, show which macro and where it is
+    # defined.
+    "-Zmacro-backtrace",
+
+    # For deterministic builds, keep the local machine's current working
+    # directory from appearing in build outputs.
+    "-Zremap-cwd-prefix=.",
+  ]
+
+  if (!is_win || force_rustc_color_output) {
+    # Colorize error output. The analogous flag is passed for clang. This must
+    # be platform-gated since rustc will unconditionally output ANSI escape
+    # sequences, ignoring the platform, when stderr is not a terminal.
+    rustflags += [ "--color=always" ]
+  }
+  if (rust_abi_target != "") {
+    rustflags += [ "--target=$rust_abi_target" ]
+  }
+  if (!use_thin_lto) {
+    # Don't include bitcode if it won't be used.
+    rustflags += [ "-Cembed-bitcode=no" ]
+  }
+  if (is_official_build) {
+    rustflags += [ "-Ccodegen-units=1" ]
+  }
+  if (!rust_prebuilt_stdlib) {
+    # When building against the Chromium Rust stdlib (which we compile) always
+    # abort instead of unwinding when panic occurs. In official builds, panics
+    # abort immediately (this is configured in the stdlib) to keep binary size
+    # down. So we unconditionally match behaviour in unofficial too.
+    rustflags += [
+      "-Cpanic=abort",
+      "-Zpanic_abort_tests",
+    ]
+  }
+
+  # Normally, this would be defined in the `runtime_library` config but NaCl
+  # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there
+  # isn't really a better config to add this define for the define to
+  # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
+  # and NaCl code.
+  #
+  # TODO(https://crbug.com/702997): Move this back to the `runtime_library`
+  # config when NaCl is removed.
+  if (use_safe_libcxx) {
+    # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once
+    # it's rolled in.
+    if (is_nacl_saigo) {
+      defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
+    } else {
+      defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ]
+    }
+  }
+}
+
+# The BUILDCONFIG file sets this config on targets by default, which means when
+# building with ThinLTO, no optimization is performed in the link step.
+config("thinlto_optimize_default") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    lto_opt_level = 0
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# Use this to enable optimization in the ThinLTO link step for select targets
+# when thin_lto_enable_optimizations is set by doing:
+#
+#   configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
+#   configs += [ "//build/config/compiler:thinlto_optimize_max" ]
+#
+# Since it makes linking significantly slower and more resource intensive, only
+# use it on important targets such as the main browser executable or dll.
+config("thinlto_optimize_max") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    if (thin_lto_enable_optimizations) {
+      lto_opt_level = 2
+    } else {
+      lto_opt_level = 0
+    }
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+  defines = []
+
+  configs = []
+  if (is_chromeos) {
+    configs += [ "//build/config/chromeos:compiler_cpu_abi" ]
+  }
+
+  # TODO(https://crbug.com/1383873): Remove this once figured out.
+  if (is_apple && current_cpu == "arm64") {
+    cflags += [ "-fno-global-isel" ]
+    ldflags += [ "-fno-global-isel" ]
+  }
+
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "--target=@X64_TARGET@",
+        "-m64",
+        "-msse3",
+      ]
+      ldflags += [ "-m64", "--target=@X64_TARGET@" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+      if (!is_nacl) {
+        cflags += [
+          "-mfpmath=sse",
+          "-msse3",
+        ]
+      }
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=arm-linux-gnueabihf" ]
+        ldflags += [ "--target=arm-linux-gnueabihf" ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "arm64") {
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=aarch64-linux-gnu" ]
+        ldflags += [ "--target=aarch64-linux-gnu" ]
+      }
+    } else if (current_cpu == "mipsel" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mipsel-linux-android" ]
+            ldflags += [ "--target=mipsel-linux-android" ]
+          } else {
+            cflags += [ "--target=mipsel-linux-gnu" ]
+            ldflags += [ "--target=mipsel-linux-gnu" ]
+          }
+        } else {
+          cflags += [ "-EL" ]
+          ldflags += [ "-EL" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [ "-mno-odd-spreg" ]
+        ldflags += [ "-mips32r6" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r6",
+          ]
+        } else {
+          cflags += [
+            "-mips32r6",
+            "-Wa,-mips32r6",
+          ]
+          if (is_android) {
+            ldflags += [ "-Wl,-melf32ltsmip" ]
+          }
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips32r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r2",
+          ]
+        } else {
+          cflags += [
+            "-mips32r2",
+            "-Wa,-mips32r2",
+          ]
+          if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+            cflags += [ "-m$mips_fpu_mode" ]
+          }
+        }
+      } else if (mips_arch_variant == "r1") {
+        ldflags += [ "-mips32" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32",
+          ]
+        } else {
+          cflags += [
+            "-mips32",
+            "-Wa,-mips32",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips-linux-gnu" ]
+          ldflags += [ "--target=mips-linux-gnu" ]
+        } else {
+          cflags += [ "-EB" ]
+          ldflags += [ "-EB" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mips64el-linux-android" ]
+            ldflags += [ "--target=mips64el-linux-android" ]
+          } else {
+            cflags += [ "--target=mips64el-linux-gnuabi64" ]
+            ldflags += [ "--target=mips64el-linux-gnuabi64" ]
+          }
+        } else {
+          cflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r6",
+          ]
+        } else {
+          cflags += [
+            "-mips64r6",
+            "-Wa,-mips64r6",
+          ]
+          ldflags += [ "-mips64r6" ]
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips64r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r2",
+          ]
+        } else {
+          cflags += [
+            "-mips64r2",
+            "-Wa,-mips64r2",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+    } else if (current_cpu == "mips64") {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips64-linux-gnuabi64" ]
+          ldflags += [ "--target=mips64-linux-gnuabi64" ]
+        } else {
+          cflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    } else if (current_cpu == "ppc64") {
+      if (current_os == "aix") {
+        cflags += [ "-maix64" ]
+        ldflags += [ "-maix64" ]
+      } else {
+        cflags += [ "-m64" ]
+        ldflags += [ "-m64" ]
+      }
+    } else if (current_cpu == "riscv64") {
+      if (is_clang && !is_android) {
+        cflags += [ "--target=riscv64-linux-gnu" ]
+        ldflags += [ "--target=riscv64-linux-gnu" ]
+      }
+      cflags += [ "-mabi=lp64d" ]
+    } else if (current_cpu == "loong64") {
+      if (is_clang) {
+        cflags += [ "--target=loongarch64-linux-gnu" ]
+        ldflags += [ "--target=loongarch64-linux-gnu" ]
+      }
+      cflags += [
+        "-mabi=lp64d",
+        "-mcmodel=medium",
+      ]
+    } else if (current_cpu == "s390x") {
+      cflags += [ "-m64" ]
+      ldflags += [ "-m64" ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+  configs = []
+  cflags = []
+  ldflags = []
+
+  if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler_codegen" ]
+  }
+
+  if (current_cpu == "arm64" && !is_win && is_clang) {
+    # Disable outlining everywhere on arm64 except Win. For more information see
+    # crbug.com/931297 for Android and crbug.com/1410297 for iOS.
+    # TODO(crbug.com/1411363): Enable this on Windows if possible.
+    cflags += [ "-mno-outline" ]
+
+    # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
+    # has been resolved, and -mno-outline is obeyed by the linker during
+    # ThinLTO.
+    ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
+  }
+
+  asmflags = cflags
+}
+
+# This provides options that make the build deterministic, so that the same
+# revision produces the same output, independent of the name of the build
+# directory and of the computer the build is done on.
+# The relative path from build dir to source dir makes it into the build
+# outputs, so it's recommended that you use a build dir two levels deep
+# (e.g. "out/Release") so that you get the same "../.." path as all the bots
+# in your build outputs.
+config("compiler_deterministic") {
+  cflags = []
+  ldflags = []
+  swiftflags = []
+
+  # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+  # deterministic build.  See https://crbug.com/314403
+  if (!is_official_build) {
+    if (is_win && !is_clang) {
+      cflags += [
+        "/wd4117",  # Trying to define or undefine a predefined macro.
+        "/D__DATE__=",
+        "/D__TIME__=",
+        "/D__TIMESTAMP__=",
+      ]
+    } else {
+      cflags += [
+        "-Wno-builtin-macro-redefined",
+        "-D__DATE__=",
+        "-D__TIME__=",
+        "-D__TIMESTAMP__=",
+      ]
+    }
+  }
+
+  # Makes builds independent of absolute file path.
+  if (is_clang && strip_absolute_paths_from_debug_symbols) {
+    # If debug option is given, clang includes $cwd in debug info by default.
+    # For such build, this flag generates reproducible obj files even we use
+    # 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=." ]
+      swiftflags += [ "-file-compilation-dir=." ]
+    }
+    if (!is_win) {
+      # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+      asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+    }
+
+    if (is_win && use_lld) {
+      if (symbol_level == 2 || (is_clang && using_sanitizer)) {
+        # Absolutize source file paths for PDB. Pass the real build directory
+        # if the pdb contains source-level debug information and if linker
+        # reproducibility is not critical.
+        ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ]
+      } else {
+        # Use a fake fixed base directory for paths in the pdb to make the pdb
+        # output fully deterministic and independent of the build directory.
+        ldflags += [ "/PDBSourcePath:o:\fake\prefix" ]
+      }
+    }
+  }
+
+  # Tells the compiler not to use absolute paths when passing the default
+  # paths to the tools it invokes. We don't want this because we don't
+  # really need it and it can mess up the goma cache entries.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags += [ "-no-canonical-prefixes" ]
+
+    # Same for links: Let the compiler driver invoke the linker
+    # with a relative path and pass relative paths to built-in
+    # libraries. Not needed on Windows because we call the linker
+    # directly there, not through the compiler driver.
+    # We don't link on goma, so this change is just for cleaner
+    # internal linker invocations, for people who work on the build.
+    if (!is_win) {
+      ldflags += [ "-no-canonical-prefixes" ]
+    }
+  }
+}
+
+config("clang_revision") {
+  if (is_clang && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
+config("rustc_revision") {
+  if (rustc_revision != "") {
+    # Similar to the above config, this is here so that all files get recompiled
+    # after a rustc roll. Nothing should ever read this cfg. This will not be
+    # set if a custom toolchain is used.
+    rustflags = [
+      "--cfg",
+      "cr_rustc_revision=\"$rustc_revision\"",
+    ]
+  }
+}
+
+config("compiler_arm_fpu") {
+  if (current_cpu == "arm" && !is_ios && !is_nacl) {
+    cflags = [ "-mfpu=$arm_fpu" ]
+    if (!arm_use_thumb) {
+      cflags += [ "-marm" ]
+    }
+    asmflags = cflags
+  }
+}
+
+config("compiler_arm_thumb") {
+  if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+      !(is_apple || is_nacl)) {
+    cflags = [ "-mthumb" ]
+  }
+}
+
+config("compiler_arm") {
+  if (current_cpu == "arm" && is_chromeos) {
+    # arm is normally the default mode for clang, but on chromeos a wrapper
+    # is used to pass -mthumb, and therefor change the default.
+    cflags = [ "-marm" ]
+  }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+  configs = []
+
+  # The order of this config is important: it must appear before
+  # android:runtime_library.  This is to ensure libc++ appears before
+  # libandroid_support in the -isystem include order.  Otherwise, there will be
+  # build errors related to symbols declared in math.h.
+  if (use_custom_libcxx) {
+    configs += [ "//build/config/c++:runtime_library" ]
+  }
+
+  # Rust and C++ both provide intrinsics for LLVM to call for math operations. We
+  # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins
+  # library. The Rust symbols are marked as weak, so that they can be replaced by
+  # the C++ symbols. This config ensures the C++ symbols exist and are strong in
+  # order to cause that replacement to occur by explicitly linking in clang's
+  # compiler-rt library.
+  if (is_clang && toolchain_has_rust) {
+    configs += [ "//build/config/clang:compiler_builtins" ]
+  }
+
+  # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia
+  # configuration.
+  if (is_posix || is_fuchsia) {
+    configs += [ "//build/config/posix:runtime_library" ]
+
+    if (use_custom_libunwind) {
+      # Instead of using an unwind lib from the toolchain,
+      # buildtools/third_party/libunwind will be built and used directly.
+      ldflags = [ "--unwindlib=none" ]
+    }
+  }
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:runtime_library" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:runtime_library" ]
+    if (is_chromeos) {
+      configs += [ "//build/config/chromeos:runtime_library" ]
+    }
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:runtime_library" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:runtime_library" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:runtime_library" ]
+  }
+
+  if (is_component_build) {
+    defines = [ "COMPONENT_BUILD" ]
+  }
+}
+
+# treat_warnings_as_errors ----------------------------------------------------
+#
+# Adding this config causes the compiler to treat warnings as fatal errors.
+# This is used as a subconfig of both chromium_code and no_chromium_code, and
+# is broken out separately so nocompile tests can force-enable this setting
+# independently of the default warning flags.
+config("treat_warnings_as_errors") {
+  if (is_win) {
+    cflags = [ "/WX" ]
+  } else {
+    cflags = [ "-Werror" ]
+
+    # The compiler driver can sometimes (rarely) emit warnings before calling
+    # the actual linker.  Make sure these warnings are treated as errors as
+    # well.
+    ldflags = [ "-Werror" ]
+  }
+
+  # Turn rustc warnings into the "deny" lint level, which produce compiler
+  # errors. The equivalent of -Werror for clang/gcc.
+  #
+  # Note we apply the actual lint flags in config("compiler"). All warnings
+  # are suppressed in third-party crates.
+  rustflags = [ "-Dwarnings" ]
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default.  This is used as a
+# subconfig of both chromium_code and no_chromium_code.  This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  ldflags = []
+  configs = []
+
+  if (is_win) {
+    if (fatal_linker_warnings) {
+      arflags = [ "/WX" ]
+      ldflags = [ "/WX" ]
+    }
+    defines = [
+      # Without this, Windows headers warn that functions like wcsnicmp
+      # should be spelled _wcsnicmp. But all other platforms keep spelling
+      # it wcsnicmp, making this warning unhelpful. We don't want it.
+      "_CRT_NONSTDC_NO_WARNINGS",
+
+      # TODO(thakis): winsock wants us to use getaddrinfo instead of
+      # gethostbyname. Fires mostly in non-Chromium code. We probably
+      # want to remove this define eventually.
+      "_WINSOCK_DEPRECATED_NO_WARNINGS",
+    ]
+    if (!is_clang) {
+      # TODO(thakis): Remove this once
+      # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
+      # rolled into angle.
+      cflags += [ "/wd4244" ]
+    }
+  } else {
+    if (is_apple && !is_nacl) {
+      # When compiling Objective-C, warns if a method is used whose
+      # availability is newer than the deployment target.
+      cflags += [ "-Wunguarded-availability" ]
+    }
+
+    if (is_ios) {
+      # When compiling Objective-C, warns if a selector named via @selector has
+      # not been defined in any visible interface.
+      cflags += [ "-Wundeclared-selector" ]
+    }
+
+    # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+    # warning).
+    if (current_cpu == "arm" && !is_clang) {
+      cflags += [ "-Wno-psabi" ]
+    }
+
+    if (!is_clang) {
+      cflags_cc += [
+        # See comment for -Wno-c++11-narrowing.
+        "-Wno-narrowing",
+      ]
+
+      # -Wno-class-memaccess warns about hash table and vector in blink.
+      # But the violation is intentional.
+      if (!is_nacl) {
+        cflags_cc += [ "-Wno-class-memaccess" ]
+      }
+
+      # -Wunused-local-typedefs is broken in gcc,
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
+      cflags += [ "-Wno-unused-local-typedefs" ]
+
+      # Don't warn about "maybe" uninitialized. Clang doesn't include this
+      # in -Wall but gcc does, and it gives false positives.
+      cflags += [ "-Wno-maybe-uninitialized" ]
+      cflags += [ "-Wno-deprecated-declarations" ]
+
+      # -Wcomment gives too many false positives in the case a
+      # backslash ended comment line is followed by a new line of
+      # comments
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
+      cflags += [ "-Wno-comments" ]
+
+      # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
+      # files.
+      cflags += [ "-Wno-packed-not-aligned" ]
+    }
+  }
+
+  # Common Clang and GCC warning setup.
+  if (!is_win || is_clang) {
+    cflags += [
+      # Disables.
+      "-Wno-missing-field-initializers",  # "struct foo f = {0};"
+      "-Wno-unused-parameter",  # Unused function parameters.
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # An ABI compat warning we don't care about, https://crbug.com/1102157
+        # TODO(thakis): Push this to the (few) targets that need it,
+        # instead of having a global flag.
+        "-Wno-psabi",
+      ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      "-Wloop-analysis",
+
+      # TODO(thakis): This used to be implied by -Wno-unused-function,
+      # which we no longer use. Check if it makes sense to remove
+      # this as well. http://crbug.com/316352
+      "-Wno-unneeded-internal-declaration",
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      if (is_win) {
+        # TODO(thakis): https://crbug.com/617318
+        # Currently goma can not handle case sensitiveness for windows well.
+        cflags += [ "-Wno-nonportable-include-path" ]
+      }
+
+      if (is_fuchsia) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1474434): fix and reenable
+          "-Wno-missing-field-initializers",
+        ]
+      }
+
+      cflags += [
+        "-Wenum-compare-conditional",
+
+        # Ignore warnings about MSVC optimization pragmas.
+        # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
+        "-Wno-ignored-pragma-optimize",
+      ]
+
+      if (!is_nacl) {
+        cflags += [
+          # TODO(crbug.com/1343975) Evaluate and possibly enable.
+          "-Wno-deprecated-builtins",
+
+          # TODO(crbug.com/1352183) Evaluate and possibly enable.
+          "-Wno-bitfield-constant-conversion",
+
+          # TODO(crbug.com/1412713) Evaluate and possibly enable.
+          "-Wno-deprecated-this-capture",
+        ]
+      }
+    }
+
+    # Some builders, such as Cronet, use a different version of Clang than
+    # Chromium. This can cause minor errors when compiling Chromium changes. We
+    # want to avoid these errors.
+    if (llvm_android_mainline) {
+      cflags += [
+        "-Wno-error=unknown-warning-option",
+        "-Wno-error=unused-command-line-argument",
+      ]
+    }
+  }
+
+  # Rust warnings
+
+  # Require `unsafe` blocks even in `unsafe` fns. This is intended to become
+  # an error by default eventually; see
+  # https://github.com/rust-lang/rust/issues/71668
+  rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
+}
+
+# prevent_unsafe_narrowing ----------------------------------------------------
+#
+# Warnings that prevent narrowing or comparisons of integer types that are
+# likely to cause out-of-bound read/writes or Undefined Behaviour. In
+# particular, size_t is used for memory sizes, allocation, indexing, and
+# offsets. Using other integer types along with size_t produces risk of
+# memory-safety bugs and thus security exploits.
+#
+# In order to prevent these bugs, allocation sizes were historically limited to
+# sizes that can be represented within 31 bits of information, allowing `int` to
+# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
+# support increasing the allocation limit we require strictly adherence to
+# using the correct types, avoiding lossy conversions, and preventing overflow.
+# To do so, enable this config and fix errors by converting types to be
+# `size_t`, which is both large enough and unsigned, when dealing with memory
+# sizes, allocations, indices, or offsets.In cases where type conversion is not
+# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
+# to convert to size_t as needed.
+# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
+#
+# To enable in a GN target, use:
+#   configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
+
+config("prevent_unsafe_narrowing") {
+  if (is_clang) {
+    cflags = [
+      "-Wshorten-64-to-32",
+      "-Wimplicit-int-conversion",
+      "-Wsign-compare",
+      "-Wsign-conversion",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
+        # fixing types to be sign-correct.
+        "-Wtautological-unsigned-zero-compare",
+      ]
+    }
+  }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+  if (is_win) {
+    if (is_clang) {
+      cflags = [ "/W4" ]  # Warning level 4.
+
+      # Opt in to additional [[nodiscard]] on standard library methods.
+      defines = [ "_HAS_NODISCARD" ]
+    }
+  } else {
+    cflags = [ "-Wall" ]
+    if (is_clang) {
+      # Enable extra warnings for chromium_code when we control the compiler.
+      cflags += [ "-Wextra" ]
+    }
+
+    # In Chromium code, we define __STDC_foo_MACROS in order to get the
+    # C99 macros on Mac and Linux.
+    defines = [
+      "__STDC_CONSTANT_MACROS",
+      "__STDC_FORMAT_MACROS",
+    ]
+
+    if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+        current_cpu != "s390" && current_cpu != "ppc64" &&
+        current_cpu != "mips" && current_cpu != "mips64" &&
+        current_cpu != "riscv64" && current_cpu != "loong64") {
+      # Non-chromium code is not guaranteed to compile cleanly with
+      # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+      # disabled, so only do that for Release build.
+      fortify_level = "2"
+
+      # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation
+      # with a few custom glibc patches. Use that if it's available.
+      if (is_chromeos_ash) {
+        fortify_level = "3"
+      }
+      defines += [ "_FORTIFY_SOURCE=" + fortify_level ]
+    }
+
+    if (is_apple) {
+      cflags_objc = [ "-Wimplicit-retain-self" ]
+      cflags_objcc = [ "-Wimplicit-retain-self" ]
+    }
+
+    if (is_mac) {
+      cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
+      cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Warn on missing break statements at the end of switch cases.
+      # For intentional fallthrough, use [[fallthrough]].
+      "-Wimplicit-fallthrough",
+
+      # Warn on unnecessary extra semicolons outside of function definitions.
+      "-Wextra-semi",
+
+      # Warn on unreachable code, including unreachable breaks and returns.
+      # See https://crbug.com/346399#c148 for suppression strategies.
+      "-Wunreachable-code-aggressive",
+    ]
+
+    # Thread safety analysis is broken under nacl: https://crbug.com/982423.
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # Thread safety analysis. See base/thread_annotations.h and
+        # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
+        "-Wthread-safety",
+      ]
+    }
+  }
+
+  configs = [
+    ":default_warnings",
+    ":noshadowing",
+  ]
+  if (treat_warnings_as_errors) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
+  if (is_win) {
+    if (is_clang) {
+      cflags += [ "/W3" ]  # Warning level 3.
+    }
+    cflags += [
+      "/wd4800",  # Disable warning when forcing value to bool.
+      "/wd4267",  # TODO(jschuh): size_t to int.
+    ]
+  } else {
+    if (is_clang && !is_nacl) {
+      # TODO(thakis): Remove !is_nacl once
+      # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+      cflags += [ "-Wall" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Lots of third-party libraries have unused variables. Instead of
+      # suppressing them individually, we just blanket suppress them here.
+      "-Wno-unused-variable",
+
+      # Similarly, we're not going to fix all the C++11 narrowing issues in
+      # third-party libraries.
+      "-Wno-c++11-narrowing",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Disabled for similar reasons as -Wunused-variable.
+        "-Wno-unused-but-set-variable",
+
+        # TODO(https://crbug.com/1202159): Clean up and enable.
+        "-Wno-misleading-indentation",
+      ]
+    }
+  }
+
+  # Suppress all warnings in third party, as Cargo does:
+  # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
+  rustflags = [ "--cap-lints=allow" ]
+
+  configs = [ ":default_warnings" ]
+
+  # GCC may emit unsuppressible warnings so only apply this config when
+  # building with clang. crbug.com/589724
+  if (treat_warnings_as_errors && is_clang) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+# noshadowing -----------------------------------------------------------------
+#
+# Allows turning -Wshadow on.
+
+config("noshadowing") {
+  # This flag has to be disabled for nacl because the nacl compiler is too
+  # strict about shadowing.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags = [ "-Wshadow" ]
+  }
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+  if (is_win) {
+    cflags_cc = [ "/GR" ]
+  } else {
+    cflags_cc = [ "-frtti" ]
+  }
+}
+
+config("no_rtti") {
+  # Some sanitizer configs may require RTTI to be left enabled globally
+  if (!use_rtti) {
+    if (is_win) {
+      cflags_cc = [ "/GR-" ]
+    } else {
+      cflags_cc = [ "-fno-rtti" ]
+      cflags_objcc = cflags_cc
+    }
+  }
+}
+
+# export_dynamic ---------------------------------------------------------------
+#
+# Ensures all exported symbols are added to the dynamic symbol table.  This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries.  Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+  # TODO(crbug.com/1052397): Revisit after target_os flip is completed.
+  if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) {
+    ldflags = [ "-rdynamic" ]
+  }
+}
+
+# thin_archive -----------------------------------------------------------------
+#
+# Enables thin archives on posix, and on windows when the lld linker is used.
+# Regular archives directly include the object files used to generate it.
+# Thin archives merely reference the object files.
+# This makes building them faster since it requires less disk IO, but is
+# inappropriate if you wish to redistribute your static library.
+# This config is added to the global config, so thin archives should already be
+# enabled.  If you want to make a distributable static library, you need to do 2
+# things:
+# 1. Set complete_static_lib so that all dependencies of the library make it
+#    into the library. See `gn help complete_static_lib` for details.
+# 2. Remove the thin_archive config, so that the .a file actually contains all
+#    .o files, instead of just references to .o files in the build directoy
+config("thin_archive") {
+  # The macOS and iOS default linker ld64 does not support reading thin
+  # archives.
+  # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
+  # confuses lldb.
+  if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
+    arflags = [ "-T" ]
+  } else if (is_win && use_lld) {
+    arflags = [ "/llvmlibthin" ]
+  }
+}
+
+# exceptions -------------------------------------------------------------------
+#
+# Allows turning Exceptions on or off.
+# Note: exceptions are disallowed in Google code.
+
+config("exceptions") {
+  if (is_win) {
+    # Enables exceptions in the STL.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=1" ]
+    }
+    cflags_cc = [ "/EHsc" ]
+  } else {
+    cflags_cc = [ "-fexceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+config("no_exceptions") {
+  if (is_win) {
+    # Disables exceptions in the STL.
+    # libc++ uses the __has_feature macro to control whether to use exceptions,
+    # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+    # breaks libc++ because it depends on MSVC headers that only provide certain
+    # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use
+    # exceptions, despite being conditional on _HAS_EXCEPTIONS.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=0" ]
+    }
+  } else {
+    cflags_cc = [ "-fno-exceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# Generate a warning for code that might emit a static initializer.
+# See: //docs/static_initializers.md
+# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
+config("wglobal_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wglobal-constructors" ]
+  }
+}
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wexit-time-destructors" ]
+  }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# suppressing the rest of them.  Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+  cflags = []
+  if (is_clang) {
+    cflags += [ "-Wno-incompatible-pointer-types" ]
+  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+    cflags += [ "-w" ]
+  } else if (is_chromeos_ash && current_cpu == "arm") {
+    cflags += [ "-w" ]
+  }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_optimization" ]
+#   configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+  common_optimize_on_cflags = [
+    "/Ob2",  # Both explicit and auto inlining.
+    "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+    "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+  ]
+  if (!is_asan) {
+    common_optimize_on_cflags += [
+      # Put data in separate COMDATs. This allows the linker
+      # to put bit-identical constants at the same address even if
+      # they're unrelated constants, which saves binary size.
+      # This optimization can't be used when ASan is enabled because
+      # it is not compatible with the ASan ODR checker.
+      "/Gw",
+    ]
+  }
+  common_optimize_on_ldflags = []
+
+  # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+  # misleading symbols in stack traces.
+  if (!is_debug && !is_component_build) {
+    common_optimize_on_ldflags += [ "/OPT:ICF" ]  # Redundant COMDAT folding.
+  }
+
+  if (is_official_build) {
+    common_optimize_on_ldflags += [ "/OPT:REF" ]  # Remove unreferenced data.
+    # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
+  }
+} else {
+  common_optimize_on_cflags = []
+  common_optimize_on_ldflags = []
+
+  if (is_android) {
+    # TODO(jdduke) Re-enable on mips after resolving linking
+    # issues with libc++ (crbug.com/456380).
+    if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+      common_optimize_on_ldflags += [
+        # Warn in case of text relocations.
+        "-Wl,--warn-shared-textrel",
+      ]
+    }
+  }
+
+  if (is_apple) {
+    common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+
+    if (is_official_build) {
+      common_optimize_on_ldflags += [
+        "-Wl,-no_data_in_code_info",
+        "-Wl,-no_function_starts",
+      ]
+    }
+  } else if (current_os != "aix" && current_os != "zos") {
+    # Non-Mac Posix flags.
+    # Aix does not support these.
+
+    common_optimize_on_cflags += [
+      # Put data and code in their own sections, so that unused symbols
+      # can be removed at link time with --gc-sections.
+      "-fdata-sections",
+      "-ffunction-sections",
+    ]
+    if ((!is_nacl || is_nacl_saigo) && is_clang) {
+      # We don't care about unique section names, this makes object files a bit
+      # smaller.
+      common_optimize_on_cflags += [ "-fno-unique-section-names" ]
+    }
+
+    common_optimize_on_ldflags += [
+      # Specifically tell the linker to perform optimizations.
+      # See http://lwn.net/Articles/192624/ .
+      # -O2 enables string tail merge optimization in gold and lld.
+      "-Wl,-O2",
+      "-Wl,--gc-sections",
+    ]
+  }
+}
+
+config("default_stack_frames") {
+  if (!is_win) {
+    if (enable_frame_pointers) {
+      cflags = [ "-fno-omit-frame-pointer" ]
+
+      # Omit frame pointers for leaf functions on x86, otherwise building libyuv
+      # gives clang's register allocator issues, see llvm.org/PR15798 /
+      # crbug.com/233709
+      if (is_clang && current_cpu == "x86" && !is_apple) {
+        cflags += [ "-momit-leaf-frame-pointer" ]
+      }
+    } else {
+      cflags = [ "-fomit-frame-pointer" ]
+    }
+  }
+  # On Windows, the flag to enable framepointers "/Oy-" must always come after
+  # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+  # the "optimize" configs, see rest of this file. The ordering that cflags are
+  # applied is well-defined by the GN spec, and there is no way to ensure that
+  # cflags set by "default_stack_frames" is applied after those set by an
+  # "optimize" config. Similarly, there is no way to propagate state from this
+  # config into the "optimize" config. We always apply the "/Oy-" config in the
+  # definition for common_optimize_on_cflags definition, even though this may
+  # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+  if (is_win) {
+    if (chrome_pgo_phase != 2) {
+      # Favor size over speed, /O1 must be before the common flags.
+      # /O1 implies /Os and /GF.
+      cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+      rustflags = [ "-Copt-level=s" ]
+    } else {
+      # PGO requires all translation units to be compiled with /O2. The actual
+      # optimization level will be decided based on the profiling data.
+      cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
+
+      # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
+      # suggests not using an explicit `-Copt-level` at all, and the default is
+      # to optimize for performance like `/O2` for clang.
+      rustflags = []
+    }
+  } else if (optimize_for_size) {
+    # Favor size over speed.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+
+      if (use_ml_inliner && is_a_target_toolchain) {
+        cflags += [
+          "-mllvm",
+          "-enable-ml-inliner=release",
+        ]
+      }
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
+    # vectorization.
+    rustflags = [ "-Copt-level=z" ]
+  } else if (is_chromeos) {
+    # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+    # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+    # any cost" (AKA -Oz). It'd be nice to:
+    # - Make `optimize_for_size` apply to all platforms where we're optimizing
+    #   for size by default (so, also Windows)
+    # - Investigate -Oz here, maybe just for ARM?
+    cflags = [ "-Os" ] + common_optimize_on_cflags
+
+    # Similar to clang, we optimize with `-Copt-level=s` to keep loop
+    # vectorization while otherwise optimizing for size.
+    rustflags = [ "-Copt-level=s" ]
+  } else {
+    cflags = [ "-O2" ] + common_optimize_on_cflags
+
+    # The `-O3` for clang turns on extra optimizations compared to the standard
+    # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
+    # to use.
+    rustflags = [ "-Copt-level=3" ]
+  }
+  ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+  if (is_win) {
+    cflags = [
+      "/Od",  # Disable optimization.
+      "/Ob0",  # Disable all inlining (on by default).
+      "/GF",  # Enable string pooling (off by default).
+    ]
+
+    if (target_cpu == "arm64") {
+      # Disable omitting frame pointers for no_optimize build because stack
+      # traces on Windows ARM64 rely on it.
+      cflags += [ "/Oy-" ]
+    }
+  } else if (is_android && !android_full_debug) {
+    # On Android we kind of optimize some things that don't affect debugging
+    # much even when optimization is disabled to get the binary size down.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    if (!is_component_build) {
+      # Required for library partitions. Without this all symbols just end up
+      # in the base partition.
+      ldflags = [ "-Wl,--gc-sections" ]
+    }
+  } else if (is_fuchsia) {
+    # On Fuchsia, we optimize for size here to reduce the size of debug build
+    # packages so they can be run in a KVM. See crbug.com/910243 for details.
+    cflags = [ "-Og" ]
+  } else {
+    cflags = [ "-O0" ]
+    ldflags = []
+  }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O2" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O3" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+config("optimize_fuzzing") {
+  cflags = [ "-O1" ] + common_optimize_on_cflags
+  rustflags = [ "-Copt-level=1" ]
+  ldflags = common_optimize_on_ldflags
+  visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else if (optimize_for_fuzzing) {
+    assert(!is_win, "Fuzzing optimize level not supported on Windows")
+
+    # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even
+    # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
+    assert(!use_clang_coverage,
+           "optimize_for_fuzzing=true should not be used with " +
+               "use_clang_coverage=true.")
+    configs = [ ":optimize_fuzzing" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
+_clang_sample_profile = ""
+if (is_clang && is_a_target_toolchain) {
+  if (clang_sample_profile_path != "") {
+    _clang_sample_profile = clang_sample_profile_path
+  } else if (clang_use_default_sample_profile) {
+    assert(build_with_chromium,
+           "Our default profiles currently only apply to Chromium")
+    assert(is_android || is_chromeos || is_castos,
+           "The current platform has no default profile")
+    if (is_android || is_castos) {
+      _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+    } else {
+      assert(
+          chromeos_afdo_platform == "atom" ||
+              chromeos_afdo_platform == "bigcore" ||
+              chromeos_afdo_platform == "arm" ||
+              chromeos_afdo_platform == "arm-exp",
+          "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
+      _clang_sample_profile =
+          "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+    }
+  }
+}
+
+# Clang offers a way to assert that AFDO profiles are accurate, which causes it
+# to optimize functions not represented in a profile more aggressively for size.
+# This config can be toggled in cases where shaving off binary size hurts
+# performance too much.
+config("afdo_optimize_size") {
+  if (_clang_sample_profile != "" && sample_profile_is_accurate) {
+    cflags = [ "-fprofile-sample-accurate" ]
+  }
+}
+
+# GCC and clang support a form of profile-guided optimization called AFDO.
+# There are some targeted places that AFDO regresses, so we provide a separate
+# config to allow AFDO to be disabled per-target.
+config("afdo") {
+  if (is_clang) {
+    cflags = []
+    if (clang_emit_debug_info_for_profiling) {
+      # Add the following flags to generate debug info for profiling.
+      cflags += [ "-gline-tables-only" ]
+      if (!is_nacl) {
+        cflags += [ "-fdebug-info-for-profiling" ]
+      }
+    }
+    if (_clang_sample_profile != "") {
+      assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
+      rebased_clang_sample_profile =
+          rebase_path(_clang_sample_profile, root_build_dir)
+      cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+      if (use_profi) {
+        cflags += [ "-fsample-profile-use-profi" ]
+      }
+
+      # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
+      # These seem to be false positives - the complaints are about functions
+      # marked with `__nodebug__` not having associated debuginfo. In the case
+      # where this was observed, the `__nodebug__` function was also marked
+      # `__always_inline__` and had no branches, so AFDO info is likely useless
+      # there.
+      cflags += [ "-Wno-backend-plugin" ]
+      inputs = [ _clang_sample_profile ]
+    }
+  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+    cflags = [ "-fauto-profile=${auto_profile_path}" ]
+    inputs = [ auto_profile_path ]
+  }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_symbols" ]
+#   configs += [ "//build/config/compiler:symbols" ]
+
+# A helper config that all configs passing /DEBUG to the linker should
+# include as sub-config.
+config("win_pdbaltpath") {
+  visibility = [
+    ":minimal_symbols",
+    ":symbols",
+  ]
+
+  # /DEBUG causes the linker to generate a pdb file, and to write the absolute
+  # path to it in the executable file it generates.  This flag turns that
+  # absolute path into just the basename of the pdb file, which helps with
+  # build reproducibility. Debuggers look for pdb files next to executables,
+  # so there's minimal downside to always using this. However, post-mortem
+  # debugging of Chromium crash dumps and ETW tracing can be complicated by this
+  # switch so an option to omit it is important.
+  if (!use_full_pdb_paths) {
+    ldflags = [ "/pdbaltpath:%_PDB%" ]
+  }
+}
+
+# Full symbols.
+config("symbols") {
+  rustflags = []
+  if (is_win) {
+    if (is_clang) {
+      cflags = [
+        # Debug information in the .obj files.
+        "/Z7",
+
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    } else {
+      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.
+    }
+
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = []
+    if (is_mac && enable_dsyms) {
+      # If generating dSYMs, specify -fno-standalone-debug. This was
+      # originally specified for https://crbug.com/479841 because dsymutil
+      # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+      # version 7 also produces debug data that is incompatible with Breakpad
+      # dump_syms, so this is still required (https://crbug.com/622406).
+      cflags += [ "-fno-standalone-debug" ]
+    }
+
+    # On aix -gdwarf causes linker failures due to thread_local variables.
+    if (!is_nacl && current_os != "aix") {
+      if (use_dwarf5) {
+        cflags += [ "-gdwarf-5" ]
+        rustflags += [ "-Zdwarf-version=5" ]
+      } else {
+        # Recent clang versions default to DWARF5 on Linux, and Android is about
+        # to switch. TODO: Adopt that in controlled way. For now, keep DWARF4.
+        # Apple platforms still default to 4 in clang, so they don't need the
+        # cflags.
+        if (!is_apple) {
+          cflags += [ "-gdwarf-4" ]
+        }
+
+        # On Apple, rustc defaults to DWARF2 so it needs to be told how to
+        # match clang.
+        rustflags += [ "-Zdwarf-version=4" ]
+      }
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if ((!is_nacl || is_nacl_saigo) && current_os != "zos") {
+      cflags += [ "-g2" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
+      # to be manually enabled.
+      #
+      # It is skipped in tsan and asan because enabling it causes some
+      # formatting changes in the output which would require fixing bunches
+      # of expectation regexps.
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    if (is_apple) {
+      swiftflags = [ "-g" ]
+    }
+
+    if (use_debug_fission) {
+      cflags += [ "-gsplit-dwarf" ]
+    }
+    asmflags = cflags
+    ldflags = []
+
+    # Split debug info with all thinlto builds except nacl and apple.
+    # thinlto requires -gsplit-dwarf in ldflags.
+    if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) {
+      ldflags += [ "-gsplit-dwarf" ]
+    }
+
+    # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+    # currently we get "warning:
+    # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+    # DWARF info may be corrupt; offsets in a range list entry are in different
+    # sections" there.  Maybe just a bug in nacl_switch_32.S.
+    _enable_gdb_index =
+        symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" &&
+        current_os != "zos" && (use_gold || use_lld) &&
+        # Disable on non-fission 32-bit Android because it pushes
+        # libcomponents_unittests over the 4gb size limit.
+        !(is_android && !use_debug_fission && current_cpu != "x64" &&
+          current_cpu != "arm64")
+    if (_enable_gdb_index) {
+      if (is_clang) {
+        # This flag enables the GNU-format pubnames and pubtypes sections,
+        # which lld needs in order to generate a correct GDB index.
+        # TODO(pcc): Try to make lld understand non-GNU-format pubnames
+        # sections (llvm.org/PR34820).
+        cflags += [ "-ggnu-pubnames" ]
+      }
+      ldflags += [ "-Wl,--gdb-index" ]
+    }
+  }
+
+  configs = []
+
+  # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
+  # https://b/243982712.
+  if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
+      !is_nacl && current_cpu == "arm") {
+    configs += [ "//build/config:compress_debug_sections" ]
+  }
+
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+    if (is_apple) {
+      # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+      # Make sure we don't use constructor homing on mac.
+      cflags += [
+        "-Xclang",
+        "-debug-info-kind=limited",
+      ]
+    } else {
+      # Use constructor homing for debug info. This option reduces debug info
+      # by emitting class type info only when constructors are emitted.
+      cflags += [
+        "-Xclang",
+        "-fuse-ctor-homing",
+      ]
+    }
+  }
+  rustflags += [ "-g" ]
+}
+
+# Minimal symbols.
+# This config guarantees to hold symbol for stack trace which are shown to user
+# when crash happens in unittests running on buildbot.
+config("minimal_symbols") {
+  rustflags = []
+  if (is_win) {
+    # Functions, files, and line tables only.
+    cflags = []
+
+    if (is_clang) {
+      cflags += [
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    }
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+
+    # Enable line tables for clang. MSVC doesn't have an equivalent option.
+    if (is_clang) {
+      # -gline-tables-only is the same as -g1, but clang-cl only exposes the
+      # former.
+      cflags += [ "-gline-tables-only" ]
+    }
+  } else {
+    cflags = []
+    if (is_mac && !use_dwarf5) {
+      # clang defaults to DWARF2 on macOS unless mac_deployment_target is
+      # at least 10.11.
+      # TODO(thakis): Remove this once mac_deployment_target is 10.11.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    } else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
+      # On aix -gdwarf causes linker failures due to thread_local variables.
+      # Recent clang versions default to DWARF5 on Linux, and Android is about
+      # to switch. TODO: Adopt that in controlled way.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    }
+
+    if (use_dwarf5 && !is_nacl) {
+      cflags += [ "-gdwarf-5" ]
+      rustflags += [ "-Zdwarf-version=5" ]
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [ "-g1" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # See comment for -gdwarf-aranges in config("symbols").
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    ldflags = []
+    if (is_android && is_clang) {
+      # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
+      # doesn't emit DW_AT_linkage_name in -g1 builds.
+      # -fdebug-info-for-profiling enables that (and a bunch of other things we
+      # don't need), so that we get qualified names in stacks.
+      # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
+      #               failing that consider doing this on non-Android too.
+      cflags += [ "-fdebug-info-for-profiling" ]
+    }
+
+    asmflags = cflags
+  }
+  rustflags += [ "-Cdebuginfo=1" ]
+}
+
+# This configuration contains function names only. That is, the compiler is
+# told to not generate debug information and the linker then just puts function
+# names in the final debug information.
+config("no_symbols") {
+  if (is_win) {
+    ldflags = [ "/DEBUG" ]
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
+  }
+
+  # This config is removed by base unittests apk.
+  if (is_android && is_clang && strip_debug_info) {
+    configs += [ ":strip_debug" ]
+  }
+}
+
+config("strip_debug") {
+  if (!defined(ldflags)) {
+    ldflags = []
+  }
+  ldflags += [ "-Wl,--strip-debug" ]
+}
+
+if (is_apple) {
+  # On macOS and iOS, this enables support for ARC (automatic reference
+  # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+  #
+  # -fobjc-arc enables ARC overall.
+  #
+  # ARC does not add exception handlers to pure Objective-C code, but does add
+  # them to Objective-C++ code with the rationale that C++ pervasively adds them
+  # in for exception safety. However, exceptions are banned in Chromium code for
+  # C++ and exceptions in Objective-C code are intended to be fatal, so
+  # -fno-objc-arc-exceptions is specified to disable these unwanted exception
+  # handlers.
+  config("enable_arc") {
+    common_flags = [
+      "-fobjc-arc",
+      "-fno-objc-arc-exceptions",
+    ]
+    cflags_objc = common_flags
+    cflags_objcc = common_flags
+  }
+}
+
+if (is_android) {
+  # Use orderfile for linking Chrome on Android.
+  # This config enables using an orderfile for linking in LLD.
+  config("chrome_orderfile_config") {
+    # Don't try to use an orderfile with call graph sorting, except on Android,
+    # where we care about memory used by code, so we still want to mandate
+    # ordering.
+    if (chrome_orderfile_path != "") {
+      assert(use_lld)
+      _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
+      ldflags = [
+        "-Wl,--symbol-ordering-file",
+        "-Wl,$_rebased_orderfile",
+        "-Wl,--no-warn-symbol-ordering",
+      ]
+      inputs = [ chrome_orderfile_path ]
+    }
+  }
+}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+  cflags = []
+  if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+    if (init_stack_vars_zero) {
+      cflags += [ "-ftrivial-auto-var-init=zero" ]
+    } else {
+      cflags += [ "-ftrivial-auto-var-init=pattern" ]
+    }
+  }
+}
+
+buildflag_header("compiler_buildflags") {
+  header = "compiler_buildflags.h"
+
+  flags = [
+    "CLANG_PGO=$chrome_pgo_phase",
+    "SYMBOL_LEVEL=$symbol_level",
+  ]
+}
+
+config("cet_shadow_stack") {
+  if (enable_cet_shadow_stack && is_win) {
+    assert(target_cpu == "x64")
+    ldflags = [ "/CETCOMPAT" ]
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/src-orig/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/src-orig/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-119.0.6026.1-target-x86_64-patch/src-orig/build/config/compiler/BUILD.gn	(revision 192)
@@ -0,0 +1,2932 @@
+# Copyright 2013 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/buildflag_header.gni")
+import("//build/config/android/config.gni")
+import("//build/config/c++/c++.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/coverage/coverage.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/host_byteorder.gni")
+import("//build/config/rust.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/rbe.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+  import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el" ||
+    current_cpu == "mips" || current_cpu == "mips64") {
+  import("//build/config/mips.gni")
+}
+if (is_mac) {
+  import("//build/config/apple/symbols.gni")
+}
+if (is_ios) {
+  import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+  # To keep NaCl variables out of builds that don't include NaCl, all
+  # variables defined in nacl/config.gni referenced here should be protected by
+  # is_nacl conditions.
+  import("//build/config/nacl/config.gni")
+}
+
+lld_path = ""
+if (!is_clang) {
+  declare_args() {
+    # This allows overriding the location of lld.
+    lld_path = rebase_path("$clang_base_path/bin", root_build_dir)
+  }
+} else {
+  # clang looks for lld next to it, no need for -B.
+  lld_path = ""
+}
+
+declare_args() {
+  # Normally, Android builds are lightly optimized, even for debug builds, to
+  # keep binary size down. Setting this flag to true disables such optimization
+  android_full_debug = false
+
+  # Compile in such a way as to make it possible for the profiler to unwind full
+  # stack frames. Setting this flag has a large effect on the performance of the
+  # generated code than just setting profiling, but gives the profiler more
+  # information to analyze.
+  # Requires profiling to be set to true.
+  enable_full_stack_frames_for_profiling = false
+
+  # When we are going to use gold we need to find it.
+  # This is initialized below, after use_gold might have been overridden.
+  gold_path = ""
+
+  # Enable fatal linker warnings. Building Chromium with certain versions
+  # of binutils can cause linker warning.
+  fatal_linker_warnings = true
+
+  # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+  # but some sanitizers are known to require it, like CFI diagnostics
+  # and UBsan variants.
+  use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+  # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+  # optimization that GCC supports. It used by ChromeOS in their official
+  # builds. To use it, set auto_profile_path to the path to a file containing
+  # the needed gcov profiling data.
+  auto_profile_path = ""
+
+  # Path to an AFDO profile to use while building with clang, if any. Empty
+  # implies none.
+  clang_sample_profile_path = ""
+
+  # Some configurations have default sample profiles. If this is true and
+  # clang_sample_profile_path is empty, we'll fall back to the default.
+  #
+  # We currently only have default profiles for Chromium in-tree, so we disable
+  # this by default for all downstream projects, since these profiles are likely
+  # nonsensical for said projects.
+  clang_use_default_sample_profile =
+      chrome_pgo_phase == 0 && build_with_chromium && is_official_build &&
+      (is_android || chromeos_is_browser_only)
+
+  # This configuration is used to select a default profile in Chrome OS based on
+  # the microarchitectures we are using. This is only used if
+  # clang_use_default_sample_profile is true and clang_sample_profile_path is
+  # empty.
+  chromeos_afdo_platform = "atom"
+
+  # Emit debug information for profiling wile building with clang.
+  # Only enable this for ChromeOS official builds for AFDO.
+  clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
+
+  # Turn this on to have the compiler output extra timing information.
+  compiler_timing = false
+
+  # Turn this on to use ghash feature of lld for faster debug link on Windows.
+  # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
+  use_ghash = true
+
+  # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on
+  # can substantially increase link time and binary size, but they generally
+  # also make binaries a fair bit faster.
+  #
+  # TODO(gbiv): We disable optimizations by default on most platforms because
+  # the space overhead is too great. We should use some mixture of profiles and
+  # optimization settings to better tune the size increase.
+  thin_lto_enable_optimizations =
+      (is_chromeos || is_android || is_win || is_linux || is_mac ||
+       (is_ios && use_lld)) && is_official_build
+
+  # Initialize all local variables with a pattern. This flag will fill
+  # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
+  # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
+  # recognizable in the debugger, and crashes on memory accesses through
+  # uninitialized pointers.
+  #
+  # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and
+  # needs to be evaluated before enabling it there as well.
+  init_stack_vars = !(is_android && is_official_build)
+
+  # Zero init has favorable performance/size tradeoffs for Chrome OS
+  # but was not evaluated for other platforms.
+  init_stack_vars_zero = is_chromeos
+
+  # This argument is to control whether enabling text section splitting in the
+  # final binary. When enabled, the separated text sections with prefix
+  # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be
+  # merged to '.text' section. This allows us to identify the hot code section
+  # ('.text.hot') in the binary, which allows our data collection pipelines to
+  # more easily identify code that we assume to be hot/cold that doesn't turn
+  # out to be such in the field.
+  use_text_section_splitting = is_chromeos
+
+  # Enable DWARF v5.
+  use_dwarf5 = false
+
+  # Override this to put full paths to PDBs in Windows PE files. This helps
+  # windbg and Windows Performance Analyzer with finding the PDBs in some local-
+  # build scenarios. This is never needed for bots or official builds. Because
+  # this puts the output directory in the DLLs/EXEs it breaks build determinism.
+  # Bugs have been reported to the windbg/WPA teams and this workaround will be
+  # removed when they are fixed.
+  use_full_pdb_paths = false
+
+  # Enable -H, which prints the include tree during compilation.
+  # For use by tools/clang/scripts/analyze_includes.py
+  show_includes = false
+
+  # Enable Profi algorithm. Profi can infer block and edge counts.
+  # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
+  # TODO(crbug.com/1375958i:) Possibly enable this for Android too.
+  use_profi = is_chromeos
+
+  # If true, linker crashes will be rerun with `--reproduce` which causes
+  # a reproducer file to be saved.
+  save_reproducers_on_lld_crash = false
+
+  # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
+  # shadow call stack in register x18. Hence, x18 must not be used by the OS
+  # or libraries. We assume that to be the case for high end Android
+  # configurations. For more details see
+  # https://clang.llvm.org/docs/ShadowCallStack.html
+  enable_shadow_call_stack = false
+
+  # Use DWARF simple template names, with the following exceptions:
+  #
+  # * Windows is not supported as it doesn't use DWARF.
+  # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
+  #   lldb doesn't have the needed changes yet.
+  # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
+  #
+  # This greatly reduces the size of debug builds, at the cost of
+  # debugging information which is required by some specialized
+  # debugging tools.
+  simple_template_names = is_clang && !is_nacl && !is_win && !is_apple
+}
+
+declare_args() {
+  # Set to true to use icf, Identical Code Folding.
+  #
+  # icf=all is broken in older golds, see
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+  # chromeos binutils has been patched with the fix, so always use icf there.
+  # The bug only affects x86 and x64, so we can still use ICF when targeting
+  # other architectures.
+  #
+  # lld doesn't have the bug.
+  use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer &&
+            !use_clang_coverage && current_os != "zos" &&
+            !(is_android && use_order_profiling) &&
+            (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" ||
+                                                       current_cpu == "x64"))))
+}
+
+if (is_android) {
+  # Set the path to use orderfile for linking Chrome
+  # Note that this is for using only one orderfile for linking
+  # the Chrome binary/library.
+  declare_args() {
+    chrome_orderfile_path = ""
+
+    if (defined(default_chrome_orderfile)) {
+      # Allow downstream tools to set orderfile path with
+      # another variable.
+      chrome_orderfile_path = default_chrome_orderfile
+    }
+  }
+}
+
+declare_args() {
+  # Turn off the --call-graph-profile-sort flag for lld by default. Enable
+  # selectively for targets where it's beneficial.
+  enable_call_graph_profile_sort =
+      chrome_pgo_phase == 2 ||
+      (is_chromeos &&
+       (clang_use_default_sample_profile || clang_sample_profile_path != ""))
+}
+
+assert(!(llvm_force_head_revision && use_goma),
+       "can't use goma with trunk clang")
+assert(!(llvm_force_head_revision && use_remoteexec),
+       "can't use rbe with trunk clang")
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+  include_dirs = [
+    "//",
+    root_gen_dir,
+  ]
+}
+
+# Compiler instrumentation can introduce dependencies in DSOs to symbols in
+# the executable they are loaded into, so they are unresolved at link-time.
+config("no_unresolved_symbols") {
+  if (!using_sanitizer &&
+      (is_linux || is_chromeos || is_android || is_fuchsia)) {
+    ldflags = [
+      "-Wl,-z,defs",
+      "-Wl,--as-needed",
+    ]
+  }
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  cflags_objc = []
+  cflags_objcc = []
+  rustflags = []
+  ldflags = []
+  defines = []
+  configs = []
+  rustflags = []
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:compiler" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:compiler" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:compiler" ]
+  } else if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:compiler" ]
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:compiler" ]
+  } else if (is_fuchsia) {
+    configs += [ "//build/config/fuchsia:compiler" ]
+  } else if (current_os == "aix") {
+    configs += [ "//build/config/aix:compiler" ]
+  } else if (current_os == "zos") {
+    configs += [ "//build/config/zos:compiler" ]
+  }
+
+  configs += [
+    # See the definitions below.
+    ":clang_revision",
+    ":rustc_revision",
+    ":compiler_cpu_abi",
+    ":compiler_codegen",
+    ":compiler_deterministic",
+  ]
+
+  # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
+  # operations (e.g. dereferencing) into defined behavior. This avoids deletion
+  # of some security-critical code: see https://crbug.com/1139129.
+  # Nacl does not support the flag. And, we still want UBSAN to catch undefined
+  # behavior related to nullptrs, so do not add this flag if UBSAN is enabled.
+  # GCC seems to have some bugs compiling constexpr code when this is defined,
+  # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
+  # TODO(mpdenton): remove is_clang once GCC bug is fixed.
+  if (!is_nacl && !is_ubsan && is_clang) {
+    cflags += [ "-fno-delete-null-pointer-checks" ]
+  }
+
+  # Don't emit the GCC version ident directives, they just end up in the
+  # .comment section or debug info taking up binary size, and makes comparing
+  # .o files built with different compiler versions harder.
+  if (!is_win || is_clang) {
+    cflags += [ "-fno-ident" ]
+  }
+
+  # In general, Windows is totally different, but all the other builds share
+  # some common compiler and linker configuration.
+  if (!is_win) {
+    # Common POSIX compiler flags setup.
+    # --------------------------------
+    cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204
+
+    # Stack protection. ShadowCallStack and Stack protector address the same
+    # problems. Therefore, we only enable one or the other. Clang advertises SCS as
+    # a stronger alternative to StackProtector, so we give SCS precedence over SP.
+    if (enable_shadow_call_stack) {
+      # On Aarch64, SCS requires the x18 register to be unused because it will hold
+      # a pointer to the shadow stack. For Android we know that Clang doesn't use
+      # x18 by default. On other OSs adding "-ffixed-x18" might be required.
+      assert(is_android)
+
+      scs_parameters = [
+        "-fsanitize=shadow-call-stack",
+        "-fno-stack-protector",
+      ]
+      cflags += scs_parameters
+      ldflags += scs_parameters
+    } else {
+      if (is_apple) {
+        # The strong variant of the stack protector significantly increases
+        # binary size, so only enable it in debug mode.
+        if (is_debug) {
+          cflags += [ "-fstack-protector-strong" ]
+        } else {
+          cflags += [ "-fstack-protector" ]
+        }
+      } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
+        # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+        # See also https://crbug.com/533294
+        # The x86 toolchain currently has problems with stack-protector.
+        if (is_android && current_cpu == "x86") {
+          cflags += [ "-fno-stack-protector" ]
+        } else if (current_os != "aix") {
+          # Not available on aix.
+          cflags += [ "-fstack-protector" ]
+        }
+      }
+    }
+
+    if (use_lld) {
+      ldflags += [ "-fuse-ld=lld" ]
+      if (lld_path != "") {
+        ldflags += [ "-B$lld_path" ]
+      }
+    }
+
+    # Linker warnings.
+    if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
+        current_os != "zos") {
+      ldflags += [ "-Wl,--fatal-warnings" ]
+    }
+    if (fatal_linker_warnings && is_apple) {
+      ldflags += [ "-Wl,-fatal_warnings" ]
+    }
+  }
+
+  if (is_clang && is_debug) {
+    # Allow comparing the address of references and 'this' against 0
+    # in debug builds. Technically, these can never be null in
+    # well-defined C/C++ and Clang can optimize such checks away in
+    # release builds, but they may be used in asserts in debug builds.
+    cflags_cc += [
+      "-Wno-undefined-bool-conversion",
+      "-Wno-tautological-undefined-compare",
+    ]
+  }
+
+  # Non-Apple Posix and Fuchsia compiler flags setup.
+  # -----------------------------------
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    if (enable_profiling) {
+      if (!is_debug) {
+        cflags += [ "-g" ]
+
+        if (enable_full_stack_frames_for_profiling) {
+          cflags += [
+            "-fno-inline",
+            "-fno-optimize-sibling-calls",
+          ]
+        }
+      }
+    }
+
+    # Explicitly pass --build-id to ld. Compilers used to always pass this
+    # implicitly but don't any more (in particular clang when built without
+    # ENABLE_LINKER_BUILD_ID=ON).
+    if (is_official_build) {
+      # The sha1 build id has lower risk of collision but is more expensive to
+      # compute, so only use it in the official build to avoid slowing down
+      # links.
+      ldflags += [ "-Wl,--build-id=sha1" ]
+    } else if (current_os != "aix" && current_os != "zos") {
+      ldflags += [ "-Wl,--build-id" ]
+    }
+
+    if (!is_android) {
+      defines += [
+        # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain
+        # the behavior of the Android NDK from earlier versions.
+        # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
+        "_FILE_OFFSET_BITS=64",
+        "_LARGEFILE_SOURCE",
+        "_LARGEFILE64_SOURCE",
+      ]
+    }
+
+    if (!is_nacl) {
+      if (exclude_unwind_tables) {
+        cflags += [
+          "-fno-unwind-tables",
+          "-fno-asynchronous-unwind-tables",
+        ]
+        rustflags += [ "-Cforce-unwind-tables=no" ]
+        defines += [ "NO_UNWIND_TABLES" ]
+      } else {
+        cflags += [ "-funwind-tables" ]
+        rustflags += [ "-Cforce-unwind-tables=yes" ]
+      }
+    }
+  }
+
+  # Apple compiler flags setup.
+  # ---------------------------------
+  if (is_apple) {
+    # On Intel, clang emits both Apple's "compact unwind" information and
+    # DWARF eh_frame unwind information by default, for compatibility reasons.
+    # This flag limits emission of eh_frame information to functions
+    # whose unwind information can't be expressed in the compact unwind format
+    # (which in practice means almost everything gets only compact unwind
+    # entries). This reduces object file size a bit and makes linking a bit
+    # faster.
+    # On arm64, this is already the default behavior.
+    if (current_cpu == "x64") {
+      asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+      cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
+    }
+  }
+
+  # Linux/Android/Fuchsia common flags setup.
+  # ---------------------------------
+  if (is_linux || is_chromeos || is_android || is_fuchsia) {
+    asmflags += [ "-fPIC" ]
+    cflags += [ "-fPIC" ]
+    ldflags += [ "-fPIC" ]
+    rustflags += [ "-Crelocation-model=pic" ]
+
+    if (!is_clang) {
+      # Use pipes for communicating between sub-processes. Faster.
+      # (This flag doesn't do anything with Clang.)
+      cflags += [ "-pipe" ]
+    }
+
+    ldflags += [
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+    ]
+
+    if (!is_component_build) {
+      ldflags += [ "-Wl,-z,now" ]
+    }
+  }
+
+  # Linux-specific compiler flags setup.
+  # ------------------------------------
+  if (use_gold) {
+    ldflags += [ "-fuse-ld=gold" ]
+    if (!is_android) {
+      # On Android, this isn't needed.  gcc in the NDK knows to look next to
+      # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+      # above.
+      if (gold_path != "") {
+        ldflags += [ "-B$gold_path" ]
+      }
+
+      ldflags += [
+        # Experimentation found that using four linking threads
+        # saved ~20% of link time.
+        # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+        # Only apply this to the target linker, since the host
+        # linker might not be gold, but isn't used much anyway.
+        "-Wl,--threads",
+        "-Wl,--thread-count=4",
+      ]
+    }
+
+    # TODO(thestig): Make this flag work with GN.
+    #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+    #  ldflags += [
+    #    "-Wl,--detect-odr-violations",
+    #  ]
+    #}
+  }
+
+  if (use_icf && (!is_apple || use_lld)) {
+    ldflags += [ "-Wl,--icf=all" ]
+  }
+
+  if (is_linux || is_chromeos) {
+    cflags += [ "-pthread" ]
+    # Do not use the -pthread ldflag here since it becomes a no-op
+    # when using -nodefaultlibs, which would cause an unused argument
+    # error.  "-lpthread" is added in //build/config:default_libs.
+  }
+
+  # Clang-specific compiler flags setup.
+  # ------------------------------------
+  if (is_clang) {
+    cflags += [ "-fcolor-diagnostics" ]
+
+    # Enable -fmerge-all-constants. This used to be the default in clang
+    # for over a decade. It makes clang non-conforming, but is fairly safe
+    # in practice and saves some binary size. We might want to consider
+    # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13),
+    # but for now it looks like our build might rely on it
+    # (https://crbug.com/829795).
+    cflags += [ "-fmerge-all-constants" ]
+  }
+
+  if (use_lld) {
+    # TODO(thakis): Make the driver pass --color-diagnostics to the linker
+    # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
+    # in ldflags instead.
+    if (is_win) {
+      # On Windows, we call the linker directly, instead of calling it through
+      # the driver.
+      ldflags += [ "--color-diagnostics" ]
+    } else {
+      ldflags += [ "-Wl,--color-diagnostics" ]
+    }
+  }
+
+  # Enable text section splitting only on linux when using lld for now. Other
+  # platforms can be added later if needed.
+  if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) {
+    ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
+  }
+
+  if (is_clang && !is_nacl && current_os != "zos") {
+    cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
+    if (save_reproducers_on_lld_crash && use_lld) {
+      ldflags += [
+        "-fcrash-diagnostics=all",
+        "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
+      ]
+    }
+
+    # TODO(hans): Remove this once Clang generates better optimized debug info
+    # by default. https://crbug.com/765793
+    cflags += [
+      "-mllvm",
+      "-instcombine-lower-dbg-declare=0",
+    ]
+    if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+      if (is_win) {
+        ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
+      } else {
+        ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
+      }
+    }
+
+    # TODO(crbug.com/1235145): Investigate why/if this should be needed.
+    if (is_win) {
+      cflags += [ "/clang:-ffp-contract=off" ]
+    } else {
+      cflags += [ "-ffp-contract=off" ]
+    }
+  }
+
+  # C11/C++11 compiler flags setup.
+  # ---------------------------
+  if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
+      current_os == "aix") {
+    if (is_clang) {
+      standard_prefix = "c"
+
+      # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
+      # defined by the compiler.  However, lots of code relies on the
+      # non-standard features that _GNU_SOURCE enables, so define it manually.
+      defines += [ "_GNU_SOURCE" ]
+
+      if (is_nacl) {
+        # Undefine __STRICT_ANSI__ to get non-standard features which would
+        # otherwise not be enabled by NaCl's sysroots.
+        cflags += [ "-U__STRICT_ANSI__" ]
+      }
+    } else {
+      # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
+      # but we use this feature in several places in Chromium.
+      # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the
+      # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
+      # to -std=c*.
+      standard_prefix = "gnu"
+    }
+
+    cflags_c += [ "-std=${standard_prefix}11" ]
+    if (is_nacl && !is_nacl_saigo) {
+      # This is for the pnacl_newlib toolchain. It's only used to build
+      # a few independent ppapi test files that don't pull in any other
+      # dependencies.
+      cflags_cc += [ "-std=${standard_prefix}++14" ]
+      if (is_clang) {
+        cflags_cc += [ "-fno-trigraphs" ]
+      }
+    } else if (is_clang) {
+      if (defined(use_cxx17) && use_cxx17) {
+        cflags_cc += [ "-std=${standard_prefix}++17" ]
+      } else {
+        cflags_cc += [ "-std=${standard_prefix}++20" ]
+      }
+    } else {
+      # The gcc bots are currently using GCC 9, which is not new enough to
+      # support "c++20"/"gnu++20".
+      cflags_cc += [ "-std=${standard_prefix}++2a" ]
+    }
+  } else if (is_win) {
+    cflags_c += [ "/std:c11" ]
+    if ((defined(use_cxx17) && use_cxx17) ||
+        (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) {
+      cflags_cc += [ "/std:c++17" ]
+    } else {
+      cflags_cc += [ "/std:c++20" ]
+    }
+  } else if (!is_nacl) {
+    # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
+    # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
+    # more, but there are still a few buildbots using it, so until those are
+    # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
+    # clause, above.
+    cflags_c += [ "-std=c11" ]
+
+    if (defined(use_cxx17) && use_cxx17) {
+      cflags_cc += [ "-std=c++17" ]
+    } else {
+      cflags_cc += [ "-std=c++20" ]
+    }
+  }
+
+  if (is_clang && current_os != "zos") {
+    # C++17 removes trigraph support, but clang still warns that it ignores
+    # them when seeing them.  Don't.
+    cflags_cc += [ "-Wno-trigraphs" ]
+  }
+
+  if (use_relative_vtables_abi) {
+    cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
+    ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
+  }
+
+  # Add flags for link-time optimization. These flags enable
+  # optimizations/transformations that require whole-program visibility at link
+  # time, so they need to be applied to all translation units, and we may end up
+  # with miscompiles if only part of the program is compiled with LTO flags. For
+  # that reason, we cannot allow targets to enable or disable these flags, for
+  # example by disabling the optimize configuration.
+  # TODO(pcc): Make this conditional on is_official_build rather than on gn
+  # flags for specific features.
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    assert(use_lld, "LTO is only supported with lld")
+
+    cflags += [
+      "-flto=thin",
+      "-fsplit-lto-unit",
+    ]
+
+    # Limit the size of the ThinLTO cache to the lesser of 10% of
+    # available disk space, 40GB and 100000 files.
+    cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000"
+
+    # An import limit of 30 has better performance (per speedometer) and lower
+    # binary size than the default setting of 100.
+    # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
+    # should be able to better manage binary size increases on its own.
+    import_instr_limit = 30
+
+    if (is_win) {
+      ldflags += [
+        "/opt:lldltojobs=all",
+        "-mllvm:-import-instr-limit=$import_instr_limit",
+        "/lldltocache:" +
+            rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+        "/lldltocachepolicy:$cache_policy",
+        "-mllvm:-disable-auto-upgrade-debug-info",
+      ]
+    } else {
+      ldflags += [ "-flto=thin" ]
+
+      # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory
+      # usage in crbug.com/1038040. Note this will increase build time in
+      # Chrome OS.
+
+      # In ThinLTO builds, we run at most one link process at a time,
+      # and let it use all cores.
+      # TODO(thakis): Check if '=0' (that is, number of cores, instead
+      # of "all" which means number of hardware threads) is faster.
+      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_apple) {
+        ldflags += [
+          "-Wl,-cache_path_lto," +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+          "-Wcrl,object_path_lto",
+        ]
+      } else {
+        ldflags +=
+            [ "-Wl,--thinlto-cache-dir=" +
+              rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ]
+      }
+
+      ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+
+      if (is_chromeos) {
+        # ARM was originally set lower than x86 to keep the size
+        # bloat of ThinLTO to <10%, but that's potentially no longer true.
+        # FIXME(inglorion): maybe tune these?
+        # TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
+        import_instr_limit = 20
+      } else if (is_android) {
+        # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win
+        # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB.
+        import_instr_limit = 5
+      }
+
+      ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
+
+      if (!is_chromeos) {
+        # TODO(https://crbug.com/972449): turn on for ChromeOS when that
+        # toolchain has this flag.
+        # We only use one version of LLVM within a build so there's no need to
+        # upgrade debug info, which can be expensive since it runs the verifier.
+        ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
+      }
+    }
+
+    # TODO(https://crbug.com/1211155): investigate why this isn't effective on
+    # arm32.
+    if (!is_android || current_cpu == "arm64") {
+      cflags += [ "-fwhole-program-vtables" ]
+
+      if (toolchain_supports_rust_thin_lto) {
+        # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
+        # behaviour. Rust needs to know the linker will be doing LTO in this case
+        # or it rejects the Zsplit-lto-unit flag.
+        rustflags += [
+          "-Zsplit-lto-unit",
+          "-Clinker-plugin-lto=yes",
+        ]
+      } else {
+        # Don't include bitcode if it won't be used.
+        rustflags += [ "-Cembed-bitcode=no" ]
+      }
+
+      if (!is_win) {
+        ldflags += [ "-fwhole-program-vtables" ]
+      }
+    }
+
+    # This flag causes LTO to create an .ARM.attributes section with the correct
+    # architecture. This is necessary because LLD will refuse to link a program
+    # unless the architecture revision in .ARM.attributes is sufficiently new.
+    # TODO(pcc): The contents of .ARM.attributes should be based on the
+    # -march flag passed at compile time (see llvm.org/pr36291).
+    if (current_cpu == "arm") {
+      ldflags += [ "-march=$arm_arch" ]
+    }
+  }
+
+  if (compiler_timing) {
+    if (is_clang && !is_nacl) {
+      cflags += [ "-ftime-trace" ]
+    } else if (is_win) {
+      cflags += [
+        # "Documented" here:
+        # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
+        "/d2cgsummary",
+      ]
+    }
+  }
+
+  # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize
+  # stack crashes (http://crbug.com/919499).
+  if (use_lld && is_android) {
+    ldflags += [ "-Wl,--no-rosegment" ]
+  }
+
+  # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+  # --no-undefined-version.
+  if (use_lld && !is_win && !is_mac && !is_ios) {
+    ldflags += [ "-Wl,--undefined-version" ]
+  }
+
+  if (use_lld && is_apple) {
+    ldflags += [ "-Wl,--strict-auto-link" ]
+  }
+
+  # LLD does call-graph-sorted binary layout by default when profile data is
+  # present. On Android this increases binary size due to more thinks for long
+  # jumps. Turn it off by default and enable selectively for targets where it's
+  # beneficial.
+  if (use_lld && !enable_call_graph_profile_sort) {
+    if (is_win) {
+      ldflags += [ "/call-graph-profile-sort:no" ]
+    } else {
+      ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
+    }
+  }
+
+  if (is_clang && !is_nacl && show_includes) {
+    if (is_win) {
+      # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
+      assert(!use_goma, "show_includes on Windows is not reliable with goma")
+      cflags += [
+        "/clang:-H",
+        "/clang:-fshow-skipped-includes",
+      ]
+    } else {
+      cflags += [
+        "-H",
+        "-fshow-skipped-includes",
+      ]
+    }
+  }
+
+  # This flag enforces that member pointer base types are complete. It helps
+  # prevent us from running into problems in the Microsoft C++ ABI (see
+  # https://crbug.com/847724).
+  if (is_clang && !is_nacl && target_os != "chromeos" &&
+      (is_win || use_custom_libcxx)) {
+    cflags += [ "-fcomplete-member-pointers" ]
+  }
+
+  # Use DWARF simple template names.
+  if (simple_template_names) {
+    cflags_cc += [ "-gsimple-template-names" ]
+  }
+
+  # MLGO specific flags. These flags enable an ML-based inliner trained on
+  # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
+  # The "release" ML model is embedded into clang as part of its build.
+  # Currently, the ML inliner is only enabled when targeting Android due to:
+  # a) Android is where size matters the most.
+  # b) MLGO presently has the limitation of only being able to embed one model
+  #    at a time; It is unclear if the embedded model is beneficial for
+  #    non-Android targets.
+  # MLGO is only officially supported on linux.
+  if (use_ml_inliner && is_a_target_toolchain) {
+    assert(
+        is_android && host_os == "linux",
+        "MLGO is currently only supported for targeting Android on a linux host")
+    if (use_thin_lto) {
+      ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
+    }
+  }
+
+  if (clang_embed_bitcode) {
+    assert(!use_thin_lto,
+           "clang_embed_bitcode is only supported in non-ThinLTO builds")
+    cflags += [
+      "-Xclang",
+      "-fembed-bitcode=all",
+    ]
+  }
+
+  if (lld_emit_indexes_and_imports) {
+    assert(use_thin_lto,
+           "lld_emit_indexes_and_imports is only supported with ThinLTO builds")
+    ldflags += [
+      "-Wl,--save-temps=import",
+      "-Wl,--thinlto-emit-index-files",
+    ]
+  }
+
+  # Pass the same C/C++ flags to the objective C/C++ compiler.
+  cflags_objc += cflags_c
+  cflags_objcc += cflags_cc
+
+  # Assign any flags set for the C compiler to asmflags so that they are sent
+  # to the assembler. The Windows assembler takes different types of flags
+  # so only do so for posix platforms.
+  if (is_posix || is_fuchsia) {
+    asmflags += cflags
+    asmflags += cflags_c
+  }
+
+  if (is_chromeos_device && !is_nacl) {
+    # On ChromeOS devices, we want to ensure we're using Chrome's allocator
+    # symbols for all C++ new/delete operator overloads. PartitionAlloc
+    # and other local allocators should always take precedence over system or
+    # preloaded allocators. These are the mangled symbol names.
+    # See b/280115910 for details.
+    ldflags += [
+      "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
+      "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
+      "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
+      "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
+      "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
+      "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
+      "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
+    ]
+  }
+
+  # Rust compiler flags setup.
+  # ---------------------------
+  rustflags += [
+    # Overflow checks are optional in Rust, but even if switched
+    # off they do not cause undefined behavior (the overflowing
+    # behavior is defined). Because containers are bounds-checked
+    # in safe Rust, they also can't provoke buffer overflows.
+    # As such these checks may be less important in Rust than C++.
+    # But in (simplistic) testing they have negligible performance
+    # overhead, and this helps to provide consistent behavior
+    # between different configurations, so we'll keep them on until
+    # we discover a reason to turn them off.
+    "-Coverflow-checks=on",
+
+    # By default Rust passes `-nodefaultlibs` to the linker, however this
+    # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
+    # is then unused and produces a warning/error. So this removes the
+    # `-nodefaultlibs` from the linker invocation from Rust, which would be used
+    # to compile dylibs on Android, such as for constructing unit test APKs.
+    "-Cdefault-linker-libraries",
+
+    # To make Rust .d files compatible with ninja
+    "-Zdep-info-omit-d-target",
+
+    # If a macro panics during compilation, show which macro and where it is
+    # defined.
+    "-Zmacro-backtrace",
+
+    # For deterministic builds, keep the local machine's current working
+    # directory from appearing in build outputs.
+    "-Zremap-cwd-prefix=.",
+  ]
+
+  if (!is_win || force_rustc_color_output) {
+    # Colorize error output. The analogous flag is passed for clang. This must
+    # be platform-gated since rustc will unconditionally output ANSI escape
+    # sequences, ignoring the platform, when stderr is not a terminal.
+    rustflags += [ "--color=always" ]
+  }
+  if (rust_abi_target != "") {
+    rustflags += [ "--target=$rust_abi_target" ]
+  }
+  if (!use_thin_lto) {
+    # Don't include bitcode if it won't be used.
+    rustflags += [ "-Cembed-bitcode=no" ]
+  }
+  if (is_official_build) {
+    rustflags += [ "-Ccodegen-units=1" ]
+  }
+  if (!rust_prebuilt_stdlib) {
+    # When building against the Chromium Rust stdlib (which we compile) always
+    # abort instead of unwinding when panic occurs. In official builds, panics
+    # abort immediately (this is configured in the stdlib) to keep binary size
+    # down. So we unconditionally match behaviour in unofficial too.
+    rustflags += [
+      "-Cpanic=abort",
+      "-Zpanic_abort_tests",
+    ]
+  }
+
+  # Normally, this would be defined in the `runtime_library` config but NaCl
+  # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there
+  # isn't really a better config to add this define for the define to
+  # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
+  # and NaCl code.
+  #
+  # TODO(https://crbug.com/702997): Move this back to the `runtime_library`
+  # config when NaCl is removed.
+  if (use_safe_libcxx) {
+    # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once
+    # it's rolled in.
+    if (is_nacl_saigo) {
+      defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
+    } else {
+      defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ]
+    }
+  }
+}
+
+# The BUILDCONFIG file sets this config on targets by default, which means when
+# building with ThinLTO, no optimization is performed in the link step.
+config("thinlto_optimize_default") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    lto_opt_level = 0
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# Use this to enable optimization in the ThinLTO link step for select targets
+# when thin_lto_enable_optimizations is set by doing:
+#
+#   configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
+#   configs += [ "//build/config/compiler:thinlto_optimize_max" ]
+#
+# Since it makes linking significantly slower and more resource intensive, only
+# use it on important targets such as the main browser executable or dll.
+config("thinlto_optimize_max") {
+  if (!is_debug && use_thin_lto && is_a_target_toolchain) {
+    if (thin_lto_enable_optimizations) {
+      lto_opt_level = 2
+    } else {
+      lto_opt_level = 0
+    }
+
+    if (is_win) {
+      ldflags = [ "/opt:lldlto=" + lto_opt_level ]
+    } else {
+      ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
+    }
+
+    if (toolchain_supports_rust_thin_lto) {
+      # We always point Rust to a linker that performs LTO, so we don't want Rust
+      # to preemptively do so during compilation too or they conflict. But we do
+      # want Rust to generate LTO metadata in order for the linker to do its job.
+      rustflags = [ "-Clinker-plugin-lto=yes" ]
+    } else {
+      # Don't include bitcode if it won't be used.
+      rustflags = [ "-Cembed-bitcode=no" ]
+    }
+  }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in.  Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+  cflags = []
+  ldflags = []
+  defines = []
+
+  configs = []
+  if (is_chromeos) {
+    configs += [ "//build/config/chromeos:compiler_cpu_abi" ]
+  }
+
+  # TODO(https://crbug.com/1383873): Remove this once figured out.
+  if (is_apple && current_cpu == "arm64") {
+    cflags += [ "-fno-global-isel" ]
+    ldflags += [ "-fno-global-isel" ]
+  }
+
+  if ((is_posix && !is_apple) || is_fuchsia) {
+    # CPU architecture. We may or may not be doing a cross compile now, so for
+    # simplicity we always explicitly set the architecture.
+    if (current_cpu == "x64") {
+      cflags += [
+        "-m64",
+        "-msse3",
+      ]
+      ldflags += [ "-m64" ]
+    } else if (current_cpu == "x86") {
+      cflags += [ "-m32" ]
+      ldflags += [ "-m32" ]
+      if (!is_nacl) {
+        cflags += [
+          "-mfpmath=sse",
+          "-msse3",
+        ]
+      }
+    } else if (current_cpu == "arm") {
+      if (is_clang && !is_android && !is_nacl &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=arm-linux-gnueabihf" ]
+        ldflags += [ "--target=arm-linux-gnueabihf" ]
+      }
+      if (!is_nacl) {
+        cflags += [
+          "-march=$arm_arch",
+          "-mfloat-abi=$arm_float_abi",
+        ]
+      }
+      if (arm_tune != "") {
+        cflags += [ "-mtune=$arm_tune" ]
+      }
+    } else if (current_cpu == "arm64") {
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+          !(is_chromeos_lacros && is_chromeos_device)) {
+        cflags += [ "--target=aarch64-linux-gnu" ]
+        ldflags += [ "--target=aarch64-linux-gnu" ]
+      }
+    } else if (current_cpu == "mipsel" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mipsel-linux-android" ]
+            ldflags += [ "--target=mipsel-linux-android" ]
+          } else {
+            cflags += [ "--target=mipsel-linux-gnu" ]
+            ldflags += [ "--target=mipsel-linux-gnu" ]
+          }
+        } else {
+          cflags += [ "-EL" ]
+          ldflags += [ "-EL" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [ "-mno-odd-spreg" ]
+        ldflags += [ "-mips32r6" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r6",
+          ]
+        } else {
+          cflags += [
+            "-mips32r6",
+            "-Wa,-mips32r6",
+          ]
+          if (is_android) {
+            ldflags += [ "-Wl,-melf32ltsmip" ]
+          }
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips32r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32r2",
+          ]
+        } else {
+          cflags += [
+            "-mips32r2",
+            "-Wa,-mips32r2",
+          ]
+          if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+            cflags += [ "-m$mips_fpu_mode" ]
+          }
+        }
+      } else if (mips_arch_variant == "r1") {
+        ldflags += [ "-mips32" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mipsel",
+            "-mcpu=mips32",
+          ]
+        } else {
+          cflags += [
+            "-mips32",
+            "-Wa,-mips32",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips" && !is_nacl) {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips-linux-gnu" ]
+          ldflags += [ "--target=mips-linux-gnu" ]
+        } else {
+          cflags += [ "-EB" ]
+          ldflags += [ "-EB" ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips32r6",
+          "-Wa,-mips32r6",
+        ]
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips32r2",
+          "-Wa,-mips32r2",
+        ]
+        if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+          cflags += [ "-m$mips_fpu_mode" ]
+        }
+      } else if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mips32",
+          "-Wa,-mips32",
+        ]
+      }
+
+      if (mips_dsp_rev == 1) {
+        cflags += [ "-mdsp" ]
+      } else if (mips_dsp_rev == 2) {
+        cflags += [ "-mdspr2" ]
+      }
+
+      cflags += [ "-m${mips_float_abi}-float" ]
+    } else if (current_cpu == "mips64el") {
+      cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          if (is_android) {
+            cflags += [ "--target=mips64el-linux-android" ]
+            ldflags += [ "--target=mips64el-linux-android" ]
+          } else {
+            cflags += [ "--target=mips64el-linux-gnuabi64" ]
+            ldflags += [ "--target=mips64el-linux-gnuabi64" ]
+          }
+        } else {
+          cflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EL",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r6",
+          ]
+        } else {
+          cflags += [
+            "-mips64r6",
+            "-Wa,-mips64r6",
+          ]
+          ldflags += [ "-mips64r6" ]
+        }
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        ldflags += [ "-mips64r2" ]
+        if (is_clang) {
+          cflags += [
+            "-march=mips64el",
+            "-mcpu=mips64r2",
+          ]
+        } else {
+          cflags += [
+            "-mips64r2",
+            "-Wa,-mips64r2",
+          ]
+        }
+      } else if (mips_arch_variant == "loongson3") {
+        defines += [ "_MIPS_ARCH_LOONGSON" ]
+        cflags += [
+          "-march=loongson3a",
+          "-mno-branch-likely",
+          "-Wa,-march=loongson3a",
+        ]
+      }
+    } else if (current_cpu == "mips64") {
+      ldflags += [ "-Wl,--hash-style=sysv" ]
+      if (custom_toolchain == "") {
+        if (is_clang) {
+          cflags += [ "--target=mips64-linux-gnuabi64" ]
+          ldflags += [ "--target=mips64-linux-gnuabi64" ]
+        } else {
+          cflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+          ldflags += [
+            "-EB",
+            "-mabi=64",
+          ]
+        }
+      }
+
+      if (mips_arch_variant == "r6") {
+        cflags += [
+          "-mips64r6",
+          "-Wa,-mips64r6",
+        ]
+        ldflags += [ "-mips64r6" ]
+
+        if (mips_use_msa == true) {
+          cflags += [
+            "-mmsa",
+            "-mfp64",
+          ]
+        }
+      } else if (mips_arch_variant == "r2") {
+        cflags += [
+          "-mips64r2",
+          "-Wa,-mips64r2",
+        ]
+        ldflags += [ "-mips64r2" ]
+      }
+    } else if (current_cpu == "ppc64") {
+      if (current_os == "aix") {
+        cflags += [ "-maix64" ]
+        ldflags += [ "-maix64" ]
+      } else {
+        cflags += [ "-m64" ]
+        ldflags += [ "-m64" ]
+      }
+    } else if (current_cpu == "riscv64") {
+      if (is_clang && !is_android) {
+        cflags += [ "--target=riscv64-linux-gnu" ]
+        ldflags += [ "--target=riscv64-linux-gnu" ]
+      }
+      cflags += [ "-mabi=lp64d" ]
+    } else if (current_cpu == "loong64") {
+      if (is_clang) {
+        cflags += [ "--target=loongarch64-linux-gnu" ]
+        ldflags += [ "--target=loongarch64-linux-gnu" ]
+      }
+      cflags += [
+        "-mabi=lp64d",
+        "-mcmodel=medium",
+      ]
+    } else if (current_cpu == "s390x") {
+      cflags += [ "-m64" ]
+      ldflags += [ "-m64" ]
+    }
+  }
+
+  asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+  configs = []
+  cflags = []
+  ldflags = []
+
+  if (is_nacl) {
+    configs += [ "//build/config/nacl:compiler_codegen" ]
+  }
+
+  if (current_cpu == "arm64" && !is_win && is_clang) {
+    # Disable outlining everywhere on arm64 except Win. For more information see
+    # crbug.com/931297 for Android and crbug.com/1410297 for iOS.
+    # TODO(crbug.com/1411363): Enable this on Windows if possible.
+    cflags += [ "-mno-outline" ]
+
+    # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
+    # has been resolved, and -mno-outline is obeyed by the linker during
+    # ThinLTO.
+    ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
+  }
+
+  asmflags = cflags
+}
+
+# This provides options that make the build deterministic, so that the same
+# revision produces the same output, independent of the name of the build
+# directory and of the computer the build is done on.
+# The relative path from build dir to source dir makes it into the build
+# outputs, so it's recommended that you use a build dir two levels deep
+# (e.g. "out/Release") so that you get the same "../.." path as all the bots
+# in your build outputs.
+config("compiler_deterministic") {
+  cflags = []
+  ldflags = []
+  swiftflags = []
+
+  # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+  # deterministic build.  See https://crbug.com/314403
+  if (!is_official_build) {
+    if (is_win && !is_clang) {
+      cflags += [
+        "/wd4117",  # Trying to define or undefine a predefined macro.
+        "/D__DATE__=",
+        "/D__TIME__=",
+        "/D__TIMESTAMP__=",
+      ]
+    } else {
+      cflags += [
+        "-Wno-builtin-macro-redefined",
+        "-D__DATE__=",
+        "-D__TIME__=",
+        "-D__TIMESTAMP__=",
+      ]
+    }
+  }
+
+  # Makes builds independent of absolute file path.
+  if (is_clang && strip_absolute_paths_from_debug_symbols) {
+    # If debug option is given, clang includes $cwd in debug info by default.
+    # For such build, this flag generates reproducible obj files even we use
+    # 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=." ]
+      swiftflags += [ "-file-compilation-dir=." ]
+    }
+    if (!is_win) {
+      # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
+      asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
+    }
+
+    if (is_win && use_lld) {
+      if (symbol_level == 2 || (is_clang && using_sanitizer)) {
+        # Absolutize source file paths for PDB. Pass the real build directory
+        # if the pdb contains source-level debug information and if linker
+        # reproducibility is not critical.
+        ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ]
+      } else {
+        # Use a fake fixed base directory for paths in the pdb to make the pdb
+        # output fully deterministic and independent of the build directory.
+        ldflags += [ "/PDBSourcePath:o:\fake\prefix" ]
+      }
+    }
+  }
+
+  # Tells the compiler not to use absolute paths when passing the default
+  # paths to the tools it invokes. We don't want this because we don't
+  # really need it and it can mess up the goma cache entries.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags += [ "-no-canonical-prefixes" ]
+
+    # Same for links: Let the compiler driver invoke the linker
+    # with a relative path and pass relative paths to built-in
+    # libraries. Not needed on Windows because we call the linker
+    # directly there, not through the compiler driver.
+    # We don't link on goma, so this change is just for cleaner
+    # internal linker invocations, for people who work on the build.
+    if (!is_win) {
+      ldflags += [ "-no-canonical-prefixes" ]
+    }
+  }
+}
+
+config("clang_revision") {
+  if (is_clang && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
+config("rustc_revision") {
+  if (rustc_revision != "") {
+    # Similar to the above config, this is here so that all files get recompiled
+    # after a rustc roll. Nothing should ever read this cfg. This will not be
+    # set if a custom toolchain is used.
+    rustflags = [
+      "--cfg",
+      "cr_rustc_revision=\"$rustc_revision\"",
+    ]
+  }
+}
+
+config("compiler_arm_fpu") {
+  if (current_cpu == "arm" && !is_ios && !is_nacl) {
+    cflags = [ "-mfpu=$arm_fpu" ]
+    if (!arm_use_thumb) {
+      cflags += [ "-marm" ]
+    }
+    asmflags = cflags
+  }
+}
+
+config("compiler_arm_thumb") {
+  if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+      !(is_apple || is_nacl)) {
+    cflags = [ "-mthumb" ]
+  }
+}
+
+config("compiler_arm") {
+  if (current_cpu == "arm" && is_chromeos) {
+    # arm is normally the default mode for clang, but on chromeos a wrapper
+    # is used to pass -mthumb, and therefor change the default.
+    cflags = [ "-marm" ]
+  }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+  configs = []
+
+  # The order of this config is important: it must appear before
+  # android:runtime_library.  This is to ensure libc++ appears before
+  # libandroid_support in the -isystem include order.  Otherwise, there will be
+  # build errors related to symbols declared in math.h.
+  if (use_custom_libcxx) {
+    configs += [ "//build/config/c++:runtime_library" ]
+  }
+
+  # Rust and C++ both provide intrinsics for LLVM to call for math operations. We
+  # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins
+  # library. The Rust symbols are marked as weak, so that they can be replaced by
+  # the C++ symbols. This config ensures the C++ symbols exist and are strong in
+  # order to cause that replacement to occur by explicitly linking in clang's
+  # compiler-rt library.
+  if (is_clang && toolchain_has_rust) {
+    configs += [ "//build/config/clang:compiler_builtins" ]
+  }
+
+  # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia
+  # configuration.
+  if (is_posix || is_fuchsia) {
+    configs += [ "//build/config/posix:runtime_library" ]
+
+    if (use_custom_libunwind) {
+      # Instead of using an unwind lib from the toolchain,
+      # buildtools/third_party/libunwind will be built and used directly.
+      ldflags = [ "--unwindlib=none" ]
+    }
+  }
+
+  # System-specific flags. If your compiler flags apply to one of the
+  # categories here, add it to the associated file to keep this shared config
+  # smaller.
+  if (is_win) {
+    configs += [ "//build/config/win:runtime_library" ]
+  } else if (is_linux || is_chromeos) {
+    configs += [ "//build/config/linux:runtime_library" ]
+    if (is_chromeos) {
+      configs += [ "//build/config/chromeos:runtime_library" ]
+    }
+  } else if (is_ios) {
+    configs += [ "//build/config/ios:runtime_library" ]
+  } else if (is_mac) {
+    configs += [ "//build/config/mac:runtime_library" ]
+  } else if (is_android) {
+    configs += [ "//build/config/android:runtime_library" ]
+  }
+
+  if (is_component_build) {
+    defines = [ "COMPONENT_BUILD" ]
+  }
+}
+
+# treat_warnings_as_errors ----------------------------------------------------
+#
+# Adding this config causes the compiler to treat warnings as fatal errors.
+# This is used as a subconfig of both chromium_code and no_chromium_code, and
+# is broken out separately so nocompile tests can force-enable this setting
+# independently of the default warning flags.
+config("treat_warnings_as_errors") {
+  if (is_win) {
+    cflags = [ "/WX" ]
+  } else {
+    cflags = [ "-Werror" ]
+
+    # The compiler driver can sometimes (rarely) emit warnings before calling
+    # the actual linker.  Make sure these warnings are treated as errors as
+    # well.
+    ldflags = [ "-Werror" ]
+  }
+
+  # Turn rustc warnings into the "deny" lint level, which produce compiler
+  # errors. The equivalent of -Werror for clang/gcc.
+  #
+  # Note we apply the actual lint flags in config("compiler"). All warnings
+  # are suppressed in third-party crates.
+  rustflags = [ "-Dwarnings" ]
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default.  This is used as a
+# subconfig of both chromium_code and no_chromium_code.  This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  ldflags = []
+  configs = []
+
+  if (is_win) {
+    if (fatal_linker_warnings) {
+      arflags = [ "/WX" ]
+      ldflags = [ "/WX" ]
+    }
+    defines = [
+      # Without this, Windows headers warn that functions like wcsnicmp
+      # should be spelled _wcsnicmp. But all other platforms keep spelling
+      # it wcsnicmp, making this warning unhelpful. We don't want it.
+      "_CRT_NONSTDC_NO_WARNINGS",
+
+      # TODO(thakis): winsock wants us to use getaddrinfo instead of
+      # gethostbyname. Fires mostly in non-Chromium code. We probably
+      # want to remove this define eventually.
+      "_WINSOCK_DEPRECATED_NO_WARNINGS",
+    ]
+    if (!is_clang) {
+      # TODO(thakis): Remove this once
+      # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
+      # rolled into angle.
+      cflags += [ "/wd4244" ]
+    }
+  } else {
+    if (is_apple && !is_nacl) {
+      # When compiling Objective-C, warns if a method is used whose
+      # availability is newer than the deployment target.
+      cflags += [ "-Wunguarded-availability" ]
+    }
+
+    if (is_ios) {
+      # When compiling Objective-C, warns if a selector named via @selector has
+      # not been defined in any visible interface.
+      cflags += [ "-Wundeclared-selector" ]
+    }
+
+    # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+    # warning).
+    if (current_cpu == "arm" && !is_clang) {
+      cflags += [ "-Wno-psabi" ]
+    }
+
+    if (!is_clang) {
+      cflags_cc += [
+        # See comment for -Wno-c++11-narrowing.
+        "-Wno-narrowing",
+      ]
+
+      # -Wno-class-memaccess warns about hash table and vector in blink.
+      # But the violation is intentional.
+      if (!is_nacl) {
+        cflags_cc += [ "-Wno-class-memaccess" ]
+      }
+
+      # -Wunused-local-typedefs is broken in gcc,
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
+      cflags += [ "-Wno-unused-local-typedefs" ]
+
+      # Don't warn about "maybe" uninitialized. Clang doesn't include this
+      # in -Wall but gcc does, and it gives false positives.
+      cflags += [ "-Wno-maybe-uninitialized" ]
+      cflags += [ "-Wno-deprecated-declarations" ]
+
+      # -Wcomment gives too many false positives in the case a
+      # backslash ended comment line is followed by a new line of
+      # comments
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
+      cflags += [ "-Wno-comments" ]
+
+      # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
+      # files.
+      cflags += [ "-Wno-packed-not-aligned" ]
+    }
+  }
+
+  # Common Clang and GCC warning setup.
+  if (!is_win || is_clang) {
+    cflags += [
+      # Disables.
+      "-Wno-missing-field-initializers",  # "struct foo f = {0};"
+      "-Wno-unused-parameter",  # Unused function parameters.
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # An ABI compat warning we don't care about, https://crbug.com/1102157
+        # TODO(thakis): Push this to the (few) targets that need it,
+        # instead of having a global flag.
+        "-Wno-psabi",
+      ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      "-Wloop-analysis",
+
+      # TODO(thakis): This used to be implied by -Wno-unused-function,
+      # which we no longer use. Check if it makes sense to remove
+      # this as well. http://crbug.com/316352
+      "-Wno-unneeded-internal-declaration",
+    ]
+
+    if (!is_nacl || is_nacl_saigo) {
+      if (is_win) {
+        # TODO(thakis): https://crbug.com/617318
+        # Currently goma can not handle case sensitiveness for windows well.
+        cflags += [ "-Wno-nonportable-include-path" ]
+      }
+
+      if (is_fuchsia) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1474434): fix and reenable
+          "-Wno-missing-field-initializers",
+        ]
+      }
+
+      cflags += [
+        "-Wenum-compare-conditional",
+
+        # Ignore warnings about MSVC optimization pragmas.
+        # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
+        "-Wno-ignored-pragma-optimize",
+      ]
+
+      if (!is_nacl) {
+        cflags += [
+          # TODO(crbug.com/1343975) Evaluate and possibly enable.
+          "-Wno-deprecated-builtins",
+
+          # TODO(crbug.com/1352183) Evaluate and possibly enable.
+          "-Wno-bitfield-constant-conversion",
+
+          # TODO(crbug.com/1412713) Evaluate and possibly enable.
+          "-Wno-deprecated-this-capture",
+        ]
+      }
+    }
+
+    # Some builders, such as Cronet, use a different version of Clang than
+    # Chromium. This can cause minor errors when compiling Chromium changes. We
+    # want to avoid these errors.
+    if (llvm_android_mainline) {
+      cflags += [
+        "-Wno-error=unknown-warning-option",
+        "-Wno-error=unused-command-line-argument",
+      ]
+    }
+  }
+
+  # Rust warnings
+
+  # Require `unsafe` blocks even in `unsafe` fns. This is intended to become
+  # an error by default eventually; see
+  # https://github.com/rust-lang/rust/issues/71668
+  rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
+}
+
+# prevent_unsafe_narrowing ----------------------------------------------------
+#
+# Warnings that prevent narrowing or comparisons of integer types that are
+# likely to cause out-of-bound read/writes or Undefined Behaviour. In
+# particular, size_t is used for memory sizes, allocation, indexing, and
+# offsets. Using other integer types along with size_t produces risk of
+# memory-safety bugs and thus security exploits.
+#
+# In order to prevent these bugs, allocation sizes were historically limited to
+# sizes that can be represented within 31 bits of information, allowing `int` to
+# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
+# support increasing the allocation limit we require strictly adherence to
+# using the correct types, avoiding lossy conversions, and preventing overflow.
+# To do so, enable this config and fix errors by converting types to be
+# `size_t`, which is both large enough and unsigned, when dealing with memory
+# sizes, allocations, indices, or offsets.In cases where type conversion is not
+# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
+# to convert to size_t as needed.
+# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
+#
+# To enable in a GN target, use:
+#   configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
+
+config("prevent_unsafe_narrowing") {
+  if (is_clang) {
+    cflags = [
+      "-Wshorten-64-to-32",
+      "-Wimplicit-int-conversion",
+      "-Wsign-compare",
+      "-Wsign-conversion",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
+        # fixing types to be sign-correct.
+        "-Wtautological-unsigned-zero-compare",
+      ]
+    }
+  }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+  if (is_win) {
+    if (is_clang) {
+      cflags = [ "/W4" ]  # Warning level 4.
+
+      # Opt in to additional [[nodiscard]] on standard library methods.
+      defines = [ "_HAS_NODISCARD" ]
+    }
+  } else {
+    cflags = [ "-Wall" ]
+    if (is_clang) {
+      # Enable extra warnings for chromium_code when we control the compiler.
+      cflags += [ "-Wextra" ]
+    }
+
+    # In Chromium code, we define __STDC_foo_MACROS in order to get the
+    # C99 macros on Mac and Linux.
+    defines = [
+      "__STDC_CONSTANT_MACROS",
+      "__STDC_FORMAT_MACROS",
+    ]
+
+    if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+        current_cpu != "s390" && current_cpu != "ppc64" &&
+        current_cpu != "mips" && current_cpu != "mips64" &&
+        current_cpu != "riscv64" && current_cpu != "loong64") {
+      # Non-chromium code is not guaranteed to compile cleanly with
+      # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+      # disabled, so only do that for Release build.
+      fortify_level = "2"
+
+      # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation
+      # with a few custom glibc patches. Use that if it's available.
+      if (is_chromeos_ash) {
+        fortify_level = "3"
+      }
+      defines += [ "_FORTIFY_SOURCE=" + fortify_level ]
+    }
+
+    if (is_apple) {
+      cflags_objc = [ "-Wimplicit-retain-self" ]
+      cflags_objcc = [ "-Wimplicit-retain-self" ]
+    }
+
+    if (is_mac) {
+      cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
+      cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Warn on missing break statements at the end of switch cases.
+      # For intentional fallthrough, use [[fallthrough]].
+      "-Wimplicit-fallthrough",
+
+      # Warn on unnecessary extra semicolons outside of function definitions.
+      "-Wextra-semi",
+
+      # Warn on unreachable code, including unreachable breaks and returns.
+      # See https://crbug.com/346399#c148 for suppression strategies.
+      "-Wunreachable-code-aggressive",
+    ]
+
+    # Thread safety analysis is broken under nacl: https://crbug.com/982423.
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [
+        # Thread safety analysis. See base/thread_annotations.h and
+        # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
+        "-Wthread-safety",
+      ]
+    }
+  }
+
+  configs = [
+    ":default_warnings",
+    ":noshadowing",
+  ]
+  if (treat_warnings_as_errors) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
+  if (is_win) {
+    if (is_clang) {
+      cflags += [ "/W3" ]  # Warning level 3.
+    }
+    cflags += [
+      "/wd4800",  # Disable warning when forcing value to bool.
+      "/wd4267",  # TODO(jschuh): size_t to int.
+    ]
+  } else {
+    if (is_clang && !is_nacl) {
+      # TODO(thakis): Remove !is_nacl once
+      # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+      cflags += [ "-Wall" ]
+    }
+  }
+
+  if (is_clang) {
+    cflags += [
+      # Lots of third-party libraries have unused variables. Instead of
+      # suppressing them individually, we just blanket suppress them here.
+      "-Wno-unused-variable",
+
+      # Similarly, we're not going to fix all the C++11 narrowing issues in
+      # third-party libraries.
+      "-Wno-c++11-narrowing",
+    ]
+    if (!is_nacl) {
+      cflags += [
+        # Disabled for similar reasons as -Wunused-variable.
+        "-Wno-unused-but-set-variable",
+
+        # TODO(https://crbug.com/1202159): Clean up and enable.
+        "-Wno-misleading-indentation",
+      ]
+    }
+  }
+
+  # Suppress all warnings in third party, as Cargo does:
+  # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
+  rustflags = [ "--cap-lints=allow" ]
+
+  configs = [ ":default_warnings" ]
+
+  # GCC may emit unsuppressible warnings so only apply this config when
+  # building with clang. crbug.com/589724
+  if (treat_warnings_as_errors && is_clang) {
+    configs += [ ":treat_warnings_as_errors" ]
+  }
+}
+
+# noshadowing -----------------------------------------------------------------
+#
+# Allows turning -Wshadow on.
+
+config("noshadowing") {
+  # This flag has to be disabled for nacl because the nacl compiler is too
+  # strict about shadowing.
+  if (is_clang && (!is_nacl || is_nacl_saigo)) {
+    cflags = [ "-Wshadow" ]
+  }
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+  if (is_win) {
+    cflags_cc = [ "/GR" ]
+  } else {
+    cflags_cc = [ "-frtti" ]
+  }
+}
+
+config("no_rtti") {
+  # Some sanitizer configs may require RTTI to be left enabled globally
+  if (!use_rtti) {
+    if (is_win) {
+      cflags_cc = [ "/GR-" ]
+    } else {
+      cflags_cc = [ "-fno-rtti" ]
+      cflags_objcc = cflags_cc
+    }
+  }
+}
+
+# export_dynamic ---------------------------------------------------------------
+#
+# Ensures all exported symbols are added to the dynamic symbol table.  This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries.  Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+  # TODO(crbug.com/1052397): Revisit after target_os flip is completed.
+  if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) {
+    ldflags = [ "-rdynamic" ]
+  }
+}
+
+# thin_archive -----------------------------------------------------------------
+#
+# Enables thin archives on posix, and on windows when the lld linker is used.
+# Regular archives directly include the object files used to generate it.
+# Thin archives merely reference the object files.
+# This makes building them faster since it requires less disk IO, but is
+# inappropriate if you wish to redistribute your static library.
+# This config is added to the global config, so thin archives should already be
+# enabled.  If you want to make a distributable static library, you need to do 2
+# things:
+# 1. Set complete_static_lib so that all dependencies of the library make it
+#    into the library. See `gn help complete_static_lib` for details.
+# 2. Remove the thin_archive config, so that the .a file actually contains all
+#    .o files, instead of just references to .o files in the build directoy
+config("thin_archive") {
+  # The macOS and iOS default linker ld64 does not support reading thin
+  # archives.
+  # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
+  # confuses lldb.
+  if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
+    arflags = [ "-T" ]
+  } else if (is_win && use_lld) {
+    arflags = [ "/llvmlibthin" ]
+  }
+}
+
+# exceptions -------------------------------------------------------------------
+#
+# Allows turning Exceptions on or off.
+# Note: exceptions are disallowed in Google code.
+
+config("exceptions") {
+  if (is_win) {
+    # Enables exceptions in the STL.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=1" ]
+    }
+    cflags_cc = [ "/EHsc" ]
+  } else {
+    cflags_cc = [ "-fexceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+config("no_exceptions") {
+  if (is_win) {
+    # Disables exceptions in the STL.
+    # libc++ uses the __has_feature macro to control whether to use exceptions,
+    # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+    # breaks libc++ because it depends on MSVC headers that only provide certain
+    # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use
+    # exceptions, despite being conditional on _HAS_EXCEPTIONS.
+    if (!use_custom_libcxx) {
+      defines = [ "_HAS_EXCEPTIONS=0" ]
+    }
+  } else {
+    cflags_cc = [ "-fno-exceptions" ]
+    cflags_objcc = cflags_cc
+  }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# Generate a warning for code that might emit a static initializer.
+# See: //docs/static_initializers.md
+# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
+config("wglobal_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wglobal-constructors" ]
+  }
+}
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wexit-time-destructors" ]
+  }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# suppressing the rest of them.  Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+  cflags = []
+  if (is_clang) {
+    cflags += [ "-Wno-incompatible-pointer-types" ]
+  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+    cflags += [ "-w" ]
+  } else if (is_chromeos_ash && current_cpu == "arm") {
+    cflags += [ "-w" ]
+  }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_optimization" ]
+#   configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+  common_optimize_on_cflags = [
+    "/Ob2",  # Both explicit and auto inlining.
+    "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+    "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+  ]
+  if (!is_asan) {
+    common_optimize_on_cflags += [
+      # Put data in separate COMDATs. This allows the linker
+      # to put bit-identical constants at the same address even if
+      # they're unrelated constants, which saves binary size.
+      # This optimization can't be used when ASan is enabled because
+      # it is not compatible with the ASan ODR checker.
+      "/Gw",
+    ]
+  }
+  common_optimize_on_ldflags = []
+
+  # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+  # misleading symbols in stack traces.
+  if (!is_debug && !is_component_build) {
+    common_optimize_on_ldflags += [ "/OPT:ICF" ]  # Redundant COMDAT folding.
+  }
+
+  if (is_official_build) {
+    common_optimize_on_ldflags += [ "/OPT:REF" ]  # Remove unreferenced data.
+    # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
+  }
+} else {
+  common_optimize_on_cflags = []
+  common_optimize_on_ldflags = []
+
+  if (is_android) {
+    # TODO(jdduke) Re-enable on mips after resolving linking
+    # issues with libc++ (crbug.com/456380).
+    if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+      common_optimize_on_ldflags += [
+        # Warn in case of text relocations.
+        "-Wl,--warn-shared-textrel",
+      ]
+    }
+  }
+
+  if (is_apple) {
+    common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+
+    if (is_official_build) {
+      common_optimize_on_ldflags += [
+        "-Wl,-no_data_in_code_info",
+        "-Wl,-no_function_starts",
+      ]
+    }
+  } else if (current_os != "aix" && current_os != "zos") {
+    # Non-Mac Posix flags.
+    # Aix does not support these.
+
+    common_optimize_on_cflags += [
+      # Put data and code in their own sections, so that unused symbols
+      # can be removed at link time with --gc-sections.
+      "-fdata-sections",
+      "-ffunction-sections",
+    ]
+    if ((!is_nacl || is_nacl_saigo) && is_clang) {
+      # We don't care about unique section names, this makes object files a bit
+      # smaller.
+      common_optimize_on_cflags += [ "-fno-unique-section-names" ]
+    }
+
+    common_optimize_on_ldflags += [
+      # Specifically tell the linker to perform optimizations.
+      # See http://lwn.net/Articles/192624/ .
+      # -O2 enables string tail merge optimization in gold and lld.
+      "-Wl,-O2",
+      "-Wl,--gc-sections",
+    ]
+  }
+}
+
+config("default_stack_frames") {
+  if (!is_win) {
+    if (enable_frame_pointers) {
+      cflags = [ "-fno-omit-frame-pointer" ]
+
+      # Omit frame pointers for leaf functions on x86, otherwise building libyuv
+      # gives clang's register allocator issues, see llvm.org/PR15798 /
+      # crbug.com/233709
+      if (is_clang && current_cpu == "x86" && !is_apple) {
+        cflags += [ "-momit-leaf-frame-pointer" ]
+      }
+    } else {
+      cflags = [ "-fomit-frame-pointer" ]
+    }
+  }
+  # On Windows, the flag to enable framepointers "/Oy-" must always come after
+  # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+  # the "optimize" configs, see rest of this file. The ordering that cflags are
+  # applied is well-defined by the GN spec, and there is no way to ensure that
+  # cflags set by "default_stack_frames" is applied after those set by an
+  # "optimize" config. Similarly, there is no way to propagate state from this
+  # config into the "optimize" config. We always apply the "/Oy-" config in the
+  # definition for common_optimize_on_cflags definition, even though this may
+  # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+  if (is_win) {
+    if (chrome_pgo_phase != 2) {
+      # Favor size over speed, /O1 must be before the common flags.
+      # /O1 implies /Os and /GF.
+      cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+      rustflags = [ "-Copt-level=s" ]
+    } else {
+      # PGO requires all translation units to be compiled with /O2. The actual
+      # optimization level will be decided based on the profiling data.
+      cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
+
+      # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
+      # suggests not using an explicit `-Copt-level` at all, and the default is
+      # to optimize for performance like `/O2` for clang.
+      rustflags = []
+    }
+  } else if (optimize_for_size) {
+    # Favor size over speed.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+
+      if (use_ml_inliner && is_a_target_toolchain) {
+        cflags += [
+          "-mllvm",
+          "-enable-ml-inliner=release",
+        ]
+      }
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
+    # vectorization.
+    rustflags = [ "-Copt-level=z" ]
+  } else if (is_chromeos) {
+    # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+    # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+    # any cost" (AKA -Oz). It'd be nice to:
+    # - Make `optimize_for_size` apply to all platforms where we're optimizing
+    #   for size by default (so, also Windows)
+    # - Investigate -Oz here, maybe just for ARM?
+    cflags = [ "-Os" ] + common_optimize_on_cflags
+
+    # Similar to clang, we optimize with `-Copt-level=s` to keep loop
+    # vectorization while otherwise optimizing for size.
+    rustflags = [ "-Copt-level=s" ]
+  } else {
+    cflags = [ "-O2" ] + common_optimize_on_cflags
+
+    # The `-O3` for clang turns on extra optimizations compared to the standard
+    # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
+    # to use.
+    rustflags = [ "-Copt-level=3" ]
+  }
+  ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+  if (is_win) {
+    cflags = [
+      "/Od",  # Disable optimization.
+      "/Ob0",  # Disable all inlining (on by default).
+      "/GF",  # Enable string pooling (off by default).
+    ]
+
+    if (target_cpu == "arm64") {
+      # Disable omitting frame pointers for no_optimize build because stack
+      # traces on Windows ARM64 rely on it.
+      cflags += [ "/Oy-" ]
+    }
+  } else if (is_android && !android_full_debug) {
+    # On Android we kind of optimize some things that don't affect debugging
+    # much even when optimization is disabled to get the binary size down.
+    if (is_clang) {
+      cflags = [ "-Oz" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-Os" ] + common_optimize_on_cflags
+    }
+
+    if (!is_component_build) {
+      # Required for library partitions. Without this all symbols just end up
+      # in the base partition.
+      ldflags = [ "-Wl,--gc-sections" ]
+    }
+  } else if (is_fuchsia) {
+    # On Fuchsia, we optimize for size here to reduce the size of debug build
+    # packages so they can be run in a KVM. See crbug.com/910243 for details.
+    cflags = [ "-Og" ]
+  } else {
+    cflags = [ "-O0" ]
+    ldflags = []
+  }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O2" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # Various components do:
+    #   if (!is_debug) {
+    #     configs -= [ "//build/config/compiler:default_optimization" ]
+    #     configs += [ "//build/config/compiler:optimize_max" ]
+    #   }
+    # So this config has to have the selection logic just like
+    # "default_optimization", below.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else {
+    ldflags = common_optimize_on_ldflags
+    if (is_win) {
+      # Favor speed over size, /O2 must be before the common flags.
+      # /O2 implies /Ot, /Oi, and /GF.
+      cflags = [ "/O2" ] + common_optimize_on_cflags
+    } else if (optimize_for_fuzzing) {
+      cflags = [ "-O1" ] + common_optimize_on_cflags
+    } else {
+      cflags = [ "-O3" ] + common_optimize_on_cflags
+    }
+    rustflags = [ "-Copt-level=3" ]
+  }
+}
+
+config("optimize_fuzzing") {
+  cflags = [ "-O1" ] + common_optimize_on_cflags
+  rustflags = [ "-Copt-level=1" ]
+  ldflags = common_optimize_on_ldflags
+  visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+  if (is_nacl && is_nacl_irt) {
+    # The NaCl IRT is a special case and always wants its own config.
+    # It gets optimized the same way regardless of the type of build.
+    configs = [ "//build/config/nacl:irt_optimize" ]
+  } else if (is_debug) {
+    configs = [ ":no_optimize" ]
+  } else if (optimize_for_fuzzing) {
+    assert(!is_win, "Fuzzing optimize level not supported on Windows")
+
+    # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even
+    # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
+    assert(!use_clang_coverage,
+           "optimize_for_fuzzing=true should not be used with " +
+               "use_clang_coverage=true.")
+    configs = [ ":optimize_fuzzing" ]
+  } else {
+    configs = [ ":optimize" ]
+  }
+}
+
+_clang_sample_profile = ""
+if (is_clang && is_a_target_toolchain) {
+  if (clang_sample_profile_path != "") {
+    _clang_sample_profile = clang_sample_profile_path
+  } else if (clang_use_default_sample_profile) {
+    assert(build_with_chromium,
+           "Our default profiles currently only apply to Chromium")
+    assert(is_android || is_chromeos || is_castos,
+           "The current platform has no default profile")
+    if (is_android || is_castos) {
+      _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+    } else {
+      assert(
+          chromeos_afdo_platform == "atom" ||
+              chromeos_afdo_platform == "bigcore" ||
+              chromeos_afdo_platform == "arm" ||
+              chromeos_afdo_platform == "arm-exp",
+          "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
+      _clang_sample_profile =
+          "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+    }
+  }
+}
+
+# Clang offers a way to assert that AFDO profiles are accurate, which causes it
+# to optimize functions not represented in a profile more aggressively for size.
+# This config can be toggled in cases where shaving off binary size hurts
+# performance too much.
+config("afdo_optimize_size") {
+  if (_clang_sample_profile != "" && sample_profile_is_accurate) {
+    cflags = [ "-fprofile-sample-accurate" ]
+  }
+}
+
+# GCC and clang support a form of profile-guided optimization called AFDO.
+# There are some targeted places that AFDO regresses, so we provide a separate
+# config to allow AFDO to be disabled per-target.
+config("afdo") {
+  if (is_clang) {
+    cflags = []
+    if (clang_emit_debug_info_for_profiling) {
+      # Add the following flags to generate debug info for profiling.
+      cflags += [ "-gline-tables-only" ]
+      if (!is_nacl) {
+        cflags += [ "-fdebug-info-for-profiling" ]
+      }
+    }
+    if (_clang_sample_profile != "") {
+      assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
+      rebased_clang_sample_profile =
+          rebase_path(_clang_sample_profile, root_build_dir)
+      cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+      if (use_profi) {
+        cflags += [ "-fsample-profile-use-profi" ]
+      }
+
+      # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
+      # These seem to be false positives - the complaints are about functions
+      # marked with `__nodebug__` not having associated debuginfo. In the case
+      # where this was observed, the `__nodebug__` function was also marked
+      # `__always_inline__` and had no branches, so AFDO info is likely useless
+      # there.
+      cflags += [ "-Wno-backend-plugin" ]
+      inputs = [ _clang_sample_profile ]
+    }
+  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+    cflags = [ "-fauto-profile=${auto_profile_path}" ]
+    inputs = [ auto_profile_path ]
+  }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+#   configs -= [ "//build/config/compiler:default_symbols" ]
+#   configs += [ "//build/config/compiler:symbols" ]
+
+# A helper config that all configs passing /DEBUG to the linker should
+# include as sub-config.
+config("win_pdbaltpath") {
+  visibility = [
+    ":minimal_symbols",
+    ":symbols",
+  ]
+
+  # /DEBUG causes the linker to generate a pdb file, and to write the absolute
+  # path to it in the executable file it generates.  This flag turns that
+  # absolute path into just the basename of the pdb file, which helps with
+  # build reproducibility. Debuggers look for pdb files next to executables,
+  # so there's minimal downside to always using this. However, post-mortem
+  # debugging of Chromium crash dumps and ETW tracing can be complicated by this
+  # switch so an option to omit it is important.
+  if (!use_full_pdb_paths) {
+    ldflags = [ "/pdbaltpath:%_PDB%" ]
+  }
+}
+
+# Full symbols.
+config("symbols") {
+  rustflags = []
+  if (is_win) {
+    if (is_clang) {
+      cflags = [
+        # Debug information in the .obj files.
+        "/Z7",
+
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    } else {
+      cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue.
+    }
+
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = []
+    if (is_mac && enable_dsyms) {
+      # If generating dSYMs, specify -fno-standalone-debug. This was
+      # originally specified for https://crbug.com/479841 because dsymutil
+      # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+      # version 7 also produces debug data that is incompatible with Breakpad
+      # dump_syms, so this is still required (https://crbug.com/622406).
+      cflags += [ "-fno-standalone-debug" ]
+    }
+
+    # On aix -gdwarf causes linker failures due to thread_local variables.
+    if (!is_nacl && current_os != "aix") {
+      if (use_dwarf5) {
+        cflags += [ "-gdwarf-5" ]
+        rustflags += [ "-Zdwarf-version=5" ]
+      } else {
+        # Recent clang versions default to DWARF5 on Linux, and Android is about
+        # to switch. TODO: Adopt that in controlled way. For now, keep DWARF4.
+        # Apple platforms still default to 4 in clang, so they don't need the
+        # cflags.
+        if (!is_apple) {
+          cflags += [ "-gdwarf-4" ]
+        }
+
+        # On Apple, rustc defaults to DWARF2 so it needs to be told how to
+        # match clang.
+        rustflags += [ "-Zdwarf-version=4" ]
+      }
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if ((!is_nacl || is_nacl_saigo) && current_os != "zos") {
+      cflags += [ "-g2" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
+      # to be manually enabled.
+      #
+      # It is skipped in tsan and asan because enabling it causes some
+      # formatting changes in the output which would require fixing bunches
+      # of expectation regexps.
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    if (is_apple) {
+      swiftflags = [ "-g" ]
+    }
+
+    if (use_debug_fission) {
+      cflags += [ "-gsplit-dwarf" ]
+    }
+    asmflags = cflags
+    ldflags = []
+
+    # Split debug info with all thinlto builds except nacl and apple.
+    # thinlto requires -gsplit-dwarf in ldflags.
+    if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) {
+      ldflags += [ "-gsplit-dwarf" ]
+    }
+
+    # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+    # currently we get "warning:
+    # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+    # DWARF info may be corrupt; offsets in a range list entry are in different
+    # sections" there.  Maybe just a bug in nacl_switch_32.S.
+    _enable_gdb_index =
+        symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" &&
+        current_os != "zos" && (use_gold || use_lld) &&
+        # Disable on non-fission 32-bit Android because it pushes
+        # libcomponents_unittests over the 4gb size limit.
+        !(is_android && !use_debug_fission && current_cpu != "x64" &&
+          current_cpu != "arm64")
+    if (_enable_gdb_index) {
+      if (is_clang) {
+        # This flag enables the GNU-format pubnames and pubtypes sections,
+        # which lld needs in order to generate a correct GDB index.
+        # TODO(pcc): Try to make lld understand non-GNU-format pubnames
+        # sections (llvm.org/PR34820).
+        cflags += [ "-ggnu-pubnames" ]
+      }
+      ldflags += [ "-Wl,--gdb-index" ]
+    }
+  }
+
+  configs = []
+
+  # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
+  # https://b/243982712.
+  if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
+      !is_nacl && current_cpu == "arm") {
+    configs += [ "//build/config:compress_debug_sections" ]
+  }
+
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+    if (is_apple) {
+      # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+      # Make sure we don't use constructor homing on mac.
+      cflags += [
+        "-Xclang",
+        "-debug-info-kind=limited",
+      ]
+    } else {
+      # Use constructor homing for debug info. This option reduces debug info
+      # by emitting class type info only when constructors are emitted.
+      cflags += [
+        "-Xclang",
+        "-fuse-ctor-homing",
+      ]
+    }
+  }
+  rustflags += [ "-g" ]
+}
+
+# Minimal symbols.
+# This config guarantees to hold symbol for stack trace which are shown to user
+# when crash happens in unittests running on buildbot.
+config("minimal_symbols") {
+  rustflags = []
+  if (is_win) {
+    # Functions, files, and line tables only.
+    cflags = []
+
+    if (is_clang) {
+      cflags += [
+        # Disable putting the compiler command line into the debug info to
+        # prevent some types of non-determinism.
+        "-gno-codeview-command-line",
+      ]
+    }
+    if (is_clang && use_lld && use_ghash) {
+      cflags += [ "-gcodeview-ghash" ]
+      ldflags = [ "/DEBUG:GHASH" ]
+    } else {
+      ldflags = [ "/DEBUG" ]
+    }
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+
+    # Enable line tables for clang. MSVC doesn't have an equivalent option.
+    if (is_clang) {
+      # -gline-tables-only is the same as -g1, but clang-cl only exposes the
+      # former.
+      cflags += [ "-gline-tables-only" ]
+    }
+  } else {
+    cflags = []
+    if (is_mac && !use_dwarf5) {
+      # clang defaults to DWARF2 on macOS unless mac_deployment_target is
+      # at least 10.11.
+      # TODO(thakis): Remove this once mac_deployment_target is 10.11.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    } else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
+      # On aix -gdwarf causes linker failures due to thread_local variables.
+      # Recent clang versions default to DWARF5 on Linux, and Android is about
+      # to switch. TODO: Adopt that in controlled way.
+      cflags += [ "-gdwarf-4" ]
+      rustflags += [ "-Zdwarf-version=4" ]
+    }
+
+    if (use_dwarf5 && !is_nacl) {
+      cflags += [ "-gdwarf-5" ]
+      rustflags += [ "-Zdwarf-version=5" ]
+    }
+
+    # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
+    # elsewhere in this file), so they can't have build-dir-independent output.
+    # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
+    # Disable symbols for nacl object files to get deterministic,
+    # build-directory-independent output.
+    # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
+    # part of chromium release (other nacl toolchains are used only for tests).
+    if (!is_nacl || is_nacl_saigo) {
+      cflags += [ "-g1" ]
+    }
+
+    if (!is_nacl && is_clang && !is_tsan && !is_asan) {
+      # See comment for -gdwarf-aranges in config("symbols").
+      cflags += [ "-gdwarf-aranges" ]
+    }
+
+    ldflags = []
+    if (is_android && is_clang) {
+      # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
+      # doesn't emit DW_AT_linkage_name in -g1 builds.
+      # -fdebug-info-for-profiling enables that (and a bunch of other things we
+      # don't need), so that we get qualified names in stacks.
+      # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
+      #               failing that consider doing this on non-Android too.
+      cflags += [ "-fdebug-info-for-profiling" ]
+    }
+
+    asmflags = cflags
+  }
+  rustflags += [ "-Cdebuginfo=1" ]
+}
+
+# This configuration contains function names only. That is, the compiler is
+# told to not generate debug information and the linker then just puts function
+# names in the final debug information.
+config("no_symbols") {
+  if (is_win) {
+    ldflags = [ "/DEBUG" ]
+
+    # All configs using /DEBUG should include this:
+    configs = [ ":win_pdbaltpath" ]
+  } else {
+    cflags = [ "-g0" ]
+    asmflags = cflags
+  }
+}
+
+# Default symbols.
+config("default_symbols") {
+  if (symbol_level == 0) {
+    configs = [ ":no_symbols" ]
+  } else if (symbol_level == 1) {
+    configs = [ ":minimal_symbols" ]
+  } else if (symbol_level == 2) {
+    configs = [ ":symbols" ]
+  } else {
+    assert(false)
+  }
+
+  # This config is removed by base unittests apk.
+  if (is_android && is_clang && strip_debug_info) {
+    configs += [ ":strip_debug" ]
+  }
+}
+
+config("strip_debug") {
+  if (!defined(ldflags)) {
+    ldflags = []
+  }
+  ldflags += [ "-Wl,--strip-debug" ]
+}
+
+if (is_apple) {
+  # On macOS and iOS, this enables support for ARC (automatic reference
+  # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+  #
+  # -fobjc-arc enables ARC overall.
+  #
+  # ARC does not add exception handlers to pure Objective-C code, but does add
+  # them to Objective-C++ code with the rationale that C++ pervasively adds them
+  # in for exception safety. However, exceptions are banned in Chromium code for
+  # C++ and exceptions in Objective-C code are intended to be fatal, so
+  # -fno-objc-arc-exceptions is specified to disable these unwanted exception
+  # handlers.
+  config("enable_arc") {
+    common_flags = [
+      "-fobjc-arc",
+      "-fno-objc-arc-exceptions",
+    ]
+    cflags_objc = common_flags
+    cflags_objcc = common_flags
+  }
+}
+
+if (is_android) {
+  # Use orderfile for linking Chrome on Android.
+  # This config enables using an orderfile for linking in LLD.
+  config("chrome_orderfile_config") {
+    # Don't try to use an orderfile with call graph sorting, except on Android,
+    # where we care about memory used by code, so we still want to mandate
+    # ordering.
+    if (chrome_orderfile_path != "") {
+      assert(use_lld)
+      _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
+      ldflags = [
+        "-Wl,--symbol-ordering-file",
+        "-Wl,$_rebased_orderfile",
+        "-Wl,--no-warn-symbol-ordering",
+      ]
+      inputs = [ chrome_orderfile_path ]
+    }
+  }
+}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+  cflags = []
+  if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+    if (init_stack_vars_zero) {
+      cflags += [ "-ftrivial-auto-var-init=zero" ]
+    } else {
+      cflags += [ "-ftrivial-auto-var-init=pattern" ]
+    }
+  }
+}
+
+buildflag_header("compiler_buildflags") {
+  header = "compiler_buildflags.h"
+
+  flags = [
+    "CLANG_PGO=$chrome_pgo_phase",
+    "SYMBOL_LEVEL=$symbol_level",
+  ]
+}
+
+config("cet_shadow_stack") {
+  if (enable_cet_shadow_stack && is_win) {
+    assert(target_cpu == "x64")
+    ldflags = [ "/CETCOMPAT" ]
+  }
+}
Index: radix-1.9/sources/packages/x/chromium/patches/README
===================================================================
--- radix-1.9/sources/packages/x/chromium/patches/README	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/patches/README	(revision 192)
@@ -0,0 +1,6 @@
+
+/* begin *
+
+   TODO: Leave some comment here.
+
+ * end */
Index: radix-1.9/sources/packages/x/chromium/patches
===================================================================
--- radix-1.9/sources/packages/x/chromium/patches	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/patches	(revision 192)

Property changes on: radix-1.9/sources/packages/x/chromium/patches
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,74 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.rk358x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: radix-1.9/sources/packages/x/chromium
===================================================================
--- radix-1.9/sources/packages/x/chromium	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium	(revision 192)

Property changes on: radix-1.9/sources/packages/x/chromium
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,74 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.rk358x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~