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/123.0.6286.1/Makefile
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/Makefile	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/Makefile	(revision 371)
@@ -0,0 +1,522 @@
+
+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_VISIONFIVE2)
+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            = 123.0.6286.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_S9XX_GLIBC)   \
+                             $(TOOLCHAIN_A311X_GLIBC)  $(TOOLCHAIN_M1000_GLIBC)),)
+target-cpu    = arm64
+target-v8-cpu = arm64
+OPT_PATCHES   = PATCHES.aarch64
+endif
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RK358X_GLIBC)),)
+target-cpu    = arm64
+target-v8-cpu = arm64
+OPT_PATCHES   = PATCHES.rk358x
+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             = 123.0.6286.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) > 4) { $(NUMPROCS) / 4 } else { 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 '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) ; \
+	   MAKEFLAGS= ninja $(NINJA_JOBS) -C $(output_dir) chrome ; \
+	 )
+	# ======= Build Chrome Sandbox =======
+	@( cd $(SRC_DIR) ; \
+	   MAKEFLAGS= ninja $(NINJA_JOBS) -C $(output_dir) chrome_sandbox ; \
+	 )
+	# ======= Build Chrome driver =======
+	@( cd $(SRC_DIR) ; \
+	   MAKEFLAGS= 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)/$(CHROMIUM_PKG_NAME) ; \
+	   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/123.0.6286.1/PATCHES
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES	(revision 371)
@@ -0,0 +1,5 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-cross-compile.patch       -p0
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-dangling-gsl.patch        -p0
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-inc-drop-host-crash.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-oauth2-default.patch      -p0
Index: radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.aarch64
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.aarch64	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.aarch64	(revision 371)
@@ -0,0 +1,3 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-host-pkg-config.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-target-aarch64.patch  -p0
Index: radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.arm
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.arm	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.arm	(revision 371)
@@ -0,0 +1,3 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-host-pkg-config.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-target-arm.patch      -p0
Index: radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.rk358x
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.rk358x	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.rk358x	(revision 371)
@@ -0,0 +1,5 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-host-pkg-config.patch -p0
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-target-aarch64.patch  -p0
+
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-gfx-linux-5.10.patch  -p0
Index: radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.x86_64
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.x86_64	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/PATCHES.x86_64	(revision 371)
@@ -0,0 +1,2 @@
+
+../../../../sources/packages/x/chromium/patches/chromium-123.0.6286.1-target-x86_64.patch   -p0
Index: radix-1.9/X11/app/chromium/123.0.6286.1/chromium-pkg-description.in
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/chromium-pkg-description.in	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/chromium-pkg-description.in	(revision 371)
@@ -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/123.0.6286.1/chromium-pkg-install.sh
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/chromium-pkg-install.sh	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/chromium-pkg-install.sh	(revision 371)
@@ -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/123.0.6286.1/chromium-pkg-install.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.apikeys.sample
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.apikeys.sample	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.apikeys.sample	(revision 371)
@@ -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/123.0.6286.1/scripts/chromium.default
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.default	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.default	(revision 371)
@@ -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/123.0.6286.1/scripts/chromium.in
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.in	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1/scripts/chromium.in	(revision 371)
@@ -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/123.0.6286.1
===================================================================
--- radix-1.9/X11/app/chromium/123.0.6286.1	(nonexistent)
+++ radix-1.9/X11/app/chromium/123.0.6286.1	(revision 371)

Property changes on: radix-1.9/X11/app/chromium/123.0.6286.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/X11/app/libreoffice/24.2.0.3/Makefile
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3/Makefile	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3/Makefile	(revision 371)
@@ -0,0 +1,478 @@
+
+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_VISIONFIVE2)
+COMPONENT_TARGETS += $(HARDWARE_SIFIVE_U740)
+
+
+NEED_ABS_PATH      = true
+COMPONENT_IS_3PP   = true
+
+
+include ../../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES    = sources/packages/x/libreoffice
+
+REQUIRES           = X11/libs/gtk+3/3.24.37
+REQUIRES          += X11/libs/qt5/5.15.8
+REQUIRES          += X11/libs/cairo/1.17.8
+REQUIRES          += X11/libs/pango/1.50.12
+REQUIRES          += X11/libs/poppler/23.02.0
+REQUIRES          += X11/libs/libepoxy/1.5.10
+REQUIRES          += X11/libs/harfbuzz/3.3.1
+REQUIRES          += X11/libs/gst-plugins-base/1.22.0
+REQUIRES          += X11/app/cups-filters/1.28.16
+REQUIRES          += X11/X.org/lib/libXinerama/1.1.5
+REQUIRES          += X11/X.org/lib/libXrandr/1.5.3
+REQUIRES          += X11/X.org/lib/libSM/1.2.4
+REQUIRES          += app/fontconfig/2.13.95
+REQUIRES          += app/sqlite/3.39.4.0
+REQUIRES          += app/postgresql/14.1
+REQUIRES          += app/mariadb/10.6.5
+REQUIRES          += dev/python3/3.10.8
+REQUIRES          += libs/expat/2.5.0
+REQUIRES          += libs/hunspell/1.7.2
+REQUIRES          += libs/hyphen/2.8.8
+REQUIRES          += libs/icu4c/73.1
+REQUIRES          += libs/boost/1.77.0
+REQUIRES          += libs/lcms2/2.14
+REQUIRES          += libs/libxslt/1.1.34
+REQUIRES          += libs/dbus-glib/0.112
+REQUIRES          += net/curl/7.75.0
+REQUIRES          += net/gpgme/1.16.0
+REQUIRES          += net/nss/3.93
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version            = 24.2.0.3
+tar_xz_archive     = $(SRC_PACKAGE_PATH)/packages/x/libreoffice/libreoffice-$(version).tar.xz
+SRC_ARCHIVE        = $(tar_xz_archive)
+SRC_DIR            = $(TARGET_BUILD_DIR)/libreoffice-$(version)
+src_dir_name       = libreoffice-$(version)
+doc_dir_name       = libreoffice-$(version)
+src_done           = $(TARGET_BUILD_DIR)/.source_done
+
+tarballs = $(foreach add, dictionaries help translations, $(addsuffix .tar.xz, $(addprefix libreoffice-$(add)-, $(version))))
+
+
+PATCHES = PATCHES
+
+build_target       = $(TARGET_BUILD_DIR)/.build_done
+configure_target   = $(TARGET_BUILD_DIR)/.configure_done
+external_tarballs  = $(TARGET_BUILD_DIR)/.external_tarballs_done
+install_target     = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = xapp
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+OFFICE_PKG_NAME                = libreoffice
+OFFICE_PKG_VERSION             = 24.2.0.3
+OFFICE_PKG_ARCH                = $(PKGARCH)
+OFFICE_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+OFFICE_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+OFFICE_PKG_GROUP               = $(PKG_GROUP)
+###                             |---handy-ruler-------------------------------|
+OFFICE_PKG_SHORT_DESCRIPTION   = free office suite
+OFFICE_PKG_URL                 = $(BUG_URL)
+OFFICE_PKG_LICENSE             = custom
+OFFICE_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(OFFICE_PKG_NAME)-pkg-description
+OFFICE_PKG_DESCRIPTION_FILE_IN = $(OFFICE_PKG_NAME)-pkg-description.in
+OFFICE_PKG_INSTALL_SCRIPT      = $(OFFICE_PKG_NAME)-pkg-install.sh
+
+OFFICE_PKG       = $(CURDIR)/$(TARGET_BUILD_DIR)/$(OFFICE_PKG_NAME)-package
+
+pkg_basename     = $(OFFICE_PKG_NAME)-$(OFFICE_PKG_VERSION)-$(OFFICE_PKG_ARCH)-$(OFFICE_PKG_DISTRO_NAME)-$(OFFICE_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))
+
+BUILD_TARGETS    = $(build_target)
+BUILD_TARGETS   += $(configure_target)
+BUILD_TARGETS   += $(external_tarballs)
+BUILD_TARGETS   += $(install_target)
+
+PRODUCT_TARGETS  = $(products)
+
+ROOTFS_TARGETS   = $(pkg_archive)
+
+
+include ../../../../build-system/core.mk
+
+
+env_sysroot = DESTDIR=$(OFFICE_PKG)
+
+
+extra_configure_switches  = --libdir=/usr/lib$(LIBSUFFIX)
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --docdir=/usr/share/doc/$(doc_dir_name)
+
+extra_configure_switches += --sysconfdir=/etc
+extra_configure_switches += --localstatedir=/var
+
+extra_configure_switches += --with-extra-buildid='Build for $(DISTRO_SPEC) $(DISTRO_VERSION)'
+extra_configure_switches += --with-vendor='RcL Team (Andrey V.Kosteltsev)'
+
+extra_configure_switches += --without-java
+extra_configure_switches += --without-junit
+
+extra_configure_switches += --enable-dbus
+extra_configure_switches += --enable-epm
+extra_configure_switches += --enable-ext-nlpsolver
+extra_configure_switches += --enable-ext-wiki-publisher
+extra_configure_switches += --enable-odk
+
+extra_configure_switches += --enable-gtk3
+extra_configure_switches += --enable-qt5
+
+extra_configure_switches += --enable-release-build
+extra_configure_switches += --enable-scripting-beanshell
+extra_configure_switches += --enable-scripting-javascript
+extra_configure_switches += --disable-symbols
+extra_configure_switches += --with-external-dict-dir=/usr/share/hunspell
+extra_configure_switches += --with-external-hyph-dir=/usr/share/hyphen
+extra_configure_switches += --with-external-thes-dir=/usr/share/mythes
+extra_configure_switches += --with-fonts
+extra_configure_switches += --with-help=html
+extra_configure_switches += --with-system-expat
+extra_configure_switches += --with-system-cairo
+extra_configure_switches += --with-system-curl
+extra_configure_switches += --with-system-dicts
+extra_configure_switches += --with-system-expat
+extra_configure_switches += --with-system-nss
+extra_configure_switches += --with-system-icu
+extra_configure_switches += --with-system-libxml
+extra_configure_switches += --with-system-zlib
+extra_configure_switches += --with-system-bzip2
+extra_configure_switches += --with-system-jpeg
+extra_configure_switches += --without-system-jars
+extra_configure_switches += --with-system-openjpeg
+extra_configure_switches += --with-system-lcms2
+extra_configure_switches += --with-system-gpgmepp
+extra_configure_switches += --without-system-libcmis
+extra_configure_switches += --without-system-libvisio
+extra_configure_switches += --with-system-openssl
+extra_configure_switches += --with-tls='nss'
+extra_configure_switches += --with-system-poppler
+extra_configure_switches += --with-system-epoxy
+extra_configure_switches += --with-system-libpng
+extra_configure_switches += --with-system-libtiff
+extra_configure_switches += --with-system-libwebp
+extra_configure_switches += --with-system-bluez
+extra_configure_switches += --with-x
+extra_configure_switches += --without-gssapi
+extra_configure_switches += --without-krb5
+extra_configure_switches += --without-myspell-dicts
+extra_configure_switches += --disable-dconf
+
+extra_configure_switches += --enable-pch=no
+extra_configure_switches += --disable-debug
+
+# Skia requires clang:
+extra_configure_switches += --disable-skia
+
+extra_configure_switches += --with-lang='de en-GB en-US es fr it pt ru'
+extra_configure_switches += --with-locales='de en-GB en-US es fr it pt ru'
+
+dictionaries-list = de en es fr it pt-BR pt-PT ru
+
+JOBS := $(shell echo 'if( $(NUMPROCS) > 4) { $(NUMPROCS) / 4 } else { if( $(NUMPROCS) > 2) { $(NUMPROCS) / 2 } else { 1 } }' | bc)
+
+extra_configure_switches += --with-parallelism=$(JOBS)
+
+
+PYTHON_VERSION=3.10
+
+extra_configure_switches += PYTHON_PLATFORM=Linux
+extra_configure_switches += PYTHON_VERSION=$(PYTHON_VERSION)
+
+extra_configure_switches += PYTHON_LIBS="-lpython$(PYTHON_VERSION)"
+extra_configure_switches += PYTHON_CFLAGS="-I$(TARGET_DEST_DIR)/usr/include/python$(PYTHON_VERSION)"
+
+extra_configure_switches += PYTHON_FOR_BUILD=$(PYTHON3)
+
+
+build-configure-switches  = --prefix=/usr
+build-configure-switches += --libdir=/usr/lib$(BUILD_MULTILIB_SUFFIX)
+build-configure-switches += --without-java
+build-configure-switches += --without-junit
+build-configure-switches += --with-system-icu
+build-configure-switches += --with-system-curl
+
+build-configure-switches += PYTHON_PLATFORM=Linux
+build-configure-switches += PYTHON_VERSION=$(PYTHON_VERSION)
+build-configure-switches += PYTHON_LIBS=-lpython$(PYTHON_VERSION)
+build-configure-switches += PYTHON_CFLAGS=-I$(BUILDSYSTEM)/usr/include/python$(PYTHON_VERSION)
+
+build-configure-switches += CC=/usr/bin/gcc
+build-configure-switches += CXX=/usr/bin/g++
+build-configure-switches += CFLAGS=-I/usr/include
+build-configure-switches += CXXFLAGS=-I/usr/include
+build-configure-switches += LDFLAGS=-L/usr/lib$(BUILD_MULTILIB_SUFFIX)
+build-configure-switches += PKG_CONFIG_PATH=/usr/lib$(BUILD_MULTILIB_SUFFIX)/pkgconfig:/usr/share/pkgconfig
+
+extra_configure_switches += --with-build-platform-configure-options='$(build-configure-switches)'
+
+CFLAGS += -Wno-deprecated-declarations -Wno-incompatible-pointer-types
+CFLAGS += -Wno-discarded-qualifiers
+
+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)),)
+LDFLAGS += -Wl,--allow-multiple-definition
+endif
+
+TARGET_LIB_RPATH = /usr/lib:\$$ORIGIN
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+	$(UNPACK_SRC_ARCHIVE)
+	# ======= Extract additional tarballs: =======
+	@for tarball in $(tarballs) ; do \
+	   tar xJf $(SRC_PACKAGE_PATH)/packages/x/libreoffice/$${tarball} -C $(TARGET_BUILD_DIR) ; \
+	 done
+	$(APPLY_PATCHES)
+	@touch $@
+
+$(configure_target): $(src_done)
+	@cd $(SRC_DIR) && \
+	  $(BUILD_ENVIRONMENT) ZIC=/usr/sbin/zic ./autogen.sh \
+	  --prefix=/usr               \
+	  --build=$(BUILD)            \
+	  --host=$(TARGET)            \
+	  $(extra_configure_switches)
+	@touch $@
+
+.NOTPARALLEL: $(external_tarballs)
+
+$(external_tarballs): $(configure_target)
+	@cd $(SRC_DIR) && env -i ZIC=/usr/sbin/zic verbose=t make download
+	# ======= Patch CoinMP (cross MIPS failure): =======
+	@( cd $(SRC_DIR)/external/tarballs ; \
+	   tar -xzf CoinMP-1.8.4.tgz       ; \
+	   rm -f CoinMP-1.8.4.tgz          ; \
+	   sed -i 's,mips,mip,g' CoinMP-1.8.4/Cbc/src/CbcModel.hpp ; \
+	   tar czf CoinMP-1.8.4.tgz CoinMP-1.8.4 ; \
+	   rm -rf CoinMP-1.8.4             ; \
+	 )
+	@touch $@
+
+$(build_target): $(external_tarballs)
+	@cd $(SRC_DIR) && env -i ZIC=/usr/sbin/zic verbose=t make
+	@cd $(SRC_DIR) && env -i ZIC=/usr/sbin/zic verbose=t make -C dictionaries
+	@touch $@
+
+$(install_target): $(build_target)
+	@mkdir -p $(OFFICE_PKG)
+	# ======= Install LibreOffice =======
+	@cd $(SRC_DIR) && env -i make $(env_sysroot) distro-pack-install
+	@( cd $(OFFICE_PKG) ; \
+	   rm -f gid_Module* ; \
+	 )
+	@mkdir -p $(OFFICE_PKG)/usr/share/appdata
+	@install -m644 $(SRC_DIR)/sysui/desktop/appstream-appdata/*.xml $(OFFICE_PKG)/usr/share/appdata/
+	# ======= Improve symbolic links: =======
+	@( cd $(OFFICE_PKG)/usr/bin ; \
+	   rm -f libreoffice soffice ; \
+	   ln -sf ../lib$(LIBSUFFIX)/libreoffice/program/soffice libreoffice ; \
+	   ln -sf ../lib$(LIBSUFFIX)/libreoffice/program/soffice soffice ; \
+	 )
+	@mkdir -p $(OFFICE_PKG)/usr/share/libreoffice/sdk/classes
+	@( cd $(OFFICE_PKG)/usr/lib$(LIBSUFFIX)/libreoffice/sdk ; \
+	   if [ -L classes ] ; then \
+	     rm -f classes ; \
+	     ln -sf ../../../share/libreoffice/sdk/classes classes ; \
+	   fi ; \
+	   if [ -L docs ] ; then \
+	     rm -f docs ; \
+	     ln -sf ../../../share/doc/libreoffice-$(version)/sdk/docs docs ; \
+	   fi ; \
+	   if [ -L idl ] ; then \
+	     rm -f idl ; \
+	     ln -sf ../../../share/idl/libreoffice idl ; \
+	   fi ; \
+	   if [ -L include ] ; then \
+	     rm -f include ; \
+	     ln -sf ../../../include/libreoffice include ; \
+	   fi ; \
+	   if [ -L index.html ] ; then \
+	     rm -f index.html ; \
+	     ln -sf ../../../share/doc/libreoffice-$(version)/sdk/index.html index.html ; \
+	   fi ; \
+	 )
+	@( cd $(OFFICE_PKG)/usr/share/applications ; \
+	   for app in base calc draw impress math startcenter writer xsltfilter ; do \
+	     rm -f libreoffice-$${app}.desktop ; \
+	     ln -sf ../../lib$(LIBSUFFIX)/libreoffice/share/xdg/$${app}.desktop libreoffice-$${app}.desktop ; \
+	   done ; \
+	 )
+	@( cd $(OFFICE_PKG)/usr/share/doc/libreoffice-$(version)/sdk ; \
+	   rm -f examples ; \
+	   ln -sf ../../../../lib$(LIBSUFFIX)/libreoffice/sdk/examples examples ; \
+	 )
+	# ======= Install Dictionaries =======
+	@( cd $(SRC_DIR)/instdir/share/extensions ; \
+	   for lang in $(dictionaries-list) ; do \
+	     cp -a dict-$${lang} $(OFFICE_PKG)/usr/lib$(LIBSUFFIX)/libreoffice/share/extensions/ ; \
+	   done ; \
+	 )
+	# ======= Create aliases for autocorrect locales: =======
+	@( cd $(OFFICE_PKG)/usr/lib$(LIBSUFFIX)/libreoffice/share/autocorr ; \
+	   en_GB_aliases="en-AG en-AU en-BS en-BW en-BZ en-CA en-DK en-GH en-HK en-IE en-IN en-JM en-NG en-NZ en-SG en-TT" ; \
+	   for lang in $${en_GB_aliases} ; do \
+	     ln -sf acor_en-GB.dat acor_$${lang}.dat ; \
+	   done ; \
+	   en_US_aliases="en-PH" ; \
+	   for lang in $${en_US_aliases} ; do \
+	     ln -sf acor_en-US.dat acor_$${lang}.dat ; \
+	   done ; \
+	   en_ZA_aliases="en-NA en-ZW" ; \
+	   for lang in $${en_ZA_aliases} ; do \
+	     ln -sf acor_en-ZA.dat acor_$${lang}.dat ; \
+	   done ; \
+	   af_ZA_aliases="af-NA" ; \
+	   for lang in $${af_ZA_aliases} ; do \
+	     ln -sf acor_af-ZA.dat acor_$${lang}.dat ; \
+	   done ; \
+	   nl_NL_aliases="nl-AW" ; \
+	   for lang in $${nl_NL_aliases} ; do \
+	     ln -sf acor_nl-NL.dat acor_$lang.dat ; \
+	   done ; \
+	   sv_SE_aliases="sv-FI" ; \
+	   for lang in $${sv_SE_aliases} ; do \
+	     ln -sf acor_sv-SE.dat acor_$${lang}.dat ; \
+	   done ; \
+	 )
+	# ======= Install a menu icon for older desktops like XFCE: =======
+	@mkdir -p $(OFFICE_PKG)/usr/share/pixmaps
+	@for file in base calc draw impress math startcenter writer ; do \
+	   ln -s ../icons/hicolor/128x128/apps/libreoffice-$${file}.png $(OFFICE_PKG)/usr/share/pixmaps/ ; \
+	 done ; \
+	# ====== Add the profile scripts: ====== 
+	@mkdir -p $(OFFICE_PKG)/etc/profile.d
+	@cat $(CURDIR)/scripts/libreoffice.csh > $(OFFICE_PKG)/etc/profile.d/libreoffice.csh.new
+	@cat $(CURDIR)/scripts/libreoffice.sh  > $(OFFICE_PKG)/etc/profile.d/libreoffice.sh.new
+	@chmod 755 $(OFFICE_PKG)/etc/profile.d/*
+	# ======= Install Documentation =======
+	@mkdir -p $(OFFICE_PKG)/usr/doc/$(doc_dir_name)
+	@cp -a $(SRC_DIR)/COPYING* \
+	       $(OFFICE_PKG)/usr/doc/$(doc_dir_name)
+	@mkdir -p $(OFFICE_PKG)/usr/share/doc/$(doc_dir_name)
+	@( cd $(SRC_DIR) ; \
+	   cp -a COPYING* README* \
+	         $(OFFICE_PKG)/usr/share/doc/$(doc_dir_name) ; \
+	 )
+	@( cd $(SRC_DIR) ; \
+	   if [ -r ChangeLog -a -s ChangeLog ]; then \
+	     DOCSDIR=`echo $(OFFICE_PKG)/usr/share/doc/$(doc_dir_name)` ; \
+	     cat ChangeLog | head -n 1000 > $${DOCSDIR}/ChangeLog ; \
+	     touch -r ChangeLog $${DOCSDIR}/ChangeLog ; \
+	   fi ; \
+	   for file in dictionaties helpcontent2 translations ; do \
+	     if [ -r ChangeLog-$${file} -a -s ChangeLog-$${file} ]; then \
+	       DOCSDIR=`echo $(OFFICE_PKG)/usr/share/doc/$(doc_dir_name)` ; \
+	       cat ChangeLog-$${file} | head -n 1000 > $${DOCSDIR}/ChangeLog-$${file} ; \
+	       touch -r ChangeLog-$${file} $${DOCSDIR}/ChangeLog-$${file} ; \
+	     fi ; \
+	   done ; \
+	 )
+	# ======= Install the same to $(TARGET_DEST_DIR) =======
+	$(call install-into-devenv, $(OFFICE_PKG))
+	# ======= Strip binaries =======
+	@( cd $(OFFICE_PKG); \
+	   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 ; \
+	 )
+ifneq ($(PATCHELF),)
+	# ======= Set RPATH/RUNPATH for target shared objects =======
+	@( cd $(OFFICE_PKG)/usr/lib$(LIBSUFFIX)/libreoffice/program ; \
+	   for file in `find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(PATCHELF) --print-rpath $$file 2> /dev/null` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(PATCHELF) --set-rpath $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+endif
+	@touch $@
+
+$(OFFICE_PKG_DESCRIPTION_FILE): $(OFFICE_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) $(OFFICE_PKG_DESCRIPTION_FILE) $(OFFICE_PKG_INSTALL_SCRIPT)
+	@cp $(OFFICE_PKG_DESCRIPTION_FILE) $(OFFICE_PKG)/.DESCRIPTION
+	@cp $(OFFICE_PKG_INSTALL_SCRIPT) $(OFFICE_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(OFFICE_PKG)/.REQUIRES
+	@echo "pkgname=$(OFFICE_PKG_NAME)"                            >  $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(OFFICE_PKG_VERSION)"                          >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "arch=$(OFFICE_PKG_ARCH)"                               >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "distroname=$(OFFICE_PKG_DISTRO_NAME)"                  >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "distrover=$(OFFICE_PKG_DISTRO_VERSION)"                >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "group=$(OFFICE_PKG_GROUP)"                             >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(OFFICE_PKG_SHORT_DESCRIPTION)\"" >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "url=$(OFFICE_PKG_URL)"                                 >> $(OFFICE_PKG)/.PKGINFO ; \
+	 echo "license=$(OFFICE_PKG_LICENSE)"                         >> $(OFFICE_PKG)/.PKGINFO
+	@$(PSEUDO) sh -c "cd $(OFFICE_PKG) && \
+	                  chown -R root:root . && \
+	                  $(MAKE_PACKAGE) -J --linkadd=yes $(GNUPG_OPTIONS) -m -d .. ."
Index: radix-1.9/X11/app/libreoffice/24.2.0.3/PATCHES
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3/PATCHES	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3/PATCHES	(revision 371)
@@ -0,0 +1,3 @@
+
+../../../../sources/packages/x/libreoffice/patches/libreoffice-24.2.0.3-isystem.patch -p0
+../../../../sources/packages/x/libreoffice/patches/libreoffice-24.2.0.3-odk-idl.patch -p0
Index: radix-1.9/X11/app/libreoffice/24.2.0.3/libreoffice-pkg-description.in
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3/libreoffice-pkg-description.in	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3/libreoffice-pkg-description.in	(revision 371)
@@ -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------------------------------------------------------|
+libreoffice: libreoffice @VERSION@ (free office suite)
+libreoffice:
+libreoffice: LibreOffice is an Open Source, community-developed, office
+libreoffice: productivity suite. It includes key desktop applications, such
+libreoffice: as a word processor, spreadsheet, presentation manager, formula
+libreoffice: editor and drawing program, with a user interface and feature
+libreoffice: set similar to other office suites.
+libreoffice:
+libreoffice: LibreOffice home: https://www.documentfoundation.org/
+libreoffice:
+libreoffice:
Index: radix-1.9/X11/app/libreoffice/24.2.0.3/libreoffice-pkg-install.sh
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3/libreoffice-pkg-install.sh	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3/libreoffice-pkg-install.sh	(revision 371)
@@ -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/profile.d/libreoffice.csh.new
+  install_file etc/profile.d/libreoffice.sh.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/libreoffice/24.2.0.3/libreoffice-pkg-install.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/X11/app/libreoffice/24.2.0.3/scripts/libreoffice.csh
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3/scripts/libreoffice.csh	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3/scripts/libreoffice.csh	(revision 371)
@@ -0,0 +1,9 @@
+#!/bin/csh
+
+# To force the use of a certain VCL UI interface, use one of these envvars.
+#setenv SAL_USE_VCLPLUGIN gen
+#setenv SAL_USE_VCLPLUGIN gtk3
+#setenv SAL_USE_VCLPLUGIN=gtk3_kde5
+#setenv SAL_USE_VCLPLUGIN=kf5
+#setenv SAL_USE_VCLPLUGIN=qt5
+
Index: radix-1.9/X11/app/libreoffice/24.2.0.3/scripts/libreoffice.sh
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3/scripts/libreoffice.sh	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3/scripts/libreoffice.sh	(revision 371)
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# To force the use of a certain VCL UI interface, use one of these envvars.
+#export SAL_USE_VCLPLUGIN=gen
+#export SAL_USE_VCLPLUGIN=gtk3
+#export SAL_USE_VCLPLUGIN=gtk3_kde5
+#export SAL_USE_VCLPLUGIN=kf5
+#export SAL_USE_VCLPLUGIN=qt5
Index: radix-1.9/X11/app/libreoffice/24.2.0.3
===================================================================
--- radix-1.9/X11/app/libreoffice/24.2.0.3	(nonexistent)
+++ radix-1.9/X11/app/libreoffice/24.2.0.3	(revision 371)

Property changes on: radix-1.9/X11/app/libreoffice/24.2.0.3
___________________________________________________________________
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 370)
+++ radix-1.9/products/X11/Makefile	(revision 371)
@@ -922,7 +922,7 @@
 REQUIRES += X11/app/pcmanfm/1.3.2
 REQUIRES += X11/app/firefox/118.0.1
 REQUIRES += X11/app/thunderbird/115.3.1
-REQUIRES += X11/app/libreoffice/7.6.2.1
+REQUIRES += X11/app/libreoffice/24.2.0.3
 
 ifeq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_A1X_GLIBC)      $(TOOLCHAIN_A2X_GLIBC)      \
                             $(TOOLCHAIN_H5_GLIBC)                                   \
@@ -931,7 +931,7 @@
                             $(TOOLCHAIN_POWER8LE_GLIBC) $(TOOLCHAIN_POWER9LE_GLIBC) \
                             $(TOOLCHAIN_RISCV64_GLIBC)                              \
                             $(TOOLCHAIN_I586_GLIBC)     $(TOOLCHAIN_I686_GLIBC)),)
-REQUIRES += X11/app/chromium/119.0.6026.1
+REQUIRES += X11/app/chromium/123.0.6286.1
 endif
 
 
Index: radix-1.9/sources/packages/x/chromium/Makefile
===================================================================
--- radix-1.9/sources/packages/x/chromium/Makefile	(revision 370)
+++ radix-1.9/sources/packages/x/chromium/Makefile	(revision 371)
@@ -7,10 +7,20 @@
 
 url         = $(DOWNLOAD_SERVER)/sources/packages/x/fontconfig
 
-versions    = 119.0.6026.1
+versions    = 123.0.6286.1 119.0.6026.1
 pkgname     = chromium
 
-patches     = $(CURDIR)/patches/chromium-119.0.6026.1-cross-compile.patch
+patches     = $(CURDIR)/patches/chromium-123.0.6286.1-cross-compile.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-dangling-gsl.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-host-pkg-config.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-inc-drop-host-crash.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-oauth2-default.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-gfx-linux-5.10.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-target-aarch64.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-target-arm.patch
+patches    += $(CURDIR)/patches/chromium-123.0.6286.1-target-x86_64.patch
+
+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
@@ -34,6 +44,15 @@
 
 $(patches):
 	@echo -e "\n======= Create Patches =======\n" ; \
+	 ( cd create-123.0.6286.1-cross-compile-patch       ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-dangling-gsl-patch        ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-host-pkg-config-patch     ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-inc-drop-host-crash-patch ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-oauth2-default-patch      ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-gfx-linux-5.10-patch      ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-target-aarch64-patch      ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-target-arm-patch          ; ./create.patch.sh ) ; \
+	 ( cd create-123.0.6286.1-target-x86_64-patch       ; ./create.patch.sh ) ; \
 	 ( 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 ) ; \
Index: radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-cross-compile.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-cross-compile-patch/src/build/toolchain/linux/unbundle/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/src/build/toolchain/linux/unbundle/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/src/build/toolchain/linux/unbundle/BUILD.gn	(revision 371)
@@ -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-123.0.6286.1-cross-compile-patch/src-orig/build/toolchain/linux/unbundle/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/src-orig/build/toolchain/linux/unbundle/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-cross-compile-patch/src-orig/build/toolchain/linux/unbundle/BUILD.gn	(revision 371)
@@ -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-123.0.6286.1-dangling-gsl-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-dangling-gsl-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-dangling-gsl-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-dangling-gsl.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-dangling-gsl-patch/src/ui/accessibility/platform/ax_platform_node_auralinux.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-dangling-gsl-patch/src/ui/accessibility/platform/ax_platform_node_auralinux.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-dangling-gsl-patch/src/ui/accessibility/platform/ax_platform_node_auralinux.cc	(revision 371)
@@ -0,0 +1,5096 @@
+// 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.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() &&
+      !AXPlatform::GetInstance().GetMode().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:
+    case ax::mojom::Role::kDisclosureTriangleGrouped:
+      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() {
+  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-123.0.6286.1-dangling-gsl-patch/src-orig/ui/accessibility/platform/ax_platform_node_auralinux.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-dangling-gsl-patch/src-orig/ui/accessibility/platform/ax_platform_node_auralinux.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-dangling-gsl-patch/src-orig/ui/accessibility/platform/ax_platform_node_auralinux.cc	(revision 371)
@@ -0,0 +1,5096 @@
+// 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.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() &&
+      !AXPlatform::GetInstance().GetMode().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:
+    case ax::mojom::Role::kDisclosureTriangleGrouped:
+      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() {
+  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-123.0.6286.1-gfx-linux-5.10-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-gfx-linux-5.10.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-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-123.0.6286.1-gfx-linux-5.10-patch/src/ui/gfx/linux/dmabuf_uapi.h
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/src/ui/gfx/linux/dmabuf_uapi.h	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/src/ui/gfx/linux/dmabuf_uapi.h	(revision 371)
@@ -0,0 +1,48 @@
+// Copyright 2023 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_GFX_LINUX_DMABUF_UAPI_H_
+#define UI_GFX_LINUX_DMABUF_UAPI_H_
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+#include <linux/dma-buf.h>
+#else
+#include <linux/types.h>
+
+struct dma_buf_sync {
+  __u64 flags;
+};
+
+constexpr __u64 DMA_BUF_SYNC_READ = 1 << 0;
+constexpr __u64 DMA_BUF_SYNC_WRITE = 2 << 0;
+constexpr __u64 DMA_BUF_SYNC_RW = DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE;
+
+constexpr __u64 DMA_BUF_SYNC_START = 0 << 2;
+constexpr __u64 DMA_BUF_SYNC_END = 1 << 2;
+
+constexpr char DMA_BUF_BASE = 'b';
+constexpr unsigned long DMA_BUF_IOCTL_SYNC =
+    _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0)
+struct dma_buf_export_sync_file {
+  __u32 flags;
+  __s32 fd;
+};
+
+struct dma_buf_import_sync_file {
+  __u32 flags;
+  __s32 fd;
+};
+
+constexpr unsigned long DMA_BUF_IOCTL_EXPORT_SYNC_FILE =
+    _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file);
+constexpr unsigned long DMA_BUF_IOCTL_IMPORT_SYNC_FILE =
+    _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file);
+#endif
+
+#endif  // UI_GFX_LINUX_DMABUF_UAPI_H_
Index: radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/src-orig/ui/gfx/linux/dmabuf_uapi.h
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/src-orig/ui/gfx/linux/dmabuf_uapi.h	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-gfx-linux-5.10-patch/src-orig/ui/gfx/linux/dmabuf_uapi.h	(revision 371)
@@ -0,0 +1,48 @@
+// Copyright 2023 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_GFX_LINUX_DMABUF_UAPI_H_
+#define UI_GFX_LINUX_DMABUF_UAPI_H_
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+#include <linux/dma-buf.h>
+#else
+#include <linux/types.h>
+
+struct dma_buf_sync {
+  __u64 flags;
+};
+
+constexpr __u64 DMA_BUF_SYNC_READ = 1 << 0;
+constexpr __u64 DMA_BUF_SYNC_WRITE = 2 << 0;
+constexpr __u64 DMA_BUF_SYNC_RW = DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE;
+
+constexpr __u64 DMA_BUF_SYNC_START = 0 << 2;
+constexpr __u64 DMA_BUF_SYNC_END = 1 << 2;
+
+constexpr char DMA_BUF_BASE = 'b';
+constexpr unsigned long DMA_BUF_IOCTL_SYNC =
+    _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
+struct dma_buf_export_sync_file {
+  __u32 flags;
+  __s32 fd;
+};
+
+struct dma_buf_import_sync_file {
+  __u32 flags;
+  __s32 fd;
+};
+
+constexpr unsigned long DMA_BUF_IOCTL_EXPORT_SYNC_FILE =
+    _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file);
+constexpr unsigned long DMA_BUF_IOCTL_IMPORT_SYNC_FILE =
+    _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file);
+#endif
+
+#endif  // UI_GFX_LINUX_DMABUF_UAPI_H_
Index: radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-host-pkg-config.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-host-pkg-config-patch/src/build/config/linux/pkg_config.gni
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/src/build/config/linux/pkg_config.gni	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/src/build/config/linux/pkg_config.gni	(revision 371)
@@ -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]) {
+      # We want the system include paths to use -isystem instead of -I to
+      # suppress warnings in those headers.
+      if (use_sysroot) {
+        include_relativized = rebase_path(include, root_build_dir)
+        cflags += [ "-isystem$include_relativized" ]
+      } else {
+        cflags += [ "-isystem$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-123.0.6286.1-host-pkg-config-patch/src-orig/build/config/linux/pkg_config.gni
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/src-orig/build/config/linux/pkg_config.gni	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-host-pkg-config-patch/src-orig/build/config/linux/pkg_config.gni	(revision 371)
@@ -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]) {
+      # We want the system include paths to use -isystem instead of -I to
+      # suppress warnings in those headers.
+      if (use_sysroot) {
+        include_relativized = rebase_path(include, root_build_dir)
+        cflags += [ "-isystem$include_relativized" ]
+      } else {
+        cflags += [ "-isystem$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-123.0.6286.1-inc-drop-host-crash-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-inc-drop-host-crash-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-inc-drop-host-crash-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-inc-drop-host-crash.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-inc-drop-host-crash-patch/src/ui/views/animation/ink_drop_host.h
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-inc-drop-host-crash-patch/src/ui/views/animation/ink_drop_host.h	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-inc-drop-host-crash-patch/src/ui/views/animation/ink_drop_host.h	(revision 371)
@@ -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-123.0.6286.1-inc-drop-host-crash-patch/src-orig/ui/views/animation/ink_drop_host.h
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-inc-drop-host-crash-patch/src-orig/ui/views/animation/ink_drop_host.h	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-inc-drop-host-crash-patch/src-orig/ui/views/animation/ink_drop_host.h	(revision 371)
@@ -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-123.0.6286.1-oauth2-default-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-oauth2-default-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-oauth2-default-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-oauth2-default.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-oauth2-default-patch/src/google_apis/google_api_keys.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-oauth2-default-patch/src/google_apis/google_api_keys.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-oauth2-default-patch/src/google_apis/google_api_keys.cc	(revision 371)
@@ -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-123.0.6286.1-oauth2-default-patch/src-orig/google_apis/google_api_keys.cc
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-oauth2-default-patch/src-orig/google_apis/google_api_keys.cc	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-oauth2-default-patch/src-orig/google_apis/google_api_keys.cc	(revision 371)
@@ -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-123.0.6286.1-target-aarch64-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-aarch64-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-aarch64-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-target-aarch64.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-target-aarch64-patch/src/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-aarch64-patch/src/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-aarch64-patch/src/build/config/compiler/BUILD.gn	(revision 371)
@@ -0,0 +1,3032 @@
+# 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/pch.gni")
+import("//build/config/rust.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/cros/cros_config.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 = ""
+
+  # Optimize for coverage guided fuzzing (balance between speed and number of
+  # branches)
+  optimize_for_fuzzing = false
+
+  # 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
+
+  # Whether to enable thin lto incremental builds.
+  # See: https://clang.llvm.org/docs/ThinLTO.html#incremental
+  # The cache can lead to non-determinism: https://crbug.com/1486045
+  thin_lto_enable_cache = true
+
+  # 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.
+  #
+  # Flag discussion: https://crbug.com/977230
+  #
+  # 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" ]
+    }
+
+    # dsymutil is not available in the system, on bots, for rustc to call. Our
+    # linker_driver.py script runs dsymutil itself, which is set to be the
+    # linker for Rust targets as well.
+    rustflags += [ "-Csplit-debuginfo=unpacked" ]
+  }
+
+  # 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/1488374): This causes binary size growth and potentially
+    # other problems.
+    # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version.
+    if (default_toolchain != "//build/toolchain/cros:target" &&
+        !llvm_android_mainline) {
+      cflags += [
+        "-mllvm",
+        "-split-threshold-for-reg-with-hint=0",
+      ]
+      if (use_thin_lto && is_a_target_toolchain) {
+        if (is_win) {
+          ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
+        } else {
+          ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=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) {
+      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",
+    ]
+
+    if (thin_lto_enable_cache) {
+      # 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"
+      cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+      if (is_win) {
+        ldflags += [
+          "/lldltocache:$cache_dir",
+          "/lldltocachepolicy:$cache_policy",
+        ]
+      } else {
+        if (is_apple) {
+          ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
+        } else {
+          ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
+        }
+        ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+      }
+    }
+
+    # 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",
+        "-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_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_apple) {
+        ldflags += [ "-Wcrl,object_path_lto" ]
+      }
+
+      # 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" ]
+      if (use_lld && is_mac) {
+        ldflags += [ "-Wl,--time-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 || !toolchain_supports_rust_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_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" ]
+    }
+  } else {
+    defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
+  }
+}
+
+# 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" ]
+  }
+
+  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",
+      ]
+
+      # Minimum SIMD support for devices running lacros.
+      # See https://crbug.com/1475858
+      if (is_chromeos_lacros) {
+        cflags += [
+          "-mssse3",
+          "-msse4",
+          "-msse4.1",
+          "-msse4.2",
+        ]
+      }
+      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_android) && !is_nacl) {
+      # 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",
+
+        # 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",
+
+        # TODO(https://crbug.com/1491833): Fix and re-enable.
+        "-Wno-invalid-offsetof",
+
+        # TODO(crbug.com/1494809): Evaluate and possibly enable.
+        "-Wno-vla-extension",
+
+        # TODO(https://crbug.com/1490607): Fix and re-enable.
+        "-Wno-thread-safety-reference-return",
+      ]
+
+      if (!is_nacl) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1513724): Fix and re-enable.
+          "-Wno-c++11-narrowing-const-reference",
+        ]
+      }
+    }
+
+    # 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",
+      ]
+    }
+  }
+}
+
+# unsafe_buffer_warning -------------------------------------------------------
+
+# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
+# have been unable to fix yet. We use this list to be able to make progress and
+# enable the warning on code that we do control/own.
+#
+# WARNING: This will disable all warnings in the files. ONLY USE THIS for
+# third-party code which we do not control/own. Fix the warnings instead in
+# our own code.
+if (is_clang) {
+  unsafe_buffer_warning_header_allowlist =
+      [ "third_party/googletest/src/googletest/include/gtest" ]
+}
+
+# Enables warnings on pointer arithmetic/indexing or calls to functions
+# annotated with `UNSAFE_BUFFER_USAGE`.
+config("unsafe_buffer_warning") {
+  if (is_clang) {
+    cflags = [ "-Wunsafe-buffer-usage" ]
+    foreach(h, unsafe_buffer_warning_header_allowlist) {
+      if (is_win) {
+        cflags += [ "/clang:--system-header-prefix=$h" ]
+      } else {
+        cflags += [ "--system-header-prefix=$h" ]
+      }
+    }
+  }
+}
+
+# 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's toolchain supports a high-quality _FORTIFY_SOURCE=3
+      # implementation with a few custom glibc patches. Use that if it's
+      # available.
+      if (is_chromeos_device && !lacros_use_chromium_toolchain) {
+        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
+  }
+
+  if (is_clang) {
+    # See below.
+    common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
+  }
+} 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",
+    ]
+  }
+
+  # We cannot rely on errno being set after math functions,
+  # especially since glibc does not set it. Thus, use -fno-math-errno
+  # so that the compiler knows it can inline math functions.
+  # Note that this is different from -ffast-math (even though -ffast-math
+  # implies -fno-math-errno), which also allows a number of unsafe
+  # optimizations.
+  common_optimize_on_cflags += [ "-fno-math-errno" ]
+}
+
+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-123.0.6286.1-target-aarch64-patch/src-orig/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-aarch64-patch/src-orig/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-aarch64-patch/src-orig/build/config/compiler/BUILD.gn	(revision 371)
@@ -0,0 +1,3032 @@
+# 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/pch.gni")
+import("//build/config/rust.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/cros/cros_config.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 = ""
+
+  # Optimize for coverage guided fuzzing (balance between speed and number of
+  # branches)
+  optimize_for_fuzzing = false
+
+  # 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
+
+  # Whether to enable thin lto incremental builds.
+  # See: https://clang.llvm.org/docs/ThinLTO.html#incremental
+  # The cache can lead to non-determinism: https://crbug.com/1486045
+  thin_lto_enable_cache = true
+
+  # 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.
+  #
+  # Flag discussion: https://crbug.com/977230
+  #
+  # 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" ]
+    }
+
+    # dsymutil is not available in the system, on bots, for rustc to call. Our
+    # linker_driver.py script runs dsymutil itself, which is set to be the
+    # linker for Rust targets as well.
+    rustflags += [ "-Csplit-debuginfo=unpacked" ]
+  }
+
+  # 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/1488374): This causes binary size growth and potentially
+    # other problems.
+    # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version.
+    if (default_toolchain != "//build/toolchain/cros:target" &&
+        !llvm_android_mainline) {
+      cflags += [
+        "-mllvm",
+        "-split-threshold-for-reg-with-hint=0",
+      ]
+      if (use_thin_lto && is_a_target_toolchain) {
+        if (is_win) {
+          ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
+        } else {
+          ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=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) {
+      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",
+    ]
+
+    if (thin_lto_enable_cache) {
+      # 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"
+      cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+      if (is_win) {
+        ldflags += [
+          "/lldltocache:$cache_dir",
+          "/lldltocachepolicy:$cache_policy",
+        ]
+      } else {
+        if (is_apple) {
+          ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
+        } else {
+          ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
+        }
+        ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+      }
+    }
+
+    # 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",
+        "-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_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_apple) {
+        ldflags += [ "-Wcrl,object_path_lto" ]
+      }
+
+      # 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" ]
+      if (use_lld && is_mac) {
+        ldflags += [ "-Wl,--time-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 || !toolchain_supports_rust_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_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" ]
+    }
+  } else {
+    defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
+  }
+}
+
+# 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" ]
+  }
+
+  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",
+      ]
+
+      # Minimum SIMD support for devices running lacros.
+      # See https://crbug.com/1475858
+      if (is_chromeos_lacros) {
+        cflags += [
+          "-mssse3",
+          "-msse4",
+          "-msse4.1",
+          "-msse4.2",
+        ]
+      }
+      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_android) && !is_nacl) {
+      # 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",
+
+        # 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",
+
+        # TODO(https://crbug.com/1491833): Fix and re-enable.
+        "-Wno-invalid-offsetof",
+
+        # TODO(crbug.com/1494809): Evaluate and possibly enable.
+        "-Wno-vla-extension",
+
+        # TODO(https://crbug.com/1490607): Fix and re-enable.
+        "-Wno-thread-safety-reference-return",
+      ]
+
+      if (!is_nacl) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1513724): Fix and re-enable.
+          "-Wno-c++11-narrowing-const-reference",
+        ]
+      }
+    }
+
+    # 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",
+      ]
+    }
+  }
+}
+
+# unsafe_buffer_warning -------------------------------------------------------
+
+# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
+# have been unable to fix yet. We use this list to be able to make progress and
+# enable the warning on code that we do control/own.
+#
+# WARNING: This will disable all warnings in the files. ONLY USE THIS for
+# third-party code which we do not control/own. Fix the warnings instead in
+# our own code.
+if (is_clang) {
+  unsafe_buffer_warning_header_allowlist =
+      [ "third_party/googletest/src/googletest/include/gtest" ]
+}
+
+# Enables warnings on pointer arithmetic/indexing or calls to functions
+# annotated with `UNSAFE_BUFFER_USAGE`.
+config("unsafe_buffer_warning") {
+  if (is_clang) {
+    cflags = [ "-Wunsafe-buffer-usage" ]
+    foreach(h, unsafe_buffer_warning_header_allowlist) {
+      if (is_win) {
+        cflags += [ "/clang:--system-header-prefix=$h" ]
+      } else {
+        cflags += [ "--system-header-prefix=$h" ]
+      }
+    }
+  }
+}
+
+# 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's toolchain supports a high-quality _FORTIFY_SOURCE=3
+      # implementation with a few custom glibc patches. Use that if it's
+      # available.
+      if (is_chromeos_device && !lacros_use_chromium_toolchain) {
+        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
+  }
+
+  if (is_clang) {
+    # See below.
+    common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
+  }
+} 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",
+    ]
+  }
+
+  # We cannot rely on errno being set after math functions,
+  # especially since glibc does not set it. Thus, use -fno-math-errno
+  # so that the compiler knows it can inline math functions.
+  # Note that this is different from -ffast-math (even though -ffast-math
+  # implies -fno-math-errno), which also allows a number of unsafe
+  # optimizations.
+  common_optimize_on_cflags += [ "-fno-math-errno" ]
+}
+
+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-123.0.6286.1-target-arm-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-arm-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-arm-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-target-arm.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-target-arm-patch/src/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-arm-patch/src/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-arm-patch/src/build/config/compiler/BUILD.gn	(revision 371)
@@ -0,0 +1,3032 @@
+# 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/pch.gni")
+import("//build/config/rust.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/cros/cros_config.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 = ""
+
+  # Optimize for coverage guided fuzzing (balance between speed and number of
+  # branches)
+  optimize_for_fuzzing = false
+
+  # 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
+
+  # Whether to enable thin lto incremental builds.
+  # See: https://clang.llvm.org/docs/ThinLTO.html#incremental
+  # The cache can lead to non-determinism: https://crbug.com/1486045
+  thin_lto_enable_cache = true
+
+  # 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.
+  #
+  # Flag discussion: https://crbug.com/977230
+  #
+  # 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" ]
+    }
+
+    # dsymutil is not available in the system, on bots, for rustc to call. Our
+    # linker_driver.py script runs dsymutil itself, which is set to be the
+    # linker for Rust targets as well.
+    rustflags += [ "-Csplit-debuginfo=unpacked" ]
+  }
+
+  # 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/1488374): This causes binary size growth and potentially
+    # other problems.
+    # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version.
+    if (default_toolchain != "//build/toolchain/cros:target" &&
+        !llvm_android_mainline) {
+      cflags += [
+        "-mllvm",
+        "-split-threshold-for-reg-with-hint=0",
+      ]
+      if (use_thin_lto && is_a_target_toolchain) {
+        if (is_win) {
+          ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
+        } else {
+          ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=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) {
+      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",
+    ]
+
+    if (thin_lto_enable_cache) {
+      # 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"
+      cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+      if (is_win) {
+        ldflags += [
+          "/lldltocache:$cache_dir",
+          "/lldltocachepolicy:$cache_policy",
+        ]
+      } else {
+        if (is_apple) {
+          ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
+        } else {
+          ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
+        }
+        ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+      }
+    }
+
+    # 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",
+        "-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_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_apple) {
+        ldflags += [ "-Wcrl,object_path_lto" ]
+      }
+
+      # 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" ]
+      if (use_lld && is_mac) {
+        ldflags += [ "-Wl,--time-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 || !toolchain_supports_rust_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_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" ]
+    }
+  } else {
+    defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
+  }
+}
+
+# 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" ]
+  }
+
+  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",
+      ]
+
+      # Minimum SIMD support for devices running lacros.
+      # See https://crbug.com/1475858
+      if (is_chromeos_lacros) {
+        cflags += [
+          "-mssse3",
+          "-msse4",
+          "-msse4.1",
+          "-msse4.2",
+        ]
+      }
+      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_android) && !is_nacl) {
+      # 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",
+
+        # 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",
+
+        # TODO(https://crbug.com/1491833): Fix and re-enable.
+        "-Wno-invalid-offsetof",
+
+        # TODO(crbug.com/1494809): Evaluate and possibly enable.
+        "-Wno-vla-extension",
+
+        # TODO(https://crbug.com/1490607): Fix and re-enable.
+        "-Wno-thread-safety-reference-return",
+      ]
+
+      if (!is_nacl) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1513724): Fix and re-enable.
+          "-Wno-c++11-narrowing-const-reference",
+        ]
+      }
+    }
+
+    # 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",
+      ]
+    }
+  }
+}
+
+# unsafe_buffer_warning -------------------------------------------------------
+
+# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
+# have been unable to fix yet. We use this list to be able to make progress and
+# enable the warning on code that we do control/own.
+#
+# WARNING: This will disable all warnings in the files. ONLY USE THIS for
+# third-party code which we do not control/own. Fix the warnings instead in
+# our own code.
+if (is_clang) {
+  unsafe_buffer_warning_header_allowlist =
+      [ "third_party/googletest/src/googletest/include/gtest" ]
+}
+
+# Enables warnings on pointer arithmetic/indexing or calls to functions
+# annotated with `UNSAFE_BUFFER_USAGE`.
+config("unsafe_buffer_warning") {
+  if (is_clang) {
+    cflags = [ "-Wunsafe-buffer-usage" ]
+    foreach(h, unsafe_buffer_warning_header_allowlist) {
+      if (is_win) {
+        cflags += [ "/clang:--system-header-prefix=$h" ]
+      } else {
+        cflags += [ "--system-header-prefix=$h" ]
+      }
+    }
+  }
+}
+
+# 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's toolchain supports a high-quality _FORTIFY_SOURCE=3
+      # implementation with a few custom glibc patches. Use that if it's
+      # available.
+      if (is_chromeos_device && !lacros_use_chromium_toolchain) {
+        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
+  }
+
+  if (is_clang) {
+    # See below.
+    common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
+  }
+} 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",
+    ]
+  }
+
+  # We cannot rely on errno being set after math functions,
+  # especially since glibc does not set it. Thus, use -fno-math-errno
+  # so that the compiler knows it can inline math functions.
+  # Note that this is different from -ffast-math (even though -ffast-math
+  # implies -fno-math-errno), which also allows a number of unsafe
+  # optimizations.
+  common_optimize_on_cflags += [ "-fno-math-errno" ]
+}
+
+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-123.0.6286.1-target-arm-patch/src-orig/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-arm-patch/src-orig/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-arm-patch/src-orig/build/config/compiler/BUILD.gn	(revision 371)
@@ -0,0 +1,3032 @@
+# 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/pch.gni")
+import("//build/config/rust.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/cros/cros_config.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 = ""
+
+  # Optimize for coverage guided fuzzing (balance between speed and number of
+  # branches)
+  optimize_for_fuzzing = false
+
+  # 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
+
+  # Whether to enable thin lto incremental builds.
+  # See: https://clang.llvm.org/docs/ThinLTO.html#incremental
+  # The cache can lead to non-determinism: https://crbug.com/1486045
+  thin_lto_enable_cache = true
+
+  # 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.
+  #
+  # Flag discussion: https://crbug.com/977230
+  #
+  # 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" ]
+    }
+
+    # dsymutil is not available in the system, on bots, for rustc to call. Our
+    # linker_driver.py script runs dsymutil itself, which is set to be the
+    # linker for Rust targets as well.
+    rustflags += [ "-Csplit-debuginfo=unpacked" ]
+  }
+
+  # 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/1488374): This causes binary size growth and potentially
+    # other problems.
+    # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version.
+    if (default_toolchain != "//build/toolchain/cros:target" &&
+        !llvm_android_mainline) {
+      cflags += [
+        "-mllvm",
+        "-split-threshold-for-reg-with-hint=0",
+      ]
+      if (use_thin_lto && is_a_target_toolchain) {
+        if (is_win) {
+          ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
+        } else {
+          ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=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) {
+      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",
+    ]
+
+    if (thin_lto_enable_cache) {
+      # 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"
+      cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+      if (is_win) {
+        ldflags += [
+          "/lldltocache:$cache_dir",
+          "/lldltocachepolicy:$cache_policy",
+        ]
+      } else {
+        if (is_apple) {
+          ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
+        } else {
+          ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
+        }
+        ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+      }
+    }
+
+    # 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",
+        "-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_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_apple) {
+        ldflags += [ "-Wcrl,object_path_lto" ]
+      }
+
+      # 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" ]
+      if (use_lld && is_mac) {
+        ldflags += [ "-Wl,--time-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 || !toolchain_supports_rust_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_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" ]
+    }
+  } else {
+    defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
+  }
+}
+
+# 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" ]
+  }
+
+  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",
+      ]
+
+      # Minimum SIMD support for devices running lacros.
+      # See https://crbug.com/1475858
+      if (is_chromeos_lacros) {
+        cflags += [
+          "-mssse3",
+          "-msse4",
+          "-msse4.1",
+          "-msse4.2",
+        ]
+      }
+      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_android) && !is_nacl) {
+      # 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",
+
+        # 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",
+
+        # TODO(https://crbug.com/1491833): Fix and re-enable.
+        "-Wno-invalid-offsetof",
+
+        # TODO(crbug.com/1494809): Evaluate and possibly enable.
+        "-Wno-vla-extension",
+
+        # TODO(https://crbug.com/1490607): Fix and re-enable.
+        "-Wno-thread-safety-reference-return",
+      ]
+
+      if (!is_nacl) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1513724): Fix and re-enable.
+          "-Wno-c++11-narrowing-const-reference",
+        ]
+      }
+    }
+
+    # 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",
+      ]
+    }
+  }
+}
+
+# unsafe_buffer_warning -------------------------------------------------------
+
+# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
+# have been unable to fix yet. We use this list to be able to make progress and
+# enable the warning on code that we do control/own.
+#
+# WARNING: This will disable all warnings in the files. ONLY USE THIS for
+# third-party code which we do not control/own. Fix the warnings instead in
+# our own code.
+if (is_clang) {
+  unsafe_buffer_warning_header_allowlist =
+      [ "third_party/googletest/src/googletest/include/gtest" ]
+}
+
+# Enables warnings on pointer arithmetic/indexing or calls to functions
+# annotated with `UNSAFE_BUFFER_USAGE`.
+config("unsafe_buffer_warning") {
+  if (is_clang) {
+    cflags = [ "-Wunsafe-buffer-usage" ]
+    foreach(h, unsafe_buffer_warning_header_allowlist) {
+      if (is_win) {
+        cflags += [ "/clang:--system-header-prefix=$h" ]
+      } else {
+        cflags += [ "--system-header-prefix=$h" ]
+      }
+    }
+  }
+}
+
+# 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's toolchain supports a high-quality _FORTIFY_SOURCE=3
+      # implementation with a few custom glibc patches. Use that if it's
+      # available.
+      if (is_chromeos_device && !lacros_use_chromium_toolchain) {
+        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
+  }
+
+  if (is_clang) {
+    # See below.
+    common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
+  }
+} 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",
+    ]
+  }
+
+  # We cannot rely on errno being set after math functions,
+  # especially since glibc does not set it. Thus, use -fno-math-errno
+  # so that the compiler knows it can inline math functions.
+  # Note that this is different from -ffast-math (even though -ffast-math
+  # implies -fno-math-errno), which also allows a number of unsafe
+  # optimizations.
+  common_optimize_on_cflags += [ "-fno-math-errno" ]
+}
+
+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-123.0.6286.1-target-x86_64-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-x86_64-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-x86_64-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+diff -u -Nr src-orig src > ../patches/chromium-123.0.6286.1-target-x86_64.patch

Property changes on: radix-1.9/sources/packages/x/chromium/create-123.0.6286.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-123.0.6286.1-target-x86_64-patch/src/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-x86_64-patch/src/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-x86_64-patch/src/build/config/compiler/BUILD.gn	(revision 371)
@@ -0,0 +1,3033 @@
+# 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/pch.gni")
+import("//build/config/rust.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/cros/cros_config.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 = ""
+
+  # Optimize for coverage guided fuzzing (balance between speed and number of
+  # branches)
+  optimize_for_fuzzing = false
+
+  # 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
+
+  # Whether to enable thin lto incremental builds.
+  # See: https://clang.llvm.org/docs/ThinLTO.html#incremental
+  # The cache can lead to non-determinism: https://crbug.com/1486045
+  thin_lto_enable_cache = true
+
+  # 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.
+  #
+  # Flag discussion: https://crbug.com/977230
+  #
+  # 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" ]
+    }
+
+    # dsymutil is not available in the system, on bots, for rustc to call. Our
+    # linker_driver.py script runs dsymutil itself, which is set to be the
+    # linker for Rust targets as well.
+    rustflags += [ "-Csplit-debuginfo=unpacked" ]
+  }
+
+  # 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/1488374): This causes binary size growth and potentially
+    # other problems.
+    # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version.
+    if (default_toolchain != "//build/toolchain/cros:target" &&
+        !llvm_android_mainline) {
+      cflags += [
+        "-mllvm",
+        "-split-threshold-for-reg-with-hint=0",
+      ]
+      if (use_thin_lto && is_a_target_toolchain) {
+        if (is_win) {
+          ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
+        } else {
+          ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=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) {
+      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",
+    ]
+
+    if (thin_lto_enable_cache) {
+      # 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"
+      cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+      if (is_win) {
+        ldflags += [
+          "/lldltocache:$cache_dir",
+          "/lldltocachepolicy:$cache_policy",
+        ]
+      } else {
+        if (is_apple) {
+          ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
+        } else {
+          ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
+        }
+        ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+      }
+    }
+
+    # 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",
+        "-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_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_apple) {
+        ldflags += [ "-Wcrl,object_path_lto" ]
+      }
+
+      # 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" ]
+      if (use_lld && is_mac) {
+        ldflags += [ "-Wl,--time-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 || !toolchain_supports_rust_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_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" ]
+    }
+  } else {
+    defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
+  }
+}
+
+# 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" ]
+  }
+
+  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",
+      ]
+
+      # Minimum SIMD support for devices running lacros.
+      # See https://crbug.com/1475858
+      if (is_chromeos_lacros) {
+        cflags += [
+          "-mssse3",
+          "-msse4",
+          "-msse4.1",
+          "-msse4.2",
+        ]
+      }
+      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_android) && !is_nacl) {
+      # 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",
+
+        # 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",
+
+        # TODO(https://crbug.com/1491833): Fix and re-enable.
+        "-Wno-invalid-offsetof",
+
+        # TODO(crbug.com/1494809): Evaluate and possibly enable.
+        "-Wno-vla-extension",
+
+        # TODO(https://crbug.com/1490607): Fix and re-enable.
+        "-Wno-thread-safety-reference-return",
+      ]
+
+      if (!is_nacl) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1513724): Fix and re-enable.
+          "-Wno-c++11-narrowing-const-reference",
+        ]
+      }
+    }
+
+    # 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",
+      ]
+    }
+  }
+}
+
+# unsafe_buffer_warning -------------------------------------------------------
+
+# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
+# have been unable to fix yet. We use this list to be able to make progress and
+# enable the warning on code that we do control/own.
+#
+# WARNING: This will disable all warnings in the files. ONLY USE THIS for
+# third-party code which we do not control/own. Fix the warnings instead in
+# our own code.
+if (is_clang) {
+  unsafe_buffer_warning_header_allowlist =
+      [ "third_party/googletest/src/googletest/include/gtest" ]
+}
+
+# Enables warnings on pointer arithmetic/indexing or calls to functions
+# annotated with `UNSAFE_BUFFER_USAGE`.
+config("unsafe_buffer_warning") {
+  if (is_clang) {
+    cflags = [ "-Wunsafe-buffer-usage" ]
+    foreach(h, unsafe_buffer_warning_header_allowlist) {
+      if (is_win) {
+        cflags += [ "/clang:--system-header-prefix=$h" ]
+      } else {
+        cflags += [ "--system-header-prefix=$h" ]
+      }
+    }
+  }
+}
+
+# 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's toolchain supports a high-quality _FORTIFY_SOURCE=3
+      # implementation with a few custom glibc patches. Use that if it's
+      # available.
+      if (is_chromeos_device && !lacros_use_chromium_toolchain) {
+        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
+  }
+
+  if (is_clang) {
+    # See below.
+    common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
+  }
+} 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",
+    ]
+  }
+
+  # We cannot rely on errno being set after math functions,
+  # especially since glibc does not set it. Thus, use -fno-math-errno
+  # so that the compiler knows it can inline math functions.
+  # Note that this is different from -ffast-math (even though -ffast-math
+  # implies -fno-math-errno), which also allows a number of unsafe
+  # optimizations.
+  common_optimize_on_cflags += [ "-fno-math-errno" ]
+}
+
+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-123.0.6286.1-target-x86_64-patch/src-orig/build/config/compiler/BUILD.gn
===================================================================
--- radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-x86_64-patch/src-orig/build/config/compiler/BUILD.gn	(nonexistent)
+++ radix-1.9/sources/packages/x/chromium/create-123.0.6286.1-target-x86_64-patch/src-orig/build/config/compiler/BUILD.gn	(revision 371)
@@ -0,0 +1,3032 @@
+# 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/pch.gni")
+import("//build/config/rust.gni")
+import("//build/config/ui.gni")
+import("//build/config/unwind.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/cros/cros_config.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 = ""
+
+  # Optimize for coverage guided fuzzing (balance between speed and number of
+  # branches)
+  optimize_for_fuzzing = false
+
+  # 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
+
+  # Whether to enable thin lto incremental builds.
+  # See: https://clang.llvm.org/docs/ThinLTO.html#incremental
+  # The cache can lead to non-determinism: https://crbug.com/1486045
+  thin_lto_enable_cache = true
+
+  # 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.
+  #
+  # Flag discussion: https://crbug.com/977230
+  #
+  # 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" ]
+    }
+
+    # dsymutil is not available in the system, on bots, for rustc to call. Our
+    # linker_driver.py script runs dsymutil itself, which is set to be the
+    # linker for Rust targets as well.
+    rustflags += [ "-Csplit-debuginfo=unpacked" ]
+  }
+
+  # 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/1488374): This causes binary size growth and potentially
+    # other problems.
+    # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version.
+    if (default_toolchain != "//build/toolchain/cros:target" &&
+        !llvm_android_mainline) {
+      cflags += [
+        "-mllvm",
+        "-split-threshold-for-reg-with-hint=0",
+      ]
+      if (use_thin_lto && is_a_target_toolchain) {
+        if (is_win) {
+          ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
+        } else {
+          ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=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) {
+      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",
+    ]
+
+    if (thin_lto_enable_cache) {
+      # 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"
+      cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+      if (is_win) {
+        ldflags += [
+          "/lldltocache:$cache_dir",
+          "/lldltocachepolicy:$cache_policy",
+        ]
+      } else {
+        if (is_apple) {
+          ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
+        } else {
+          ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
+        }
+        ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
+      }
+    }
+
+    # 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",
+        "-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_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_apple) {
+        ldflags += [ "-Wcrl,object_path_lto" ]
+      }
+
+      # 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" ]
+      if (use_lld && is_mac) {
+        ldflags += [ "-Wl,--time-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 || !toolchain_supports_rust_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_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" ]
+    }
+  } else {
+    defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
+  }
+}
+
+# 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" ]
+  }
+
+  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",
+      ]
+
+      # Minimum SIMD support for devices running lacros.
+      # See https://crbug.com/1475858
+      if (is_chromeos_lacros) {
+        cflags += [
+          "-mssse3",
+          "-msse4",
+          "-msse4.1",
+          "-msse4.2",
+        ]
+      }
+      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_android) && !is_nacl) {
+      # 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",
+
+        # 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",
+
+        # TODO(https://crbug.com/1491833): Fix and re-enable.
+        "-Wno-invalid-offsetof",
+
+        # TODO(crbug.com/1494809): Evaluate and possibly enable.
+        "-Wno-vla-extension",
+
+        # TODO(https://crbug.com/1490607): Fix and re-enable.
+        "-Wno-thread-safety-reference-return",
+      ]
+
+      if (!is_nacl) {
+        cflags_cc += [
+          # TODO(https://crbug.com/1513724): Fix and re-enable.
+          "-Wno-c++11-narrowing-const-reference",
+        ]
+      }
+    }
+
+    # 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",
+      ]
+    }
+  }
+}
+
+# unsafe_buffer_warning -------------------------------------------------------
+
+# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
+# have been unable to fix yet. We use this list to be able to make progress and
+# enable the warning on code that we do control/own.
+#
+# WARNING: This will disable all warnings in the files. ONLY USE THIS for
+# third-party code which we do not control/own. Fix the warnings instead in
+# our own code.
+if (is_clang) {
+  unsafe_buffer_warning_header_allowlist =
+      [ "third_party/googletest/src/googletest/include/gtest" ]
+}
+
+# Enables warnings on pointer arithmetic/indexing or calls to functions
+# annotated with `UNSAFE_BUFFER_USAGE`.
+config("unsafe_buffer_warning") {
+  if (is_clang) {
+    cflags = [ "-Wunsafe-buffer-usage" ]
+    foreach(h, unsafe_buffer_warning_header_allowlist) {
+      if (is_win) {
+        cflags += [ "/clang:--system-header-prefix=$h" ]
+      } else {
+        cflags += [ "--system-header-prefix=$h" ]
+      }
+    }
+  }
+}
+
+# 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's toolchain supports a high-quality _FORTIFY_SOURCE=3
+      # implementation with a few custom glibc patches. Use that if it's
+      # available.
+      if (is_chromeos_device && !lacros_use_chromium_toolchain) {
+        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
+  }
+
+  if (is_clang) {
+    # See below.
+    common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
+  }
+} 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",
+    ]
+  }
+
+  # We cannot rely on errno being set after math functions,
+  # especially since glibc does not set it. Thus, use -fno-math-errno
+  # so that the compiler knows it can inline math functions.
+  # Note that this is different from -ffast-math (even though -ffast-math
+  # implies -fno-math-errno), which also allows a number of unsafe
+  # optimizations.
+  common_optimize_on_cflags += [ "-fno-math-errno" ]
+}
+
+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/libreoffice/Makefile
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/Makefile	(revision 370)
+++ radix-1.9/sources/packages/x/libreoffice/Makefile	(revision 371)
@@ -7,7 +7,7 @@
 
 url         = $(DOWNLOAD_SERVER)/sources/packages/x/libreoffice
 
-versions    = 7.6.2.1
+versions    = 24.2.0.3 7.6.2.1
 pkgname     = libreoffice
 suffix      = tar.xz
 
@@ -15,7 +15,10 @@
 tarballs   += $(foreach add, dictionaries help translations, $(addsuffix .$(suffix), $(addprefix $(pkgname)-$(add)-, $(versions))))
 sha1s       = $(addsuffix .sha1sum, $(tarballs))
 
-patches     = $(CURDIR)/patches/libreoffice-7.6.2.1-isystem.patch
+patches     = $(CURDIR)/patches/libreoffice-24.2.0.3-isystem.patch
+patches    += $(CURDIR)/patches/libreoffice-24.2.0.3-odk-idl.patch
+
+patches    += $(CURDIR)/patches/libreoffice-7.6.2.1-isystem.patch
 patches    += $(CURDIR)/patches/libreoffice-7.6.2.1-odk-idl.patch
 
 .NOTPARALLEL: $(patches)
@@ -51,8 +54,10 @@
 
 $(patches): $(sha1s)
 	@echo -e "\n======= Create Patches =======\n" ; \
-	 ( cd create-7.6.2.1-isystem-patch ; ./create.patch.sh ) ; \
-	 ( cd create-7.6.2.1-odk-idl-patch ; ./create.patch.sh ) ; \
+	 ( cd create-24.2.0.3-isystem-patch ; ./create.patch.sh ) ; \
+	 ( cd create-24.2.0.3-odk-idl-patch ; ./create.patch.sh ) ; \
+	 ( cd create-7.6.2.1-isystem-patch  ; ./create.patch.sh ) ; \
+	 ( cd create-7.6.2.1-odk-idl-patch  ; ./create.patch.sh ) ; \
 	 echo -e "\n"
 
 download_clean:
Index: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=24.2.0.3
+
+tar --files-from=file.list -xJvf ../libreoffice-$VERSION.tar.xz
+mv libreoffice-$VERSION libreoffice-$VERSION-orig
+
+cp -rf ./libreoffice-$VERSION-new ./libreoffice-$VERSION
+
+diff --unified -Nr  libreoffice-$VERSION-orig  libreoffice-$VERSION > libreoffice-$VERSION-isystem.patch
+
+mv libreoffice-$VERSION-isystem.patch ../patches
+
+rm -rf ./libreoffice-$VERSION
+rm -rf ./libreoffice-$VERSION-orig

Property changes on: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/file.list
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/file.list	(nonexistent)
+++ radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/file.list	(revision 371)
@@ -0,0 +1 @@
+libreoffice-24.2.0.3/configure.ac
Index: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/libreoffice-24.2.0.3-new/configure.ac
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/libreoffice-24.2.0.3-new/configure.ac	(nonexistent)
+++ radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-isystem-patch/libreoffice-24.2.0.3-new/configure.ac	(revision 371)
@@ -0,0 +1,15327 @@
+dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 100 -*-
+dnl configure.ac serves as input for the GNU autoconf package
+dnl in order to create a configure script.
+
+# The version number in the second argument to AC_INIT should be four numbers separated by
+# periods. Some parts of the code requires the first one to be less than 128 and the others to be less
+# than 256. The four numbers can optionally be followed by a period and a free-form string containing
+# no spaces or periods, like "frobozz-mumble-42" or "alpha0". If the free-form string ends with one or
+# several non-alphanumeric characters, those are split off and used only for the
+# ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no idea.
+
+AC_INIT([LibreOffice],[24.2.0.3],[],[],[http://documentfoundation.org/])
+
+dnl libnumbertext needs autoconf 2.68, but that can pick up autoconf268 just fine if it is installed
+dnl whereas aclocal (as run by autogen.sh) insists on using autoconf and fails hard
+dnl so check for the version of autoconf that is actually used to create the configure script
+AC_PREREQ([2.59])
+m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.68]), -1,
+    [AC_MSG_ERROR([at least autoconf version 2.68 is needed (you can use AUTOCONF environment variable to point to a suitable one)])])
+
+if test -n "$BUILD_TYPE"; then
+    AC_MSG_ERROR([You have sourced config_host.mk in this shell.  This may lead to trouble, please run in a fresh (login) shell.])
+fi
+
+save_CC=$CC
+save_CXX=$CXX
+
+first_arg_basename()
+{
+    for i in $1; do
+        basename "$i"
+        break
+    done
+}
+
+CC_BASE=`first_arg_basename "$CC"`
+CXX_BASE=`first_arg_basename "$CXX"`
+
+BUILD_TYPE="LibO"
+SCPDEFS=""
+GIT_NEEDED_SUBMODULES=""
+LO_PATH= # used by path_munge to construct a PATH variable
+
+FilterLibs()
+{
+    # Return value: $filteredlibs
+
+    filteredlibs=
+    if test "$COM" = "MSC"; then
+        for f in $1; do
+            if test "x$f" != "x${f#-L}"; then
+                filteredlibs="$filteredlibs -LIBPATH:${f:2}"
+            elif test "x$f" != "x${f#-l}"; then
+                filteredlibs="$filteredlibs ${f:2}.lib"
+            else
+                filteredlibs="$filteredlibs $f"
+            fi
+        done
+    else
+        for f in $1; do
+            case "$f" in
+                # let's start with Fedora's paths for now
+                -L/lib|-L/lib/|-L/lib64|-L/lib64/|-L/usr/lib|-L/usr/lib/|-L/usr/lib64|-L/usr/lib64/)
+                    # ignore it: on UNIXoids it is searched by default anyway
+                    # but if it's given explicitly then it may override other paths
+                    # (on macOS it would be an error to use it instead of SDK)
+                    ;;
+                *)
+                    filteredlibs="$filteredlibs $f"
+                    ;;
+            esac
+        done
+    fi
+}
+
+PathFormat()
+{
+    # Args: $1: A pathname. On Cygwin and WSL, in either the Unix or the Windows format. Note that this
+    # function is called also on Unix.
+    #
+    # Return value: $formatted_path and $formatted_path_unix.
+    #
+    # $formatted_path is the argument in Windows format, but using forward slashes instead of
+    # backslashes, using 8.3 pathname components if necessary (if it otherwise would contains spaces
+    # or shell metacharacters).
+    #
+    # $formatted_path_unix is the argument in a form usable in Cygwin or WSL, using 8.3 components if
+    # necessary. On Cygwin, it is the same as $formatted_path, but on WSL it is $formatted_path as a
+    # Unix pathname.
+    #
+    # Errors out if 8.3 names are needed but aren't present for some of the path components.
+
+    # Examples:
+    #
+    # /home/tml/lo/master-optimised => C:/cygwin64/home/tml/lo/master-optimised
+    #
+    # C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe => C:/PROGRA~2/MICROS~3/INSTAL~1/vswhere.exe
+    #
+    # C:\Program Files (x86)\Microsoft Visual Studio\2019\Community => C:/PROGRA~2/MICROS~3/2019/COMMUN~1
+    #
+    # C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt => C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt
+    #
+    # /cygdrive/c/PROGRA~2/WI3CF2~1/10 => C:/PROGRA~2/WI3CF2~1/10
+    #
+    # C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\ => C:/PROGRA~2/WI3CF2~1/NETFXSDK/4.8/
+    #
+    # /usr/bin/find.exe => C:/cygwin64/bin/find.exe
+
+    if test -n "$UNITTEST_WSL_PATHFORMAT"; then
+        printf "PathFormat $1 ==> "
+    fi
+
+    formatted_path="$1"
+    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
+        if test "$build_os" = "wsl"; then
+            formatted_path=$(echo "$formatted_path" | tr -d '\r')
+        fi
+
+        pf_conv_to_dos=
+        # spaces,parentheses,brackets,braces are problematic in pathname
+        # so are backslashes
+        case "$formatted_path" in
+            *\ * | *\)* | *\(* | *\{* | *\}* | *\[* | *\]* | *\\* )
+                pf_conv_to_dos="yes"
+            ;;
+        esac
+        if test "$pf_conv_to_dos" = "yes"; then
+            if test "$build_os" = "wsl"; then
+                case "$formatted_path" in
+                    /*)
+                        formatted_path=$(wslpath -w "$formatted_path")
+                        ;;
+                esac
+                formatted_path=$($WSL_LO_HELPER --8.3 "$formatted_path")
+            elif test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+                formatted_path=`cygpath -sm "$formatted_path"`
+            else
+                formatted_path=`cygpath -d "$formatted_path"`
+            fi
+            if test $? -ne 0;  then
+                AC_MSG_ERROR([path conversion failed for "$1".])
+            fi
+        fi
+        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
+        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
+        if test "$fp_count_slash$fp_count_colon" != "00"; then
+            if test "$fp_count_colon" = "0"; then
+                new_formatted_path=`realpath "$formatted_path"`
+                if test $? -ne 0;  then
+                    AC_MSG_WARN([realpath failed for "$formatted_path", not necessarily a problem.])
+                else
+                    formatted_path="$new_formatted_path"
+                fi
+            fi
+            if test "$build_os" = "wsl"; then
+                if test "$fp_count_colon" != "0"; then
+                    formatted_path=$(wslpath "$formatted_path")
+                    local final_slash=
+                    case "$formatted_path" in
+                        */)
+                            final_slash=/
+                            ;;
+                    esac
+                    formatted_path=$(wslpath -m $formatted_path)
+                    case "$formatted_path" in
+                        */)
+                            ;;
+                        *)
+                            formatted_path="$formatted_path"$final_slash
+                            ;;
+                    esac
+                else
+                    formatted_path=$(wslpath -m "$formatted_path")
+                fi
+            else
+                formatted_path=`cygpath -m "$formatted_path"`
+            fi
+            if test $? -ne 0;  then
+                AC_MSG_ERROR([path conversion failed for "$1".])
+            fi
+        fi
+        fp_count_space=`echo "$formatted_path" | $GREP -c "[ ]"`
+        if test "$fp_count_space" != "0"; then
+            AC_MSG_ERROR([converted path "$formatted_path" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?])
+        fi
+    fi
+    if test "$build_os" = "wsl"; then
+        # WSL can't run Windows binaries from Windows pathnames so we need a separate return value in Unix format
+        formatted_path_unix=$(wslpath "$formatted_path")
+    else
+        # But Cygwin can
+        formatted_path_unix="$formatted_path"
+    fi
+}
+
+AbsolutePath()
+{
+    # There appears to be no simple and portable method to get an absolute and
+    # canonical path, so we try creating the directory if does not exist and
+    # utilizing the shell and pwd.
+
+    # Args: $1: A possibly relative pathname
+    # Return value: $absolute_path
+
+    # Convert to unix path, mkdir would treat c:/path as a relative path.
+    PathFormat "$1"
+    local rel="$formatted_path_unix"
+    absolute_path=""
+    test ! -e "$rel" && mkdir -p "$rel"
+    if test -d "$rel" ; then
+        cd "$rel" || AC_MSG_ERROR([absolute path resolution failed for "$rel".])
+        absolute_path="$(pwd)"
+        cd - > /dev/null
+    else
+        AC_MSG_ERROR([Failed to resolve absolute path.  "$rel" does not exist or is not a directory.])
+    fi
+}
+
+WARNINGS_FILE=config.warn
+WARNINGS_FILE_FOR_BUILD=config.Build.warn
+rm -f "$WARNINGS_FILE" "$WARNINGS_FILE_FOR_BUILD"
+have_WARNINGS="no"
+add_warning()
+{
+    if test "$have_WARNINGS" = "no"; then
+        echo "*************************************" > "$WARNINGS_FILE"
+        have_WARNINGS="yes"
+        if which tput >/dev/null && test "`tput colors 2>/dev/null || echo 0`" -ge 8; then
+            dnl <esc> as actual byte (U+1b), [ escaped using quadrigraph @<:@
+            COLORWARN='*@<:@1;33;40m WARNING @<:@0m:'
+        else
+            COLORWARN="* WARNING :"
+        fi
+    fi
+    echo "$COLORWARN $@" >> "$WARNINGS_FILE"
+}
+
+dnl Some Mac User have the bad habit of letting a lot of crap
+dnl accumulate in their PATH and even adding stuff in /usr/local/bin
+dnl that confuse the build.
+dnl For the ones that use LODE, let's be nice and protect them
+dnl from themselves
+
+mac_sanitize_path()
+{
+    mac_path="$LODE_HOME/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+dnl a common but nevertheless necessary thing that may be in a fancy
+dnl path location is git, so make sure we have it
+    mac_git_path=`which git 2>/dev/null`
+    if test -n "$mac_git_path" -a -x "$mac_git_path" -a "$mac_git_path" != "/usr/bin/git" ; then
+        mac_path="$mac_path:`dirname $mac_git_path`"
+    fi
+dnl a not so common but nevertheless quite helpful thing that may be in a fancy
+dnl path location is gpg, so make sure we find it
+    mac_gpg_path=`which gpg 2>/dev/null`
+    if test -n "$mac_gpg_path" -a -x "$mac_gpg_path" -a "$mac_gpg_path" != "/usr/bin/gpg" ; then
+        mac_path="$mac_path:`dirname $mac_gpg_path`"
+    fi
+    PATH="$mac_path"
+    unset mac_path
+    unset mac_git_path
+    unset mac_gpg_path
+}
+
+dnl semantically test a three digits version
+dnl $1 - $3 = minimal version
+dnl $4 - $6 = current version
+
+check_semantic_version_three()
+{
+    test "$4" -gt "$1" \
+        -o \( "$4" -eq "$1" -a "$5" -gt "$2" \) \
+        -o \( "$4" -eq "$1" -a "$5" -eq "$2" -a "$6" -ge "$3" \)
+    return $?
+}
+
+dnl calls check_semantic_version_three with digits in named variables $1_MAJOR, $1_MINOR, $1_TINY
+dnl $1 = current version prefix, e.g. EMSCRIPTEN => EMSCRIPTEN_
+dnl $2 = postfix to $1, e.g. MIN => EMSCRIPTEN_MIN_
+
+check_semantic_version_three_prefixed()
+{
+    eval local MIN_MAJOR="\$${1}_${2}_MAJOR"
+    eval local MIN_MINOR="\$${1}_${2}_MINOR"
+    eval local MIN_TINY="\$${1}_${2}_TINY"
+    eval local CUR_MAJOR="\$${1}_MAJOR"
+    eval local CUR_MINOR="\$${1}_MINOR"
+    eval local CUR_TINY="\$${1}_TINY"
+    check_semantic_version_three $MIN_MAJOR $MIN_MINOR $MIN_TINY $CUR_MAJOR $CUR_MINOR $CUR_TINY
+    return $?
+}
+
+echo "********************************************************************"
+echo "*"
+echo "*   Running ${PACKAGE_NAME} build configuration."
+echo "*"
+echo "********************************************************************"
+echo ""
+
+dnl ===================================================================
+dnl checks build and host OSes
+dnl do this before argument processing to allow for platform dependent defaults
+dnl ===================================================================
+
+# Check for WSL (version 2, at least). But if --host is explicitly specified (to really do build for
+# Linux on WSL) trust that.
+if test -z "$host" -a -z "$build" -a "`wslsys -v 2>/dev/null`" != ""; then
+    ac_cv_host="x86_64-pc-wsl"
+    ac_cv_host_cpu="x86_64"
+    ac_cv_host_os="wsl"
+    ac_cv_build="$ac_cv_host"
+    ac_cv_build_cpu="$ac_cv_host_cpu"
+    ac_cv_build_os="$ac_cv_host_os"
+
+    # Emulation of Cygwin's cygpath command for WSL.
+    cygpath()
+    {
+        if test -n "$UNITTEST_WSL_CYGPATH"; then
+            echo -n cygpath "$@" "==> "
+        fi
+
+        # Cygwin's real cygpath has a plethora of options but we use only a few here.
+        local args="$@"
+        local opt
+        local opt_d opt_m opt_u opt_w opt_l opt_s opt_p
+        OPTIND=1
+
+        while getopts dmuwlsp opt; do
+            case "$opt" in
+                \?)
+                    AC_MSG_ERROR([Unimplemented cygpath emulation option in invocation: cygpath $args])
+                    ;;
+                ?)
+                    eval opt_$opt=yes
+                    ;;
+            esac
+        done
+
+        shift $((OPTIND-1))
+
+        if test $# -ne 1; then
+            AC_MSG_ERROR([Invalid cygpath emulation invocation: Pathname missing]);
+        fi
+
+        local input="$1"
+
+        local result
+
+        if test -n "$opt_d" -o -n "$opt_m" -o -n "$opt_w"; then
+            # Print Windows path, possibly in 8.3 form (-d) or with forward slashes (-m)
+
+            if test -n "$opt_u"; then
+                AC_MSG_ERROR([Invalid cygpath invocation: Both Windows and Unix path output requested])
+            fi
+
+            case "$input" in
+                /mnt/*)
+                    # A Windows file in WSL format
+                    input=$(wslpath -w "$input")
+                    ;;
+                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
+                    # Already in Windows format
+                    ;;
+                /*)
+                    input=$(wslpath -w "$input")
+                    ;;
+                *)
+                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
+                    ;;
+            esac
+            if test -n "$opt_d" -o -n "$opt_s"; then
+                input=$($WSL_LO_HELPER --8.3 "$input")
+            fi
+            if test -n "$opt_m"; then
+                input="${input//\\//}"
+            fi
+            echo "$input"
+        else
+            # Print Unix path
+
+            case "$input" in
+                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
+                    wslpath -u "$input"
+                    ;;
+                /)
+                    echo "$input"
+                    ;;
+                *)
+                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
+                    ;;
+            esac
+        fi
+    }
+
+    if test -n "$UNITTEST_WSL_CYGPATH"; then
+        BUILDDIR=.
+
+        # Nothing special with these file names, just arbitrary ones picked to test with
+        cygpath -d /usr/lib64/ld-linux-x86-64.so.2
+        cygpath -w /usr/lib64/ld-linux-x86-64.so.2
+        cygpath -m /usr/lib64/ld-linux-x86-64.so.2
+        cygpath -m -s /usr/lib64/ld-linux-x86-64.so.2
+        # At least on my machine for instance this file does have an 8.3 name
+        cygpath -d /mnt/c/windows/WindowsUpdate.log
+        # But for instance this one doesn't
+        cygpath -w /mnt/c/windows/system32/AboutSettingsHandlers.dll
+        cygpath -ws /mnt/c/windows/WindowsUpdate.log
+        cygpath -m /mnt/c/windows/system32/AboutSettingsHandlers.dll
+        cygpath -ms /mnt/c/windows/WindowsUpdate.log
+
+        cygpath -u 'c:\windows\system32\AboutSettingsHandlers.dll'
+        cygpath -u 'c:/windows/system32/AboutSettingsHandlers.dll'
+
+        exit 0
+    fi
+
+    if test -z "$WSL_LO_HELPER"; then
+        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/wsl-lo-helper" ; then
+            WSL_LO_HELPER="$LODE_HOME/opt/bin/wsl-lo-helper"
+        elif test -x "/opt/lo/bin/wsl-lo-helper"; then
+            WSL_LO_HELPER="/opt/lo/bin/wsl-lo-helper"
+        fi
+    fi
+    if test -z "$WSL_LO_HELPER"; then
+        AC_MSG_ERROR([wsl-lo-helper not found. See solenv/wsl/README.])
+    fi
+fi
+
+AC_CANONICAL_HOST
+AC_CANONICAL_BUILD
+
+if test -n "$UNITTEST_WSL_PATHFORMAT"; then
+    BUILDDIR=.
+    GREP=grep
+
+    # Use of PathFormat must be after AC_CANONICAL_BUILD above
+    PathFormat /
+    printf "$formatted_path , $formatted_path_unix\n"
+
+    PathFormat $PWD
+    printf "$formatted_path , $formatted_path_unix\n"
+
+    PathFormat "$PROGRAMFILESX86"
+    printf "$formatted_path , $formatted_path_unix\n"
+
+    exit 0
+fi
+
+AC_MSG_CHECKING([for product name])
+PRODUCTNAME="AC_PACKAGE_NAME"
+if test -n "$with_product_name" -a "$with_product_name" != no; then
+    PRODUCTNAME="$with_product_name"
+fi
+if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
+    PRODUCTNAME="${PRODUCTNAME}Dev"
+fi
+AC_MSG_RESULT([$PRODUCTNAME])
+AC_SUBST(PRODUCTNAME)
+PRODUCTNAME_WITHOUT_SPACES=$(printf %s "$PRODUCTNAME" | sed 's/ //g')
+AC_SUBST(PRODUCTNAME_WITHOUT_SPACES)
+
+dnl ===================================================================
+dnl Our version is defined by the AC_INIT() at the top of this script.
+dnl ===================================================================
+
+AC_MSG_CHECKING([for package version])
+if test -n "$with_package_version" -a "$with_package_version" != no; then
+    PACKAGE_VERSION="$with_package_version"
+fi
+AC_MSG_RESULT([$PACKAGE_VERSION])
+
+set `echo "$PACKAGE_VERSION" | sed "s/\./ /g"`
+
+LIBO_VERSION_MAJOR=$1
+LIBO_VERSION_MINOR=$2
+LIBO_VERSION_MICRO=$3
+LIBO_VERSION_PATCH=$4
+
+LIBO_VERSION_SUFFIX=$5
+
+# Split out LIBO_VERSION_SUFFIX_SUFFIX... horrible crack. But apparently wanted separately in
+# openoffice.lst as ABOUTBOXPRODUCTVERSIONSUFFIX. Note that the double brackets are for m4's sake,
+# they get undoubled before actually passed to sed.
+LIBO_VERSION_SUFFIX_SUFFIX=`echo "$LIBO_VERSION_SUFFIX" | sed -e 's/.*[[a-zA-Z0-9]]\([[^a-zA-Z0-9]]*\)$/\1/'`
+test -n "$LIBO_VERSION_SUFFIX_SUFFIX" && LIBO_VERSION_SUFFIX="${LIBO_VERSION_SUFFIX%${LIBO_VERSION_SUFFIX_SUFFIX}}"
+# LIBO_VERSION_SUFFIX, if non-empty, should include the period separator
+test -n "$LIBO_VERSION_SUFFIX" && LIBO_VERSION_SUFFIX=".$LIBO_VERSION_SUFFIX"
+
+# The value for key CFBundleVersion in the Info.plist file must be a period-separated list of at most
+# three non-negative integers. Please find more information about CFBundleVersion at
+# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion
+
+# The value for key CFBundleShortVersionString in the Info.plist file must be a period-separated list
+# of at most three non-negative integers. Please find more information about
+# CFBundleShortVersionString at
+# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring
+
+# But that is enforced only in the App Store, and we apparently want to break the rules otherwise.
+
+if test "$enable_macosx_sandbox" = yes; then
+    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.`expr $LIBO_VERSION_MICRO '*' 1000 + $LIBO_VERSION_PATCH`
+    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION
+else
+    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.$LIBO_VERSION_MICRO.$LIBO_VERSION_PATCH
+    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION$LIBO_VERSION_SUFFIX
+fi
+
+AC_SUBST(LIBO_VERSION_MAJOR)
+AC_SUBST(LIBO_VERSION_MINOR)
+AC_SUBST(LIBO_VERSION_MICRO)
+AC_SUBST(LIBO_VERSION_PATCH)
+AC_SUBST(LIBO_VERSION_SUFFIX)
+AC_SUBST(LIBO_VERSION_SUFFIX_SUFFIX)
+AC_SUBST(MACOSX_BUNDLE_SHORTVERSION)
+AC_SUBST(MACOSX_BUNDLE_VERSION)
+
+AC_DEFINE_UNQUOTED(LIBO_VERSION_MAJOR,$LIBO_VERSION_MAJOR)
+AC_DEFINE_UNQUOTED(LIBO_VERSION_MINOR,$LIBO_VERSION_MINOR)
+AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
+AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
+
+git_date=`git log -1 --pretty=format:"%cd" --date=format:'%Y' 2>&/dev/null`
+LIBO_THIS_YEAR=${git_date:-2024}
+AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
+
+dnl ===================================================================
+dnl Product version
+dnl ===================================================================
+AC_MSG_CHECKING([for product version])
+PRODUCTVERSION="$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR"
+AC_MSG_RESULT([$PRODUCTVERSION])
+AC_SUBST(PRODUCTVERSION)
+
+AC_PROG_EGREP
+# AC_PROG_EGREP doesn't set GREP on all systems as well
+AC_PATH_PROG(GREP, grep)
+
+BUILDDIR=`pwd`
+cd $srcdir
+SRC_ROOT=`pwd`
+cd $BUILDDIR
+x_Cygwin=[\#]
+
+dnl ======================================
+dnl Required GObject introspection version
+dnl ======================================
+INTROSPECTION_REQUIRED_VERSION=1.32.0
+
+dnl ===================================================================
+dnl Search all the common names for GNU Make
+dnl ===================================================================
+AC_MSG_CHECKING([for GNU Make])
+
+# try to use our own make if it is available and GNUMAKE was not already defined
+if test -z "$GNUMAKE"; then
+    if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/make" ; then
+        GNUMAKE="$LODE_HOME/opt/bin/make"
+    elif test -x "/opt/lo/bin/make"; then
+        GNUMAKE="/opt/lo/bin/make"
+    fi
+fi
+
+GNUMAKE_WIN_NATIVE=
+for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
+    if test -n "$a"; then
+        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
+        if test $? -eq 0;  then
+            if test "$build_os" = "cygwin"; then
+                if test -n "$($a -v | grep 'Built for Windows')" ; then
+                    GNUMAKE="$(cygpath -m "$(which "$(cygpath -u $a)")")"
+                    GNUMAKE_WIN_NATIVE="TRUE"
+                else
+                    GNUMAKE=`which $a`
+                fi
+            else
+                GNUMAKE=`which $a`
+            fi
+            break
+        fi
+    fi
+done
+AC_MSG_RESULT($GNUMAKE)
+if test -z "$GNUMAKE"; then
+    AC_MSG_ERROR([not found. install GNU Make.])
+else
+    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+        AC_MSG_NOTICE([Using a native Win32 GNU Make version.])
+    fi
+fi
+
+win_short_path_for_make()
+{
+    local short_path="$1"
+    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+        cygpath -sm "$short_path"
+    else
+        cygpath -u "$(cygpath -d "$short_path")"
+    fi
+}
+
+
+if test "$build_os" = "cygwin"; then
+    PathFormat "$SRC_ROOT"
+    SRC_ROOT="$formatted_path"
+    PathFormat "$BUILDDIR"
+    BUILDDIR="$formatted_path"
+    x_Cygwin=
+    AC_MSG_CHECKING(for explicit COMSPEC)
+    if test -z "$COMSPEC"; then
+        AC_MSG_ERROR([COMSPEC not set in environment, please set it and rerun])
+    else
+        AC_MSG_RESULT([found: $COMSPEC])
+    fi
+fi
+
+AC_SUBST(SRC_ROOT)
+AC_SUBST(BUILDDIR)
+AC_SUBST(x_Cygwin)
+AC_DEFINE_UNQUOTED(SRCDIR,"$SRC_ROOT")
+AC_DEFINE_UNQUOTED(SRC_ROOT,"$SRC_ROOT")
+AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
+
+if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
+    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
+fi
+
+# need sed in os checks...
+AC_PATH_PROGS(SED, sed)
+if test -z "$SED"; then
+    AC_MSG_ERROR([install sed to run this script])
+fi
+
+# Set the ENABLE_LTO variable
+# ===================================================================
+AC_MSG_CHECKING([whether to use link-time optimization])
+if test -n "$enable_lto" -a "$enable_lto" != "no"; then
+    ENABLE_LTO="TRUE"
+    AC_MSG_RESULT([yes])
+else
+    ENABLE_LTO=""
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_LTO)
+
+AC_ARG_ENABLE(fuzz-options,
+    AS_HELP_STRING([--enable-fuzz-options],
+        [Randomly enable or disable each of those configurable options
+         that are supposed to be freely selectable without interdependencies,
+         or where bad interaction from interdependencies is automatically avoided.])
+)
+
+dnl ===================================================================
+dnl When building for Android, --with-android-ndk,
+dnl --with-android-ndk-toolchain-version and --with-android-sdk are
+dnl mandatory
+dnl ===================================================================
+
+AC_ARG_WITH(android-ndk,
+    AS_HELP_STRING([--with-android-ndk],
+        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
+,)
+
+AC_ARG_WITH(android-ndk-toolchain-version,
+    AS_HELP_STRING([--with-android-ndk-toolchain-version],
+        [Specify which toolchain version to use, of those present in the
+        Android NDK you are using. The default (and only supported version currently) is "clang5.0"]),,
+        with_android_ndk_toolchain_version=clang5.0)
+
+AC_ARG_WITH(android-sdk,
+    AS_HELP_STRING([--with-android-sdk],
+        [Specify location of the Android SDK. Mandatory when building for Android.]),
+,)
+
+AC_ARG_WITH(android-api-level,
+    AS_HELP_STRING([--with-android-api-level],
+        [Specify the API level when building for Android. Defaults to 16 for ARM and x86 and to 21 for ARM64 and x86-64]),
+,)
+
+ANDROID_NDK_DIR=
+if test -z "$with_android_ndk" -a -e "$SRC_ROOT/external/android-ndk" -a "$build" != "$host"; then
+    with_android_ndk="$SRC_ROOT/external/android-ndk"
+fi
+if test -n "$with_android_ndk"; then
+    eval ANDROID_NDK_DIR=$with_android_ndk
+
+    ANDROID_API_LEVEL=21
+    if test -n "$with_android_api_level" ; then
+        ANDROID_API_LEVEL="$with_android_api_level"
+    fi
+
+    if test $host_cpu = arm; then
+        LLVM_TRIPLE=armv7a-linux-androideabi
+        ANDROID_SYSROOT_PLATFORM=arm-linux-androideabi
+        ANDROID_APP_ABI=armeabi-v7a
+        ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8"
+    elif test $host_cpu = aarch64; then
+        LLVM_TRIPLE=aarch64-linux-android
+        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
+        ANDROID_APP_ABI=arm64-v8a
+    elif test $host_cpu = x86_64; then
+        LLVM_TRIPLE=x86_64-linux-android
+        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
+        ANDROID_APP_ABI=x86_64
+    else
+        # host_cpu is something like "i386" or "i686" I guess, NDK uses
+        # "x86" in some contexts
+        LLVM_TRIPLE=i686-linux-android
+        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
+        ANDROID_APP_ABI=x86
+    fi
+
+    # Set up a lot of pre-canned defaults
+
+    if test ! -f $ANDROID_NDK_DIR/RELEASE.TXT; then
+        if test ! -f $ANDROID_NDK_DIR/source.properties; then
+            AC_MSG_ERROR([Unrecognized Android NDK. Missing RELEASE.TXT or source.properties file in $ANDROID_NDK_DIR.])
+        fi
+        ANDROID_NDK_VERSION=`sed -n -e 's/Pkg.Revision = //p' $ANDROID_NDK_DIR/source.properties`
+    else
+        ANDROID_NDK_VERSION=`cut -f1 -d' ' <$ANDROID_NDK_DIR/RELEASE.TXT`
+    fi
+    if test -z "$ANDROID_NDK_VERSION";  then
+        AC_MSG_ERROR([Failed to determine Android NDK version. Please check your installation.])
+    fi
+    case $ANDROID_NDK_VERSION in
+    r9*|r10*)
+        AC_MSG_ERROR([Building for Android requires NDK version >= 23.*])
+        ;;
+    11.1.*|12.1.*|13.1.*|14.1.*|16.*|17.*|18.*|19.*|20.*|21.*|22.*)
+        AC_MSG_ERROR([Building for Android requires NDK version >= 23.*])
+        ;;
+    23.*|24.*|25.*)
+        ;;
+    *)
+        AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 23.* to 25.* have been used successfully. Proceed at your own risk.])
+        add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 23.* to 25.* have been used successfully. Proceed at your own risk."
+        ;;
+    esac
+
+    case "$with_android_ndk_toolchain_version" in
+    clang5.0)
+        ANDROID_GCC_TOOLCHAIN_VERSION=4.9
+        ;;
+    *)
+        AC_MSG_ERROR([Unrecognized value for the --with-android-ndk-toolchain-version option. Building for Android is only supported with Clang 5.*])
+    esac
+
+    AC_MSG_NOTICE([using the Android API level... $ANDROID_API_LEVEL])
+
+    # NDK 15 or later toolchain is 64bit-only, except for Windows that we don't support. Using a 64-bit
+    # linker is required if you compile large parts of the code with -g. A 32-bit linker just won't
+    # manage to link the (app-specific) single huge .so that is built for the app in
+    # android/source/ if there is debug information in a significant part of the object files.
+    # (A 64-bit ld.gold grows too much over 10 gigabytes of virtual space when linking such a .so if
+    # all objects have been built with debug information.)
+    case $build_os in
+    linux-gnu*)
+        android_HOST_TAG=linux-x86_64
+        ;;
+    darwin*)
+        android_HOST_TAG=darwin-x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([We only support building for Android from Linux or macOS])
+        # ndk would also support windows and windows-x86_64
+        ;;
+    esac
+    ANDROID_TOOLCHAIN=$ANDROID_NDK_DIR/toolchains/llvm/prebuilt/$android_HOST_TAG
+    ANDROID_COMPILER_BIN=$ANDROID_TOOLCHAIN/bin
+
+    test -z "$AR" && AR=$ANDROID_COMPILER_BIN/llvm-ar
+    test -z "$NM" && NM=$ANDROID_COMPILER_BIN/llvm-nm
+    test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/llvm-objdump
+    test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/llvm-ranlib
+    test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/llvm-strip
+
+    ANDROIDCFLAGS="$ANDROIDCFLAGS -target ${LLVM_TRIPLE}${ANDROID_API_LEVEL}"
+    ANDROIDCFLAGS="$ANDROIDCFLAGS -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments"
+    if test "$ENABLE_LTO" = TRUE; then
+        # -flto comes from com_GCC_defs.mk, too, but we need to make sure it gets passed as part of
+        # $CC and $CXX when building external libraries
+        ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
+    fi
+
+    ANDROIDCXXFLAGS="$ANDROIDCFLAGS -stdlib=libc++"
+
+    if test -z "$CC"; then
+        CC="$ANDROID_COMPILER_BIN/clang $ANDROIDCFLAGS"
+        CC_BASE="clang"
+    fi
+    if test -z "$CXX"; then
+        CXX="$ANDROID_COMPILER_BIN/clang++ $ANDROIDCXXFLAGS"
+        CXX_BASE="clang++"
+    fi
+fi
+AC_SUBST(ANDROID_NDK_DIR)
+AC_SUBST(ANDROID_API_LEVEL)
+AC_SUBST(ANDROID_APP_ABI)
+AC_SUBST(ANDROID_GCC_TOOLCHAIN_VERSION)
+AC_SUBST(ANDROID_SYSROOT_PLATFORM)
+AC_SUBST(ANDROID_TOOLCHAIN)
+
+dnl ===================================================================
+dnl --with-android-sdk
+dnl ===================================================================
+ANDROID_SDK_DIR=
+if test -z "$with_android_sdk" -a -e "$SRC_ROOT/external/android-sdk-linux" -a "$build" != "$host"; then
+    with_android_sdk="$SRC_ROOT/external/android-sdk-linux"
+fi
+if test -n "$with_android_sdk"; then
+    eval ANDROID_SDK_DIR=$with_android_sdk
+    PATH="$ANDROID_SDK_DIR/platform-tools:$ANDROID_SDK_DIR/tools:$PATH"
+fi
+AC_SUBST(ANDROID_SDK_DIR)
+
+AC_ARG_ENABLE([android-lok],
+    AS_HELP_STRING([--enable-android-lok],
+        [The Android app from the android/ subdir needs several tweaks all
+         over the place that break the LOK when used in the Online-based
+         Android app.  This switch indicates that the intent of this build is
+         actually the Online-based, non-modified LOK.])
+)
+ENABLE_ANDROID_LOK=
+if test -n "$ANDROID_NDK_DIR" ; then
+    if test "$enable_android_lok" = yes; then
+        ENABLE_ANDROID_LOK=TRUE
+        AC_DEFINE(HAVE_FEATURE_ANDROID_LOK)
+        AC_MSG_NOTICE([building the Android version... for the Online-based Android app])
+    else
+        AC_MSG_NOTICE([building the Android version... for the app from the android/ subdir])
+    fi
+fi
+AC_SUBST([ENABLE_ANDROID_LOK])
+
+libo_FUZZ_ARG_ENABLE([android-editing],
+    AS_HELP_STRING([--enable-android-editing],
+        [Enable the experimental editing feature on Android.])
+)
+ENABLE_ANDROID_EDITING=
+if test "$enable_android_editing" = yes; then
+    ENABLE_ANDROID_EDITING=TRUE
+fi
+AC_SUBST([ENABLE_ANDROID_EDITING])
+
+disable_database_connectivity_dependencies()
+{
+    enable_evolution2=no
+    enable_firebird_sdbc=no
+    enable_mariadb_sdbc=no
+    enable_postgresql_sdbc=no
+    enable_report_builder=no
+}
+
+# ===================================================================
+#
+# Start initial platform setup
+#
+# The using_* variables reflect platform support and should not be
+# changed after the "End initial platform setup" block.
+# This is also true for most test_* variables.
+# ===================================================================
+build_crypto=yes
+test_clucene=no
+test_gdb_index=no
+test_openldap=yes
+test_split_debug=no
+test_webdav=yes
+usable_dlapi=yes
+
+# There is currently just iOS not using salplug, so this explicitly enables it.
+# must: using_freetype_fontconfig
+#  may: using_headless_plugin defaults to $using_freetype_fontconfig
+# must: using_x11
+
+# Default values, as such probably valid just for Linux, set
+# differently below just for Mac OSX, but at least better than
+# hardcoding these as we used to do. Much of this is duplicated also
+# in solenv for old build system and for gbuild, ideally we should
+# perhaps define stuff like this only here in configure.ac?
+
+LINKFLAGSSHL="-shared"
+PICSWITCH="-fpic"
+DLLPOST=".so"
+
+LINKFLAGSNOUNDEFS="-Wl,-z,defs"
+
+INSTROOTBASESUFFIX=
+INSTROOTCONTENTSUFFIX=
+SDKDIRNAME=sdk
+
+HOST_PLATFORM="$host"
+
+host_cpu_for_clang="$host_cpu"
+
+case "$host_os" in
+
+solaris*)
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    build_skia=yes
+    _os=SunOS
+
+    dnl ===========================================================
+    dnl Check whether we're using Solaris 10 - SPARC or Intel.
+    dnl ===========================================================
+    AC_MSG_CHECKING([the Solaris operating system release])
+    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
+    if test "$_os_release" -lt "10"; then
+        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
+    else
+        AC_MSG_RESULT([ok ($_os_release)])
+    fi
+
+    dnl Check whether we're using a SPARC or i386 processor
+    AC_MSG_CHECKING([the processor type])
+    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
+        AC_MSG_RESULT([ok ($host_cpu)])
+    else
+        AC_MSG_ERROR([only SPARC and i386 processors are supported])
+    fi
+    ;;
+
+linux-gnu*|k*bsd*-gnu*|linux-musl*)
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    build_skia=yes
+    test_gdb_index=yes
+    test_split_debug=yes
+    if test "$enable_fuzzers" = yes; then
+        test_system_freetype=no
+    fi
+    _os=Linux
+    ;;
+
+gnu)
+    using_freetype_fontconfig=yes
+    using_x11=no
+    _os=GNU
+     ;;
+
+cygwin*|wsl*)
+    # When building on Windows normally with MSVC under Cygwin,
+    # configure thinks that the host platform (the platform the
+    # built code will run on) is Cygwin, even if it obviously is
+    # Windows, which in Autoconf terminology is called
+    # "mingw32". (Which is misleading as MinGW is the name of the
+    # tool-chain, not an operating system.)
+
+    # Somewhat confusing, yes. But this configure script doesn't
+    # look at $host etc that much, it mostly uses its own $_os
+    # variable, set here in this case statement.
+
+    using_freetype_fontconfig=no
+    using_x11=no
+    test_unix_dlapi=no
+    test_openldap=no
+    enable_pagein=no
+    build_skia=yes
+    _os=WINNT
+
+    DLLPOST=".dll"
+    LINKFLAGSNOUNDEFS=
+
+    if test "$host_cpu" = "aarch64"; then
+        build_skia=no
+        enable_gpgmepp=no
+        enable_coinmp=no
+        enable_firebird_sdbc=no
+    fi
+    ;;
+
+darwin*) # macOS
+    using_freetype_fontconfig=no
+    using_x11=no
+    build_skia=yes
+    enable_pagein=no
+    if test -n "$LODE_HOME" ; then
+        mac_sanitize_path
+        AC_MSG_NOTICE([sanitized the PATH to $PATH])
+    fi
+    _os=Darwin
+    INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
+    INSTROOTCONTENTSUFFIX=/Contents
+    SDKDIRNAME=${PRODUCTNAME_WITHOUT_SPACES}${PRODUCTVERSION}_SDK
+    # See "Default values, as such probably valid just for Linux" comment above the case "$host_os"
+    LINKFLAGSSHL="-dynamiclib"
+
+    # -fPIC is default
+    PICSWITCH=""
+
+    DLLPOST=".dylib"
+
+    # -undefined error is the default
+    LINKFLAGSNOUNDEFS=""
+    case "$host_cpu" in
+    aarch64|arm64)
+        # Apple's Clang uses "arm64"
+        host_cpu_for_clang=arm64
+    esac
+;;
+
+ios*) # iOS
+    using_freetype_fontconfig=no
+    using_x11=no
+    build_crypto=no
+    test_libcmis=no
+    test_openldap=no
+    test_webdav=no
+    if test -n "$LODE_HOME" ; then
+        mac_sanitize_path
+        AC_MSG_NOTICE([sanitized the PATH to $PATH])
+    fi
+    enable_gpgmepp=no
+    _os=iOS
+    enable_mpl_subset=yes
+    enable_lotuswordpro=no
+    disable_database_connectivity_dependencies
+    enable_coinmp=no
+    enable_lpsolve=no
+    enable_extension_integration=no
+    enable_xmlhelp=no
+    with_ppds=no
+    if test "$enable_ios_simulator" = "yes"; then
+        host=x86_64-apple-darwin
+    fi
+    # See "Default values, as such probably valid just for Linux" comment above the case "$host_os"
+    LINKFLAGSSHL="-dynamiclib"
+
+    # -fPIC is default
+    PICSWITCH=""
+
+    DLLPOST=".dylib"
+
+    # -undefined error is the default
+    LINKFLAGSNOUNDEFS=""
+
+    # HOST_PLATFORM is used for external projects and their configury typically doesn't like the "ios"
+    # part, so use aarch64-apple-darwin for now.
+    HOST_PLATFORM=aarch64-apple-darwin
+
+    # Apple's Clang uses "arm64"
+    host_cpu_for_clang=arm64
+;;
+
+freebsd*)
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    build_skia=yes
+    AC_MSG_CHECKING([the FreeBSD operating system release])
+    if test -n "$with_os_version"; then
+        OSVERSION="$with_os_version"
+    else
+        OSVERSION=`/sbin/sysctl -n kern.osreldate`
+    fi
+    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
+    AC_MSG_CHECKING([which thread library to use])
+    if test "$OSVERSION" -lt "500016"; then
+        PTHREAD_CFLAGS="-D_THREAD_SAFE"
+        PTHREAD_LIBS="-pthread"
+    elif test "$OSVERSION" -lt "502102"; then
+        PTHREAD_CFLAGS="-D_THREAD_SAFE"
+        PTHREAD_LIBS="-lc_r"
+    else
+        PTHREAD_CFLAGS=""
+        PTHREAD_LIBS="-pthread"
+    fi
+    AC_MSG_RESULT([$PTHREAD_LIBS])
+    _os=FreeBSD
+    ;;
+
+*netbsd*)
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    test_gtk3_kde5=no
+    build_skia=yes
+    PTHREAD_LIBS="-pthread -lpthread"
+    _os=NetBSD
+    ;;
+
+openbsd*)
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    PTHREAD_CFLAGS="-D_THREAD_SAFE"
+    PTHREAD_LIBS="-pthread"
+    _os=OpenBSD
+    ;;
+
+dragonfly*)
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    build_skia=yes
+    PTHREAD_LIBS="-pthread"
+    _os=DragonFly
+    ;;
+
+linux-android*)
+    # API exists, but seems not really usable since Android 7 AFAIK
+    usable_dlapi=no
+    using_freetype_fontconfig=yes
+    using_headless_plugin=no
+    using_x11=no
+    build_crypto=no
+    test_openldap=no
+    test_system_freetype=no
+    test_webdav=no
+    disable_database_connectivity_dependencies
+    enable_lotuswordpro=no
+    enable_mpl_subset=yes
+    enable_cairo_canvas=no
+    enable_coinmp=yes
+    enable_lpsolve=no
+    enable_odk=no
+    enable_python=no
+    enable_xmlhelp=no
+    _os=Android
+    ;;
+
+haiku*)
+    using_freetype_fontconfig=yes
+    using_x11=no
+    test_gtk3=no
+    test_gtk3_kde5=no
+    test_kf5=yes
+    test_kf6=yes
+    enable_odk=no
+    enable_coinmp=no
+    enable_pdfium=no
+    enable_sdremote=no
+    enable_postgresql_sdbc=no
+    enable_firebird_sdbc=no
+    _os=Haiku
+    ;;
+
+emscripten)
+    # API currently just exists in headers, not code
+    usable_dlapi=no
+    using_freetype_fontconfig=yes
+    using_x11=yes
+    test_openldap=no
+    test_qt5=yes
+    test_split_debug=yes
+    test_system_freetype=no
+    enable_compiler_plugins=no
+    enable_customtarget_components=yes
+    enable_split_debug=yes
+    enable_wasm_strip=yes
+    with_system_zlib=no
+    with_theme="colibre"
+    _os=Emscripten
+    ;;
+
+*)
+    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
+    ;;
+esac
+
+AC_SUBST(HOST_PLATFORM)
+
+if test -z "$using_x11" -o -z "$using_freetype_fontconfig"; then
+    AC_MSG_ERROR([You must set \$using_freetype_fontconfig and \$using_x11 for your platform])
+fi
+
+# Set defaults, if not set by platform
+test "${test_cups+set}" = set || test_cups="$using_x11"
+test "${test_dbus+set}" = set || test_dbus="$using_x11"
+test "${test_gen+set}" = set || test_gen="$using_x11"
+test "${test_gstreamer_1_0+set}" = set || test_gstreamer_1_0="$using_x11"
+test "${test_gtk3+set}" = set || test_gtk3="$using_x11"
+test "${test_gtk4+set}" = set || test_gtk4="$using_x11"
+test "${test_kf5+set}" = set || test_kf5="$using_x11"
+test "${test_kf6+set}" = set || test_kf6="$using_x11"
+# don't handle test_qt5, so it can disable test_kf5 later
+test "${test_qt6+set}" = set || test_qt6="$using_x11"
+test "${test_randr+set}" = set || test_randr="$using_x11"
+test "${test_xrender+set}" = set || test_xrender="$using_x11"
+test "${using_headless_plugin+set}" = set || using_headless_plugin="$using_freetype_fontconfig"
+
+test "${test_gtk3_kde5+set}" != set -a "$test_kf5" = yes -a "$test_gtk3" = yes && test_gtk3_kde5="yes"
+# Make sure fontconfig and freetype test both either system or not
+test "${test_system_fontconfig+set}" != set -a "${test_system_freetype+set}" = set && test_system_fontconfig="$test_system_freetype"
+test "${test_system_freetype+set}" != set -a "${test_system_fontconfig+set}" = set && test_system_freetype="$test_system_fontconfig"
+
+# convenience / platform overriding "fixes"
+# Don't sort!
+test "$test_kf5" = yes -a "$test_qt5" = no && test_kf5=no
+test "$test_kf5" = yes && test_qt5=yes
+test "$test_gtk3" != yes && enable_gtk3=no
+test "$test_gtk3" != yes -o "$test_kf5" != yes && test_gtk3_kde5=no
+test "$using_freetype_fontconfig" = no && using_headless_plugin=no
+test "$using_freetype_fontconfig" = yes && test_cairo=yes
+
+# Keep in sync with the above $using_x11 depending test default list
+disable_x11_tests()
+{
+    test_cups=no
+    test_dbus=no
+    test_gen=no
+    test_gstreamer_1_0=no
+    test_gtk3_kde5=no
+    test_gtk3=no
+    test_gtk4=no
+    test_kf5=no
+    test_kf6=no
+    test_qt5=no
+    test_qt6=no
+    test_randr=no
+    test_xrender=no
+}
+
+test "$using_x11" = yes && USING_X11=TRUE
+
+if test "$using_freetype_fontconfig" = yes; then
+    AC_DEFINE(USE_HEADLESS_CODE)
+    USE_HEADLESS_CODE=TRUE
+    if test "$using_headless_plugin" = yes; then
+        AC_DEFINE(ENABLE_HEADLESS)
+        ENABLE_HEADLESS=TRUE
+    fi
+else
+    test_fontconfig=no
+    test_freetype=no
+fi
+
+AC_SUBST(ENABLE_HEADLESS)
+AC_SUBST(USE_HEADLESS_CODE)
+
+AC_MSG_NOTICE([VCL platform has a usable dynamic loading API: $usable_dlapi])
+AC_MSG_NOTICE([VCL platform uses freetype+fontconfig: $using_freetype_fontconfig])
+AC_MSG_NOTICE([VCL platform uses headless plugin: $using_headless_plugin])
+AC_MSG_NOTICE([VCL platform uses X11: $using_x11])
+
+# ===================================================================
+#
+# End initial platform setup
+#
+# ===================================================================
+
+if test "$_os" = "Android" ; then
+    # Verify that the NDK and SDK options are proper
+    if test -z "$with_android_ndk"; then
+        AC_MSG_ERROR([the --with-android-ndk option is mandatory, unless it is available at external/android-ndk/.])
+    elif test ! -f "$ANDROID_NDK_DIR/meta/abis.json"; then
+        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
+    fi
+
+    if test -z "$ANDROID_SDK_DIR"; then
+        AC_MSG_ERROR([the --with-android-sdk option is mandatory, unless it is available at external/android-sdk-linux/.])
+    elif test ! -d "$ANDROID_SDK_DIR/platforms"; then
+        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
+    fi
+fi
+
+AC_SUBST(SDKDIRNAME)
+
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_LIBS)
+
+# Check for explicit A/C/CXX/OBJC/OBJCXX/LDFLAGS.
+# By default use the ones specified by our build system,
+# but explicit override is possible.
+AC_MSG_CHECKING(for explicit AFLAGS)
+if test -n "$AFLAGS"; then
+    AC_MSG_RESULT([$AFLAGS])
+    x_AFLAGS=
+else
+    AC_MSG_RESULT(no)
+    x_AFLAGS=[\#]
+fi
+AC_MSG_CHECKING(for explicit CFLAGS)
+if test -n "$CFLAGS"; then
+    AC_MSG_RESULT([$CFLAGS])
+    x_CFLAGS=
+else
+    AC_MSG_RESULT(no)
+    x_CFLAGS=[\#]
+fi
+AC_MSG_CHECKING(for explicit CXXFLAGS)
+if test -n "$CXXFLAGS"; then
+    AC_MSG_RESULT([$CXXFLAGS])
+    x_CXXFLAGS=
+else
+    AC_MSG_RESULT(no)
+    x_CXXFLAGS=[\#]
+fi
+AC_MSG_CHECKING(for explicit OBJCFLAGS)
+if test -n "$OBJCFLAGS"; then
+    AC_MSG_RESULT([$OBJCFLAGS])
+    x_OBJCFLAGS=
+else
+    AC_MSG_RESULT(no)
+    x_OBJCFLAGS=[\#]
+fi
+AC_MSG_CHECKING(for explicit OBJCXXFLAGS)
+if test -n "$OBJCXXFLAGS"; then
+    AC_MSG_RESULT([$OBJCXXFLAGS])
+    x_OBJCXXFLAGS=
+else
+    AC_MSG_RESULT(no)
+    x_OBJCXXFLAGS=[\#]
+fi
+AC_MSG_CHECKING(for explicit LDFLAGS)
+if test -n "$LDFLAGS"; then
+    AC_MSG_RESULT([$LDFLAGS])
+    x_LDFLAGS=
+else
+    AC_MSG_RESULT(no)
+    x_LDFLAGS=[\#]
+fi
+AC_SUBST(AFLAGS)
+AC_SUBST(CFLAGS)
+AC_SUBST(CXXFLAGS)
+AC_SUBST(OBJCFLAGS)
+AC_SUBST(OBJCXXFLAGS)
+AC_SUBST(LDFLAGS)
+AC_SUBST(x_AFLAGS)
+AC_SUBST(x_CFLAGS)
+AC_SUBST(x_CXXFLAGS)
+AC_SUBST(x_OBJCFLAGS)
+AC_SUBST(x_OBJCXXFLAGS)
+AC_SUBST(x_LDFLAGS)
+
+dnl These are potentially set for MSVC, in the code checking for UCRT below:
+my_original_CFLAGS=$CFLAGS
+my_original_CXXFLAGS=$CXXFLAGS
+my_original_CPPFLAGS=$CPPFLAGS
+
+dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
+dnl Needs to precede the AC_C_BIGENDIAN and AC_SEARCH_LIBS calls below, which apparently call
+dnl AC_PROG_CC internally.
+if test "$_os" != "WINNT"; then
+    # AC_PROG_CC sets CFLAGS to -g -O2 if not set, avoid that
+    save_CFLAGS=$CFLAGS
+    AC_PROG_CC
+    CFLAGS=$save_CFLAGS
+    if test -z "$CC_BASE"; then
+        CC_BASE=`first_arg_basename "$CC"`
+    fi
+fi
+
+if test "$_os" != "WINNT"; then
+    AC_C_BIGENDIAN([ENDIANNESS=big], [ENDIANNESS=little])
+else
+    ENDIANNESS=little
+fi
+AC_SUBST(ENDIANNESS)
+
+if test "$usable_dlapi" != no; then
+    AC_DEFINE([HAVE_DLAPI])
+    if test "$test_unix_dlapi" != no; then
+        save_LIBS="$LIBS"
+        AC_SEARCH_LIBS([dlsym], [dl],
+            [case "$ac_cv_search_dlsym" in -l*) UNIX_DLAPI_LIBS="$ac_cv_search_dlsym";; esac],
+            [AC_MSG_ERROR([dlsym not found in either libc nor libdl])])
+        LIBS="$save_LIBS"
+        AC_DEFINE([HAVE_UNIX_DLAPI])
+    fi
+fi
+AC_SUBST(UNIX_DLAPI_LIBS)
+
+# Check for a (GNU) backtrace implementation
+AC_ARG_VAR([BACKTRACE_CFLAGS], [Compiler flags needed to use backtrace(3)])
+AC_ARG_VAR([BACKTRACE_LIBS], [Linker flags needed to use backtrace(3)])
+AS_IF([test "x$BACKTRACE_LIBS$BACKTRACE_CFLAGS" = x], [
+    save_LIBS="$LIBS"
+    AC_SEARCH_LIBS([backtrace], [libexecinfo],
+        [case "$ac_cv_search_backtrace" in -l*) BACKTRACE_LIBS="$ac_cv_search_backtrace";; esac],
+        [PKG_CHECK_MODULES([BACKTRACE], [libexecinfo], [ac_cv_search_backtrace=], [:])])
+    LIBS="$save_LIBS"
+])
+AS_IF([test "x$ac_cv_search_backtrace" != xno ], [
+    AC_DEFINE([HAVE_FEATURE_BACKTRACE])
+])
+
+dnl ===================================================================
+dnl Sanity checks for Emscripten SDK setup
+dnl ===================================================================
+
+EMSCRIPTEN_MIN_MAJOR=2
+EMSCRIPTEN_MIN_MINOR=0
+EMSCRIPTEN_MIN_TINY=31
+EMSCRIPTEN_MIN_VERSION="${EMSCRIPTEN_MIN_MAJOR}.${EMSCRIPTEN_MIN_MINOR}.${EMSCRIPTEN_MIN_TINY}"
+
+if test "$_os" = "Emscripten"; then
+    AC_MSG_CHECKING([if Emscripten is at least $EMSCRIPTEN_MIN_VERSION])
+    AS_IF([test -z "$EMSDK"],
+          [AC_MSG_ERROR([No \$EMSDK environment variable.])])
+    EMSCRIPTEN_VERSION_H=$EMSDK/upstream/emscripten/cache/sysroot/include/emscripten/version.h
+    if test -f "$EMSCRIPTEN_VERSION_H"; then
+        EMSCRIPTEN_MAJOR=$($GREP __EMSCRIPTEN_major__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_major__ //p')
+        EMSCRIPTEN_MINOR=$($GREP __EMSCRIPTEN_minor__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_minor__ //p')
+        EMSCRIPTEN_TINY=$($GREP __EMSCRIPTEN_tiny__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_tiny__ //p')
+    else
+        EMSCRIPTEN_DEFINES=$(echo | emcc -dM -E - | $GREP __EMSCRIPTEN_)
+        EMSCRIPTEN_MAJOR=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_major__ //p')
+        EMSCRIPTEN_MINOR=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_minor__ //p')
+        EMSCRIPTEN_TINY=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_tiny__ //p')
+    fi
+
+    EMSCRIPTEN_VERSION="${EMSCRIPTEN_MAJOR}.${EMSCRIPTEN_MINOR}.${EMSCRIPTEN_TINY}"
+
+    check_semantic_version_three_prefixed EMSCRIPTEN MIN
+    if test $? -eq 0; then
+        AC_MSG_RESULT([yes ($EMSCRIPTEN_VERSION)])
+    else
+        AC_MSG_ERROR([no, found $EMSCRIPTEN_VERSION])
+    fi
+
+    EMSCRIPTEN_ERROR=0
+    if ! which emconfigure >/dev/null 2>&1; then
+        AC_MSG_WARN([emconfigure must be in your \$PATH])
+        EMSCRIPTEN_ERROR=1
+    fi
+    if test -z "$EMMAKEN_JUST_CONFIGURE"; then
+        AC_MSG_WARN(["\$EMMAKEN_JUST_CONFIGURE wasn't set by emconfigure. Prefix configure or use autogen.sh])
+        EMSCRIPTEN_ERROR=1
+    fi
+    EMSDK_FILE_PACKAGER="$(em-config EMSCRIPTEN_ROOT)"/tools/file_packager
+    if ! test -x "$EMSDK_FILE_PACKAGER"; then
+        AC_MSG_WARN([No file_packager found in $(em-config EMSCRIPTEN_ROOT)/tools/file_packager.])
+        EMSCRIPTEN_ERROR=1
+    fi
+    if test $EMSCRIPTEN_ERROR -ne 0; then
+        AC_MSG_ERROR(["Please fix your EMSDK setup to build with Emscripten!"])
+    fi
+fi
+AC_SUBST(EMSDK_FILE_PACKAGER)
+
+###############################################################################
+# Extensions switches --enable/--disable
+###############################################################################
+# By default these should be enabled unless having extra dependencies.
+# If there is extra dependency over configure options then the enable should
+# be automagic based on whether the requiring feature is enabled or not.
+# All this options change anything only with --enable-extension-integration.
+
+# The name of this option and its help string makes it sound as if
+# extensions are built anyway, just not integrated in the installer,
+# if you use --disable-extension-integration. Is that really the
+# case?
+
+AC_ARG_ENABLE(ios-simulator,
+    AS_HELP_STRING([--enable-ios-simulator],
+        [build for iOS simulator])
+)
+
+libo_FUZZ_ARG_ENABLE(extension-integration,
+    AS_HELP_STRING([--disable-extension-integration],
+        [Disable integration of the built extensions in the installer of the
+         product. Use this switch to disable the integration.])
+)
+
+AC_ARG_ENABLE(avmedia,
+    AS_HELP_STRING([--disable-avmedia],
+        [Disable displaying and inserting AV media in documents. Work in progress, use only if you are hacking on it.]),
+,test "${enable_avmedia+set}" = set || enable_avmedia=yes)
+
+AC_ARG_ENABLE(database-connectivity,
+    AS_HELP_STRING([--disable-database-connectivity],
+        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
+)
+
+# This doesn't mean not building (or "integrating") extensions
+# (although it probably should; i.e. it should imply
+# --disable-extension-integration I guess), it means not supporting
+# any extension mechanism at all
+libo_FUZZ_ARG_ENABLE(extensions,
+    AS_HELP_STRING([--disable-extensions],
+        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
+)
+
+AC_ARG_ENABLE(scripting,
+    AS_HELP_STRING([--disable-scripting],
+        [Disable BASIC, Java and Python. Work in progress, use only if you are hacking on it.]),
+,test "${enable_scripting+set}" = set || enable_scripting=yes)
+
+# This is mainly for Android and iOS, but could potentially be used in some
+# special case otherwise, too, so factored out as a separate setting
+
+AC_ARG_ENABLE(dynamic-loading,
+    AS_HELP_STRING([--disable-dynamic-loading],
+        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
+)
+
+libo_FUZZ_ARG_ENABLE(report-builder,
+    AS_HELP_STRING([--disable-report-builder],
+        [Disable the Report Builder.])
+)
+
+libo_FUZZ_ARG_ENABLE(ext-wiki-publisher,
+    AS_HELP_STRING([--enable-ext-wiki-publisher],
+        [Enable the Wiki Publisher extension.])
+)
+
+libo_FUZZ_ARG_ENABLE(lpsolve,
+    AS_HELP_STRING([--disable-lpsolve],
+        [Disable compilation of the lp solve solver ])
+)
+libo_FUZZ_ARG_ENABLE(coinmp,
+    AS_HELP_STRING([--disable-coinmp],
+        [Disable compilation of the CoinMP solver ])
+)
+
+libo_FUZZ_ARG_ENABLE(pdfimport,
+    AS_HELP_STRING([--disable-pdfimport],
+        [Disable building the PDF import feature.])
+)
+
+libo_FUZZ_ARG_ENABLE(pdfium,
+    AS_HELP_STRING([--disable-pdfium],
+        [Disable building PDFium. Results in unsecure PDF signature verification.])
+)
+
+libo_FUZZ_ARG_ENABLE(skia,
+    AS_HELP_STRING([--disable-skia],
+        [Disable building Skia. Use --enable-skia=debug to build without optimizations.])
+)
+
+###############################################################################
+
+dnl ---------- *** ----------
+
+libo_FUZZ_ARG_ENABLE(mergelibs,
+    AS_HELP_STRING([--enable-mergelibs],
+        [Merge several of the smaller libraries into one big, "merged", one.])
+)
+
+libo_FUZZ_ARG_ENABLE(breakpad,
+    AS_HELP_STRING([--enable-breakpad],
+        [Enables breakpad for crash reporting.])
+)
+
+libo_FUZZ_ARG_ENABLE(crashdump,
+    AS_HELP_STRING([--disable-crashdump],
+        [Disable dump.ini and dump-file, when --enable-breakpad])
+)
+
+AC_ARG_ENABLE(fetch-external,
+    AS_HELP_STRING([--disable-fetch-external],
+        [Disables fetching external tarballs from web sources.])
+)
+
+AC_ARG_ENABLE(fuzzers,
+    AS_HELP_STRING([--enable-fuzzers],
+        [Enables building libfuzzer targets for fuzz testing.])
+)
+
+libo_FUZZ_ARG_ENABLE(pch,
+    AS_HELP_STRING([--enable-pch=<yes/no/system/base/normal/full>],
+        [Enables precompiled header support for C++. Forced default on Windows/VC build.
+         Using 'system' will include only external headers, 'base' will add also headers
+         from base modules, 'normal' will also add all headers except from the module built,
+         'full' will use all suitable headers even from a module itself.])
+)
+
+libo_FUZZ_ARG_ENABLE(epm,
+    AS_HELP_STRING([--enable-epm],
+        [LibreOffice includes self-packaging code, that requires epm, however epm is
+         useless for large scale package building.])
+)
+
+libo_FUZZ_ARG_ENABLE(odk,
+    AS_HELP_STRING([--enable-odk],
+        [Enable building the Office Development Kit, the part that extensions need to build against])
+)
+
+AC_ARG_ENABLE(mpl-subset,
+    AS_HELP_STRING([--enable-mpl-subset],
+        [Don't compile any pieces which are not MPL or more liberally licensed])
+)
+
+libo_FUZZ_ARG_ENABLE(evolution2,
+    AS_HELP_STRING([--enable-evolution2],
+        [Allows the built-in evolution 2 addressbook connectivity build to be
+         enabled.])
+)
+
+AC_ARG_ENABLE(avahi,
+    AS_HELP_STRING([--enable-avahi],
+        [Determines whether to use Avahi to advertise Impress to remote controls.])
+)
+
+libo_FUZZ_ARG_ENABLE(werror,
+    AS_HELP_STRING([--enable-werror],
+        [Turn warnings to errors. (Has no effect in modules where the treating
+         of warnings as errors is disabled explicitly.)]),
+,)
+
+libo_FUZZ_ARG_ENABLE(assert-always-abort,
+    AS_HELP_STRING([--enable-assert-always-abort],
+        [make assert() failures abort even when building without --enable-debug or --enable-dbgutil.]),
+,)
+
+libo_FUZZ_ARG_ENABLE(dbgutil,
+    AS_HELP_STRING([--enable-dbgutil],
+        [Provide debugging support from --enable-debug and include additional debugging
+         utilities such as object counting or more expensive checks.
+         This is the recommended option for developers.
+         Note that this makes the build ABI incompatible, it is not possible to mix object
+         files or libraries from a --enable-dbgutil and a --disable-dbgutil build.]))
+
+libo_FUZZ_ARG_ENABLE(debug,
+    AS_HELP_STRING([--enable-debug],
+        [Include debugging information, disable compiler optimization and inlining plus
+         extra debugging code like assertions. Extra large build! (enables -g compiler flag).]))
+
+libo_FUZZ_ARG_ENABLE(split-debug,
+    AS_HELP_STRING([--disable-split-debug],
+        [Disable using split debug information (-gsplit-dwarf compile flag). Split debug information
+         saves disk space and build time, but requires tools that support it (both build tools and debuggers).]))
+
+libo_FUZZ_ARG_ENABLE(gdb-index,
+    AS_HELP_STRING([--disable-gdb-index],
+        [Disables creating debug information in the gdb index format, which makes gdb start faster.
+         The feature requires a linker that supports the --gdb-index option.]))
+
+libo_FUZZ_ARG_ENABLE(sal-log,
+    AS_HELP_STRING([--enable-sal-log],
+        [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.]))
+
+libo_FUZZ_ARG_ENABLE(symbols,
+    AS_HELP_STRING([--enable-symbols],
+        [Generate debug information.
+         By default, enabled for --enable-debug and --enable-dbgutil, disabled
+         otherwise. It is possible to explicitly specify gbuild build targets
+         (where 'all' means everything, '-' prepended means to not enable, '/' appended means
+         everything in the directory; there is no ordering, more specific overrides
+         more general, and disabling takes precedence).
+         Example: --enable-symbols="all -sw/ -Library_sc".]))
+
+libo_FUZZ_ARG_ENABLE(optimized,
+    AS_HELP_STRING([--enable-optimized=<yes/no/debug>],
+        [Whether to compile with optimization flags.
+         By default, disabled for --enable-debug and --enable-dbgutil, enabled
+         otherwise. Using 'debug' will try to use only optimizations that should
+         not interfere with debugging. For Emscripten we default to optimized (-O1)
+         debug build, as otherwise binaries become too large.]))
+
+libo_FUZZ_ARG_ENABLE(runtime-optimizations,
+    AS_HELP_STRING([--disable-runtime-optimizations],
+        [Statically disable certain runtime optimizations (like rtl/alloc.h or
+         JVM JIT) that are known to interact badly with certain dynamic analysis
+         tools (like -fsanitize=address or Valgrind).  By default, disabled iff
+         CC contains "-fsanitize=*".  (For Valgrind, those runtime optimizations
+         are typically disabled dynamically via RUNNING_ON_VALGRIND.)]))
+
+AC_ARG_WITH(valgrind,
+    AS_HELP_STRING([--with-valgrind],
+        [Make availability of Valgrind headers a hard requirement.]))
+
+libo_FUZZ_ARG_ENABLE(compiler-plugins,
+    AS_HELP_STRING([--enable-compiler-plugins],
+        [Enable compiler plugins that will perform additional checks during
+         building. Enabled automatically by --enable-dbgutil.
+         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
+COMPILER_PLUGINS_DEBUG=
+if test "$enable_compiler_plugins" = debug; then
+    enable_compiler_plugins=yes
+    COMPILER_PLUGINS_DEBUG=TRUE
+fi
+
+libo_FUZZ_ARG_ENABLE(compiler-plugins-analyzer-pch,
+    AS_HELP_STRING([--disable-compiler-plugins-analyzer-pch],
+        [Disable use of precompiled headers when running the Clang compiler plugin analyzer.  Not
+         relevant in the --disable-compiler-plugins case.]))
+
+libo_FUZZ_ARG_ENABLE(ooenv,
+    AS_HELP_STRING([--enable-ooenv],
+        [Enable ooenv for the instdir installation.]))
+
+AC_ARG_ENABLE(lto,
+    AS_HELP_STRING([--enable-lto],
+        [Enable link-time optimization. Suitable for (optimised) product builds. Building might take
+         longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold'
+         linker.)]))
+
+AC_ARG_ENABLE(python,
+    AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>],
+        [Enables or disables Python support at run-time.
+         Also specifies what Python to use at build-time.
+         'fully-internal' even forces the internal version for uses of Python
+         during the build.
+         On macOS the only choices are
+         'internal' (default) or 'fully-internal'. Otherwise the default is 'auto'.
+         ]))
+
+libo_FUZZ_ARG_ENABLE(gtk3,
+    AS_HELP_STRING([--disable-gtk3],
+        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
+,test "${test_gtk3}" = no -o "${enable_gtk3+set}" = set || enable_gtk3=yes)
+
+AC_ARG_ENABLE(gtk4,
+    AS_HELP_STRING([--enable-gtk4],
+        [Determines whether to use Gtk+ 4.0 vclplug on platforms where Gtk+ 4.0 is available.]))
+
+AC_ARG_ENABLE(atspi-tests,
+    AS_HELP_STRING([--disable-atspi-tests],
+        [Determines whether to enable AT-SPI2 tests for the GTK3 vclplug.]))
+
+AC_ARG_ENABLE(introspection,
+    AS_HELP_STRING([--enable-introspection],
+        [Generate files for GObject introspection.  Requires --enable-gtk3.  (Typically used by
+         Linux distributions.)]))
+
+AC_ARG_ENABLE(split-app-modules,
+    AS_HELP_STRING([--enable-split-app-modules],
+        [Split file lists for app modules, e.g. base, calc.
+         Has effect only with make distro-pack-install]),
+,)
+
+AC_ARG_ENABLE(split-opt-features,
+    AS_HELP_STRING([--enable-split-opt-features],
+        [Split file lists for some optional features, e.g. pyuno, testtool.
+         Has effect only with make distro-pack-install]),
+,)
+
+libo_FUZZ_ARG_ENABLE(cairo-canvas,
+    AS_HELP_STRING([--disable-cairo-canvas],
+        [Determines whether to build the Cairo canvas on platforms where Cairo is available.]),
+,)
+
+libo_FUZZ_ARG_ENABLE(dbus,
+    AS_HELP_STRING([--disable-dbus],
+        [Determines whether to enable features that depend on dbus.
+         e.g. Presentation mode screensaver control, bluetooth presentation control, automatic font install]),
+,test "${enable_dbus+set}" = set || enable_dbus=yes)
+
+libo_FUZZ_ARG_ENABLE(sdremote,
+    AS_HELP_STRING([--disable-sdremote],
+        [Determines whether to enable Impress remote control (i.e. the server component).]),
+,test "${enable_sdremote+set}" = set || enable_sdremote=yes)
+
+libo_FUZZ_ARG_ENABLE(sdremote-bluetooth,
+    AS_HELP_STRING([--disable-sdremote-bluetooth],
+        [Determines whether to build sdremote with bluetooth support.
+         Requires dbus on Linux.]))
+
+libo_FUZZ_ARG_ENABLE(gio,
+    AS_HELP_STRING([--disable-gio],
+        [Determines whether to use the GIO support.]),
+,test "${enable_gio+set}" = set || enable_gio=yes)
+
+AC_ARG_ENABLE(qt5,
+    AS_HELP_STRING([--enable-qt5],
+        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
+         available.]),
+,)
+
+AC_ARG_ENABLE(qt6,
+    AS_HELP_STRING([--enable-qt6],
+        [Determines whether to use Qt6 vclplug on platforms where Qt6 is
+         available.]),
+,)
+
+AC_ARG_ENABLE(kf5,
+    AS_HELP_STRING([--enable-kf5],
+        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
+         KF5 are available.]),
+,)
+
+AC_ARG_ENABLE(kf6,
+    AS_HELP_STRING([--enable-kf6],
+        [Determines whether to use KF6 vclplug on platforms where Qt6 and
+         KF6 are available.]),
+,)
+
+
+AC_ARG_ENABLE(gtk3_kde5,
+    AS_HELP_STRING([--enable-gtk3-kde5],
+        [Determines whether to use Gtk3 vclplug with KF5 file dialogs on
+         platforms where Gtk3, Qt5 and Plasma is available.]),
+,)
+
+AC_ARG_ENABLE(gen,
+    AS_HELP_STRING([--enable-gen],
+        [To select the gen backend in case of --disable-dynamic-loading.
+         Per default auto-enabled when X11 is used.]),
+,test "${test_gen}" = no -o "${enable_gen+set}" = set || enable_gen=yes)
+
+AC_ARG_ENABLE(gui,
+    AS_HELP_STRING([--disable-gui],
+        [Disable use of X11 or Wayland to reduce dependencies (e.g. for building LibreOfficeKit).]),
+,enable_gui=yes)
+
+libo_FUZZ_ARG_ENABLE(randr,
+    AS_HELP_STRING([--disable-randr],
+        [Disable RandR support in the vcl project.]),
+,test "${enable_randr+set}" = set || enable_randr=yes)
+
+libo_FUZZ_ARG_ENABLE(gstreamer-1-0,
+    AS_HELP_STRING([--disable-gstreamer-1-0],
+        [Disable building with the gstreamer 1.0 avmedia backend.]),
+,test "${enable_gstreamer_1_0+set}" = set || enable_gstreamer_1_0=yes)
+
+libo_FUZZ_ARG_ENABLE([eot],
+    [AS_HELP_STRING([--enable-eot],
+        [Enable support for Embedded OpenType fonts.])],
+,test "${enable_eot+set}" = set || enable_eot=no)
+
+libo_FUZZ_ARG_ENABLE(cve-tests,
+    AS_HELP_STRING([--disable-cve-tests],
+        [Prevent CVE tests to be executed]),
+,)
+
+AC_ARG_ENABLE(build-opensymbol,
+    AS_HELP_STRING([--enable-build-opensymbol],
+        [Do not use the prebuilt opens___.ttf. Build it instead. This needs
+         fontforge installed.]),
+,)
+
+AC_ARG_ENABLE(dependency-tracking,
+    AS_HELP_STRING([--enable-dependency-tracking],
+        [Do not reject slow dependency extractors.])[
+  --disable-dependency-tracking
+                          Disables generation of dependency information.
+                          Speed up one-time builds.],
+,)
+
+AC_ARG_ENABLE(icecream,
+    AS_HELP_STRING([--enable-icecream],
+        [Use the 'icecream' distributed compiling tool to speedup the compilation.
+         It defaults to /opt/icecream for the location of the icecream gcc/g++
+         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
+,)
+
+AC_ARG_ENABLE(ld,
+    AS_HELP_STRING([--enable-ld=<linker>],
+        [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.
+         By default tries to use the best linker possible, use --disable-ld to use the default linker.
+         If <linker> contains any ':', the part before the first ':' is used as the value of
+         -fuse-ld, while the part after the first ':' is used as the value of --ld-path (which is
+         needed for Clang 12).]),
+,)
+
+libo_FUZZ_ARG_ENABLE(cups,
+    AS_HELP_STRING([--disable-cups],
+        [Do not build cups support.])
+)
+
+AC_ARG_ENABLE(ccache,
+    AS_HELP_STRING([--disable-ccache],
+        [Do not try to use ccache automatically.
+         By default we will try to detect if ccache is available; in that case if
+         CC/CXX are not yet set, and --enable-icecream is not given, we
+         attempt to use ccache. --disable-ccache disables ccache completely.
+         Additionally ccache's depend mode is enabled if possible,
+         use --enable-ccache=nodepend to enable ccache without depend mode.
+]),
+,)
+
+AC_ARG_ENABLE(z7-debug,
+    AS_HELP_STRING([--enable-z7-debug],
+        [Makes the MSVC compiler use -Z7 for debugging instead of the default -Zi. Using this option takes
+         more disk spaces but allows to use ccache. Final PDB files are created even with this option enabled.
+         Enabled by default if ccache is detected.]))
+
+libo_FUZZ_ARG_ENABLE(online-update,
+    AS_HELP_STRING([--enable-online-update],
+        [Enable the online update service that will check for new versions of
+         LibreOffice. Disabled by default. Requires --with-privacy-policy-url to be set.]),
+,)
+
+libo_FUZZ_ARG_ENABLE(online-update-mar,
+    AS_HELP_STRING([--enable-online-update-mar],
+        [Enable the experimental Mozilla-like online update service that will
+         check for new versions of LibreOffice. Disabled by default.]),
+,)
+
+libo_FUZZ_ARG_WITH(online-update-mar-baseurl,
+    AS_HELP_STRING([--with-online-update-mar-baseurl=...],
+        [Set the base URL value for --enable-online-update-mar.
+         (Can be left off for debug purposes, even if that may render the feature
+         non-functional.)]),
+,)
+
+libo_FUZZ_ARG_WITH(online-update-mar-certificateder,
+    AS_HELP_STRING([--with-online-update-mar-certificateder=...],
+        [Set the certificate DER value for --enable-online-update-mar.
+         (Can be left off for debug purposes, even if that may render the feature
+         non-functional.)]),
+,)
+
+libo_FUZZ_ARG_WITH(online-update-mar-certificatename,
+    AS_HELP_STRING([--with-online-update-mar-certificatename=...],
+        [Set the certificate name value for --enable-online-update-mar.
+         (Can be left off for debug purposes, even if that may render the feature
+         non-functional.)]),
+,)
+
+libo_FUZZ_ARG_WITH(online-update-mar-certificatepath,
+    AS_HELP_STRING([--with-online-update-mar-certificatepath=...],
+        [Set the certificate path value for --enable-online-update-mar.
+         (Can be left off for debug purposes, even if that may render the feature
+         non-functional.)]),
+,)
+
+libo_FUZZ_ARG_WITH(online-update-mar-serverurl,
+    AS_HELP_STRING([--with-online-update-mar-serverurl=...],
+        [Set the server URL value for --enable-online-update-mar.
+         (Can be left off for debug purposes, even if that may render the feature
+         non-functional.)]),
+,)
+
+libo_FUZZ_ARG_WITH(online-update-mar-uploadurl,
+    AS_HELP_STRING([--with-online-update-mar-uploadurl=...],
+        [Set the upload URL value for --enable-online-update-mar.
+         (Can be left off for debug purposes, even if that may render the feature
+         non-functional.)]),
+,)
+
+libo_FUZZ_ARG_ENABLE(extension-update,
+    AS_HELP_STRING([--disable-extension-update],
+        [Disable possibility to update installed extensions.]),
+,)
+
+libo_FUZZ_ARG_ENABLE(release-build,
+    AS_HELP_STRING([--enable-release-build],
+        [Enable release build. Note that the "release build" choice is orthogonal to
+         whether symbols are present, debug info is generated, or optimization
+         is done.
+         See https://wiki.documentfoundation.org/Development/DevBuild]),
+,)
+
+AC_ARG_ENABLE(windows-build-signing,
+    AS_HELP_STRING([--enable-windows-build-signing],
+        [Enable signing of windows binaries (*.exe, *.dll)]),
+,)
+
+AC_ARG_ENABLE(silent-msi,
+    AS_HELP_STRING([--enable-silent-msi],
+        [Enable MSI with LIMITUI=1 (silent install).]),
+,)
+
+AC_ARG_ENABLE(wix,
+    AS_HELP_STRING([--enable-wix],
+        [Build Windows installer using WiX.]),
+,)
+
+AC_ARG_ENABLE(macosx-code-signing,
+    AS_HELP_STRING([--enable-macosx-code-signing=<identity>],
+        [Sign executables, dylibs, frameworks and the app bundle. If you
+         don't provide an identity the first suitable certificate
+         in your keychain is used.]),
+,)
+
+AC_ARG_ENABLE(macosx-package-signing,
+    AS_HELP_STRING([--enable-macosx-package-signing=<identity>],
+        [Create a .pkg suitable for uploading to the Mac App Store and sign
+         it. If you don't provide an identity the first suitable certificate
+         in your keychain is used.]),
+,)
+
+AC_ARG_ENABLE(macosx-sandbox,
+    AS_HELP_STRING([--enable-macosx-sandbox],
+        [Make the app bundle run in a sandbox. Requires code signing.
+         Is required by apps distributed in the Mac App Store, and implies
+         adherence to App Store rules.]),
+,)
+
+AC_ARG_WITH(macosx-bundle-identifier,
+    AS_HELP_STRING([--with-macosx-bundle-identifier=tld.mumble.orifice.TheOffice],
+        [Define the macOS bundle identifier. Default is the somewhat weird
+         org.libreoffice.script ("script", huh?).]),
+,with_macosx_bundle_identifier=org.libreoffice.script)
+
+AC_ARG_WITH(macosx-provisioning-profile,
+    AS_HELP_STRING([--with-macosx-provisioning-profile=/path/to/mac.provisionprofile],
+        [Specify the path to a provisioning profile to use]),
+,)
+
+AC_ARG_WITH(product-name,
+    AS_HELP_STRING([--with-product-name='My Own Office Suite'],
+        [Define the product name. Default is AC_PACKAGE_NAME.]),
+,with_product_name=$PRODUCTNAME)
+
+libo_FUZZ_ARG_ENABLE(community-flavor,
+    AS_HELP_STRING([--disable-community-flavor],
+        [Disable the Community branding.]),
+,)
+
+AC_ARG_WITH(package-version,
+    AS_HELP_STRING([--with-package-version='3.1.4.5'],
+        [Define the package version. Default is AC_PACKAGE_VERSION. Use only if you distribute an own build for macOS.]),
+,)
+
+libo_FUZZ_ARG_ENABLE(readonly-installset,
+    AS_HELP_STRING([--enable-readonly-installset],
+        [Prevents any attempts by LibreOffice to write into its installation. That means
+         at least that no "system-wide" extensions can be added. Partly experimental work in
+         progress, probably not fully implemented. Always enabled for macOS.]),
+,)
+
+libo_FUZZ_ARG_ENABLE(mariadb-sdbc,
+    AS_HELP_STRING([--disable-mariadb-sdbc],
+        [Disable the build of the MariaDB/MySQL-SDBC driver.])
+)
+
+libo_FUZZ_ARG_ENABLE(postgresql-sdbc,
+    AS_HELP_STRING([--disable-postgresql-sdbc],
+        [Disable the build of the PostgreSQL-SDBC driver.])
+)
+
+libo_FUZZ_ARG_ENABLE(lotuswordpro,
+    AS_HELP_STRING([--disable-lotuswordpro],
+        [Disable the build of the Lotus Word Pro filter.]),
+,test "${enable_lotuswordpro+set}" = set || enable_lotuswordpro=yes)
+
+libo_FUZZ_ARG_ENABLE(firebird-sdbc,
+    AS_HELP_STRING([--disable-firebird-sdbc],
+        [Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
+,test "${enable_firebird_sdbc+set}" = set || enable_firebird_sdbc=yes)
+
+AC_ARG_ENABLE(bogus-pkg-config,
+    AS_HELP_STRING([--enable-bogus-pkg-config],
+        [MACOSX only: on MacOSX pkg-config can cause trouble. by default if one is found in the PATH, an error is issued. This flag turn that error into a warning.]),
+)
+
+AC_ARG_ENABLE(openssl,
+    AS_HELP_STRING([--disable-openssl],
+        [Disable using libssl/libcrypto from OpenSSL. If disabled,
+         components will use NSS. Work in progress,
+         use only if you are hacking on it.]),
+,enable_openssl=yes)
+
+libo_FUZZ_ARG_ENABLE(cipher-openssl-backend,
+    AS_HELP_STRING([--enable-cipher-openssl-backend],
+        [Enable using OpenSSL as the actual implementation of the rtl/cipher.h functionality.
+         Requires --enable-openssl.]))
+
+AC_ARG_ENABLE(nss,
+    AS_HELP_STRING([--disable-nss],
+        [Disable using NSS. If disabled,
+         components will use openssl. Work in progress,
+         use only if you are hacking on it.]),
+,enable_nss=yes)
+
+AC_ARG_ENABLE(library-bin-tar,
+    AS_HELP_STRING([--enable-library-bin-tar],
+        [Enable the building and reused of tarball of binary build for some 'external' libraries.
+        Some libraries can save their build result in a tarball
+        stored in TARFILE_LOCATION. That binary tarball is
+        uniquely identified by the source tarball,
+        the content of the config_host.mk file and the content
+        of the top-level directory in core for that library
+        If this option is enabled, then if such a tarfile exist, it will be untarred
+        instead of the source tarfile, and the build step will be skipped for that
+        library.
+        If a proper tarfile does not exist, then the normal source-based
+        build is done for that library and a proper binary tarfile is created
+        for the next time.]),
+)
+
+AC_ARG_ENABLE(dconf,
+    AS_HELP_STRING([--disable-dconf],
+        [Disable the dconf configuration backend (enabled by default where
+         available).]))
+
+libo_FUZZ_ARG_ENABLE(formula-logger,
+    AS_HELP_STRING(
+        [--enable-formula-logger],
+        [Enable formula logger for logging formula calculation flow in Calc.]
+    )
+)
+
+AC_ARG_ENABLE(ldap,
+    AS_HELP_STRING([--disable-ldap],
+        [Disable LDAP support.]),
+,enable_ldap=yes)
+
+AC_ARG_ENABLE(opencl,
+    AS_HELP_STRING([--disable-opencl],
+        [Disable OpenCL support.]),
+,enable_opencl=yes)
+
+libo_FUZZ_ARG_ENABLE(librelogo,
+    AS_HELP_STRING([--disable-librelogo],
+        [Do not build LibreLogo.]),
+,enable_librelogo=yes)
+
+AC_ARG_ENABLE(wasm-strip,
+    AS_HELP_STRING([--enable-wasm-strip],
+        [Strip the static build like for WASM/emscripten platform.]),
+,)
+
+AC_ARG_WITH(main-module,
+    AS_HELP_STRING([--with-main-module=<writer/calc>],
+        [Specify which main module to build for wasm.
+        Default value is 'writer'.]),
+,)
+
+AC_ARG_ENABLE(wasm-exceptions,
+    AS_HELP_STRING([--enable-wasm-exceptions],
+        [Build with native WASM exceptions (AKA -fwasm-exceptions),
+        matter of fact, this is currently not finished by any implementation)
+        (see https://webassembly.org/roadmap/ for the current state]),
+,)
+
+AC_ARG_ENABLE(xmlhelp,
+    AS_HELP_STRING([--disable-xmlhelp],
+        [Disable XML help support]),
+,enable_xmlhelp=yes)
+
+AC_ARG_ENABLE(customtarget-components,
+    AS_HELP_STRING([--enable-customtarget-components],
+        [Generates the static UNO object constructor mapping from the build.]))
+
+dnl ===================================================================
+dnl Optional Packages (--with/without-)
+dnl ===================================================================
+
+AC_ARG_WITH(gcc-home,
+    AS_HELP_STRING([--with-gcc-home],
+        [Specify the location of gcc/g++ manually. This can be used in conjunction
+         with --enable-icecream when icecream gcc/g++ wrappers are installed in a
+         non-default path.]),
+,)
+
+AC_ARG_WITH(gnu-patch,
+    AS_HELP_STRING([--with-gnu-patch],
+        [Specify location of GNU patch on Solaris or FreeBSD.]),
+,)
+
+AC_ARG_WITH(build-platform-configure-options,
+    AS_HELP_STRING([--with-build-platform-configure-options],
+        [Specify options for the configure script run for the *build* platform in a cross-compilation]),
+,)
+
+AC_ARG_WITH(gnu-cp,
+    AS_HELP_STRING([--with-gnu-cp],
+        [Specify location of GNU cp on Solaris or FreeBSD.]),
+,)
+
+AC_ARG_WITH(external-tar,
+    AS_HELP_STRING([--with-external-tar=<TARFILE_PATH>],
+        [Specify an absolute path of where to find (and store) tarfiles.]),
+    TARFILE_LOCATION=$withval ,
+)
+
+AC_ARG_WITH(referenced-git,
+    AS_HELP_STRING([--with-referenced-git=<OTHER_CHECKOUT_DIR>],
+        [Specify another checkout directory to reference. This makes use of
+                 git submodule update --reference, and saves a lot of diskspace
+                 when having multiple trees side-by-side.]),
+    GIT_REFERENCE_SRC=$withval ,
+)
+
+AC_ARG_WITH(linked-git,
+    AS_HELP_STRING([--with-linked-git=<submodules repo basedir>],
+        [Specify a directory where the repositories of submodules are located.
+         This uses a method similar to git-new-workdir to get submodules.]),
+    GIT_LINK_SRC=$withval ,
+)
+
+AC_ARG_WITH(galleries,
+    AS_HELP_STRING([--with-galleries],
+        [Specify how galleries should be built. It is possible either to
+         build these internally from source ("build"),
+         or to disable them ("no")]),
+)
+
+AC_ARG_WITH(templates,
+    AS_HELP_STRING([--with-templates],
+        [Specify we build with or without template files. It is possible either to
+         build with templates ("yes"),
+         or to disable them ("no")]),
+)
+
+AC_ARG_WITH(theme,
+    AS_HELP_STRING([--with-theme="theme1 theme2..."],
+        [Choose which themes to include. By default those themes with an '*' are included.
+         Possible choices: *breeze, *breeze_dark, *breeze_dark_svg, *breeze_svg,
+         *colibre, *colibre_svg, *colibre_dark, *colibre_dark_svg,
+         *elementary, *elementary_svg,
+         *karasa_jaga, *karasa_jaga_svg,
+         *sifr, *sifr_dark, *sifr_dark_svg, *sifr_svg,
+         *sukapura, *sukapura_dark, *sukapura_dark_svg, *sukapura_svg.]),
+,)
+
+libo_FUZZ_ARG_WITH(helppack-integration,
+    AS_HELP_STRING([--without-helppack-integration],
+        [It will not integrate the helppacks to the installer
+         of the product. Please use this switch to use the online help
+         or separate help packages.]),
+,)
+
+libo_FUZZ_ARG_WITH(fonts,
+    AS_HELP_STRING([--without-fonts],
+        [LibreOffice includes some third-party fonts to provide a reliable basis for
+         help content, templates, samples, etc. When these fonts are already
+         known to be available on the system then you should use this option.]),
+,)
+
+AC_ARG_WITH(epm,
+    AS_HELP_STRING([--with-epm],
+        [Decides which epm to use. Default is to use the one from the system if
+         one is built. When either this is not there or you say =internal epm
+         will be built.]),
+,)
+
+AC_ARG_WITH(package-format,
+    AS_HELP_STRING([--with-package-format],
+        [Specify package format(s) for LibreOffice installation sets. The
+         implicit --without-package-format leads to no installation sets being
+         generated. Possible values: archive, bsd, deb, dmg,
+         installed, msi, pkg, and rpm.
+         Example: --with-package-format='deb rpm']),
+,)
+
+AC_ARG_WITH(tls,
+    AS_HELP_STRING([--with-tls],
+        [Decides which TLS/SSL and cryptographic implementations to use for
+         LibreOffice's code. Default is to use NSS although OpenSSL is also
+         possible. Notice that selecting NSS restricts the usage of OpenSSL
+         in LO's code but selecting OpenSSL doesn't restrict by now the
+         usage of NSS in LO's code. Possible values: openssl, nss.
+         Example: --with-tls="nss"]),
+,)
+
+AC_ARG_WITH(system-libs,
+    AS_HELP_STRING([--with-system-libs],
+        [Use libraries already on system -- enables all --with-system-* flags.]),
+,)
+
+AC_ARG_WITH(system-bzip2,
+    AS_HELP_STRING([--with-system-bzip2],
+        [Use bzip2 already on system. Used when --enable-online-update-mar
+        or --enable-python=internal]),,
+    [with_system_bzip2="$with_system_libs"])
+
+AC_ARG_WITH(system-headers,
+    AS_HELP_STRING([--with-system-headers],
+        [Use headers already on system -- enables all --with-system-* flags for
+         external packages whose headers are the only entities used i.e.
+         boost/odbc/sane-header(s).]),,
+    [with_system_headers="$with_system_libs"])
+
+AC_ARG_WITH(system-jars,
+    AS_HELP_STRING([--without-system-jars],
+        [When building with --with-system-libs, also the needed jars are expected
+         on the system. Use this to disable that]),,
+    [with_system_jars="$with_system_libs"])
+
+AC_ARG_WITH(system-cairo,
+    AS_HELP_STRING([--with-system-cairo],
+        [Use cairo libraries already on system.  Happens automatically for
+         (implicit) --enable-gtk3.]))
+
+AC_ARG_WITH(system-epoxy,
+    AS_HELP_STRING([--with-system-epoxy],
+        [Use epoxy libraries already on system.  Happens automatically for
+         (implicit) --enable-gtk3.]),,
+       [with_system_epoxy="$with_system_libs"])
+
+AC_ARG_WITH(myspell-dicts,
+    AS_HELP_STRING([--with-myspell-dicts],
+        [Adds myspell dictionaries to the LibreOffice installation set]),
+,)
+
+AC_ARG_WITH(system-dicts,
+    AS_HELP_STRING([--without-system-dicts],
+        [Do not use dictionaries from system paths.]),
+,)
+
+AC_ARG_WITH(external-dict-dir,
+    AS_HELP_STRING([--with-external-dict-dir],
+        [Specify external dictionary dir.]),
+,)
+
+AC_ARG_WITH(external-hyph-dir,
+    AS_HELP_STRING([--with-external-hyph-dir],
+        [Specify external hyphenation pattern dir.]),
+,)
+
+AC_ARG_WITH(external-thes-dir,
+    AS_HELP_STRING([--with-external-thes-dir],
+        [Specify external thesaurus dir.]),
+,)
+
+AC_ARG_WITH(system-zlib,
+    AS_HELP_STRING([--with-system-zlib],
+        [Use zlib already on system.]),,
+    [with_system_zlib=auto])
+
+AC_ARG_WITH(system-jpeg,
+    AS_HELP_STRING([--with-system-jpeg],
+        [Use jpeg already on system.]),,
+    [with_system_jpeg="$with_system_libs"])
+
+AC_ARG_WITH(system-expat,
+    AS_HELP_STRING([--with-system-expat],
+        [Use expat already on system.]),,
+    [with_system_expat="$with_system_libs"])
+
+AC_ARG_WITH(system-libxml,
+    AS_HELP_STRING([--with-system-libxml],
+        [Use libxml/libxslt already on system.]),,
+    [with_system_libxml=auto])
+
+AC_ARG_WITH(system-openldap,
+    AS_HELP_STRING([--with-system-openldap],
+        [Use the OpenLDAP LDAP SDK already on system.]),,
+    [with_system_openldap="$with_system_libs"])
+
+libo_FUZZ_ARG_ENABLE(poppler,
+    AS_HELP_STRING([--disable-poppler],
+        [Disable building Poppler.])
+)
+
+AC_ARG_WITH(system-poppler,
+    AS_HELP_STRING([--with-system-poppler],
+        [Use system poppler (only needed for PDF import).]),,
+    [with_system_poppler="$with_system_libs"])
+
+AC_ARG_WITH(system-abseil,
+    AS_HELP_STRING([--with-system-abseil],
+        [Use the abseil libraries already on system.]),,
+    [with_system_abseil="$with_system_libs"])
+
+AC_ARG_WITH(system-openjpeg,
+    AS_HELP_STRING([--with-system-openjpeg],
+        [Use the OpenJPEG library already on system.]),,
+    [with_system_openjpeg="$with_system_libs"])
+
+libo_FUZZ_ARG_ENABLE(gpgmepp,
+    AS_HELP_STRING([--disable-gpgmepp],
+        [Disable building gpgmepp. Do not use in normal cases unless you want to fix potential problems it causes.])
+)
+
+AC_ARG_WITH(system-gpgmepp,
+    AS_HELP_STRING([--with-system-gpgmepp],
+        [Use gpgmepp already on system]),,
+    [with_system_gpgmepp="$with_system_libs"])
+
+AC_ARG_WITH(system-mariadb,
+    AS_HELP_STRING([--with-system-mariadb],
+        [Use MariaDB/MySQL libraries already on system.]),,
+    [with_system_mariadb="$with_system_libs"])
+
+AC_ARG_ENABLE(bundle-mariadb,
+    AS_HELP_STRING([--enable-bundle-mariadb],
+        [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
+)
+
+AC_ARG_WITH(system-postgresql,
+    AS_HELP_STRING([--with-system-postgresql],
+        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
+         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
+    [with_system_postgresql="$with_system_libs"])
+
+AC_ARG_WITH(libpq-path,
+    AS_HELP_STRING([--with-libpq-path=<absolute path to your libpq installation>],
+        [Use this PostgreSQL C interface (libpq) installation for building
+         the PostgreSQL-SDBC extension.]),
+,)
+
+AC_ARG_WITH(system-firebird,
+    AS_HELP_STRING([--with-system-firebird],
+        [Use Firebird libraries already on system, for building the Firebird-SDBC
+         driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
+    [with_system_firebird="$with_system_libs"])
+
+AC_ARG_WITH(system-libtommath,
+            AS_HELP_STRING([--with-system-libtommath],
+                           [Use libtommath already on system]),,
+            [with_system_libtommath="$with_system_libs"])
+
+AC_ARG_WITH(system-hsqldb,
+    AS_HELP_STRING([--with-system-hsqldb],
+        [Use hsqldb already on system.]))
+
+AC_ARG_WITH(hsqldb-jar,
+    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    HSQLDB_JAR=$withval)
+
+libo_FUZZ_ARG_ENABLE(scripting-beanshell,
+    AS_HELP_STRING([--disable-scripting-beanshell],
+        [Disable support for scripts in BeanShell.]),
+,
+)
+
+AC_ARG_WITH(system-beanshell,
+    AS_HELP_STRING([--with-system-beanshell],
+        [Use beanshell already on system.]),,
+    [with_system_beanshell="$with_system_jars"])
+
+AC_ARG_WITH(beanshell-jar,
+    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    BSH_JAR=$withval)
+
+libo_FUZZ_ARG_ENABLE(scripting-javascript,
+    AS_HELP_STRING([--disable-scripting-javascript],
+        [Disable support for scripts in JavaScript.]),
+,
+)
+
+AC_ARG_WITH(system-rhino,
+    AS_HELP_STRING([--with-system-rhino],
+        [Use rhino already on system.]),,)
+#    [with_system_rhino="$with_system_jars"])
+# Above is not used as we have different debug interface
+# patched into internal rhino. This code needs to be fixed
+# before we can enable it by default.
+
+AC_ARG_WITH(rhino-jar,
+    AS_HELP_STRING([--with-rhino-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    RHINO_JAR=$withval)
+
+AC_ARG_WITH(system-jfreereport,
+    AS_HELP_STRING([--with-system-jfreereport],
+        [Use JFreeReport already on system.]),,
+    [with_system_jfreereport="$with_system_jars"])
+
+AC_ARG_WITH(sac-jar,
+    AS_HELP_STRING([--with-sac-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    SAC_JAR=$withval)
+
+AC_ARG_WITH(libxml-jar,
+    AS_HELP_STRING([--with-libxml-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBXML_JAR=$withval)
+
+AC_ARG_WITH(flute-jar,
+    AS_HELP_STRING([--with-flute-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    FLUTE_JAR=$withval)
+
+AC_ARG_WITH(jfreereport-jar,
+    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    JFREEREPORT_JAR=$withval)
+
+AC_ARG_WITH(liblayout-jar,
+    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBLAYOUT_JAR=$withval)
+
+AC_ARG_WITH(libloader-jar,
+    AS_HELP_STRING([--with-libloader-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBLOADER_JAR=$withval)
+
+AC_ARG_WITH(libformula-jar,
+    AS_HELP_STRING([--with-libformula-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBFORMULA_JAR=$withval)
+
+AC_ARG_WITH(librepository-jar,
+    AS_HELP_STRING([--with-librepository-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBREPOSITORY_JAR=$withval)
+
+AC_ARG_WITH(libfonts-jar,
+    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBFONTS_JAR=$withval)
+
+AC_ARG_WITH(libserializer-jar,
+    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBSERIALIZER_JAR=$withval)
+
+AC_ARG_WITH(libbase-jar,
+    AS_HELP_STRING([--with-libbase-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    LIBBASE_JAR=$withval)
+
+AC_ARG_WITH(system-odbc,
+    AS_HELP_STRING([--with-system-odbc],
+        [Use the odbc headers already on system.]),,
+    [with_system_odbc="auto"])
+
+AC_ARG_WITH(system-sane,
+    AS_HELP_STRING([--with-system-sane],
+        [Use sane.h already on system.]),,
+    [with_system_sane="$with_system_headers"])
+
+AC_ARG_WITH(system-bluez,
+    AS_HELP_STRING([--with-system-bluez],
+        [Use bluetooth.h already on system.]),,
+    [with_system_bluez="$with_system_headers"])
+
+AC_ARG_WITH(system-boost,
+    AS_HELP_STRING([--with-system-boost],
+        [Use boost already on system.]),,
+    [with_system_boost="$with_system_headers"])
+
+AC_ARG_WITH(system-dragonbox,
+    AS_HELP_STRING([--with-system-dragonbox],
+        [Use dragonbox already on system.]),,
+    [with_system_dragonbox="$with_system_headers"])
+
+AC_ARG_WITH(system-frozen,
+    AS_HELP_STRING([--with-system-frozen],
+        [Use frozen already on system.]),,
+    [with_system_frozen="$with_system_headers"])
+
+AC_ARG_WITH(system-libfixmath,
+    AS_HELP_STRING([--with-system-libfixmath],
+        [Use libfixmath already on system.]),,
+    [with_system_libfixmath="$with_system_libs"])
+
+AC_ARG_WITH(system-glm,
+    AS_HELP_STRING([--with-system-glm],
+        [Use glm already on system.]),,
+    [with_system_glm="$with_system_headers"])
+
+AC_ARG_WITH(system-hunspell,
+    AS_HELP_STRING([--with-system-hunspell],
+        [Use libhunspell already on system.]),,
+    [with_system_hunspell="$with_system_libs"])
+
+libo_FUZZ_ARG_ENABLE(cairo-rgba,
+    AS_HELP_STRING([--enable-cairo-rgba],
+        [Use RGBA order, instead of default BRGA. Not possible with --with-system-cairo]))
+
+libo_FUZZ_ARG_ENABLE(zxing,
+    AS_HELP_STRING([--disable-zxing],
+       [Disable use of zxing external library.]))
+
+AC_ARG_WITH(system-zxing,
+    AS_HELP_STRING([--with-system-zxing],
+        [Use libzxing already on system.]),,
+    [with_system_zxing="$with_system_libs"])
+
+AC_ARG_WITH(system-zxcvbn,
+    AS_HELP_STRING([--with-system-zxcvbn],
+        [Use libzxcvbn already on system.]),,
+    [with_system_zxcvbn="$with_system_libs"])
+
+AC_ARG_WITH(system-box2d,
+    AS_HELP_STRING([--with-system-box2d],
+        [Use box2d already on system.]),,
+    [with_system_box2d="$with_system_libs"])
+
+AC_ARG_WITH(system-mythes,
+    AS_HELP_STRING([--with-system-mythes],
+        [Use mythes already on system.]),,
+    [with_system_mythes="$with_system_libs"])
+
+AC_ARG_WITH(system-altlinuxhyph,
+    AS_HELP_STRING([--with-system-altlinuxhyph],
+        [Use ALTLinuxhyph already on system.]),,
+    [with_system_altlinuxhyph="$with_system_libs"])
+
+AC_ARG_WITH(system-lpsolve,
+    AS_HELP_STRING([--with-system-lpsolve],
+        [Use lpsolve already on system.]),,
+    [with_system_lpsolve="$with_system_libs"])
+
+AC_ARG_WITH(system-coinmp,
+    AS_HELP_STRING([--with-system-coinmp],
+        [Use CoinMP already on system.]),,
+    [with_system_coinmp="$with_system_libs"])
+
+AC_ARG_WITH(system-liblangtag,
+    AS_HELP_STRING([--with-system-liblangtag],
+        [Use liblangtag library already on system.]),,
+    [with_system_liblangtag="$with_system_libs"])
+
+AC_ARG_WITH(system-lockfile,
+    AS_HELP_STRING([--with-system-lockfile[=file]],
+        [Detect a system lockfile program or use the \$file argument.]))
+
+AC_ARG_WITH(webdav,
+    AS_HELP_STRING([--without-webdav],
+        [Disable WebDAV support in the UCB.]))
+
+AC_ARG_WITH(linker-hash-style,
+    AS_HELP_STRING([--with-linker-hash-style],
+        [Use linker with --hash-style=<style> when linking shared objects.
+         Possible values: "sysv", "gnu", "both". The default value is "gnu"
+         if supported on the build system, and "sysv" otherwise.]))
+
+AC_ARG_WITH(jdk-home,
+    AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
+        [If you have installed JDK 17 or later on your system please supply the
+         path here. Note that this is not the location of the java command but the
+         location of the entire distribution. In case of cross-compiling, this
+         is the JDK of the host os. Use --with-build-platform-configure-options
+         to point to a different build platform JDK.]),
+,)
+
+AC_ARG_WITH(help,
+    AS_HELP_STRING([--with-help],
+        [Enable the build of help. There is a special parameter "common" that
+         can be used to bundle only the common part, .e.g help-specific icons.
+         This is useful when you build the helpcontent separately.])
+    [
+                          Usage:     --with-help    build the old local help
+                                 --without-help     no local help (default)
+                                 --with-help=html   build the new HTML local help
+                                 --with-help=online build the new HTML online help
+    ],
+,)
+
+AC_ARG_WITH(omindex,
+   AS_HELP_STRING([--with-omindex],
+        [Enable the support of xapian-omega index for online help.])
+   [
+                         Usage: --with-omindex=server prepare the pages for omindex
+                                but let xapian-omega be built in server.
+                                --with-omindex=noxap do not prepare online pages
+                                for xapian-omega
+  ],
+,)
+
+libo_FUZZ_ARG_WITH(java,
+    AS_HELP_STRING([--with-java=<java command>],
+        [Specify the name of the Java interpreter command. Typically "java"
+         which is the default.
+
+         To build without support for Java components, applets, accessibility
+         or the XML filters written in Java, use --without-java or --with-java=no.]),
+    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
+    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ]
+)
+
+AC_ARG_WITH(jvm-path,
+    AS_HELP_STRING([--with-jvm-path=<absolute path to parent of jvm home>],
+        [Use a specific JVM search path at runtime.
+         e.g. use --with-jvm-path=/usr/lib/ to find JRE/JDK in /usr/lib/jvm/]),
+,)
+
+AC_ARG_WITH(ant-home,
+    AS_HELP_STRING([--with-ant-home=<absolute path to Ant home>],
+        [If you have installed Apache Ant on your system, please supply the path here.
+         Note that this is not the location of the Ant binary but the location
+         of the entire distribution.]),
+,)
+
+AC_ARG_WITH(symbol-config,
+    AS_HELP_STRING([--with-symbol-config],
+        [Configuration for the crashreport symbol upload]),
+        [],
+        [with_symbol_config=no])
+
+AC_ARG_WITH(export-validation,
+    AS_HELP_STRING([--without-export-validation],
+        [Disable validating OOXML and ODF files as exported from in-tree tests.]),
+,with_export_validation=auto)
+
+AC_ARG_WITH(bffvalidator,
+    AS_HELP_STRING([--with-bffvalidator=<absolute path to BFFValidator>],
+        [Enables export validation for Microsoft Binary formats (doc, xls, ppt).
+         Requires installed Microsoft Office Binary File Format Validator.
+         Note: export-validation (--with-export-validation) is required to be turned on.
+         See https://web.archive.org/web/20200804155745/https://www.microsoft.com/en-us/download/details.aspx?id=26794]),
+,with_bffvalidator=no)
+
+libo_FUZZ_ARG_WITH(junit,
+    AS_HELP_STRING([--with-junit=<absolute path to JUnit 4 jar>],
+        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
+         --without-junit disables those tests. Not relevant in the --without-java case.]),
+,with_junit=yes)
+
+AC_ARG_WITH(hamcrest,
+    AS_HELP_STRING([--with-hamcrest=<absolute path to hamcrest jar>],
+        [Specifies the hamcrest jar file to use for JUnit-based tests.
+         --without-junit disables those tests. Not relevant in the --without-java case.]),
+,with_hamcrest=yes)
+
+AC_ARG_WITH(perl-home,
+    AS_HELP_STRING([--with-perl-home=<abs. path to Perl 5 home>],
+        [If you have installed Perl 5 Distribution, on your system, please
+         supply the path here. Note that this is not the location of the Perl
+         binary but the location of the entire distribution.]),
+,)
+
+libo_FUZZ_ARG_WITH(doxygen,
+    AS_HELP_STRING(
+        [--with-doxygen=<absolute path to doxygen executable>],
+        [Specifies the doxygen executable to use when generating ODK C/C++
+         documentation. --without-doxygen disables generation of ODK C/C++
+         documentation. Not relevant in the --disable-odk case.]),
+,with_doxygen=yes)
+
+AC_ARG_WITH(visual-studio,
+    AS_HELP_STRING([--with-visual-studio=<2019/2022/2022preview>],
+        [Specify which Visual Studio version to use in case several are
+         installed. Currently 2019 (default) and 2022 are supported.]),
+,)
+
+AC_ARG_WITH(windows-sdk,
+    AS_HELP_STRING([--with-windows-sdk=<8.0(A)/8.1(A)/10.0>],
+        [Specify which Windows SDK, or "Windows Kit", version to use
+         in case the one that came with the selected Visual Studio
+         is not what you want for some reason. Note that not all compiler/SDK
+         combinations are supported. The intent is that this option should not
+         be needed.]),
+,)
+
+AC_ARG_WITH(lang,
+    AS_HELP_STRING([--with-lang="es sw tu cs sk"],
+        [Use this option to build LibreOffice with additional UI language support.
+         English (US) is always included by default.
+         Separate multiple languages with space.
+         For all languages, use --with-lang=ALL.]),
+,)
+
+AC_ARG_WITH(locales,
+    AS_HELP_STRING([--with-locales="en es pt fr zh kr ja"],
+        [Use this option to limit the locale information built in.
+         Separate multiple locales with space.
+         Very experimental and might well break stuff.
+         Just a desperate measure to shrink code and data size.
+         By default all the locales available is included.
+         Just works with --disable-dynloading. Defaults to "ALL".
+         This option is completely unrelated to --with-lang.])
+    [
+                          Affects also our character encoding conversion
+                          tables for encodings mainly targeted for a
+                          particular locale, like EUC-CN and EUC-TW for
+                          zh, ISO-2022-JP for ja.
+
+                          Affects also our add-on break iterator data for
+                          some languages.
+
+                          For the default, all locales, don't use this switch at all.
+                          Specifying just the language part of a locale means all matching
+                          locales will be included.
+    ],
+,)
+
+# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
+libo_FUZZ_ARG_WITH(krb5,
+    AS_HELP_STRING([--with-krb5],
+        [Enable MIT Kerberos 5 support in modules that support it.
+         By default automatically enabled on platforms
+         where a good system Kerberos 5 is available.]),
+,)
+
+libo_FUZZ_ARG_WITH(gssapi,
+    AS_HELP_STRING([--with-gssapi],
+        [Enable GSSAPI support in modules that support it.
+         By default automatically enabled on platforms
+         where a good system GSSAPI is available.]),
+,)
+
+libo_FUZZ_ARG_WITH(lxml,
+    AS_HELP_STRING([--without-lxml],
+        [gla11y will use python lxml when available, potentially building a local copy if necessary.
+         --without-lxml tells it to not use python lxml at all, which means that gla11y will only
+         report widget classes and ids.]),
+,)
+
+libo_FUZZ_ARG_WITH(latest-c++,
+    AS_HELP_STRING([--with-latest-c++],
+        [Try to enable the latest features of the C++ compiler, even if they are not yet part of a
+         published standard.  This option is ignored when CXXFLAGS_CXX11 is set explicitly.]),,
+        [with_latest_c__=no])
+
+AC_ARG_WITH(gtk3-build,
+    AS_HELP_STRING([--with-gtk3-build=<absolute path to GTK3 build>],
+        [(Windows-only) In order to build GtkTiledViewer on Windows, pass the path
+         to a GTK3 build, like '--with-gtk3-build=C:/gtk-build/gtk/x64/release'.]))
+
+dnl ===================================================================
+dnl Branding
+dnl ===================================================================
+
+AC_ARG_WITH(branding,
+    AS_HELP_STRING([--with-branding=/path/to/images],
+        [Use given path to retrieve branding images set.])
+    [
+                          Search for intro.png about.svg and logo.svg.
+                          If any is missing, default ones will be used instead.
+
+                          Search also progress.conf for progress
+                          settings on intro screen :
+
+                          PROGRESSBARCOLOR="255,255,255" Set color of
+                          progress bar. Comma separated RGB decimal values.
+                          PROGRESSSIZE="407,6" Set size of progress bar.
+                          Comma separated decimal values (width, height).
+                          PROGRESSPOSITION="61,317" Set position of progress
+                          bar from left,top. Comma separated decimal values.
+                          PROGRESSFRAMECOLOR="20,136,3" Set color of progress
+                          bar frame. Comma separated RGB decimal values.
+                          PROGRESSTEXTCOLOR="0,0,0" Set color of progress
+                          bar text. Comma separated RGB decimal values.
+                          PROGRESSTEXTBASELINE="287" Set vertical position of
+                          progress bar text from top. Decimal value.
+
+                          Default values will be used if not found.
+    ],
+,)
+
+
+AC_ARG_WITH(extra-buildid,
+    AS_HELP_STRING([--with-extra-buildid="Tinderbox: Win-x86@6, Branch:master, Date:2012-11-26_00.29.34"],
+        [Show addition build identification in about dialog.]),
+,)
+
+
+AC_ARG_WITH(vendor,
+    AS_HELP_STRING([--with-vendor="John the Builder"],
+        [Set vendor of the build.]),
+,)
+
+AC_ARG_WITH(privacy-policy-url,
+    AS_HELP_STRING([--with-privacy-policy-url="https://yourdomain/privacy-policy"],
+        [The URL to your privacy policy (needed when
+         enabling online-update or crashreporting via breakpad)]),
+        [if test "x$with_privacy_policy_url" = "xyes"; then
+            AC_MSG_FAILURE([you need to specify an argument when using --with-privacy-policy-url])
+         elif test "x$with_privacy_policy_url" = "xno"; then
+            with_privacy_policy_url="undefined"
+         fi]
+,[with_privacy_policy_url="undefined"])
+
+AC_ARG_WITH(android-package-name,
+    AS_HELP_STRING([--with-android-package-name="org.libreoffice"],
+        [Set Android package name of the build.]),
+,)
+
+AC_ARG_WITH(compat-oowrappers,
+    AS_HELP_STRING([--with-compat-oowrappers],
+        [Install oo* wrappers in parallel with
+         lo* ones to keep backward compatibility.
+         Has effect only with make distro-pack-install]),
+,)
+
+AC_ARG_WITH(os-version,
+    AS_HELP_STRING([--with-os-version=<OSVERSION>],
+        [For FreeBSD users, use this option to override the detected OSVERSION.]),
+,)
+
+AC_ARG_WITH(parallelism,
+    AS_HELP_STRING([--with-parallelism],
+        [Number of jobs to run simultaneously during build. Parallel builds can
+        save a lot of time on multi-cpu machines. Defaults to the number of
+        CPUs on the machine, unless you configure --enable-icecream - then to
+        40.]),
+,)
+
+AC_ARG_WITH(all-tarballs,
+    AS_HELP_STRING([--with-all-tarballs],
+        [Download all external tarballs unconditionally]))
+
+AC_ARG_WITH(gdrive-client-id,
+    AS_HELP_STRING([--with-gdrive-client-id],
+        [Provides the client id of the application for OAuth2 authentication
+        on Google Drive. If either this or --with-gdrive-client-secret is
+        empty, the feature will be disabled]),
+)
+
+AC_ARG_WITH(gdrive-client-secret,
+    AS_HELP_STRING([--with-gdrive-client-secret],
+        [Provides the client secret of the application for OAuth2
+        authentication on Google Drive. If either this or
+        --with-gdrive-client-id is empty, the feature will be disabled]),
+)
+
+AC_ARG_WITH(alfresco-cloud-client-id,
+    AS_HELP_STRING([--with-alfresco-cloud-client-id],
+        [Provides the client id of the application for OAuth2 authentication
+        on Alfresco Cloud. If either this or --with-alfresco-cloud-client-secret is
+        empty, the feature will be disabled]),
+)
+
+AC_ARG_WITH(alfresco-cloud-client-secret,
+    AS_HELP_STRING([--with-alfresco-cloud-client-secret],
+        [Provides the client secret of the application for OAuth2
+        authentication on Alfresco Cloud. If either this or
+        --with-alfresco-cloud-client-id is empty, the feature will be disabled]),
+)
+
+AC_ARG_WITH(onedrive-client-id,
+    AS_HELP_STRING([--with-onedrive-client-id],
+        [Provides the client id of the application for OAuth2 authentication
+        on OneDrive. If either this or --with-onedrive-client-secret is
+        empty, the feature will be disabled]),
+)
+
+AC_ARG_WITH(onedrive-client-secret,
+    AS_HELP_STRING([--with-onedrive-client-secret],
+        [Provides the client secret of the application for OAuth2
+        authentication on OneDrive. If either this or
+        --with-onedrive-client-id is empty, the feature will be disabled]),
+)
+
+dnl Check for coredumpctl support to present information about crashing test processes:
+AC_ARG_WITH(coredumpctl,
+    AS_HELP_STRING([--with-coredumpctl],
+        [Use coredumpctl (together with systemd-run) to retrieve core dumps of crashing test
+        processes.]))
+
+AC_ARG_WITH(buildconfig-recorded,
+    AS_HELP_STRING([--with-buildconfig-recorded],
+        [Put build config into version info reported by LOK. Incompatible with reproducible builds.]),
+)
+
+AC_MSG_CHECKING([whether to record build config])
+if test -z "$with_buildconfig_recorded"; then
+    with_buildconfig_recorded=no
+fi
+if test "$with_buildconfig_recorded" = no; then
+    AC_MSG_RESULT([no])
+else
+    AC_MSG_RESULT([yes])
+    # replace backslashes, to get a valid c++ string
+    config_args=$(echo $ac_configure_args | tr '\\' '/')
+    AC_DEFINE_UNQUOTED([BUILDCONFIG],[["$config_args"]],[Options passed to configure script])
+    AC_DEFINE([BUILDCONFIG_RECORDED],[1],[Options passed to configure script])
+fi
+
+dnl ===================================================================
+dnl Do we want to use pre-build binary tarball for recompile
+dnl ===================================================================
+
+if test "$enable_library_bin_tar" = "yes" ; then
+    USE_LIBRARY_BIN_TAR=TRUE
+else
+    USE_LIBRARY_BIN_TAR=
+fi
+AC_SUBST(USE_LIBRARY_BIN_TAR)
+
+dnl ===================================================================
+dnl Test whether build target is Release Build
+dnl ===================================================================
+AC_MSG_CHECKING([whether build target is Release Build])
+if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
+    AC_MSG_RESULT([no])
+    ENABLE_RELEASE_BUILD=
+    dnl Pu the value on one line as make (at least on macOS) seems to ignore
+    dnl the newlines and then complains about spaces.
+    GET_TASK_ALLOW_ENTITLEMENT='<!-- We want to be able to debug a hardened process when not building for release --><key>com.apple.security.get-task-allow</key><true/>'
+else
+    AC_MSG_RESULT([yes])
+    ENABLE_RELEASE_BUILD=TRUE
+    GET_TASK_ALLOW_ENTITLEMENT=
+fi
+AC_SUBST(ENABLE_RELEASE_BUILD)
+AC_SUBST(GET_TASK_ALLOW_ENTITLEMENT)
+
+AC_MSG_CHECKING([whether to build a Community flavor])
+if test -z "$enable_community_flavor" -o "$enable_community_flavor" = "yes"; then
+    AC_DEFINE(HAVE_FEATURE_COMMUNITY_FLAVOR)
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+
+dnl ===================================================================
+dnl Test whether to sign Windows Build
+dnl ===================================================================
+AC_MSG_CHECKING([whether to sign windows build])
+if test "$enable_windows_build_signing" = "yes" -a "$_os" = "WINNT"; then
+    AC_MSG_RESULT([yes])
+    WINDOWS_BUILD_SIGNING="TRUE"
+else
+    AC_MSG_RESULT([no])
+    WINDOWS_BUILD_SIGNING="FALSE"
+fi
+AC_SUBST(WINDOWS_BUILD_SIGNING)
+
+dnl ===================================================================
+dnl MacOSX build and runtime environment options
+dnl ===================================================================
+
+AC_ARG_WITH(macosx-version-min-required,
+    AS_HELP_STRING([--with-macosx-version-min-required=<version>],
+        [set the minimum OS version needed to run the built LibreOffice])
+    [
+                          e. g.: --with-macosx-version-min-required=10.15
+    ],
+,)
+
+dnl ===================================================================
+dnl Check for incompatible options set by fuzzing, and reset those
+dnl automatically to working combinations
+dnl ===================================================================
+
+if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
+        "$enable_dbus" != "$enable_avahi"; then
+    AC_MSG_NOTICE([Resetting --enable-avahi=$enable_dbus])
+    enable_avahi=$enable_dbus
+fi
+
+add_lopath_after ()
+{
+    if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
+        LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
+    fi
+}
+
+add_lopath_before ()
+{
+    local IFS=${P_SEP}
+    local path_cleanup
+    local dir
+    for dir in $LO_PATH ; do
+        if test "$dir" != "$1" ; then
+            path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
+        fi
+    done
+    LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
+}
+
+dnl ===================================================================
+dnl check for required programs (grep, awk, sed, bash)
+dnl ===================================================================
+
+pathmunge ()
+{
+    local new_path
+    if test -n "$1"; then
+        if test "$build_os" = "cygwin"; then
+            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+                PathFormat "$1"
+                new_path=`cygpath -sm "$formatted_path"`
+            else
+                PathFormat "$1"
+                new_path=`cygpath -u "$formatted_path"`
+            fi
+        else
+            new_path="$1"
+        fi
+        if test "$2" = "after"; then
+            add_lopath_after "$new_path"
+        else
+            add_lopath_before "$new_path"
+        fi
+    fi
+}
+
+AC_PROG_AWK
+AC_PATH_PROG( AWK, $AWK)
+if test -z "$AWK"; then
+    AC_MSG_ERROR([install awk to run this script])
+fi
+
+AC_PATH_PROG(BASH, bash)
+if test -z "$BASH"; then
+    AC_MSG_ERROR([bash not found in \$PATH])
+fi
+AC_SUBST(BASH)
+
+# prefer parallel compression tools, if available
+AC_PATH_PROG(COMPRESSIONTOOL, pigz)
+if test -z "$COMPRESSIONTOOL"; then
+    AC_PATH_PROG(COMPRESSIONTOOL, gzip)
+    if test -z "$COMPRESSIONTOOL"; then
+        AC_MSG_ERROR([gzip not found in \$PATH])
+    fi
+fi
+AC_SUBST(COMPRESSIONTOOL)
+
+AC_MSG_CHECKING([for GNU or BSD tar])
+for a in $GNUTAR gtar gnutar tar bsdtar /usr/sfw/bin/gtar; do
+    $a --version 2> /dev/null | grep -E "GNU|bsdtar"  2>&1 > /dev/null
+    if test $? -eq 0;  then
+        GNUTAR=$a
+        break
+    fi
+done
+AC_MSG_RESULT($GNUTAR)
+if test -z "$GNUTAR"; then
+    AC_MSG_ERROR([not found. install GNU or BSD tar.])
+fi
+AC_SUBST(GNUTAR)
+
+AC_MSG_CHECKING([for tar's option to strip components])
+$GNUTAR --help 2> /dev/null | grep -E "bsdtar|strip-components" 2>&1 >/dev/null
+if test $? -eq 0; then
+    STRIP_COMPONENTS="--strip-components"
+else
+    $GNUTAR --help 2> /dev/null | grep -E "strip-path" 2>&1 >/dev/null
+    if test $? -eq 0; then
+        STRIP_COMPONENTS="--strip-path"
+    else
+        STRIP_COMPONENTS="unsupported"
+    fi
+fi
+AC_MSG_RESULT($STRIP_COMPONENTS)
+if test x$STRIP_COMPONENTS = xunsupported; then
+    AC_MSG_ERROR([you need a tar that is able to strip components.])
+fi
+AC_SUBST(STRIP_COMPONENTS)
+
+dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
+dnl desktop OSes from "mobile" ones.
+
+dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
+dnl In other words, that when building for an OS that is not a
+dnl "desktop" one but a "mobile" one, we are always cross-compiling.
+
+dnl Note the direction of the implication; there is no assumption that
+dnl cross-compiling would imply a non-desktop OS.
+
+if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes"; then
+    BUILD_TYPE="$BUILD_TYPE DESKTOP"
+    AC_DEFINE(HAVE_FEATURE_DESKTOP)
+    if test "$_os" != Emscripten; then
+        AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
+    fi
+fi
+
+# explicitly doesn't include enable_gtk3=no and enable_qt5=yes, so it should
+# also work with the default gtk3 plugin.
+if test "$enable_wasm_strip" = "yes"; then
+    enable_avmedia=no
+    enable_libcmis=no
+    enable_coinmp=no
+    enable_cups=no
+    test "$_os" = Emscripten && enable_curl=no
+    enable_database_connectivity=no
+    enable_dbus=no
+    enable_dconf=no
+    test "${enable_dynamic_loading+set}" = set -o "$_os" != Emscripten || enable_dynamic_loading=no
+    enable_extension_integration=no
+    enable_extensions=no
+    enable_extension_update=no
+    enable_gio=no
+    enable_gpgmepp=no
+    enable_ldap=no
+    enable_lotuswordpro=no
+    enable_lpsolve=no
+    enable_nss=no
+    enable_odk=no
+    enable_online_update=no
+    enable_opencl=no
+    enable_pdfimport=no
+    enable_randr=no
+    enable_report_builder=no
+    enable_scripting=no
+    enable_sdremote_bluetooth=no
+    enable_skia=no
+    enable_xmlhelp=no
+    enable_zxing=no
+    test_libepubgen=no
+    test_libcdr=no
+    test_libcmis=no
+    test_libetonyek=no
+    test_libfreehand=no
+    test_libmspub=no
+    test_libpagemaker=no
+    test_libqxp=no
+    test_libvisio=no
+    test_libzmf=no
+    test_webdav=no
+    with_galleries=no
+    with_templates=no
+    with_webdav=no
+    with_x=no
+
+    test "${with_fonts+set}" = set || with_fonts=yes
+    test "${with_locales+set}" = set || with_locales=en
+
+    AC_DEFINE(ENABLE_WASM_STRIP_ACCESSIBILITY)
+    AC_DEFINE(ENABLE_WASM_STRIP_WRITER)
+    AC_DEFINE(ENABLE_WASM_STRIP_CALC)
+    AC_DEFINE(ENABLE_WASM_STRIP_CANVAS)
+#    AC_DEFINE(ENABLE_WASM_STRIP_CHART)
+    AC_DEFINE(ENABLE_WASM_STRIP_DBACCESS)
+    AC_DEFINE(ENABLE_WASM_STRIP_EPUB)
+    AC_DEFINE(ENABLE_WASM_STRIP_EXTRA)
+    AC_DEFINE(ENABLE_WASM_STRIP_GUESSLANG)
+#    AC_DEFINE(ENABLE_WASM_STRIP_HUNSPELL)
+    AC_DEFINE(ENABLE_WASM_STRIP_LANGUAGETOOL)
+    AC_DEFINE(ENABLE_WASM_STRIP_PINGUSER)
+    AC_DEFINE(ENABLE_WASM_STRIP_PREMULTIPLY)
+    AC_DEFINE(ENABLE_WASM_STRIP_RECENT)
+    AC_DEFINE(ENABLE_WASM_STRIP_RECOVERYUI)
+    AC_DEFINE(ENABLE_WASM_STRIP_SPLASH)
+    AC_DEFINE(ENABLE_WASM_STRIP_SWEXPORTS)
+    AC_DEFINE(ENABLE_WASM_STRIP_SCEXPORTS)
+fi
+
+EMSCRIPTEN_NEH_MAJOR=3
+EMSCRIPTEN_NEH_MINOR=1
+EMSCRIPTEN_NEH_TINY=3
+EMSCRIPTEN_NEH_VERSION="${EMSCRIPTEN_NEH_MAJOR}.${EMSCRIPTEN_NEH_MINOR}.${EMSCRIPTEN_NEH_TINY}"
+
+if test "$enable_wasm_exceptions" = yes; then
+    AC_MSG_CHECKING([if Emscripten version is at least $EMSCRIPTEN_NEH_VERSION for SjLj + native EH])
+    check_semantic_version_three_prefixed EMSCRIPTEN NEH
+    if test $? -ne 0; then
+        AC_MSG_ERROR([no, found $EMSCRIPTEN_VERSION])
+    else
+        AC_MSG_RESULT([yes ($EMSCRIPTEN_VERSION)])
+    fi
+    ENABLE_WASM_EXCEPTIONS=TRUE
+fi
+AC_SUBST(ENABLE_WASM_EXCEPTIONS)
+
+# Whether to build "avmedia" functionality or not.
+
+if test "$enable_avmedia" = yes; then
+    BUILD_TYPE="$BUILD_TYPE AVMEDIA"
+    AC_DEFINE(HAVE_FEATURE_AVMEDIA)
+else
+    test_gstreamer_1_0=no
+fi
+
+# Decide whether to build database connectivity stuff (including Base) or not.
+if test "$enable_database_connectivity" != no; then
+    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
+    AC_DEFINE(HAVE_FEATURE_DBCONNECTIVITY)
+else
+    if test "$_os" = iOS; then
+        AC_MSG_ERROR([Presumly can't disable DB connectivity on iOS.])
+    fi
+    disable_database_connectivity_dependencies
+fi
+
+if test -z "$enable_extensions"; then
+    # For iOS and Android Viewer, disable extensions unless specifically overridden with --enable-extensions.
+    if test $_os != iOS && test $_os != Android -o "$ENABLE_ANDROID_LOK" = TRUE ; then
+        enable_extensions=yes
+    fi
+fi
+
+DISABLE_SCRIPTING=''
+if test "$enable_scripting" = yes; then
+    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
+    AC_DEFINE(HAVE_FEATURE_SCRIPTING)
+else
+    DISABLE_SCRIPTING='TRUE'
+    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
+fi
+
+if test $_os = iOS -o $_os = Android -o $_os = Emscripten; then
+    # Disable dynamic_loading always for iOS and Android
+    enable_dynamic_loading=no
+elif test -z "$enable_dynamic_loading"; then
+    # Otherwise enable it unless specifically disabled
+    enable_dynamic_loading=yes
+fi
+
+DISABLE_DYNLOADING=''
+if test "$enable_dynamic_loading" = yes; then
+    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
+else
+    DISABLE_DYNLOADING='TRUE'
+    if test $_os != iOS -a $_os != Android; then
+        enable_database_connectivity=no
+        enable_nss=no
+        enable_odk=no
+        enable_python=no
+        enable_skia=no
+        with_java=no
+    fi
+fi
+AC_SUBST(DISABLE_DYNLOADING)
+
+ENABLE_CUSTOMTARGET_COMPONENTS=
+if test "$enable_customtarget_components" = yes -a "$DISABLE_DYNLOADING" = TRUE; then
+    ENABLE_CUSTOMTARGET_COMPONENTS=TRUE
+    if test -n "$with_locales" -a "$with_locales" != en -a "$with_locales" != ALL; then
+        AC_MSG_ERROR([Currently just --with-locales=all or en is supported with --enable-customtarget-components])
+    fi
+fi
+AC_SUBST(ENABLE_CUSTOMTARGET_COMPONENTS)
+
+if test "$enable_extensions" = yes; then
+    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
+    AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
+else
+    enable_extension_integration=no
+    enable_extension_update=no
+fi
+
+# remember SYSBASE value
+AC_SUBST(SYSBASE)
+
+dnl ===================================================================
+dnl  Sort out various gallery compilation options
+dnl ===================================================================
+WITH_GALLERY_BUILD=TRUE
+AC_MSG_CHECKING([how to build and package galleries])
+if test -n "${with_galleries}"; then
+    if test "$with_galleries" = "build"; then
+        if test "$enable_database_connectivity" = no; then
+            AC_MSG_ERROR([DB connectivity is needed for gengal / svx])
+        fi
+        AC_MSG_RESULT([build from source images internally])
+    elif test "$with_galleries" = "no"; then
+        WITH_GALLERY_BUILD=
+        AC_MSG_RESULT([disable non-internal gallery build])
+    else
+        AC_MSG_ERROR([unknown value --with-galleries=$with_galleries])
+    fi
+else
+    if test $_os != iOS -a $_os != Android; then
+        AC_MSG_RESULT([internal src images for desktop])
+    else
+        WITH_GALLERY_BUILD=
+        AC_MSG_RESULT([disable src image build])
+    fi
+fi
+AC_SUBST(WITH_GALLERY_BUILD)
+
+dnl ===================================================================
+dnl  Sort out various templates compilation options
+dnl ===================================================================
+WITH_TEMPLATES=TRUE
+AC_MSG_CHECKING([build with or without template files])
+if test -n "${with_templates}"; then
+    if test "$with_templates" = "yes"; then
+        AC_MSG_RESULT([enable all templates])
+    elif test "$with_templates" = "no"; then
+        WITH_TEMPLATES=
+        AC_MSG_RESULT([disable non-internal templates])
+    else
+        AC_MSG_ERROR([unknown value --with-templates=$with_templates])
+    fi
+else
+    if test $_os != iOS -a $_os != Android -a $_os != Emscripten; then
+        AC_MSG_RESULT([enable all templates])
+    else
+        WITH_TEMPLATES=
+        AC_MSG_RESULT([disable non-internal templates])
+    fi
+fi
+AC_SUBST(WITH_TEMPLATES)
+
+dnl ===================================================================
+dnl  Checks if ccache is available
+dnl ===================================================================
+CCACHE_DEPEND_MODE=
+if test "$enable_ccache" = "no"; then
+    CCACHE=""
+elif test -n "$enable_ccache" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" \); then
+    case "%$CC%$CXX%" in
+    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some version number etc),
+    # assume that's good then
+    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
+        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
+        CCACHE_DEPEND_MODE=1
+        ;;
+    *)
+        # try to use our own ccache if it is available and CCACHE was not already defined
+        if test -z "$CCACHE"; then
+            if test "$_os" = "WINNT"; then
+                ccache_ext=.exe # e.g. openssl build needs ccache.exe, not just ccache
+            fi
+            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/ccache$ccache_ext" ; then
+                CCACHE="$LODE_HOME/opt/bin/ccache$ccache_ext"
+            elif test -x "/opt/lo/bin/ccache$ccache_ext"; then
+                CCACHE="/opt/lo/bin/ccache$ccache_ext"
+            fi
+        fi
+        AC_PATH_PROG([CCACHE],[ccache],[not found])
+        if test "$CCACHE" != "not found" -a "$_os" = "WINNT"; then
+            CCACHE=`win_short_path_for_make "$CCACHE"`
+            # check that it has MSVC support (it should recognize it in CCACHE_COMPILERTYPE)
+            rm -f conftest.txt
+            AC_MSG_CHECKING([whether $CCACHE has MSVC support])
+            CCACHE_COMPILERTYPE=cl CCACHE_LOGFILE=conftest.txt $CCACHE echo >/dev/null 2>/dev/null
+            if grep -q 'Config: (environment) compiler_type = cl' conftest.txt; then
+                AC_MSG_RESULT(yes)
+            else
+                AC_MSG_RESULT(no)
+                CCACHE="not found"
+            fi
+            rm -f conftest.txt
+        fi
+        if test "$CCACHE" = "not found" -a "$_os" = "WINNT"; then
+            # on windows/VC perhaps sccache is around?
+            case "%$CC%$CXX%" in
+            # If $CC and/or $CXX already contain "sccache" (possibly suffixed with some version number etc),
+            # assume that's good then
+            *%sccache[[-_' ']]*|*/sccache[[-_' ']]*)
+                AC_MSG_NOTICE([sccache seems to be included in a pre-defined CC and/or CXX])
+                CCACHE_DEPEND_MODE=1
+                SCCACHE=1
+                ;;
+            *)
+                # for sharing code below, reuse CCACHE env var
+                AC_PATH_PROG([CCACHE],[sccache],[not found])
+                if test "$CCACHE" != "not found"; then
+                    CCACHE=`win_short_path_for_make "$CCACHE"`
+                    SCCACHE=1
+                    CCACHE_DEPEND_MODE=1
+                fi
+                ;;
+            esac
+        fi
+        if test "$CCACHE" = "not found"; then
+            CCACHE=""
+        fi
+        if test -n "$CCACHE" -a -z "$SCCACHE"; then
+            CCACHE_DEPEND_MODE=1
+            # Need to check for ccache version: otherwise prevents
+            # caching of the results (like "-x objective-c++" for Mac)
+            if test $_os = Darwin -o $_os = iOS; then
+                # Check ccache version
+                AC_MSG_CHECKING([whether version of ccache is suitable])
+                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
+                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
+                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
+                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
+                else
+                    AC_MSG_RESULT([no, $CCACHE_VERSION])
+                    CCACHE=""
+                    CCACHE_DEPEND_MODE=
+                fi
+            fi
+        fi
+        ;;
+    esac
+else
+    CCACHE=""
+fi
+if test "$enable_ccache" = "nodepend"; then
+    CCACHE_DEPEND_MODE=""
+fi
+AC_SUBST(CCACHE_DEPEND_MODE)
+
+# sccache defaults are good enough
+if test "$CCACHE" != "" -a -z "$SCCACHE"; then
+    # e.g. (/home/rene/.config/ccache/ccache.conf) max_size = 20.0G
+    # or (...) max_size = 20.0 G
+    # -p works with both 4.2 and 4.4
+    ccache_size_msg=$([$CCACHE -p | $AWK /max_size/'{ print $4 $5 }' | sed -e 's/\.[0-9]*//'])
+    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
+    if test "$ccache_size" = ""; then
+        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
+        if test "$ccache_size" = ""; then
+            ccache_size=0
+        fi
+        # we could not determine the size or it was less than 1GB -> disable auto-ccache
+        if test $ccache_size -lt 1024; then
+            CCACHE=""
+            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-productive: Disabling auto-ccache detection])
+            add_warning "ccache's cache size is less than 1GB using it is counter-productive: auto-ccache detection disabled"
+        else
+            # warn that ccache may be too small for debug build
+            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
+            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
+        fi
+    else
+        if test $ccache_size -lt 5; then
+            #warn that ccache may be too small for debug build
+            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
+            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
+        fi
+    fi
+fi
+
+ENABLE_Z7_DEBUG=
+if test "$enable_z7_debug" != no; then
+    if test "$enable_z7_debug" = yes -o -n "$CCACHE"; then
+        ENABLE_Z7_DEBUG=TRUE
+    fi
+else
+    AC_MSG_WARN([ccache will not work with --disable-z7-debug])
+    add_warning "ccache will not work with --disable-z7-debug"
+fi
+AC_SUBST(ENABLE_Z7_DEBUG)
+
+dnl ===================================================================
+dnl  Checks for C compiler,
+dnl  The check for the C++ compiler is later on.
+dnl ===================================================================
+if test "$_os" != "WINNT"; then
+    GCC_HOME_SET="true"
+    AC_MSG_CHECKING([gcc home])
+    if test -z "$with_gcc_home"; then
+        if test "$enable_icecream" = "yes"; then
+            if test -d "/usr/lib/icecc/bin"; then
+                GCC_HOME="/usr/lib/icecc/"
+            elif test -d "/usr/libexec/icecc/bin"; then
+                GCC_HOME="/usr/libexec/icecc/"
+            elif test -d "/opt/icecream/bin"; then
+                GCC_HOME="/opt/icecream/"
+            else
+                AC_MSG_ERROR([Could not figure out the location of icecream GCC wrappers, manually use --with-gcc-home])
+
+            fi
+        else
+            GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
+            GCC_HOME_SET="false"
+        fi
+    else
+        GCC_HOME="$with_gcc_home"
+    fi
+    AC_MSG_RESULT($GCC_HOME)
+    AC_SUBST(GCC_HOME)
+
+    if test "$GCC_HOME_SET" = "true"; then
+        if test -z "$CC"; then
+            CC="$GCC_HOME/bin/gcc"
+            CC_BASE="gcc"
+        fi
+        if test -z "$CXX"; then
+            CXX="$GCC_HOME/bin/g++"
+            CXX_BASE="g++"
+        fi
+    fi
+fi
+
+COMPATH=`dirname "$CC"`
+if test "$COMPATH" = "."; then
+    AC_PATH_PROGS(COMPATH, $CC)
+    dnl double square bracket to get single because of M4 quote...
+    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`
+fi
+COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
+
+dnl ===================================================================
+dnl Java support
+dnl ===================================================================
+AC_MSG_CHECKING([whether to build with Java support])
+if test "$with_java" != "no"; then
+    if test "$DISABLE_SCRIPTING" = TRUE; then
+        AC_MSG_RESULT([no, overridden by --disable-scripting])
+        ENABLE_JAVA=""
+        with_java=no
+    else
+        AC_MSG_RESULT([yes])
+        ENABLE_JAVA="TRUE"
+        AC_DEFINE(HAVE_FEATURE_JAVA)
+    fi
+else
+    AC_MSG_RESULT([no])
+    ENABLE_JAVA=""
+fi
+
+AC_SUBST(ENABLE_JAVA)
+
+dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) support for Java
+
+dnl ENABLE_JAVA="" indicate no Java support at all
+
+dnl ===================================================================
+dnl Check macOS SDK and compiler
+dnl ===================================================================
+
+if test $_os = Darwin; then
+
+    # The SDK in the currently selected Xcode should be found.
+
+    AC_MSG_CHECKING([what macOS SDK to use])
+    # XCode only ships with a single SDK for a while now, and using older SDKs alongside is not
+    # really supported anymore, instead you'd use different copies of Xcode, each with their own
+    # SDK, and thus xcrun will pick the SDK that matches the currently selected Xcode version
+    # also restricting the SDK version to "known good" versions doesn't seem necessary anymore, the
+    # problems that existed in the PPC days with target versions not being respected or random
+    # failures seems to be a thing of the past or rather: limiting either the Xcode version or the
+    # SDK version is enough, no need to do both...
+    MACOSX_SDK_PATH=`xcrun --sdk macosx --show-sdk-path 2> /dev/null`
+    if test ! -d "$MACOSX_SDK_PATH"; then
+        AC_MSG_ERROR([Could not find an appropriate macOS SDK])
+    fi
+    macosx_sdk=`xcodebuild -version -sdk "$MACOSX_SDK_PATH" SDKVersion`
+    MACOSX_SDK_BUILD_VERSION=$(xcodebuild -version -sdk "$MACOSX_SDK_PATH" ProductBuildVersion)
+    # format changed between 10.9 and 10.10 - up to 10.9 it was just four digits (1090), starting
+    # with macOS 10.10 it was switched to account for x.y.z with six digits, 10.10 is 101000,
+    # 10.10.2 is 101002
+    # we don't target the lower versions anymore, so it doesn't matter that we don't generate the
+    # correct version in case such an old SDK is specified, it will be rejected later anyway
+    MACOSX_SDK_VERSION=$(echo $macosx_sdk | $AWK -F. '{ print $1*10000+$2*100+$3 }')
+    if test $MACOSX_SDK_VERSION -lt 101500; then
+        AC_MSG_ERROR([macOS SDK $macosx_sdk is not supported, lowest supported version is 10.15])
+    fi
+    if test "$host_cpu" = arm64 -a $MACOSX_SDK_VERSION -lt 110000; then
+        AC_MSG_ERROR([macOS SDK $macosx_sdk is not supported for Apple Silicon (need at least 11.0)])
+    fi
+    AC_MSG_RESULT([macOS SDK $macosx_sdk at $MACOSX_SDK_PATH])
+
+    AC_MSG_CHECKING([what minimum version of macOS to require])
+    if test "$with_macosx_version_min_required" = "" ; then
+        if test "$host_cpu" = x86_64; then
+            with_macosx_version_min_required="10.15";
+        else
+            with_macosx_version_min_required="11.0";
+        fi
+    fi
+    # see same notes about MACOSX_SDK_VERSION above
+    MAC_OS_X_VERSION_MIN_REQUIRED=$(echo $with_macosx_version_min_required | $AWK -F. '{ print $1*10000+$2*100+$3 }')
+    if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 101500; then
+        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, minimum supported version is 10.15])
+    fi
+    AC_MSG_RESULT([$with_macosx_version_min_required])
+
+    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macos-with-sdk])
+    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MACOSX_SDK_VERSION; then
+        AC_MSG_ERROR([the version minimum required ($with_macosx_version_min_required) cannot be greater than the sdk level ($macosx_sdk)])
+    else
+        AC_MSG_RESULT([yes])
+    fi
+
+    # export this so that "xcrun" invocations later return matching values
+    DEVELOPER_DIR="${MACOSX_SDK_PATH%/SDKs*}"
+    DEVELOPER_DIR="${DEVELOPER_DIR%/Platforms*}"
+    export DEVELOPER_DIR
+    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
+    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
+
+    AC_MSG_CHECKING([whether Xcode is new enough])
+    my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
+    my_xcode_ver2=${my_xcode_ver1#Xcode }
+    my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
+    if test "$my_xcode_ver3" -ge 1205; then
+        AC_MSG_RESULT([yes ($my_xcode_ver2)])
+        if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 120000; then
+            if test "$my_xcode_ver3" -ge 1600; then
+                dnl the Xcode 15 relnotes state that the classic linker will disappear in the next version, but nothing about
+                dnl fixing the problem with weak symbols/macOS 11 compatibility, so assume for now that Xcode 16 will break it...
+                AC_MSG_ERROR([Check that Xcode 16 still supports the old linker/that it doesn't break macOS 11 compatibility, then remove this check]);
+            fi
+            if test "$my_xcode_ver3" -ge 1500; then
+                AC_MSG_WARN([Xcode 15 has a new linker that causes runtime crashes on macOS 11])
+                add_warning "Xcode 15 has a new linker that causes runtime crashes on macOS 11, forcing the old linker."
+                add_warning "see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking"
+                LDFLAGS="$LDFLAGS -Wl,-ld_classic"
+                # if LDFLAGS weren't set already, a check above sets x_LDFLAGS=[#] to comment-out the export LDFLAGS line in config_host.mk
+                x_LDFLAGS=
+            fi
+        fi
+    else
+        AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 12.5])
+    fi
+
+    my_xcode_ver1=$(xcrun xcodebuild -version | tail -n 1)
+    MACOSX_XCODE_BUILD_VERSION=${my_xcode_ver1#Build version }
+
+    LIBTOOL=/usr/bin/libtool
+    INSTALL_NAME_TOOL=install_name_tool
+    if test -z "$save_CC"; then
+        stdlib=-stdlib=libc++
+
+        AC_MSG_CHECKING([what C compiler to use])
+        CC="`xcrun -find clang`"
+        CC_BASE=`first_arg_basename "$CC"`
+        if test "$host_cpu" = x86_64; then
+            CC+=" -target x86_64-apple-macos"
+        else
+            CC+=" -target arm64-apple-macos"
+        fi
+        CC+=" -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
+        AC_MSG_RESULT([$CC])
+
+        AC_MSG_CHECKING([what C++ compiler to use])
+        CXX="`xcrun -find clang++`"
+        CXX_BASE=`first_arg_basename "$CXX"`
+        if test "$host_cpu" = x86_64; then
+            CXX+=" -target x86_64-apple-macos"
+        else
+            CXX+=" -target arm64-apple-macos"
+        fi
+        CXX+=" $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
+        AC_MSG_RESULT([$CXX])
+
+        INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
+        AR=`xcrun -find ar`
+        NM=`xcrun -find nm`
+        STRIP=`xcrun -find strip`
+        LIBTOOL=`xcrun -find libtool`
+        RANLIB=`xcrun -find ranlib`
+    fi
+
+    AC_MSG_CHECKING([whether to do code signing])
+
+    if test -z "$enable_macosx_code_signing" -o "$enable_macosx_code_signing" == "no" ; then
+        AC_MSG_RESULT([no])
+    else
+        if test "$enable_macosx_code_signing" = yes; then
+            # By default use the first suitable certificate (?).
+
+            # https://stackoverflow.com/questions/13196291/difference-between-mac-developer-and-3rd-party-mac-developer-application
+            # says that the "Mac Developer" certificate is useful just for self-testing. For distribution
+            # outside the Mac App Store, use the "Developer ID Application" one, and for distribution in
+            # the App Store, the "3rd Party Mac Developer" one. I think it works best to the
+            # "Developer ID Application" one.
+            identity="Developer ID Application:"
+        else
+            identity=$enable_macosx_code_signing
+        fi
+        identity=`security find-identity -p codesigning -v 2>/dev/null | $AWK "/$identity/{print \\$2; exit}"`
+        if test -n "$identity"; then
+            MACOSX_CODESIGNING_IDENTITY=$identity
+            pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
+            AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
+        else
+            AC_MSG_ERROR([cannot determine identity to use])
+        fi
+    fi
+
+    AC_MSG_CHECKING([whether to create a Mac App Store package])
+
+    if test -z "$enable_macosx_package_signing" || test "$enable_macosx_package_signing" == no; then
+        AC_MSG_RESULT([no])
+    elif test -z "$MACOSX_CODESIGNING_IDENTITY"; then
+        AC_MSG_ERROR([You forgot --enable-macosx-code-signing])
+    else
+        if test "$enable_macosx_package_signing" = yes; then
+            # By default use the first suitable certificate.
+            # It should be a "3rd Party Mac Developer Installer" one
+            identity="3rd Party Mac Developer Installer:"
+        else
+            identity=$enable_macosx_package_signing
+        fi
+        identity=`security find-identity -v 2>/dev/null | $AWK "/$identity/ {print \\$2; exit}"`
+        if test -n "$identity"; then
+            MACOSX_PACKAGE_SIGNING_IDENTITY=$identity
+            pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
+            AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
+        else
+            AC_MSG_ERROR([Could not find any suitable '3rd Party Mac Developer Installer' certificate])
+        fi
+    fi
+
+    if test -n "$MACOSX_CODESIGNING_IDENTITY" -a -n "$MACOSX_PACKAGE_SIGNING_IDENTITY" -a "$MACOSX_CODESIGNING_IDENTITY" = "$MACOSX_PACKAGE_SIGNING_IDENTITY"; then
+        AC_MSG_ERROR([You should not use the same identity for code and package signing])
+    fi
+
+    AC_MSG_CHECKING([whether to sandbox the application])
+
+    if test -n "$ENABLE_JAVA" -a "$enable_macosx_sandbox" = yes; then
+        AC_MSG_ERROR([macOS sandboxing (actually App Store rules) disallows use of Java])
+    elif test "$enable_macosx_sandbox" = yes; then
+        ENABLE_MACOSX_SANDBOX=TRUE
+        AC_DEFINE(HAVE_FEATURE_MACOSX_SANDBOX)
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+    fi
+
+    AC_MSG_CHECKING([what macOS app bundle identifier to use])
+    MACOSX_BUNDLE_IDENTIFIER=$with_macosx_bundle_identifier
+    AC_MSG_RESULT([$MACOSX_BUNDLE_IDENTIFIER])
+
+    if test -n "$with_macosx_provisioning_profile" ; then
+        if test ! -f "$with_macosx_provisioning_profile"; then
+            AC_MSG_ERROR([provisioning profile not found at $with_macosx_provisioning_profile])
+        else
+            MACOSX_PROVISIONING_PROFILE=$with_macosx_provisioning_profile
+            MACOSX_PROVISIONING_INFO=$([security cms -D -i "$MACOSX_PROVISIONING_PROFILE" | \
+                xmllint --xpath "//key[.='com.apple.application-identifier' or .='com.apple.developer.team-identifier'] \
+                    | //key[.='com.apple.application-identifier' or .='com.apple.developer.team-identifier']/following-sibling::string[1]" - | \
+                sed -e 's#><#>\n\t<#g' -e 's#^#\t#'])
+        fi
+    fi
+fi
+AC_SUBST(MACOSX_SDK_PATH)
+AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
+AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
+AC_SUBST(INSTALL_NAME_TOOL)
+AC_SUBST(LIBTOOL) # Note that the macOS libtool command is unrelated to GNU libtool
+AC_SUBST(MACOSX_CODESIGNING_IDENTITY)
+AC_SUBST(MACOSX_PACKAGE_SIGNING_IDENTITY)
+AC_SUBST(ENABLE_MACOSX_SANDBOX)
+AC_SUBST(MACOSX_BUNDLE_IDENTIFIER)
+AC_SUBST(MACOSX_PROVISIONING_INFO)
+AC_SUBST(MACOSX_PROVISIONING_PROFILE)
+AC_SUBST(MACOSX_SDK_BUILD_VERSION)
+AC_SUBST(MACOSX_XCODE_BUILD_VERSION)
+
+dnl ===================================================================
+dnl Check iOS SDK and compiler
+dnl ===================================================================
+
+if test $_os = iOS; then
+    AC_MSG_CHECKING([what iOS SDK to use])
+
+    if test "$enable_ios_simulator" = "yes"; then
+        platformlc=iphonesimulator
+        versionmin=-mios-simulator-version-min=14.5
+    else
+        platformlc=iphoneos
+        versionmin=-miphoneos-version-min=14.5
+    fi
+
+    sysroot=`xcrun --sdk $platformlc --show-sdk-path`
+
+    if ! test -d "$sysroot"; then
+        AC_MSG_ERROR([Could not find iOS SDK $sysroot])
+    fi
+
+    AC_MSG_RESULT($sysroot)
+
+    stdlib="-stdlib=libc++"
+
+    AC_MSG_CHECKING([what C compiler to use])
+    CC="`xcrun -find clang`"
+    CC_BASE=`first_arg_basename "$CC"`
+    CC+=" -arch $host_cpu_for_clang -isysroot $sysroot $versionmin"
+    AC_MSG_RESULT([$CC])
+
+    AC_MSG_CHECKING([what C++ compiler to use])
+    CXX="`xcrun -find clang++`"
+    CXX_BASE=`first_arg_basename "$CXX"`
+    CXX+=" -arch $host_cpu_for_clang $stdlib -isysroot $sysroot $versionmin"
+    AC_MSG_RESULT([$CXX])
+
+    INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
+    AR=`xcrun -find ar`
+    NM=`xcrun -find nm`
+    STRIP=`xcrun -find strip`
+    LIBTOOL=`xcrun -find libtool`
+    RANLIB=`xcrun -find ranlib`
+fi
+
+AC_MSG_CHECKING([whether to treat the installation as read-only])
+
+if test $_os = Darwin; then
+    enable_readonly_installset=yes
+elif test "$enable_extensions" != yes; then
+    enable_readonly_installset=yes
+fi
+if test "$enable_readonly_installset" = yes; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(HAVE_FEATURE_READONLY_INSTALLSET)
+else
+    AC_MSG_RESULT([no])
+fi
+
+dnl ===================================================================
+dnl Structure of install set
+dnl ===================================================================
+
+if test $_os = Darwin; then
+    LIBO_BIN_FOLDER=MacOS
+    LIBO_ETC_FOLDER=Resources
+    LIBO_LIBEXEC_FOLDER=MacOS
+    LIBO_LIB_FOLDER=Frameworks
+    LIBO_LIB_PYUNO_FOLDER=Resources
+    LIBO_SHARE_FOLDER=Resources
+    LIBO_SHARE_HELP_FOLDER=Resources/help
+    LIBO_SHARE_JAVA_FOLDER=Resources/java
+    LIBO_SHARE_PRESETS_FOLDER=Resources/presets
+    LIBO_SHARE_READMES_FOLDER=Resources/readmes
+    LIBO_SHARE_RESOURCE_FOLDER=Resources/resource
+    LIBO_SHARE_SHELL_FOLDER=Resources/shell
+    LIBO_URE_BIN_FOLDER=MacOS
+    LIBO_URE_ETC_FOLDER=Resources/ure/etc
+    LIBO_URE_LIB_FOLDER=Frameworks
+    LIBO_URE_MISC_FOLDER=Resources/ure/share/misc
+    LIBO_URE_SHARE_JAVA_FOLDER=Resources/java
+elif test $_os = WINNT; then
+    LIBO_BIN_FOLDER=program
+    LIBO_ETC_FOLDER=program
+    LIBO_LIBEXEC_FOLDER=program
+    LIBO_LIB_FOLDER=program
+    LIBO_LIB_PYUNO_FOLDER=program
+    LIBO_SHARE_FOLDER=share
+    LIBO_SHARE_HELP_FOLDER=help
+    LIBO_SHARE_JAVA_FOLDER=program/classes
+    LIBO_SHARE_PRESETS_FOLDER=presets
+    LIBO_SHARE_READMES_FOLDER=readmes
+    LIBO_SHARE_RESOURCE_FOLDER=program/resource
+    LIBO_SHARE_SHELL_FOLDER=program/shell
+    LIBO_URE_BIN_FOLDER=program
+    LIBO_URE_ETC_FOLDER=program
+    LIBO_URE_LIB_FOLDER=program
+    LIBO_URE_MISC_FOLDER=program
+    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
+else
+    LIBO_BIN_FOLDER=program
+    LIBO_ETC_FOLDER=program
+    LIBO_LIBEXEC_FOLDER=program
+    LIBO_LIB_FOLDER=program
+    LIBO_LIB_PYUNO_FOLDER=program
+    LIBO_SHARE_FOLDER=share
+    LIBO_SHARE_HELP_FOLDER=help
+    LIBO_SHARE_JAVA_FOLDER=program/classes
+    LIBO_SHARE_PRESETS_FOLDER=presets
+    LIBO_SHARE_READMES_FOLDER=readmes
+    if test "$enable_fuzzers" != yes; then
+        LIBO_SHARE_RESOURCE_FOLDER=program/resource
+    else
+        LIBO_SHARE_RESOURCE_FOLDER=resource
+    fi
+    LIBO_SHARE_SHELL_FOLDER=program/shell
+    LIBO_URE_BIN_FOLDER=program
+    LIBO_URE_ETC_FOLDER=program
+    LIBO_URE_LIB_FOLDER=program
+    LIBO_URE_MISC_FOLDER=program
+    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
+fi
+AC_DEFINE_UNQUOTED(LIBO_BIN_FOLDER,"$LIBO_BIN_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_ETC_FOLDER,"$LIBO_ETC_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_LIBEXEC_FOLDER,"$LIBO_LIBEXEC_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_LIB_FOLDER,"$LIBO_LIB_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_LIB_PYUNO_FOLDER,"$LIBO_LIB_PYUNO_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_SHARE_FOLDER,"$LIBO_SHARE_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_SHARE_HELP_FOLDER,"$LIBO_SHARE_HELP_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_SHARE_JAVA_FOLDER,"$LIBO_SHARE_JAVA_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_SHARE_PRESETS_FOLDER,"$LIBO_SHARE_PRESETS_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_SHARE_RESOURCE_FOLDER,"$LIBO_SHARE_RESOURCE_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_SHARE_SHELL_FOLDER,"$LIBO_SHARE_SHELL_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_URE_BIN_FOLDER,"$LIBO_URE_BIN_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_URE_ETC_FOLDER,"$LIBO_URE_ETC_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_URE_LIB_FOLDER,"$LIBO_URE_LIB_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_URE_MISC_FOLDER,"$LIBO_URE_MISC_FOLDER")
+AC_DEFINE_UNQUOTED(LIBO_URE_SHARE_JAVA_FOLDER,"$LIBO_URE_SHARE_JAVA_FOLDER")
+
+# Not all of them needed in config_host.mk, add more if need arises
+AC_SUBST(LIBO_BIN_FOLDER)
+AC_SUBST(LIBO_ETC_FOLDER)
+AC_SUBST(LIBO_LIB_FOLDER)
+AC_SUBST(LIBO_LIB_PYUNO_FOLDER)
+AC_SUBST(LIBO_SHARE_FOLDER)
+AC_SUBST(LIBO_SHARE_HELP_FOLDER)
+AC_SUBST(LIBO_SHARE_JAVA_FOLDER)
+AC_SUBST(LIBO_SHARE_PRESETS_FOLDER)
+AC_SUBST(LIBO_SHARE_READMES_FOLDER)
+AC_SUBST(LIBO_SHARE_RESOURCE_FOLDER)
+AC_SUBST(LIBO_URE_BIN_FOLDER)
+AC_SUBST(LIBO_URE_ETC_FOLDER)
+AC_SUBST(LIBO_URE_LIB_FOLDER)
+AC_SUBST(LIBO_URE_MISC_FOLDER)
+AC_SUBST(LIBO_URE_SHARE_JAVA_FOLDER)
+
+dnl ===================================================================
+dnl Windows specific tests and stuff
+dnl ===================================================================
+
+reg_get_value()
+{
+    # Return value: $regvalue
+    unset regvalue
+
+    if test "$build_os" = "wsl"; then
+        regvalue=$($WSL_LO_HELPER --read-registry $1 "$2" 2>/dev/null)
+        return
+    fi
+
+    local _regentry="/proc/registry${1}/${2}"
+    if test -f "$_regentry"; then
+        # Stop bash complaining about \0 bytes in input, as it can't handle them.
+        # Registry keys read via /proc/registry* are always \0 terminated!
+        local _regvalue=$(tr -d '\0' < "$_regentry")
+        if test $? -eq 0; then
+            regvalue=$_regvalue
+        fi
+    fi
+}
+
+# Get a value from the 32-bit side of the Registry
+reg_get_value_32()
+{
+    reg_get_value "32" "$1"
+}
+
+# Get a value from the 64-bit side of the Registry
+reg_get_value_64()
+{
+    reg_get_value "64" "$1"
+}
+
+reg_list_values()
+{
+    # Return value: $reglist
+    unset reglist
+
+    if test "$build_os" = "wsl"; then
+        reglist=$($WSL_LO_HELPER --list-registry $1 "$2" 2>/dev/null | tr -d '\r')
+        return
+    fi
+
+    reglist=$(ls "/proc/registry${1}/${2}")
+}
+
+# List values from the 32-bit side of the Registry
+reg_list_values_32()
+{
+    reg_list_values "32" "$1"
+}
+
+# List values from the 64-bit side of the Registry
+reg_list_values_64()
+{
+    reg_list_values "64" "$1"
+}
+
+case "$host_os" in
+cygwin*|wsl*)
+    COM=MSC
+    OS=WNT
+    RTL_OS=Windows
+    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+        P_SEP=";"
+    else
+        P_SEP=:
+    fi
+    case "$host_cpu" in
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=windows_x86_64
+        WINDOWS_X64=1
+        SCPDEFS="$SCPDEFS -DWINDOWS_X64"
+        WIN_HOST_ARCH="x64"
+        WIN_MULTI_ARCH="x86"
+        WIN_HOST_BITS=64
+        ;;
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=windows_x86
+        WIN_HOST_ARCH="x86"
+        WIN_HOST_BITS=32
+        WIN_OTHER_ARCH="x64"
+        ;;
+    aarch64)
+        CPUNAME=AARCH64
+        RTL_ARCH=AARCH64
+        PLATFORMID=windows_aarch64
+        WINDOWS_X64=1
+        SCPDEFS="$SCPDEFS -DWINDOWS_AARCH64"
+        WIN_HOST_ARCH="arm64"
+        WIN_HOST_BITS=64
+        with_ucrt_dir=no
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+
+    case "$build_cpu" in
+    x86_64) WIN_BUILD_ARCH="x64" ;;
+    i*86) WIN_BUILD_ARCH="x86" ;;
+    aarch64) WIN_BUILD_ARCH="arm64" ;;
+    *)
+        AC_MSG_ERROR([Unsupported build_cpu $build_cpu for host_os $host_os])
+        ;;
+    esac
+
+    SCPDEFS="$SCPDEFS -D_MSC_VER"
+    ;;
+esac
+
+# multi-arch is an arch, which can execute on the host (x86 on x64), while
+# other-arch won't, but wouldn't break the build (x64 on x86).
+if test -n "$WIN_MULTI_ARCH" -a -n "$WIN_OTHER_ARCH"; then
+    AC_MSG_ERROR([Broken configure.ac file: can't have set \$WIN_MULTI_ARCH and $WIN_OTHER_ARCH])
+fi
+
+
+if test "$build_cpu" != "$host_cpu" -o "$DISABLE_DYNLOADING" = TRUE; then
+    # To allow building Windows multi-arch releases without cross-tooling
+    if test "$DISABLE_DYNLOADING" = TRUE -o \( -z "$WIN_MULTI_ARCH" -a -z "$WIN_OTHER_ARCH" \); then
+        cross_compiling="yes"
+    fi
+fi
+
+if test "$cross_compiling" = "yes"; then
+    export CROSS_COMPILING=TRUE
+    if test "$enable_dynamic_loading" != yes -a "$enable_wasm_strip" = yes; then
+        ENABLE_WASM_STRIP=TRUE
+    fi
+    if test "$_os" = "Emscripten"; then
+        if test "$with_main_module" = "calc"; then
+            ENABLE_WASM_STRIP_WRITER=TRUE
+        elif test "$with_main_module" = "writer"; then
+            ENABLE_WASM_STRIP_CALC=TRUE
+        fi
+    fi
+else
+    CROSS_COMPILING=
+    BUILD_TYPE="$BUILD_TYPE NATIVE"
+fi
+AC_SUBST(CROSS_COMPILING)
+AC_SUBST(ENABLE_WASM_STRIP)
+AC_SUBST(ENABLE_WASM_STRIP_WRITER)
+AC_SUBST(ENABLE_WASM_STRIP_CALC)
+
+ISYSTEM=-I
+AC_SUBST(ISYSTEM)
+
+dnl ===================================================================
+dnl  Check which Visual Studio compiler is used
+dnl ===================================================================
+
+map_vs_year_to_version()
+{
+    # Return value: $vsversion
+
+    unset vsversion
+
+    case $1 in
+    2019)
+        vsversion=16;;
+    2022)
+        vsversion=17;;
+    2022preview)
+        vsversion=17.9;;
+    *)
+        AC_MSG_ERROR([Assertion failure - invalid argument "$1" to map_vs_year_to_version()]);;
+    esac
+}
+
+vs_versions_to_check()
+{
+    # Args: $1 (optional) : versions to check, in the order of preference
+    # Return value: $vsversions
+
+    unset vsversions
+
+    if test -n "$1"; then
+        map_vs_year_to_version "$1"
+        vsversions=$vsversion
+    else
+        # Default version is 2019
+        vsversions="16"
+    fi
+}
+
+win_get_env_from_vsdevcmdbat()
+{
+    local WRAPPERBATCHFILEPATH="`mktemp -t wrpXXXXXX.bat`"
+    printf '@set VSCMD_SKIP_SENDTELEMETRY=1\r\n' > $WRAPPERBATCHFILEPATH
+    printf '@call "%s/../Common7/Tools/VsDevCmd.bat" /no_logo\r\n' "$(cygpath -w $VC_PRODUCT_DIR)" >> $WRAPPERBATCHFILEPATH
+    # use 'echo.%ENV%' syntax (instead of 'echo %ENV%') to avoid outputting "ECHO is off." in case when ENV is empty or a space
+    printf '@setlocal\r\n@echo.%%%s%%\r\n@endlocal\r\n' "$1" >> $WRAPPERBATCHFILEPATH
+    local result
+    if test "$build_os" = "wsl"; then
+        result=$(cd /mnt/c && cmd.exe /c $(wslpath -w $WRAPPERBATCHFILEPATH) | tr -d '\r')
+    else
+        chmod +x $WRAPPERBATCHFILEPATH
+        result=$("$WRAPPERBATCHFILEPATH" | tr -d '\r')
+    fi
+    rm -f $WRAPPERBATCHFILEPATH
+    printf '%s' "$result"
+}
+
+find_ucrt()
+{
+    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/InstallationFolder"
+    if test -n "$regvalue"; then
+        PathFormat "$regvalue"
+        UCRTSDKDIR=$formatted_path_unix
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/ProductVersion"
+        UCRTVERSION=$regvalue
+        # Rest if not exist
+        if ! test -d "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"; then
+          UCRTSDKDIR=
+        fi
+    fi
+    if test -z "$UCRTSDKDIR"; then
+        ide_env_dir="$VC_PRODUCT_DIR/../Common7/Tools/"
+        ide_env_file="${ide_env_dir}VsDevCmd.bat"
+        if test -f "$ide_env_file"; then
+            PathFormat "$(win_get_env_from_vsdevcmdbat UniversalCRTSdkDir)"
+            UCRTSDKDIR=$formatted_path
+            UCRTVERSION=$(win_get_env_from_vsdevcmdbat UCRTVersion)
+            dnl Hack needed at least by tml:
+            if test "$UCRTVERSION" = 10.0.15063.0 \
+                -a ! -f "${UCRTSDKDIR}Include/10.0.15063.0/um/sqlext.h" \
+                -a -f "${UCRTSDKDIR}Include/10.0.14393.0/um/sqlext.h"
+            then
+                UCRTVERSION=10.0.14393.0
+            fi
+        else
+          AC_MSG_ERROR([No UCRT found])
+        fi
+    fi
+}
+
+find_msvc()
+{
+    # Find Visual C++
+    # Args: $1 (optional) : The VS version year
+    # Return values: $vctest, $vcyear, $vctoolset, $vcnumwithdot, $vcbuildnumber
+
+    unset vctest vctoolset vcnumwithdot vcbuildnumber
+
+    vs_versions_to_check "$1"
+    if test "$build_os" = wsl; then
+        vswhere="$PROGRAMFILESX86"
+        if test -z "$vswhere"; then
+            vswhere="c:\\Program Files (x86)"
+        fi
+    else
+        vswhere="$(perl -e 'print $ENV{"ProgramFiles(x86)"}')"
+    fi
+    vswhere+="\\Microsoft Visual Studio\\Installer\\vswhere.exe"
+    PathFormat "$vswhere"
+    vswhere=$formatted_path_unix
+    for ver in $vsversions; do
+        vswhereoutput=`$vswhere -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
+        if test -z "$vswhereoutput"; then
+            vswhereoutput=`$vswhere -prerelease -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
+        fi
+        # Fall back to all MS products (this includes VC++ Build Tools)
+        if ! test -n "$vswhereoutput"; then
+            AC_MSG_CHECKING([VC++ Build Tools and similar])
+            vswhereoutput=`$vswhere -products \* -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
+        fi
+        if test -n "$vswhereoutput"; then
+            PathFormat "$vswhereoutput"
+            vctest=$formatted_path_unix
+            break
+        fi
+    done
+
+    if test -n "$vctest"; then
+        vcnumwithdot="$ver"
+        if test "${vcnumwithdot%%.*}" = "$vcnumwithdot"; then
+            vcnumwithdot=$vcnumwithdot.0
+        fi
+        case "$vcnumwithdot" in
+        16.0)
+            vcyear=2019
+            vctoolset=v142
+            ;;
+        17.0 | 17.9)
+            vcyear=2022
+            vctoolset=v143
+            ;;
+        esac
+        vcbuildnumber=`ls $vctest/VC/Tools/MSVC -A1r | head -1`
+
+    fi
+}
+
+test_cl_exe()
+{
+    AC_MSG_CHECKING([$1 compiler])
+
+    CL_EXE_PATH="$2/cl.exe"
+
+    if test ! -f "$CL_EXE_PATH"; then
+        if test "$1" = "multi-arch"; then
+            AC_MSG_WARN([no compiler (cl.exe) in $2])
+            return 1
+        else
+            AC_MSG_ERROR([no compiler (cl.exe) in $2])
+        fi
+    fi
+
+    dnl ===========================================================
+    dnl  Check for the corresponding mspdb*.dll
+    dnl ===========================================================
+
+    # MSVC 15.0 has libraries from 14.0?
+    mspdbnum="140"
+
+    if test ! -e "$2/mspdb${mspdbnum}.dll"; then
+        AC_MSG_ERROR([No mspdb${mspdbnum}.dll in $2, Visual Studio installation broken?])
+    fi
+
+    # The compiles has to find its shared libraries
+    OLD_PATH="$PATH"
+    TEMP_PATH=`cygpath -d "$2"`
+    PATH="`cygpath -u "$TEMP_PATH"`:$PATH"
+
+    if ! "$CL_EXE_PATH" -? </dev/null >/dev/null 2>&1; then
+        AC_MSG_ERROR([no compiler (cl.exe) in $2])
+    fi
+
+    PATH="$OLD_PATH"
+
+    AC_MSG_RESULT([$CL_EXE_PATH])
+}
+
+SOLARINC=
+MSBUILD_PATH=
+DEVENV=
+if test "$_os" = "WINNT"; then
+    AC_MSG_CHECKING([Visual C++])
+    find_msvc "$with_visual_studio"
+    if test -z "$vctest"; then
+        if test -n "$with_visual_studio"; then
+            AC_MSG_ERROR([no Visual Studio $with_visual_studio installation found])
+        else
+            AC_MSG_ERROR([no Visual Studio installation found])
+        fi
+    fi
+    AC_MSG_RESULT([])
+
+    VC_PRODUCT_DIR="$vctest/VC"
+    COMPATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber"
+
+    # $WIN_OTHER_ARCH is a hack to test the x64 compiler on x86, even if it's not multi-arch
+    if test -n "$WIN_MULTI_ARCH" -o -n "$WIN_OTHER_ARCH"; then
+        MSVC_MULTI_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/${WIN_MULTI_ARCH}${WIN_OTHER_ARCH}"
+        test_cl_exe "multi-arch" "$MSVC_MULTI_PATH"
+        if test $? -ne 0; then
+            WIN_MULTI_ARCH=""
+            WIN_OTHER_ARCH=""
+        fi
+    fi
+
+    if test "$WIN_BUILD_ARCH" = "$WIN_HOST_ARCH"; then
+        MSVC_BUILD_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_BUILD_ARCH"
+        test_cl_exe "build" "$MSVC_BUILD_PATH"
+    fi
+
+    if test "$WIN_BUILD_ARCH" != "$WIN_HOST_ARCH"; then
+        MSVC_HOST_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_HOST_ARCH"
+        test_cl_exe "host" "$MSVC_HOST_PATH"
+    else
+        MSVC_HOST_PATH="$MSVC_BUILD_PATH"
+    fi
+
+    AC_MSG_CHECKING([for short pathname of VC product directory])
+    VC_PRODUCT_DIR=`win_short_path_for_make "$VC_PRODUCT_DIR"`
+    AC_MSG_RESULT([$VC_PRODUCT_DIR])
+
+    UCRTSDKDIR=
+    UCRTVERSION=
+
+    AC_MSG_CHECKING([for UCRT location])
+    find_ucrt
+    # find_ucrt errors out if it doesn't find it
+    AC_MSG_RESULT([$UCRTSDKDIR ($UCRTVERSION)])
+    PathFormat "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"
+    ucrtincpath_formatted=$formatted_path
+    # SOLARINC is used for external modules and must be set too.
+    # And no, it's not sufficient to set SOLARINC only, as configure
+    # itself doesn't honour it.
+    SOLARINC="$SOLARINC -I$ucrtincpath_formatted"
+    CFLAGS="$CFLAGS -I$ucrtincpath_formatted"
+    CXXFLAGS="$CXXFLAGS -I$ucrtincpath_formatted"
+    CPPFLAGS="$CPPFLAGS -I$ucrtincpath_formatted"
+
+    AC_SUBST(UCRTSDKDIR)
+    AC_SUBST(UCRTVERSION)
+
+    AC_MSG_CHECKING([for MSBuild.exe location for: $vcnumwithdot])
+    # Find the proper version of MSBuild.exe to use based on the VS version
+    reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSBuild/$vcnumwithdot/MSBuildOverrideTasksPath
+    if test -z "$regvalue" ; then
+        if test "$WIN_BUILD_ARCH" != "x64"; then
+            regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin"
+        else
+            regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin/amd64"
+        fi
+    fi
+    if test -d "$regvalue" ; then
+        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
+        AC_MSG_RESULT([$regvalue])
+    else
+        AC_MSG_ERROR([MSBuild.exe location not found])
+    fi
+
+    # Find the version of devenv.exe
+    # MSVC 2017 devenv does not start properly from a DOS 8.3 path
+    DEVENV=$(cygpath -lm "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe")
+    DEVENV_unix=$(cygpath -u "$DEVENV")
+    if test ! -e "$DEVENV_unix"; then
+        AC_MSG_WARN([No devenv.exe found - this is expected for VC++ Build Tools])
+    fi
+
+    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
+    dnl needed when building CLR code:
+    if test -z "$MSVC_CXX"; then
+        # This gives us a posix path with 8.3 filename restrictions
+        MSVC_CXX=`win_short_path_for_make "$MSVC_HOST_PATH/cl.exe"`
+    fi
+
+    if test -z "$CC"; then
+        CC=$MSVC_CXX
+        CC_BASE=`first_arg_basename "$CC"`
+    fi
+    if test -z "$CXX"; then
+        CXX=$MSVC_CXX
+        CXX_BASE=`first_arg_basename "$CXX"`
+    fi
+
+    if test -n "$CC"; then
+        # Remove /cl.exe from CC case insensitive
+        AC_MSG_NOTICE([found Visual C++ $vcyear])
+
+        main_include_dir=`cygpath -d -m "$COMPATH/Include"`
+        CPPFLAGS="$CPPFLAGS -I$main_include_dir"
+
+        PathFormat "$COMPATH"
+        COMPATH=`win_short_path_for_make "$formatted_path"`
+
+        VCVER=$vcnumwithdot
+        VCTOOLSET=$vctoolset
+
+        # The WINDOWS_SDK_ACCEPTABLE_VERSIONS is mostly an educated guess...  Assuming newer ones
+        # are always "better", we list them in reverse chronological order.
+
+        case "$vcnumwithdot" in
+        16.0 | 17.0 | 17.9)
+            WINDOWS_SDK_ACCEPTABLE_VERSIONS="10.0 8.1A 8.1 8.0"
+            ;;
+        esac
+
+        # The expectation is that --with-windows-sdk should not need to be used
+        if test -n "$with_windows_sdk"; then
+            case " $WINDOWS_SDK_ACCEPTABLE_VERSIONS " in
+            *" "$with_windows_sdk" "*)
+                WINDOWS_SDK_ACCEPTABLE_VERSIONS=$with_windows_sdk
+                ;;
+            *)
+                AC_MSG_ERROR([Windows SDK $with_windows_sdk is not known to work with VS $vcyear])
+                ;;
+            esac
+        fi
+
+        # Make AC_COMPILE_IFELSE etc. work (set by AC_PROG_C, which we don't use for MSVC)
+        ac_objext=obj
+        ac_exeext=exe
+
+    else
+        AC_MSG_ERROR([Visual C++ not found after all, huh])
+    fi
+
+    # ERROR if VS version < 16.5
+    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.5])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+        // See <https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros> for mapping
+        // between Visual Studio versions and _MSC_VER:
+        #if _MSC_VER < 1925
+        #error
+        #endif
+    ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no])])
+
+    # WARN if VS version < 16.10
+    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.10])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+        #if _MSC_VER < 1929
+        #error
+        #endif
+    ]])],[vs2019_recommended_version=yes],[vs2019_recommended_version=no])
+
+    if test $vs2019_recommended_version = yes; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_WARN([no])
+        add_warning "You should have at least Visual Studio 2019 version 16.10 to avoid build problems. Otherwise, you may face problems with the build of some modules including dragonbox."
+    fi
+
+    # Check for 64-bit (cross-)compiler to use to build the 64-bit
+    # version of the Explorer extension (and maybe other small
+    # bits, too) needed when installing a 32-bit LibreOffice on a
+    # 64-bit OS. The 64-bit Explorer extension is a feature that
+    # has been present since long in OOo. Don't confuse it with
+    # building LibreOffice itself as 64-bit code.
+
+    BUILD_X64=
+    CXX_X64_BINARY=
+
+    if test "$WIN_HOST_ARCH" = "x86" -a -n "$WIN_OTHER_ARCH"; then
+        AC_MSG_CHECKING([for the libraries to build the 64-bit Explorer extensions])
+        if test -f "$COMPATH/atlmfc/lib/x64/atls.lib" -o \
+             -f "$COMPATH/atlmfc/lib/spectre/x64/atls.lib"
+        then
+            BUILD_X64=TRUE
+            CXX_X64_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
+            AC_MSG_RESULT([found])
+        else
+            AC_MSG_RESULT([not found])
+            AC_MSG_WARN([Installation set will not contain 64-bit Explorer extensions])
+        fi
+    elif test "$WIN_HOST_ARCH" = "x64"; then
+        CXX_X64_BINARY=$CXX
+    fi
+    AC_SUBST(BUILD_X64)
+
+    # These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
+    AC_SUBST(CXX_X64_BINARY)
+
+    # Check for 32-bit compiler to use to build the 32-bit TWAIN shim
+    # needed to support TWAIN scan on both 32- and 64-bit systems
+
+    case "$WIN_HOST_ARCH" in
+    x64)
+        AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
+        if test -n "$CXX_X86_BINARY"; then
+            BUILD_X86=TRUE
+            AC_MSG_RESULT([preset])
+        elif test -n "$WIN_MULTI_ARCH"; then
+            BUILD_X86=TRUE
+            CXX_X86_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
+            AC_MSG_RESULT([found])
+        else
+            AC_MSG_RESULT([not found])
+            AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
+        fi
+        ;;
+    x86)
+        BUILD_X86=TRUE
+        CXX_X86_BINARY=$MSVC_CXX
+        ;;
+    esac
+    AC_SUBST(BUILD_X86)
+    AC_SUBST(CXX_X86_BINARY)
+fi
+AC_SUBST(VCVER)
+AC_SUBST(VCTOOLSET)
+AC_SUBST(DEVENV)
+AC_SUBST(MSVC_CXX)
+
+COM_IS_CLANG=
+AC_MSG_CHECKING([whether the compiler is actually Clang])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+    #ifndef __clang__
+    you lose
+    #endif
+    int foo=42;
+    ]])],
+    [AC_MSG_RESULT([yes])
+     COM_IS_CLANG=TRUE],
+    [AC_MSG_RESULT([no])])
+AC_SUBST(COM_IS_CLANG)
+
+CLANGVER=
+if test "$COM_IS_CLANG" = TRUE; then
+    AC_MSG_CHECKING([whether Clang is new enough])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+        #if !defined __apple_build_version__
+        #error
+        #endif
+        ]])],
+        [my_apple_clang=yes],[my_apple_clang=])
+    if test "$my_apple_clang" = yes; then
+        AC_MSG_RESULT([assumed yes (Apple Clang)])
+    elif test "$_os" = Emscripten; then
+        AC_MSG_RESULT([assumed yes (Emscripten Clang)])
+    else
+        if test "$_os" = WINNT; then
+            dnl In which case, assume clang-cl:
+            my_args="/EP /TC"
+        else
+            my_args="-E -P"
+        fi
+        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC $my_args - | sed 's/ //g'`
+        CLANG_FULL_VERSION=`echo __clang_version__ | $CC $my_args -`
+        CLANGVER=`echo $clang_version \
+            | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
+        if test "$CLANGVER" -ge 120000; then
+            AC_MSG_RESULT([yes ($clang_version)])
+        else
+            AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 12])
+        fi
+        AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
+        AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
+    fi
+fi
+
+SHOWINCLUDES_PREFIX=
+if test "$_os" = WINNT; then
+    dnl We need to guess the prefix of the -showIncludes output, it can be
+    dnl localized
+    AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
+    echo "#include <stdlib.h>" > conftest.c
+    SHOWINCLUDES_PREFIX=`VSLANG=1033 $CC $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
+        grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
+    rm -f conftest.c conftest.obj
+    if test -z "$SHOWINCLUDES_PREFIX"; then
+        AC_MSG_ERROR([cannot determine the -showIncludes prefix])
+    else
+        AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
+    fi
+fi
+AC_SUBST(SHOWINCLUDES_PREFIX)
+
+#
+# prefix C with ccache if needed
+#
+if test "$CCACHE" != ""; then
+    AC_MSG_CHECKING([whether $CC_BASE is already ccached])
+
+    AC_LANG_PUSH([C])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS --ccache-skip -O2"
+    # msvc does not fail on unknown options, check stdout
+    if test "$COM" = MSC; then
+        CFLAGS="$CFLAGS -nologo"
+    fi
+    save_ac_c_werror_flag=$ac_c_werror_flag
+    ac_c_werror_flag=yes
+    dnl an empty program will do, we're checking the compiler flags
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+                      [use_ccache=yes], [use_ccache=no])
+    CFLAGS=$save_CFLAGS
+    ac_c_werror_flag=$save_ac_c_werror_flag
+    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
+        AC_MSG_RESULT([yes])
+    else
+        CC="$CCACHE $CC"
+        CC_BASE="ccache $CC_BASE"
+        AC_MSG_RESULT([no])
+    fi
+    AC_LANG_POP([C])
+fi
+
+# ===================================================================
+# check various GCC options that Clang does not support now but maybe
+# will somewhen in the future, check them even for GCC, so that the
+# flags are set
+# ===================================================================
+
+HAVE_GCC_GGDB2=
+if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
+    AC_MSG_CHECKING([whether $CC_BASE supports -ggdb2])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -ggdb2"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
+    CFLAGS=$save_CFLAGS
+    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+    fi
+
+    if test "$host_cpu" = "m68k"; then
+        AC_MSG_CHECKING([whether $CC_BASE supports -mlong-jump-table-offsets])
+        save_CFLAGS=$CFLAGS
+        CFLAGS="$CFLAGS -Werror -mlong-jump-table-offsets"
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_LONG_JUMP_TABLE_OFFSETS=TRUE ],[])
+        CFLAGS=$save_CFLAGS
+        if test "$HAVE_GCC_LONG_JUMP_TABLE_OFFSETS" = "TRUE"; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_ERROR([no])
+        fi
+    fi
+fi
+AC_SUBST(HAVE_GCC_GGDB2)
+
+dnl ===================================================================
+dnl  Test the gcc version
+dnl ===================================================================
+if test "$GCC" = "yes" -a -z "$COM_IS_CLANG"; then
+    AC_MSG_CHECKING([the GCC version])
+    _gcc_version=`$CC -dumpfullversion`
+    gcc_full_version=$(printf '%s' "$_gcc_version" | \
+        $AWK -F. '{ print $1*10000+$2*100+(NF<3?1:$3) }')
+    GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'`
+
+    AC_MSG_RESULT([gcc $_gcc_version ($gcc_full_version)])
+
+    if test "$gcc_full_version" -lt 120000; then
+        AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 12])
+    fi
+else
+    # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses.
+    # GCC version should generally be checked only when handling GCC-specific bugs, for testing
+    # things like features configure checks should be used, otherwise they may e.g. fail with Clang
+    # (which reports itself as GCC 4.2.1).
+    GCC_VERSION=
+fi
+AC_SUBST(GCC_VERSION)
+
+dnl Set the ENABLE_DBGUTIL variable
+dnl ===================================================================
+AC_MSG_CHECKING([whether to build with additional debug utilities])
+if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
+    ENABLE_DBGUTIL="TRUE"
+    # this is an extra var so it can have different default on different MSVC
+    # versions (in case there are version specific problems with it)
+    MSVC_USE_DEBUG_RUNTIME="TRUE"
+
+    AC_MSG_RESULT([yes])
+    # cppunit and graphite expose STL in public headers
+    if test "$with_system_cppunit" = "yes"; then
+        AC_MSG_ERROR([--with-system-cppunit conflicts with --enable-dbgutil])
+    else
+        with_system_cppunit=no
+    fi
+    if test "$with_system_graphite" = "yes"; then
+        AC_MSG_ERROR([--with-system-graphite conflicts with --enable-dbgutil])
+    else
+        with_system_graphite=no
+    fi
+    if test "$with_system_orcus" = "yes"; then
+        AC_MSG_ERROR([--with-system-orcus conflicts with --enable-dbgutil])
+    else
+        with_system_orcus=no
+    fi
+    if test "$with_system_libcmis" = "yes"; then
+        AC_MSG_ERROR([--with-system-libcmis conflicts with --enable-dbgutil])
+    else
+        with_system_libcmis=no
+    fi
+    if test "$with_system_hunspell" = "yes"; then
+        AC_MSG_ERROR([--with-system-hunspell conflicts with --enable-dbgutil])
+    else
+        with_system_hunspell=no
+    fi
+    if test "$with_system_gpgmepp" = "yes"; then
+        AC_MSG_ERROR([--with-system-gpgmepp conflicts with --enable-dbgutil])
+    else
+        with_system_gpgmepp=no
+    fi
+    # As mixing system libwps and non-system libnumbertext or vice versa likely causes trouble (see
+    # 603074c5f2b84de8a24593faf807da784b040625 "Pass _GLIBCXX_DEBUG into external/libwps" and the
+    # mail thread starting at <https://gcc.gnu.org/ml/gcc/2018-05/msg00057.html> "libstdc++: ODR
+    # violation when using std::regex with and without -D_GLIBCXX_DEBUG"), simply make sure neither
+    # of those two is using the system variant:
+    if test "$with_system_libnumbertext" = "yes"; then
+        AC_MSG_ERROR([--with-system-libnumbertext conflicts with --enable-dbgutil])
+    else
+        with_system_libnumbertext=no
+    fi
+    if test "$with_system_libwps" = "yes"; then
+        AC_MSG_ERROR([--with-system-libwps conflicts with --enable-dbgutil])
+    else
+        with_system_libwps=no
+    fi
+else
+    ENABLE_DBGUTIL=""
+    MSVC_USE_DEBUG_RUNTIME=""
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_DBGUTIL)
+AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
+
+dnl Set the ENABLE_DEBUG variable.
+dnl ===================================================================
+if test -n "$enable_debug" && test "$enable_debug" != "yes" && test "$enable_debug" != "no"; then
+    AC_MSG_ERROR([--enable-debug now accepts only yes or no, use --enable-symbols])
+fi
+if test -n "$ENABLE_DBGUTIL" -a "$enable_debug" = "no"; then
+    if test -z "$libo_fuzzed_enable_debug"; then
+        AC_MSG_ERROR([--disable-debug cannot be used with --enable-dbgutil])
+    else
+        AC_MSG_NOTICE([Resetting --enable-debug=yes])
+        enable_debug=yes
+    fi
+fi
+
+AC_MSG_CHECKING([whether to do a debug build])
+if test -n "$ENABLE_DBGUTIL" -o \( -n "$enable_debug" -a "$enable_debug" != "no" \) ; then
+    ENABLE_DEBUG="TRUE"
+    if test -n "$ENABLE_DBGUTIL" ; then
+        AC_MSG_RESULT([yes (dbgutil)])
+    else
+        AC_MSG_RESULT([yes])
+    fi
+else
+    ENABLE_DEBUG=""
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_DEBUG)
+
+dnl ===================================================================
+dnl Select the linker to use (gold/lld/ld.bfd/mold).
+dnl This is done only after compiler checks (need to know if Clang is
+dnl used, for different defaults) and after checking if a debug build
+dnl is wanted (non-debug builds get the default linker if not explicitly
+dnl specified otherwise).
+dnl All checks for linker features/options should come after this.
+dnl ===================================================================
+check_use_ld()
+{
+    use_ld=-fuse-ld=${1%%:*}
+    use_ld_path=${1#*:}
+    if test "$use_ld_path" != "$1"; then
+        if test "$COM_IS_CLANG" = TRUE; then
+            if test "$CLANGVER" -ge 120000; then
+                use_ld="${use_ld} --ld-path=${use_ld_path}"
+            else
+                use_ld="-fuse-ld=${use_ld_path}"
+            fi
+        else
+            # I tried to use gcc's '-B<path>' and a directory + symlink setup in
+            # $BUILDDIR, but libtool always filtered-out that option, so gcc wouldn't
+            # pickup the alternative linker, when called by libtool for linking.
+            # For mold, one can use LD_PRELOAD=/usr/lib/mold/mold-wrapper.so instead.
+            AC_MSG_ERROR([A linker path is just supported with clang, because of libtool's -B filtering!])
+        fi
+    fi
+    use_ld_fail_if_error=$2
+    use_ld_ok=
+    AC_MSG_CHECKING([for $use_ld linker support])
+    use_ld_ldflags_save="$LDFLAGS"
+    LDFLAGS="$LDFLAGS $use_ld"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <stdio.h>
+        ],[
+printf ("hello world\n");
+        ])], USE_LD=$use_ld, [])
+    if test -n "$USE_LD"; then
+        AC_MSG_RESULT( yes )
+        use_ld_ok=yes
+    else
+        if test -n "$use_ld_fail_if_error"; then
+            AC_MSG_ERROR( no )
+        else
+            AC_MSG_RESULT( no )
+        fi
+    fi
+    if test -n "$use_ld_ok"; then
+        dnl keep the value of LDFLAGS
+        return 0
+    fi
+    LDFLAGS="$use_ld_ldflags_save"
+    return 1
+}
+USE_LD=
+if test "$enable_ld" != "no"; then
+    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
+        if test -n "$enable_ld"; then
+            check_use_ld "$enable_ld" fail_if_error
+        elif test -z "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+            dnl non-debug builds default to the default linker
+            true
+        elif test -n "$COM_IS_CLANG"; then
+            check_use_ld lld
+            if test $? -ne 0; then
+                check_use_ld gold
+                if test $? -ne 0; then
+                    check_use_ld mold
+                fi
+            fi
+        else
+            # For gcc first try gold, new versions also support lld/mold.
+            check_use_ld gold
+            if test $? -ne 0; then
+                check_use_ld lld
+                if test $? -ne 0; then
+                    check_use_ld mold
+                fi
+            fi
+        fi
+        ld_output=$(echo 'int main() { return 0; }' | $CC -Wl,-v -x c -o conftest.out - $CFLAGS $LDFLAGS 2>/dev/null)
+        rm conftest.out
+        ld_used=$(echo "$ld_output" | grep -E '(^GNU gold|^GNU ld|^LLD|^mold)')
+        if test -z "$ld_used"; then
+            ld_used="unknown"
+        fi
+        AC_MSG_CHECKING([for linker that is used])
+        AC_MSG_RESULT([$ld_used])
+        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+            if echo "$ld_used" | grep -q "^GNU ld"; then
+                AC_MSG_WARN([The default GNU linker is slow, consider using LLD, mold or the GNU gold linker.])
+                add_warning "The default GNU linker is slow, consider using LLD, mold or the GNU gold linker."
+            fi
+        fi
+    else
+        if test "$enable_ld" = "yes"; then
+            AC_MSG_ERROR([--enable-ld not supported])
+        fi
+    fi
+fi
+AC_SUBST(USE_LD)
+AC_SUBST(LD)
+
+HAVE_LD_BSYMBOLIC_FUNCTIONS=
+if test "$GCC" = "yes" -a "$_os" != Emscripten ; then
+    AC_MSG_CHECKING([for -Bsymbolic-functions linker support])
+    bsymbolic_functions_ldflags_save=$LDFLAGS
+    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <stdio.h>
+        ],[
+printf ("hello world\n");
+        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
+    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
+        AC_MSG_RESULT( found )
+    else
+        AC_MSG_RESULT( not found )
+    fi
+    LDFLAGS=$bsymbolic_functions_ldflags_save
+fi
+AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
+
+LD_GC_SECTIONS=
+if test "$GCC" = "yes"; then
+    for flag in "--gc-sections" "-dead_strip"; do
+        AC_MSG_CHECKING([for $flag linker support])
+        ldflags_save=$LDFLAGS
+        LDFLAGS="$LDFLAGS -Wl,$flag"
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <stdio.h>
+            ],[
+printf ("hello world\n");
+            ])],[
+            LD_GC_SECTIONS="-Wl,$flag"
+            AC_MSG_RESULT( found )
+            ], [
+            AC_MSG_RESULT( not found )
+            ])
+        LDFLAGS=$ldflags_save
+        if test -n "$LD_GC_SECTIONS"; then
+            break
+        fi
+    done
+fi
+AC_SUBST(LD_GC_SECTIONS)
+
+HAVE_EXTERNAL_DWARF=
+if test "$enable_split_debug" != no; then
+    use_split_debug=
+    if test -n "$ENABLE_LTO"; then
+        : # Inherently incompatible, since no debug info is created while compiling, GCC complains.
+    elif test "$enable_split_debug" = yes; then
+        use_split_debug=1
+    dnl Currently by default enabled only on Linux, feel free to set test_split_debug above also for other platforms.
+    elif test "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+        use_split_debug=1
+    fi
+    if test -n "$use_split_debug"; then
+        if test "$_os" = "Emscripten"; then
+            TEST_CC_FLAG=-gseparate-dwarf
+        else
+            TEST_CC_FLAG=-gsplit-dwarf
+        fi
+        AC_MSG_CHECKING([whether $CC_BASE supports $TEST_CC_FLAG])
+        save_CFLAGS=$CFLAGS
+        CFLAGS="$CFLAGS -Werror $TEST_CC_FLAG"
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_EXTERNAL_DWARF=TRUE ],[])
+        CFLAGS=$save_CFLAGS
+        if test "$HAVE_EXTERNAL_DWARF" = "TRUE"; then
+            AC_MSG_RESULT([yes])
+        else
+            if test "$enable_split_debug" = yes; then
+                AC_MSG_ERROR([no])
+            else
+                AC_MSG_RESULT([no])
+            fi
+        fi
+    fi
+    if test -z "$HAVE_EXTERNAL_DWARF" -a "$test_split_debug" = "yes" -a -n "$use_split_debug"; then
+        AC_MSG_WARN([Compiler is not capable of creating split debug info, linking will require more time and disk space.])
+        add_warning "Compiler is not capable of creating split debug info, linking will require more time and disk space."
+    fi
+fi
+AC_SUBST(HAVE_EXTERNAL_DWARF)
+
+HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=
+AC_MSG_CHECKING([whether $CC_BASE supports -Xclang -debug-info-kind=constructor])
+save_CFLAGS=$CFLAGS
+CFLAGS="$CFLAGS -Werror -Xclang -debug-info-kind=constructor"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=TRUE ],[])
+CFLAGS=$save_CFLAGS
+if test "$HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR" = "TRUE"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR)
+
+ENABLE_GDB_INDEX=
+if test "$enable_gdb_index" != "no"; then
+    dnl Currently by default enabled only on Linux, feel free to set test_gdb_index above also for other platforms.
+    if test "$enable_gdb_index" = yes -o \( "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
+        AC_MSG_CHECKING([whether $CC_BASE supports -ggnu-pubnames])
+        save_CFLAGS=$CFLAGS
+        CFLAGS="$CFLAGS -Werror -g -ggnu-pubnames"
+        have_ggnu_pubnames=
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[have_ggnu_pubnames=TRUE],[have_ggnu_pubnames=])
+        if test "$have_ggnu_pubnames" != "TRUE"; then
+            if test "$enable_gdb_index" = "yes"; then
+                AC_MSG_ERROR([no, --enable-gdb-index not supported])
+            else
+                AC_MSG_RESULT( no )
+            fi
+        else
+            AC_MSG_RESULT( yes )
+            AC_MSG_CHECKING([whether $CC_BASE supports -Wl,--gdb-index])
+            ldflags_save=$LDFLAGS
+            LDFLAGS="$LDFLAGS -Wl,--gdb-index"
+            AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <stdio.h>
+                ],[
+printf ("hello world\n");
+                ])], ENABLE_GDB_INDEX=TRUE, [])
+            if test "$ENABLE_GDB_INDEX" = "TRUE"; then
+                AC_MSG_RESULT( yes )
+            else
+                if test "$enable_gdb_index" = "yes"; then
+                    AC_MSG_ERROR( no )
+                else
+                    AC_MSG_RESULT( no )
+                fi
+            fi
+            LDFLAGS=$ldflags_save
+        fi
+        CFLAGS=$save_CFLAGS
+        fi
+    if test -z "$ENABLE_GDB_INDEX" -a "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+        AC_MSG_WARN([Linker is not capable of creating gdb index, debugger startup will be slow.])
+        add_warning "Linker is not capable of creating gdb index, debugger startup will be slow."
+    fi
+fi
+AC_SUBST(ENABLE_GDB_INDEX)
+
+if test -z "$enable_sal_log" && test "$ENABLE_DEBUG" = TRUE; then
+    enable_sal_log=yes
+fi
+if test "$enable_sal_log" = yes; then
+    ENABLE_SAL_LOG=TRUE
+fi
+AC_SUBST(ENABLE_SAL_LOG)
+
+dnl Check for enable symbols option
+dnl ===================================================================
+AC_MSG_CHECKING([whether to generate debug information])
+if test -z "$enable_symbols"; then
+    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+        enable_symbols=yes
+    else
+        enable_symbols=no
+    fi
+fi
+if test "$enable_symbols" = yes; then
+    ENABLE_SYMBOLS_FOR=all
+    AC_MSG_RESULT([yes])
+elif test "$enable_symbols" = no; then
+    ENABLE_SYMBOLS_FOR=
+    AC_MSG_RESULT([no])
+else
+    # Selective debuginfo.
+    ENABLE_SYMBOLS_FOR="$enable_symbols"
+    AC_MSG_RESULT([for "$enable_symbols"])
+fi
+AC_SUBST(ENABLE_SYMBOLS_FOR)
+
+if test -n "$with_android_ndk" -a \( -n "$ENABLE_SYMBOLS" -o -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_DEBUGINFO_FOR" = "all"; then
+    # Building on Android with full symbols: without enough memory the linker never finishes currently.
+    AC_MSG_CHECKING([whether enough memory is available for linking])
+    mem_size=$(grep -o 'MemTotal: *.\+ kB' /proc/meminfo | sed 's/MemTotal: *\(.\+\) kB/\1/')
+    # Check for 15GB, as Linux reports a bit less than the physical memory size.
+    if test -n "$mem_size" -a $mem_size -lt 15728640; then
+        AC_MSG_ERROR([building with full symbols and less than 16GB of memory is not supported])
+    else
+        AC_MSG_RESULT([yes])
+    fi
+fi
+
+ENABLE_OPTIMIZED=
+ENABLE_OPTIMIZED_DEBUG=
+AC_MSG_CHECKING([whether to compile with optimization flags])
+if test -z "$enable_optimized"; then
+    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+        enable_optimized=no
+    else
+        enable_optimized=yes
+    fi
+fi
+if test "$enable_optimized" = yes; then
+    ENABLE_OPTIMIZED=TRUE
+    AC_MSG_RESULT([yes])
+elif test "$enable_optimized" = debug; then
+    ENABLE_OPTIMIZED_DEBUG=TRUE
+    AC_MSG_RESULT([yes (debug)])
+    HAVE_GCC_OG=
+    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
+        AC_MSG_CHECKING([whether $CC_BASE supports -Og])
+        save_CFLAGS=$CFLAGS
+        CFLAGS="$CFLAGS -Werror -Og"
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_OG=TRUE ],[])
+        CFLAGS=$save_CFLAGS
+        if test "$HAVE_GCC_OG" = "TRUE"; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_RESULT([no])
+        fi
+    fi
+    if test -z "$HAVE_GCC_OG" -a "$_os" != "Emscripten"; then
+        AC_MSG_ERROR([The compiler does not support optimizations suitable for debugging.])
+    fi
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_OPTIMIZED)
+AC_SUBST(ENABLE_OPTIMIZED_DEBUG)
+
+#
+# determine CPUNAME, OS, ...
+#
+case "$host_os" in
+
+cygwin*|wsl*)
+    # Already handled
+    ;;
+
+darwin*)
+    COM=GCC
+    OS=MACOSX
+    RTL_OS=MacOSX
+    P_SEP=:
+
+    case "$host_cpu" in
+    aarch64|arm64)
+        if test "$enable_ios_simulator" = "yes"; then
+            OS=iOS
+        else
+            CPUNAME=AARCH64
+            RTL_ARCH=AARCH64
+            PLATFORMID=macosx_aarch64
+        fi
+        ;;
+    x86_64)
+        if test "$enable_ios_simulator" = "yes"; then
+            OS=iOS
+        fi
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=macosx_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+ios*)
+    COM=GCC
+    OS=iOS
+    RTL_OS=iOS
+    P_SEP=:
+
+    case "$host_cpu" in
+    aarch64|arm64)
+        if test "$enable_ios_simulator" = "yes"; then
+            AC_MSG_ERROR([iOS simulator is only available in macOS not iOS])
+        fi
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    CPUNAME=AARCH64
+    RTL_ARCH=AARCH64
+    PLATFORMID=ios_arm64
+    ;;
+
+dragonfly*)
+    COM=GCC
+    OS=DRAGONFLY
+    RTL_OS=DragonFly
+    P_SEP=:
+
+    case "$host_cpu" in
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=dragonfly_x86
+        ;;
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=dragonfly_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+freebsd*)
+    COM=GCC
+    RTL_OS=FreeBSD
+    OS=FREEBSD
+    P_SEP=:
+
+    case "$host_cpu" in
+    aarch64)
+        CPUNAME=AARCH64
+        PLATFORMID=freebsd_aarch64
+        RTL_ARCH=AARCH64
+        ;;
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=freebsd_x86
+        ;;
+    x86_64|amd64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=freebsd_x86_64
+        ;;
+    powerpc64)
+        CPUNAME=POWERPC64
+        RTL_ARCH=PowerPC_64
+        PLATFORMID=freebsd_powerpc64
+        ;;
+    powerpc|powerpcspe)
+        CPUNAME=POWERPC
+        RTL_ARCH=PowerPC
+        PLATFORMID=freebsd_powerpc
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+haiku*)
+    COM=GCC
+    GUIBASE=haiku
+    RTL_OS=Haiku
+    OS=HAIKU
+    P_SEP=:
+
+    case "$host_cpu" in
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=haiku_x86
+        ;;
+    x86_64|amd64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=haiku_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+kfreebsd*)
+    COM=GCC
+    OS=LINUX
+    RTL_OS=kFreeBSD
+    P_SEP=:
+
+    case "$host_cpu" in
+
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=kfreebsd_x86
+        ;;
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=kfreebsd_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+linux-gnu*|linux-musl*)
+    COM=GCC
+    OS=LINUX
+    RTL_OS=Linux
+    P_SEP=:
+
+    case "$host_cpu" in
+
+    aarch64)
+        CPUNAME=AARCH64
+        PLATFORMID=linux_aarch64
+        RTL_ARCH=AARCH64
+        EPM_FLAGS="-a arm64"
+        ;;
+    alpha)
+        CPUNAME=AXP
+        RTL_ARCH=ALPHA
+        PLATFORMID=linux_alpha
+        ;;
+    arm*)
+        CPUNAME=ARM
+        EPM_FLAGS="-a arm"
+        RTL_ARCH=ARM_EABI
+        PLATFORMID=linux_arm_eabi
+        case "$host_cpu" in
+        arm*-linux)
+            RTL_ARCH=ARM_OABI
+            PLATFORMID=linux_arm_oabi
+            ;;
+        esac
+        ;;
+    hppa)
+        CPUNAME=HPPA
+        RTL_ARCH=HPPA
+        EPM_FLAGS="-a hppa"
+        PLATFORMID=linux_hppa
+        ;;
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=linux_x86
+        ;;
+    ia64)
+        CPUNAME=IA64
+        RTL_ARCH=IA64
+        PLATFORMID=linux_ia64
+        ;;
+    mips)
+        CPUNAME=MIPS
+        RTL_ARCH=MIPS_EB
+        EPM_FLAGS="-a mips"
+        PLATFORMID=linux_mips_eb
+        ;;
+    mips64)
+        CPUNAME=MIPS64
+        RTL_ARCH=MIPS64_EB
+        EPM_FLAGS="-a mips64"
+        PLATFORMID=linux_mips64_eb
+        ;;
+    mips64el)
+        CPUNAME=MIPS64
+        RTL_ARCH=MIPS64_EL
+        EPM_FLAGS="-a mips64el"
+        PLATFORMID=linux_mips64_el
+        ;;
+    mipsel)
+        CPUNAME=MIPS
+        RTL_ARCH=MIPS_EL
+        EPM_FLAGS="-a mipsel"
+        PLATFORMID=linux_mips_el
+        ;;
+    riscv64)
+        CPUNAME=RISCV64
+        RTL_ARCH=RISCV64
+        EPM_FLAGS="-a riscv64"
+        PLATFORMID=linux_riscv64
+        ;;
+    m68k)
+        CPUNAME=M68K
+        RTL_ARCH=M68K
+        PLATFORMID=linux_m68k
+        ;;
+    powerpc)
+        CPUNAME=POWERPC
+        RTL_ARCH=PowerPC
+        PLATFORMID=linux_powerpc
+        ;;
+    powerpc64)
+        CPUNAME=POWERPC64
+        RTL_ARCH=PowerPC_64
+        PLATFORMID=linux_powerpc64
+        ;;
+    powerpc64le)
+        CPUNAME=POWERPC64
+        RTL_ARCH=PowerPC_64_LE
+        PLATFORMID=linux_powerpc64_le
+        ;;
+    sparc)
+        CPUNAME=SPARC
+        RTL_ARCH=SPARC
+        PLATFORMID=linux_sparc
+        ;;
+    sparc64)
+        CPUNAME=SPARC64
+        RTL_ARCH=SPARC64
+        PLATFORMID=linux_sparc64
+        ;;
+    s390x)
+        CPUNAME=S390X
+        RTL_ARCH=S390x
+        PLATFORMID=linux_s390x
+        ;;
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=linux_x86_64
+        ;;
+    loongarch64)
+        CPUNAME=LOONGARCH64
+        RTL_ARCH=LOONGARCH64
+        PLATFORMID=linux_loongarch64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+linux-android*)
+    COM=GCC
+    OS=ANDROID
+    RTL_OS=Android
+    P_SEP=:
+
+    case "$host_cpu" in
+
+    arm|armel)
+        CPUNAME=ARM
+        RTL_ARCH=ARM_EABI
+        PLATFORMID=android_arm_eabi
+        ;;
+    aarch64)
+        CPUNAME=AARCH64
+        RTL_ARCH=AARCH64
+        PLATFORMID=android_aarch64
+        ;;
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=android_x86
+        ;;
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=android_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+*netbsd*)
+    COM=GCC
+    OS=NETBSD
+    RTL_OS=NetBSD
+    P_SEP=:
+
+    case "$host_cpu" in
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=netbsd_x86
+        ;;
+    powerpc)
+        CPUNAME=POWERPC
+        RTL_ARCH=PowerPC
+        PLATFORMID=netbsd_powerpc
+        ;;
+    sparc)
+        CPUNAME=SPARC
+        RTL_ARCH=SPARC
+        PLATFORMID=netbsd_sparc
+        ;;
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=netbsd_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    ;;
+
+openbsd*)
+    COM=GCC
+    OS=OPENBSD
+    RTL_OS=OpenBSD
+    P_SEP=:
+
+    case "$host_cpu" in
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=openbsd_x86
+        ;;
+    x86_64)
+        CPUNAME=X86_64
+        RTL_ARCH=X86_64
+        PLATFORMID=openbsd_x86_64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    SOLARINC="$SOLARINC -I/usr/local/include"
+    ;;
+
+solaris*)
+    COM=GCC
+    OS=SOLARIS
+    RTL_OS=Solaris
+    P_SEP=:
+
+    case "$host_cpu" in
+    i*86)
+        CPUNAME=INTEL
+        RTL_ARCH=x86
+        PLATFORMID=solaris_x86
+        ;;
+    sparc)
+        CPUNAME=SPARC
+        RTL_ARCH=SPARC
+        PLATFORMID=solaris_sparc
+        ;;
+    sparc64)
+        CPUNAME=SPARC64
+        RTL_ARCH=SPARC64
+        PLATFORMID=solaris_sparc64
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    SOLARINC="$SOLARINC -I/usr/local/include"
+    ;;
+
+emscripten*)
+    COM=GCC
+    OS=EMSCRIPTEN
+    RTL_OS=Emscripten
+    P_SEP=:
+
+    case "$host_cpu" in
+    wasm32|wasm64)
+        ;;
+    *)
+        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
+        ;;
+    esac
+    CPUNAME=INTEL
+    RTL_ARCH=x86
+    PLATFORMID=linux_x86
+    ;;
+
+*)
+    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
+    ;;
+esac
+
+DISABLE_GUI=""
+if test "$enable_gui" = "no"; then
+    if test "$using_x11" != yes; then
+        AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice with --disable-gui.])
+    fi
+    USING_X11=
+    DISABLE_GUI=TRUE
+    test_epoxy=no
+else
+    AC_DEFINE(HAVE_FEATURE_UI)
+fi
+AC_SUBST(DISABLE_GUI)
+
+if test "$with_x" = "no"; then
+    USING_X11=
+fi
+
+if test -z "$USING_X11" -a "$enable_qt5" = "yes" -a "$enable_gen" = "yes"; then
+    AC_MSG_ERROR([Can't select gen VCL plugin, if --without-x is used!])
+fi
+
+if test "$using_x11" = yes; then
+    if test "$USING_X11" = TRUE; then
+        AC_DEFINE(USING_X11)
+    else
+        disable_x11_tests
+        if test "$DISABLE_DYNLOADING" = TRUE; then
+            test_qt5=yes
+        fi
+    fi
+else
+    if test "$USING_X11" = TRUE; then
+        AC_MSG_ERROR([Platform doesn't support X11 (\$using_x11), but \$USING_X11 is set!])
+    fi
+fi
+
+WORKDIR="${BUILDDIR}/workdir"
+INSTDIR="${BUILDDIR}/instdir"
+INSTROOTBASE=${INSTDIR}${INSTROOTBASESUFFIX}
+INSTROOT=${INSTROOTBASE}${INSTROOTCONTENTSUFFIX}
+AC_SUBST(COM)
+AC_SUBST(CPUNAME)
+AC_SUBST(RTL_OS)
+AC_SUBST(RTL_ARCH)
+AC_SUBST(EPM_FLAGS)
+AC_SUBST(USING_X11)
+AC_SUBST([INSTDIR])
+AC_SUBST([INSTROOT])
+AC_SUBST([INSTROOTBASE])
+AC_SUBST(OS)
+AC_SUBST(P_SEP)
+AC_SUBST(WORKDIR)
+AC_SUBST(PLATFORMID)
+AC_SUBST(WINDOWS_X64)
+AC_DEFINE_UNQUOTED(SDKDIR, "$INSTDIR/$SDKDIRNAME")
+AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR")
+
+if test "$OS" = WNT -a "$COM" = MSC; then
+    case "$CPUNAME" in
+    INTEL) CPPU_ENV=msci ;;
+    X86_64) CPPU_ENV=mscx ;;
+    AARCH64) CPPU_ENV=msca ;;
+    *)
+        AC_MSG_ERROR([Unknown \$CPUNAME '$CPUNAME' for $OS / $COM"])
+        ;;
+    esac
+else
+    CPPU_ENV=gcc3
+fi
+AC_SUBST(CPPU_ENV)
+
+dnl ===================================================================
+dnl Test which package format to use
+dnl ===================================================================
+AC_MSG_CHECKING([which package format to use])
+if test -n "$with_package_format" -a "$with_package_format" != no; then
+    for i in $with_package_format; do
+        case "$i" in
+        bsd | deb | pkg | rpm | archive | dmg | installed | msi)
+            ;;
+        *)
+            AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
+bsd - FreeBSD, NetBSD, or OpenBSD software distribution
+deb - Debian software distribution
+pkg - Solaris software distribution
+rpm - RedHat software distribution
+
+LibreOffice additionally supports:
+archive - .tar.gz or .zip
+dmg - macOS .dmg
+installed - installation tree
+msi - Windows .msi
+        ])
+            ;;
+        esac
+    done
+    # fakeroot is needed to ensure correct file ownerships/permissions
+    # inside deb packages and tar archives created on Linux and Solaris.
+    if test "$OS" = "LINUX" || test "$OS" = "SOLARIS"; then
+        AC_PATH_PROG(FAKEROOT, fakeroot, no)
+        if test "$FAKEROOT" = "no"; then
+            AC_MSG_ERROR(
+                [--with-package-format='$with_package_format' requires fakeroot. Install fakeroot.])
+        fi
+    fi
+    PKGFORMAT="$with_package_format"
+    AC_MSG_RESULT([$PKGFORMAT])
+else
+    PKGFORMAT=
+    AC_MSG_RESULT([none])
+fi
+AC_SUBST(PKGFORMAT)
+
+dnl ===================================================================
+dnl handle help related options
+dnl
+dnl If you change help related options, please update README.help
+dnl ===================================================================
+
+ENABLE_HTMLHELP=
+HELP_OMINDEX_PAGE=
+HELP_ONLINE=
+WITH_HELPPACKS=
+
+AC_MSG_CHECKING([which help to build])
+if test -n "$with_help" -a "$with_help" != "no"; then
+    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
+    BUILD_TYPE="$BUILD_TYPE HELP"
+    case "$with_help" in
+    "html")
+        ENABLE_HTMLHELP=TRUE
+        WITH_HELPPACKS=TRUE
+        SCPDEFS="$SCPDEFS -DWITH_HELPPACKS"
+        AC_MSG_RESULT([HTML (local)])
+        ;;
+    "online")
+        ENABLE_HTMLHELP=TRUE
+        HELP_ONLINE=TRUE
+        AC_MSG_RESULT([HTML (online)])
+        ;;
+    yes)
+        WITH_HELPPACKS=TRUE
+        SCPDEFS="$SCPDEFS -DWITH_HELPPACKS"
+        AC_MSG_RESULT([XML (local)])
+        ;;
+    *)
+        AC_MSG_ERROR([Unknown --with-help=$with_help])
+        ;;
+    esac
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_MSG_CHECKING([if we need to build the help index tooling])
+if test \( "$with_help" = yes -o "$enable_extension_integration" != no \) -a -z "$DISABLE_DYNLOADING"; then
+    BUILD_TYPE="$BUILD_TYPE HELPTOOLS"
+    test_clucene=yes
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_MSG_CHECKING([whether to enable xapian-omega support for online help])
+if test -n "$with_omindex" -a "$with_omindex" != "no"; then
+    if test "$HELP_ONLINE" != TRUE; then
+        AC_MSG_ERROR([Can't build xapian-omega index without --help=online])
+    fi
+    case "$with_omindex" in
+    "server")
+        HELP_OMINDEX_PAGE=TRUE
+        AC_MSG_RESULT([SERVER])
+        ;;
+    "noxap")
+        AC_MSG_RESULT([NOXAP])
+        ;;
+    *)
+        AC_MSG_ERROR([Unknown --with-omindex=$with_omindex])
+        ;;
+    esac
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_MSG_CHECKING([whether to include the XML-help support])
+if test "$enable_xmlhelp" = yes; then
+    BUILD_TYPE="$BUILD_TYPE XMLHELP"
+    test_clucene=yes
+    AC_DEFINE(HAVE_FEATURE_XMLHELP)
+    AC_MSG_RESULT([yes])
+else
+    if test "$with_help" = yes; then
+        add_warning "Building the XML help, but LO with disabled xmlhelp support. Generated help can't be accessed from this LO build!"
+    fi
+    AC_MSG_RESULT([no])
+fi
+
+dnl Test whether to integrate helppacks into the product's installer
+AC_MSG_CHECKING([for helppack integration])
+if test -z "$WITH_HELPPACKS" -o "$with_helppack_integration" = no; then
+    AC_MSG_RESULT([no integration])
+else
+    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
+    AC_MSG_RESULT([integration])
+fi
+
+AC_SUBST([ENABLE_HTMLHELP])
+AC_SUBST([HELP_OMINDEX_PAGE])
+AC_SUBST([HELP_ONLINE])
+# WITH_HELPPACKS is used only in configure
+
+dnl ===================================================================
+dnl Set up a different compiler to produce tools to run on the build
+dnl machine when doing cross-compilation
+dnl ===================================================================
+
+m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
+m4_pattern_allow([PKG_CONFIG_LIBDIR])
+if test "$cross_compiling" = "yes"; then
+    AC_MSG_CHECKING([for BUILD platform configuration])
+    echo
+    rm -rf CONF-FOR-BUILD config_build.mk
+    mkdir CONF-FOR-BUILD
+    # Here must be listed all files needed when running the configure script. In particular, also
+    # those expanded by the AC_CONFIG_FILES() call near the end of this configure.ac. For clarity,
+    # keep them in the same order as there.
+    (cd $SRC_ROOT && tar cf - \
+        config.guess \
+        bin/get_config_variables \
+        solenv/bin/getcompver.awk \
+        solenv/inc/langlist.mk \
+        download.lst \
+        config_host.mk.in \
+        config_host_lang.mk.in \
+        Makefile.in \
+        bin/bffvalidator.sh.in \
+        bin/odfvalidator.sh.in \
+        bin/officeotron.sh.in \
+        instsetoo_native/util/openoffice.lst.in \
+        config_host/*.in \
+        sysui/desktop/macosx/Info.plist.in \
+        sysui/desktop/macosx/hardened_runtime.xcent.in \
+        sysui/desktop/macosx/lo.xcent.in \
+        .vscode/vs-code-template.code-workspace.in \
+        solenv/lockfile/autoconf.h.in \
+        ) \
+    | (cd CONF-FOR-BUILD && tar xf -)
+    cp configure CONF-FOR-BUILD
+    test -d config_build && cp -p config_build/*.h CONF-FOR-BUILD/config_host 2>/dev/null
+    (
+    unset COM USING_X11 OS CPUNAME
+    unset CC CXX SYSBASE CFLAGS
+    unset AR LD NM OBJDUMP PKG_CONFIG RANLIB READELF STRIP
+    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
+    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC
+    unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
+    if test -n "$CC_FOR_BUILD"; then
+        export CC="$CC_FOR_BUILD"
+        CC_BASE=`first_arg_basename "$CC"`
+    fi
+    if test -n "$CXX_FOR_BUILD"; then
+        export CXX="$CXX_FOR_BUILD"
+        CXX_BASE=`first_arg_basename "$CXX"`
+    fi
+    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
+    cd CONF-FOR-BUILD
+
+    # Handle host configuration, which affects the cross-toolset too
+    sub_conf_opts=""
+    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
+    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
+    test "$with_junit" = "no" && sub_conf_opts="$sub_conf_opts --without-junit"
+    # While we don't need scripting support, we don't have a PYTHON_FOR_BUILD Java equivalent, so must enable scripting for Java
+    if test -n "$ENABLE_JAVA"; then
+        case "$_os" in
+        Android)
+            # Hack for Android - the build doesn't need a host JDK, so just forward to build for convenience
+            test -n "$with_jdk_home" && sub_conf_opts="$sub_conf_opts --with-jdk-home=$with_jdk_home"
+            ;;
+        *)
+            if test -z "$with_jdk_home"; then
+                AC_MSG_ERROR([Missing host JDK! This can't be detected for the build OS, so you have to specify it with --with-jdk-home.])
+            fi
+            ;;
+        esac
+    else
+        sub_conf_opts="$sub_conf_opts --without-java"
+    fi
+    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
+    test "$with_galleries" = "no" -o -z "$WITH_GALLERY_BUILD" && sub_conf_opts="$sub_conf_opts --with-galleries=no --disable-database-connectivity"
+    test "$with_templates" = "no" -o -z "$WITH_TEMPLATES" && sub_conf_opts="$sub_conf_opts --with-templates=no"
+    test -n "$with_help" -a "$with_help" != "no" && sub_conf_opts="$sub_conf_opts --with-help=$with_help"
+    test "$enable_extensions" = yes || sub_conf_opts="$sub_conf_opts --disable-extensions"
+    test "${enable_ld+set}" = set -a "$build_cpu" = "$host_cpu" && sub_conf_opts="$sub_conf_opts --enable-ld=${enable_ld}"
+    test "${enable_pch+set}" = set && sub_conf_opts="$sub_conf_opts --enable-pch=${enable_pch}"
+    test "$enable_wasm_strip" = "yes" && sub_conf_opts="$sub_conf_opts --enable-wasm-strip"
+    test "${with_system_lockfile+set}" = set && sub_conf_opts="$sub_conf_opts --with-system-lockfile=${with_system_lockfile}"
+    test "${enable_fuzzers}" = yes && sub_conf_opts="$sub_conf_opts --without-system-libxml"
+    if test "$_os" = "Emscripten"; then
+        sub_conf_opts="$sub_conf_opts --without-system-libxml --without-system-fontconfig --without-system-freetype --without-system-zlib"
+        if test "${with_main_module+set}" = set; then
+            sub_conf_opts="$sub_conf_opts --with-main-module=${with_main_module}"
+        else
+            sub_conf_opts="$sub_conf_opts --with-main-module=writer"
+        fi
+    fi
+    # windows uses full-internal python and that in turn relies on openssl, so also enable openssl
+    # when cross-compiling for aarch64, overriding the defaults below
+    test "${PLATFORMID}" = "windows_aarch64" && sub_conf_opts="$sub_conf_opts --enable-openssl --with-tls=openssl"
+
+    # Don't bother having configure look for stuff not needed for the build platform anyway
+    # WARNING: any option with an argument containing spaces must be handled separately (see --with-theme)
+    sub_conf_defaults=" \
+        --build="$build_alias" \
+        --disable-cairo-canvas \
+        --disable-cups \
+        --disable-customtarget-components \
+        --disable-firebird-sdbc \
+        --disable-gpgmepp \
+        --disable-gstreamer-1-0 \
+        --disable-gtk3 \
+        --disable-gtk4 \
+        --disable-libcmis \
+        --disable-mariadb-sdbc \
+        --disable-nss \
+        --disable-online-update \
+        --disable-opencl \
+        --disable-openssl \
+        --disable-pdfimport \
+        --disable-postgresql-sdbc \
+        --disable-skia \
+        --disable-xmlhelp \
+        --enable-dynamic-loading \
+        --enable-icecream="$enable_icecream" \
+        --without-doxygen \
+        --without-tls \
+        --without-webdav \
+        --without-x \
+"
+    # single quotes added for better readability in case of spaces
+    echo "    Running CONF-FOR-BUILD/configure" \
+        $sub_conf_defaults \
+        --with-parallelism="'$with_parallelism'" \
+        --with-theme="'$with_theme'" \
+        --with-vendor="'$with_vendor'" \
+        $sub_conf_opts \
+        $with_build_platform_configure_options \
+        --srcdir=$srcdir
+
+    ./configure \
+        $sub_conf_defaults \
+        --with-parallelism="$with_parallelism" \
+        --with-theme="$with_theme" \
+        "--with-vendor=$with_vendor" \
+        $sub_conf_opts \
+        $with_build_platform_configure_options \
+        --srcdir=$srcdir \
+        2>&1 | sed -e 's/^/    /'
+    if test [${PIPESTATUS[0]}] -ne 0; then
+        AC_MSG_ERROR([Running the configure script for BUILD side failed, see CONF-FOR-BUILD/config.log])
+    fi
+
+    # filter permitted build targets
+    PERMITTED_BUILD_TARGETS="
+        ARGON2
+        AVMEDIA
+        BOOST
+        BZIP2
+        CAIRO
+        CLUCENE
+        CURL
+        DBCONNECTIVITY
+        DESKTOP
+        DRAGONBOX
+        DYNLOADING
+        EPOXY
+        EXPAT
+        FROZEN
+        GLM
+        GRAPHITE
+        HARFBUZZ
+        HELPTOOLS
+        ICU
+        LCMS2
+        LIBJPEG_TURBO
+        LIBLANGTAG
+        LibO
+        LIBFFI
+        LIBPN
+        LIBTIFF
+        LIBWEBP
+        LIBXML2
+        LIBXSLT
+        MDDS
+        NATIVE
+        OPENSSL
+        ORCUS
+        PYTHON
+        SCRIPTING
+        ZLIB
+        ZXCVBN
+"
+    # converts BUILD_TYPE and PERMITTED_BUILD_TARGETS into non-whitespace,
+    # newlined lists, to use grep as a filter
+    PERMITTED_BUILD_TARGETS=$(echo "$PERMITTED_BUILD_TARGETS" | sed -e '/^ *$/d' -e 's/ *//')
+    BUILD_TARGETS="$(sed -n -e '/^export BUILD_TYPE=/ s/.*=//p' config_host.mk | tr ' ' '\n')"
+    BUILD_TARGETS="$(echo "$BUILD_TARGETS" | grep -F "$PERMITTED_BUILD_TARGETS" | tr '\n' ' ')"
+    sed -i -e "s/ BUILD_TYPE=.*$/ BUILD_TYPE=$BUILD_TARGETS/" config_host.mk
+
+    cp config_host.mk ../config_build.mk
+    cp config_host_lang.mk ../config_build_lang.mk
+    mv config.log ../config.Build.log
+    mkdir -p ../config_build
+    mv config_host/*.h ../config_build
+    test -f "$WARNINGS_FILE" && mv "$WARNINGS_FILE" "../$WARNINGS_FILE_FOR_BUILD"
+
+    # all these will get a _FOR_BUILD postfix
+    DIRECT_FOR_BUILD_SETTINGS="
+        CC
+        CPPU_ENV
+        CXX
+        ILIB
+        JAVA_HOME
+        JAVAIFLAGS
+        JDK
+        JDK_SECURITYMANAGER_DISALLOWED
+        LIBO_BIN_FOLDER
+        LIBO_LIB_FOLDER
+        LIBO_URE_LIB_FOLDER
+        LIBO_URE_MISC_FOLDER
+        OS
+        SDKDIRNAME
+        SYSTEM_LIBXML
+        SYSTEM_LIBXSLT
+"
+    # these overwrite host config with build config
+    OVERWRITING_SETTINGS="
+        ANT
+        ANT_HOME
+        ANT_LIB
+        JAVA_SOURCE_VER
+        JAVA_TARGET_VER
+        JAVACFLAGS
+        JAVACOMPILER
+        JAVADOC
+        JAVADOCISGJDOC
+        LOCKFILE
+        SYSTEM_GENBRK
+        SYSTEM_GENCCODE
+        SYSTEM_GENCMN
+"
+    # these need some special handling
+    EXTRA_HANDLED_SETTINGS="
+        INSTDIR
+        INSTROOT
+        PATH
+        WORKDIR
+"
+    OLD_PATH=$PATH
+    . ./bin/get_config_variables $DIRECT_FOR_BUILD_SETTINGS $OVERWRITING_SETTINGS $EXTRA_HANDLED_SETTINGS
+    BUILD_PATH=$PATH
+    PATH=$OLD_PATH
+
+    line=`echo "LO_PATH_FOR_BUILD='${BUILD_PATH}'" | sed -e 's,/CONF-FOR-BUILD,,g'`
+    echo "$line" >>build-config
+
+    for V in $DIRECT_FOR_BUILD_SETTINGS; do
+        VV='$'$V
+        VV=`eval "echo $VV"`
+        if test -n "$VV"; then
+            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
+            echo "$line" >>build-config
+        fi
+    done
+
+    for V in $OVERWRITING_SETTINGS; do
+        VV='$'$V
+        VV=`eval "echo $VV"`
+        if test -n "$VV"; then
+            line=${V}='${'${V}:-$VV'}'
+            echo "$line" >>build-config
+        fi
+    done
+
+    for V in INSTDIR INSTROOT WORKDIR; do
+        VV='$'$V
+        VV=`eval "echo $VV"`
+        VV=`echo $VV | sed -e "s,/CONF-FOR-BUILD/\([[a-z]]*\),/\1_for_build,g"`
+        if test -n "$VV"; then
+            line="${V}_FOR_BUILD='$VV'"
+            echo "$line" >>build-config
+        fi
+    done
+
+    )
+    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([setup/configure for BUILD side failed, see CONF-FOR-BUILD/config.log])
+    test -f config_build.mk || AC_MSG_ERROR([A file called config_build.mk was supposed to have been copied here, but it isn't found])
+    perl -pi -e 's,/(workdir|instdir)(/|$),/\1_for_build\2,g;' \
+             -e 's,/CONF-FOR-BUILD,,g;' config_build.mk
+
+    eval `cat CONF-FOR-BUILD/build-config`
+
+    AC_MSG_RESULT([checking for BUILD platform configuration... done])
+
+    rm -rf CONF-FOR-BUILD
+else
+    OS_FOR_BUILD="$OS"
+    CC_FOR_BUILD="$CC"
+    CPPU_ENV_FOR_BUILD="$CPPU_ENV"
+    CXX_FOR_BUILD="$CXX"
+    INSTDIR_FOR_BUILD="$INSTDIR"
+    INSTROOT_FOR_BUILD="$INSTROOT"
+    LIBO_BIN_FOLDER_FOR_BUILD="$LIBO_BIN_FOLDER"
+    LIBO_LIB_FOLDER_FOR_BUILD="$LIBO_LIB_FOLDER"
+    LIBO_URE_LIB_FOLDER_FOR_BUILD="$LIBO_URE_LIB_FOLDER"
+    LIBO_URE_MISC_FOLDER_FOR_BUILD="$LIBO_URE_MISC_FOLDER"
+    SDKDIRNAME_FOR_BUILD="$SDKDIRNAME"
+    WORKDIR_FOR_BUILD="$WORKDIR"
+fi
+AC_SUBST(OS_FOR_BUILD)
+AC_SUBST(INSTDIR_FOR_BUILD)
+AC_SUBST(INSTROOT_FOR_BUILD)
+AC_SUBST(LIBO_BIN_FOLDER_FOR_BUILD)
+AC_SUBST(LIBO_LIB_FOLDER_FOR_BUILD)
+AC_SUBST(LIBO_URE_LIB_FOLDER_FOR_BUILD)
+AC_SUBST(LIBO_URE_MISC_FOLDER_FOR_BUILD)
+AC_SUBST(SDKDIRNAME_FOR_BUILD)
+AC_SUBST(WORKDIR_FOR_BUILD)
+AC_SUBST(CC_FOR_BUILD)
+AC_SUBST(CXX_FOR_BUILD)
+AC_SUBST(CPPU_ENV_FOR_BUILD)
+
+dnl ===================================================================
+dnl Check for lockfile deps
+dnl ===================================================================
+if test -z "$CROSS_COMPILING"; then
+    test -n "$LOCKFILE" -a "${with_system_lockfile+set}" != set && with_system_lockfile="$LOCKFILE"
+    test "${with_system_lockfile+set}" = set || with_system_lockfile=no
+    AC_MSG_CHECKING([which lockfile binary to use])
+    case "$with_system_lockfile" in
+    yes)
+        AC_MSG_RESULT([external])
+        AC_PATH_PROGS([LOCKFILE],[dotlockfile lockfile])
+        ;;
+    no)
+        AC_MSG_RESULT([internal])
+        ;;
+    *)
+        if test -x "$with_system_lockfile"; then
+            LOCKFILE="$with_system_lockfile"
+        else
+            AC_MSG_ERROR(['$with_system_lockfile' is not executable.])
+        fi
+        AC_MSG_RESULT([$with_system_lockfile])
+        ;;
+    esac
+fi
+
+if test -n "$LOCKFILE" -a "$DISABLE_DYNLOADING" = TRUE; then
+    add_warning "The default system lockfile has increasing poll intervals up to 60s, so linking executables may be delayed."
+fi
+
+AC_CHECK_HEADERS([getopt.h paths.h sys/param.h])
+AC_CHECK_FUNCS([utime utimes])
+AC_SUBST(LOCKFILE)
+
+dnl ===================================================================
+dnl Check for syslog header
+dnl ===================================================================
+AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
+
+dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
+dnl ===================================================================
+AC_MSG_CHECKING([whether to turn warnings to errors])
+if test -n "$enable_werror" -a "$enable_werror" != "no"; then
+    ENABLE_WERROR="TRUE"
+    PYTHONWARNINGS="error"
+    AC_MSG_RESULT([yes])
+else
+    if test -n "$LODE_HOME" -a -z "$enable_werror"; then
+        ENABLE_WERROR="TRUE"
+        PYTHONWARNINGS="error"
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST(ENABLE_WERROR)
+AC_SUBST(PYTHONWARNINGS)
+
+dnl Check for --enable-assert-always-abort, set ASSERT_ALWAYS_ABORT
+dnl ===================================================================
+AC_MSG_CHECKING([whether to have assert() failures abort even without --enable-debug])
+if test -z "$enable_assert_always_abort"; then
+   if test "$ENABLE_DEBUG" = TRUE; then
+       enable_assert_always_abort=yes
+   else
+       enable_assert_always_abort=no
+   fi
+fi
+if test "$enable_assert_always_abort" = "yes"; then
+    ASSERT_ALWAYS_ABORT="TRUE"
+    AC_MSG_RESULT([yes])
+else
+    ASSERT_ALWAYS_ABORT="FALSE"
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ASSERT_ALWAYS_ABORT)
+
+# Determine whether to use ooenv for the instdir installation
+# ===================================================================
+if test $_os != "WINNT" -a $_os != "Darwin"; then
+    AC_MSG_CHECKING([whether to use ooenv for the instdir installation])
+    if test -z "$enable_ooenv"; then
+        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
+            enable_ooenv=yes
+        else
+            enable_ooenv=no
+        fi
+    fi
+    if test "$enable_ooenv" = "no"; then
+        AC_MSG_RESULT([no])
+    else
+        ENABLE_OOENV="TRUE"
+        AC_MSG_RESULT([yes])
+    fi
+fi
+AC_SUBST(ENABLE_OOENV)
+
+if test "$test_kf5" = "yes" -a "$enable_kf5" = "yes"; then
+    if test "$enable_qt5" = "no"; then
+        AC_MSG_ERROR([KF5 support depends on QT5, so it conflicts with --disable-qt5])
+    else
+        enable_qt5=yes
+    fi
+fi
+
+if test "$test_kf6" = "yes" -a "$enable_kf6" = "yes"; then
+    if test "$enable_qt6" = "no"; then
+        AC_MSG_ERROR([KF6 support depends on QT6, so it conflicts with --disable-qt6])
+    else
+        enable_qt6=yes
+    fi
+fi
+
+
+AC_MSG_CHECKING([whether to build the pagein binaries for oosplash])
+if test "${enable_pagein}" != no -a -z "$DISABLE_DYNLOADING"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_PAGEIN=TRUE
+    AC_DEFINE(HAVE_FEATURE_PAGEIN)
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_PAGEIN)
+
+dnl ===================================================================
+dnl check for cups support
+dnl ===================================================================
+
+AC_MSG_CHECKING([whether to enable CUPS support])
+if test "$test_cups" = yes -a "$enable_cups" != no; then
+    ENABLE_CUPS=TRUE
+    AC_MSG_RESULT([yes])
+
+    AC_MSG_CHECKING([whether cups support is present])
+    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
+    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
+    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then
+        AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.])
+    fi
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_SUBST(ENABLE_CUPS)
+
+libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.12.0],,system,TRUE)
+
+dnl whether to find & fetch external tarballs?
+dnl ===================================================================
+if test -z "$TARFILE_LOCATION" -a -n "$LODE_HOME" ; then
+   if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+       TARFILE_LOCATION="`cygpath -m $LODE_HOME/ext_tar`"
+   else
+       TARFILE_LOCATION="$LODE_HOME/ext_tar"
+   fi
+fi
+if test -z "$TARFILE_LOCATION"; then
+    if test -d "$SRC_ROOT/src" ; then
+        mv "$SRC_ROOT/src" "$SRC_ROOT/external/tarballs"
+        ln -s "$SRC_ROOT/external/tarballs" "$SRC_ROOT/src"
+    fi
+    TARFILE_LOCATION="$SRC_ROOT/external/tarballs"
+else
+    AbsolutePath "$TARFILE_LOCATION"
+    PathFormat "${absolute_path}"
+    TARFILE_LOCATION="${formatted_path_unix}"
+fi
+AC_SUBST(TARFILE_LOCATION)
+
+AC_MSG_CHECKING([whether we want to fetch tarballs])
+if test "$enable_fetch_external" != "no"; then
+    if test "$with_all_tarballs" = "yes"; then
+        AC_MSG_RESULT([yes, all of them])
+        DO_FETCH_TARBALLS="ALL"
+    else
+        AC_MSG_RESULT([yes, if we use them])
+        DO_FETCH_TARBALLS="TRUE"
+    fi
+else
+    AC_MSG_RESULT([no])
+    DO_FETCH_TARBALLS=
+fi
+AC_SUBST(DO_FETCH_TARBALLS)
+
+dnl Test whether to include MySpell dictionaries
+dnl ===================================================================
+AC_MSG_CHECKING([whether to include MySpell dictionaries])
+if test "$with_myspell_dicts" = "yes"; then
+    AC_MSG_RESULT([yes])
+    WITH_MYSPELL_DICTS=TRUE
+    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
+    GIT_NEEDED_SUBMODULES="dictionaries $GIT_NEEDED_SUBMODULES"
+else
+    AC_MSG_RESULT([no])
+    WITH_MYSPELL_DICTS=
+fi
+AC_SUBST(WITH_MYSPELL_DICTS)
+
+# There are no "system" myspell, hyphen or mythes dictionaries on macOS, Windows, Android or iOS.
+if test $_os = Darwin -o $_os = WINNT -o $_os = iOS -o $_os = Android; then
+    if test "$with_system_dicts" = yes; then
+        AC_MSG_ERROR([There are no system dicts on this OS in the formats the 3rd-party libs we use expect]);
+    fi
+    with_system_dicts=no
+fi
+
+AC_MSG_CHECKING([whether to use dicts from external paths])
+if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
+    AC_MSG_RESULT([yes])
+    SYSTEM_DICTS=TRUE
+    AC_MSG_CHECKING([for spelling dictionary directory])
+    if test -n "$with_external_dict_dir"; then
+        DICT_SYSTEM_DIR=file://$with_external_dict_dir
+    else
+        DICT_SYSTEM_DIR=file:///usr/share/hunspell
+        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
+            DICT_SYSTEM_DIR=file:///usr/share/myspell
+        fi
+    fi
+    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
+    AC_MSG_CHECKING([for hyphenation patterns directory])
+    if test -n "$with_external_hyph_dir"; then
+        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
+    else
+        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
+    fi
+    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
+    AC_MSG_CHECKING([for thesaurus directory])
+    if test -n "$with_external_thes_dir"; then
+        THES_SYSTEM_DIR=file://$with_external_thes_dir
+    else
+        THES_SYSTEM_DIR=file:///usr/share/mythes
+    fi
+    AC_MSG_RESULT([$THES_SYSTEM_DIR])
+else
+    AC_MSG_RESULT([no])
+    SYSTEM_DICTS=
+fi
+AC_SUBST(SYSTEM_DICTS)
+AC_SUBST(DICT_SYSTEM_DIR)
+AC_SUBST(HYPH_SYSTEM_DIR)
+AC_SUBST(THES_SYSTEM_DIR)
+
+dnl ===================================================================
+dnl Precompiled headers.
+ENABLE_PCH=""
+AC_MSG_CHECKING([whether to enable pch feature])
+if test -z "$enable_pch"; then
+    if test "$_os" = "WINNT"; then
+        # Enabled by default on Windows.
+        enable_pch=yes
+        # never use sccache on auto-enabled PCH builds, except if requested explicitly
+        if test -z "$enable_ccache" -a "$SCCACHE"; then
+            CCACHE=""
+        fi
+    else
+        enable_pch=no
+    fi
+fi
+if test "$enable_pch" != no -a "$_os" = Emscripten -a "$ENABLE_WASM_EXCEPTIONS" = TRUE; then
+    AC_MSG_ERROR([PCH currently isn't supported for Emscripten with native EH (nEH) because of missing Sj/Lj support with nEH in clang.])
+fi
+if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
+    AC_MSG_ERROR([Precompiled header not yet supported for your platform/compiler])
+fi
+if test "$enable_pch" = "system"; then
+    ENABLE_PCH="1"
+    AC_MSG_RESULT([yes (system headers)])
+elif test "$enable_pch" = "base"; then
+    ENABLE_PCH="2"
+    AC_MSG_RESULT([yes (system and base headers)])
+elif test "$enable_pch" = "normal"; then
+    ENABLE_PCH="3"
+    AC_MSG_RESULT([yes (normal)])
+elif test "$enable_pch" = "full"; then
+    ENABLE_PCH="4"
+    AC_MSG_RESULT([yes (full)])
+elif test "$enable_pch" = "yes"; then
+    # Pick a suitable default.
+    if test "$GCC" = "yes"; then
+        # With Clang and GCC higher levels do not seem to make a noticeable improvement,
+        # while making the PCHs larger and rebuilds more likely.
+        ENABLE_PCH="2"
+        AC_MSG_RESULT([yes (system and base headers)])
+    else
+        # With MSVC the highest level makes a significant difference,
+        # and it was the default when there used to be no PCH levels.
+        ENABLE_PCH="4"
+        AC_MSG_RESULT([yes (full)])
+    fi
+elif test "$enable_pch" = "no"; then
+    AC_MSG_RESULT([no])
+else
+    AC_MSG_ERROR([Unknown value for --enable-pch])
+fi
+AC_SUBST(ENABLE_PCH)
+# ccache 3.7.1 and older do not properly detect/handle -include .gch in CCACHE_DEPEND mode
+if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_IS_CLANG" != "TRUE"; then
+    AC_PATH_PROG([CCACHE_BIN],[ccache],[not found])
+    if test "$CCACHE_BIN" != "not found"; then
+        AC_MSG_CHECKING([ccache version])
+        CCACHE_VERSION=`"$CCACHE_BIN" -V | "$AWK" '/^ccache version/{print $3}'`
+        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
+        AC_MSG_RESULT([$CCACHE_VERSION])
+        AC_MSG_CHECKING([whether ccache depend mode works properly with GCC PCH])
+        if test "$CCACHE_NUMVER" -gt "030701"; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_RESULT([no (not newer than 3.7.1)])
+            CCACHE_DEPEND_MODE=
+        fi
+    fi
+fi
+
+PCH_INSTANTIATE_TEMPLATES=
+if test -n "$ENABLE_PCH"; then
+    AC_MSG_CHECKING([whether $CC supports -fpch-instantiate-templates])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -fpch-instantiate-templates"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_INSTANTIATE_TEMPLATES="-fpch-instantiate-templates" ],[])
+    CFLAGS=$save_CFLAGS
+    if test -n "$PCH_INSTANTIATE_TEMPLATES"; then
+        AC_MSG_RESULT(yes)
+    else
+        AC_MSG_RESULT(no)
+    fi
+fi
+AC_SUBST(PCH_INSTANTIATE_TEMPLATES)
+
+BUILDING_PCH_WITH_OBJ=
+if test -n "$ENABLE_PCH"; then
+    AC_MSG_CHECKING([whether $CC supports -Xclang -building-pch-with-obj])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -Xclang -building-pch-with-obj"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ BUILDING_PCH_WITH_OBJ="-Xclang -building-pch-with-obj" ],[])
+    CFLAGS=$save_CFLAGS
+    if test -n "$BUILDING_PCH_WITH_OBJ"; then
+        AC_MSG_RESULT(yes)
+    else
+        AC_MSG_RESULT(no)
+    fi
+fi
+AC_SUBST(BUILDING_PCH_WITH_OBJ)
+
+PCH_CODEGEN=
+PCH_NO_CODEGEN=
+fpch_prefix=
+if test "$COM" = MSC; then
+    fpch_prefix="-Xclang "
+fi
+if test -n "$BUILDING_PCH_WITH_OBJ"; then
+    AC_MSG_CHECKING([whether $CC supports ${fpch_prefix}-fpch-codegen])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fpch-codegen"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
+        [ PCH_CODEGEN="${fpch_prefix}-fpch-codegen" ],[])
+    CFLAGS=$save_CFLAGS
+    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fno-pch-codegen"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
+        [ PCH_NO_CODEGEN="${fpch_prefix}-fno-pch-codegen" ],[])
+    CFLAGS=$save_CFLAGS
+    if test -n "$PCH_CODEGEN"; then
+        AC_MSG_RESULT(yes)
+    else
+        AC_MSG_RESULT(no)
+    fi
+fi
+AC_SUBST(PCH_CODEGEN)
+AC_SUBST(PCH_NO_CODEGEN)
+PCH_DEBUGINFO=
+if test -n "$BUILDING_PCH_WITH_OBJ"; then
+    AC_MSG_CHECKING([whether $CC supports ${fpch_prefix}-fpch-debuginfo])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fpch-debuginfo"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_DEBUGINFO="${fpch_prefix}-fpch-debuginfo" ],[])
+    CFLAGS=$save_CFLAGS
+    if test -n "$PCH_DEBUGINFO"; then
+        AC_MSG_RESULT(yes)
+    else
+        AC_MSG_RESULT(no)
+    fi
+fi
+AC_SUBST(PCH_DEBUGINFO)
+
+TAB=`printf '\t'`
+
+AC_MSG_CHECKING([the GNU Make version])
+_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
+_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
+if test "$_make_longver" -ge "040000"; then
+    AC_MSG_RESULT([$GNUMAKE $_make_version])
+else
+    AC_MSG_ERROR([failed ($GNUMAKE version >= 4.0 needed)])
+fi
+
+_make_ver_check=`$GNUMAKE --version | grep "Built for Windows"`
+STALE_MAKE=
+if test "$_make_ver_check" = ""; then
+   STALE_MAKE=TRUE
+fi
+
+HAVE_LD_HASH_STYLE=FALSE
+WITH_LINKER_HASH_STYLE=
+AC_MSG_CHECKING([for --hash-style gcc linker support])
+if test "$GCC" = "yes"; then
+    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
+        hash_styles="gnu sysv"
+    elif test "$with_linker_hash_style" = "no"; then
+        hash_styles=
+    else
+        hash_styles="$with_linker_hash_style"
+    fi
+
+    for hash_style in $hash_styles; do
+        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
+        hash_style_ldflags_save=$LDFLAGS
+        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"
+
+        AC_RUN_IFELSE([AC_LANG_PROGRAM(
+            [
+#include <stdio.h>
+            ],[
+printf ("");
+            ])],
+            [
+                  HAVE_LD_HASH_STYLE=TRUE
+                  WITH_LINKER_HASH_STYLE=$hash_style
+            ],
+            [HAVE_LD_HASH_STYLE=FALSE],
+            [HAVE_LD_HASH_STYLE=FALSE])
+        LDFLAGS=$hash_style_ldflags_save
+    done
+
+    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
+        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
+    else
+        AC_MSG_RESULT( no )
+    fi
+    LDFLAGS=$hash_style_ldflags_save
+else
+    AC_MSG_RESULT( no )
+fi
+AC_SUBST(HAVE_LD_HASH_STYLE)
+AC_SUBST(WITH_LINKER_HASH_STYLE)
+
+dnl ===================================================================
+dnl Check whether there's a Perl version available.
+dnl ===================================================================
+if test -z "$with_perl_home"; then
+    AC_PATH_PROG(PERL, perl)
+else
+    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
+    _perl_path="$with_perl_home/bin/perl"
+    if test -x "$_perl_path"; then
+        PERL=$_perl_path
+    else
+        AC_MSG_ERROR([$_perl_path not found])
+    fi
+fi
+
+dnl ===================================================================
+dnl Testing for Perl version 5 or greater.
+dnl $] is the Perl version variable, it is returned as an integer
+dnl ===================================================================
+if test "$PERL"; then
+    AC_MSG_CHECKING([the Perl version])
+    ${PERL} -e "exit($]);"
+    _perl_version=$?
+    if test "$_perl_version" -lt 5; then
+        AC_MSG_ERROR([found Perl $_perl_version, use Perl 5])
+    fi
+    AC_MSG_RESULT([Perl $_perl_version])
+else
+    AC_MSG_ERROR([Perl not found, install Perl 5])
+fi
+
+dnl ===================================================================
+dnl Testing for required Perl modules
+dnl ===================================================================
+
+AC_MSG_CHECKING([for required Perl modules])
+perl_use_string="use Cwd ; use Digest::MD5"
+if test "$_os" = "WINNT"; then
+    if test -n "$PKGFORMAT"; then
+        for i in $PKGFORMAT; do
+            case "$i" in
+            msi)
+                # for getting fonts versions to use in MSI
+                perl_use_string="$perl_use_string ; use Font::TTF::Font"
+                ;;
+            esac
+        done
+    fi
+fi
+if test "$with_system_hsqldb" = "yes"; then
+    perl_use_string="$perl_use_string ; use Archive::Zip"
+fi
+if test "$enable_openssl" = "yes" -a "$with_system_openssl" != "yes"; then
+    # OpenSSL needs that to build
+    perl_use_string="$perl_use_string ; use FindBin"
+fi
+if $PERL -e "$perl_use_string">/dev/null 2>&1; then
+    AC_MSG_RESULT([all modules found])
+else
+    AC_MSG_RESULT([failed to find some modules])
+    # Find out which modules are missing.
+    for i in $perl_use_string; do
+        if test "$i" != "use" -a "$i" != ";"; then
+            if ! $PERL -e "use $i;">/dev/null 2>&1; then
+                missing_perl_modules="$missing_perl_modules $i"
+            fi
+        fi
+    done
+    AC_MSG_ERROR([
+    The missing Perl modules are: $missing_perl_modules
+    Install them as superuser/administrator with "cpan -i $missing_perl_modules"])
+fi
+
+dnl ===================================================================
+dnl Check for pkg-config
+dnl ===================================================================
+if test "$_os" != "WINNT"; then
+    PKG_PROG_PKG_CONFIG
+fi
+AC_SUBST(PKG_CONFIG)
+AC_SUBST(PKG_CONFIG_PATH)
+AC_SUBST(PKG_CONFIG_LIBDIR)
+
+if test "$_os" != "WINNT"; then
+
+    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
+    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
+    # explicitly. Or put /path/to/compiler in PATH yourself.
+
+    toolprefix=gcc
+    if test "$COM_IS_CLANG" = "TRUE"; then
+        toolprefix=llvm
+    fi
+    AC_CHECK_TOOLS(AR,$toolprefix-ar ar)
+    AC_CHECK_TOOLS(NM,$toolprefix-nm nm)
+    AC_CHECK_TOOLS(RANLIB,$toolprefix-ranlib ranlib)
+    AC_CHECK_TOOLS(OBJDUMP,$toolprefix-objdump objdump)
+    AC_CHECK_TOOLS(READELF,$toolprefix-readelf readelf)
+    AC_CHECK_TOOLS(STRIP,$toolprefix-strip strip)
+fi
+AC_SUBST(AR)
+AC_SUBST(NM)
+AC_SUBST(OBJDUMP)
+AC_SUBST(RANLIB)
+AC_SUBST(READELF)
+AC_SUBST(STRIP)
+
+dnl ===================================================================
+dnl pkg-config checks on macOS
+dnl ===================================================================
+
+if test $_os = Darwin; then
+    AC_MSG_CHECKING([for bogus pkg-config])
+    if test -n "$PKG_CONFIG"; then
+        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
+            AC_MSG_ERROR([yes, from Mono. This *will* break the build. Please remove or hide $PKG_CONFIG])
+        else
+            if test "$enable_bogus_pkg_config" = "yes"; then
+                AC_MSG_RESULT([yes, user-approved from unknown origin.])
+            else
+                AC_MSG_ERROR([yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.])
+            fi
+        fi
+    else
+        AC_MSG_RESULT([no, good])
+    fi
+fi
+
+find_csc()
+{
+    # Return value: $csctest
+
+    unset csctest
+
+    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Client/InstallPath"
+    if test -n "$regvalue"; then
+        csctest=$regvalue
+        return
+    fi
+}
+
+find_al()
+{
+    # Return value: $altest
+
+    unset altest
+
+    # We need this check to detect 4.6.1 or above.
+    for ver in 4.8.1 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1; do
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/WinSDK-NetFx40Tools/InstallationFolder"
+        PathFormat "$regvalue"
+        if test -n "$regvalue" -a \( -f "$formatted_path_unix/al.exe" -o -f "$formatted_path_unix/bin/al.exe" \); then
+            altest=$regvalue
+            return
+        fi
+    done
+
+    reg_list_values_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows"
+    for x in $reglist; do
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/$x/WinSDK-NetFx40Tools/InstallationFolder"
+        PathFormat "$regvalue"
+        if test -n "$regvalue" -a \( -f "$formatted_path_unix/al.exe" -o -f "$formatted_path_unix/bin/al.exe" \); then
+            altest=$regvalue
+            return
+        fi
+    done
+}
+
+find_dotnetsdk()
+{
+    unset frametest
+
+    for ver in 4.8.1 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6; do
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/KitsInstallationFolder"
+        if test -n "$regvalue"; then
+            frametest=$regvalue
+            return
+        fi
+    done
+    AC_MSG_ERROR([The Windows NET SDK (minimum 4.6) not found, check the installation])
+}
+
+find_winsdk_version()
+{
+    # Args: $1 : SDK version as in "8.0", "8.1A" etc
+    # Return values: $winsdktest, $winsdkbinsubdir, $winsdklibsubdir
+
+    unset winsdktest winsdkbinsubdir winsdklibsubdir
+
+    case "$1" in
+    8.0|8.0A)
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot"
+        if test -n "$regvalue"; then
+            winsdktest=$regvalue
+            winsdklibsubdir=win8
+            return
+        fi
+        ;;
+    8.1|8.1A)
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot81"
+        if test -n "$regvalue"; then
+            winsdktest=$regvalue
+            winsdklibsubdir=winv6.3
+            return
+        fi
+        ;;
+    10.0)
+        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/InstallationFolder"
+        if test -n "$regvalue"; then
+            winsdktest=$regvalue
+            reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/ProductVersion"
+            if test -n "$regvalue"; then
+                winsdkbinsubdir="$regvalue".0
+                winsdklibsubdir=$winsdkbinsubdir
+                local tmppath="$winsdktest\\Include\\$winsdklibsubdir"
+                local tmppath_unix=$(cygpath -u "$tmppath")
+                # test exist the SDK path
+                if test -d "$tmppath_unix"; then
+                   # when path is convertible to a short path then path is okay
+                   cygpath -d "$tmppath" >/dev/null 2>&1
+                   if test $? -ne 0; then
+                      AC_MSG_ERROR([Windows SDK doesn't have a 8.3 name, see NtfsDisable8dot3NameCreation])
+                   fi
+                else
+                   AC_MSG_ERROR([The Windows SDK not found, check the installation])
+                fi
+            fi
+            return
+        fi
+        ;;
+    esac
+}
+
+find_winsdk()
+{
+    # Return value: From find_winsdk_version
+
+    unset winsdktest
+
+    for ver in $WINDOWS_SDK_ACCEPTABLE_VERSIONS; do
+        find_winsdk_version $ver
+        if test -n "$winsdktest"; then
+            return
+        fi
+    done
+}
+
+find_msms()
+{
+    # Return value: $msmdir
+    local version="$1"
+
+    AC_MSG_CHECKING([for MSVC $version merge modules directory])
+    local my_msm_file="Microsoft_VC${version}_CRT_x86.msm"
+    local my_msm_dir
+
+    echo "$as_me:$LINENO: searching for $my_msm_file" >&5
+
+    msmdir=
+    case "$VCVER" in
+    16.0 | 17.0 | 17.9)
+        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
+            my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/"
+            echo "$as_me:$LINENO: looking for $my_msm_dir${my_msm_file}])" >&5
+            if test -e "$my_msm_dir${my_msm_file}"; then
+                msmdir=$my_msm_dir
+            fi
+        done
+        ;;
+    esac
+
+    if test -n "$msmdir"; then
+        msmdir=`cygpath -m "$msmdir"`
+        AC_MSG_RESULT([$msmdir])
+    else
+        if test "$ENABLE_RELEASE_BUILD" = "TRUE" ; then
+            AC_MSG_FAILURE([not found])
+        else
+            AC_MSG_WARN([not found (check config.log)])
+            add_warning "MSM ${my_msm_file} not found"
+        fi
+    fi
+}
+
+find_msvc_x64_dlls()
+{
+    # Return value: $msvcdllpath, $msvcdlls
+
+    AC_MSG_CHECKING([for MSVC x64 DLL path])
+
+    dnl Order crtver in increasing order. Then check the directories returned by
+    dnl ls in an inner loop; assuming they are also ordered in increasing order,
+    dnl the result will be the highest CRT version found in the highest directory.
+
+    msvcdllpath="$VC_PRODUCT_DIR/redist/x64/Microsoft.VC${VCVER}.CRT"
+    case "$VCVER" in
+    16.0 | 17.0 | 17.9)
+        for crtver in 141 142 143; do
+            for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
+                echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC$crtver.CRT" >&5
+                if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC$crtver.CRT"; then
+                    msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC$crtver.CRT"
+                fi
+            done
+        done
+        ;;
+    esac
+    AC_MSG_RESULT([$msvcdllpath])
+    AC_MSG_CHECKING([for MSVC x64 DLLs])
+    msvcdlls="msvcp140.dll vcruntime140.dll"
+    for dll in $msvcdlls; do
+        if ! test -f "$msvcdllpath/$dll"; then
+            AC_MSG_FAILURE([missing $dll])
+        fi
+    done
+    AC_MSG_RESULT([found all ($msvcdlls)])
+}
+
+dnl =========================================
+dnl Check for the Windows  SDK.
+dnl =========================================
+if test "$_os" = "WINNT"; then
+    AC_MSG_CHECKING([for Windows SDK])
+    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
+        find_winsdk
+        WINDOWS_SDK_HOME=$winsdktest
+
+        # normalize if found
+        if test -n "$WINDOWS_SDK_HOME"; then
+            WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
+            WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
+        fi
+
+        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
+    fi
+
+    if test -n "$WINDOWS_SDK_HOME"; then
+        # Remove a possible trailing backslash
+        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
+
+        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
+             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
+             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
+            have_windows_sdk_headers=yes
+        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
+             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
+             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
+            have_windows_sdk_headers=yes
+        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
+             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
+             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
+            have_windows_sdk_headers=yes
+        else
+            have_windows_sdk_headers=no
+        fi
+
+        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
+            have_windows_sdk_libs=yes
+        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/user32.lib"; then
+            have_windows_sdk_libs=yes
+        else
+            have_windows_sdk_libs=no
+        fi
+
+        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
+            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
+the  Windows SDK are installed.])
+        fi
+    fi
+
+    if test -z "$WINDOWS_SDK_HOME"; then
+        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
+    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
+        WINDOWS_SDK_VERSION=80
+        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
+    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
+        WINDOWS_SDK_VERSION=81
+        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
+    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
+        WINDOWS_SDK_VERSION=10
+        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
+    else
+        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
+    fi
+    PathFormat "$WINDOWS_SDK_HOME"
+    WINDOWS_SDK_HOME="$formatted_path"
+    WINDOWS_SDK_HOME_unix="$formatted_path_unix"
+    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
+        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
+        if test -d "$WINDOWS_SDK_HOME/include/um"; then
+            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
+        elif test -d "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um"; then
+            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
+        fi
+    fi
+
+    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
+    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
+    dnl but not in v8.0), so allow this to be overridden with a
+    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
+    dnl and configuration error if no WiLangId.vbs is found would arguably be
+    dnl better, but I do not know under which conditions exactly it is needed by
+    dnl msiglobal.pm:
+    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
+        WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/Samples/sysmgmt/msi/scripts/WiLangId.vbs
+        WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
+        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
+            WINDOWS_SDK_WILANGID="${WINDOWS_SDK_HOME}/bin/${WINDOWS_SDK_LIB_SUBDIR}/${WIN_BUILD_ARCH}/WiLangId.vbs"
+            WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
+        fi
+        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
+            WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/bin/$WIN_BUILD_ARCH/WiLangId.vbs
+            WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
+        fi
+        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
+            WINDOWS_SDK_WILANGID=$(cygpath -sm "C:/Program Files (x86)/Windows Kits/8.1/bin/$WIN_BUILD_ARCH/WiLangId.vbs")
+            WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
+        fi
+    fi
+    if test -n "$with_lang" -a "$with_lang" != "en-US"; then
+        if test -n "$with_package_format" -a "$with_package_format" != no; then
+            for i in "$with_package_format"; do
+                if test "$i" = "msi"; then
+                    if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
+                        AC_MSG_ERROR([WiLangId.vbs not found - building translated packages will fail])
+                    fi
+                fi
+            done
+        fi
+    fi
+fi
+AC_SUBST(WINDOWS_SDK_HOME)
+AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
+AC_SUBST(WINDOWS_SDK_VERSION)
+AC_SUBST(WINDOWS_SDK_WILANGID)
+
+if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
+    dnl Check midl.exe; this being the first check for a tool in the SDK bin
+    dnl dir, it also determines that dir's path w/o an arch segment if any,
+    dnl WINDOWS_SDK_BINDIR_NO_ARCH:
+    AC_MSG_CHECKING([for midl.exe])
+
+    find_winsdk
+    PathFormat "$winsdktest"
+    winsdktest_unix="$formatted_path_unix"
+
+    if test -n "$winsdkbinsubdir" \
+        -a -f "$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/midl.exe"
+    then
+        MIDL_PATH=$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH
+        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin/$winsdkbinsubdir
+    elif test -f "$winsdktest_unix/Bin/$WIN_BUILD_ARCH/midl.exe"; then
+        MIDL_PATH=$winsdktest/Bin/$WIN_BUILD_ARCH
+        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin
+    elif test -f "$winsdktest_unix/Bin/midl.exe"; then
+        MIDL_PATH=$winsdktest/Bin
+        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin
+    fi
+    PathFormat "$MIDL_PATH"
+    if test ! -f "$formatted_path_unix/midl.exe"; then
+        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WIN_BUILD_ARCH, Windows SDK installation broken?])
+    else
+        AC_MSG_RESULT([$MIDL_PATH/midl.exe])
+    fi
+
+    # Convert to posix path with 8.3 filename restrictions ( No spaces )
+    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`
+
+    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
+    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
+    elif test -f "$WINDOWS_SDK_HOME/bin/x86/msiinfo.exe" \
+         -a -f "$WINDOWS_SDK_HOME/bin/x86/msidb.exe" \
+         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
+         -a -f "$WINDOWS_SDK_HOME/bin/x86/msitran.exe"; then :
+    else
+        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
+    fi
+
+    dnl Check csc.exe
+    AC_MSG_CHECKING([for csc.exe])
+    find_csc
+    PathFormat "$csctest"
+    csctest_unix="$formatted_path_unix"
+    if test -f "$csctest_unix/csc.exe"; then
+        CSC_PATH="$csctest"
+    fi
+    if test ! -f "$csctest_unix/csc.exe"; then
+        AC_MSG_ERROR([csc.exe not found as $CSC_PATH/csc.exe])
+    else
+        AC_MSG_RESULT([$CSC_PATH/csc.exe])
+    fi
+
+    CSC_PATH=`win_short_path_for_make "$CSC_PATH"`
+
+    dnl Check al.exe
+    AC_MSG_CHECKING([for al.exe])
+    if test -n "$winsdkbinsubdir" \
+        -a -f "$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/al.exe"
+    then
+        AL_PATH="$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH"
+    elif test -f "$winsdktest_unix/Bin/$WIN_BUILD_ARCH/al.exe"; then
+        AL_PATH="$winsdktest/Bin/$WIN_BUILD_ARCH"
+    elif test -f "$winsdktest_unix/Bin/al.exe"; then
+        AL_PATH="$winsdktest/Bin"
+    fi
+
+    if test -z "$AL_PATH"; then
+        find_al
+        PathFormat "$altest"
+        altest_unix="$formatted_path_unix"
+        if test -f "$altest_unix/bin/al.exe"; then
+            AL_PATH="$altest/bin"
+        elif test -f "$altest_unix/al.exe"; then
+            AL_PATH="$altest"
+        fi
+    fi
+    PathFormat "$AL_PATH"
+    if test ! -f "$formatted_path_unix/al.exe"; then
+        AC_MSG_ERROR([al.exe not found as $AL_PATH/al.exe])
+    else
+        AC_MSG_RESULT([$AL_PATH/al.exe])
+    fi
+
+    AL_PATH=`win_short_path_for_make "$AL_PATH"`
+
+    dnl Check mscoree.lib / .NET Framework dir
+    AC_MSG_CHECKING(.NET Framework)
+    find_dotnetsdk
+    PathFormat "$frametest"
+    frametest="$formatted_path_unix"
+    if test -f "$frametest/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
+        DOTNET_FRAMEWORK_HOME="$frametest"
+    else
+        if test -f "$winsdktest_unix/lib/mscoree.lib" -o -f "$winsdktest_unix/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib"; then
+            DOTNET_FRAMEWORK_HOME="$winsdktest"
+        fi
+    fi
+    PathFormat "$DOTNET_FRAMEWORK_HOME"
+    if test ! -f "$formatted_path_unix/lib/mscoree.lib" -a ! -f "$formatted_path_unix/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib" -a ! -f "$formatted_path_unix/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
+        AC_MSG_ERROR([mscoree.lib not found])
+    fi
+    AC_MSG_RESULT([found: $DOTNET_FRAMEWORK_HOME])
+
+    PathFormat "$MIDL_PATH"
+    MIDL_PATH="$formatted_path"
+
+    PathFormat "$AL_PATH"
+    AL_PATH="$formatted_path"
+
+    PathFormat "$DOTNET_FRAMEWORK_HOME"
+    DOTNET_FRAMEWORK_HOME="$formatted_path"
+
+    PathFormat "$CSC_PATH"
+    CSC_PATH="$formatted_path"
+fi
+
+dnl ===================================================================
+dnl Testing for C++ compiler and version...
+dnl ===================================================================
+
+if test "$_os" != "WINNT"; then
+    # AC_PROG_CXX sets CXXFLAGS to -g -O2 if not set, avoid that
+    save_CXXFLAGS=$CXXFLAGS
+    AC_PROG_CXX
+    CXXFLAGS=$save_CXXFLAGS
+    if test -z "$CXX_BASE"; then
+        CXX_BASE=`first_arg_basename "$CXX"`
+    fi
+fi
+
+dnl check for GNU C++ compiler version
+if test "$GXX" = "yes" -a -z "$COM_IS_CLANG"; then
+    AC_MSG_CHECKING([the GNU C++ compiler version])
+
+    _gpp_version=`$CXX -dumpversion`
+    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
+
+    if test "$_gpp_majmin" -lt "700"; then
+        AC_MSG_ERROR([You need to use GNU C++ compiler version >= 7.0 to build LibreOffice, you have $_gpp_version.])
+    else
+        AC_MSG_RESULT([ok (g++ $_gpp_version)])
+    fi
+
+    dnl see https://issuetracker.google.com/issues/36962819
+        glibcxx_threads=no
+        AC_LANG_PUSH([C++])
+        AC_REQUIRE_CPP
+        AC_MSG_CHECKING([whether $CXX_BASE is broken with boost.thread])
+        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
+            #include <bits/c++config.h>]],[[
+            #if !defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
+            && !defined(_GLIBCXX__PTHREADS) \
+            && !defined(_GLIBCXX_HAS_GTHREADS)
+            choke me
+            #endif
+        ]])],[AC_MSG_RESULT([yes])
+        glibcxx_threads=yes],[AC_MSG_RESULT([no])])
+        AC_LANG_POP([C++])
+        if test $glibcxx_threads = yes; then
+            BOOST_CXXFLAGS="-D_GLIBCXX_HAS_GTHREADS"
+        fi
+fi
+AC_SUBST(BOOST_CXXFLAGS)
+
+#
+# prefx CXX with ccache if needed
+#
+if test "$CCACHE" != ""; then
+    AC_MSG_CHECKING([whether $CXX_BASE is already ccached])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
+    # msvc does not fail on unknown options, check stdout
+    if test "$COM" = MSC; then
+        CXXFLAGS="$CXXFLAGS -nologo"
+    fi
+    save_ac_cxx_werror_flag=$ac_cxx_werror_flag
+    ac_cxx_werror_flag=yes
+    dnl an empty program will do, we're checking the compiler flags
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+                      [use_ccache=yes], [use_ccache=no])
+    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
+        AC_MSG_RESULT([yes])
+    else
+        CXX="$CCACHE $CXX"
+        CXX_BASE="ccache $CXX_BASE"
+        AC_MSG_RESULT([no])
+    fi
+    CXXFLAGS=$save_CXXFLAGS
+    ac_cxx_werror_flag=$save_ac_cxx_werror_flag
+    AC_LANG_POP([C++])
+fi
+
+dnl ===================================================================
+dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
+dnl ===================================================================
+
+if test "$_os" != "WINNT"; then
+    AC_PROG_CXXCPP
+
+    dnl Check whether there's a C pre-processor.
+    AC_PROG_CPP
+fi
+
+
+dnl ===================================================================
+dnl Find integral type sizes and alignments
+dnl ===================================================================
+
+if test "$_os" != "WINNT"; then
+
+    AC_CHECK_SIZEOF(long)
+    AC_CHECK_SIZEOF(short)
+    AC_CHECK_SIZEOF(int)
+    AC_CHECK_SIZEOF(long long)
+    AC_CHECK_SIZEOF(double)
+    AC_CHECK_SIZEOF(void*)
+    AC_CHECK_SIZEOF(size_t)
+
+    SAL_TYPES_SIZEOFSHORT=$ac_cv_sizeof_short
+    SAL_TYPES_SIZEOFINT=$ac_cv_sizeof_int
+    SAL_TYPES_SIZEOFLONG=$ac_cv_sizeof_long
+    SAL_TYPES_SIZEOFLONGLONG=$ac_cv_sizeof_long_long
+    SAL_TYPES_SIZEOFPOINTER=$ac_cv_sizeof_voidp
+    SIZEOF_SIZE_T=$ac_cv_sizeof_size_t
+
+    dnl Allow build without AC_CHECK_ALIGNOF, grrr
+    m4_pattern_allow([AC_CHECK_ALIGNOF])
+    m4_ifdef([AC_CHECK_ALIGNOF],
+        [
+            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
+            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
+            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
+            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
+        ],
+        [
+            case "$_os-$host_cpu" in
+            Linux-i686)
+                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
+                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
+                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=4
+                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=4
+                ;;
+            Linux-x86_64)
+                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
+                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
+                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=8
+                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=8
+                ;;
+            *)
+                if test -z "$ac_cv_alignof_short" -o \
+                        -z "$ac_cv_alignof_int" -o \
+                        -z "$ac_cv_alignof_long" -o \
+                        -z "$ac_cv_alignof_double"; then
+                   AC_MSG_ERROR([Your Autoconf doesn't have [AC_][CHECK_ALIGNOF]. You need to set the environment variables ac_cv_alignof_short, ac_cv_alignof_int, ac_cv_alignof_long and ac_cv_alignof_double.])
+                fi
+                ;;
+            esac
+        ])
+
+    SAL_TYPES_ALIGNMENT2=$ac_cv_alignof_short
+    SAL_TYPES_ALIGNMENT4=$ac_cv_alignof_int
+    if test $ac_cv_sizeof_long -eq 8; then
+        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_long
+    elif test $ac_cv_sizeof_double -eq 8; then
+        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_double
+    else
+        AC_MSG_ERROR([Cannot find alignment of 8 byte types.])
+    fi
+
+    dnl Check for large file support
+    AC_SYS_LARGEFILE
+    if test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
+        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
+    fi
+    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
+        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
+    fi
+else
+    # Hardcode for MSVC
+    SAL_TYPES_SIZEOFSHORT=2
+    SAL_TYPES_SIZEOFINT=4
+    SAL_TYPES_SIZEOFLONG=4
+    SAL_TYPES_SIZEOFLONGLONG=8
+    if test $WIN_HOST_BITS -eq 32; then
+        SAL_TYPES_SIZEOFPOINTER=4
+        SIZEOF_SIZE_T=4
+    else
+        SAL_TYPES_SIZEOFPOINTER=8
+        SIZEOF_SIZE_T=8
+    fi
+    SAL_TYPES_ALIGNMENT2=2
+    SAL_TYPES_ALIGNMENT4=4
+    SAL_TYPES_ALIGNMENT8=8
+    LFS_CFLAGS=''
+fi
+AC_SUBST(LFS_CFLAGS)
+AC_SUBST(SIZEOF_SIZE_T)
+
+AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFSHORT,$SAL_TYPES_SIZEOFSHORT)
+AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFINT,$SAL_TYPES_SIZEOFINT)
+AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONG,$SAL_TYPES_SIZEOFLONG)
+AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONGLONG,$SAL_TYPES_SIZEOFLONGLONG)
+AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFPOINTER,$SAL_TYPES_SIZEOFPOINTER)
+AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
+AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
+AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
+
+dnl Calc jumbo sheets (1m+ rows) depend on 64 bit tools::Long .
+AC_MSG_CHECKING([whether jumbo sheets are supported])
+if test "$_os" != "WINNT"; then
+    if test $SAL_TYPES_SIZEOFLONG -gt 4; then
+        AC_MSG_RESULT([yes])
+        ENABLE_JUMBO_SHEETS=TRUE
+        AC_DEFINE(HAVE_FEATURE_JUMBO_SHEETS)
+    else
+        AC_MSG_RESULT([no])
+    fi
+else
+    if test $WIN_HOST_BITS -gt 32; then
+        # 64bit windows is special-cased for tools::Long because long is 32bit
+        AC_MSG_RESULT([yes])
+        ENABLE_JUMBO_SHEETS=TRUE
+        AC_DEFINE(HAVE_FEATURE_JUMBO_SHEETS)
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST(ENABLE_JUMBO_SHEETS)
+
+dnl ===================================================================
+dnl Check whether to enable runtime optimizations
+dnl ===================================================================
+ENABLE_RUNTIME_OPTIMIZATIONS=
+AC_MSG_CHECKING([whether to enable runtime optimizations])
+if test -z "$enable_runtime_optimizations"; then
+    for i in $CC; do
+        case $i in
+        -fsanitize=*)
+            enable_runtime_optimizations=no
+            break
+            ;;
+        esac
+    done
+fi
+if test "$enable_runtime_optimizations" != no; then
+    ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
+    AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
+
+dnl ===================================================================
+dnl Check if valgrind headers are available
+dnl ===================================================================
+ENABLE_VALGRIND=
+if test "$cross_compiling" != yes -a "$with_valgrind" != no; then
+    prev_cppflags=$CPPFLAGS
+    # Is VALGRIND_CFLAGS something one is supposed to have in the environment,
+    # or where does it come from?
+    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
+    AC_CHECK_HEADER([valgrind/valgrind.h],
+        [ENABLE_VALGRIND=TRUE])
+    CPPFLAGS=$prev_cppflags
+fi
+AC_SUBST([ENABLE_VALGRIND])
+if test -z "$ENABLE_VALGRIND"; then
+    if test "$with_valgrind" = yes; then
+        AC_MSG_ERROR([--with-valgrind specified but no Valgrind headers found])
+    fi
+    VALGRIND_CFLAGS=
+fi
+AC_SUBST([VALGRIND_CFLAGS])
+
+
+dnl ===================================================================
+dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
+dnl ===================================================================
+
+# We need at least the sys/sdt.h include header.
+AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
+if test "$SDT_H_FOUND" = "TRUE"; then
+    # Found sys/sdt.h header, now make sure the c++ compiler works.
+    # Old g++ versions had problems with probes in constructors/destructors.
+    AC_MSG_CHECKING([working sys/sdt.h and c++ support])
+    AC_LANG_PUSH([C++])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+    #include <sys/sdt.h>
+    class ProbeClass
+    {
+    private:
+      int& ref;
+      const char *name;
+
+    public:
+      ProbeClass(int& v, const char *n) : ref(v), name(n)
+      {
+        DTRACE_PROBE2(_test_, cons, name, ref);
+      }
+
+      void method(int min)
+      {
+        DTRACE_PROBE3(_test_, meth, name, ref, min);
+        ref -= min;
+      }
+
+      ~ProbeClass()
+      {
+        DTRACE_PROBE2(_test_, dest, name, ref);
+      }
+    };
+    ]],[[
+    int i = 64;
+    DTRACE_PROBE1(_test_, call, i);
+    ProbeClass inst = ProbeClass(i, "call");
+    inst.method(24);
+    ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
+          [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
+    AC_LANG_POP([C++])
+fi
+AC_CONFIG_HEADERS([config_host/config_probes.h])
+
+dnl ===================================================================
+dnl GCC features
+dnl ===================================================================
+HAVE_GCC_STACK_CLASH_PROTECTION=
+if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
+    AC_MSG_CHECKING([whether $CC_BASE supports -fstack-clash-protection])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -fstack-clash-protection"
+    AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(, [[return 0;]])],
+        [AC_MSG_RESULT([yes]); HAVE_GCC_STACK_CLASH_PROTECTION=TRUE],
+        [AC_MSG_RESULT([no])])
+    CFLAGS=$save_CFLAGS
+
+    AC_MSG_CHECKING([whether $CC_BASE supports -mno-avx])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -mno-avx"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
+    CFLAGS=$save_CFLAGS
+    if test "$HAVE_GCC_AVX" = "TRUE"; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+    fi
+
+    AC_MSG_CHECKING([whether $CC_BASE supports atomic functions])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
+    int v = 0;
+    if (__sync_add_and_fetch(&v, 1) != 1 ||
+        __sync_sub_and_fetch(&v, 1) != 0)
+        return 1;
+    __sync_synchronize();
+    if (__sync_val_compare_and_swap(&v, 0, 1) != 0 ||
+        v != 1)
+        return 1;
+    return 0;
+]])],[HAVE_GCC_BUILTIN_ATOMIC=TRUE],[])
+    if test "$HAVE_GCC_BUILTIN_ATOMIC" = "TRUE"; then
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_GCC_BUILTIN_ATOMIC)
+    else
+        AC_MSG_RESULT([no])
+    fi
+
+    AC_MSG_CHECKING([whether $CXX_BASE defines __base_class_type_info in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cstddef>
+            #include <cxxabi.h>
+            std::size_t f() { return sizeof(__cxxabiv1::__base_class_type_info); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE defines __class_type_info in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cstddef>
+            #include <cxxabi.h>
+            std::size_t f() { return sizeof(__cxxabiv1::__class_type_info); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CLASS_TYPE_INFO],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_allocate_exception in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_eh_globals in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cstddef>
+            #include <cxxabi.h>
+            std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_exception in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cstddef>
+            #include <cxxabi.h>
+            std::size_t f() { return sizeof(__cxxabiv1::__cxa_exception); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTION],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_get_globals in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void * f() { return __cxxabiv1::__cxa_get_globals(); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CXA_GET_GLOBALS],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_current_exception_type in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void * f() { return __cxxabiv1::__cxa_current_exception_type(); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_throw in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_CXA_THROW],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE defines __si_class_type_info in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cstddef>
+            #include <cxxabi.h>
+            std::size_t f() { return sizeof(__cxxabiv1::__si_class_type_info); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_SI_CLASS_TYPE_INFO],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([whether $CXX_BASE defines __vmi_class_type_info in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cstddef>
+            #include <cxxabi.h>
+            std::size_t f() { return sizeof(__cxxabiv1::__vmi_class_type_info); }
+        ])], [
+            AC_DEFINE([HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+fi
+
+AC_SUBST(HAVE_GCC_AVX)
+AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC)
+AC_SUBST(HAVE_GCC_STACK_CLASH_PROTECTION)
+
+dnl ===================================================================
+dnl Identify the C++ library
+dnl ===================================================================
+
+AC_MSG_CHECKING([what the C++ library is])
+HAVE_LIBSTDCPP=
+HAVE_LIBCPP=
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <utility>
+#ifndef __GLIBCXX__
+foo bar
+#endif
+]])],
+    [CPP_LIBRARY=GLIBCXX
+     cpp_library_name="GNU libstdc++"
+     HAVE_LIBSTDCPP=TRUE
+    ],
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <utility>
+#ifndef _LIBCPP_VERSION
+foo bar
+#endif
+]])],
+    [CPP_LIBRARY=LIBCPP
+     cpp_library_name="LLVM libc++"
+     AC_DEFINE([HAVE_LIBCPP])
+     HAVE_LIBCPP=TRUE
+    ],
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <utility>
+#ifndef _MSC_VER
+foo bar
+#endif
+]])],
+    [CPP_LIBRARY=MSVCRT
+     cpp_library_name="Microsoft"
+    ],
+    AC_MSG_ERROR([Could not figure out what C++ library this is]))))
+AC_MSG_RESULT([$cpp_library_name])
+AC_LANG_POP([C++])
+AC_SUBST([HAVE_LIBSTDCPP])
+AC_SUBST([HAVE_LIBCPP])
+
+if test -z "${LIBCPP_DEBUG+x}" -a -z "$CROSS_COMPILING" -a -n "$HAVE_LIBCPP" -a -n "$ENABLE_DBGUTIL"
+then
+    # Libc++ has two levels of debug mode, assertions mode enabled with -D_LIBCPP_DEBUG=0,
+    # and actual debug mode enabled with -D_LIBCPP_DEBUG=1 (and starting with LLVM15
+    # assertions mode will be separate and controlled by -D_LIBCPP_ENABLE_ASSERTIONS=1,
+    # although there will be backwards compatibility).
+    # Debug mode is supported by libc++ only if built for it, e.g. Mac libc++ isn't,
+    # and there would be undefined references to debug functions.
+    # Moreover std::to_string() has a bug (https://reviews.llvm.org/D125184).
+    # So check if debug mode can be used and disable or downgrade it to assertions
+    # if needed.
+    AC_MSG_CHECKING([if libc++ has a usable debug mode])
+    AC_LANG_PUSH([C++])
+    libcpp_debug_links=
+    AC_LINK_IFELSE([AC_LANG_SOURCE([[
+#define _LIBCPP_DEBUG 0 // only assertions
+#include <vector>
+int main()
+{
+    std::vector<int> v;
+    v.push_back( 1 );
+    return v[ 3 ];
+}
+]])], [libcpp_debug_links=1])
+    if test -n "$libcpp_debug_links"; then
+        # we can use at least assertions, check if debug mode works
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#define _LIBCPP_DEBUG 1 // debug mode
+#include <string>
+#include <vector>
+int foo(const std::vector<int>& v) { return *v.begin(); }
+int main()
+{
+    std::vector<int> v;
+    v.push_back( 1 );
+    std::string s = "xxxxxxxxxxxxxxxxxxxxxxxxx" + std::to_string(10);
+    return (foo(v) + s.size()) != 0 ? 0 : 1;
+}
+]])],
+        [AC_MSG_RESULT(yes)
+         LIBCPP_DEBUG=-D_LIBCPP_DEBUG=1
+        ],
+        [AC_MSG_RESULT(no, using only assertions)
+         LIBCPP_DEBUG=-D_LIBCPP_DEBUG=0
+        ]
+        )
+    else
+        AC_MSG_RESULT(no)
+    fi
+    AC_LANG_POP([C++])
+fi
+AC_SUBST([LIBCPP_DEBUG])
+
+dnl ===================================================================
+dnl Check for gperf
+dnl ===================================================================
+AC_PATH_PROG(GPERF, gperf)
+if test -z "$GPERF"; then
+    AC_MSG_ERROR([gperf not found but needed. Install it.])
+fi
+if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+    GPERF=`cygpath -m $GPERF`
+fi
+AC_MSG_CHECKING([whether gperf is new enough])
+my_gperf_ver1=$($GPERF --version | head -n 1)
+my_gperf_ver2=${my_gperf_ver1#GNU gperf }
+my_gperf_ver3=$(printf %s "$my_gperf_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
+if test "$my_gperf_ver3" -ge 301; then
+    AC_MSG_RESULT([yes ($my_gperf_ver2)])
+else
+    AC_MSG_ERROR(["$my_gperf_ver1" is too old or unrecognized, must be at least gperf 3.1])
+fi
+AC_SUBST(GPERF)
+
+dnl ===================================================================
+dnl Check for system libcmis
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.6 >= 0.6.1],enabled)
+
+dnl ===================================================================
+dnl C++11
+dnl ===================================================================
+
+if test -z "${CXXFLAGS_CXX11+x}"; then
+    AC_MSG_CHECKING([whether $CXX_BASE supports C++20])
+    if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
+        if test "$with_latest_c__" = yes; then
+            CXXFLAGS_CXX11=-std:c++latest
+        else
+            CXXFLAGS_CXX11=-std:c++20
+        fi
+        CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -permissive- -Zc:__cplusplus,preprocessor"
+    elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
+        my_flags='-std=c++20 -std=c++2a'
+        if test "$with_latest_c__" = yes; then
+            my_flags="-std=c++26 -std=c++2c -std=c++23 -std=c++2b $my_flags"
+        fi
+        for flag in $my_flags; do
+            if test "$COM" = MSC; then
+                flag="-Xclang $flag"
+            fi
+            save_CXXFLAGS=$CXXFLAGS
+            CXXFLAGS="$CXXFLAGS $flag -Werror"
+            AC_LANG_PUSH([C++])
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+                #include <algorithm>
+                #include <functional>
+                #include <vector>
+
+                void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
+                    std::sort(v.begin(), v.end(), fn);
+                }
+                ]])],[CXXFLAGS_CXX11=$flag])
+            AC_LANG_POP([C++])
+            CXXFLAGS=$save_CXXFLAGS
+            if test -n "$CXXFLAGS_CXX11"; then
+                break
+            fi
+        done
+    fi
+    if test -n "$CXXFLAGS_CXX11"; then
+        AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
+    else
+        AC_MSG_ERROR(no)
+    fi
+fi
+AC_SUBST(CXXFLAGS_CXX11)
+
+if test "$GCC" = "yes"; then
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+    CHECK_L_ATOMIC
+    CXXFLAGS=$save_CXXFLAGS
+    AC_SUBST(ATOMIC_LIB)
+fi
+
+AC_MSG_CHECKING([whether $CXX_BASE supports C++11 without Language Defect 757])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_LANG_PUSH([C++])
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <stddef.h>
+
+template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
+
+namespace
+{
+        struct b
+        {
+                int i;
+                int j;
+        };
+}
+]], [[
+struct a
+{
+        int i;
+        int j;
+};
+a thinga[]={{0,0}, {1,1}};
+b thingb[]={{0,0}, {1,1}};
+size_t i = sizeof(sal_n_array_size(thinga));
+size_t j = sizeof(sal_n_array_size(thingb));
+return !(i != 0 && j != 0);
+]])
+    ], [ AC_MSG_RESULT(yes) ],
+    [ AC_MSG_ERROR(no)])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+
+HAVE_GCC_FNO_SIZED_DEALLOCATION=
+if test "$GCC" = yes; then
+    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-sized-deallocation])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS -fno-sized-deallocation"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[HAVE_GCC_FNO_SIZED_DEALLOCATION=TRUE])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+    if test "$HAVE_GCC_FNO_SIZED_DEALLOCATION" = TRUE; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
+
+AC_MSG_CHECKING([whether $CXX_BASE supports C++2a constinit sorted vectors])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+        #include <algorithm>
+        #include <initializer_list>
+        #include <vector>
+        template<typename T> class S {
+        private:
+            std::vector<T> v_;
+        public:
+            constexpr S(std::initializer_list<T> i): v_(i) { std::sort(v_.begin(), v_.end()); }
+        };
+        constinit S<int> s{3, 2, 1};
+    ])], [
+        AC_DEFINE([HAVE_CPP_CONSTINIT_SORTED_VECTOR],[1])
+        AC_MSG_RESULT([yes])
+    ], [AC_MSG_RESULT([no])])
+CXXFLAGS=$save_CXXFLAGS
+AC_LANG_POP([C++])
+
+AC_MSG_CHECKING([whether $CXX_BASE implements C++ DR P1155R3])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+        struct S1 { S1(S1 &&); };
+        struct S2: S1 {};
+        S1 f(S2 s) { return s; }
+    ])], [
+        AC_DEFINE([HAVE_P1155R3],[1])
+        AC_MSG_RESULT([yes])
+    ], [AC_MSG_RESULT([no])])
+CXXFLAGS=$save_CXXFLAGS
+AC_LANG_POP([C++])
+
+AC_MSG_CHECKING([whether $CXX_BASE supports C++20 std::atomic_ref])
+HAVE_CXX20_ATOMIC_REF=
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+        #include <atomic>
+        int x;
+        std::atomic_ref<int> y(x);
+    ])], [
+        HAVE_CXX20_ATOMIC_REF=TRUE
+        AC_MSG_RESULT([yes])
+    ], [AC_MSG_RESULT([no])])
+CXXFLAGS=$save_CXXFLAGS
+AC_LANG_POP([C++])
+AC_SUBST([HAVE_CXX20_ATOMIC_REF])
+
+dnl Supported since GCC 9 and Clang 10 (which each also started to support -Wdeprecated-copy, but
+dnl which is included in -Wextra anyway):
+HAVE_WDEPRECATED_COPY_DTOR=
+if test "$GCC" = yes; then
+    AC_MSG_CHECKING([whether $CXX_BASE supports -Wdeprecated-copy-dtor])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS -Werror -Wdeprecated-copy-dtor"
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
+            HAVE_WDEPRECATED_COPY_DTOR=TRUE
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST([HAVE_WDEPRECATED_COPY_DTOR])
+
+dnl At least GCC 8.2 with -O2 (i.e., --enable-optimized) causes a false-positive -Wmaybe-
+dnl uninitialized warning for code like
+dnl
+dnl   OString f();
+dnl   boost::optional<OString> * g(bool b) {
+dnl       boost::optional<OString> o;
+dnl       if (b) o = f();
+dnl       return new boost::optional<OString>(o);
+dnl   }
+dnl
+dnl (as is e.g. present, in a slightly more elaborate form, in
+dnl librdf_TypeConverter::extractNode_NoLock in unoxml/source/rdf/librdf_repository.cxx); the below
+dnl code is meant to be a faithfully stripped-down and self-contained version of the above code:
+HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=
+if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
+    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=maybe-uninitialized])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wmaybe-uninitialized"
+    if test "$ENABLE_OPTIMIZED" = TRUE; then
+        CXXFLAGS="$CXXFLAGS -O2"
+    else
+        CXXFLAGS="$CXXFLAGS -O0"
+    fi
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+            #include <new>
+            void f1(int);
+            struct S1 {
+                ~S1() { f1(n); }
+                int n = 0;
+            };
+            struct S2 {
+                S2() {}
+                S2(S2 const & s) { if (s.init) set(*reinterpret_cast<S1 const *>(s.stg)); }
+                ~S2() { if (init) reinterpret_cast<S1 *>(stg)->S1::~S1(); }
+                void set(S1 s) {
+                    new (stg) S1(s);
+                    init = true;
+                }
+                bool init = false;
+                char stg[sizeof (S1)];
+            } ;
+            S1 f2();
+            S2 * f3(bool b) {
+                S2 o;
+                if (b) o.set(f2());
+                return new S2(o);
+            }
+        ]])], [AC_MSG_RESULT([no])], [
+            HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=TRUE
+            AC_MSG_RESULT([yes])
+        ])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST([HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED])
+
+dnl Check for <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c5> "[8/9/10/11 Regression]
+dnl -Wstringop-overflow false positive due to using MEM_REF type of &MEM" (fixed in GCC 11), which
+dnl hits us e.g. with GCC 10 and --enable-optimized at
+dnl
+dnl   In file included from include/rtl/string.hxx:49,
+dnl                    from include/rtl/ustring.hxx:43,
+dnl                    from include/osl/file.hxx:35,
+dnl                    from include/codemaker/global.hxx:28,
+dnl                    from include/codemaker/options.hxx:23,
+dnl                    from codemaker/source/commoncpp/commoncpp.cxx:24:
+dnl   In function ‘char* rtl::addDataHelper(char*, const char*, std::size_t)’,
+dnl       inlined from ‘static char* rtl::ToStringHelper<const char [N]>::addData(char*, const char*) [with long unsigned int N = 3]’ at include/rtl/stringconcat.hxx:147:85,
+dnl       inlined from ‘char* rtl::OStringConcat<T1, T2>::addData(char*) const [with T1 = const char [3]; T2 = rtl::OString]’ at include/rtl/stringconcat.hxx:226:103,
+dnl       inlined from ‘rtl::OStringBuffer& rtl::OStringBuffer::append(rtl::OStringConcat<T1, T2>&&) [with T1 = const char [3]; T2 = rtl::OString]’ at include/rtl/strbuf.hxx:599:30,
+dnl       inlined from ‘rtl::OString codemaker::cpp::scopedCppName(const rtl::OString&, bool)’ at codemaker/source/commoncpp/commoncpp.cxx:53:55:
+dnl   include/rtl/stringconcat.hxx:78:15: error: writing 2 bytes into a region of size 1 [-Werror=stringop-overflow=]
+dnl      78 |         memcpy( buffer, data, length );
+dnl         |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
+HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=
+if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
+    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=stringop-overflow=])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wstringop-overflow"
+    if test "$ENABLE_OPTIMIZED" = TRUE; then
+        CXXFLAGS="$CXXFLAGS -O2"
+    else
+        CXXFLAGS="$CXXFLAGS -O0"
+    fi
+    dnl Test code taken from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c0>:
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+            void fill(char const * begin, char const * end, char c);
+            struct q {
+                char ids[4];
+                char username[6];
+            };
+            void test(q & c) {
+                fill(c.ids, c.ids + sizeof(c.ids), '\0');
+                __builtin_strncpy(c.username, "root", sizeof(c.username));
+            }
+        ]])], [AC_MSG_RESULT([no])], [
+            HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=TRUE
+            AC_MSG_RESULT([yes])
+        ])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST([HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW])
+
+HAVE_DLLEXPORTINLINES=
+if test "$_os" = "WINNT"; then
+    AC_MSG_CHECKING([whether $CXX_BASE supports -Zc:dllexportInlines-])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
+            HAVE_DLLEXPORTINLINES=TRUE
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST([HAVE_DLLEXPORTINLINES])
+
+dnl ===================================================================
+dnl CPU Intrinsics support - SSE, AVX
+dnl ===================================================================
+
+CXXFLAGS_INTRINSICS_SSE2=
+CXXFLAGS_INTRINSICS_SSSE3=
+CXXFLAGS_INTRINSICS_SSE41=
+CXXFLAGS_INTRINSICS_SSE42=
+CXXFLAGS_INTRINSICS_AVX=
+CXXFLAGS_INTRINSICS_AVX2=
+CXXFLAGS_INTRINSICS_AVX512=
+CXXFLAGS_INTRINSICS_AVX512F=
+CXXFLAGS_INTRINSICS_F16C=
+CXXFLAGS_INTRINSICS_FMA=
+
+if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
+    # GCC, Clang or Clang-cl (clang-cl + MSVC's -arch options don't work well together)
+    flag_sse2=-msse2
+    flag_ssse3=-mssse3
+    flag_sse41=-msse4.1
+    flag_sse42=-msse4.2
+    flag_avx=-mavx
+    flag_avx2=-mavx2
+    flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
+    flag_avx512f=-mavx512f
+    flag_f16c=-mf16c
+    flag_fma=-mfma
+else
+    # With MSVC using -arch is in fact not necessary for being able
+    # to use CPU intrinsics, code using AVX512F intrinsics will compile
+    # even if compiled with -arch:AVX, the -arch option really only affects
+    # instructions generated for C/C++ code.
+    # So use the matching same (or lower) -arch options, but only in order
+    # to generate the best matching instructions for the C++ code surrounding
+    # the intrinsics.
+    # SSE2 is the default for x86/x64, so no need to specify the option.
+    flag_sse2=
+    # No specific options for these, use the next lower.
+    flag_ssse3="$flag_sse2"
+    flag_sse41="$flag_sse2"
+    flag_sse42="$flag_sse2"
+    flag_avx=-arch:AVX
+    flag_avx2=-arch:AVX2
+    flag_avx512=-arch:AVX512
+    # Using -arch:AVX512 would enable more than just AVX512F, so use only AVX2.
+    flag_avx512f=-arch:AVX2
+    # No MSVC options for these.
+    flag_f16c="$flag_sse2"
+    flag_fma="$flag_sse2"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_sse2"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <emmintrin.h>
+    int main () {
+        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+        c = _mm_xor_si128 (a, b);
+        return 0;
+    }
+    ])],
+    [can_compile_sse2=yes],
+    [can_compile_sse2=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_sse2}])
+if test "${can_compile_sse2}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_ssse3"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <tmmintrin.h>
+    int main () {
+        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+        c = _mm_maddubs_epi16 (a, b);
+        return 0;
+    }
+    ])],
+    [can_compile_ssse3=yes],
+    [can_compile_ssse3=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_ssse3}])
+if test "${can_compile_ssse3}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_sse41"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <smmintrin.h>
+    int main () {
+        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+        c = _mm_cmpeq_epi64 (a, b);
+        return 0;
+    }
+    ])],
+    [can_compile_sse41=yes],
+    [can_compile_sse41=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_sse41}])
+if test "${can_compile_sse41}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_sse42"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <nmmintrin.h>
+    int main () {
+        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+        c = _mm_cmpgt_epi64 (a, b);
+        return 0;
+    }
+    ])],
+    [can_compile_sse42=yes],
+    [can_compile_sse42=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_sse42}])
+if test "${can_compile_sse42}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_avx"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <immintrin.h>
+    int main () {
+        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
+        c = _mm256_xor_ps(a, b);
+        return 0;
+    }
+    ])],
+    [can_compile_avx=yes],
+    [can_compile_avx=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_avx}])
+if test "${can_compile_avx}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_AVX="$flag_avx"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_avx2"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <immintrin.h>
+    int main () {
+        __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
+        c = _mm256_maddubs_epi16(a, b);
+        return 0;
+    }
+    ])],
+    [can_compile_avx2=yes],
+    [can_compile_avx2=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_avx2}])
+if test "${can_compile_avx2}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_avx512"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <immintrin.h>
+    int main () {
+        __m512i a = _mm512_loadu_si512(0);
+        __m512d v1 = _mm512_load_pd(0);
+        // https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/config/i386/avx512fintrin.h;h=23bce99cbe7016a04e14c2163ed3fe6a5a64f4e2
+        __m512d v2 = _mm512_abs_pd(v1);
+        return 0;
+    }
+    ])],
+    [can_compile_avx512=yes],
+    [can_compile_avx512=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_avx512}])
+if test "${can_compile_avx512}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
+    CXXFLAGS_INTRINSICS_AVX512F="$flag_avx512f"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_f16c"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <immintrin.h>
+    int main () {
+        __m128i a = _mm_set1_epi32 (0);
+        __m128 c;
+        c = _mm_cvtph_ps(a);
+        return 0;
+    }
+    ])],
+    [can_compile_f16c=yes],
+    [can_compile_f16c=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_f16c}])
+if test "${can_compile_f16c}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
+fi
+
+AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $flag_fma"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+    #include <immintrin.h>
+    int main () {
+        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
+        d = _mm256_fmadd_ps(a, b, c);
+        return 0;
+    }
+    ])],
+    [can_compile_fma=yes],
+    [can_compile_fma=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([${can_compile_fma}])
+if test "${can_compile_fma}" = "yes" ; then
+    CXXFLAGS_INTRINSICS_FMA="$flag_fma"
+fi
+
+AC_SUBST([CXXFLAGS_INTRINSICS_SSE2])
+AC_SUBST([CXXFLAGS_INTRINSICS_SSSE3])
+AC_SUBST([CXXFLAGS_INTRINSICS_SSE41])
+AC_SUBST([CXXFLAGS_INTRINSICS_SSE42])
+AC_SUBST([CXXFLAGS_INTRINSICS_AVX])
+AC_SUBST([CXXFLAGS_INTRINSICS_AVX2])
+AC_SUBST([CXXFLAGS_INTRINSICS_AVX512])
+AC_SUBST([CXXFLAGS_INTRINSICS_AVX512F])
+AC_SUBST([CXXFLAGS_INTRINSICS_F16C])
+AC_SUBST([CXXFLAGS_INTRINSICS_FMA])
+
+dnl ===================================================================
+dnl system stl sanity tests
+dnl ===================================================================
+if test "$_os" != "WINNT"; then
+
+    AC_LANG_PUSH([C++])
+
+    save_CPPFLAGS="$CPPFLAGS"
+    if test -n "$MACOSX_SDK_PATH"; then
+        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
+    fi
+
+    # Assume visibility is not broken with libc++. The below test is very much designed for libstdc++
+    # only.
+    if test "$CPP_LIBRARY" = GLIBCXX; then
+        dnl gcc#19664, gcc#22482, rhbz#162935
+        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
+        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
+        AC_MSG_RESULT([$stlvisok])
+        if test "$stlvisok" = "no"; then
+            AC_MSG_ERROR([Your libstdc++ headers are not visibility safe. This is no longer supported.])
+        fi
+    fi
+
+    # As the below test checks things when linking self-compiled dynamic libraries, it presumably is irrelevant
+    # when we don't make any dynamic libraries?
+    if test "$DISABLE_DYNLOADING" = ""; then
+        AC_MSG_CHECKING([if $CXX_BASE is -fvisibility-inlines-hidden safe (Clang bug 11250)])
+        cat > conftestlib1.cc <<_ACEOF
+template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
+struct S2: S1<int> { virtual ~S2(); };
+S2::~S2() {}
+_ACEOF
+        cat > conftestlib2.cc <<_ACEOF
+template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
+struct S2: S1<int> { virtual ~S2(); };
+struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
+_ACEOF
+        gccvisinlineshiddenok=yes
+        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
+            gccvisinlineshiddenok=no
+        else
+            dnl At least Clang -fsanitize=address and -fsanitize=undefined are
+            dnl known to not work with -z defs (unsetting which makes the test
+            dnl moot, though):
+            my_linkflagsnoundefs=$LINKFLAGSNOUNDEFS
+            if test "$COM_IS_CLANG" = TRUE; then
+                for i in $CXX $CXXFLAGS; do
+                    case $i in
+                    -fsanitize=*)
+                        my_linkflagsnoundefs=
+                        break
+                        ;;
+                    esac
+                done
+            fi
+            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $my_linkflagsnoundefs -o libconftest2$DLLPOST >/dev/null 2>&5; then
+                gccvisinlineshiddenok=no
+            fi
+        fi
+
+        rm -fr libconftest*
+        AC_MSG_RESULT([$gccvisinlineshiddenok])
+        if test "$gccvisinlineshiddenok" = "no"; then
+            AC_MSG_ERROR([Your gcc/clang is not -fvisibility-inlines-hidden safe. This is no longer supported.])
+        fi
+    fi
+
+   AC_MSG_CHECKING([if $CXX_BASE has a visibility bug with class-level attributes (GCC bug 26905)])
+    cat >visibility.cxx <<_ACEOF
+#pragma GCC visibility push(hidden)
+struct __attribute__ ((visibility ("default"))) TestStruct {
+  static void Init();
+};
+__attribute__ ((visibility ("default"))) void TestFunc() {
+  TestStruct::Init();
+}
+_ACEOF
+    if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx; then
+        gccvisbroken=yes
+    else
+        case "$host_cpu" in
+        i?86|x86_64)
+            if test "$_os" = "Darwin" -o "$_os" = "iOS"; then
+                gccvisbroken=no
+            else
+                if $EGREP -q '@PLT|@GOT' visibility.s || test "$ENABLE_LTO" = "TRUE"; then
+                    gccvisbroken=no
+                else
+                    gccvisbroken=yes
+                fi
+            fi
+            ;;
+        *)
+            gccvisbroken=no
+            ;;
+        esac
+    fi
+    rm -f visibility.s visibility.cxx
+
+    AC_MSG_RESULT([$gccvisbroken])
+    if test "$gccvisbroken" = "yes"; then
+        AC_MSG_ERROR([Your gcc is not -fvisibility=hidden safe. This is no longer supported.])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+
+    AC_MSG_CHECKING([if CET endbranch is recognized])
+cat > endbr.s <<_ACEOF
+endbr32
+_ACEOF
+    HAVE_ASM_END_BRANCH_INS_SUPPORT=
+    if $CXX -c endbr.s -o endbr.o >/dev/null 2>&5; then
+        AC_MSG_RESULT([yes])
+        HAVE_ASM_END_BRANCH_INS_SUPPORT=TRUE
+    else
+        AC_MSG_RESULT([no])
+    fi
+    rm -f endbr.s endbr.o
+    AC_SUBST(HAVE_ASM_END_BRANCH_INS_SUPPORT)
+
+    AC_LANG_POP([C++])
+fi
+
+dnl ===================================================================
+dnl  Clang++ tests
+dnl ===================================================================
+
+HAVE_GCC_FNO_ENFORCE_EH_SPECS=
+if test "$GCC" = "yes"; then
+    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-enforce-eh-specs])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)
+
+dnl ===================================================================
+dnl Compiler plugins
+dnl ===================================================================
+
+COMPILER_PLUGINS=
+# currently only Clang
+
+if test "$COM_IS_CLANG" != "TRUE"; then
+    if test "$libo_fuzzed_enable_compiler_plugins" = yes -a "$enable_compiler_plugins" = yes; then
+        AC_MSG_NOTICE([Resetting --enable-compiler-plugins=no])
+        enable_compiler_plugins=no
+    fi
+fi
+
+COMPILER_PLUGINS_COM_IS_CLANG=
+if test "$COM_IS_CLANG" = "TRUE"; then
+    if test -n "$enable_compiler_plugins"; then
+        compiler_plugins="$enable_compiler_plugins"
+    elif test -n "$ENABLE_DBGUTIL"; then
+        compiler_plugins=test
+    else
+        compiler_plugins=no
+    fi
+    if test "$compiler_plugins" != no -a "$my_apple_clang" != yes; then
+        if test "$CLANGVER" -lt 120001; then
+            if test "$compiler_plugins" = yes; then
+                AC_MSG_ERROR(
+                    [Clang $CLANGVER is too old to build compiler plugins; need >= 12.0.1.])
+            else
+                compiler_plugins=no
+            fi
+        fi
+    fi
+    if test "$compiler_plugins" != "no"; then
+        dnl The prefix where Clang resides, override to where Clang resides if
+        dnl using a source build:
+        if test -z "$CLANGDIR"; then
+            CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $(printf '%s\n' $CXX | grep clang | head -n 1)))))
+        fi
+        # Assume Clang is self-built, but allow overriding COMPILER_PLUGINS_CXX to the compiler Clang was built with.
+        if test -z "$COMPILER_PLUGINS_CXX"; then
+            COMPILER_PLUGINS_CXX=[$(echo $CXX | sed -e 's/-fsanitize=[^ ]*//g')]
+        fi
+        clangbindir=$CLANGDIR/bin
+        if test "$build_os" = "cygwin"; then
+            clangbindir=$(cygpath -u "$clangbindir")
+        fi
+        AC_PATH_PROG(LLVM_CONFIG, llvm-config,[],"$clangbindir" $PATH)
+        if test -n "$LLVM_CONFIG"; then
+            COMPILER_PLUGINS_CXXFLAGS=$($LLVM_CONFIG --cxxflags)
+            COMPILER_PLUGINS_LINKFLAGS=$($LLVM_CONFIG --ldflags --libs --system-libs | tr '\n' ' ')
+            if test -z "$CLANGLIBDIR"; then
+                CLANGLIBDIR=$($LLVM_CONFIG --libdir)
+            fi
+            # Try if clang is built from source (in which case its includes are not together with llvm includes).
+            # src-root is [llvm-toplevel-src-dir]/llvm, clang is [llvm-toplevel-src-dir]/clang
+            if $LLVM_CONFIG --src-root >/dev/null 2>&1; then
+                clangsrcdir=$(dirname $($LLVM_CONFIG --src-root))
+                if test -n "$clangsrcdir" -a -d "$clangsrcdir" -a -d "$clangsrcdir/clang/include"; then
+                    COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangsrcdir/clang/include"
+                fi
+            fi
+            # obj-root is [llvm-toplevel-obj-dir]/, clang is [llvm-toplevel-obj-dir]/tools/clang
+            clangobjdir=$($LLVM_CONFIG --obj-root)
+            if test -n "$clangobjdir" -a -d "$clangobjdir" -a -d "$clangobjdir/tools/clang/include"; then
+                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangobjdir/tools/clang/include"
+            fi
+        fi
+        AC_MSG_NOTICE([compiler plugins compile flags: $COMPILER_PLUGINS_CXXFLAGS])
+        AC_LANG_PUSH([C++])
+        save_CXX=$CXX
+        save_CXXCPP=$CXXCPP
+        save_CPPFLAGS=$CPPFLAGS
+        save_CXXFLAGS=$CXXFLAGS
+        save_LDFLAGS=$LDFLAGS
+        save_LIBS=$LIBS
+        CXX=$COMPILER_PLUGINS_CXX
+        CXXCPP="$COMPILER_PLUGINS_CXX -E"
+        CPPFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
+        CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
+        AC_CHECK_HEADER(clang/Basic/SourceLocation.h,
+            [COMPILER_PLUGINS=TRUE],
+            [
+            if test "$compiler_plugins" = "yes"; then
+                AC_MSG_ERROR([Cannot find Clang headers to build compiler plugins.])
+            else
+                AC_MSG_WARN([Cannot find Clang headers to build compiler plugins, plugins disabled])
+                add_warning "Cannot find Clang headers to build compiler plugins, plugins disabled."
+            fi
+            ])
+        dnl TODO: Windows doesn't use LO_CLANG_SHARED_PLUGINS for now, see corresponding TODO
+        dnl comment in compilerplugins/Makefile-clang.mk:
+        if test -n "$COMPILER_PLUGINS" && test "$_os" != "WINNT"; then
+            LDFLAGS=""
+            AC_MSG_CHECKING([for clang libraries to use])
+            if test -z "$CLANGTOOLLIBS"; then
+                LIBS="-lclang-cpp $COMPILER_PLUGINS_LINKFLAGS"
+                AC_LINK_IFELSE([
+                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
+                        [[ clang::FullSourceLoc().dump(); ]])
+                ],[CLANGTOOLLIBS="$LIBS"],[])
+            fi
+            dnl If the above check for the combined -lclang-cpp failed, fall back to a hand-curated
+            dnl list of individual -lclang* (but note that that list can become outdated over time,
+            dnl see e.g. the since-reverted 5078591de9a0e65ca560a4f1913e90dfe95f66bf "CLANGTOOLLIBS
+            dnl needs to include -lclangSupport now"):
+            if test -z "$CLANGTOOLLIBS"; then
+                LIBS="-lclangTooling -lclangFrontend -lclangDriver -lclangParse -lclangSema -lclangEdit \
+ -lclangAnalysis -lclangAST -lclangLex -lclangSerialization -lclangBasic $COMPILER_PLUGINS_LINKFLAGS"
+                AC_LINK_IFELSE([
+                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
+                        [[ clang::FullSourceLoc().dump(); ]])
+                ],[CLANGTOOLLIBS="$LIBS"],[])
+            fi
+            AC_MSG_RESULT([$CLANGTOOLLIBS])
+            if test -z "$CLANGTOOLLIBS"; then
+                if test "$compiler_plugins" = "yes"; then
+                    AC_MSG_ERROR([Cannot find Clang libraries to build compiler plugins.])
+                else
+                    AC_MSG_WARN([Cannot find Clang libraries to build compiler plugins, plugins disabled])
+                    add_warning "Cannot find Clang libraries to build compiler plugins, plugins disabled."
+                fi
+                COMPILER_PLUGINS=
+            fi
+            if test -n "$COMPILER_PLUGINS"; then
+                if test -z "$CLANGSYSINCLUDE"; then
+                    if test -n "$LLVM_CONFIG"; then
+                        # Path to the clang system headers (no idea if there's a better way to get it).
+                        CLANGSYSINCLUDE=$($LLVM_CONFIG --libdir)/clang/$($LLVM_CONFIG --version | sed 's/git\|svn//')/include
+                    fi
+                fi
+            fi
+        fi
+        CXX=$save_CXX
+        CXXCPP=$save_CXXCPP
+        CPPFLAGS=$save_CPPFLAGS
+        CXXFLAGS=$save_CXXFLAGS
+        LDFLAGS=$save_LDFLAGS
+        LIBS="$save_LIBS"
+        AC_LANG_POP([C++])
+
+        AC_MSG_CHECKING([whether the compiler for building compilerplugins is actually Clang])
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+            #ifndef __clang__
+            you lose
+            #endif
+            int foo=42;
+            ]])],
+            [AC_MSG_RESULT([yes])
+             COMPILER_PLUGINS_COM_IS_CLANG=TRUE],
+            [AC_MSG_RESULT([no])])
+        AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
+    fi
+else
+    if test "$enable_compiler_plugins" = "yes"; then
+        AC_MSG_ERROR([Compiler plugins are currently supported only with the Clang compiler.])
+    fi
+fi
+COMPILER_PLUGINS_ANALYZER_PCH=
+if test "$enable_compiler_plugins_analyzer_pch" != no; then
+    COMPILER_PLUGINS_ANALYZER_PCH=TRUE
+fi
+AC_SUBST(COMPILER_PLUGINS)
+AC_SUBST(COMPILER_PLUGINS_ANALYZER_PCH)
+AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
+AC_SUBST(COMPILER_PLUGINS_CXX)
+AC_SUBST(COMPILER_PLUGINS_CXXFLAGS)
+AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
+AC_SUBST(COMPILER_PLUGINS_DEBUG)
+AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
+AC_SUBST(CLANGDIR)
+AC_SUBST(CLANGLIBDIR)
+AC_SUBST(CLANGTOOLLIBS)
+AC_SUBST(CLANGSYSINCLUDE)
+
+# Plugin to help linker.
+# Add something like LD_PLUGIN=/usr/lib64/LLVMgold.so to your autogen.input.
+# This makes --enable-lto build with clang work.
+AC_SUBST(LD_PLUGIN)
+
+AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
+AC_SUBST(HAVE_POSIX_FALLOCATE)
+
+JITC_PROCESSOR_TYPE=""
+if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
+    # IBMs JDK needs this...
+    JITC_PROCESSOR_TYPE=6
+    export JITC_PROCESSOR_TYPE
+fi
+AC_SUBST([JITC_PROCESSOR_TYPE])
+
+# Misc Windows Stuff
+AC_ARG_WITH(ucrt-dir,
+    AS_HELP_STRING([--with-ucrt-dir],
+        [path to the directory with the arch-specific MSU packages of the Windows Universal CRT redistributables
+        (MS KB 2999226) for packaging into the installsets (without those the target system needs to install
+        the UCRT or Visual C++ Runtimes manually). The directory must contain the following 6 files:
+            Windows6.1-KB2999226-x64.msu
+            Windows6.1-KB2999226-x86.msu
+            Windows8.1-KB2999226-x64.msu
+            Windows8.1-KB2999226-x86.msu
+            Windows8-RT-KB2999226-x64.msu
+            Windows8-RT-KB2999226-x86.msu
+        A zip archive including those files is available from Microsoft site:
+        https://www.microsoft.com/en-us/download/details.aspx?id=48234]),
+,)
+
+UCRT_REDISTDIR="$with_ucrt_dir"
+if test $_os = "WINNT"; then
+    find_msvc_x64_dlls
+    MSVC_DLL_PATH=`win_short_path_for_make "$msvcdllpath"`
+    MSVC_DLLS="$msvcdlls"
+    if echo "$msvcdllpath" | grep -q "VC143.CRT$"; then
+        with_redist=143
+    elif echo "$msvcdllpath" | grep -q "VC142.CRT$"; then
+        with_redist=142
+    elif echo "$msvcdllpath" | grep -q "VC141.CRT$"; then
+        with_redist=141
+    fi
+    for i in $PKGFORMAT; do
+        if test "$i" = msi; then
+            find_msms "$with_redist"
+            if test -n "$msmdir"; then
+                MSM_PATH=`win_short_path_for_make "$msmdir"`
+                SCPDEFS="$SCPDEFS -DWITH_VC_REDIST=$with_redist"
+            fi
+            break
+        fi
+    done
+
+    if test "$UCRT_REDISTDIR" = "no"; then
+        dnl explicitly disabled
+        UCRT_REDISTDIR=""
+    else
+        if ! test -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x64.msu" -a \
+                  -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x86.msu" -a \
+                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x64.msu" -a \
+                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x86.msu" -a \
+                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x64.msu" -a \
+                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x86.msu"; then
+            UCRT_REDISTDIR=""
+            if test -n "$PKGFORMAT"; then
+               for i in $PKGFORMAT; do
+                   case "$i" in
+                   msi)
+                       AC_MSG_WARN([--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency])
+                       add_warning "--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency"
+                       ;;
+                   esac
+               done
+            fi
+        fi
+    fi
+fi
+
+AC_SUBST(UCRT_REDISTDIR)
+AC_SUBST(MSVC_DLL_PATH)
+AC_SUBST(MSVC_DLLS)
+AC_SUBST(MSM_PATH)
+
+
+dnl ===================================================================
+dnl Checks for Java
+dnl ===================================================================
+if test "$ENABLE_JAVA" != ""; then
+
+    # Windows-specific tests
+    if test "$build_os" = "cygwin"; then
+        if test -z "$with_jdk_home"; then
+            dnl See <https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-EEED398E-AE37-4D12-
+            dnl AB10-49F82F720027> section "Windows Registry Key Changes":
+            reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/CurrentVersion"
+            if test -n "$regvalue"; then
+                ver=$regvalue
+                reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/$ver/JavaHome"
+                with_jdk_home=$regvalue
+            fi
+            howfound="found automatically"
+        else
+            with_jdk_home=`win_short_path_for_make "$with_jdk_home"`
+            howfound="you passed"
+        fi
+
+        if ! test -f "$with_jdk_home/lib/jvm.lib" -a -f "$with_jdk_home/bin/java.exe"; then
+            AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option (or fix the path) pointing to a $WIN_HOST_BITS-bit JDK >= 17])
+        fi
+    fi
+
+    # macOS: /usr/libexec/java_home helps to set the current JDK_HOME. Actually JDK_HOME should NOT be set where java (/usr/bin/java) is located.
+    # /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, but /usr does not contain the JDK libraries
+    if test -z "$with_jdk_home" -a "$_os" = "Darwin" -a -x /usr/libexec/java_home; then
+        with_jdk_home=`/usr/libexec/java_home`
+    fi
+
+    JAVA_HOME=; export JAVA_HOME
+    if test -z "$with_jdk_home"; then
+        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
+    else
+        _java_path="$with_jdk_home/bin/$with_java"
+        dnl Check if there is a Java interpreter at all.
+        if test -x "$_java_path"; then
+            JAVAINTERPRETER=$_java_path
+        else
+            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
+        fi
+    fi
+
+    dnl Check that the JDK found is correct architecture (at least 2 reasons to
+    dnl check: officebean needs to link -ljawt, and libjpipe.so needs to be
+    dnl loaded by java to run JunitTests:
+    if test "$build_os" = "cygwin" -a "$cross_compiling" != "yes"; then
+        shortjdkhome=`cygpath -d "$with_jdk_home"`
+        if test $WIN_HOST_BITS -eq 64 -a -f "$with_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
+            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
+            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
+        elif test $WIN_HOST_BITS -eq 32 -a -f "$with_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
+            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
+            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
+        fi
+
+        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
+            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
+        fi
+        JAVAINTERPRETER=`win_short_path_for_make "$JAVAINTERPRETER"`
+    elif test "$cross_compiling" != "yes"; then
+        case $CPUNAME in
+            AARCH64|AXP|X86_64|IA64|POWERPC64|S390X|SPARC64|MIPS64|RISCV64|LOONGARCH64)
+                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
+                    AC_MSG_WARN([You are building 64-bit binaries but the JDK $JAVAINTERPRETER is 32-bit])
+                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
+                fi
+                ;;
+            *) # assumption: everything else 32-bit
+                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
+                    AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
+                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
+                fi
+                ;;
+        esac
+    fi
+fi
+
+dnl ===================================================================
+dnl Checks for JDK.
+dnl ===================================================================
+
+# Whether all the complexity here actually is needed any more or not, no idea.
+
+JDK_SECURITYMANAGER_DISALLOWED=
+if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
+    _gij_longver=0
+    AC_MSG_CHECKING([the installed JDK])
+    if test -n "$JAVAINTERPRETER"; then
+        dnl java -version sends output to stderr!
+        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
+            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
+        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
+            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
+        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
+            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
+        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
+            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
+        else
+            JDK=sun
+
+            dnl Sun JDK specific tests
+            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
+            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
+
+            if test "$_jdk_ver" -lt 170000; then
+                AC_MSG_ERROR([JDK is too old, you need at least 17 ($_jdk_ver < 170000)])
+            fi
+            dnl TODO: Presumably, the Security Manager will not merely be disallowed, but be
+            dnl completely removed in some Java version > 18 (see
+            dnl <https://openjdk.java.net/jeps/411> "Deprecate the Security Manager for Removal"):
+            if test "$_jdk_ver" -ge 180000; then
+                JDK_SECURITYMANAGER_DISALLOWED=TRUE
+            fi
+
+            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
+            if test "$_os" = "WINNT"; then
+                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
+            fi
+            AC_MSG_RESULT([found $JAVA_HOME (JDK $_jdk)])
+
+            # set to limit VM usage for JunitTests
+            JAVAIFLAGS=-Xmx64M
+            # set to limit VM usage for javac
+            JAVACFLAGS=-J-Xmx128M
+        fi
+    else
+        AC_MSG_ERROR([Java not found. You need at least JDK 17])
+    fi
+else
+    if test -z "$ENABLE_JAVA"; then
+        dnl Java disabled
+        JAVA_HOME=
+        export JAVA_HOME
+    elif test "$cross_compiling" = "yes"; then
+        # Just assume compatibility of build and host JDK
+        JDK=$JDK_FOR_BUILD
+        JAVAIFLAGS=$JAVAIFLAGS_FOR_BUILD
+    fi
+fi
+
+dnl ===================================================================
+dnl Checks for javac
+dnl ===================================================================
+if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
+    javacompiler="javac"
+    : ${JAVA_SOURCE_VER=8}
+    : ${JAVA_TARGET_VER=8}
+    if test -z "$with_jdk_home"; then
+        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
+    else
+        _javac_path="$with_jdk_home/bin/$javacompiler"
+        dnl Check if there is a Java compiler at all.
+        if test -x "$_javac_path"; then
+            JAVACOMPILER=$_javac_path
+        fi
+    fi
+    if test -z "$JAVACOMPILER"; then
+        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
+    fi
+    if test "$build_os" = "cygwin"; then
+        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
+            JAVACOMPILER="${JAVACOMPILER}.exe"
+        fi
+        JAVACOMPILER=`win_short_path_for_make "$JAVACOMPILER"`
+    fi
+fi
+
+dnl ===================================================================
+dnl Checks for javadoc
+dnl ===================================================================
+if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
+    if test -z "$with_jdk_home"; then
+        AC_PATH_PROG(JAVADOC, javadoc)
+    else
+        _javadoc_path="$with_jdk_home/bin/javadoc"
+        dnl Check if there is a javadoc at all.
+        if test -x "$_javadoc_path"; then
+            JAVADOC=$_javadoc_path
+        else
+            AC_PATH_PROG(JAVADOC, javadoc)
+        fi
+    fi
+    if test -z "$JAVADOC"; then
+        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
+    fi
+    if test "$build_os" = "cygwin"; then
+        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
+            JAVADOC="${JAVADOC}.exe"
+        fi
+        JAVADOC=`win_short_path_for_make "$JAVADOC"`
+    fi
+
+    if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then
+    JAVADOCISGJDOC="yes"
+    fi
+fi
+AC_SUBST(JAVADOC)
+AC_SUBST(JAVADOCISGJDOC)
+
+if test "$ENABLE_JAVA" != "" -a \( "$cross_compiling" != "yes" -o -n "$with_jdk_home" \); then
+    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
+    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
+        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
+           # try to recover first by looking whether we have an alternative
+           # system as in Debian or newer SuSEs where following /usr/bin/javac
+           # over /etc/alternatives/javac leads to the right bindir where we
+           # just need to strip a bit away to get a valid JAVA_HOME
+           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
+        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
+            # maybe only one level of symlink (e.g. on Mac)
+            JAVA_HOME=$(readlink $JAVACOMPILER)
+            if test "$(dirname $JAVA_HOME)" = "."; then
+                # we've got no path to trim back
+                JAVA_HOME=""
+            fi
+        else
+            # else warn
+            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
+            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
+            add_warning "JAVA_HOME is set to /usr - this is very likely to be incorrect"
+            add_warning "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home"
+        fi
+        dnl now that we probably have the path to the real javac, make a JAVA_HOME out of it...
+        if test "$JAVA_HOME" != "/usr"; then
+            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
+                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
+                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
+                dnl Tiger already returns a JDK path...
+                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
+            else
+                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
+                dnl check that we have a directory as certain distros eg gentoo substitute javac for a script
+                dnl that checks which version to run
+                if test -f "$JAVA_HOME"; then
+                    JAVA_HOME=""; # set JAVA_HOME to null if it's a file
+                fi
+            fi
+        fi
+    fi
+    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink
+
+    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
+    if test -z "$JAVA_HOME"; then
+        if test "x$with_jdk_home" = "x"; then
+            cat > findhome.java <<_ACEOF
+[import java.io.File;
+
+class findhome
+{
+    public static void main(String args[])
+    {
+        String jrelocation = System.getProperty("java.home");
+        File jre = new File(jrelocation);
+        System.out.println(jre.getParent());
+    }
+}]
+_ACEOF
+            AC_MSG_CHECKING([if javac works])
+            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
+            AC_TRY_EVAL(javac_cmd)
+            if test $? = 0 -a -f ./findhome.class; then
+                AC_MSG_RESULT([javac works])
+            else
+                echo "configure: javac test failed" >&5
+                cat findhome.java >&5
+                AC_MSG_ERROR([javac does not work - java projects will not build!])
+            fi
+            AC_MSG_CHECKING([if gij knows its java.home])
+            JAVA_HOME=`$JAVAINTERPRETER findhome`
+            if test $? = 0 -a "$JAVA_HOME" != ""; then
+                AC_MSG_RESULT([$JAVA_HOME])
+            else
+                echo "configure: java test failed" >&5
+                cat findhome.java >&5
+                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
+            fi
+            # clean-up after ourselves
+            rm -f ./findhome.java ./findhome.class
+        else
+            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
+        fi
+    fi
+
+    # now check if $JAVA_HOME is really valid
+    if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
+        if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
+            AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
+            AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
+            AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects will not be built correctly])
+            add_warning "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script"
+            add_warning "attempted to find JAVA_HOME automatically, but apparently it failed"
+            add_warning "in case JAVA_HOME is incorrectly set, some projects will not be built correctly"
+        fi
+    fi
+    PathFormat "$JAVA_HOME"
+    JAVA_HOME="$formatted_path"
+fi
+
+if test -z "$JAWTLIB" -a -n "$ENABLE_JAVA" -a "$_os" != Android -a \
+    "$_os" != Darwin
+then
+    AC_MSG_CHECKING([for JAWT lib])
+    if test "$_os" = WINNT; then
+        # The path to $JAVA_HOME/lib/$JAWTLIB is part of $ILIB:
+        JAWTLIB=jawt.lib
+    else
+        case "$host_cpu" in
+        arm*)
+            AS_IF([test -e "$JAVA_HOME/jre/lib/aarch32/libjawt.so"], [my_java_arch=aarch32], [my_java_arch=arm])
+            JAVA_ARCH=$my_java_arch
+            ;;
+        i*86)
+            my_java_arch=i386
+            ;;
+        m68k)
+            my_java_arch=m68k
+            ;;
+        powerpc)
+            my_java_arch=ppc
+            ;;
+        powerpc64)
+            my_java_arch=ppc64
+            ;;
+        powerpc64le)
+            AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
+            JAVA_ARCH=$my_java_arch
+            ;;
+        sparc64)
+            my_java_arch=sparcv9
+            ;;
+        x86_64)
+            my_java_arch=amd64
+            ;;
+        *)
+            my_java_arch=$host_cpu
+            ;;
+        esac
+        # This is where JDK9 puts the library
+        if test -e "$JAVA_HOME/lib/libjawt.so"; then
+            JAWTLIB="-L$JAVA_HOME/lib/ -ljawt"
+        else
+            JAWTLIB="-L$JAVA_HOME/jre/lib/$my_java_arch -ljawt"
+        fi
+        AS_IF([test "$JAVA_ARCH" != ""], [AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$JAVA_ARCH"])])
+    fi
+    AC_MSG_RESULT([$JAWTLIB])
+fi
+AC_SUBST(JAWTLIB)
+
+if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then
+    case "$host_os" in
+
+    cygwin*|wsl*)
+        JAVAINC="-I$JAVA_HOME/include/win32"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include"
+        ;;
+
+    darwin*)
+        if test -d "$JAVA_HOME/include/darwin"; then
+            JAVAINC="-I$JAVA_HOME/include  -I$JAVA_HOME/include/darwin"
+        else
+            JAVAINC=${ISYSTEM}$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers
+        fi
+        ;;
+
+    dragonfly*)
+        JAVAINC="-I$JAVA_HOME/include"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+        ;;
+
+    freebsd*)
+        JAVAINC="-I$JAVA_HOME/include"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/freebsd"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/bsd"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+        ;;
+
+    k*bsd*-gnu*)
+        JAVAINC="-I$JAVA_HOME/include"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+        ;;
+
+    linux-gnu*)
+        JAVAINC="-I$JAVA_HOME/include"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+        ;;
+
+    *netbsd*)
+        JAVAINC="-I$JAVA_HOME/include"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/netbsd"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+       ;;
+
+    openbsd*)
+        JAVAINC="-I$JAVA_HOME/include"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/openbsd"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+        ;;
+
+    solaris*)
+        JAVAINC="-I$JAVA_HOME/include"
+        JAVAINC="$JAVAINC -I$JAVA_HOME/include/solaris"
+        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
+        ;;
+    esac
+fi
+SOLARINC="$SOLARINC $JAVAINC"
+
+if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
+    JAVA_HOME_FOR_BUILD=$JAVA_HOME
+    JAVAIFLAGS_FOR_BUILD=$JAVAIFLAGS
+    JDK_FOR_BUILD=$JDK
+    JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD=$JDK_SECURITYMANAGER_DISALLOWED
+fi
+
+AC_SUBST(JAVACFLAGS)
+AC_SUBST(JAVACOMPILER)
+AC_SUBST(JAVAINTERPRETER)
+AC_SUBST(JAVAIFLAGS)
+AC_SUBST(JAVAIFLAGS_FOR_BUILD)
+AC_SUBST(JAVA_HOME)
+AC_SUBST(JAVA_HOME_FOR_BUILD)
+AC_SUBST(JDK)
+AC_SUBST(JDK_FOR_BUILD)
+AC_SUBST(JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD)
+AC_SUBST(JAVA_SOURCE_VER)
+AC_SUBST(JAVA_TARGET_VER)
+
+
+dnl ===================================================================
+dnl Export file validation
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable export file validation])
+if test "$with_export_validation" != "no"; then
+    if test -z "$ENABLE_JAVA"; then
+        if test "$with_export_validation" = "yes"; then
+            AC_MSG_ERROR([requested, but Java is disabled])
+        else
+            AC_MSG_RESULT([no, as Java is disabled])
+        fi
+    elif ! test -d "${SRC_ROOT}/schema"; then
+        if test "$with_export_validation" = "yes"; then
+            AC_MSG_ERROR([requested, but schema directory is missing (it is excluded from tarballs)])
+        else
+            AC_MSG_RESULT([no, schema directory is missing (it is excluded from tarballs)])
+        fi
+    else
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_EXPORT_VALIDATION)
+
+        AC_PATH_PROGS(ODFVALIDATOR, odfvalidator)
+        if test -z "$ODFVALIDATOR"; then
+            # remember to download the ODF toolkit with validator later
+            AC_MSG_NOTICE([no odfvalidator found, will download it])
+            BUILD_TYPE="$BUILD_TYPE ODFVALIDATOR"
+            ODFVALIDATOR="$BUILDDIR/bin/odfvalidator.sh"
+
+            # and fetch name of odfvalidator jar name from download.lst
+            ODFVALIDATOR_JAR=`$SED -n -e "s/^ODFVALIDATOR_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
+            AC_SUBST(ODFVALIDATOR_JAR)
+
+            if test -z "$ODFVALIDATOR_JAR"; then
+                AC_MSG_ERROR([cannot determine odfvalidator jar location (--with-export-validation)])
+            fi
+        fi
+        if test "$build_os" = "cygwin"; then
+            # In case of Cygwin it will be executed from Windows,
+            # so we need to run bash and absolute path to validator
+            # so instead of "odfvalidator" it will be
+            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
+            ODFVALIDATOR="bash.exe `cygpath -m "$ODFVALIDATOR"`"
+        else
+            ODFVALIDATOR="sh $ODFVALIDATOR"
+        fi
+        AC_SUBST(ODFVALIDATOR)
+
+
+        AC_PATH_PROGS(OFFICEOTRON, officeotron)
+        if test -z "$OFFICEOTRON"; then
+            # remember to download the officeotron with validator later
+            AC_MSG_NOTICE([no officeotron found, will download it])
+            BUILD_TYPE="$BUILD_TYPE OFFICEOTRON"
+            OFFICEOTRON="$BUILDDIR/bin/officeotron.sh"
+
+            # and fetch name of officeotron jar name from download.lst
+            OFFICEOTRON_JAR=`$SED -n -e "s/^OFFICEOTRON_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
+            AC_SUBST(OFFICEOTRON_JAR)
+
+            if test -z "$OFFICEOTRON_JAR"; then
+                AC_MSG_ERROR([cannot determine officeotron jar location (--with-export-validation)])
+            fi
+        else
+            # check version of existing officeotron
+            OFFICEOTRON_VER=`$OFFICEOTRON --version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
+            if test 0"$OFFICEOTRON_VER" -lt 704; then
+                AC_MSG_ERROR([officeotron too old])
+            fi
+        fi
+        if test "$build_os" = "cygwin"; then
+            # In case of Cygwin it will be executed from Windows,
+            # so we need to run bash and absolute path to validator
+            # so instead of "odfvalidator" it will be
+            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
+            OFFICEOTRON="bash.exe `cygpath -m "$OFFICEOTRON"`"
+        else
+            OFFICEOTRON="sh $OFFICEOTRON"
+        fi
+    fi
+    AC_SUBST(OFFICEOTRON)
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_MSG_CHECKING([for Microsoft Binary File Format Validator])
+if test "$with_bffvalidator" != "no"; then
+    AC_DEFINE(HAVE_BFFVALIDATOR)
+
+    if test "$with_export_validation" = "no"; then
+        AC_MSG_ERROR([Please enable export validation (-with-export-validation)!])
+    fi
+
+    if test "$with_bffvalidator" = "yes"; then
+        BFFVALIDATOR=`win_short_path_for_make "$PROGRAMFILES/Microsoft Office/BFFValidator/BFFValidator.exe"`
+    else
+        BFFVALIDATOR="$with_bffvalidator"
+    fi
+
+    if test "$build_os" = "cygwin"; then
+        if test -n "$BFFVALIDATOR" -a -e "`cygpath $BFFVALIDATOR`"; then
+            AC_MSG_RESULT($BFFVALIDATOR)
+        else
+            AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
+        fi
+    elif test -n "$BFFVALIDATOR"; then
+        # We are not in Cygwin but need to run Windows binary with wine
+        AC_PATH_PROGS(WINE, wine)
+
+        # so swap in a shell wrapper that converts paths transparently
+        BFFVALIDATOR_EXE="$BFFVALIDATOR"
+        BFFVALIDATOR="sh $BUILDDIR/bin/bffvalidator.sh"
+        AC_SUBST(BFFVALIDATOR_EXE)
+        AC_MSG_RESULT($BFFVALIDATOR)
+    else
+        AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
+    fi
+    AC_SUBST(BFFVALIDATOR)
+else
+    AC_MSG_RESULT([no])
+fi
+
+dnl ===================================================================
+dnl Check for epm (not needed for Windows)
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable EPM for packing])
+if test "$enable_epm" = "yes"; then
+    AC_MSG_RESULT([yes])
+    if test "$_os" != "WINNT"; then
+        if test $_os = Darwin; then
+            EPM=internal
+        elif test -n "$with_epm"; then
+            EPM=$with_epm
+        else
+            AC_PATH_PROG(EPM, epm, no)
+        fi
+        if test "$EPM" = "no" -o "$EPM" = "internal"; then
+            AC_MSG_NOTICE([EPM will be built.])
+            BUILD_TYPE="$BUILD_TYPE EPM"
+            EPM=${WORKDIR}/UnpackedTarball/epm/epm
+        else
+            # Gentoo has some epm which is something different...
+            AC_MSG_CHECKING([whether the found epm is the right epm])
+            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
+                AC_MSG_RESULT([yes])
+            else
+                AC_MSG_ERROR([no. Install ESP Package Manager (https://jimjag.github.io/epm/) and/or specify the path to the right epm])
+            fi
+            AC_MSG_CHECKING([epm version])
+            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
+            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
+               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
+                AC_MSG_RESULT([OK, >= 3.7])
+            else
+                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
+                AC_MSG_ERROR([Install ESP Package Manager (https://jimjag.github.io/epm/) and/or specify the path to the right epm])
+            fi
+        fi
+    fi
+
+    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
+        AC_MSG_CHECKING([for rpm])
+        for a in "$RPM" rpmbuild rpm; do
+            $a --usage >/dev/null 2> /dev/null
+            if test $? -eq 0; then
+                RPM=$a
+                break
+            else
+                $a --version >/dev/null 2> /dev/null
+                if test $? -eq 0; then
+                    RPM=$a
+                    break
+                fi
+            fi
+        done
+        if test -z "$RPM"; then
+            AC_MSG_ERROR([not found])
+        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
+            RPM_PATH=`which $RPM`
+            AC_MSG_RESULT([$RPM_PATH])
+            SCPDEFS="$SCPDEFS -DWITH_RPM"
+        else
+            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
+        fi
+    fi
+    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
+        AC_PATH_PROG(DPKG, dpkg, no)
+        if test "$DPKG" = "no"; then
+            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
+        fi
+    fi
+    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
+       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
+        if test "$with_epm" = "no" -a "$_os" != "Darwin"; then
+            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
+                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
+                if grep "Patched for .*Office" $EPM >/dev/null 2>/dev/null; then
+                    AC_MSG_RESULT([yes])
+                else
+                    AC_MSG_RESULT([no])
+                    if echo "$PKGFORMAT" | $GREP -q rpm; then
+                        _pt="rpm"
+                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
+                        add_warning "the rpms will need to be installed with --nodeps"
+                    else
+                        _pt="pkg"
+                    fi
+                    AC_MSG_WARN([the ${_pt}s will not be relocatable])
+                    add_warning "the ${_pt}s will not be relocatable"
+                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
+                                 relocation will work, you need to patch your epm with the
+                                 patch in epm/epm-3.7.patch or build with
+                                 --with-epm=internal which will build a suitable epm])
+                fi
+            fi
+        fi
+    fi
+    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
+        AC_PATH_PROG(PKGMK, pkgmk, no)
+        if test "$PKGMK" = "no"; then
+            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
+        fi
+    fi
+    AC_SUBST(RPM)
+    AC_SUBST(DPKG)
+    AC_SUBST(PKGMK)
+else
+    for i in $PKGFORMAT; do
+        case "$i" in
+        bsd | deb | pkg | rpm | native | portable)
+            AC_MSG_ERROR(
+                [--with-package-format='$PKGFORMAT' requires --enable-epm])
+            ;;
+        esac
+    done
+    AC_MSG_RESULT([no])
+    EPM=NO
+fi
+AC_SUBST(EPM)
+
+ENABLE_LWP=
+if test "$enable_lotuswordpro" = "yes"; then
+    ENABLE_LWP="TRUE"
+fi
+AC_SUBST(ENABLE_LWP)
+
+dnl ===================================================================
+dnl Check for building ODK
+dnl ===================================================================
+AC_MSG_CHECKING([whether to build the ODK])
+if test "$enable_odk" = yes; then
+    if test "$DISABLE_DYNLOADING" = TRUE; then
+        AC_MSG_ERROR([can't build ODK for --disable-dynamic-loading builds])
+    fi
+    AC_MSG_RESULT([yes])
+    BUILD_TYPE="$BUILD_TYPE ODK"
+else
+    AC_MSG_RESULT([no])
+fi
+
+if test "$enable_odk" != yes; then
+    unset DOXYGEN
+else
+    if test "$with_doxygen" = no; then
+        AC_MSG_CHECKING([for doxygen])
+        unset DOXYGEN
+        AC_MSG_RESULT([no])
+    else
+        if test "$with_doxygen" = yes; then
+            AC_PATH_PROG([DOXYGEN], [doxygen])
+            if test -z "$DOXYGEN"; then
+                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
+            fi
+            if $DOXYGEN -g - | grep -q "HAVE_DOT *= *YES"; then
+                if ! dot -V 2>/dev/null; then
+                    AC_MSG_ERROR([dot not found in \$PATH but doxygen defaults to HAVE_DOT=YES; install graphviz or disable its use via --without-doxygen])
+                fi
+            fi
+        else
+            AC_MSG_CHECKING([for doxygen])
+            DOXYGEN=$with_doxygen
+            AC_MSG_RESULT([$DOXYGEN])
+        fi
+        if test -n "$DOXYGEN"; then
+            DOXYGEN_VERSION=`$DOXYGEN --version 2>/dev/null`
+            DOXYGEN_NUMVERSION=`echo $DOXYGEN_VERSION | $AWK -F. '{ print \$1*10000 + \$2*100 + \$3 }'`
+            if ! test "$DOXYGEN_NUMVERSION" -ge "10804" ; then
+                AC_MSG_ERROR([found doxygen is too old; need at least version 1.8.4 or specify --without-doxygen])
+            fi
+        fi
+    fi
+fi
+AC_SUBST([DOXYGEN])
+
+dnl ==================================================================
+dnl libfuzzer
+dnl ==================================================================
+AC_MSG_CHECKING([whether to enable fuzzers])
+if test "$enable_fuzzers" != yes; then
+    AC_MSG_RESULT([no])
+else
+    if test -z $LIB_FUZZING_ENGINE; then
+      AC_MSG_ERROR(['LIB_FUZZING_ENGINE' must be set when using --enable-fuzzers. Examples include '-fsanitize=fuzzer'.])
+    fi
+    AC_MSG_RESULT([yes])
+    ENABLE_FUZZERS="TRUE"
+    AC_DEFINE([ENABLE_FUZZERS],1)
+    BUILD_TYPE="$BUILD_TYPE FUZZERS"
+fi
+AC_SUBST(LIB_FUZZING_ENGINE)
+
+dnl ===================================================================
+dnl Check for system zlib
+dnl ===================================================================
+if test "$with_system_zlib" = "auto"; then
+    case "$_os" in
+    WINNT)
+        with_system_zlib="$with_system_libs"
+        ;;
+    *)
+        if test "$enable_fuzzers" != "yes"; then
+            with_system_zlib=yes
+        else
+            with_system_zlib=no
+        fi
+        ;;
+    esac
+fi
+
+dnl we want to use libo_CHECK_SYSTEM_MODULE here too, but macOS is too stupid
+dnl and has no pkg-config for it at least on some tinderboxes,
+dnl so leaving that out for now
+dnl libo_CHECK_SYSTEM_MODULE([zlib],[ZLIB],[zlib])
+AC_MSG_CHECKING([which zlib to use])
+if test "$with_system_zlib" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_ZLIB=TRUE
+    AC_CHECK_HEADER(zlib.h, [],
+        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
+    AC_CHECK_LIB(z, deflate, [ ZLIB_LIBS=-lz ],
+        [AC_MSG_ERROR(zlib not found or functional)], [])
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_ZLIB=
+    BUILD_TYPE="$BUILD_TYPE ZLIB"
+    ZLIB_CFLAGS="-I${WORKDIR}/UnpackedTarball/zlib"
+    if test "$COM" = "MSC"; then
+        ZLIB_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/zlib.lib"
+    else
+        ZLIB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lzlib"
+    fi
+fi
+AC_SUBST(ZLIB_CFLAGS)
+AC_SUBST(ZLIB_LIBS)
+AC_SUBST(SYSTEM_ZLIB)
+
+dnl ===================================================================
+dnl Check for system jpeg
+dnl ===================================================================
+AC_MSG_CHECKING([which libjpeg to use])
+if test "$with_system_jpeg" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_LIBJPEG=TRUE
+    AC_CHECK_HEADER(jpeglib.h, [ LIBJPEG_CFLAGS= ],
+        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
+    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ LIBJPEG_LIBS="-ljpeg" ],
+        [AC_MSG_ERROR(jpeg library not found or functional)], [])
+else
+    SYSTEM_LIBJPEG=
+    AC_MSG_RESULT([internal, libjpeg-turbo])
+    BUILD_TYPE="$BUILD_TYPE LIBJPEG_TURBO"
+
+    case "$host_cpu" in
+    x86_64 | amd64 | i*86 | x86 | ia32)
+        AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
+        if test -z "$NASM" -a "$build_os" = "cygwin"; then
+            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/nasm"; then
+                NASM="$LODE_HOME/opt/bin/nasm"
+            elif test -x "/opt/lo/bin/nasm"; then
+                NASM="/opt/lo/bin/nasm"
+            fi
+        fi
+
+        if test -n "$NASM"; then
+            AC_MSG_CHECKING([for object file format of host system])
+            case "$host_os" in
+              cygwin* | mingw* | pw32* | wsl*)
+                case "$host_cpu" in
+                  x86_64)
+                    objfmt='Win64-COFF'
+                    ;;
+                  *)
+                    objfmt='Win32-COFF'
+                    ;;
+                esac
+              ;;
+              msdosdjgpp* | go32*)
+                objfmt='COFF'
+              ;;
+              os2-emx*) # not tested
+                objfmt='MSOMF' # obj
+              ;;
+              linux*coff* | linux*oldld*)
+                objfmt='COFF' # ???
+              ;;
+              linux*aout*)
+                objfmt='a.out'
+              ;;
+              linux*)
+                case "$host_cpu" in
+                  x86_64)
+                    objfmt='ELF64'
+                    ;;
+                  *)
+                    objfmt='ELF'
+                    ;;
+                esac
+              ;;
+              kfreebsd* | freebsd* | netbsd* | openbsd*)
+                if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+                  objfmt='BSD-a.out'
+                else
+                  case "$host_cpu" in
+                    x86_64 | amd64)
+                      objfmt='ELF64'
+                      ;;
+                    *)
+                      objfmt='ELF'
+                      ;;
+                  esac
+                fi
+              ;;
+              solaris* | sunos* | sysv* | sco*)
+                case "$host_cpu" in
+                  x86_64)
+                    objfmt='ELF64'
+                    ;;
+                  *)
+                    objfmt='ELF'
+                    ;;
+                esac
+              ;;
+              darwin* | rhapsody* | nextstep* | openstep* | macos*)
+                case "$host_cpu" in
+                  x86_64)
+                    objfmt='Mach-O64'
+                    ;;
+                  *)
+                    objfmt='Mach-O'
+                    ;;
+                esac
+              ;;
+              *)
+                objfmt='ELF ?'
+              ;;
+            esac
+
+            AC_MSG_RESULT([$objfmt])
+            if test "$objfmt" = 'ELF ?'; then
+              objfmt='ELF'
+              AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
+            fi
+
+            AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
+            case "$objfmt" in
+              MSOMF)      NAFLAGS='-fobj -DOBJ32 -DPIC';;
+              Win32-COFF) NAFLAGS='-fwin32 -DWIN32 -DPIC';;
+              Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__ -DPIC';;
+              COFF)       NAFLAGS='-fcoff -DCOFF -DPIC';;
+              a.out)      NAFLAGS='-faout -DAOUT -DPIC';;
+              BSD-a.out)  NAFLAGS='-faoutb -DAOUT -DPIC';;
+              ELF)        NAFLAGS='-felf -DELF -DPIC';;
+              ELF64)      NAFLAGS='-felf64 -DELF -D__x86_64__ -DPIC';;
+              RDF)        NAFLAGS='-frdf -DRDF -DPIC';;
+              Mach-O)     NAFLAGS='-fmacho -DMACHO -DPIC';;
+              Mach-O64)   NAFLAGS='-fmacho64 -DMACHO -D__x86_64__ -DPIC';;
+            esac
+            AC_MSG_RESULT([$NAFLAGS])
+
+            AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
+            cat > conftest.asm << EOF
+            [%line __oline__ "configure"
+                    section .text
+                    global  _main,main
+            _main:
+            main:   xor     eax,eax
+                    ret
+            ]
+EOF
+            try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
+            if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
+              AC_MSG_RESULT(yes)
+            else
+              echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
+              cat conftest.asm >&AS_MESSAGE_LOG_FD
+              rm -rf conftest*
+              AC_MSG_RESULT(no)
+              AC_MSG_WARN([installation or configuration problem: assembler cannot create object files.])
+              NASM=""
+            fi
+
+        fi
+
+        if test -z "$NASM"; then
+cat << _EOS
+****************************************************************************
+You need yasm or nasm (Netwide Assembler) to build the internal jpeg library optimally.
+To get one please:
+
+_EOS
+            if test "$build_os" = "cygwin"; then
+cat << _EOS
+install a pre-compiled binary for Win32
+
+mkdir -p /opt/lo/bin
+cd /opt/lo/bin
+wget https://dev-www.libreoffice.org/bin/cygwin/nasm.exe
+chmod +x nasm
+
+or get and install one from https://www.nasm.us/
+
+Then re-run autogen.sh
+
+Note: autogen.sh will try to use /opt/lo/bin/nasm if the environment variable NASM is not already defined.
+Alternatively, you can install the 'new' nasm where ever you want and make sure that \`which nasm\` finds it.
+
+_EOS
+            else
+cat << _EOS
+consult https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/BUILDING.md
+
+_EOS
+            fi
+            AC_MSG_WARN([no suitable nasm (Netwide Assembler) found])
+            add_warning "no suitable nasm (Netwide Assembler) found for internal libjpeg-turbo"
+        fi
+      ;;
+    esac
+fi
+
+AC_SUBST(NASM)
+AC_SUBST(NAFLAGS)
+AC_SUBST(LIBJPEG_CFLAGS)
+AC_SUBST(LIBJPEG_LIBS)
+AC_SUBST(SYSTEM_LIBJPEG)
+
+dnl ===================================================================
+dnl Check for system clucene
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([clucene],[CLUCENE],[libclucene-core])
+if test "$SYSTEM_CLUCENE" = TRUE; then
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    save_CPPFLAGS=$CPPFLAGS
+    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
+    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
+    dnl https://sourceforge.net/p/clucene/bugs/200/
+    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
+    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
+                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
+    CXXFLAGS=$save_CXXFLAGS
+    CPPFLAGS=$save_CPPFLAGS
+    AC_LANG_POP([C++])
+    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
+fi
+
+dnl ===================================================================
+dnl Check for system expat
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([expat], [EXPAT], [expat])
+
+dnl ===================================================================
+dnl Check for system xmlsec
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.35])
+
+AC_MSG_CHECKING([whether to enable Embedded OpenType support])
+if test "$enable_eot" = "yes"; then
+    ENABLE_EOT="TRUE"
+    AC_DEFINE([ENABLE_EOT])
+    AC_MSG_RESULT([yes])
+
+    libo_CHECK_SYSTEM_MODULE([libeot],[LIBEOT],[libeot >= 0.01])
+else
+    ENABLE_EOT=
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST([ENABLE_EOT])
+
+dnl ===================================================================
+dnl Check for DLP libs
+dnl ===================================================================
+REVENGE_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/librevenge/inc"
+AS_IF([test "$COM" = "MSC"],
+      [librevenge_libdir="${WORKDIR}/LinkTarget/Library"],
+      [librevenge_libdir="${WORKDIR}/UnpackedTarball/librevenge/src/lib/.libs"]
+)
+REVENGE_LIBS_internal="-L${librevenge_libdir} -lrevenge-0.0"
+libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1])
+
+libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
+
+libo_CHECK_SYSTEM_MODULE([libepubgen],[EPUBGEN],[libepubgen-0.1])
+
+WPD_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/libwpd/inc"
+AS_IF([test "$COM" = "MSC"],
+      [libwpd_libdir="${WORKDIR}/LinkTarget/Library"],
+      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
+)
+WPD_LIBS_internal="-L${libwpd_libdir} -lwpd-0.10"
+libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10])
+
+libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
+
+libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
+libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.14])
+
+libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
+
+libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
+
+libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
+
+libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.21])
+libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.21])
+
+libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
+libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.10])
+
+libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
+
+libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
+libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
+
+libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
+
+libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
+
+libo_CHECK_SYSTEM_MODULE([libqxp],[QXP],[libqxp-0.0])
+
+libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
+
+libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
+libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.7])
+
+dnl ===================================================================
+dnl Check for system lcms2
+dnl ===================================================================
+if test "$with_system_lcms2" != "yes"; then
+    SYSTEM_LCMS2=
+fi
+LCMS2_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/lcms2/include"
+LCMS2_LIBS_internal="-L${WORKDIR}/UnpackedTarball/lcms2/src/.libs -llcms2"
+libo_CHECK_SYSTEM_MODULE([lcms2],[LCMS2],[lcms2])
+if test "$GCC" = "yes"; then
+    LCMS2_CFLAGS="${LCMS2_CFLAGS} -Wno-long-long"
+fi
+if test "$COM" = "MSC"; then # override the above
+    LCMS2_LIBS=${WORKDIR}/UnpackedTarball/lcms2/bin/lcms2.lib
+fi
+
+dnl ===================================================================
+dnl Check for system cppunit
+dnl ===================================================================
+if test "$_os" != "Android" ; then
+    libo_CHECK_SYSTEM_MODULE([cppunit],[CPPUNIT],[cppunit >= 1.14.0])
+fi
+
+dnl ===================================================================
+dnl Check whether freetype is available
+dnl
+dnl FreeType has 3 different kinds of versions
+dnl * release, like 2.4.10
+dnl * libtool, like 13.0.7 (this what pkg-config returns)
+dnl * soname
+dnl FreeType's docs/VERSION.DLL provides a table mapping between the three
+dnl
+dnl 9.9.3 is 2.2.0
+dnl When the minimal version is at least 2.8.1, remove Skia's check down below.
+dnl ===================================================================
+FREETYPE_CFLAGS_internal="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
+if test "x$ac_config_site_64bit_host" = xYES; then
+    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib64 -lfreetype"
+else
+    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
+fi
+libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],,system,TRUE)
+
+# ===================================================================
+# Check for system libxslt
+# to prevent incompatibilities between internal libxml2 and external libxslt,
+# or vice versa, use with_system_libxml here
+# ===================================================================
+if test "$with_system_libxml" = "auto"; then
+    case "$_os" in
+    WINNT|iOS|Android)
+        with_system_libxml="$with_system_libs"
+        ;;
+    Emscripten)
+        with_system_libxml=no
+        ;;
+    *)
+        if test "$enable_fuzzers" != "yes"; then
+            with_system_libxml=yes
+        else
+            with_system_libxml=no
+        fi
+        ;;
+    esac
+fi
+
+AC_MSG_CHECKING([which libxslt to use])
+if test "$with_system_libxml" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_LIBXSLT=TRUE
+    if test "$_os" = "Darwin"; then
+        dnl make sure to use SDK path
+        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
+        LIBEXSLT_CFLAGS="$LIBXSLT_CFLAGS"
+        dnl omit -L/usr/lib
+        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
+        LIBEXSLT_LIBS="-lexslt $LIBXSLT_LIBS"
+    else
+        PKG_CHECK_MODULES(LIBXSLT, libxslt)
+        LIBXSLT_CFLAGS=$(printf '%s' "$LIBXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${LIBXSLT_LIBS}"
+        LIBXSLT_LIBS="${filteredlibs}"
+        PKG_CHECK_MODULES(LIBEXSLT, libexslt)
+        LIBEXSLT_CFLAGS=$(printf '%s' "$LIBEXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${LIBEXSLT_LIBS}"
+        LIBEXSLT_LIBS=$(printf '%s' "${filteredlibs}" | sed -e "s/-lgpg-error//"  -e "s/-lgcrypt//")
+    fi
+
+    dnl Check for xsltproc
+    AC_PATH_PROG(XSLTPROC, xsltproc, no)
+    if test "$XSLTPROC" = "no"; then
+        AC_MSG_ERROR([xsltproc is required])
+    fi
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_LIBXSLT=
+    BUILD_TYPE="$BUILD_TYPE LIBXSLT"
+fi
+AC_SUBST(SYSTEM_LIBXSLT)
+if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
+    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
+fi
+AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)
+
+AC_SUBST(LIBEXSLT_CFLAGS)
+AC_SUBST(LIBEXSLT_LIBS)
+AC_SUBST(LIBXSLT_CFLAGS)
+AC_SUBST(LIBXSLT_LIBS)
+AC_SUBST(XSLTPROC)
+
+# ===================================================================
+# Check for system libxml
+# ===================================================================
+AC_MSG_CHECKING([which libxml to use])
+if test "$with_system_libxml" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_LIBXML=TRUE
+    if test "$_os" = "Darwin"; then
+        dnl make sure to use SDK path
+        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
+        dnl omit -L/usr/lib
+        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
+    elif test $_os = iOS; then
+        dnl make sure to use SDK path
+        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
+        LIBXML_CFLAGS="-I$usr/include/libxml2"
+        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
+    else
+        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
+        LIBXML_CFLAGS=$(printf '%s' "$LIBXML_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${LIBXML_LIBS}"
+        LIBXML_LIBS="${filteredlibs}"
+    fi
+
+    dnl Check for xmllint
+    AC_PATH_PROG(XMLLINT, xmllint, no)
+    if test "$XMLLINT" = "no"; then
+        AC_MSG_ERROR([xmllint is required])
+    fi
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_LIBXML=
+    LIBXML_CFLAGS="-I${WORKDIR}/UnpackedTarball/libxml2/include"
+    if test "$COM" = "MSC"; then
+        LIBXML_CFLAGS="${LIBXML_CFLAGS} -I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
+    fi
+    if test "$COM" = "MSC"; then
+        LIBXML_LIBS="${WORKDIR}/UnpackedTarball/libxml2/win32/bin.msvc/libxml2.lib"
+    else
+        LIBXML_LIBS="-L${WORKDIR}/UnpackedTarball/libxml2/.libs -lxml2"
+        if test "$DISABLE_DYNLOADING" = TRUE; then
+            LIBXML_LIBS="$LIBXML_LIBS -lm"
+        fi
+    fi
+    BUILD_TYPE="$BUILD_TYPE LIBXML2"
+fi
+AC_SUBST(SYSTEM_LIBXML)
+if test -z "$SYSTEM_LIBXML_FOR_BUILD"; then
+    SYSTEM_LIBXML_FOR_BUILD="$SYSTEM_LIBXML"
+fi
+AC_SUBST(SYSTEM_LIBXML_FOR_BUILD)
+AC_SUBST(LIBXML_CFLAGS)
+AC_SUBST(LIBXML_LIBS)
+AC_SUBST(XMLLINT)
+
+# =====================================================================
+# Checking for a Python interpreter with version >= 3.3.
+# Optionally user can pass an option to configure, i. e.
+# ./configure PYTHON=/usr/bin/python
+# =====================================================================
+if test $_os = Darwin -a "$enable_python" != no -a "$enable_python" != fully-internal -a "$enable_python" != internal -a "$enable_python" != system; then
+    # Only allowed choices for macOS are 'no', 'internal' (default), and 'fully-internal'
+    # unless PYTHON is defined as above which allows 'system'
+    enable_python=internal
+fi
+if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
+    if test -n "$PYTHON"; then
+        PYTHON_FOR_BUILD=$PYTHON
+    else
+        # This allows a lack of system python with no error, we use internal one in that case.
+        AM_PATH_PYTHON([3.3],, [:])
+        # Clean PYTHON_VERSION checked below if cross-compiling
+        PYTHON_VERSION=""
+        if test "$PYTHON" != ":"; then
+            PYTHON_FOR_BUILD=$PYTHON
+        fi
+    fi
+fi
+
+# Checks for Python to use for Pyuno
+AC_MSG_CHECKING([which Python to use for Pyuno])
+case "$enable_python" in
+no|disable)
+    if test -z "$PYTHON_FOR_BUILD" -a "$cross_compiling" != yes; then
+        # Python is required to build LibreOffice. In theory we could separate the build-time Python
+        # requirement from the choice whether to include Python stuff in the installer, but why
+        # bother?
+        AC_MSG_ERROR([Python is required at build time.])
+    fi
+    enable_python=no
+    AC_MSG_RESULT([none])
+    ;;
+""|yes|auto)
+    if test "$DISABLE_SCRIPTING" = TRUE; then
+        if test -z "$PYTHON_FOR_BUILD" -a "$cross_compiling" != yes; then
+            AC_MSG_ERROR([Python support can't be disabled without cross-compiling or a system python.])
+        fi
+        AC_MSG_RESULT([none, overridden by --disable-scripting])
+        enable_python=no
+    elif test $build_os = cygwin -o $build_os = wsl; then
+        dnl When building on Windows we don't attempt to use any installed
+        dnl "system"  Python.
+        AC_MSG_RESULT([fully internal])
+        enable_python=internal
+    elif test "$cross_compiling" = yes; then
+        AC_MSG_RESULT([system])
+        enable_python=system
+    else
+        # Unset variables set by the above AM_PATH_PYTHON so that
+        # we actually do check anew.
+        AC_MSG_RESULT([])
+        unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir
+        AM_PATH_PYTHON([3.3],, [:])
+        AC_MSG_CHECKING([which Python to use for Pyuno])
+        if test "$PYTHON" = ":"; then
+            if test -z "$PYTHON_FOR_BUILD"; then
+                AC_MSG_RESULT([fully internal])
+            else
+                AC_MSG_RESULT([internal])
+            fi
+            enable_python=internal
+        else
+            AC_MSG_RESULT([system])
+            enable_python=system
+        fi
+    fi
+    ;;
+internal)
+    AC_MSG_RESULT([internal])
+    ;;
+fully-internal)
+    AC_MSG_RESULT([fully internal])
+    enable_python=internal
+    ;;
+system)
+    AC_MSG_RESULT([system])
+    if test "$_os" = Darwin -a -z "$PYTHON"; then
+        AC_MSG_ERROR([--enable-python=system doesn't work on macOS because the version provided is obsolete])
+    fi
+    ;;
+*)
+    AC_MSG_ERROR([Incorrect --enable-python option])
+    ;;
+esac
+
+if test $enable_python != no; then
+    BUILD_TYPE="$BUILD_TYPE PYUNO"
+fi
+
+if test $enable_python = system; then
+    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
+        # Fallback: Accept these in the environment, or as set above
+        # for MacOSX.
+        :
+    elif test "$cross_compiling" != yes; then
+        # Unset variables set by the above AM_PATH_PYTHON so that
+        # we actually do check anew.
+        unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir
+        # This causes an error if no python command is found
+        AM_PATH_PYTHON([3.3])
+        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
+        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
+        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
+        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
+        if test -z "$PKG_CONFIG"; then
+            PYTHON_CFLAGS="-I$python_include"
+            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
+        elif $PKG_CONFIG --exists python-$python_version-embed; then
+            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version-embed`"
+            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version-embed` $python_libs"
+        elif $PKG_CONFIG --exists python-$python_version; then
+            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
+            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
+        else
+            PYTHON_CFLAGS="-I$python_include"
+            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
+        fi
+        FilterLibs "${PYTHON_LIBS}"
+        PYTHON_LIBS="${filteredlibs}"
+    else
+        dnl How to find out the cross-compilation Python installation path?
+        AC_MSG_CHECKING([for python version])
+        AS_IF([test -n "$PYTHON_VERSION"],
+              [AC_MSG_RESULT([$PYTHON_VERSION])],
+              [AC_MSG_RESULT([not found])
+               AC_MSG_ERROR([no usable python found])])
+        test -n "$PYTHON_CFLAGS" && break
+    fi
+
+    dnl Check if the headers really work
+    save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
+    AC_CHECK_HEADER(Python.h)
+    CPPFLAGS="$save_CPPFLAGS"
+
+    # let the PYTHON_FOR_BUILD match the same python installation that
+    # provides PYTHON_CFLAGS/PYTHON_LDFLAGS for pyuno, which should be
+    # better for PythonTests.
+    PYTHON_FOR_BUILD=$PYTHON
+fi
+
+if test "$with_lxml" != no; then
+    if test -z "$PYTHON_FOR_BUILD"; then
+        case $build_os in
+            cygwin)
+                AC_MSG_WARN([No system-provided python lxml, gla11y will only report widget classes and ids])
+                ;;
+            *)
+                if test "$cross_compiling" != yes ; then
+                    BUILD_TYPE="$BUILD_TYPE LXML"
+                fi
+                ;;
+        esac
+    else
+        AC_MSG_CHECKING([for python lxml])
+        if $PYTHON_FOR_BUILD -c "import lxml.etree as ET" 2> /dev/null ; then
+            AC_MSG_RESULT([yes])
+        else
+            case $build_os in
+                cygwin)
+                    AC_MSG_RESULT([no, gla11y will only report widget classes and ids])
+                    ;;
+                *)
+                    if test "$cross_compiling" != yes -a "x$ac_cv_header_Python_h" = "xyes"; then
+                        if test -n ${SYSTEM_LIBXSLT} -o -n ${SYSTEM_LIBXML}; then
+                            AC_MSG_RESULT([no, and no system libxml/libxslt, gla11y will only report widget classes and ids])
+                        else
+                            BUILD_TYPE="$BUILD_TYPE LXML"
+                            AC_MSG_RESULT([no, using internal lxml])
+                        fi
+                    else
+                        AC_MSG_RESULT([no, and system does not provide python development headers, gla11y will only report widget classes and ids])
+                    fi
+                    ;;
+            esac
+        fi
+    fi
+fi
+
+if test \( "$cross_compiling" = yes -a -z "$PYTHON_FOR_BUILD" \) -o "$enable_python" = internal; then
+    SYSTEM_PYTHON=
+    PYTHON_VERSION_MAJOR=3
+    PYTHON_VERSION_MINOR=8
+    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.18
+    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
+        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
+    fi
+    AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
+
+    # Embedded Python dies without Home set
+    if test "$HOME" = ""; then
+        export HOME=""
+    fi
+fi
+
+dnl By now enable_python should be "system", "internal" or "no"
+case $enable_python in
+system)
+    SYSTEM_PYTHON=TRUE
+
+    if test "x$ac_cv_header_Python_h" != "xyes"; then
+       AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])
+    fi
+
+    AC_LANG_PUSH(C)
+    CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+    AC_MSG_CHECKING([for correct python library version])
+       AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <Python.h>
+
+int main(int argc, char **argv) {
+   if ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
+   else return 1;
+}
+       ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3])],[AC_MSG_RESULT([skipped; cross-compiling])])
+    AC_LANG_POP(C)
+
+    dnl FIXME Check if the Python library can be linked with, too?
+    ;;
+
+internal)
+    BUILD_TYPE="$BUILD_TYPE PYTHON"
+    if test "$OS" = LINUX -o "$OS" = WNT ; then
+        BUILD_TYPE="$BUILD_TYPE LIBFFI"
+    fi
+    ;;
+no)
+    DISABLE_PYTHON=TRUE
+    SYSTEM_PYTHON=
+    ;;
+*)
+    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
+    ;;
+esac
+
+AC_SUBST(DISABLE_PYTHON)
+AC_SUBST(SYSTEM_PYTHON)
+AC_SUBST(PYTHON_CFLAGS)
+AC_SUBST(PYTHON_FOR_BUILD)
+AC_SUBST(PYTHON_LIBS)
+AC_SUBST(PYTHON_VERSION)
+AC_SUBST(PYTHON_VERSION_MAJOR)
+AC_SUBST(PYTHON_VERSION_MINOR)
+
+AC_MSG_CHECKING([whether to build LibreLogo])
+case "$enable_python" in
+no|disable)
+    AC_MSG_RESULT([no; Python disabled])
+    ;;
+*)
+    if test "${enable_librelogo}" = "no"; then
+        AC_MSG_RESULT([no])
+    else
+        AC_MSG_RESULT([yes])
+        BUILD_TYPE="${BUILD_TYPE} LIBRELOGO"
+        AC_DEFINE([ENABLE_LIBRELOGO],1)
+    fi
+    ;;
+esac
+AC_SUBST(ENABLE_LIBRELOGO)
+
+ENABLE_MARIADBC=
+MARIADBC_MAJOR=1
+MARIADBC_MINOR=0
+MARIADBC_MICRO=2
+AC_MSG_CHECKING([whether to build the MariaDB/MySQL SDBC driver])
+if test "x$enable_mariadb_sdbc" != "xno" -a "$enable_mpl_subset" != "yes"; then
+    ENABLE_MARIADBC=TRUE
+    AC_MSG_RESULT([yes])
+    BUILD_TYPE="$BUILD_TYPE MARIADBC"
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_MARIADBC)
+AC_SUBST(MARIADBC_MAJOR)
+AC_SUBST(MARIADBC_MINOR)
+AC_SUBST(MARIADBC_MICRO)
+
+if test "$ENABLE_MARIADBC" = "TRUE"; then
+    dnl ===================================================================
+    dnl Check for system MariaDB
+    dnl ===================================================================
+    AC_MSG_CHECKING([which MariaDB to use])
+    if test "$with_system_mariadb" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_MARIADB_CONNECTOR_C=TRUE
+        #AC_PATH_PROG(MARIADBCONFIG, [mariadb_config])
+        if test -z "$MARIADBCONFIG"; then
+            AC_PATH_PROG(MARIADBCONFIG, [mysql_config])
+            if test -z "$MARIADBCONFIG"; then
+                AC_MSG_ERROR([mysql_config is missing. Install MySQL client library development package.])
+                #AC_MSG_ERROR([mariadb_config and mysql_config are missing. Install MariaDB or MySQL client library development package.])
+            fi
+        fi
+        AC_MSG_CHECKING([MariaDB version])
+        MARIADB_VERSION=`$MARIADBCONFIG --version`
+        MARIADB_MAJOR=`$MARIADBCONFIG --version | cut -d"." -f1`
+        if test "$MARIADB_MAJOR" -ge "5"; then
+            AC_MSG_RESULT([OK])
+        else
+            AC_MSG_ERROR([too old, use 5.0.x or later])
+        fi
+        AC_MSG_CHECKING([for MariaDB Client library])
+        MARIADB_CFLAGS=`$MARIADBCONFIG --cflags`
+        if test "$COM_IS_CLANG" = TRUE; then
+            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-fstack-protector-strong//)
+        fi
+        MARIADB_LIBS=`$MARIADBCONFIG --libs_r`
+        dnl At least mariadb-5.5.34-3.fc20.x86_64 plus
+        dnl mariadb-5.5.34-3.fc20.i686 reports 64-bit specific output even under
+        dnl linux32:
+        if test "$OS" = LINUX -a "$CPUNAME" = INTEL; then
+            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-m64//)
+            MARIADB_LIBS=$(printf '%s' "$MARIADB_LIBS" \
+                | sed -e 's|/lib64/|/lib/|')
+        fi
+        FilterLibs "${MARIADB_LIBS}"
+        MARIADB_LIBS="${filteredlibs}"
+        AC_MSG_RESULT([includes '$MARIADB_CFLAGS', libraries '$MARIADB_LIBS'])
+        AC_MSG_CHECKING([whether to bundle the MySQL/MariaDB client library])
+        if test "$enable_bundle_mariadb" = "yes"; then
+            AC_MSG_RESULT([yes])
+            BUNDLE_MARIADB_CONNECTOR_C=TRUE
+            LIBMARIADB=lib$(echo "${MARIADB_LIBS}" | sed -e 's/[[[:space:]]]\{1,\}-l\([[^[:space:]]]\{1,\}\)/\
+\1\
+/g' -e 's/^-l\([[^[:space:]]]\{1,\}\)[[[:space:]]]*/\
+\1\
+/g' | grep -E '(mysqlclient|mariadb)')
+            if test "$_os" = "Darwin"; then
+                LIBMARIADB=${LIBMARIADB}.dylib
+            elif test "$_os" = "WINNT"; then
+                LIBMARIADB=${LIBMARIADB}.dll
+            else
+                LIBMARIADB=${LIBMARIADB}.so
+            fi
+            LIBMARIADB_PATH=$($MARIADBCONFIG --variable=pkglibdir)
+            AC_MSG_CHECKING([for $LIBMARIADB in $LIBMARIADB_PATH])
+            if test -e "$LIBMARIADB_PATH/$LIBMARIADB"; then
+                AC_MSG_RESULT([found.])
+                PathFormat "$LIBMARIADB_PATH"
+                LIBMARIADB_PATH="$formatted_path"
+            else
+                AC_MSG_ERROR([not found.])
+            fi
+        else
+            AC_MSG_RESULT([no])
+            BUNDLE_MARIADB_CONNECTOR_C=
+        fi
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_MARIADB_CONNECTOR_C=
+        MARIADB_CFLAGS="-I${WORKDIR}/UnpackedTarball/mariadb-connector-c/include"
+        MARIADB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lmariadb-connector-c"
+        BUILD_TYPE="$BUILD_TYPE MARIADB_CONNECTOR_C"
+    fi
+
+    AC_SUBST(SYSTEM_MARIADB_CONNECTOR_C)
+    AC_SUBST(MARIADB_CFLAGS)
+    AC_SUBST(MARIADB_LIBS)
+    AC_SUBST(LIBMARIADB)
+    AC_SUBST(LIBMARIADB_PATH)
+    AC_SUBST(BUNDLE_MARIADB_CONNECTOR_C)
+fi
+
+dnl ===================================================================
+dnl Check for system hsqldb
+dnl ===================================================================
+if test "$with_java" != "no" -a "$cross_compiling" != "yes"; then
+    AC_MSG_CHECKING([which hsqldb to use])
+    if test "$with_system_hsqldb" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_HSQLDB=TRUE
+        if test -z $HSQLDB_JAR; then
+            HSQLDB_JAR=/usr/share/java/hsqldb.jar
+        fi
+        if ! test -f $HSQLDB_JAR; then
+               AC_MSG_ERROR(hsqldb.jar not found.)
+        fi
+        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
+        export HSQLDB_JAR
+        if $PERL -e \
+           'use Archive::Zip;
+            my $file = "$ENV{'HSQLDB_JAR'}";
+            my $zip = Archive::Zip->new( $file );
+            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
+            if ( $mf =~ m/Specification-Version: 1.8.*/ )
+            {
+                push @l, split(/\n/, $mf);
+                foreach my $line (@l)
+                {
+                    if ($line =~ m/Specification-Version:/)
+                    {
+                        ($t, $version) = split (/:/,$line);
+                        $version =~ s/^\s//;
+                        ($a, $b, $c, $d) = split (/\./,$version);
+                        if ($c == "0" && $d > "8")
+                        {
+                            exit 0;
+                        }
+                        else
+                        {
+                            exit 1;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                exit 1;
+            }'; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
+        fi
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_HSQLDB=
+        BUILD_TYPE="$BUILD_TYPE HSQLDB"
+        NEED_ANT=TRUE
+    fi
+else
+    if test "$with_java" != "no" -a -z "$HSQLDB_JAR"; then
+        BUILD_TYPE="$BUILD_TYPE HSQLDB"
+    fi
+fi
+AC_SUBST(SYSTEM_HSQLDB)
+AC_SUBST(HSQLDB_JAR)
+
+dnl ===================================================================
+dnl Check for PostgreSQL stuff
+dnl ===================================================================
+AC_MSG_CHECKING([whether to build the PostgreSQL SDBC driver])
+if test "x$enable_postgresql_sdbc" != "xno"; then
+    AC_MSG_RESULT([yes])
+    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"
+
+    if test "$with_krb5" = "yes" -a "$enable_openssl" = "no"; then
+        AC_MSG_ERROR([krb5 needs OpenSSL, but --disable-openssl was given.])
+    fi
+    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
+        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
+    fi
+
+    postgres_interface=""
+    if test "$with_system_postgresql" = "yes"; then
+        postgres_interface="external PostgreSQL"
+        SYSTEM_POSTGRESQL=TRUE
+        if test "$_os" = Darwin; then
+            supp_path=''
+            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
+                pg_supp_path="$P_SEP$d$pg_supp_path"
+            done
+        fi
+        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
+        if test -n "$PGCONFIG"; then
+            POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
+            POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
+        else
+            PKG_CHECK_MODULES(POSTGRESQL, libpq, [
+              POSTGRESQL_INC=$POSTGRESQL_CFLAGS
+              POSTGRESQL_LIB=$POSTGRESQL_LIBS
+            ],[
+              AC_MSG_ERROR([pg_config or 'pkg-config libpq' needed; set PGCONFIG if not in PATH])
+            ])
+        fi
+        FilterLibs "${POSTGRESQL_LIB}"
+        POSTGRESQL_LIB="${filteredlibs}"
+    else
+        # if/when anything else than PostgreSQL uses Kerberos,
+        # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
+        WITH_KRB5=
+        WITH_GSSAPI=
+        case "$_os" in
+        Darwin)
+            # macOS has system MIT Kerberos 5 since 10.4
+            if test "$with_krb5" != "no"; then
+                WITH_KRB5=TRUE
+                save_LIBS=$LIBS
+                # Not sure whether it makes any sense here to search multiple potential libraries; it is not likely
+                # that the libraries where these functions are located on macOS will change, is it?
+                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
+                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
+                KRB5_LIBS=$LIBS
+                LIBS=$save_LIBS
+                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
+                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
+                KRB5_LIBS="$KRB5_LIBS $LIBS"
+                LIBS=$save_LIBS
+            fi
+            if test "$with_gssapi" != "no"; then
+                WITH_GSSAPI=TRUE
+                save_LIBS=$LIBS
+                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
+                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
+                GSSAPI_LIBS=$LIBS
+                LIBS=$save_LIBS
+            fi
+            ;;
+        WINNT)
+            if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
+                AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
+            fi
+            ;;
+        Linux|GNU|*BSD|DragonFly)
+            if test "$with_krb5" != "no"; then
+                WITH_KRB5=TRUE
+                save_LIBS=$LIBS
+                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
+                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
+                KRB5_LIBS=$LIBS
+                LIBS=$save_LIBS
+                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
+                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
+                KRB5_LIBS="$KRB5_LIBS $LIBS"
+                LIBS=$save_LIBS
+            fi
+            if test "$with_gssapi" != "no"; then
+                WITH_GSSAPI=TRUE
+                save_LIBS=$LIBS
+                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
+                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
+                GSSAPI_LIBS=$LIBS
+                LIBS=$save_LIBS
+            fi
+            ;;
+        *)
+            if test "$with_krb5" = "yes"; then
+                WITH_KRB5=TRUE
+                save_LIBS=$LIBS
+                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
+                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
+                KRB5_LIBS=$LIBS
+                LIBS=$save_LIBS
+                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
+                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
+                KRB5_LIBS="$KRB5_LIBS $LIBS"
+                LIBS=$save_LIBS
+            fi
+            if test "$with_gssapi" = "yes"; then
+                WITH_GSSAPI=TRUE
+                save_LIBS=$LIBS
+                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
+                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
+                LIBS=$save_LIBS
+                GSSAPI_LIBS=$LIBS
+            fi
+        esac
+
+        if test -n "$with_libpq_path"; then
+            SYSTEM_POSTGRESQL=TRUE
+            postgres_interface="external libpq"
+            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
+            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
+        else
+            SYSTEM_POSTGRESQL=
+            postgres_interface="internal"
+            POSTGRESQL_LIB=""
+            POSTGRESQL_INC="%OVERRIDE_ME%"
+            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
+        fi
+    fi
+
+    AC_MSG_CHECKING([PostgreSQL C interface])
+    AC_MSG_RESULT([$postgres_interface])
+
+    if test "${SYSTEM_POSTGRESQL}" = "TRUE"; then
+        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
+        save_CFLAGS=$CFLAGS
+        save_CPPFLAGS=$CPPFLAGS
+        save_LIBS=$LIBS
+        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
+        LIBS="${LIBS} ${POSTGRESQL_LIB}"
+        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
+        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
+            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
+        CFLAGS=$save_CFLAGS
+        CPPFLAGS=$save_CPPFLAGS
+        LIBS=$save_LIBS
+    fi
+    BUILD_POSTGRESQL_SDBC=TRUE
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(WITH_KRB5)
+AC_SUBST(WITH_GSSAPI)
+AC_SUBST(GSSAPI_LIBS)
+AC_SUBST(KRB5_LIBS)
+AC_SUBST(BUILD_POSTGRESQL_SDBC)
+AC_SUBST(SYSTEM_POSTGRESQL)
+AC_SUBST(POSTGRESQL_INC)
+AC_SUBST(POSTGRESQL_LIB)
+
+dnl ===================================================================
+dnl Check for Firebird stuff
+dnl ===================================================================
+ENABLE_FIREBIRD_SDBC=
+if test "$enable_firebird_sdbc" = "yes" ; then
+    SCPDEFS="$SCPDEFS -DWITH_FIREBIRD_SDBC"
+
+    dnl ===================================================================
+    dnl Check for system Firebird
+    dnl ===================================================================
+    AC_MSG_CHECKING([which Firebird to use])
+    if test "$with_system_firebird" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_FIREBIRD=TRUE
+        AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
+        if test -z "$FIREBIRDCONFIG"; then
+            AC_MSG_NOTICE([No fb_config -- using pkg-config])
+            PKG_CHECK_MODULES([FIREBIRD], [fbclient >= 3], [FIREBIRD_PKGNAME=fbclient], [
+                PKG_CHECK_MODULES([FIREBIRD], [fbembed], [FIREBIRD_PKGNAME=fbembed])
+            ])
+            FIREBIRD_VERSION=`pkg-config --modversion "$FIREBIRD_PKGNAME"`
+        else
+            AC_MSG_NOTICE([fb_config found])
+            FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
+            AC_MSG_CHECKING([for Firebird Client library])
+            FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
+            FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
+            FilterLibs "${FIREBIRD_LIBS}"
+            FIREBIRD_LIBS="${filteredlibs}"
+        fi
+        AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
+        AC_MSG_CHECKING([Firebird version])
+        if test -n "${FIREBIRD_VERSION}"; then
+            FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
+            if test "$FIREBIRD_MAJOR" -ge "3"; then
+                AC_MSG_RESULT([OK])
+            else
+                AC_MSG_ERROR([Ensure firebird >= 3 is installed])
+            fi
+        else
+            save_CFLAGS="${CFLAGS}"
+            CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
+            AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
+#if defined(FB_API_VER) && FB_API_VER == 30
+int fb_api_is_30(void) { return 0; }
+#else
+#error "Wrong Firebird API version"
+#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 3.0.x is installed]))
+            CFLAGS="$save_CFLAGS"
+        fi
+        ENABLE_FIREBIRD_SDBC=TRUE
+        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
+    elif test "$enable_database_connectivity" = no; then
+        AC_MSG_RESULT([none])
+    elif test "$cross_compiling" = "yes"; then
+        AC_MSG_RESULT([none])
+    else
+        dnl Embedded Firebird has version 3.0
+        dnl We need libatomic_ops for any non X86/X64 system
+        if test "${CPUNAME}" != INTEL -a "${CPUNAME}" != X86_64; then
+            dnl ===================================================================
+            dnl Check for system libatomic_ops
+            dnl ===================================================================
+            libo_CHECK_SYSTEM_MODULE([libatomic_ops],[LIBATOMIC_OPS],[atomic_ops >= 0.7.2])
+            if test "$with_system_libatomic_ops" = "yes"; then
+                SYSTEM_LIBATOMIC_OPS=TRUE
+                AC_CHECK_HEADERS(atomic_ops.h, [],
+                [AC_MSG_ERROR(atomic_ops.h not found. install libatomic_ops)], [])
+            else
+                SYSTEM_LIBATOMIC_OPS=
+                LIBATOMIC_OPS_CFLAGS="-I${WORKDIR}/UnpackedTarball/libatomic_ops/include"
+                LIBATOMIC_OPS_LIBS="-latomic_ops"
+                BUILD_TYPE="$BUILD_TYPE LIBATOMIC_OPS"
+            fi
+        fi
+
+        AC_MSG_RESULT([internal])
+        SYSTEM_FIREBIRD=
+        FIREBIRD_CFLAGS="-I${WORKDIR}/UnpackedTarball/firebird/gen/Release/firebird/include"
+        FIREBIRD_LIBS="-lfbclient"
+
+        if test "$with_system_libtommath" = "yes"; then
+            SYSTEM_LIBTOMMATH=TRUE
+            dnl check for tommath presence
+            save_LIBS=$LIBS
+            AC_CHECK_HEADER(tommath.h,,AC_MSG_ERROR(Include file for tommath not found - please install development tommath package))
+            AC_CHECK_LIB(tommath, mp_init, LIBTOMMATH_LIBS=-ltommath, AC_MSG_ERROR(Library tommath not found - please install development tommath package))
+            LIBS=$save_LIBS
+        else
+            SYSTEM_LIBTOMMATH=
+            LIBTOMMATH_CFLAGS="-I${WORKDIR}/UnpackedTarball/libtommath"
+            LIBTOMMATH_LIBS="-ltommath"
+            BUILD_TYPE="$BUILD_TYPE LIBTOMMATH"
+        fi
+
+        BUILD_TYPE="$BUILD_TYPE FIREBIRD"
+        ENABLE_FIREBIRD_SDBC=TRUE
+        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
+    fi
+fi
+AC_SUBST(ENABLE_FIREBIRD_SDBC)
+AC_SUBST(SYSTEM_LIBATOMIC_OPS)
+AC_SUBST(LIBATOMIC_OPS_CFLAGS)
+AC_SUBST(LIBATOMIC_OPS_LIBS)
+AC_SUBST(SYSTEM_FIREBIRD)
+AC_SUBST(FIREBIRD_CFLAGS)
+AC_SUBST(FIREBIRD_LIBS)
+AC_SUBST(SYSTEM_LIBTOMMATH)
+AC_SUBST(LIBTOMMATH_CFLAGS)
+AC_SUBST(LIBTOMMATH_LIBS)
+
+dnl ===================================================================
+dnl Check for system curl
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([curl],[CURL],[libcurl >= 7.68.0],enabled)
+
+dnl ===================================================================
+dnl Check for system boost
+dnl ===================================================================
+AC_MSG_CHECKING([which boost to use])
+if test "$with_system_boost" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_BOOST=TRUE
+    AX_BOOST_BASE([1.66],,[AC_MSG_ERROR([no suitable Boost found])])
+    AX_BOOST_DATE_TIME
+    AX_BOOST_FILESYSTEM
+    AX_BOOST_IOSTREAMS
+    AX_BOOST_LOCALE
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $CXXFLAGS_CXX11"
+    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
+       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
+    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
+       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+    # this is in m4/ax_boost_base.m4
+    FilterLibs "${BOOST_LDFLAGS}"
+    BOOST_LDFLAGS="${filteredlibs}"
+else
+    AC_MSG_RESULT([internal])
+    BUILD_TYPE="$BUILD_TYPE BOOST"
+    SYSTEM_BOOST=
+    if test "${COM}" = "GCC" -o "${COM_IS_CLANG}" = "TRUE"; then
+        # use warning-suppressing wrapper headers
+        BOOST_CPPFLAGS="-I${SRC_ROOT}/external/boost/include -I${WORKDIR}/UnpackedTarball/boost"
+    else
+        BOOST_CPPFLAGS="-I${WORKDIR}/UnpackedTarball/boost"
+    fi
+fi
+AC_SUBST(SYSTEM_BOOST)
+
+dnl ===================================================================
+dnl Check for system mdds
+dnl ===================================================================
+MDDS_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/mdds/include"
+libo_CHECK_SYSTEM_MODULE([mdds],[MDDS],[mdds-2.1 >= 2.1.0])
+
+dnl ===================================================================
+dnl Check for system dragonbox
+dnl ===================================================================
+AC_MSG_CHECKING([which dragonbox to use])
+if test "$with_system_dragonbox" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_DRAGONBOX=TRUE
+    AC_LANG_PUSH([C++])
+    save_CPPFLAGS=$CPPFLAGS
+    # This is where upstream installs to, unfortunately no .pc or so...
+    DRAGONBOX_CFLAGS=-I/usr/include/dragonbox-1.1.3
+    CPPFLAGS="$CPPFLAGS $DRAGONBOX_CFLAGS"
+    AC_CHECK_HEADER([dragonbox/dragonbox.h], [],
+       [AC_MSG_ERROR([dragonbox/dragonbox.h not found. install dragonbox])], [])
+    AC_LANG_POP([C++])
+    CPPFLAGS=$save_CPPFLAGS
+else
+    AC_MSG_RESULT([internal])
+    BUILD_TYPE="$BUILD_TYPE DRAGONBOX"
+    SYSTEM_DRAGONBOX=
+fi
+AC_SUBST([SYSTEM_DRAGONBOX])
+AC_SUBST([DRAGONBOX_CFLAGS])
+
+dnl ===================================================================
+dnl Check for system frozen
+dnl ===================================================================
+AC_MSG_CHECKING([which frozen to use])
+if test "$with_system_frozen" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_FROZEN=TRUE
+    AC_LANG_PUSH([C++])
+    save_CPPFLAGS=$CPPFLAGS
+    AC_CHECK_HEADER([frozen/unordered_map.h], [],
+       [AC_MSG_ERROR([frozen/unordered_map.h not found. install frozen headers])], [])
+    AC_LANG_POP([C++])
+    CPPFLAGS=$save_CPPFLAGS
+else
+    AC_MSG_RESULT([internal])
+    BUILD_TYPE="$BUILD_TYPE FROZEN"
+    SYSTEM_FROZEN=
+fi
+AC_SUBST([SYSTEM_FROZEN])
+AC_SUBST([FROZEN_CFLAGS])
+
+dnl ===================================================================
+dnl Check for system libfixmath
+dnl ===================================================================
+AC_MSG_CHECKING([which libfixmath to use])
+if test "$with_system_libfixmath" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_LIBFIXMATH=TRUE
+    AC_LANG_PUSH([C++])
+    AC_CHECK_HEADER([libfixmath/fix16.hpp], [],
+       [AC_MSG_ERROR([libfixmath/fix16.hpp not found. install libfixmath])], [])
+    AC_CHECK_LIB([libfixmath], [fix16_mul], [:], [AC_MSG_ERROR(libfixmath lib not found or functional)], [])
+    AC_LANG_POP([C++])
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_LIBFIXMATH=
+fi
+AC_SUBST([SYSTEM_LIBFIXMATH])
+
+dnl ===================================================================
+dnl Check for system glm
+dnl ===================================================================
+AC_MSG_CHECKING([which glm to use])
+if test "$with_system_glm" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_GLM=TRUE
+    AC_LANG_PUSH([C++])
+    AC_CHECK_HEADER([glm/glm.hpp], [],
+       [AC_MSG_ERROR([glm/glm.hpp not found. install glm])], [])
+    AC_LANG_POP([C++])
+else
+    AC_MSG_RESULT([internal])
+    BUILD_TYPE="$BUILD_TYPE GLM"
+    SYSTEM_GLM=
+    GLM_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/glm"
+fi
+AC_SUBST([GLM_CFLAGS])
+AC_SUBST([SYSTEM_GLM])
+
+dnl ===================================================================
+dnl Check for system odbc
+dnl ===================================================================
+AC_MSG_CHECKING([which odbc headers to use])
+if test "$with_system_odbc" = "yes" -o '(' "$with_system_headers" = "yes" -a "$with_system_odbc" = "auto" ')' -o '(' "$_os" = "WINNT" -a  "$with_system_odbc" != "no" ')'; then
+    AC_MSG_RESULT([external])
+    SYSTEM_ODBC_HEADERS=TRUE
+
+    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
+        save_CPPFLAGS=$CPPFLAGS
+        find_winsdk
+        PathFormat "$winsdktest"
+        CPPFLAGS="$CPPFLAGS -I$formatted_path/include/um -I$formatted_path/Include/$winsdklibsubdir/um -I$formatted_path/include -I$formatted_path/include/shared -I$formatted_path/include/$winsdklibsubdir/shared"
+        AC_CHECK_HEADER(sqlext.h, [],
+            [AC_MSG_ERROR(odbc not found. install odbc)],
+            [#include <windows.h>])
+        CPPFLAGS=$save_CPPFLAGS
+    else
+        AC_CHECK_HEADER(sqlext.h, [],
+            [AC_MSG_ERROR(odbc not found. install odbc)],[])
+    fi
+elif test "$enable_database_connectivity" = no; then
+    AC_MSG_RESULT([none])
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_ODBC_HEADERS=
+fi
+AC_SUBST(SYSTEM_ODBC_HEADERS)
+
+dnl ===================================================================
+dnl Check for system NSS
+dnl ===================================================================
+if test "$enable_fuzzers" != "yes" -a "$enable_nss" = "yes"; then
+    libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8],,system-if-linux)
+    AC_DEFINE(HAVE_FEATURE_NSS)
+    ENABLE_NSS=TRUE
+elif test $_os != iOS -a "$enable_openssl" != "no"; then
+    with_tls=openssl
+fi
+AC_SUBST(ENABLE_NSS)
+
+dnl ===================================================================
+dnl Enable LDAP support
+dnl ===================================================================
+
+if test "$test_openldap" = yes; then
+    AC_MSG_CHECKING([whether to enable LDAP support])
+    if test "$enable_ldap" = yes -a \( "$enable_openssl" = yes -o "$with_system_openldap" = yes \); then
+        AC_MSG_RESULT([yes])
+        ENABLE_LDAP=TRUE
+    else
+        if test "$enable_ldap" != "yes"; then
+            AC_MSG_RESULT([no])
+        else
+            AC_MSG_RESULT([no (needs OPENSSL or system openldap)])
+        fi
+    fi
+
+dnl ===================================================================
+dnl Check for system openldap
+dnl ===================================================================
+
+    if test "$ENABLE_LDAP" = TRUE; then
+        AC_MSG_CHECKING([which openldap library to use])
+        if test "$with_system_openldap" = yes; then
+            AC_MSG_RESULT([external])
+            SYSTEM_OPENLDAP=TRUE
+            AC_CHECK_HEADERS(ldap.h, [], [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
+            AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
+            AC_CHECK_LIB([ldap], [ldap_set_option], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
+        else
+            AC_MSG_RESULT([internal])
+            BUILD_TYPE="$BUILD_TYPE OPENLDAP"
+        fi
+    fi
+fi
+
+AC_SUBST(ENABLE_LDAP)
+AC_SUBST(SYSTEM_OPENLDAP)
+
+dnl ===================================================================
+dnl Check for TLS/SSL and cryptographic implementation to use
+dnl ===================================================================
+AC_MSG_CHECKING([which TLS/SSL and cryptographic implementation to use])
+if test -n "$with_tls"; then
+    case $with_tls in
+    openssl)
+        AC_DEFINE(USE_TLS_OPENSSL)
+        TLS=OPENSSL
+        AC_MSG_RESULT([$TLS])
+
+        if test "$enable_openssl" != "yes"; then
+            AC_MSG_ERROR(["Disabling OpenSSL was requested, but the requested TLS to use is actually OpenSSL."])
+        fi
+
+        # warn that OpenSSL has been selected but not all TLS code has this option
+        AC_MSG_WARN([TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS])
+        add_warning "TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS"
+        ;;
+    nss)
+        AC_DEFINE(USE_TLS_NSS)
+        TLS=NSS
+        AC_MSG_RESULT([$TLS])
+        ;;
+    no)
+        AC_MSG_RESULT([none])
+        AC_MSG_WARN([Skipping TLS/SSL])
+        ;;
+    *)
+        AC_MSG_RESULT([])
+        AC_MSG_ERROR([unsupported implementation $with_tls. Supported are:
+openssl - OpenSSL
+nss - Mozilla's Network Security Services (NSS)
+    ])
+        ;;
+    esac
+else
+    # default to using NSS, it results in smaller oox lib
+    AC_DEFINE(USE_TLS_NSS)
+    TLS=NSS
+    AC_MSG_RESULT([$TLS])
+fi
+AC_SUBST(TLS)
+
+dnl ===================================================================
+dnl Check for system sane
+dnl ===================================================================
+AC_MSG_CHECKING([which sane header to use])
+if test "$with_system_sane" = "yes"; then
+    AC_MSG_RESULT([external])
+    AC_CHECK_HEADER(sane/sane.h, [],
+      [AC_MSG_ERROR(sane not found. install sane)], [])
+else
+    AC_MSG_RESULT([internal])
+    BUILD_TYPE="$BUILD_TYPE SANE"
+fi
+
+dnl ===================================================================
+dnl Check for system icu
+dnl ===================================================================
+ICU_MAJOR=73
+ICU_MINOR=2
+ICU_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
+ICU_LIBS_internal="-L${WORKDIR}/UnpackedTarball/icu/source/lib"
+libo_CHECK_SYSTEM_MODULE([icu],[ICU],[icu-i18n >= 66])
+if test "$SYSTEM_ICU" = TRUE; then
+    AC_LANG_PUSH([C++])
+    AC_MSG_CHECKING([for unicode/rbbi.h])
+    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([icu headers not found])])
+    AC_LANG_POP([C++])
+
+    ICU_VERSION=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
+    ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
+    ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
+
+    if test "$CROSS_COMPILING" != TRUE; then
+        # using the system icu tools can lead to version confusion, use the
+        # ones from the build environment when cross-compiling
+        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
+        if test -z "$SYSTEM_GENBRK"; then
+            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
+        fi
+        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
+        if test -z "$SYSTEM_GENCCODE"; then
+            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
+        fi
+        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
+        if test -z "$SYSTEM_GENCMN"; then
+            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
+        fi
+    fi
+fi
+
+AC_SUBST(SYSTEM_GENBRK)
+AC_SUBST(SYSTEM_GENCCODE)
+AC_SUBST(SYSTEM_GENCMN)
+AC_SUBST(ICU_MAJOR)
+AC_SUBST(ICU_MINOR)
+
+dnl ==================================================================
+dnl CURL
+dnl ==================================================================
+if test "$enable_curl" == "yes"; then
+    AC_DEFINE([HAVE_FEATURE_CURL])
+fi
+
+dnl ==================================================================
+dnl Breakpad
+dnl ==================================================================
+DEFAULT_CRASHDUMP_VALUE="true"
+AC_MSG_CHECKING([whether to enable breakpad])
+if test "$enable_breakpad" != yes; then
+    AC_MSG_RESULT([no])
+else
+    if test "$enable_curl" != "yes"; then
+        AC_MSG_ERROR([--disable-breakpad must be used when --disable-curl is used])
+    fi
+    AC_MSG_RESULT([yes])
+    ENABLE_BREAKPAD="TRUE"
+    AC_DEFINE(ENABLE_BREAKPAD)
+    AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
+    BUILD_TYPE="$BUILD_TYPE BREAKPAD"
+
+    AC_MSG_CHECKING([for disable crash dump])
+    if test "$enable_crashdump" = no; then
+        DEFAULT_CRASHDUMP_VALUE="false"
+        AC_MSG_RESULT([yes])
+    else
+       AC_MSG_RESULT([no])
+    fi
+
+    AC_MSG_CHECKING([for crashreport config])
+    if test "$with_symbol_config" = "no"; then
+        BREAKPAD_SYMBOL_CONFIG="invalid"
+        AC_MSG_RESULT([no])
+    else
+        BREAKPAD_SYMBOL_CONFIG="$with_symbol_config"
+        AC_DEFINE(BREAKPAD_SYMBOL_CONFIG)
+        AC_MSG_RESULT([yes])
+    fi
+    AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
+fi
+AC_SUBST(ENABLE_BREAKPAD)
+AC_SUBST(DEFAULT_CRASHDUMP_VALUE)
+
+dnl ==================================================================
+dnl libcmis
+dnl ==================================================================
+if test "$enable_libcmis" == "yes"; then
+    if test "$enable_curl" != "yes"; then
+        AC_MSG_ERROR([--disable-libcmis must be used when --disable-curl is used])
+    fi
+fi
+
+dnl ===================================================================
+dnl Orcus
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.18 >= 0.19.1])
+if test "$with_system_orcus" != "yes"; then
+    if test "$SYSTEM_BOOST" = "TRUE"; then
+        dnl Link with Boost.System
+        dnl This seems to be necessary since boost 1.50 (1.48 does not need it,
+        dnl 1.49 is untested). The macro BOOST_THREAD_DONT_USE_SYSTEM mentioned
+        dnl in documentation has no effect.
+        AX_BOOST_SYSTEM
+    fi
+fi
+dnl FIXME by renaming SYSTEM_LIBORCUS to SYSTEM_ORCUS in the build system world
+SYSTEM_LIBORCUS=$SYSTEM_ORCUS
+AC_SUBST([BOOST_SYSTEM_LIB])
+AC_SUBST(SYSTEM_LIBORCUS)
+
+dnl ===================================================================
+dnl HarfBuzz
+dnl ===================================================================
+harfbuzz_required_version=5.1.0
+
+GRAPHITE_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/graphite/include -DGRAPHITE2_STATIC"
+HARFBUZZ_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/harfbuzz/src"
+case "$_os" in
+    Linux)
+        GRAPHITE_LIBS_internal="${WORKDIR}/LinkTarget/StaticLibrary/libgraphite.a"
+        HARFBUZZ_LIBS_internal="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.a"
+        ;;
+    *)
+        GRAPHITE_LIBS_internal="-L${WORKDIR}/LinkTarget/StaticLibrary -lgraphite"
+        HARFBUZZ_LIBS_internal="-L${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs -lharfbuzz"
+        ;;
+esac
+libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3])
+libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= $harfbuzz_required_version])
+
+if test "$COM" = "MSC"; then # override the above
+    GRAPHITE_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/graphite.lib"
+    HARFBUZZ_LIBS="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.lib"
+fi
+
+if test "$with_system_harfbuzz" = "yes"; then
+    if test "$with_system_graphite" = "no"; then
+        AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used])
+    fi
+    AC_MSG_CHECKING([whether system Harfbuzz is built with Graphite support])
+    save_LIBS="$LIBS"
+    save_CFLAGS="$CFLAGS"
+    LIBS="$LIBS $HARFBUZZ_LIBS"
+    CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
+    AC_CHECK_FUNC(hb_graphite2_face_get_gr_face,,[AC_MSG_ERROR([Harfbuzz needs to be built with Graphite support.])])
+    LIBS="$save_LIBS"
+    CFLAGS="$save_CFLAGS"
+else
+    if test "$with_system_graphite" = "yes"; then
+        AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
+    fi
+fi
+
+if test "$USING_X11" = TRUE; then
+    AC_PATH_X
+    AC_PATH_XTRA
+    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+    if test -z "$x_includes"; then
+        x_includes="default_x_includes"
+    fi
+    if test -z "$x_libraries"; then
+        x_libraries="default_x_libraries"
+    fi
+    CFLAGS="$CFLAGS $X_CFLAGS"
+    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
+    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
+else
+    x_includes="no_x_includes"
+    x_libraries="no_x_libraries"
+fi
+
+if test "$USING_X11" = TRUE; then
+    dnl ===================================================================
+    dnl Check for extension headers
+    dnl ===================================================================
+    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
+     [#include <X11/extensions/shape.h>])
+
+    # vcl needs ICE and SM
+    AC_CHECK_HEADERS(X11/ICE/ICElib.h,[],[AC_MSG_ERROR([libICE headers not found])])
+    AC_CHECK_LIB([ICE], [IceConnectionNumber], [:],
+        [AC_MSG_ERROR(ICE library not found)])
+    AC_CHECK_HEADERS(X11/SM/SMlib.h,[],[AC_MSG_ERROR([libSM headers not found])])
+    AC_CHECK_LIB([SM], [SmcOpenConnection], [:],
+        [AC_MSG_ERROR(SM library not found)])
+fi
+
+if test "$USING_X11" = TRUE -a "$ENABLE_JAVA" != ""; then
+    # bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c needs Xt
+    AC_CHECK_HEADERS(X11/Intrinsic.h,[],[AC_MSG_ERROR([libXt headers not found])])
+fi
+
+dnl ===================================================================
+dnl Check for system Xrender
+dnl ===================================================================
+AC_MSG_CHECKING([whether to use Xrender])
+if test "$USING_X11" = TRUE -a  "$test_xrender" = "yes"; then
+    AC_MSG_RESULT([yes])
+    PKG_CHECK_MODULES(XRENDER, xrender)
+    XRENDER_CFLAGS=$(printf '%s' "$XRENDER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${XRENDER_LIBS}"
+    XRENDER_LIBS="${filteredlibs}"
+    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
+      [AC_MSG_ERROR(libXrender not found or functional)], [])
+    AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
+      [AC_MSG_ERROR(Xrender not found. install X)], [])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(XRENDER_CFLAGS)
+AC_SUBST(XRENDER_LIBS)
+
+dnl ===================================================================
+dnl Check for XRandr
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable RandR support])
+if test "$USING_X11" = TRUE -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
+    AC_MSG_RESULT([yes])
+    PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
+    if test "$ENABLE_RANDR" != "TRUE"; then
+        AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
+                    [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
+        XRANDR_CFLAGS=" "
+        AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
+          [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
+        XRANDR_LIBS="-lXrandr "
+        ENABLE_RANDR="TRUE"
+    fi
+    XRANDR_CFLAGS=$(printf '%s' "$XRANDR_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${XRANDR_LIBS}"
+    XRANDR_LIBS="${filteredlibs}"
+else
+    ENABLE_RANDR=""
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(XRANDR_CFLAGS)
+AC_SUBST(XRANDR_LIBS)
+AC_SUBST(ENABLE_RANDR)
+
+if test -z "$with_webdav"; then
+    with_webdav=$test_webdav
+fi
+
+AC_MSG_CHECKING([for WebDAV support])
+case "$with_webdav" in
+no)
+    AC_MSG_RESULT([no])
+    WITH_WEBDAV=""
+    ;;
+*)
+    AC_MSG_RESULT([yes])
+    # curl is already mandatory (almost) and checked elsewhere
+    if test "$enable_curl" = "no"; then
+        AC_MSG_ERROR(["--without-webdav must be used when --disable-curl is used"])
+    fi
+    WITH_WEBDAV=TRUE
+    ;;
+esac
+AC_SUBST(WITH_WEBDAV)
+
+dnl ===================================================================
+dnl Check for disabling cve_tests
+dnl ===================================================================
+AC_MSG_CHECKING([whether to execute CVE tests])
+# If not explicitly enabled or disabled, default
+if test -z "$enable_cve_tests"; then
+    case "$OS" in
+    WNT)
+        # Default cves off for Windows with its wild and wonderful
+        # variety of AV software kicking in and panicking
+        enable_cve_tests=no
+        ;;
+    *)
+        # otherwise yes
+        enable_cve_tests=yes
+        ;;
+    esac
+fi
+if test "$enable_cve_tests" = "no"; then
+    AC_MSG_RESULT([no])
+    DISABLE_CVE_TESTS=TRUE
+    AC_SUBST(DISABLE_CVE_TESTS)
+else
+    AC_MSG_RESULT([yes])
+fi
+
+dnl ===================================================================
+dnl Check for system openssl
+dnl ===================================================================
+ENABLE_OPENSSL=
+AC_MSG_CHECKING([whether to disable OpenSSL usage])
+if test "$enable_openssl" = "yes"; then
+    AC_MSG_RESULT([no])
+    ENABLE_OPENSSL=TRUE
+    if test "$_os" = Darwin ; then
+        # OpenSSL is deprecated when building for 10.7 or later.
+        #
+        # https://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion
+        # https://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion
+
+        with_system_openssl=no
+        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
+    elif test "$_os" = "FreeBSD" -o "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \
+            && test "$with_system_openssl" != "no"; then
+        with_system_openssl=yes
+        SYSTEM_OPENSSL=TRUE
+        OPENSSL_CFLAGS=
+        OPENSSL_LIBS="-lssl -lcrypto"
+    else
+        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
+        if test -n "${SYSTEM_OPENSSL}"; then
+            AC_DEFINE([SYSTEM_OPENSSL])
+        fi
+    fi
+    if test "$with_system_openssl" = "yes"; then
+        AC_MSG_CHECKING([whether openssl supports SHA512])
+        AC_LANG_PUSH([C])
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/sha.h>]],[[
+            SHA512_CTX context;
+]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])])
+        AC_LANG_POP(C)
+    fi
+else
+    AC_MSG_RESULT([yes])
+
+    # warn that although OpenSSL is disabled, system libraries may depend on it
+    AC_MSG_WARN([OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies])
+    add_warning "OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies"
+fi
+
+AC_SUBST([ENABLE_OPENSSL])
+
+if test "$enable_cipher_openssl_backend" = yes && test "$ENABLE_OPENSSL" != TRUE; then
+    if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then
+        AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no])
+        enable_cipher_openssl_backend=no
+    else
+        AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.])
+    fi
+fi
+AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h])
+ENABLE_CIPHER_OPENSSL_BACKEND=
+if test "$enable_cipher_openssl_backend" = yes; then
+    AC_MSG_RESULT([yes])
+    ENABLE_CIPHER_OPENSSL_BACKEND=TRUE
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND])
+
+dnl ===================================================================
+dnl Select the crypto backends used by LO
+dnl ===================================================================
+
+if test "$build_crypto" = yes; then
+    if test "$OS" = WNT; then
+        BUILD_TYPE="$BUILD_TYPE CRYPTO_MSCAPI"
+        AC_DEFINE([USE_CRYPTO_MSCAPI])
+    elif test "$ENABLE_NSS" = TRUE; then
+        BUILD_TYPE="$BUILD_TYPE CRYPTO_NSS"
+        AC_DEFINE([USE_CRYPTO_NSS])
+    fi
+fi
+
+ARGON2_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/argon2/include"
+if test "$COM" = "MSC"; then
+    ARGON2_LIBS_internal="${WORKDIR}/UnpackedTarball/argon2/vs2015/build/Argon2OptDll.lib"
+else
+    ARGON2_LIBS_internal="${WORKDIR}/UnpackedTarball/argon2/libargon2.a"
+fi
+libo_CHECK_SYSTEM_MODULE([argon2],[ARGON2],[libargon2])
+
+dnl ===================================================================
+dnl Check for system redland
+dnl ===================================================================
+dnl redland: versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
+dnl raptor2: need at least 2.0.7 for CVE-2012-0037
+libo_CHECK_SYSTEM_MODULE([redland],[REDLAND],[redland >= 1.0.8 raptor2 >= 2.0.7])
+if test "$with_system_redland" = "yes"; then
+    AC_CHECK_LIB([rdf], [librdf_world_set_raptor_init_handler], [:],
+            [AC_MSG_ERROR(librdf too old. Need >= 1.0.16)], [])
+else
+    RAPTOR_MAJOR="0"
+    RASQAL_MAJOR="3"
+    REDLAND_MAJOR="0"
+fi
+AC_SUBST(RAPTOR_MAJOR)
+AC_SUBST(RASQAL_MAJOR)
+AC_SUBST(REDLAND_MAJOR)
+
+dnl ===================================================================
+dnl Check for system hunspell
+dnl ===================================================================
+AC_MSG_CHECKING([which libhunspell to use])
+if test "$with_system_hunspell" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_HUNSPELL=TRUE
+    AC_LANG_PUSH([C++])
+    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
+    if test "$HUNSPELL_PC" != "TRUE"; then
+        AC_CHECK_HEADER(hunspell.hxx, [],
+            [
+            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
+            [AC_MSG_ERROR(hunspell headers not found.)], [])
+            ], [])
+        AC_CHECK_LIB([hunspell], [main], [:],
+           [ AC_MSG_ERROR(hunspell library not found.) ], [])
+        HUNSPELL_LIBS=-lhunspell
+    fi
+    AC_LANG_POP([C++])
+    HUNSPELL_CFLAGS=$(printf '%s' "$HUNSPELL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${HUNSPELL_LIBS}"
+    HUNSPELL_LIBS="${filteredlibs}"
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_HUNSPELL=
+    HUNSPELL_CFLAGS="-I${WORKDIR}/UnpackedTarball/hunspell/src/hunspell"
+    if test "$COM" = "MSC"; then
+        HUNSPELL_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/hunspell.lib"
+    else
+        HUNSPELL_LIBS="-L${WORKDIR}/UnpackedTarball/hunspell/src/hunspell/.libs -lhunspell-1.7"
+    fi
+    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
+fi
+AC_SUBST(SYSTEM_HUNSPELL)
+AC_SUBST(HUNSPELL_CFLAGS)
+AC_SUBST(HUNSPELL_LIBS)
+
+dnl ===================================================================
+dnl Check for system zxcvbn
+dnl ===================================================================
+AC_MSG_CHECKING([which zxcvbn to use])
+if test "$with_system_zxcvbn" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_ZXCVBN=TRUE
+    AC_CHECK_HEADER(zxcvbn.h, [],
+       [ AC_MSG_ERROR(zxcvbn headers not found.)], [])
+    AC_CHECK_LIB(zxcvbn, ZxcvbnMatch, [],
+        [ AC_MSG_ERROR(zxcvbn library not found.)], [])
+else
+   AC_MSG_RESULT([internal])
+   BUILD_TYPE="$BUILD_TYPE ZXCVBN"
+   SYSTEM_ZXCVBN=
+fi
+AC_SUBST(SYSTEM_ZXCVBN)
+
+dnl ===================================================================
+dnl Check for system zxing
+dnl ===================================================================
+AC_MSG_CHECKING([whether to use zxing])
+if test "$enable_zxing" = "no"; then
+    AC_MSG_RESULT([no])
+    ENABLE_ZXING=
+    SYSTEM_ZXING=
+else
+    AC_MSG_RESULT([yes])
+    ENABLE_ZXING=TRUE
+    AC_MSG_CHECKING([which libzxing to use])
+    if test "$with_system_zxing" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_ZXING=TRUE
+        ZXING_CFLAGS=
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        save_IFS=$IFS
+        IFS=$P_SEP
+        for i in $CPLUS_INCLUDE_PATH /usr/include; do
+            dnl Reset IFS as soon as possible, to avoid unexpected side effects (and the
+            dnl "/usr/include" fallback makes sure we get here at least once; resetting rather than
+            dnl unsetting follows the advice at <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;
+            dnl a=commitdiff;h=e51c9919f2cf70185b7916ac040bc0bbfd0f743b> "Add recommendation on (not)
+            dnl unsetting IFS."):
+            IFS=$save_IFS
+            dnl TODO: GCC and Clang treat empty paths in CPLUS_INCLUDE_PATH like ".", but we simply
+            dnl ignore them here:
+            if test -z "$i"; then
+                continue
+            fi
+            dnl TODO: White space in $i would cause problems:
+            CXXFLAGS="$save_CXXFLAGS ${CXXFLAGS_CXX11} -I$i/ZXing"
+            AC_CHECK_HEADER(MultiFormatWriter.h, [ZXING_CFLAGS=-I$i/ZXing; break],
+                [unset ac_cv_header_MultiFormatWriter_h], [#include <stdexcept>])
+        done
+        CXXFLAGS=$save_CXXFLAGS
+        if test -z "$ZXING_CFLAGS"; then
+            AC_MSG_ERROR(zxing headers not found.)
+        fi
+        AC_CHECK_LIB([ZXing], [main], [ZXING_LIBS=-lZXing],
+            [ AC_CHECK_LIB([ZXingCore], [main], [ZXING_LIBS=-lZXingCore],
+            [ AC_MSG_ERROR(zxing C++ library not found.) ])], [])
+        AC_LANG_POP([C++])
+        ZXING_CFLAGS=$(printf '%s' "$ZXING_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${ZXING_LIBS}"
+        ZXING_LIBS="${filteredlibs}"
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_ZXING=
+        BUILD_TYPE="$BUILD_TYPE ZXING"
+        ZXING_CFLAGS="-I${WORKDIR}/UnpackedTarball/zxing/core/src"
+    fi
+    if test "$ENABLE_ZXING" = TRUE; then
+        AC_DEFINE(ENABLE_ZXING)
+    fi
+    AC_MSG_CHECKING([whether zxing::tosvg function is available])
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 $ZXING_CFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <BitMatrix.h>
+            #include <BitMatrixIO.h>
+            int main(){
+                ZXing::BitMatrix matrix(1, 1);
+                matrix.set(0, 0, true);
+                ZXing::ToSVG(matrix);
+                return 0;
+            }
+        ])], [
+            AC_DEFINE([HAVE_ZXING_TOSVG],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+    AC_SUBST(HAVE_ZXING_TOSVG)
+fi
+AC_SUBST(SYSTEM_ZXING)
+AC_SUBST(ENABLE_ZXING)
+AC_SUBST(ZXING_CFLAGS)
+AC_SUBST(ZXING_LIBS)
+
+dnl ===================================================================
+dnl Check for system box2d
+dnl ===================================================================
+AC_MSG_CHECKING([which box2d to use])
+if test "$with_system_box2d" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_BOX2D=TRUE
+    AC_LANG_PUSH([C++])
+    AC_CHECK_HEADER(box2d/box2d.h, [BOX2D_H_FOUND='TRUE'],
+        [BOX2D_H_FOUND='FALSE'])
+    if test "$BOX2D_H_FOUND" = "TRUE"; then # 2.4.0+
+        _BOX2D_LIB=box2d
+        AC_DEFINE(BOX2D_HEADER,<box2d/box2d.h>)
+    else
+        # fail this. there's no other alternative to check when we are here.
+        AC_CHECK_HEADER([Box2D/Box2D.h], [],
+            [AC_MSG_ERROR(box2d headers not found.)])
+        _BOX2D_LIB=Box2D
+        AC_DEFINE(BOX2D_HEADER,<Box2D/Box2D.h>)
+    fi
+    AC_CHECK_LIB([$_BOX2D_LIB], [main], [:],
+        [ AC_MSG_ERROR(box2d library not found.) ], [])
+    BOX2D_LIBS=-l$_BOX2D_LIB
+    AC_LANG_POP([C++])
+    BOX2D_CFLAGS=$(printf '%s' "$BOX2D_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${BOX2D_LIBS}"
+    BOX2D_LIBS="${filteredlibs}"
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_BOX2D=
+    BUILD_TYPE="$BUILD_TYPE BOX2D"
+fi
+AC_SUBST(SYSTEM_BOX2D)
+AC_SUBST(BOX2D_CFLAGS)
+AC_SUBST(BOX2D_LIBS)
+
+dnl ===================================================================
+dnl Checking for altlinuxhyph
+dnl ===================================================================
+AC_MSG_CHECKING([which altlinuxhyph to use])
+if test "$with_system_altlinuxhyph" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_HYPH=TRUE
+    AC_CHECK_HEADER(hyphen.h, [],
+       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
+    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
+       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
+       [#include <hyphen.h>])
+    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
+        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
+    if test -z "$HYPHEN_LIB"; then
+        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
+           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
+    fi
+    if test -z "$HYPHEN_LIB"; then
+        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
+           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
+    fi
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_HYPH=
+    BUILD_TYPE="$BUILD_TYPE HYPHEN"
+    if test "$COM" = "MSC"; then
+        HYPHEN_LIB="${WORKDIR}/LinkTarget/StaticLibrary/hyphen.lib"
+    else
+        HYPHEN_LIB="-L${WORKDIR}/UnpackedTarball/hyphen/.libs -lhyphen"
+    fi
+fi
+AC_SUBST(SYSTEM_HYPH)
+AC_SUBST(HYPHEN_LIB)
+
+dnl ===================================================================
+dnl Checking for mythes
+dnl ===================================================================
+AC_MSG_CHECKING([which mythes to use])
+if test "$with_system_mythes" = "yes"; then
+    AC_MSG_RESULT([external])
+    SYSTEM_MYTHES=TRUE
+    AC_LANG_PUSH([C++])
+    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
+    if test "$MYTHES_PKGCONFIG" = "no"; then
+        AC_CHECK_HEADER(mythes.hxx, [],
+            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
+        AC_CHECK_LIB([mythes-1.2], [main], [:],
+            [ MYTHES_FOUND=no], [])
+    if test "$MYTHES_FOUND" = "no"; then
+        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
+                [ MYTHES_FOUND=no], [])
+    fi
+    if test "$MYTHES_FOUND" = "no"; then
+        AC_MSG_ERROR([mythes library not found!.])
+    fi
+    fi
+    AC_LANG_POP([C++])
+    MYTHES_CFLAGS=$(printf '%s' "$MYTHES_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${MYTHES_LIBS}"
+    MYTHES_LIBS="${filteredlibs}"
+else
+    AC_MSG_RESULT([internal])
+    SYSTEM_MYTHES=
+    BUILD_TYPE="$BUILD_TYPE MYTHES"
+    if test "$COM" = "MSC"; then
+        MYTHES_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/mythes.lib"
+    else
+        MYTHES_LIBS="-L${WORKDIR}/UnpackedTarball/mythes/.libs -lmythes-1.2"
+    fi
+fi
+AC_SUBST(SYSTEM_MYTHES)
+AC_SUBST(MYTHES_CFLAGS)
+AC_SUBST(MYTHES_LIBS)
+
+dnl ===================================================================
+dnl How should we build the linear programming solver ?
+dnl ===================================================================
+
+ENABLE_COINMP=
+AC_MSG_CHECKING([whether to build with CoinMP])
+if test "$enable_coinmp" != "no"; then
+    ENABLE_COINMP=TRUE
+    AC_MSG_RESULT([yes])
+    if test "$with_system_coinmp" = "yes"; then
+        SYSTEM_COINMP=TRUE
+        PKG_CHECK_MODULES(COINMP, coinmp coinutils)
+        FilterLibs "${COINMP_LIBS}"
+        COINMP_LIBS="${filteredlibs}"
+    else
+        BUILD_TYPE="$BUILD_TYPE COINMP"
+    fi
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_COINMP)
+AC_SUBST(SYSTEM_COINMP)
+AC_SUBST(COINMP_CFLAGS)
+AC_SUBST(COINMP_LIBS)
+
+ENABLE_LPSOLVE=
+AC_MSG_CHECKING([whether to build with lpsolve])
+if test "$enable_lpsolve" != "no"; then
+    ENABLE_LPSOLVE=TRUE
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_LPSOLVE)
+
+if test "$ENABLE_LPSOLVE" = TRUE; then
+    AC_MSG_CHECKING([which lpsolve to use])
+    if test "$with_system_lpsolve" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_LPSOLVE=TRUE
+        AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
+           [ AC_MSG_ERROR(lpsolve headers not found.)], [])
+        save_LIBS=$LIBS
+        # some systems need this. Like Ubuntu...
+        AC_CHECK_LIB(m, floor)
+        AC_CHECK_LIB(dl, dlopen)
+        AC_CHECK_LIB([lpsolve55], [make_lp], [:],
+            [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
+        LIBS=$save_LIBS
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_LPSOLVE=
+        BUILD_TYPE="$BUILD_TYPE LPSOLVE"
+    fi
+fi
+AC_SUBST(SYSTEM_LPSOLVE)
+
+dnl ===================================================================
+dnl Checking for libexttextcat
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([libexttextcat],[LIBEXTTEXTCAT],[libexttextcat >= 3.4.1])
+if test "$with_system_libexttextcat" = "yes"; then
+    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
+fi
+AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
+
+dnl ===================================================================
+dnl Checking for libnumbertext
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.6])
+if test "$with_system_libnumbertext" = "yes"; then
+    SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
+    SYSTEM_LIBNUMBERTEXT=YES
+else
+    SYSTEM_LIBNUMBERTEXT=
+fi
+AC_SUBST(SYSTEM_LIBNUMBERTEXT)
+AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
+
+dnl ***************************************
+dnl testing libc version for Linux...
+dnl ***************************************
+if test "$_os" = "Linux"; then
+    AC_MSG_CHECKING([whether the libc is recent enough])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+    #include <features.h>
+    #if defined(__GNU_LIBRARY__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
+    #error glibc >= 2.1 is required
+    #endif
+    ]])],, [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, upgrade libc])])
+fi
+
+dnl =========================================
+dnl Check for uuidgen
+dnl =========================================
+if test "$_os" = "WINNT"; then
+    # we must use the uuidgen from the Windows SDK, which will be in the LO_PATH, but isn't in
+    # the PATH for AC_PATH_PROG. It is already tested above in the WINDOWS_SDK_HOME check.
+    UUIDGEN=uuidgen.exe
+    AC_SUBST(UUIDGEN)
+else
+    AC_PATH_PROG([UUIDGEN], [uuidgen])
+    if test -z "$UUIDGEN"; then
+        AC_MSG_WARN([uuid is needed for building installation sets])
+    fi
+fi
+
+dnl ***************************************
+dnl Checking for bison and flex
+dnl ***************************************
+AC_PATH_PROG(BISON, bison)
+if test -z "$BISON"; then
+    AC_MSG_ERROR([no bison found in \$PATH, install it])
+else
+    AC_MSG_CHECKING([the bison version])
+    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
+    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
+    dnl Accept newer than 2.0; for --enable-compiler-plugins at least 2.3 is known to be bad and
+    dnl cause
+    dnl
+    dnl   idlc/source/parser.y:222:15: error: externally available entity 'YYSTYPE' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]
+    dnl   typedef union YYSTYPE
+    dnl           ~~~~~~^~~~~~~
+    dnl
+    dnl while at least 3.4.1 is know to be good:
+    if test "$COMPILER_PLUGINS" = TRUE; then
+        if test "$_bison_longver" -lt 2004; then
+            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.4+ for --enable-compiler-plugins)])
+        fi
+    else
+        if test "$_bison_longver" -lt 2000; then
+            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.0+)])
+        fi
+    fi
+fi
+AC_SUBST([BISON])
+
+AC_PATH_PROG(FLEX, flex)
+if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+    FLEX=`cygpath -m $FLEX`
+fi
+if test -z "$FLEX"; then
+    AC_MSG_ERROR([no flex found in \$PATH, install it])
+else
+    AC_MSG_CHECKING([the flex version])
+    _flex_version=$($FLEX --version | $SED -e 's/^.*\([[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\).*$/\1/')
+    if test $(echo $_flex_version | $AWK -F. '{printf("%d%03d%03d", $1, $2, $3)}') -lt 2006000; then
+        AC_MSG_ERROR([failed ($FLEX $_flex_version found, but need at least 2.6.0)])
+    fi
+fi
+AC_SUBST([FLEX])
+
+AC_PATH_PROG(DIFF, diff)
+if test -z "$DIFF"; then
+    AC_MSG_ERROR(["diff" not found in \$PATH, install it])
+fi
+AC_SUBST([DIFF])
+
+AC_PATH_PROG(UNIQ, uniq)
+if test -z "$UNIQ"; then
+    AC_MSG_ERROR(["uniq" not found in \$PATH, install it])
+fi
+AC_SUBST([UNIQ])
+
+dnl ***************************************
+dnl Checking for patch
+dnl ***************************************
+AC_PATH_PROG(PATCH, patch)
+if test -z "$PATCH"; then
+    AC_MSG_ERROR(["patch" not found in \$PATH, install it])
+fi
+
+dnl On Solaris or macOS, check if --with-gnu-patch was used
+if test "$_os" = "SunOS" -o "$_os" = "Darwin"; then
+    if test -z "$with_gnu_patch"; then
+        GNUPATCH=$PATCH
+    else
+        if test -x "$with_gnu_patch"; then
+            GNUPATCH=$with_gnu_patch
+        else
+            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
+        fi
+    fi
+
+    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
+    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
+        AC_MSG_RESULT([yes])
+    else
+        if $GNUPATCH --version | grep "2\.0-.*-Apple" >/dev/null 2>/dev/null; then
+            AC_MSG_RESULT([no, but accepted (Apple patch)])
+            add_warning "patch utility is not GNU patch. Apple's patch should work OK, but it might experience issues where GNU patch doesn't."
+        else
+            AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
+        fi
+    fi
+else
+    GNUPATCH=$PATCH
+fi
+
+if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+    GNUPATCH=`cygpath -m $GNUPATCH`
+fi
+
+dnl We also need to check for --with-gnu-cp
+
+if test -z "$with_gnu_cp"; then
+    # check the place where the good stuff is hidden on Solaris...
+    if test -x /usr/gnu/bin/cp; then
+        GNUCP=/usr/gnu/bin/cp
+    else
+        AC_PATH_PROGS(GNUCP, gnucp cp)
+    fi
+    if test -z $GNUCP; then
+        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
+    fi
+else
+    if test -x "$with_gnu_cp"; then
+        GNUCP=$with_gnu_cp
+    else
+        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
+    fi
+fi
+
+if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+    GNUCP=`cygpath -m $GNUCP`
+fi
+
+AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
+if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
+    AC_MSG_RESULT([yes])
+elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
+    AC_MSG_RESULT([yes])
+else
+    case "$build_os" in
+    darwin*|netbsd*|openbsd*|freebsd*|dragonfly*)
+        x_GNUCP=[\#]
+        GNUCP=''
+        AC_MSG_RESULT([no gnucp found - using the system's cp command])
+        ;;
+    *)
+        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
+        ;;
+    esac
+fi
+
+AC_SUBST(GNUPATCH)
+AC_SUBST(GNUCP)
+AC_SUBST(x_GNUCP)
+
+dnl ***************************************
+dnl testing assembler path
+dnl ***************************************
+ML_EXE=""
+if test "$_os" = "WINNT"; then
+    case "$WIN_HOST_ARCH" in
+    x86) assembler=ml.exe ;;
+    x64) assembler=ml64.exe ;;
+    arm64) assembler=armasm64.exe ;;
+    esac
+
+    AC_MSG_CHECKING([for the MSVC assembler ($assembler)])
+    if test -f "$MSVC_HOST_PATH/$assembler"; then
+        ML_EXE=`win_short_path_for_make "$MSVC_HOST_PATH/$assembler"`
+        AC_MSG_RESULT([$ML_EXE])
+    else
+        AC_MSG_ERROR([not found in $MSVC_HOST_PATH])
+    fi
+fi
+
+AC_SUBST(ML_EXE)
+
+dnl ===================================================================
+dnl We need zip and unzip
+dnl ===================================================================
+AC_PATH_PROG(ZIP, zip)
+test -z "$ZIP" && AC_MSG_ERROR([zip is required])
+if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
+    AC_MSG_ERROR([Zip version 3.0 or newer is required to build, please install it and make sure it is the one found first in PATH],,)
+fi
+
+AC_PATH_PROG(UNZIP, unzip)
+test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])
+
+dnl ===================================================================
+dnl Zip must be a specific type for different build types.
+dnl ===================================================================
+if test $build_os = cygwin; then
+    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
+        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
+    fi
+fi
+
+dnl ===================================================================
+dnl We need touch with -h option support.
+dnl ===================================================================
+AC_PATH_PROG(TOUCH, touch)
+test -z "$TOUCH" && AC_MSG_ERROR([touch is required])
+touch "$WARNINGS_FILE"
+if ! "$TOUCH" -h "$WARNINGS_FILE" 2>/dev/null > /dev/null; then
+    AC_MSG_ERROR([touch version with -h option support is required to build, please install it and make sure it is the one found first in PATH],,)
+fi
+
+dnl ===================================================================
+dnl Check for system epoxy
+dnl ===================================================================
+EPOXY_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/epoxy/include"
+libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.2])
+
+dnl ===================================================================
+dnl Show which vclplugs will be built.
+dnl ===================================================================
+R=""
+
+libo_ENABLE_VCLPLUG([gen])
+libo_ENABLE_VCLPLUG([gtk3])
+libo_ENABLE_VCLPLUG([gtk3_kde5])
+libo_ENABLE_VCLPLUG([gtk4])
+libo_ENABLE_VCLPLUG([kf5])
+libo_ENABLE_VCLPLUG([kf6])
+libo_ENABLE_VCLPLUG([qt5])
+libo_ENABLE_VCLPLUG([qt6])
+
+if test "$_os" = "WINNT"; then
+    R="$R win"
+elif test "$_os" = "Darwin"; then
+    R="$R osx"
+elif test "$_os" = "iOS"; then
+    R="ios"
+elif test "$_os" = Android; then
+    R="android"
+fi
+
+build_vcl_plugins="$R"
+if test -z "$build_vcl_plugins"; then
+    build_vcl_plugins=" none"
+fi
+AC_MSG_NOTICE([VCLplugs to be built:${build_vcl_plugins}])
+VCL_PLUGIN_INFO=$R
+AC_SUBST([VCL_PLUGIN_INFO])
+
+if test "$DISABLE_DYNLOADING" = TRUE -a -z "$DISABLE_GUI" -a \( -z "$R" -o $(echo "$R" | wc -w) -ne 1 \); then
+    AC_MSG_ERROR([Can't build --disable-dynamic-loading without --disable-gui and a single VCL plugin"])
+fi
+
+dnl ===================================================================
+dnl Check for GTK libraries
+dnl ===================================================================
+
+GTK3_CFLAGS=""
+GTK3_LIBS=""
+ENABLE_GTKTILEDVIEWER=""
+if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" = "xyes"; then
+    if test "$with_system_cairo" = no; then
+        add_warning 'Non-system cairo combined with gtk3 is known to cause trouble (eg. broken image in the splashscreen). Use --with-system-cairo unless you know what you are doing.'
+    fi
+    : ${with_system_cairo:=yes}
+    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.20 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 atk >= 2.28.1 cairo)
+    GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
+    FilterLibs "${GTK3_LIBS}"
+    GTK3_LIBS="${filteredlibs}"
+
+    dnl We require egl only for the gtk3 plugin. Otherwise we use glx.
+    if test "$with_system_epoxy" != "yes"; then
+        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
+        AC_CHECK_HEADER(EGL/eglplatform.h, [],
+                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
+    fi
+elif test -n "$with_gtk3_build" -a "$OS" = "WNT"; then
+    PathFormat "${with_gtk3_build}/lib/pkgconfig"
+    if test "$build_os" = "cygwin"; then
+        dnl cygwin's pkg-config does not recognize "C:/..."-style paths, only "/cygdrive/c/..."
+        formatted_path_unix=`cygpath -au "$formatted_path_unix"`
+    fi
+
+    PKG_CONFIG_PATH="$formatted_path_unix"; export PKG_CONFIG_PATH
+    PKG_CHECK_MODULES(GTK3, cairo gdk-3.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0)
+    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
+    FilterLibs "${GTK3_LIBS}"
+    GTK3_LIBS="${filteredlibs}"
+    ENABLE_GTKTILEDVIEWER="yes"
+fi
+AC_SUBST(GTK3_LIBS)
+AC_SUBST(GTK3_CFLAGS)
+AC_SUBST(ENABLE_GTKTILEDVIEWER)
+
+GTK4_CFLAGS=""
+GTK4_LIBS=""
+if test "$test_gtk4" = yes -a "x$enable_gtk4" = "xyes"; then
+    if test "$with_system_cairo" = no; then
+        add_warning 'Non-system cairo combined with gtk4 is assumed to cause trouble; proceed at your own risk.'
+    fi
+    : ${with_system_cairo:=yes}
+    PKG_CHECK_MODULES(GTK4, gtk4 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo atk)
+    GTK4_CFLAGS=$(printf '%s' "$GTK4_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    GTK4_CFLAGS="$GTK4_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
+    FilterLibs "${GTK4_LIBS}"
+    GTK4_LIBS="${filteredlibs}"
+
+    dnl We require egl only for the gtk4 plugin. Otherwise we use glx.
+    if test "$with_system_epoxy" != "yes"; then
+        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
+        AC_CHECK_HEADER(EGL/eglplatform.h, [],
+                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
+    fi
+fi
+AC_SUBST(GTK4_LIBS)
+AC_SUBST(GTK4_CFLAGS)
+
+if test "$enable_introspection" = yes; then
+    if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
+        GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
+    else
+        AC_MSG_ERROR([--enable-introspection requires --enable-gtk3])
+    fi
+fi
+
+# AT-SPI2 tests require gtk3, xvfb-run, dbus-launch and atspi-2
+if ! test "$ENABLE_GTK3" = TRUE; then
+    if test "$enable_atspi_tests" = yes; then
+        AC_MSG_ERROR([--enable-atspi-tests requires --enable-gtk3])
+    fi
+    enable_atspi_tests=no
+fi
+if ! test "$enable_atspi_tests" = no; then
+    AC_PATH_PROGS([XVFB_RUN], [xvfb-run], no)
+    if ! test "$XVFB_RUN" = no; then
+        dnl make sure the found xvfb-run actually works
+        AC_MSG_CHECKING([whether $XVFB_RUN works...])
+        if $XVFB_RUN --auto-servernum true >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_RESULT([no])
+            XVFB_RUN=no
+        fi
+    fi
+    if test "$XVFB_RUN" = no; then
+        if test "$enable_atspi_tests" = yes; then
+            AC_MSG_ERROR([xvfb-run required by --enable-atspi-tests not found])
+        fi
+        enable_atspi_tests=no
+    fi
+fi
+if ! test "$enable_atspi_tests" = no; then
+    AC_PATH_PROGS([DBUS_LAUNCH], [dbus-launch], no)
+    if test "$DBUS_LAUNCH" = no; then
+        if test "$enable_atspi_tests" = yes; then
+            AC_MSG_ERROR([dbus-launch required by --enable-atspi-tests not found])
+        fi
+        enable_atspi_tests=no
+    fi
+fi
+if ! test "$enable_atspi_tests" = no; then
+    PKG_CHECK_MODULES([ATSPI2], [atspi-2 gobject-2.0],,
+                      [if test "$enable_atspi_tests" = yes; then
+                           AC_MSG_ERROR([$ATSPI2_PKG_ERRORS])
+                       else
+                           enable_atspi_tests=no
+                       fi])
+fi
+if ! test "x$enable_atspi_tests" = xno; then
+    PKG_CHECK_MODULES([ATSPI2_2_32], [atspi-2 >= 2.32],
+                      [have_atspi_scroll_to=1],
+                      [have_atspi_scroll_to=0])
+    AC_DEFINE_UNQUOTED([HAVE_ATSPI2_SCROLL_TO], [$have_atspi_scroll_to],
+                       [Whether AT-SPI2 has the scrollTo API])
+fi
+ENABLE_ATSPI_TESTS=
+test "$enable_atspi_tests" = no || ENABLE_ATSPI_TESTS=TRUE
+AC_SUBST([ENABLE_ATSPI_TESTS])
+
+dnl ===================================================================
+dnl check for dbus support
+dnl ===================================================================
+ENABLE_DBUS=""
+DBUS_CFLAGS=""
+DBUS_LIBS=""
+DBUS_GLIB_CFLAGS=""
+DBUS_GLIB_LIBS=""
+DBUS_HAVE_GLIB=""
+
+if test "$enable_dbus" = "no"; then
+    test_dbus=no
+fi
+
+AC_MSG_CHECKING([whether to enable DBUS support])
+if test "$test_dbus" = "yes"; then
+    ENABLE_DBUS="TRUE"
+    AC_MSG_RESULT([yes])
+    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.60)
+    AC_DEFINE(ENABLE_DBUS)
+    DBUS_CFLAGS=$(printf '%s' "$DBUS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${DBUS_LIBS}"
+    DBUS_LIBS="${filteredlibs}"
+
+    # Glib is needed for BluetoothServer
+    # Sets also DBUS_GLIB_CFLAGS/DBUS_GLIB_LIBS if successful.
+    PKG_CHECK_MODULES(DBUS_GLIB,[glib-2.0 >= 2.4],
+        [
+            DBUS_HAVE_GLIB="TRUE"
+            AC_DEFINE(DBUS_HAVE_GLIB,1)
+        ],
+        AC_MSG_WARN([[No Glib found, Bluetooth support will be disabled]])
+    )
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_SUBST(ENABLE_DBUS)
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+AC_SUBST(DBUS_GLIB_CFLAGS)
+AC_SUBST(DBUS_GLIB_LIBS)
+AC_SUBST(DBUS_HAVE_GLIB)
+
+AC_MSG_CHECKING([whether to enable Impress remote control])
+if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_SDREMOTE=TRUE
+    SDREMOTE_ENTITLEMENT="	<key>com.apple.security.network.server</key>
+	<true/>"
+    AC_MSG_CHECKING([whether to enable Bluetooth support in Impress remote control])
+
+    if test $OS = MACOSX && test "$MACOSX_SDK_VERSION" -ge 101500; then
+        # The Bluetooth code doesn't compile with macOS SDK 10.15
+        if test "$enable_sdremote_bluetooth" = yes; then
+            AC_MSG_ERROR([macOS SDK $macosx_sdk does not currently support --enable-sdremote-bluetooth])
+        fi
+        add_warning "not building the bluetooth part of the sdremote - used api was removed from macOS SDK 10.15"
+        enable_sdremote_bluetooth=no
+    fi
+    # If not explicitly enabled or disabled, default
+    if test -z "$enable_sdremote_bluetooth"; then
+        case "$OS" in
+        LINUX|MACOSX|WNT)
+            # Default to yes for these
+            enable_sdremote_bluetooth=yes
+            ;;
+        *)
+            # otherwise no
+            enable_sdremote_bluetooth=no
+            ;;
+        esac
+    fi
+    # $enable_sdremote_bluetooth is guaranteed non-empty now
+
+    if test "$enable_sdremote_bluetooth" != "no"; then
+        if test "$OS" = "LINUX"; then
+            if test "$ENABLE_DBUS" = "TRUE" -a "$DBUS_HAVE_GLIB" = "TRUE"; then
+                AC_MSG_RESULT([yes])
+                ENABLE_SDREMOTE_BLUETOOTH=TRUE
+                dnl ===================================================================
+                dnl Check for system bluez
+                dnl ===================================================================
+                AC_MSG_CHECKING([which Bluetooth header to use])
+                if test "$with_system_bluez" = "yes"; then
+                    AC_MSG_RESULT([external])
+                    AC_CHECK_HEADER(bluetooth/bluetooth.h, [],
+                        [AC_MSG_ERROR(bluetooth.h not found. install bluez)], [])
+                    SYSTEM_BLUEZ=TRUE
+                else
+                    AC_MSG_RESULT([internal])
+                    SYSTEM_BLUEZ=
+                fi
+            else
+                AC_MSG_RESULT([no, dbus disabled])
+                ENABLE_SDREMOTE_BLUETOOTH=
+                SYSTEM_BLUEZ=
+            fi
+        else
+            AC_MSG_RESULT([yes])
+            ENABLE_SDREMOTE_BLUETOOTH=TRUE
+            SYSTEM_BLUEZ=
+            SDREMOTE_ENTITLEMENT="$SDREMOTE_ENTITLEMENT
+	<key>com.apple.security.device.bluetooth</key>
+	<true/>"
+        fi
+    else
+        AC_MSG_RESULT([no])
+        ENABLE_SDREMOTE_BLUETOOTH=
+        SYSTEM_BLUEZ=
+    fi
+else
+    ENABLE_SDREMOTE=
+    SYSTEM_BLUEZ=
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_SDREMOTE)
+AC_SUBST(ENABLE_SDREMOTE_BLUETOOTH)
+AC_SUBST(SDREMOTE_ENTITLEMENT)
+AC_SUBST(SYSTEM_BLUEZ)
+
+dnl ===================================================================
+dnl Check whether to enable GIO support
+dnl ===================================================================
+if test "$ENABLE_GTK4" = "TRUE" -o "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
+    AC_MSG_CHECKING([whether to enable GIO support])
+    if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
+        dnl Need at least 2.26 for the dbus support.
+        PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26],
+                          [ENABLE_GIO="TRUE"], [ENABLE_GIO=""])
+        if test "$ENABLE_GIO" = "TRUE"; then
+            AC_DEFINE(ENABLE_GIO)
+            GIO_CFLAGS=$(printf '%s' "$GIO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+            FilterLibs "${GIO_LIBS}"
+            GIO_LIBS="${filteredlibs}"
+        fi
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST(ENABLE_GIO)
+AC_SUBST(GIO_CFLAGS)
+AC_SUBST(GIO_LIBS)
+
+
+dnl ===================================================================
+
+SPLIT_APP_MODULES=""
+if test "$enable_split_app_modules" = "yes"; then
+    SPLIT_APP_MODULES="TRUE"
+fi
+AC_SUBST(SPLIT_APP_MODULES)
+
+SPLIT_OPT_FEATURES=""
+if test "$enable_split_opt_features" = "yes"; then
+    SPLIT_OPT_FEATURES="TRUE"
+fi
+AC_SUBST(SPLIT_OPT_FEATURES)
+
+dnl ===================================================================
+dnl Check whether the GStreamer libraries are available.
+dnl ===================================================================
+
+ENABLE_GSTREAMER_1_0=""
+
+if test "$test_gstreamer_1_0" = yes; then
+
+    AC_MSG_CHECKING([whether to enable the GStreamer 1.0 avmedia backend])
+    if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
+        ENABLE_GSTREAMER_1_0="TRUE"
+        AC_MSG_RESULT([yes])
+        PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
+        GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${GSTREAMER_1_0_LIBS}"
+        GSTREAMER_1_0_LIBS="${filteredlibs}"
+        AC_DEFINE(ENABLE_GSTREAMER_1_0)
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST(GSTREAMER_1_0_CFLAGS)
+AC_SUBST(GSTREAMER_1_0_LIBS)
+AC_SUBST(ENABLE_GSTREAMER_1_0)
+
+ENABLE_OPENGL_TRANSITIONS=
+ENABLE_OPENGL_CANVAS=
+if test $_os = iOS -o $_os = Android -o "$ENABLE_FUZZERS" = "TRUE"; then
+   : # disable
+elif test "$_os" = "Darwin"; then
+    # We use frameworks on macOS, no need for detail checks
+    ENABLE_OPENGL_TRANSITIONS=TRUE
+    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
+    ENABLE_OPENGL_CANVAS=TRUE
+elif test $_os = WINNT; then
+    ENABLE_OPENGL_TRANSITIONS=TRUE
+    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
+    ENABLE_OPENGL_CANVAS=TRUE
+else
+    if test "$USING_X11" = TRUE; then
+        AC_CHECK_LIB(GL, glBegin, [:], AC_MSG_ERROR([libGL required.]))
+        ENABLE_OPENGL_TRANSITIONS=TRUE
+        AC_DEFINE(HAVE_FEATURE_OPENGL,1)
+        ENABLE_OPENGL_CANVAS=TRUE
+    fi
+fi
+
+AC_SUBST(ENABLE_OPENGL_TRANSITIONS)
+AC_SUBST(ENABLE_OPENGL_CANVAS)
+
+dnl =================================================
+dnl Check whether to build with OpenCL support.
+dnl =================================================
+
+if test $_os != iOS -a $_os != Android -a "$ENABLE_FUZZERS" != "TRUE" -a "$enable_opencl" = "yes"; then
+    # OPENCL in BUILD_TYPE and HAVE_FEATURE_OPENCL tell that OpenCL is potentially available on the
+    # platform (optional at run-time, used through clew).
+    BUILD_TYPE="$BUILD_TYPE OPENCL"
+    AC_DEFINE(HAVE_FEATURE_OPENCL)
+fi
+
+dnl =================================================
+dnl Check whether to build with dconf support.
+dnl =================================================
+
+if test $_os != Android -a $_os != iOS -a "$enable_dconf" != no; then
+    PKG_CHECK_MODULES([DCONF], [dconf >= 0.40.0], [], [
+        if test "$enable_dconf" = yes; then
+            AC_MSG_ERROR([dconf not found])
+        else
+            enable_dconf=no
+        fi])
+fi
+AC_MSG_CHECKING([whether to enable dconf])
+if test $_os = Android -o $_os = iOS -o "$enable_dconf" = no; then
+    DCONF_CFLAGS=
+    DCONF_LIBS=
+    ENABLE_DCONF=
+    AC_MSG_RESULT([no])
+else
+    ENABLE_DCONF=TRUE
+    AC_DEFINE(ENABLE_DCONF)
+    AC_MSG_RESULT([yes])
+fi
+AC_SUBST([DCONF_CFLAGS])
+AC_SUBST([DCONF_LIBS])
+AC_SUBST([ENABLE_DCONF])
+
+# pdf import?
+AC_MSG_CHECKING([whether to build the PDF import feature])
+ENABLE_PDFIMPORT=
+if test -z "$enable_pdfimport" -o "$enable_pdfimport" = yes; then
+    AC_MSG_RESULT([yes])
+    ENABLE_PDFIMPORT=TRUE
+    AC_DEFINE(HAVE_FEATURE_PDFIMPORT)
+else
+    AC_MSG_RESULT([no])
+fi
+
+# Pdfium?
+AC_MSG_CHECKING([whether to build PDFium])
+ENABLE_PDFIUM=
+if test \( -z "$enable_pdfium" -a "$ENABLE_PDFIMPORT" = "TRUE" \) -o "$enable_pdfium" = yes; then
+    AC_MSG_RESULT([yes])
+    ENABLE_PDFIUM=TRUE
+    BUILD_TYPE="$BUILD_TYPE PDFIUM"
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_PDFIUM)
+
+if test "$ENABLE_PDFIUM" = "TRUE"; then
+    AC_MSG_CHECKING([which OpenJPEG library to use])
+    if test "$with_system_openjpeg" = "yes"; then
+        SYSTEM_OPENJPEG2=TRUE
+        AC_MSG_RESULT([external])
+        PKG_CHECK_MODULES( OPENJPEG2, libopenjp2 )
+        OPENJPEG2_CFLAGS=$(printf '%s' "$OPENJPEG2_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${OPENJPEG2_LIBS}"
+        OPENJPEG2_LIBS="${filteredlibs}"
+    else
+        SYSTEM_OPENJPEG2=FALSE
+        AC_MSG_RESULT([internal])
+    fi
+
+    AC_MSG_CHECKING([which Abseil library to use])
+    if test "$with_system_abseil" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_ABSEIL=TRUE
+        AC_LANG_PUSH([C++])
+        AC_CHECK_HEADER(absl/types/bad_optional_access.h, [],
+                        [AC_MSG_ERROR(abseil headers not found.)], [])
+        AC_CHECK_HEADER(absl/types/bad_variant_access.h, [],
+                        [AC_MSG_ERROR(abseil headers not found.)], [])
+        AC_CHECK_LIB([absl_bad_optional_access], [main], [],
+                     [AC_MSG_ERROR([libabsl_bad_optional_access library not found.])])
+        AC_CHECK_LIB([absl_bad_variant_access], [main], [],
+                     [AC_MSG_ERROR([libabsl_bad_variant_access library not found.])])
+        ABSEIL_LIBS="-labsl_bad_optional_access -labsl_bad_variant_access"
+        AC_LANG_POP([C++])
+        ABSEIL_CFLAGS=$(printf '%s' "$ABSEIL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${ABSEIL_LIBS}"
+        ABSEIL_LIBS="${filteredlibs}"
+    else
+        AC_MSG_RESULT([internal])
+    fi
+fi
+AC_SUBST(SYSTEM_OPENJPEG2)
+AC_SUBST(SYSTEM_ABSEIL)
+AC_SUBST(ABSEIL_CFLAGS)
+AC_SUBST(ABSEIL_LIBS)
+
+dnl ===================================================================
+dnl Check for poppler
+dnl ===================================================================
+ENABLE_POPPLER=
+AC_MSG_CHECKING([whether to build Poppler])
+if test \( -z "$enable_poppler" -a "$ENABLE_PDFIMPORT" = "TRUE" -a $_os != Android \) -o "$enable_poppler" = yes; then
+    AC_MSG_RESULT([yes])
+    ENABLE_POPPLER=TRUE
+    AC_DEFINE(HAVE_FEATURE_POPPLER)
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_POPPLER)
+
+if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" != "TRUE" -a "$ENABLE_PDFIUM" != "TRUE"; then
+    AC_MSG_ERROR([Cannot import PDF without either Pdfium or Poppler; please enable either of them.])
+fi
+
+if test "$ENABLE_PDFIMPORT" != "TRUE" -a \( "$ENABLE_POPPLER" = "TRUE" -o "$ENABLE_PDFIUM" = "TRUE" \); then
+    AC_MSG_ERROR([Cannot enable Pdfium or Poppler when PDF importing is disabled; please enable PDF import first.])
+fi
+
+if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" = "TRUE"; then
+    dnl ===================================================================
+    dnl Check for system poppler
+    dnl ===================================================================
+    AC_MSG_CHECKING([which PDF import poppler to use])
+    if test "$with_system_poppler" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_POPPLER=TRUE
+        PKG_CHECK_MODULES(POPPLER,[poppler >= 0.14 poppler-cpp])
+        POPPLER_CFLAGS=$(printf '%s' "$POPPLER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${POPPLER_LIBS}"
+        POPPLER_LIBS="${filteredlibs}"
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_POPPLER=
+        BUILD_TYPE="$BUILD_TYPE POPPLER"
+    fi
+    AC_DEFINE([ENABLE_PDFIMPORT],1)
+fi
+AC_SUBST(ENABLE_PDFIMPORT)
+AC_SUBST(SYSTEM_POPPLER)
+AC_SUBST(POPPLER_CFLAGS)
+AC_SUBST(POPPLER_LIBS)
+
+# Skia?
+ENABLE_SKIA=
+if test "$enable_skia" != "no" -a "$build_skia" = "yes" -a -z "$DISABLE_GUI"; then
+    # Skia now requires at least freetype2 >= 2.8.1, which is less that what LO requires as system freetype.
+    if test "$SYSTEM_FREETYPE" = TRUE; then
+        PKG_CHECK_EXISTS(freetype2 >= 21.0.15, # 21.0.15 = 2.8.1
+            [skia_freetype_ok=yes],
+            [skia_freetype_ok=no])
+    else # internal is ok
+        skia_freetype_ok=yes
+    fi
+    AC_MSG_CHECKING([whether to build Skia])
+    if test "$skia_freetype_ok" = "yes"; then
+        if test "$enable_skia" = "debug"; then
+            AC_MSG_RESULT([yes (debug)])
+            ENABLE_SKIA_DEBUG=TRUE
+        else
+            AC_MSG_RESULT([yes])
+            ENABLE_SKIA_DEBUG=
+        fi
+        ENABLE_SKIA=TRUE
+        if test "$ENDIANNESS" = "big" && test "$ENABLE_SKIA" = "TRUE"; then
+            AC_MSG_ERROR([skia doesn't work/isn't supported upstream on big-endian. Use --disable-skia])
+        fi
+
+        AC_DEFINE(HAVE_FEATURE_SKIA)
+        BUILD_TYPE="$BUILD_TYPE SKIA"
+
+        if test "$OS" = "MACOSX"; then
+            AC_DEFINE(SK_GANESH,1)
+            AC_DEFINE(SK_METAL,1)
+            SKIA_GPU=METAL
+            AC_SUBST(SKIA_GPU)
+        else
+            AC_DEFINE(SK_GANESH,1)
+            AC_DEFINE(SK_VULKAN,1)
+            SKIA_GPU=VULKAN
+            AC_SUBST(SKIA_GPU)
+        fi
+    else
+        AC_MSG_RESULT([no (freetype too old)])
+        add_warning "freetype version is too old for Skia library, at least 2.8.1 required, Skia support disabled"
+    fi
+
+else
+    AC_MSG_CHECKING([whether to build Skia])
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_SKIA)
+AC_SUBST(ENABLE_SKIA_DEBUG)
+
+LO_CLANG_CXXFLAGS_INTRINSICS_SSE2=
+LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3=
+LO_CLANG_CXXFLAGS_INTRINSICS_SSE41=
+LO_CLANG_CXXFLAGS_INTRINSICS_SSE42=
+LO_CLANG_CXXFLAGS_INTRINSICS_AVX=
+LO_CLANG_CXXFLAGS_INTRINSICS_AVX2=
+LO_CLANG_CXXFLAGS_INTRINSICS_AVX512=
+LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F=
+LO_CLANG_CXXFLAGS_INTRINSICS_F16C=
+LO_CLANG_CXXFLAGS_INTRINSICS_FMA=
+LO_CLANG_VERSION=
+HAVE_LO_CLANG_DLLEXPORTINLINES=
+
+if test "$ENABLE_SKIA" = TRUE -a "$COM_IS_CLANG" != TRUE; then
+    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
+        AC_MSG_CHECKING([for Clang])
+        AC_MSG_RESULT([$LO_CLANG_CC / $LO_CLANG_CXX])
+    else
+        if test "$_os" = "WINNT"; then
+            AC_MSG_CHECKING([for clang-cl])
+            if test -x "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"; then
+                LO_CLANG_CC=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"`
+            elif test -n "$PROGRAMFILES" -a -x "$(cygpath -u "$PROGRAMFILES/LLVM/bin/clang-cl.exe")"; then
+                LO_CLANG_CC=`win_short_path_for_make "$PROGRAMFILES/LLVM/bin/clang-cl.exe"`
+            elif test -x "$(cygpath -u "c:/Program Files/LLVM/bin/clang-cl.exe")"; then
+                LO_CLANG_CC=`win_short_path_for_make "c:/Program Files/LLVM/bin/clang-cl.exe"`
+            fi
+            if test -n "$LO_CLANG_CC"; then
+                dnl explicitly set -m32/-m64
+                LO_CLANG_CC="$LO_CLANG_CC -m$WIN_HOST_BITS"
+                LO_CLANG_CXX="$LO_CLANG_CC"
+                AC_MSG_RESULT([$LO_CLANG_CC])
+            else
+                AC_MSG_RESULT([no])
+            fi
+
+            AC_MSG_CHECKING([the dependency generation prefix (clang.exe -showIncludes)])
+            echo "#include <stdlib.h>" > conftest.c
+            LO_CLANG_SHOWINCLUDES_PREFIX=`VSLANG=1033 $LO_CLANG_CC $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
+                grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
+            rm -f conftest.c conftest.obj
+            if test -z "$LO_CLANG_SHOWINCLUDES_PREFIX"; then
+                AC_MSG_ERROR([cannot determine the -showIncludes prefix])
+            else
+                AC_MSG_RESULT(["$LO_CLANG_SHOWINCLUDES_PREFIX"])
+            fi
+        else
+            AC_CHECK_PROG(LO_CLANG_CC,clang,clang,[])
+            AC_CHECK_PROG(LO_CLANG_CXX,clang++,clang++,[])
+        fi
+    fi
+    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
+        clang2_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $LO_CLANG_CC -E - | tail -1 | sed 's/ //g'`
+        LO_CLANG_VERSION=`echo "$clang2_version" | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
+        if test "$LO_CLANG_VERSION" -lt 50002; then
+            AC_MSG_WARN(["$clang2_version" is too old or unrecognized, must be at least Clang 5.0.2])
+            LO_CLANG_CC=
+            LO_CLANG_CXX=
+        fi
+    fi
+    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX" -a "$_os" = "WINNT"; then
+        save_CXX="$CXX"
+        CXX="$LO_CLANG_CXX"
+        AC_MSG_CHECKING([whether $CXX supports -Zc:dllexportInlines-])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
+                HAVE_LO_CLANG_DLLEXPORTINLINES=TRUE
+                AC_MSG_RESULT([yes])
+            ], [AC_MSG_RESULT([no])])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_LANG_POP([C++])
+        CXX="$save_CXX"
+        if test -z "$HAVE_LO_CLANG_DLLEXPORTINLINES"; then
+            AC_MSG_ERROR([Clang compiler does not support -Zc:dllexportInlines-. The Skia library needs to be built using a newer Clang version, or use --disable-skia.])
+        fi
+    fi
+    if test -z "$LO_CLANG_CC" -o -z "$LO_CLANG_CXX"; then
+        # Skia is the default on Windows and Mac, so hard-require Clang.
+        # Elsewhere it's used just by the 'gen' VCL backend which is rarely used.
+        if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
+            AC_MSG_ERROR([Clang compiler not found. The Skia library needs to be built using Clang, or use --disable-skia.])
+        else
+            AC_MSG_WARN([Clang compiler not found.])
+        fi
+    else
+
+        save_CXX="$CXX"
+        CXX="$LO_CLANG_CXX"
+        # copy&paste (and adjust) of intrinsics checks, since MSVC's -arch doesn't work well for Clang-cl
+        flag_sse2=-msse2
+        flag_ssse3=-mssse3
+        flag_sse41=-msse4.1
+        flag_sse42=-msse4.2
+        flag_avx=-mavx
+        flag_avx2=-mavx2
+        flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
+        flag_avx512f=-mavx512f
+        flag_f16c=-mf16c
+        flag_fma=-mfma
+
+        AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_sse2"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <emmintrin.h>
+            int main () {
+                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+                c = _mm_xor_si128 (a, b);
+                return 0;
+            }
+            ])],
+            [can_compile_sse2=yes],
+            [can_compile_sse2=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_sse2}])
+        if test "${can_compile_sse2}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_ssse3"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <tmmintrin.h>
+            int main () {
+                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+                c = _mm_maddubs_epi16 (a, b);
+                return 0;
+            }
+            ])],
+            [can_compile_ssse3=yes],
+            [can_compile_ssse3=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_ssse3}])
+        if test "${can_compile_ssse3}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_sse41"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <smmintrin.h>
+            int main () {
+                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+                c = _mm_cmpeq_epi64 (a, b);
+                return 0;
+            }
+            ])],
+            [can_compile_sse41=yes],
+            [can_compile_sse41=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_sse41}])
+        if test "${can_compile_sse41}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_sse42"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <nmmintrin.h>
+            int main () {
+                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+                c = _mm_cmpgt_epi64 (a, b);
+                return 0;
+            }
+            ])],
+            [can_compile_sse42=yes],
+            [can_compile_sse42=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_sse42}])
+        if test "${can_compile_sse42}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_avx"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <immintrin.h>
+            int main () {
+                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
+                c = _mm256_xor_ps(a, b);
+                return 0;
+            }
+            ])],
+            [can_compile_avx=yes],
+            [can_compile_avx=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_avx}])
+        if test "${can_compile_avx}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_AVX="$flag_avx"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_avx2"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <immintrin.h>
+            int main () {
+                __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
+                c = _mm256_maddubs_epi16(a, b);
+                return 0;
+            }
+            ])],
+            [can_compile_avx2=yes],
+            [can_compile_avx2=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_avx2}])
+        if test "${can_compile_avx2}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_avx512"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <immintrin.h>
+            int main () {
+                __m512i a = _mm512_loadu_si512(0);
+                __m512d v1 = _mm512_load_pd(0);
+                // https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/config/i386/avx512fintrin.h;h=23bce99cbe7016a04e14c2163ed3fe6a5a64f4e2
+                __m512d v2 = _mm512_abs_pd(v1);
+                return 0;
+            }
+            ])],
+            [can_compile_avx512=yes],
+            [can_compile_avx512=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_avx512}])
+        if test "${can_compile_avx512}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
+            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F="$flag_avx512f"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_f16c"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <immintrin.h>
+            int main () {
+                __m128i a = _mm_set1_epi32 (0);
+                __m128 c;
+                c = _mm_cvtph_ps(a);
+                return 0;
+            }
+            ])],
+            [can_compile_f16c=yes],
+            [can_compile_f16c=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_f16c}])
+        if test "${can_compile_f16c}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
+        fi
+
+        AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS $flag_fma"
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <immintrin.h>
+            int main () {
+                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
+                d = _mm256_fmadd_ps(a, b, c);
+                return 0;
+            }
+            ])],
+            [can_compile_fma=yes],
+            [can_compile_fma=no])
+        AC_LANG_POP([C++])
+        CXXFLAGS=$save_CXXFLAGS
+        AC_MSG_RESULT([${can_compile_fma}])
+        if test "${can_compile_fma}" = "yes" ; then
+            LO_CLANG_CXXFLAGS_INTRINSICS_FMA="$flag_fma"
+        fi
+
+        CXX="$save_CXX"
+    fi
+fi
+#
+# prefix LO_CLANG_CC/LO_CLANG_CXX with ccache if needed
+#
+if test "$CCACHE" != "" -a -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
+    AC_MSG_CHECKING([whether $LO_CLANG_CC is already ccached])
+    AC_LANG_PUSH([C])
+    save_CC="$CC"
+    CC="$LO_CLANG_CC"
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS --ccache-skip -O2 -Werror"
+    dnl an empty program will do, we're checking the compiler flags
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+                      [use_ccache=yes], [use_ccache=no])
+    CFLAGS=$save_CFLAGS
+    CC=$save_CC
+    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
+        AC_MSG_RESULT([yes])
+    else
+        LO_CLANG_CC="$CCACHE $LO_CLANG_CC"
+        AC_MSG_RESULT([no])
+    fi
+    AC_LANG_POP([C])
+
+    AC_MSG_CHECKING([whether $LO_CLANG_CXX is already ccached])
+    AC_LANG_PUSH([C++])
+    save_CXX="$CXX"
+    CXX="$LO_CLANG_CXX"
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS --ccache-skip -O2 -Werror"
+    dnl an empty program will do, we're checking the compiler flags
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+                      [use_ccache=yes], [use_ccache=no])
+    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
+        AC_MSG_RESULT([yes])
+    else
+        LO_CLANG_CXX="$CCACHE $LO_CLANG_CXX"
+        AC_MSG_RESULT([no])
+    fi
+    CXXFLAGS=$save_CXXFLAGS
+    CXX=$save_CXX
+    AC_LANG_POP([C++])
+fi
+
+AC_SUBST(LO_CLANG_CC)
+AC_SUBST(LO_CLANG_CXX)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE2)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE41)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE42)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX2)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_F16C)
+AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_FMA)
+AC_SUBST(LO_CLANG_SHOWINCLUDES_PREFIX)
+AC_SUBST(LO_CLANG_VERSION)
+AC_SUBST(CLANG_USE_LD)
+AC_SUBST([HAVE_LO_CLANG_DLLEXPORTINLINES])
+
+SYSTEM_GPGMEPP=
+
+AC_MSG_CHECKING([whether to enable gpgmepp])
+if test "$enable_gpgmepp" = no; then
+    AC_MSG_RESULT([no])
+elif test "$enable_mpl_subset" = "yes"; then
+    AC_MSG_RESULT([no (MPL only)])
+elif test "$enable_fuzzers" = "yes"; then
+    AC_MSG_RESULT([no (oss-fuzz)])
+elif test \( \( "$_os" = "Linux" -o "$_os" = "Darwin" \) -a "$ENABLE_NSS" = TRUE \) -o "$_os" = "WINNT" ; then
+    AC_MSG_RESULT([yes])
+    dnl ===================================================================
+    dnl Check for system gpgme
+    dnl ===================================================================
+    AC_MSG_CHECKING([which gpgmepp to use])
+    if test "$with_system_gpgmepp" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_GPGMEPP=TRUE
+
+        # C++ library doesn't come with fancy gpgmepp-config, check for headers the old-fashioned way
+        AC_CHECK_HEADER(gpgme++/gpgmepp_version.h, [ GPGMEPP_CFLAGS=-I/usr/include/gpgme++ ],
+            [AC_MSG_ERROR([gpgmepp headers not found, install gpgmepp >= 1.14 development package])], [])
+        AC_CHECK_HEADER(gpgme.h, [],
+            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
+        AC_CHECK_LIB(gpgmepp, main, [],
+            [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
+        GPGMEPP_LIBS=-lgpgmepp
+    else
+        AC_MSG_RESULT([internal])
+        BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
+
+        GPG_ERROR_CFLAGS="-I${WORKDIR}/UnpackedTarball/libgpg-error/src"
+        LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src"
+        if test "$_os" != "WINNT"; then
+            GPG_ERROR_LIBS="-L${WORKDIR}/UnpackedTarball/libgpg-error/src/.libs -lgpg-error"
+            LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan"
+        fi
+    fi
+    ENABLE_GPGMEPP=TRUE
+    AC_DEFINE([HAVE_FEATURE_GPGME])
+    AC_PATH_PROG(GPG, gpg)
+    # TODO: Windows's cygwin gpg does not seem to work with our gpgme,
+    # so let's exclude that manually for the moment
+    if test -n "$GPG" -a "$_os" != "WINNT"; then
+        # make sure we not only have a working gpgme, but a full working
+        # gpg installation to run OpenPGP signature verification
+        AC_DEFINE([HAVE_FEATURE_GPGVERIFY])
+    fi
+    if test "$_os" = "Linux"; then
+      uid=`id -u`
+      AC_MSG_CHECKING([for /run/user/$uid])
+      if test -d /run/user/$uid; then
+        AC_MSG_RESULT([yes])
+        AC_PATH_PROG(GPGCONF, gpgconf)
+
+        # Older versions of gpgconf are not working as expected, since
+        # `gpgconf --remove-socketdir` fails to exit any gpg-agent daemon operating
+        # on that socket dir that has (indirectly) been started by the tests in xmlsecurity/qa/unit/signing/signing.cxx
+        # (see commit message of f0305ec0a7d199e605511844d9d6af98b66d4bfd%5E )
+        AC_MSG_CHECKING([whether version of gpgconf is suitable ... ])
+        GPGCONF_VERSION=`"$GPGCONF" --version | "$AWK" '/^gpgconf \(GnuPG\)/{print $3}'`
+        GPGCONF_NUMVER=`echo $GPGCONF_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
+        if test "$GPGCONF_VERSION" = "2.2_OOo" -o "$GPGCONF_NUMVER" -ge "020200"; then
+          AC_MSG_RESULT([yes, $GPGCONF_VERSION])
+          AC_MSG_CHECKING([for gpgconf --create-socketdir... ])
+          if $GPGCONF --dump-options > /dev/null ; then
+            if $GPGCONF --dump-options | grep -q create-socketdir ; then
+              AC_MSG_RESULT([yes])
+              AC_DEFINE([HAVE_GPGCONF_SOCKETDIR])
+              AC_DEFINE_UNQUOTED([GPGME_GPGCONF], ["$GPGCONF"])
+            else
+              AC_MSG_RESULT([no])
+            fi
+          else
+            AC_MSG_RESULT([no. missing or broken gpgconf?])
+          fi
+        else
+          AC_MSG_RESULT([no, $GPGCONF_VERSION])
+        fi
+      else
+        AC_MSG_RESULT([no])
+     fi
+   fi
+else
+    AC_MSG_RESULT([no (unsupported OS or missing NSS)])
+fi
+AC_SUBST(ENABLE_GPGMEPP)
+AC_SUBST(SYSTEM_GPGMEPP)
+AC_SUBST(GPG_ERROR_CFLAGS)
+AC_SUBST(GPG_ERROR_LIBS)
+AC_SUBST(LIBASSUAN_CFLAGS)
+AC_SUBST(LIBASSUAN_LIBS)
+AC_SUBST(GPGMEPP_CFLAGS)
+AC_SUBST(GPGMEPP_LIBS)
+
+AC_MSG_CHECKING([whether to build Java Websocket for the UNO remote websocket client])
+if test "$with_java" != "no"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_JAVA_WEBSOCKET=TRUE
+    BUILD_TYPE="$BUILD_TYPE JAVA_WEBSOCKET"
+    NEED_ANT=TRUE
+else
+    AC_MSG_RESULT([no])
+    ENABLE_JAVA_WEBSOCKET=
+fi
+AC_SUBST(ENABLE_JAVA_WEBSOCKET)
+
+AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
+if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_MEDIAWIKI=TRUE
+    BUILD_TYPE="$BUILD_TYPE XSLTML"
+    if test  "x$with_java" = "xno"; then
+        AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
+    fi
+else
+    AC_MSG_RESULT([no])
+    ENABLE_MEDIAWIKI=
+    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
+fi
+AC_SUBST(ENABLE_MEDIAWIKI)
+
+AC_MSG_CHECKING([whether to build the Report Builder])
+if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_REPORTBUILDER=TRUE
+    AC_MSG_CHECKING([which jfreereport libs to use])
+    if test "$with_system_jfreereport" = "yes"; then
+        SYSTEM_JFREEREPORT=TRUE
+        AC_MSG_RESULT([external])
+        if test -z $SAC_JAR; then
+            SAC_JAR=/usr/share/java/sac.jar
+        fi
+        if ! test -f $SAC_JAR; then
+             AC_MSG_ERROR(sac.jar not found.)
+        fi
+
+        if test -z $LIBXML_JAR; then
+            if test -f /usr/share/java/libxml-1.0.0.jar; then
+                LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar
+            elif test -f /usr/share/java/libxml.jar; then
+                LIBXML_JAR=/usr/share/java/libxml.jar
+            else
+                AC_MSG_ERROR(libxml.jar replacement not found.)
+            fi
+        elif ! test -f $LIBXML_JAR; then
+            AC_MSG_ERROR(libxml.jar not found.)
+        fi
+
+        if test -z $FLUTE_JAR; then
+            if test -f /usr/share/java/flute-1.3.0.jar; then
+                FLUTE_JAR=/usr/share/java/flute-1.3.0.jar
+            elif test -f /usr/share/java/flute.jar; then
+                FLUTE_JAR=/usr/share/java/flute.jar
+            else
+                AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)
+            fi
+        elif ! test -f $FLUTE_JAR; then
+            AC_MSG_ERROR(flute-1.3.0.jar not found.)
+        fi
+
+        if test -z $JFREEREPORT_JAR; then
+            if test -f /usr/share/java/flow-engine-0.9.2.jar; then
+                JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar
+            elif test -f /usr/share/java/flow-engine.jar; then
+                JFREEREPORT_JAR=/usr/share/java/flow-engine.jar
+            else
+                AC_MSG_ERROR(jfreereport.jar replacement not found.)
+            fi
+        elif ! test -f  $JFREEREPORT_JAR; then
+                AC_MSG_ERROR(jfreereport.jar not found.)
+        fi
+
+        if test -z $LIBLAYOUT_JAR; then
+            if test -f /usr/share/java/liblayout-0.2.9.jar; then
+                LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar
+            elif test -f /usr/share/java/liblayout.jar; then
+                LIBLAYOUT_JAR=/usr/share/java/liblayout.jar
+            else
+                AC_MSG_ERROR(liblayout.jar replacement not found.)
+            fi
+        elif ! test -f $LIBLAYOUT_JAR; then
+                AC_MSG_ERROR(liblayout.jar not found.)
+        fi
+
+        if test -z $LIBLOADER_JAR; then
+            if test -f /usr/share/java/libloader-1.0.0.jar; then
+                LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar
+            elif test -f /usr/share/java/libloader.jar; then
+                LIBLOADER_JAR=/usr/share/java/libloader.jar
+            else
+                AC_MSG_ERROR(libloader.jar replacement not found.)
+            fi
+        elif ! test -f  $LIBLOADER_JAR; then
+            AC_MSG_ERROR(libloader.jar not found.)
+        fi
+
+        if test -z $LIBFORMULA_JAR; then
+            if test -f /usr/share/java/libformula-0.2.0.jar; then
+                LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar
+            elif test -f /usr/share/java/libformula.jar; then
+                LIBFORMULA_JAR=/usr/share/java/libformula.jar
+            else
+                AC_MSG_ERROR(libformula.jar replacement not found.)
+            fi
+        elif ! test -f $LIBFORMULA_JAR; then
+                AC_MSG_ERROR(libformula.jar not found.)
+        fi
+
+        if test -z $LIBREPOSITORY_JAR; then
+            if test -f /usr/share/java/librepository-1.0.0.jar; then
+                LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar
+            elif test -f /usr/share/java/librepository.jar; then
+                LIBREPOSITORY_JAR=/usr/share/java/librepository.jar
+            else
+                AC_MSG_ERROR(librepository.jar replacement not found.)
+            fi
+        elif ! test -f $LIBREPOSITORY_JAR; then
+            AC_MSG_ERROR(librepository.jar not found.)
+        fi
+
+        if test -z $LIBFONTS_JAR; then
+            if test -f /usr/share/java/libfonts-1.0.0.jar; then
+                LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar
+            elif test -f /usr/share/java/libfonts.jar; then
+                LIBFONTS_JAR=/usr/share/java/libfonts.jar
+            else
+                AC_MSG_ERROR(libfonts.jar replacement not found.)
+            fi
+        elif ! test -f $LIBFONTS_JAR; then
+                AC_MSG_ERROR(libfonts.jar not found.)
+        fi
+
+        if test -z $LIBSERIALIZER_JAR; then
+            if test -f /usr/share/java/libserializer-1.0.0.jar; then
+                LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar
+            elif test -f /usr/share/java/libserializer.jar; then
+                LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar
+            else
+                AC_MSG_ERROR(libserializer.jar replacement not found.)
+            fi
+        elif ! test -f $LIBSERIALIZER_JAR; then
+                AC_MSG_ERROR(libserializer.jar not found.)
+        fi
+
+        if test -z $LIBBASE_JAR; then
+            if test -f /usr/share/java/libbase-1.0.0.jar; then
+                LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar
+            elif test -f /usr/share/java/libbase.jar; then
+                LIBBASE_JAR=/usr/share/java/libbase.jar
+            else
+                AC_MSG_ERROR(libbase.jar replacement not found.)
+            fi
+        elif ! test -f $LIBBASE_JAR; then
+            AC_MSG_ERROR(libbase.jar not found.)
+        fi
+
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_JFREEREPORT=
+        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
+        NEED_ANT=TRUE
+    fi
+else
+    AC_MSG_RESULT([no])
+    ENABLE_REPORTBUILDER=
+    SYSTEM_JFREEREPORT=
+fi
+AC_SUBST(ENABLE_REPORTBUILDER)
+AC_SUBST(SYSTEM_JFREEREPORT)
+AC_SUBST(SAC_JAR)
+AC_SUBST(LIBXML_JAR)
+AC_SUBST(FLUTE_JAR)
+AC_SUBST(JFREEREPORT_JAR)
+AC_SUBST(LIBBASE_JAR)
+AC_SUBST(LIBLAYOUT_JAR)
+AC_SUBST(LIBLOADER_JAR)
+AC_SUBST(LIBFORMULA_JAR)
+AC_SUBST(LIBREPOSITORY_JAR)
+AC_SUBST(LIBFONTS_JAR)
+AC_SUBST(LIBSERIALIZER_JAR)
+
+# scripting provider for BeanShell?
+AC_MSG_CHECKING([whether to build support for scripts in BeanShell])
+if test "${enable_scripting_beanshell}" != "no" -a "x$with_java" != "xno"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_SCRIPTING_BEANSHELL=TRUE
+
+    dnl ===================================================================
+    dnl Check for system beanshell
+    dnl ===================================================================
+    AC_MSG_CHECKING([which beanshell to use])
+    if test "$with_system_beanshell" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_BSH=TRUE
+        if test -z $BSH_JAR; then
+            BSH_JAR=/usr/share/java/bsh.jar
+        fi
+        if ! test -f $BSH_JAR; then
+            AC_MSG_ERROR(bsh.jar not found.)
+        fi
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_BSH=
+        BUILD_TYPE="$BUILD_TYPE BSH"
+    fi
+else
+    AC_MSG_RESULT([no])
+    ENABLE_SCRIPTING_BEANSHELL=
+    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_BEANSHELL"
+fi
+AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
+AC_SUBST(SYSTEM_BSH)
+AC_SUBST(BSH_JAR)
+
+# scripting provider for JavaScript?
+AC_MSG_CHECKING([whether to build support for scripts in JavaScript])
+if test "${enable_scripting_javascript}" != "no" -a "x$with_java" != "xno"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_SCRIPTING_JAVASCRIPT=TRUE
+
+    dnl ===================================================================
+    dnl Check for system rhino
+    dnl ===================================================================
+    AC_MSG_CHECKING([which rhino to use])
+    if test "$with_system_rhino" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_RHINO=TRUE
+        if test -z $RHINO_JAR; then
+            RHINO_JAR=/usr/share/java/js.jar
+        fi
+        if ! test -f $RHINO_JAR; then
+            AC_MSG_ERROR(js.jar not found.)
+        fi
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_RHINO=
+        BUILD_TYPE="$BUILD_TYPE RHINO"
+        NEED_ANT=TRUE
+    fi
+else
+    AC_MSG_RESULT([no])
+    ENABLE_SCRIPTING_JAVASCRIPT=
+    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_JAVASCRIPT"
+fi
+AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
+AC_SUBST(SYSTEM_RHINO)
+AC_SUBST(RHINO_JAR)
+
+# This is only used in Qt5/Qt6/KF5/KF6 checks to determine if /usr/lib64
+# paths should be added to library search path. So lets put all 64-bit
+# platforms there.
+supports_multilib=
+case "$host_cpu" in
+x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el | loongarch64 | riscv64)
+    if test "$SAL_TYPES_SIZEOFLONG" = "8"; then
+        supports_multilib="yes"
+    fi
+    ;;
+*)
+    ;;
+esac
+
+dnl ===================================================================
+dnl QT5 Integration
+dnl ===================================================================
+
+QT5_CFLAGS=""
+QT5_LIBS=""
+QMAKE5="qmake"
+MOC5="moc"
+QT5_GOBJECT_CFLAGS=""
+QT5_GOBJECT_LIBS=""
+QT5_HAVE_GOBJECT=""
+QT5_PLATFORMS_SRCDIR=""
+if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
+        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
+        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
+then
+    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
+    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
+
+    if test -n "$supports_multilib"; then
+        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
+    fi
+
+    qt5_test_include="QtWidgets/qapplication.h"
+    if test "$_os" = "Emscripten"; then
+        qt5_test_library="libQt5Widgets.a"
+    else
+        qt5_test_library="libQt5Widgets.so"
+    fi
+
+    dnl Check for qmake5
+    if test -n "$QT5DIR"; then
+        AC_PATH_PROG(QMAKE5, [qmake], no, [$QT5DIR/bin])
+    else
+        AC_PATH_PROGS(QMAKE5, [qmake-qt5 qmake], no)
+    fi
+    if test "$QMAKE5" = "no"; then
+        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+    else
+        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
+        if test -z "$qmake5_test_ver"; then
+            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+        fi
+        qmake5_minor_version="`echo $qmake5_test_ver | cut -d. -f2`"
+        qt5_minimal_minor="15"
+        if test "$qmake5_minor_version" -lt "$qt5_minimal_minor"; then
+            AC_MSG_ERROR([The minimal supported Qt5 version is 5.${qt5_minimal_minor}, but your 'qmake -v' reports Qt5 version $qmake5_test_ver.])
+        else
+            AC_MSG_NOTICE([Detected Qt5 version: $qmake5_test_ver])
+        fi
+    fi
+
+    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
+    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
+    qt5_platformsdir="`$QMAKE5 -query QT_INSTALL_PLUGINS`/platforms"
+    QT5_PLATFORMS_SRCDIR="$qt5_platformsdir"
+
+    AC_MSG_CHECKING([for Qt5 headers])
+    qt5_incdir="no"
+    for inc_dir in $qt5_incdirs; do
+        if test -r "$inc_dir/$qt5_test_include"; then
+            qt5_incdir="$inc_dir"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$qt5_incdir])
+    if test "x$qt5_incdir" = "xno"; then
+        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+    fi
+    # check for scenario: qt5-qtbase-devel-*.86_64 installed but host is i686
+    AC_LANG_PUSH([C++])
+    save_CPPFLAGS=$CPPFLAGS
+    CPPFLAGS="${CPPFLAGS} -I${qt5_incdir}"
+    AC_CHECK_HEADER(QtCore/qconfig.h, [],
+        [AC_MSG_ERROR(qconfig.h header not found.)], [])
+    CPPFLAGS=$save_CPPFLAGS
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([for Qt5 libraries])
+    qt5_libdir="no"
+    for lib_dir in $qt5_libdirs; do
+        if test -r "$lib_dir/$qt5_test_library"; then
+            qt5_libdir="$lib_dir"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$qt5_libdir])
+    if test "x$qt5_libdir" = "xno"; then
+        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+    fi
+
+    if test "$_os" = "Emscripten"; then
+        if test ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html ; then
+            QT5_PLATFORMS_SRCDIR="${QT5_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
+        fi
+        if test ! -f "${qt5_platformsdir}"/libqwasm.a -o ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html; then
+            AC_MSG_ERROR([No Qt5 WASM QPA plugin found in ${qt5_platformsdir} or ${QT5_PLATFORMS_SRCDIR}])
+        fi
+
+        EMSDK_LLVM_NM="$(em-config LLVM_ROOT)"/llvm-nm
+        if ! test -x "$EMSDK_LLVM_NM"; then
+            AC_MSG_ERROR([Missing llvm-nm expected to be found at "$EMSDK_LLVM_NM".])
+        fi
+        if test ! -f "${qt5_libdir}"/libQt5Gui.a; then
+            AC_MSG_ERROR([No Qt5 WASM libQt5Gui.a in ${qt5_libdir}])
+        fi
+        QT5_WASM_SJLJ="`${EMSDK_LLVM_NM} "${qt5_libdir}"/libQt5Gui.a 2>/dev/null | $GREP emscripten_longjmp`"
+        if test "$ENABLE_WASM_EXCEPTIONS" = TRUE -a -n "$QT5_WASM_SJLJ"; then
+            AC_MSG_ERROR(['emscripten_longjmp' symbol found in libQt5Gui.a (missing '-s SUPPORT_LONGJMP=wasm'). See static/README.wasm.md.])
+        fi
+        if test "$ENABLE_WASM_EXCEPTIONS" != TRUE -a -z "$QT5_WASM_SJLJ"; then
+            AC_MSG_ERROR(['emscripten_longjmp' symbol not found in libQt5Gui.a. You probably use an incompatible Qt build with '-s SUPPORT_LONGJMP=wasm'.])
+        fi
+    fi
+
+    QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
+    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
+    if test "$_os" = "Emscripten"; then
+        QT5_LIBS="$QT5_LIBS -lqtpcre2 -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -L${qt5_platformsdir} -lqwasm"
+    fi
+
+    if test "$USING_X11" = TRUE; then
+        PKG_CHECK_MODULES(QT5_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for correct app grouping in X11.])])
+        QT5_CFLAGS="$QT5_CFLAGS $QT5_XCB_CFLAGS $QT5_XCB_ICCCM_CFLAGS"
+        QT5_LIBS="$QT5_LIBS $QT5_XCB_LIBS $QT5_XCB_ICCCM_LIBS -lQt5X11Extras"
+        QT5_USING_X11=1
+        AC_DEFINE(QT5_USING_X11)
+    fi
+
+    dnl Check for Meta Object Compiler
+
+    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH])
+    if test "$MOC5" = "no"; then
+        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
+the root of your Qt installation by exporting QT5DIR before running "configure".])
+    fi
+
+    if test "$test_gstreamer_1_0" = yes; then
+        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
+                QT5_HAVE_GOBJECT=1
+                AC_DEFINE(QT5_HAVE_GOBJECT)
+            ],
+            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
+        )
+    fi
+fi
+AC_SUBST(QT5_CFLAGS)
+AC_SUBST(QT5_LIBS)
+AC_SUBST(MOC5)
+AC_SUBST(QT5_GOBJECT_CFLAGS)
+AC_SUBST(QT5_GOBJECT_LIBS)
+AC_SUBST(QT5_HAVE_GOBJECT)
+AC_SUBST(QT5_PLATFORMS_SRCDIR)
+
+dnl ===================================================================
+dnl QT6 Integration
+dnl ===================================================================
+
+QT6_CFLAGS=""
+QT6_LIBS=""
+QMAKE6="qmake"
+MOC6="moc"
+QT6_PLATFORMS_SRCDIR=""
+if test \( "$test_kf6" = "yes" -a "$ENABLE_KF6" = "TRUE" \) -o \
+        \( "$test_qt6" = "yes" -a "$ENABLE_QT6" = "TRUE" \)
+then
+    qt6_incdirs="$QT6INC /usr/include/qt6 /usr/include $x_includes"
+    qt6_libdirs="$QT6LIB /usr/lib/qt6 /usr/lib $x_libraries"
+
+    if test -n "$supports_multilib"; then
+        qt6_libdirs="$qt6_libdirs /usr/lib64/qt6 /usr/lib64/qt /usr/lib64"
+    fi
+
+    qt6_test_include="QtWidgets/qapplication.h"
+    if test "$_os" = "Emscripten"; then
+        qt6_test_library="libQt6Widgets.a"
+    else
+        qt6_test_library="libQt6Widgets.so"
+    fi
+
+    dnl Check for qmake6
+    if test -n "$QT6DIR"; then
+        AC_PATH_PROG(QMAKE6, [qmake], no, [$QT6DIR/bin])
+    else
+        AC_PATH_PROGS(QMAKE6, [qmake-qt6 qmake6 qmake], no)
+    fi
+    if test "$QMAKE6" = "no"; then
+        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
+    else
+        qmake6_test_ver="`$QMAKE6 -v 2>&1 | $SED -n -e 's/^Using Qt version \(6\.[[0-9.]]\+\).*$/\1/p'`"
+        if test -z "$qmake6_test_ver"; then
+            AC_MSG_ERROR([Wrong qmake for Qt6 found. Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
+        fi
+        AC_MSG_NOTICE([Detected Qt6 version: $qmake6_test_ver])
+    fi
+
+    qt6_incdirs="`$QMAKE6 -query QT_INSTALL_HEADERS` $qt6_incdirs"
+    qt6_libdirs="`$QMAKE6 -query QT_INSTALL_LIBS` $qt6_libdirs"
+    qt6_platformsdir="`$QMAKE6 -query QT_INSTALL_PLUGINS`/platforms"
+    QT6_PLATFORMS_SRCDIR="$qt6_platformsdir"
+
+    AC_MSG_CHECKING([for Qt6 headers])
+    qt6_incdir="no"
+    for inc_dir in $qt6_incdirs; do
+        if test -r "$inc_dir/$qt6_test_include"; then
+            qt6_incdir="$inc_dir"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$qt6_incdir])
+    if test "x$qt6_incdir" = "xno"; then
+        AC_MSG_ERROR([Qt6 headers not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
+    fi
+    # check for scenario: qt6-qtbase-devel-*.86_64 installed but host is i686
+    AC_LANG_PUSH([C++])
+    save_CPPFLAGS=$CPPFLAGS
+    CPPFLAGS="${CPPFLAGS} -I${qt6_incdir}"
+    AC_CHECK_HEADER(QtCore/qconfig.h, [],
+        [AC_MSG_ERROR(qconfig.h header not found.)], [])
+    CPPFLAGS=$save_CPPFLAGS
+    AC_LANG_POP([C++])
+
+    AC_MSG_CHECKING([for Qt6 libraries])
+    qt6_libdir="no"
+    for lib_dir in $qt6_libdirs; do
+        if test -r "$lib_dir/$qt6_test_library"; then
+            qt6_libdir="$lib_dir"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$qt6_libdir])
+    if test "x$qt6_libdir" = "xno"; then
+        AC_MSG_ERROR([Qt6 libraries not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
+    fi
+
+    if test "$_os" = "Emscripten"; then
+        if test ! -f "$QT6_PLATFORMS_SRCDIR"/wasm_shell.html ; then
+            QT6_PLATFORMS_SRCDIR="${QT6_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
+        fi
+        if test ! -f "${qt6_platformsdir}"/libqwasm.a -o ! -f "$QT6_PLATFORMS_SRCDIR"/wasm_shell.html; then
+            AC_MSG_ERROR([No Qt6 WASM QPA plugin found in ${qt6_platformsdir} or ${QT6_PLATFORMS_SRCDIR}])
+        fi
+    fi
+
+    QT6_CFLAGS="-I$qt6_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
+    QT6_CFLAGS=$(printf '%s' "$QT6_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    QT6_LIBS="-L$qt6_libdir -lQt6Core -lQt6Gui -lQt6Widgets -lQt6Network"
+    if test "$_os" = "Emscripten"; then
+        QT6_LIBS="$QT6_LIBS -lqtpcre2 -lQt6EventDispatcherSupport -lQt6FontDatabaseSupport -L${qt6_platformsdir} -lqwasm"
+    fi
+
+    if test "$USING_X11" = TRUE; then
+        PKG_CHECK_MODULES(QT6_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for key modifier handling in X11.])])
+        QT6_CFLAGS="$QT6_CFLAGS $QT6_XCB_CFLAGS"
+        QT6_LIBS="$QT6_LIBS $QT6_XCB_LIBS"
+        QT6_USING_X11=1
+        AC_DEFINE(QT6_USING_X11)
+    fi
+
+    dnl Check for Meta Object Compiler
+
+    for lib_dir in $qt6_libdirs; do
+        if test -z "$qt6_libexec_dirs"; then
+            qt6_libexec_dirs="$lib_dir/libexec"
+        else
+            qt6_libexec_dirs="$qt6_libexec_dirs:$lib_dir/libexec"
+        fi
+    done
+    AC_PATH_PROGS( MOC6, [moc-qt6 moc], no, [`dirname $qt6_libdir`/libexec:$QT6DIR/libexec:$qt6_libexec_dirs:`echo $qt6_libdirs | $SED -e 's/ /:/g'`:$PATH])
+    if test "$MOC6" = "no"; then
+        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
+the root of your Qt installation by exporting QT6DIR before running "configure".])
+    else
+        moc6_test_ver="`$MOC6 -v 2>&1 | $SED -n -e 's/^moc \(6.*\)/\1/p'`"
+        if test -z "$moc6_test_ver"; then
+            AC_MSG_ERROR([Wrong moc for Qt6 found.])
+        fi
+        AC_MSG_NOTICE([Detected moc version: $moc_test_ver])
+    fi
+fi
+AC_SUBST(QT6_CFLAGS)
+AC_SUBST(QT6_LIBS)
+AC_SUBST(MOC6)
+AC_SUBST(QT6_PLATFORMS_SRCDIR)
+
+dnl ===================================================================
+dnl KF5 Integration
+dnl ===================================================================
+
+KF5_CFLAGS=""
+KF5_LIBS=""
+KF5_CONFIG="kf5-config"
+if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
+        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
+then
+    if test "$OS" = "HAIKU"; then
+        haiku_arch="`echo $RTL_ARCH | tr X x`"
+        kf5_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
+        kf5_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
+    fi
+
+    kf5_incdirs="$KF5INC /usr/include $kf5_haiku_incdirs $x_includes"
+    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $kf5_haiku_libdirs $x_libraries"
+    if test -n "$supports_multilib"; then
+        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
+    fi
+
+    kf5_test_include="KF5/KIOFileWidgets/KFileWidget"
+    kf5_test_library="libKF5KIOFileWidgets.so"
+    kf5_libdirs="$qt5_libdir $kf5_libdirs"
+
+    dnl kf5 KDE4 support compatibility installed
+    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
+    if test "$KF5_CONFIG" != "no"; then
+        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
+        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
+    fi
+
+    dnl Check for KF5 headers
+    AC_MSG_CHECKING([for KF5 headers])
+    kf5_incdir="no"
+    for kf5_check in $kf5_incdirs; do
+        if test -r "$kf5_check/$kf5_test_include"; then
+            kf5_incdir="$kf5_check/KF5"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$kf5_incdir])
+    if test "x$kf5_incdir" = "xno"; then
+        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
+    fi
+
+    dnl Check for KF5 libraries
+    AC_MSG_CHECKING([for KF5 libraries])
+    kf5_libdir="no"
+    for kf5_check in $kf5_libdirs; do
+        if test -r "$kf5_check/$kf5_test_library"; then
+            kf5_libdir="$kf5_check"
+            break
+        fi
+    done
+
+    AC_MSG_RESULT([$kf5_libdir])
+    if test "x$kf5_libdir" = "xno"; then
+        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
+    fi
+
+    KF5_CFLAGS="-I$kf5_incdir -I$kf5_incdir/KCoreAddons -I$kf5_incdir/KI18n -I$kf5_incdir/KConfigCore -I$kf5_incdir/KWindowSystem -I$kf5_incdir/KIOCore -I$kf5_incdir/KIOWidgets -I$kf5_incdir/KIOFileWidgets -I$qt5_incdir -I$qt5_incdir/QtCore -I$qt5_incdir/QtGui -I$qt5_incdir/QtWidgets -I$qt5_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
+    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -lKF5KIOWidgets -lKF5KIOFileWidgets -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
+    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+
+    if test "$USING_X11" = TRUE; then
+        KF5_LIBS="$KF5_LIBS -lQt5X11Extras"
+    fi
+
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
+    AC_MSG_CHECKING([whether KDE is >= 5.0])
+       AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <kcoreaddons_version.h>
+
+int main(int argc, char **argv) {
+       if (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 0) return 0;
+       else return 1;
+}
+       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST(KF5_CFLAGS)
+AC_SUBST(KF5_LIBS)
+
+dnl ===================================================================
+dnl KF6 Integration
+dnl ===================================================================
+
+KF6_CFLAGS=""
+KF6_LIBS=""
+if test \( "$test_kf6" = "yes" -a "$ENABLE_KF6" = "TRUE" \)
+then
+    if test "$OS" = "HAIKU"; then
+        haiku_arch="`echo $RTL_ARCH | tr X x`"
+        kf6_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
+        kf6_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
+    fi
+
+    kf6_incdirs="$KF6INC /usr/include $kf6_haiku_incdirs $x_includes"
+    kf6_libdirs="$KF6LIB /usr/lib /usr/lib/kf6 /usr/lib/kf6/devel $kf6_haiku_libdirs $x_libraries"
+    if test -n "$supports_multilib"; then
+        kf6_libdirs="$kf6_libdirs /usr/lib64 /usr/lib64/kf6 /usr/lib64/kf6/devel"
+    fi
+
+    kf6_test_include="KF6/KIOFileWidgets/KFileWidget"
+    kf6_test_library="libKF6KIOFileWidgets.so"
+    kf6_libdirs="$qt6_libdir $kf6_libdirs"
+
+    dnl Check for KF6 headers
+    AC_MSG_CHECKING([for KF6 headers])
+    kf6_incdir="no"
+    for kf6_check in $kf6_incdirs; do
+        if test -r "$kf6_check/$kf6_test_include"; then
+            kf6_incdir="$kf6_check/KF6"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$kf6_incdir])
+    if test "x$kf6_incdir" = "xno"; then
+        AC_MSG_ERROR([KF6 headers not found.  Please specify the root of your KF6 installation by exporting KF6DIR before running "configure".])
+    fi
+
+    dnl Check for KF6 libraries
+    AC_MSG_CHECKING([for KF6 libraries])
+    kf6_libdir="no"
+    for kf6_check in $kf6_libdirs; do
+        if test -r "$kf6_check/$kf6_test_library"; then
+            kf6_libdir="$kf6_check"
+            break
+        fi
+    done
+
+    AC_MSG_RESULT([$kf6_libdir])
+    if test "x$kf6_libdir" = "xno"; then
+        AC_MSG_ERROR([KF6 libraries not found.  Please specify the root of your KF6 installation by exporting KF6DIR before running "configure".])
+    fi
+
+    KF6_CFLAGS="-I$kf6_incdir -I$kf6_incdir/KCoreAddons -I$kf6_incdir/KI18n -I$kf6_incdir/KConfigCore -I$kf6_incdir/KWindowSystem -I$kf6_incdir/KIO -I$kf6_incdir/KIOCore -I$kf6_incdir/KIOWidgets -I$kf6_incdir/KIOFileWidgets -I$qt6_incdir -I$qt6_incdir/QtCore -I$qt6_incdir/QtGui -I$qt6_incdir/QtWidgets -I$qt6_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
+    KF6_LIBS="-L$kf6_libdir -lKF6CoreAddons -lKF6I18n -lKF6ConfigCore -lKF6WindowSystem -lKF6KIOCore -lKF6KIOWidgets -lKF6KIOFileWidgets -L$qt6_libdir -lQt6Core -lQt6Gui -lQt6Widgets -lQt6Network"
+    KF6_CFLAGS=$(printf '%s' "$KF6_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $KF6_CFLAGS"
+    dnl KF6 development version as of 2023-06 uses version number 5.240
+    AC_MSG_CHECKING([whether KDE is >= 5.240])
+       AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <kcoreaddons_version.h>
+
+int main(int argc, char **argv) {
+       if (KCOREADDONS_VERSION_MAJOR == 6 || (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 240)) return 0;
+       else return 1;
+}
+       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST(KF6_CFLAGS)
+AC_SUBST(KF6_LIBS)
+
+dnl ===================================================================
+dnl Test whether to include Evolution 2 support
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable evolution 2 support])
+if test "$enable_evolution2" = yes; then
+    AC_MSG_RESULT([yes])
+    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
+    GOBJECT_CFLAGS=$(printf '%s' "$GOBJECT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${GOBJECT_LIBS}"
+    GOBJECT_LIBS="${filteredlibs}"
+    ENABLE_EVOAB2="TRUE"
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_EVOAB2)
+AC_SUBST(GOBJECT_CFLAGS)
+AC_SUBST(GOBJECT_LIBS)
+
+dnl ===================================================================
+dnl Test which themes to include
+dnl ===================================================================
+AC_MSG_CHECKING([which themes to include])
+# if none given use default subset of available themes
+if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
+    with_theme="breeze breeze_dark breeze_dark_svg breeze_svg colibre colibre_svg colibre_dark colibre_dark_svg elementary elementary_svg karasa_jaga karasa_jaga_svg sifr sifr_svg sifr_dark sifr_dark_svg sukapura sukapura_dark sukapura_dark_svg sukapura_svg"
+fi
+
+WITH_THEMES=""
+if test "x$with_theme" != "xno"; then
+    for theme in $with_theme; do
+        case $theme in
+        breeze|breeze_dark|breeze_dark_svg|breeze_svg|colibre|colibre_svg|colibre_dark|colibre_dark_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg|sifr|sifr_svg|sifr_dark|sifr_dark_svg|sukapura|sukapura_dark|sukapura_dark_svg|sukapura_svg) WITH_THEMES="${WITH_THEMES:+$WITH_THEMES }$theme" ;;
+        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
+        esac
+    done
+fi
+AC_MSG_RESULT([$WITH_THEMES])
+AC_SUBST([WITH_THEMES])
+
+###############################################################################
+# Extensions checking
+###############################################################################
+AC_MSG_CHECKING([for extensions integration])
+if test "x$enable_extension_integration" != "xno"; then
+    WITH_EXTENSION_INTEGRATION=TRUE
+    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
+    AC_MSG_RESULT([yes, use integration])
+else
+    WITH_EXTENSION_INTEGRATION=
+    AC_MSG_RESULT([no, do not integrate])
+fi
+AC_SUBST(WITH_EXTENSION_INTEGRATION)
+
+dnl Should any extra extensions be included?
+dnl There are standalone tests for each of these below.
+WITH_EXTRA_EXTENSIONS=
+AC_SUBST([WITH_EXTRA_EXTENSIONS])
+
+libo_CHECK_EXTENSION([Numbertext],[NUMBERTEXT],[numbertext],[numbertext],[b7cae45ad2c23551fd6ccb8ae2c1f59e-numbertext_0.9.5.oxt])
+if test "x$with_java" != "xno"; then
+    libo_CHECK_EXTENSION([NLPSolver],[NLPSOLVER],[nlpsolver],[nlpsolver],[])
+fi
+
+AC_MSG_CHECKING([whether to build opens___.ttf])
+if test "$enable_build_opensymbol" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_PATH_PROG(FONTFORGE, fontforge)
+    if test -z "$FONTFORGE"; then
+        AC_MSG_ERROR([fontforge not installed])
+    fi
+else
+    AC_MSG_RESULT([no])
+    BUILD_TYPE="$BUILD_TYPE OPENSYMBOL"
+fi
+AC_SUBST(FONTFORGE)
+
+dnl ===================================================================
+dnl Test whether to include fonts
+dnl ===================================================================
+AC_MSG_CHECKING([whether to include third-party fonts])
+if test "$with_fonts" != "no"; then
+    AC_MSG_RESULT([yes])
+    WITH_FONTS=TRUE
+    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
+    AC_DEFINE(HAVE_MORE_FONTS)
+else
+    AC_MSG_RESULT([no])
+    WITH_FONTS=
+    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
+fi
+AC_SUBST(WITH_FONTS)
+
+
+dnl ===================================================================
+dnl Test whether to enable online update service
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable online update])
+ENABLE_ONLINE_UPDATE=
+if test "$enable_online_update" = ""; then
+    AC_MSG_RESULT([no])
+else
+    if test "$enable_online_update" = "mar"; then
+        AC_MSG_ERROR([--enable-online-update=mar is deprecated, use --enable-online-update-mar instead])
+    elif test "$enable_online_update" = "yes"; then
+        if test "$enable_curl" != "yes"; then
+            AC_MSG_ERROR([--disable-online-update must be used when --disable-curl is used])
+        fi
+        AC_MSG_RESULT([yes])
+        ENABLE_ONLINE_UPDATE="TRUE"
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+AC_SUBST(ENABLE_ONLINE_UPDATE)
+
+
+dnl ===================================================================
+dnl Test whether to enable mar online update service
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable mar online update])
+ENABLE_ONLINE_UPDATE_MAR=
+if test "$enable_online_update_mar" = yes; then
+    AC_MSG_RESULT([yes])
+    BUILD_TYPE="$BUILD_TYPE ONLINEUPDATE"
+    ENABLE_ONLINE_UPDATE_MAR="TRUE"
+    AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
+
+AC_MSG_CHECKING([for mar online update baseurl])
+ONLINEUPDATE_MAR_BASEURL=$with_online_update_mar_baseurl
+if test -n "$ONLINEUPDATE_MAR_BASEURL"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ONLINEUPDATE_MAR_BASEURL)
+
+AC_MSG_CHECKING([for mar online update certificateder])
+ONLINEUPDATE_MAR_CERTIFICATEDER=$with_online_update_mar_certificateder
+if test -n "$ONLINEUPDATE_MAR_CERTIFICATEDER"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEDER)
+
+AC_MSG_CHECKING([for mar online update certificatename])
+ONLINEUPDATE_MAR_CERTIFICATENAME=$with_online_update_mar_certificatename
+if test -n "$ONLINEUPDATE_MAR_CERTIFICATENAME"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATENAME)
+
+AC_MSG_CHECKING([for mar online update certificatepath])
+ONLINEUPDATE_MAR_CERTIFICATEPATH=$with_online_update_mar_certificatepath
+if test -n "$ONLINEUPDATE_MAR_CERTIFICATEPATH"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEPATH)
+
+AC_MSG_CHECKING([for mar online update serverurl])
+ONLINEUPDATE_MAR_SERVERURL=$with_online_update_mar_serverurl
+if test -n "$ONLINEUPDATE_MAR_SERVERURL"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ONLINEUPDATE_MAR_SERVERURL)
+
+AC_MSG_CHECKING([for mar online update uploadurl])
+ONLINEUPDATE_MAR_UPLOADURL=$with_online_update_mar_uploadurl
+if test -n "$ONLINEUPDATE_MAR_UPLOADURL"; then
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ONLINEUPDATE_MAR_UPLOADURL)
+
+
+PRIVACY_POLICY_URL="$with_privacy_policy_url"
+if test "$ENABLE_ONLINE_UPDATE" = TRUE -o "$ENABLE_BREAKPAD" = "TRUE"; then
+    if test "x$with_privacy_policy_url" = "xundefined"; then
+        AC_MSG_FAILURE([online update or breakpad/crashreporting are enabled, but no --with-privacy-policy-url=... was provided])
+    fi
+fi
+AC_SUBST(PRIVACY_POLICY_URL)
+dnl ===================================================================
+dnl Test whether we need bzip2
+dnl ===================================================================
+SYSTEM_BZIP2=
+if test "$ENABLE_ONLINE_UPDATE_MAR" = "TRUE" -o "$enable_python" = internal; then
+    AC_MSG_CHECKING([whether to use system bzip2])
+    if test "$with_system_bzip2" = yes; then
+        SYSTEM_BZIP2=TRUE
+        AC_MSG_RESULT([yes])
+        PKG_CHECK_MODULES(BZIP2, bzip2)
+        FilterLibs "${BZIP2_LIBS}"
+        BZIP2_LIBS="${filteredlibs}"
+    else
+        AC_MSG_RESULT([no])
+        BUILD_TYPE="$BUILD_TYPE BZIP2"
+    fi
+fi
+AC_SUBST(SYSTEM_BZIP2)
+AC_SUBST(BZIP2_CFLAGS)
+AC_SUBST(BZIP2_LIBS)
+
+dnl ===================================================================
+dnl Test whether to enable extension update
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable extension update])
+ENABLE_EXTENSION_UPDATE=
+if test "x$enable_extension_update" = "xno"; then
+    AC_MSG_RESULT([no])
+else
+    AC_MSG_RESULT([yes])
+    ENABLE_EXTENSION_UPDATE="TRUE"
+    AC_DEFINE(ENABLE_EXTENSION_UPDATE)
+    SCPDEFS="$SCPDEFS -DENABLE_EXTENSION_UPDATE"
+fi
+AC_SUBST(ENABLE_EXTENSION_UPDATE)
+
+
+dnl ===================================================================
+dnl Test whether to create MSI with LIMITUI=1 (silent install)
+dnl ===================================================================
+AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
+if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
+    AC_MSG_RESULT([no])
+    ENABLE_SILENT_MSI=
+else
+    AC_MSG_RESULT([yes])
+    ENABLE_SILENT_MSI=TRUE
+    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
+fi
+AC_SUBST(ENABLE_SILENT_MSI)
+
+dnl ===================================================================
+dnl Check for WiX tools.
+dnl ===================================================================
+if test "$enable_wix" = "" -o "enable_wix" = "no"; then
+    AC_MSG_RESULT([no])
+    ENABLE_WIX=
+else
+    AC_MSG_RESULT([yes])
+    # FIXME: this should do proper detection, but the path is currently
+    # hardcoded in msicreator/createmsi.py
+    if ! test -x "/cygdrive/c/Program Files (x86)/WiX Toolset v3.11/bin/candle"; then
+      AC_MSG_ERROR([WiX requested but WiX toolset v3.11 not found at the expected location])
+    fi
+    ENABLE_WIX=TRUE
+fi
+AC_SUBST(ENABLE_WIX)
+
+AC_MSG_CHECKING([whether and how to use Xinerama])
+if test "$USING_X11" = TRUE; then
+    if test "$x_libraries" = "default_x_libraries"; then
+        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
+        if test "x$XINERAMALIB" = x; then
+           XINERAMALIB="/usr/lib"
+        fi
+    else
+        XINERAMALIB="$x_libraries"
+    fi
+    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
+        # we have both versions, let the user decide but use the dynamic one
+        # per default
+        USE_XINERAMA=TRUE
+        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
+            XINERAMA_LINK=dynamic
+        else
+            XINERAMA_LINK=static
+        fi
+    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
+        # we have only the dynamic version
+        USE_XINERAMA=TRUE
+        XINERAMA_LINK=dynamic
+    elif test -e "$XINERAMALIB/libXinerama.a"; then
+        # static version
+        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
+            USE_XINERAMA=TRUE
+            XINERAMA_LINK=static
+        else
+            USE_XINERAMA=
+            XINERAMA_LINK=none
+        fi
+    else
+        # no Xinerama
+        USE_XINERAMA=
+        XINERAMA_LINK=none
+    fi
+    if test "$USE_XINERAMA" = "TRUE"; then
+        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
+        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
+            [AC_MSG_ERROR(Xinerama header not found.)], [])
+        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
+        if test "x$XEXTLIB" = x; then
+           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
+        fi
+        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
+        if test "$_os" = "FreeBSD"; then
+            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
+        fi
+        if test "$_os" = "Linux"; then
+            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
+        fi
+        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
+            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
+    else
+        AC_MSG_ERROR([libXinerama not found or wrong architecture.])
+    fi
+else
+    USE_XINERAMA=
+    XINERAMA_LINK=none
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(XINERAMA_LINK)
+
+AC_MSG_CHECKING([whether to use non-standard RGBA32 cairo pixel order])
+if test -z "$enable_cairo_rgba" -a "$_os" = "Android"; then
+    enable_cairo_rgba=yes
+fi
+if test "$enable_cairo_rgba" = yes; then
+    AC_DEFINE(ENABLE_CAIRO_RGBA)
+    ENABLE_CAIRO_RGBA=TRUE
+    AC_MSG_RESULT([yes])
+else
+    ENABLE_CAIRO_RGBA=
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_CAIRO_RGBA)
+
+dnl ===================================================================
+dnl Test whether to build cairo or rely on the system version
+dnl ===================================================================
+
+if test "$test_cairo" = "yes"; then
+    AC_MSG_CHECKING([whether to use the system cairo])
+
+    : ${with_system_cairo:=$with_system_libs}
+    if test "$with_system_cairo" = "yes" -a "$enable_cairo_rgba" != "yes"; then
+        SYSTEM_CAIRO=TRUE
+        AC_MSG_RESULT([yes])
+
+        PKG_CHECK_MODULES( CAIRO, cairo >= 1.12.0 )
+        CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${CAIRO_LIBS}"
+        CAIRO_LIBS="${filteredlibs}"
+
+        if test "$test_xrender" = "yes"; then
+            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
+            AC_LANG_PUSH([C])
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
+#ifdef PictStandardA8
+#else
+      return fail;
+#endif
+]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])
+
+            AC_LANG_POP([C])
+        fi
+    else
+        AC_MSG_RESULT([no])
+        BUILD_TYPE="$BUILD_TYPE CAIRO"
+    fi
+
+    if test "$enable_cairo_canvas" != no; then
+        AC_DEFINE(ENABLE_CAIRO_CANVAS)
+        ENABLE_CAIRO_CANVAS=TRUE
+    fi
+fi
+
+AC_SUBST(CAIRO_CFLAGS)
+AC_SUBST(CAIRO_LIBS)
+AC_SUBST(ENABLE_CAIRO_CANVAS)
+AC_SUBST(SYSTEM_CAIRO)
+
+dnl ===================================================================
+dnl Test whether to use avahi
+dnl ===================================================================
+if test "$_os" = "WINNT"; then
+    # Windows uses bundled mDNSResponder
+    BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
+elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
+    PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
+                      [ENABLE_AVAHI="TRUE"])
+    AC_DEFINE(HAVE_FEATURE_AVAHI)
+    AVAHI_CFLAGS=$(printf '%s' "$AVAHI_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${AVAHI_LIBS}"
+    AVAHI_LIBS="${filteredlibs}"
+fi
+
+AC_SUBST(ENABLE_AVAHI)
+AC_SUBST(AVAHI_CFLAGS)
+AC_SUBST(AVAHI_LIBS)
+
+dnl ===================================================================
+dnl Test whether to use liblangtag
+dnl ===================================================================
+SYSTEM_LIBLANGTAG=
+AC_MSG_CHECKING([whether to use system liblangtag])
+if test "$with_system_liblangtag" = yes; then
+    SYSTEM_LIBLANGTAG=TRUE
+    AC_MSG_RESULT([yes])
+    PKG_CHECK_MODULES( LIBLANGTAG, liblangtag >= 0.4.0)
+    dnl cf. <https://bitbucket.org/tagoh/liblangtag/commits/9324836a0d1c> "Fix a build issue with inline keyword"
+    PKG_CHECK_EXISTS([liblangtag >= 0.5.5], [], [AC_DEFINE([LIBLANGTAG_INLINE_FIX])])
+    LIBLANGTAG_CFLAGS=$(printf '%s' "$LIBLANGTAG_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    FilterLibs "${LIBLANGTAG_LIBS}"
+    LIBLANGTAG_LIBS="${filteredlibs}"
+else
+    SYSTEM_LIBLANGTAG=
+    AC_MSG_RESULT([no])
+    BUILD_TYPE="$BUILD_TYPE LIBLANGTAG"
+    LIBLANGTAG_CFLAGS="-I${WORKDIR}/UnpackedTarball/liblangtag"
+    if test "$COM" = "MSC"; then
+        LIBLANGTAG_LIBS="${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs/liblangtag.lib"
+    else
+        LIBLANGTAG_LIBS="-L${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs -llangtag"
+    fi
+fi
+AC_SUBST(SYSTEM_LIBLANGTAG)
+AC_SUBST(LIBLANGTAG_CFLAGS)
+AC_SUBST(LIBLANGTAG_LIBS)
+
+dnl ===================================================================
+dnl Test whether to build libpng or rely on the system version
+dnl ===================================================================
+
+LIBPNG_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/libpng"
+LIBPNG_LIBS_internal="-L${WORKDIR}/LinkTarget/StaticLibrary -llibpng"
+libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng])
+
+dnl ===================================================================
+dnl Test whether to build libtiff or rely on the system version
+dnl ===================================================================
+
+libo_CHECK_SYSTEM_MODULE([libtiff],[LIBTIFF],[libtiff-4])
+
+dnl ===================================================================
+dnl Test whether to build libwebp or rely on the system version
+dnl ===================================================================
+
+libo_CHECK_SYSTEM_MODULE([libwebp],[LIBWEBP],[libwebp])
+
+dnl ===================================================================
+dnl Check for runtime JVM search path
+dnl ===================================================================
+if test "$ENABLE_JAVA" != ""; then
+    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
+    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
+        AC_MSG_RESULT([yes])
+        if ! test -d "$with_jvm_path"; then
+            AC_MSG_ERROR(["$with_jvm_path" not a directory])
+        fi
+        if ! test -d "$with_jvm_path"jvm; then
+            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
+        fi
+        JVM_ONE_PATH_CHECK="$with_jvm_path"
+        AC_SUBST(JVM_ONE_PATH_CHECK)
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+
+dnl ===================================================================
+dnl Test for the presence of Ant and that it works
+dnl ===================================================================
+
+# java takes the encoding from LC_ALL, and since autoconf forces it to C it
+# breaks filename decoding, so for the ant section, set it to LANG
+LC_ALL=$LANG
+if test "$ENABLE_JAVA" != "" -a "$NEED_ANT" = "TRUE" -a "$cross_compiling" != "yes"; then
+    ANT_HOME=; export ANT_HOME
+    WITH_ANT_HOME=; export WITH_ANT_HOME
+    if test -z "$with_ant_home" -a -n "$LODE_HOME" ; then
+        if test -x "$LODE_HOME/opt/ant/bin/ant" ; then
+            if test "$_os" = "WINNT"; then
+                with_ant_home="`cygpath -m $LODE_HOME/opt/ant`"
+            else
+                with_ant_home="$LODE_HOME/opt/ant"
+            fi
+        elif test -x  "$LODE_HOME/opt/bin/ant" ; then
+            with_ant_home="$LODE_HOME/opt/ant"
+        fi
+    fi
+    if test -z "$with_ant_home"; then
+        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd])
+    else
+        if test "$_os" = "WINNT"; then
+            # AC_PATH_PROGS needs unix path
+            with_ant_home=`cygpath -u "$with_ant_home"`
+        fi
+        AbsolutePath "$with_ant_home"
+        with_ant_home=$absolute_path
+        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
+        WITH_ANT_HOME=$with_ant_home
+        ANT_HOME=$with_ant_home
+    fi
+
+    if test -z "$ANT"; then
+        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
+    else
+        # resolve relative or absolute symlink
+        while test -h "$ANT"; do
+            a_cwd=`pwd`
+            a_basename=`basename "$ANT"`
+            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
+            cd "`dirname "$ANT"`"
+            cd "`dirname "$a_script"`"
+            ANT="`pwd`"/"`basename "$a_script"`"
+            cd "$a_cwd"
+        done
+
+        AC_MSG_CHECKING([if $ANT works])
+        mkdir -p conftest.dir
+        a_cwd=$(pwd)
+        cd conftest.dir
+        cat > conftest.java << EOF
+        public class conftest {
+            int testmethod(int a, int b) {
+                    return a + b;
+            }
+        }
+EOF
+
+        cat > conftest.xml << EOF
+        <project name="conftest" default="conftest">
+        <target name="conftest">
+            <javac srcdir="." includes="conftest.java">
+            </javac>
+        </target>
+        </project>
+EOF
+
+        AC_TRY_COMMAND("$ANT" -buildfile conftest.xml 1>&2)
+        if test $? = 0 -a -f ./conftest.class; then
+            AC_MSG_RESULT([Ant works])
+            if test -z "$WITH_ANT_HOME"; then
+                ANT_HOME=`"$ANT" -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
+                if test -z "$ANT_HOME"; then
+                    ANT_HOME=`echo "$ANT" | $SED -n "s/\/bin\/ant.*\$//p"`
+                fi
+            else
+                ANT_HOME="$WITH_ANT_HOME"
+            fi
+        else
+            echo "configure: Ant test failed" >&5
+            cat conftest.java >&5
+            cat conftest.xml >&5
+            AC_MSG_ERROR([Ant does not work - Some Java projects will not build!])
+        fi
+        cd "$a_cwd"
+        rm -fr conftest.dir
+    fi
+    if test -z "$ANT_HOME"; then
+        ANT_HOME="NO_ANT_HOME"
+    else
+        PathFormat "$ANT_HOME"
+        ANT_HOME="$formatted_path"
+        PathFormat "$ANT"
+        ANT="$formatted_path"
+    fi
+
+    dnl Checking for ant.jar
+    if test "$ANT_HOME" != "NO_ANT_HOME"; then
+        AC_MSG_CHECKING([Ant lib directory])
+        if test -f $ANT_HOME/lib/ant.jar; then
+            ANT_LIB="$ANT_HOME/lib"
+        else
+            if test -f $ANT_HOME/ant.jar; then
+                ANT_LIB="$ANT_HOME"
+            else
+                if test -f /usr/share/java/ant.jar; then
+                    ANT_LIB=/usr/share/java
+                else
+                    if test -f /usr/share/ant-core/lib/ant.jar; then
+                        ANT_LIB=/usr/share/ant-core/lib
+                    else
+                        if test -f $ANT_HOME/lib/ant/ant.jar; then
+                            ANT_LIB="$ANT_HOME/lib/ant"
+                        else
+                            if test -f /usr/share/lib/ant/ant.jar; then
+                                ANT_LIB=/usr/share/lib/ant
+                            else
+                                AC_MSG_ERROR([Ant libraries not found!])
+                            fi
+                        fi
+                    fi
+                fi
+            fi
+        fi
+        PathFormat "$ANT_LIB"
+        ANT_LIB="$formatted_path"
+        AC_MSG_RESULT([Ant lib directory found.])
+    fi
+
+    ant_minver=1.6.0
+    ant_minminor1=`echo $ant_minver | cut -d"." -f2`
+
+    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
+    ant_version=`"$ANT" -version | $AWK '$3 == "version" { print $4; }'`
+    ant_version_major=`echo $ant_version | cut -d. -f1`
+    ant_version_minor=`echo $ant_version | cut -d. -f2`
+    echo "configure: ant_version $ant_version " >&5
+    echo "configure: ant_version_major $ant_version_major " >&5
+    echo "configure: ant_version_minor $ant_version_minor " >&5
+    if test "$ant_version_major" -ge "2"; then
+        AC_MSG_RESULT([yes, $ant_version])
+    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
+        AC_MSG_RESULT([yes, $ant_version])
+    else
+        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
+    fi
+
+    rm -f conftest* core core.* *.core
+fi
+AC_SUBST(ANT)
+AC_SUBST(ANT_HOME)
+AC_SUBST(ANT_LIB)
+
+OOO_JUNIT_JAR=
+HAMCREST_JAR=
+if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no" -a "$cross_compiling" != "yes"; then
+    AC_MSG_CHECKING([for JUnit 4])
+    if test "$with_junit" = "yes"; then
+        if test -n "$LODE_HOME" -a -e "$LODE_HOME/opt/share/java/junit.jar" ; then
+            OOO_JUNIT_JAR="$LODE_HOME/opt/share/java/junit.jar"
+        elif test -e /usr/share/java/junit4.jar; then
+            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
+        else
+           if test -e /usr/share/lib/java/junit.jar; then
+              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
+           else
+              OOO_JUNIT_JAR=/usr/share/java/junit.jar
+           fi
+        fi
+    else
+        OOO_JUNIT_JAR=$with_junit
+    fi
+    if test "$_os" = "WINNT"; then
+        OOO_JUNIT_JAR=`cygpath -m "$OOO_JUNIT_JAR"`
+    fi
+    printf 'import org.junit.Before;' > conftest.java
+    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
+        AC_MSG_RESULT([$OOO_JUNIT_JAR])
+    else
+        AC_MSG_ERROR(
+[cannot find JUnit 4 jar; please install one in the default location (/usr/share/java),
+ specify its pathname via --with-junit=..., or disable it via --without-junit])
+    fi
+    rm -f conftest.class conftest.java
+    if test $OOO_JUNIT_JAR != ""; then
+        BUILD_TYPE="$BUILD_TYPE QADEVOOO"
+    fi
+
+    AC_MSG_CHECKING([for included Hamcrest])
+    printf 'import org.hamcrest.BaseDescription;' > conftest.java
+    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
+        AC_MSG_RESULT([Included in $OOO_JUNIT_JAR])
+    else
+        AC_MSG_RESULT([Not included])
+        AC_MSG_CHECKING([for standalone hamcrest jar.])
+        if test "$with_hamcrest" = "yes"; then
+            if test -e /usr/share/lib/java/hamcrest.jar; then
+                HAMCREST_JAR=/usr/share/lib/java/hamcrest.jar
+            elif test -e /usr/share/java/hamcrest/core.jar; then
+                HAMCREST_JAR=/usr/share/java/hamcrest/core.jar
+            elif test -e /usr/share/java/hamcrest/hamcrest.jar; then
+                HAMCREST_JAR=/usr/share/java/hamcrest/hamcrest.jar
+            else
+                HAMCREST_JAR=/usr/share/java/hamcrest.jar
+            fi
+        else
+            HAMCREST_JAR=$with_hamcrest
+        fi
+        if test "$_os" = "WINNT"; then
+            HAMCREST_JAR=`cygpath -m "$HAMCREST_JAR"`
+        fi
+        if "$JAVACOMPILER" -classpath "$HAMCREST_JAR" conftest.java >&5 2>&5; then
+            AC_MSG_RESULT([$HAMCREST_JAR])
+        else
+            AC_MSG_ERROR([junit does not contain hamcrest; please use a junit jar that includes hamcrest, install a hamcrest jar in the default location (/usr/share/java),
+                          specify its path with --with-hamcrest=..., or disable junit with --without-junit])
+        fi
+    fi
+    rm -f conftest.class conftest.java
+fi
+AC_SUBST(OOO_JUNIT_JAR)
+AC_SUBST(HAMCREST_JAR)
+# set back LC_ALL to C after the java related tests...
+LC_ALL=C
+
+AC_SUBST(SCPDEFS)
+
+#
+# check for wget and curl
+#
+WGET=
+CURL=
+
+if test "$enable_fetch_external" != "no"; then
+
+CURL=`which curl 2>/dev/null`
+
+for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
+    # wget new enough?
+    $i --help 2> /dev/null | $GREP no-use-server-timestamps 2>&1 > /dev/null
+    if test $? -eq 0; then
+        WGET=$i
+        break
+    fi
+done
+
+if test -z "$WGET" -a -z "$CURL"; then
+    AC_MSG_ERROR([neither wget nor curl found!])
+fi
+
+fi
+
+AC_SUBST(WGET)
+AC_SUBST(CURL)
+
+#
+# check for sha256sum
+#
+SHA256SUM=
+
+for i in shasum /usr/local/bin/shasum /usr/sfw/bin/shasum /opt/sfw/bin/shasum /opt/local/bin/shasum; do
+    eval "$i -a 256 --version" > /dev/null 2>&1
+    ret=$?
+    if test $ret -eq 0; then
+        SHA256SUM="$i -a 256"
+        break
+    fi
+done
+
+if test -z "$SHA256SUM"; then
+    for i in sha256sum /usr/local/bin/sha256sum /usr/sfw/bin/sha256sum /opt/sfw/bin/sha256sum /opt/local/bin/sha256sum; do
+        eval "$i --version" > /dev/null 2>&1
+        ret=$?
+        if test $ret -eq 0; then
+            SHA256SUM=$i
+            break
+        fi
+    done
+fi
+
+if test -z "$SHA256SUM"; then
+    AC_MSG_ERROR([no sha256sum found!])
+fi
+
+AC_SUBST(SHA256SUM)
+
+dnl ===================================================================
+dnl Dealing with l10n options
+dnl ===================================================================
+AC_MSG_CHECKING([which languages to be built])
+# get list of all languages
+# generate shell variable from completelangiso= from solenv/inc/langlist.mk
+# the sed command does the following:
+#   + if a line ends with a backslash, append the next line to it
+#   + adds " on the beginning of the value (after =)
+#   + adds " at the end of the value
+#   + removes en-US; we want to put it on the beginning
+#   + prints just the section starting with 'completelangiso=' and ending with the " at the end of line
+[eval $(sed -e :a -e '/\\$/N; s/\\\n//; ta' -n -e 's/=/="/;s/\([^\\]\)$/\1"/;s/en-US//;/^completelangiso/p' $SRC_ROOT/solenv/inc/langlist.mk)]
+ALL_LANGS="en-US $completelangiso"
+# check the configured localizations
+WITH_LANG="$with_lang"
+
+# Check for --without-lang which turns up as $with_lang being "no". Luckily there is no language with code "no".
+# (Norwegian is "nb" and "nn".)
+if test "$WITH_LANG" = "no"; then
+    WITH_LANG=
+fi
+
+if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
+    AC_MSG_RESULT([en-US])
+else
+    AC_MSG_RESULT([$WITH_LANG])
+    GIT_NEEDED_SUBMODULES="translations $GIT_NEEDED_SUBMODULES"
+    if test -z "$MSGFMT"; then
+        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msgfmt" ; then
+            MSGFMT="$LODE_HOME/opt/bin/msgfmt"
+        elif test -x "/opt/lo/bin/msgfmt"; then
+            MSGFMT="/opt/lo/bin/msgfmt"
+        else
+            AC_CHECK_PROGS(MSGFMT, [msgfmt])
+            if test -z "$MSGFMT"; then
+                AC_MSG_ERROR([msgfmt not found. Install GNU gettext, or re-run without languages.])
+            fi
+        fi
+    fi
+    if test -z "$MSGUNIQ"; then
+        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msguniq" ; then
+            MSGUNIQ="$LODE_HOME/opt/bin/msguniq"
+        elif test -x "/opt/lo/bin/msguniq"; then
+            MSGUNIQ="/opt/lo/bin/msguniq"
+        else
+            AC_CHECK_PROGS(MSGUNIQ, [msguniq])
+            if test -z "$MSGUNIQ"; then
+                AC_MSG_ERROR([msguniq not found. Install GNU gettext, or re-run without languages.])
+            fi
+        fi
+    fi
+fi
+AC_SUBST(MSGFMT)
+AC_SUBST(MSGUNIQ)
+# check that the list is valid
+for lang in $WITH_LANG; do
+    test "$lang" = "ALL" && continue
+    # need to check for the exact string, so add space before and after the list of all languages
+    for vl in $ALL_LANGS; do
+        if test "$vl" = "$lang"; then
+           break
+        fi
+    done
+    if test "$vl" != "$lang"; then
+        # if you're reading this - you prolly quoted your languages remove the quotes ...
+        AC_MSG_ERROR([invalid language: '$lang' (vs '$v1'); supported languages are: $ALL_LANGS])
+    fi
+done
+if test -n "$WITH_LANG" -a "$WITH_LANG" != "ALL"; then
+    echo $WITH_LANG | grep -q en-US
+    test $? -ne 1 || WITH_LANG=`echo $WITH_LANG en-US`
+fi
+# list with substituted ALL
+WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
+test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
+test "$WITH_LANG" = "en-US" && WITH_LANG=
+if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
+    test "$WITH_LANG_LIST" = "en-US" || WITH_LANG_LIST=`echo $WITH_LANG_LIST qtz`
+    ALL_LANGS=`echo $ALL_LANGS qtz`
+fi
+AC_SUBST(ALL_LANGS)
+AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
+AC_SUBST(WITH_LANG)
+AC_SUBST(WITH_LANG_LIST)
+AC_SUBST(GIT_NEEDED_SUBMODULES)
+
+WITH_POOR_HELP_LOCALIZATIONS=
+if test -d "$SRC_ROOT/translations/source"; then
+    for l in `ls -1 $SRC_ROOT/translations/source`; do
+        if test ! -d "$SRC_ROOT/translations/source/$l/helpcontent2"; then
+            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
+        fi
+    done
+fi
+AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
+
+if test -n "$with_locales" -a "$with_locales" != ALL; then
+    WITH_LOCALES="$with_locales"
+
+    just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
+    # Only languages and scripts for which we actually have ifdefs need to be handled. Also see
+    # config_host/config_locales.h.in
+    for locale in $WITH_LOCALES; do
+        lang=${locale%_*}
+
+        AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
+
+        case $lang in
+        hi|mr*ne)
+            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
+            ;;
+        bg|ru)
+            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
+            ;;
+        esac
+    done
+else
+    AC_DEFINE(WITH_LOCALE_ALL)
+fi
+AC_SUBST(WITH_LOCALES)
+
+dnl git submodule update --reference
+dnl ===================================================================
+if test -n "${GIT_REFERENCE_SRC}"; then
+    for repo in ${GIT_NEEDED_SUBMODULES}; do
+        if ! test -d "${GIT_REFERENCE_SRC}"/${repo}; then
+            AC_MSG_ERROR([referenced git: required repository does not exist: ${GIT_REFERENCE_SRC}/${repo}])
+        fi
+    done
+fi
+AC_SUBST(GIT_REFERENCE_SRC)
+
+dnl git submodules linked dirs
+dnl ===================================================================
+if test -n "${GIT_LINK_SRC}"; then
+    for repo in ${GIT_NEEDED_SUBMODULES}; do
+        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
+            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
+        fi
+    done
+fi
+AC_SUBST(GIT_LINK_SRC)
+
+dnl branding
+dnl ===================================================================
+AC_MSG_CHECKING([for alternative branding images directory])
+# initialize mapped arrays
+BRAND_INTRO_IMAGES="intro.png intro-highres.png"
+brand_files="$BRAND_INTRO_IMAGES logo.svg logo_inverted.svg logo-sc.svg logo-sc_inverted.svg about.svg"
+
+if test -z "$with_branding" -o "$with_branding" = "no"; then
+    AC_MSG_RESULT([none])
+    DEFAULT_BRAND_IMAGES="$brand_files"
+else
+    if ! test -d $with_branding ; then
+        AC_MSG_ERROR([No directory $with_branding, falling back to default branding])
+    else
+        AC_MSG_RESULT([$with_branding])
+        CUSTOM_BRAND_DIR="$with_branding"
+        for lfile in $brand_files
+        do
+            if ! test -f $with_branding/$lfile ; then
+                AC_MSG_WARN([Branded file $lfile does not exist, using the default one])
+                DEFAULT_BRAND_IMAGES="$DEFAULT_BRAND_IMAGES $lfile"
+            else
+                CUSTOM_BRAND_IMAGES="$CUSTOM_BRAND_IMAGES $lfile"
+            fi
+        done
+        check_for_progress="yes"
+    fi
+fi
+AC_SUBST([BRAND_INTRO_IMAGES])
+AC_SUBST([CUSTOM_BRAND_DIR])
+AC_SUBST([CUSTOM_BRAND_IMAGES])
+AC_SUBST([DEFAULT_BRAND_IMAGES])
+
+
+AC_MSG_CHECKING([for 'intro' progress settings])
+PROGRESSBARCOLOR=
+PROGRESSSIZE=
+PROGRESSPOSITION=
+PROGRESSFRAMECOLOR=
+PROGRESSTEXTCOLOR=
+PROGRESSTEXTBASELINE=
+
+if test "$check_for_progress" = "yes" -a -f "$with_branding/progress.conf" ; then
+    source "$with_branding/progress.conf"
+    AC_MSG_RESULT([settings found in $with_branding/progress.conf])
+else
+    AC_MSG_RESULT([none])
+fi
+
+AC_SUBST(PROGRESSBARCOLOR)
+AC_SUBST(PROGRESSSIZE)
+AC_SUBST(PROGRESSPOSITION)
+AC_SUBST(PROGRESSFRAMECOLOR)
+AC_SUBST(PROGRESSTEXTCOLOR)
+AC_SUBST(PROGRESSTEXTBASELINE)
+
+
+dnl ===================================================================
+dnl Custom build version
+dnl ===================================================================
+AC_MSG_CHECKING([for extra build ID])
+if test -n "$with_extra_buildid" -a "$with_extra_buildid" != "yes" ; then
+    EXTRA_BUILDID="$with_extra_buildid"
+fi
+# in tinderboxes, it is easier to set EXTRA_BUILDID via the environment variable instead of configure switch
+if test -n "$EXTRA_BUILDID" ; then
+    AC_MSG_RESULT([$EXTRA_BUILDID])
+else
+    AC_MSG_RESULT([not set])
+fi
+AC_DEFINE_UNQUOTED([EXTRA_BUILDID], ["$EXTRA_BUILDID"])
+
+OOO_VENDOR=
+AC_MSG_CHECKING([for vendor])
+if test -z "$with_vendor" -o "$with_vendor" = "no"; then
+    OOO_VENDOR="$USERNAME"
+
+    if test -z "$OOO_VENDOR"; then
+        OOO_VENDOR="$USER"
+    fi
+
+    if test -z "$OOO_VENDOR"; then
+        OOO_VENDOR="`id -u -n`"
+    fi
+
+    AC_MSG_RESULT([not set, using $OOO_VENDOR])
+else
+    OOO_VENDOR="$with_vendor"
+    AC_MSG_RESULT([$OOO_VENDOR])
+fi
+AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
+AC_SUBST(OOO_VENDOR)
+
+if test "$_os" = "Android" ; then
+    ANDROID_PACKAGE_NAME=
+    AC_MSG_CHECKING([for Android package name])
+    if test -z "$with_android_package_name" -o "$with_android_package_name" = "no"; then
+        if test -n "$ENABLE_DEBUG"; then
+            # Default to the package name that makes ndk-gdb happy.
+            ANDROID_PACKAGE_NAME="org.libreoffice"
+        else
+            ANDROID_PACKAGE_NAME="org.example.libreoffice"
+        fi
+
+        AC_MSG_RESULT([not set, using $ANDROID_PACKAGE_NAME])
+    else
+        ANDROID_PACKAGE_NAME="$with_android_package_name"
+        AC_MSG_RESULT([$ANDROID_PACKAGE_NAME])
+    fi
+    AC_SUBST(ANDROID_PACKAGE_NAME)
+fi
+
+AC_MSG_CHECKING([whether to install the compat oo* wrappers])
+if test "$with_compat_oowrappers" = "yes"; then
+    WITH_COMPAT_OOWRAPPERS=TRUE
+    AC_MSG_RESULT(yes)
+else
+    WITH_COMPAT_OOWRAPPERS=
+    AC_MSG_RESULT(no)
+fi
+AC_SUBST(WITH_COMPAT_OOWRAPPERS)
+
+INSTALLDIRNAME=`echo AC_PACKAGE_NAME | $AWK '{print tolower($0)}'`
+AC_MSG_CHECKING([for install dirname])
+if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
+    INSTALLDIRNAME="$with_install_dirname"
+fi
+AC_MSG_RESULT([$INSTALLDIRNAME])
+AC_SUBST(INSTALLDIRNAME)
+
+AC_MSG_CHECKING([for prefix])
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+test "x$exec_prefix" = xNONE && exec_prefix=$prefix
+PREFIXDIR="$prefix"
+AC_MSG_RESULT([$PREFIXDIR])
+AC_SUBST(PREFIXDIR)
+
+LIBDIR=[$(eval echo $(eval echo $libdir))]
+AC_SUBST(LIBDIR)
+
+DATADIR=[$(eval echo $(eval echo $datadir))]
+AC_SUBST(DATADIR)
+
+MANDIR=[$(eval echo $(eval echo $mandir))]
+AC_SUBST(MANDIR)
+
+DOCDIR=[$(eval echo $(eval echo $docdir))]
+AC_SUBST(DOCDIR)
+
+BINDIR=[$(eval echo $(eval echo $bindir))]
+AC_SUBST(BINDIR)
+
+INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
+AC_SUBST(INSTALLDIR)
+
+TESTINSTALLDIR="${BUILDDIR}/test-install"
+AC_SUBST(TESTINSTALLDIR)
+
+
+# ===================================================================
+# OAuth2 id and secrets
+# ===================================================================
+
+AC_MSG_CHECKING([for Google Drive client id and secret])
+if test "$with_gdrive_client_id" = "no" -o -z "$with_gdrive_client_id"; then
+    AC_MSG_RESULT([not set])
+    GDRIVE_CLIENT_ID="\"\""
+    GDRIVE_CLIENT_SECRET="\"\""
+else
+    AC_MSG_RESULT([set])
+    GDRIVE_CLIENT_ID="\"$with_gdrive_client_id\""
+    GDRIVE_CLIENT_SECRET="\"$with_gdrive_client_secret\""
+fi
+AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_ID, $GDRIVE_CLIENT_ID)
+AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_SECRET, $GDRIVE_CLIENT_SECRET)
+
+AC_MSG_CHECKING([for Alfresco Cloud client id and secret])
+if test "$with_alfresco_cloud_client_id" = "no" -o -z "$with_alfresco_cloud_client_id"; then
+    AC_MSG_RESULT([not set])
+    ALFRESCO_CLOUD_CLIENT_ID="\"\""
+    ALFRESCO_CLOUD_CLIENT_SECRET="\"\""
+else
+    AC_MSG_RESULT([set])
+    ALFRESCO_CLOUD_CLIENT_ID="\"$with_alfresco_cloud_client_id\""
+    ALFRESCO_CLOUD_CLIENT_SECRET="\"$with_alfresco_cloud_client_secret\""
+fi
+AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_ID, $ALFRESCO_CLOUD_CLIENT_ID)
+AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_SECRET, $ALFRESCO_CLOUD_CLIENT_SECRET)
+
+AC_MSG_CHECKING([for OneDrive client id and secret])
+if test "$with_onedrive_client_id" = "no" -o -z "$with_onedrive_client_id"; then
+    AC_MSG_RESULT([not set])
+    ONEDRIVE_CLIENT_ID="\"\""
+    ONEDRIVE_CLIENT_SECRET="\"\""
+else
+    AC_MSG_RESULT([set])
+    ONEDRIVE_CLIENT_ID="\"$with_onedrive_client_id\""
+    ONEDRIVE_CLIENT_SECRET="\"$with_onedrive_client_secret\""
+fi
+AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_ID, $ONEDRIVE_CLIENT_ID)
+AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_SECRET, $ONEDRIVE_CLIENT_SECRET)
+
+
+dnl ===================================================================
+dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
+dnl --enable-dependency-tracking configure option
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable dependency tracking])
+if test "$enable_dependency_tracking" = "no"; then
+    nodep=TRUE
+    AC_MSG_RESULT([no])
+else
+    AC_MSG_RESULT([yes])
+fi
+AC_SUBST(nodep)
+
+dnl ===================================================================
+dnl Number of CPUs to use during the build
+dnl ===================================================================
+AC_MSG_CHECKING([for number of processors to use])
+# plain --with-parallelism is just the default
+if test -n "$with_parallelism" -a "$with_parallelism" != "yes"; then
+    if test "$with_parallelism" = "no"; then
+        PARALLELISM=0
+    else
+        PARALLELISM=$with_parallelism
+    fi
+else
+    if test "$enable_icecream" = "yes"; then
+        PARALLELISM="40"
+    else
+        case `uname -s` in
+
+        Darwin|FreeBSD|NetBSD|OpenBSD)
+            PARALLELISM=`sysctl -n hw.ncpu`
+            ;;
+
+        Linux)
+            PARALLELISM=`getconf _NPROCESSORS_ONLN`
+        ;;
+        # what else than above does profit here *and* has /proc?
+        *)
+            PARALLELISM=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
+            ;;
+        esac
+
+        # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
+        # unexpected format, 'wc -l' will have returned 0 (and we won't use -j at all).
+    fi
+fi
+
+if test $PARALLELISM -eq 0; then
+    AC_MSG_RESULT([explicit make -j option needed])
+else
+    AC_MSG_RESULT([$PARALLELISM])
+fi
+AC_SUBST(PARALLELISM)
+
+#
+# Set up ILIB for MSVC build
+#
+ILIB1=
+if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
+    ILIB="."
+    if test -n "$JAVA_HOME"; then
+        ILIB="$ILIB;$JAVA_HOME/lib"
+    fi
+    ILIB1=-link
+    PathFormat "${COMPATH}/lib/$WIN_HOST_ARCH"
+    ILIB="$ILIB;$formatted_path"
+    ILIB1="$ILIB1 -LIBPATH:$formatted_path"
+    ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
+    ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
+    if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
+        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
+        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
+    fi
+    PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/$WIN_HOST_ARCH"
+    ucrtlibpath_formatted=$formatted_path
+    ILIB="$ILIB;$ucrtlibpath_formatted"
+    ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
+    if test -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
+        PathFormat "$DOTNET_FRAMEWORK_HOME/lib"
+        ILIB="$ILIB;$formatted_path"
+    else
+        PathFormat "$DOTNET_FRAMEWORK_HOME/Lib/um/$WIN_HOST_ARCH"
+        ILIB="$ILIB;$formatted_path"
+    fi
+
+    if test "$cross_compiling" != "yes"; then
+        ILIB_FOR_BUILD="$ILIB"
+    fi
+fi
+AC_SUBST(ILIB)
+AC_SUBST(ILIB_FOR_BUILD)
+
+AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
+dnl ...that does not suffer from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
+dnl from consteval constructor initializing const variable",
+dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ is not a constant
+dnl expression' with consteval constructor", <https://bugs.llvm.org/show_bug.cgi?id=50063> "code
+dnl using consteval: 'clang/lib/CodeGen/Address.h:38: llvm::Value*
+dnl clang::CodeGen::Address::getPointer() const: Assertion `isValid()' failed.'" (which should be
+dnl fixed since Clang 14), <https://developercommunity.visualstudio.com/t/1581879> "Bogus error
+dnl C7595 with consteval constructor in ternary expression (/std:c++latest)", or
+dnl <https://github.com/llvm/llvm-project/issues/54612> "C++20, consteval, anonymous union:
+dnl llvm/lib/IR/Instructions.cpp:1491: void llvm::StoreInst::AssertOK(): Assertion
+dnl `cast<PointerType>(getOperand(1)->getType())->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType())
+dnl && "Ptr must be a pointer to Val type!"' failed." (which should be fixed since Clang 17):
+AC_LANG_PUSH([C++])
+save_CXX=$CXX
+if test "$COM" = MSC && test "$COM_IS_CLANG" != TRUE; then
+    CXX="env LIB=$ILIB $CXX"
+fi
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_RUN_IFELSE([AC_LANG_PROGRAM([
+        struct S {
+            consteval S() { i = 1; }
+            int i = 0;
+        };
+        S const s;
+
+        struct S1 {
+             int a;
+             consteval S1(int n): a(n) {}
+        };
+        struct S2 {
+            S1 x;
+            S2(): x(0) {}
+        };
+
+        struct S3 {
+            consteval S3() {}
+            union {
+                int a;
+                unsigned b = 0;
+            };
+        };
+        void f() { S3(); }
+
+        struct S4 { consteval S4() = default; };
+        void f4(bool b) { b ? S4() : S4(); }
+
+        struct S5 {
+            consteval S5() { c = 0; }
+            char * f() { return &c; }
+            union {
+                char c;
+                int i;
+            };
+        };
+        auto s5 = S5().f();
+    ], [
+        return (s.i == 1) ? 0 : 1;
+    ])], [
+        AC_DEFINE([HAVE_CPP_CONSTEVAL],[1])
+        AC_MSG_RESULT([yes])
+    ], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([assumed no (cross compiling)])])
+CXX=$save_CXX
+CXXFLAGS=$save_CXXFLAGS
+AC_LANG_POP([C++])
+
+# ===================================================================
+# Creating bigger shared library to link against
+# ===================================================================
+AC_MSG_CHECKING([whether to create huge library])
+MERGELIBS=
+
+if test $_os = iOS -o $_os = Android; then
+    # Never any point in mergelibs for these as we build just static
+    # libraries anyway...
+    enable_mergelibs=no
+fi
+
+if test -n "$enable_mergelibs" -a "$enable_mergelibs" != "no"; then
+    if test $_os != Linux -a $_os != WINNT; then
+        add_warning "--enable-mergelibs is not tested for this platform"
+    fi
+    MERGELIBS="TRUE"
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(ENABLE_MERGELIBS)
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST([MERGELIBS])
+
+dnl ===================================================================
+dnl icerun is a wrapper that stops us spawning tens of processes
+dnl locally - for tools that can't be executed on the compile cluster
+dnl this avoids a dozen javac's ganging up on your laptop to kill it.
+dnl ===================================================================
+AC_MSG_CHECKING([whether to use icerun wrapper])
+ICECREAM_RUN=
+if test "$enable_icecream" = "yes" && which icerun >/dev/null 2>&1 ; then
+    ICECREAM_RUN=icerun
+    AC_MSG_RESULT([yes])
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ICECREAM_RUN)
+
+dnl ===================================================================
+dnl Setup the ICECC_VERSION for the build the same way it was set for
+dnl configure, so that CC/CXX and ICECC_VERSION are in sync
+dnl ===================================================================
+x_ICECC_VERSION=[\#]
+if test -n "$ICECC_VERSION" ; then
+    x_ICECC_VERSION=
+fi
+AC_SUBST(x_ICECC_VERSION)
+AC_SUBST(ICECC_VERSION)
+
+dnl ===================================================================
+
+AC_MSG_CHECKING([MPL subset])
+MPL_SUBSET=
+LICENSE="LGPL"
+
+if test "$enable_mpl_subset" = "yes"; then
+    mpl_error_string=
+    newline=$'\n    *'
+    warn_report=false
+    if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
+        warn_report=true
+    elif test "$ENABLE_REPORTBUILDER" = "TRUE"; then
+        warn_report=true
+    fi
+    if test "$warn_report" = "true"; then
+        mpl_error_string="$mpl_error_string$newline Need to --disable-report-builder - extended database report builder."
+    fi
+    if test "x$enable_postgresql_sdbc" != "xno"; then
+        mpl_error_string="$mpl_error_string$newline Need to --disable-postgresql-sdbc - the PostgreSQL database backend."
+    fi
+    if test "$enable_lotuswordpro" = "yes"; then
+        mpl_error_string="$mpl_error_string$newline Need to --disable-lotuswordpro - a Lotus Word Pro file format import filter."
+    fi
+    if test -n "$ENABLE_POPPLER"; then
+        if test "x$SYSTEM_POPPLER" = "x"; then
+            mpl_error_string="$mpl_error_string$newline Need to disable PDF import via poppler (--disable-poppler) or use system library."
+        fi
+    fi
+    # cf. m4/libo_check_extension.m4
+    if test "x$WITH_EXTRA_EXTENSIONS" != "x"; then
+        mpl_error_string="$mpl_error_string$newline Need to disable extra extensions enabled using --enable-ext-XXXX."
+    fi
+    denied_themes=
+    filtered_themes=
+    for theme in $WITH_THEMES; do
+        case $theme in
+        breeze|breeze_dark|breeze_dark_svg|breeze_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg) #denylist of icon themes under GPL or LGPL
+            denied_themes="${denied_themes:+$denied_themes }$theme" ;;
+        *)
+            filtered_themes="${filtered_themes:+$filtered_themes }$theme" ;;
+        esac
+    done
+    if test "x$denied_themes" != "x"; then
+        if test "x$filtered_themes" == "x"; then
+            filtered_themes="colibre"
+        fi
+        mpl_error_string="$mpl_error_string$newline Need to disable icon themes: $denied_themes, use --with-theme=$filtered_themes."
+    fi
+
+    ENABLE_OPENGL_TRANSITIONS=
+
+    if test "$enable_lpsolve" != "no" -o "x$ENABLE_LPSOLVE" = "xTRUE"; then
+        mpl_error_string="$mpl_error_string$newline Need to --disable-lpsolve - calc linear programming solver."
+    fi
+
+    if test "x$mpl_error_string" != "x"; then
+        AC_MSG_ERROR([$mpl_error_string])
+    fi
+
+    MPL_SUBSET="TRUE"
+    LICENSE="MPL-2.0"
+    AC_DEFINE(MPL_HAVE_SUBSET)
+    AC_MSG_RESULT([only])
+else
+    AC_MSG_RESULT([no restrictions])
+fi
+AC_SUBST(MPL_SUBSET)
+AC_SUBST(LICENSE)
+
+dnl ===================================================================
+
+AC_MSG_CHECKING([formula logger])
+ENABLE_FORMULA_LOGGER=
+
+if test "x$enable_formula_logger" = "xyes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(ENABLE_FORMULA_LOGGER)
+    ENABLE_FORMULA_LOGGER=TRUE
+elif test -n "$ENABLE_DBGUTIL" ; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(ENABLE_FORMULA_LOGGER)
+    ENABLE_FORMULA_LOGGER=TRUE
+else
+    AC_MSG_RESULT([no])
+fi
+
+AC_SUBST(ENABLE_FORMULA_LOGGER)
+
+dnl ===================================================================
+dnl Checking for active Antivirus software.
+dnl ===================================================================
+
+if test $_os = WINNT -a -f "$SRC_ROOT/antivirusDetection.vbs" ; then
+    AC_MSG_CHECKING([for active Antivirus software])
+    PathFormat "$SRC_ROOT/antivirusDetection.vbs"
+    ANTIVIRUS_LIST=`cscript.exe //Nologo ${formatted_path}`
+    if [ [ "$ANTIVIRUS_LIST" != "NULL" ] ]; then
+        if [ [ "$ANTIVIRUS_LIST" != "NOT_FOUND" ] ]; then
+            AC_MSG_RESULT([found])
+            EICAR_STRING='X5O!P%@AP@<:@4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
+            echo $EICAR_STRING > $SRC_ROOT/eicar
+            EICAR_TEMP_FILE_CONTENTS=`cat $SRC_ROOT/eicar`
+            rm $SRC_ROOT/eicar
+            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
+                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
+            fi
+            echo $EICAR_STRING > $BUILDDIR/eicar
+            EICAR_TEMP_FILE_CONTENTS=`cat $BUILDDIR/eicar`
+            rm $BUILDDIR/eicar
+            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
+                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
+            fi
+            add_warning "To speed up builds and avoid failures in unit tests, it is highly recommended that you exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST"
+        else
+            AC_MSG_RESULT([not found])
+        fi
+    else
+        AC_MSG_RESULT([n/a])
+    fi
+fi
+
+dnl ===================================================================
+
+AC_MSG_CHECKING([for coredumpctl support])
+if test -z "$with_coredumpctl" && test $_os != Linux; then
+    with_coredumpctl=no
+fi
+if test "$with_coredumpctl" = no; then
+    WITH_COREDUMPCTL=
+else
+    AC_PATH_PROG(COREDUMPCTL, coredumpctl)
+    AC_PATH_PROG(JQ, jq)
+    AC_PATH_PROG(SYSTEMD_ESCAPE, systemd-escape)
+    AC_PATH_PROG(SYSTEMD_RUN, systemd-run)
+    if test -z "$COREDUMPCTL" || test -z "$JQ" || test -z "$SYSTEMD_ESCAPE" \
+        || test -z "$SYSTEMD_RUN"
+    then
+        if test -z "$with_coredumpctl"; then
+            WITH_COREDUMPCTL=
+        else
+            if test -z "$COREDUMPCTL"; then
+                AC_MSG_ERROR([coredumpctl not found])
+            fi
+            if test -z "$JQ"; then
+                AC_MSG_ERROR([jq not found])
+            fi
+            if test -z "$SYSTEMD_ESCAPE"; then
+                AC_MSG_ERROR([systemd-escape not found])
+            fi
+            if test -z "$SYSTEMD_RUN"; then
+                AC_MSG_ERROR([systemd-run not found])
+            fi
+        fi
+    else
+        WITH_COREDUMPCTL=TRUE
+    fi
+fi
+if test -z "$WITH_COREDUMPCTL"; then
+    AC_MSG_RESULT([no])
+else
+    AC_MSG_RESULT([yes])
+fi
+AC_SUBST(COREDUMPCTL)
+AC_SUBST(JQ)
+AC_SUBST(SYSTEMD_ESCAPE)
+AC_SUBST(SYSTEMD_RUN)
+AC_SUBST(WITH_COREDUMPCTL)
+
+dnl ===================================================================
+dnl Setting up the environment.
+dnl ===================================================================
+AC_MSG_NOTICE([setting up the build environment variables...])
+
+AC_SUBST(COMPATH)
+
+if test "$build_os" = "cygwin" -o "$build_os" = wsl; then
+    if test -d "$COMPATH/atlmfc/lib/spectre"; then
+        ATL_LIB="$COMPATH/atlmfc/lib/spectre"
+        ATL_INCLUDE="$COMPATH/atlmfc/include"
+    elif test -d "$COMPATH/atlmfc/lib"; then
+        ATL_LIB="$COMPATH/atlmfc/lib"
+        ATL_INCLUDE="$COMPATH/atlmfc/include"
+    else
+        ATL_LIB="$WINDOWS_SDK_HOME/lib" # Doesn't exist for VSE
+        ATL_INCLUDE="$WINDOWS_SDK_HOME/include/atl"
+    fi
+    ATL_LIB="$ATL_LIB/$WIN_HOST_ARCH"
+    ATL_LIB=`win_short_path_for_make "$ATL_LIB"`
+    ATL_INCLUDE=`win_short_path_for_make "$ATL_INCLUDE"`
+fi
+
+if test "$build_os" = "cygwin"; then
+    # sort.exe and find.exe also exist in C:/Windows/system32 so need /usr/bin/
+    PathFormat "/usr/bin/find.exe"
+    FIND="$formatted_path"
+    PathFormat "/usr/bin/sort.exe"
+    SORT="$formatted_path"
+    PathFormat "/usr/bin/grep.exe"
+    WIN_GREP="$formatted_path"
+    PathFormat "/usr/bin/ls.exe"
+    WIN_LS="$formatted_path"
+    PathFormat "/usr/bin/touch.exe"
+    WIN_TOUCH="$formatted_path"
+else
+    FIND=find
+    SORT=sort
+fi
+
+AC_SUBST(ATL_INCLUDE)
+AC_SUBST(ATL_LIB)
+AC_SUBST(FIND)
+AC_SUBST(SORT)
+AC_SUBST(WIN_GREP)
+AC_SUBST(WIN_LS)
+AC_SUBST(WIN_TOUCH)
+
+AC_SUBST(BUILD_TYPE)
+
+AC_SUBST(SOLARINC)
+
+PathFormat "$PERL"
+PERL="$formatted_path"
+AC_SUBST(PERL)
+
+if test -n "$TMPDIR"; then
+    TEMP_DIRECTORY="$TMPDIR"
+else
+    TEMP_DIRECTORY="/tmp"
+fi
+CYGWIN_BASH="C:/cygwin64/bin/bash.exe"
+if test "$build_os" = "cygwin"; then
+    TEMP_DIRECTORY=`cygpath -m "$TEMP_DIRECTORY"`
+    CYGWIN_BASH=`cygpath -m /usr/bin/bash`
+fi
+AC_SUBST(TEMP_DIRECTORY)
+AC_SUBST(CYGWIN_BASH)
+
+# setup the PATH for the environment
+if test -n "$LO_PATH_FOR_BUILD"; then
+    LO_PATH="$LO_PATH_FOR_BUILD"
+    case "$host_os" in
+    cygwin*|wsl*)
+        pathmunge "$MSVC_HOST_PATH" "before"
+        ;;
+    esac
+else
+    LO_PATH="$PATH"
+
+    case "$host_os" in
+
+    dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
+        if test "$ENABLE_JAVA" != ""; then
+            pathmunge "$JAVA_HOME/bin" "after"
+        fi
+        ;;
+
+    cygwin*|wsl*)
+        # Win32 make needs native paths
+        if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
+            LO_PATH=`cygpath -p -m "$PATH"`
+        fi
+        if test "$WIN_BUILD_ARCH" = "x64"; then
+            # needed for msi packaging
+            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
+        fi
+        if test "$WIN_BUILD_ARCH" = "arm64"; then
+            # needed for msi packaging - as of 10.0.22621 SDK no arm64 ones yet
+            # the x86 ones probably would work just as well...
+            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/arm" "before"
+        fi
+        # .NET 4.6 and higher don't have bin directory
+        if test -f "$DOTNET_FRAMEWORK_HOME/bin"; then
+            pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
+        fi
+        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
+        pathmunge "$CSC_PATH" "before"
+        pathmunge "$MIDL_PATH" "before"
+        pathmunge "$AL_PATH" "before"
+        pathmunge "$MSVC_MULTI_PATH" "before"
+        pathmunge "$MSVC_BUILD_PATH" "before"
+        if test -n "$MSBUILD_PATH" ; then
+            pathmunge "$MSBUILD_PATH" "before"
+        fi
+        pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/$WIN_BUILD_ARCH" "before"
+        if test "$ENABLE_JAVA" != ""; then
+            if test -d "$JAVA_HOME/jre/bin/client"; then
+                pathmunge "$JAVA_HOME/jre/bin/client" "before"
+            fi
+            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
+                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
+            fi
+            pathmunge "$JAVA_HOME/bin" "before"
+        fi
+        pathmunge "$MSVC_HOST_PATH" "before"
+        ;;
+
+    solaris*)
+        pathmunge "/usr/css/bin" "before"
+        if test "$ENABLE_JAVA" != ""; then
+            pathmunge "$JAVA_HOME/bin" "after"
+        fi
+        ;;
+    esac
+fi
+
+AC_SUBST(LO_PATH)
+
+# Allow to pass LO_ELFCHECK_ALLOWLIST from autogen.input to bin/check-elf-dynamic-objects:
+if test "$LO_ELFCHECK_ALLOWLIST" = x || test "${LO_ELFCHECK_ALLOWLIST-x}" != x; then
+    x_LO_ELFCHECK_ALLOWLIST=
+else
+    x_LO_ELFCHECK_ALLOWLIST=[\#]
+fi
+AC_SUBST(x_LO_ELFCHECK_ALLOWLIST)
+AC_SUBST(LO_ELFCHECK_ALLOWLIST)
+
+libo_FUZZ_SUMMARY
+
+# Generate a configuration sha256 we can use for deps
+if test -f config_host.mk; then
+    config_sha256=`$SHA256SUM config_host.mk | sed "s/ .*//"`
+fi
+if test -f config_host_lang.mk; then
+    config_lang_sha256=`$SHA256SUM config_host_lang.mk | sed "s/ .*//"`
+fi
+
+CFLAGS=$my_original_CFLAGS
+CXXFLAGS=$my_original_CXXFLAGS
+CPPFLAGS=$my_original_CPPFLAGS
+
+AC_CONFIG_LINKS([include:include])
+
+# Keep in sync with list of files far up, at AC_MSG_CHECKING([for
+# BUILD platform configuration] - otherwise breaks cross building
+AC_CONFIG_FILES([config_host.mk
+                 config_host_lang.mk
+                 Makefile
+                 bin/bffvalidator.sh
+                 bin/odfvalidator.sh
+                 bin/officeotron.sh
+                 instsetoo_native/util/openoffice.lst
+                 sysui/desktop/macosx/Info.plist
+                 hardened_runtime.xcent:sysui/desktop/macosx/hardened_runtime.xcent.in
+                 lo.xcent:sysui/desktop/macosx/lo.xcent.in
+                 vs-code.code-workspace.template:.vscode/vs-code-template.code-workspace.in])
+
+AC_CONFIG_HEADERS([config_host/config_atspi.h])
+AC_CONFIG_HEADERS([config_host/config_buildconfig.h])
+AC_CONFIG_HEADERS([config_host/config_buildid.h])
+AC_CONFIG_HEADERS([config_host/config_box2d.h])
+AC_CONFIG_HEADERS([config_host/config_clang.h])
+AC_CONFIG_HEADERS([config_host/config_crypto.h])
+AC_CONFIG_HEADERS([config_host/config_dconf.h])
+AC_CONFIG_HEADERS([config_host/config_eot.h])
+AC_CONFIG_HEADERS([config_host/config_extensions.h])
+AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
+AC_CONFIG_HEADERS([config_host/config_cairo_rgba.h])
+AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
+AC_CONFIG_HEADERS([config_host/config_dbus.h])
+AC_CONFIG_HEADERS([config_host/config_features.h])
+AC_CONFIG_HEADERS([config_host/config_feature_desktop.h])
+AC_CONFIG_HEADERS([config_host/config_feature_opencl.h])
+AC_CONFIG_HEADERS([config_host/config_firebird.h])
+AC_CONFIG_HEADERS([config_host/config_folders.h])
+AC_CONFIG_HEADERS([config_host/config_fonts.h])
+AC_CONFIG_HEADERS([config_host/config_fuzzers.h])
+AC_CONFIG_HEADERS([config_host/config_gio.h])
+AC_CONFIG_HEADERS([config_host/config_global.h])
+AC_CONFIG_HEADERS([config_host/config_gpgme.h])
+AC_CONFIG_HEADERS([config_host/config_java.h])
+AC_CONFIG_HEADERS([config_host/config_langs.h])
+AC_CONFIG_HEADERS([config_host/config_lgpl.h])
+AC_CONFIG_HEADERS([config_host/config_libcxx.h])
+AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
+AC_CONFIG_HEADERS([config_host/config_locales.h])
+AC_CONFIG_HEADERS([config_host/config_mpl.h])
+AC_CONFIG_HEADERS([config_host/config_oox.h])
+AC_CONFIG_HEADERS([config_host/config_options.h])
+AC_CONFIG_HEADERS([config_host/config_options_calc.h])
+AC_CONFIG_HEADERS([config_host/config_zxing.h])
+AC_CONFIG_HEADERS([config_host/config_skia.h])
+AC_CONFIG_HEADERS([config_host/config_typesizes.h])
+AC_CONFIG_HEADERS([config_host/config_validation.h])
+AC_CONFIG_HEADERS([config_host/config_vendor.h])
+AC_CONFIG_HEADERS([config_host/config_vclplug.h])
+AC_CONFIG_HEADERS([config_host/config_version.h])
+AC_CONFIG_HEADERS([config_host/config_oauth2.h])
+AC_CONFIG_HEADERS([config_host/config_poppler.h])
+AC_CONFIG_HEADERS([config_host/config_python.h])
+AC_CONFIG_HEADERS([config_host/config_writerperfect.h])
+AC_CONFIG_HEADERS([config_host/config_wasm_strip.h])
+AC_CONFIG_HEADERS([solenv/lockfile/autoconf.h])
+AC_OUTPUT
+
+if test "$CROSS_COMPILING" = TRUE; then
+    (echo; echo export BUILD_TYPE_FOR_HOST=$BUILD_TYPE) >>config_build.mk
+fi
+
+# touch the config timestamp file
+if test ! -f config_host.mk.stamp; then
+    echo > config_host.mk.stamp
+elif test "$config_sha256" = `$SHA256SUM config_host.mk | sed "s/ .*//"`; then
+    echo "Host Configuration unchanged - avoiding scp2 stamp update"
+else
+    echo > config_host.mk.stamp
+fi
+
+# touch the config lang timestamp file
+if test ! -f config_host_lang.mk.stamp; then
+    echo > config_host_lang.mk.stamp
+elif test "$config_lang_sha256" = `$SHA256SUM config_host_lang.mk | sed "s/ .*//"`; then
+    echo "Language Configuration unchanged - avoiding scp2 stamp update"
+else
+    echo > config_host_lang.mk.stamp
+fi
+
+
+if test \( "$STALE_MAKE" = "TRUE" \) \
+        -a "$build_os" = "cygwin"; then
+
+cat << _EOS
+****************************************************************************
+WARNING:
+Your make version is known to be horribly slow, and hard to debug
+problems with. To get a reasonably functional make please do:
+
+to install a pre-compiled binary make for Win32
+
+ mkdir -p /opt/lo/bin
+ cd /opt/lo/bin
+ wget https://dev-www.libreoffice.org/bin/cygwin/make-4.2.1-msvc.exe
+ cp make-4.2.1-msvc.exe make
+ chmod +x make
+
+to install from source:
+place yourself in a working directory of you choice.
+
+ git clone git://git.savannah.gnu.org/make.git
+
+ [go to Start menu, open "Visual Studio 2019" or "Visual Studio 2022", and then click "x86 Native Tools Command Prompt" or "x64 Native Tools Command Prompt"]
+ set PATH=%PATH%;C:\Cygwin\bin
+ [or Cygwin64, if that is what you have]
+ cd path-to-make-repo-you-cloned-above
+ build_w32.bat --without-guile
+
+should result in a WinRel/gnumake.exe.
+Copy it to the Cygwin /opt/lo/bin directory as make.exe
+
+Then re-run autogen.sh
+
+Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
+Alternatively, you can install the 'new' make where ever you want and make sure that `which make` finds it.
+
+_EOS
+fi
+
+
+cat << _EOF
+****************************************************************************
+
+To show information on various make targets and make flags, run:
+$GNUMAKE help
+
+To just build, run:
+$GNUMAKE
+
+_EOF
+
+if test $_os != WINNT -a "$CROSS_COMPILING" != TRUE; then
+    cat << _EOF
+After the build has finished successfully, you can immediately run what you built using the command:
+_EOF
+
+    if test $_os = Darwin; then
+        echo open instdir/$PRODUCTNAME_WITHOUT_SPACES.app
+    else
+        echo instdir/program/soffice
+    fi
+    cat << _EOF
+
+If you want to run the unit tests, run:
+$GNUMAKE check
+
+_EOF
+fi
+
+if test -s "$WARNINGS_FILE_FOR_BUILD"; then
+    echo "BUILD / cross-toolset config, repeated ($WARNINGS_FILE_FOR_BUILD)"
+    cat "$WARNINGS_FILE_FOR_BUILD"
+    echo
+fi
+
+if test -s "$WARNINGS_FILE"; then
+    echo "HOST config ($WARNINGS_FILE)"
+    cat "$WARNINGS_FILE"
+fi
+
+# Remove unneeded emconfigure artifacts
+rm -f a.out a.wasm a.out.js a.out.wasm
+
+dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
Index: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/create.patch.sh	(nonexistent)
+++ radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/create.patch.sh	(revision 371)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=24.2.0.3
+
+tar --files-from=file.list -xJvf ../libreoffice-$VERSION.tar.xz
+mv libreoffice-$VERSION libreoffice-$VERSION-orig
+
+cp -rf ./libreoffice-$VERSION-new ./libreoffice-$VERSION
+
+diff --unified -Nr  libreoffice-$VERSION-orig  libreoffice-$VERSION > libreoffice-$VERSION-odk-idl.patch
+
+mv libreoffice-$VERSION-odk-idl.patch ../patches
+
+rm -rf ./libreoffice-$VERSION
+rm -rf ./libreoffice-$VERSION-orig

Property changes on: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/file.list
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/file.list	(nonexistent)
+++ radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/file.list	(revision 371)
@@ -0,0 +1 @@
+libreoffice-24.2.0.3/bin/distro-install-sdk
Index: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/libreoffice-24.2.0.3-new/bin/distro-install-sdk
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/libreoffice-24.2.0.3-new/bin/distro-install-sdk	(nonexistent)
+++ radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/libreoffice-24.2.0.3-new/bin/distro-install-sdk	(revision 371)
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+if test -z "${SRC_ROOT}"; then
+    echo "distro-install-clean-up: No environment set!"
+    exit 1
+fi
+
+if test -d $DESTDIR$INSTALLDIR/sdk ; then
+
+    echo "SDK installation clean up"
+
+    # bin potential .orig files
+    find $DESTDIR$INSTALLDIR/sdk -name "*.orig" -exec rm -f {} \;
+
+    # move some SDK directories to the right place according to FHS
+    # note that examples must stay in $DESTDIR$INSTALLDIR/sdk because there are used
+    # relative paths to $DESTDIR$INSTALLDIR/sdk/setting and it does not work via
+    # a symlink
+    mkdir -p $DESTDIR$PREFIXDIR/include
+    mkdir -p $DESTDIR$DATADIR/idl/$INSTALLDIRNAME
+    mkdir -p $DESTDIR$DATADIR/$INSTALLDIRNAME/sdk
+    mkdir -p $DESTDIR$DOCDIR/sdk
+    mv $DESTDIR$INSTALLDIR/sdk/include      $DESTDIR$PREFIXDIR/include/$INSTALLDIRNAME
+    if [ -d $DESTDIR$INSTALLDIR/sdk/classes ]; then
+        mv $DESTDIR$INSTALLDIR/sdk/classes      $DESTDIR$DATADIR/$INSTALLDIRNAME/sdk/classes
+    fi
+    if [ -d $DESTDIR$INSTALLDIR/sdk/idl ]; then
+        mv $DESTDIR$INSTALLDIR/sdk/idl          $DESTDIR$DATADIR/idl/$INSTALLDIRNAME
+    fi
+    mv $DESTDIR$INSTALLDIR/sdk/docs         $DESTDIR$DOCDIR/sdk
+    mv $DESTDIR$INSTALLDIR/sdk/share/readme $DESTDIR$DOCDIR/sdk/readme
+    mv $DESTDIR$INSTALLDIR/sdk/index.html   $DESTDIR$DOCDIR/sdk
+
+    # compat symlinks
+    ln -sf $PREFIXDIR/include/$INSTALLDIRNAME                        $DESTDIR$INSTALLDIR/sdk/include
+    ln -sf $DATADIR/$INSTALLDIRNAME/sdk/classes                      $DESTDIR$INSTALLDIR/sdk/classes
+    ln -sf $DATADIR/idl/$INSTALLDIRNAME                              $DESTDIR$INSTALLDIR/sdk/idl
+    ln -sf $DOCDIR/sdk/docs                                          $DESTDIR$INSTALLDIR/sdk/
+    ln -sf $DOCDIR/sdk/index.html                                    $DESTDIR$INSTALLDIR/sdk/index.html
+    ln -sf $INSTALLDIR/sdk/examples         $DESTDIR$DOCDIR/sdk/examples
+
+    # fix file list
+    sed -e "s|^\(%dir \)\?$INSTALLDIR/sdk/include|\1$PREFIXDIR/include/$INSTALLDIRNAME|" \
+	-e "s|^\(%dir \)\?$INSTALLDIR/sdk/classes|\1$DATADIR/$INSTALLDIRNAME/sdk/classes|" \
+	-e "s|^\(%dir \)\?$INSTALLDIR/sdk/idl|\1$DATADIR/idl/$INSTALLDIRNAME|" \
+	-e "s|^\(%dir \)\?$INSTALLDIR/sdk/docs|\1$DOCDIR/sdk/docs|" \
+	-e "s|^\(%dir \)\?$INSTALLDIR/sdk/share/readme|\1$DOCDIR/sdk/readme|" \
+	-e "s|^$INSTALLDIR/sdk/index.html$|$DOCDIR/sdk/index.html|" \
+	-e "s|^\(%dir \)\?$INSTALLDIR/sdk/share.*$||" \
+	-e "/\.orig$/D" \
+	-e "/^$/D" \
+	$DESTDIR/gid_Module_Root_SDK | sort -u \
+	>$DESTDIR/gid_Module_Root_SDK.new
+    mv $DESTDIR/gid_Module_Root_SDK.new $DESTDIR/gid_Module_Root_SDK
+    #
+    echo "%dir $DATADIR/$INSTALLDIRNAME/sdk"                    >>$DESTDIR/gid_Module_Root_SDK
+    echo "%dir $DATADIR/$INSTALLDIRNAME"                        >>$DESTDIR/gid_Module_Root_SDK
+    echo "%dir $DATADIR/idl"                                    >>$DESTDIR/gid_Module_Root_SDK
+    echo "%dir $DOCDIR/sdk/docs"                                >>$DESTDIR/gid_Module_Root_SDK
+    echo "%dir $DOCDIR/sdk"                                     >>$DESTDIR/gid_Module_Root_SDK
+    echo "%dir $DOCDIR"                                         >>$DESTDIR/gid_Module_Root_SDK
+    echo "$INSTALLDIR/sdk/include"     >>$DESTDIR/gid_Module_Root_SDK
+    echo "$INSTALLDIR/sdk/classes"     >>$DESTDIR/gid_Module_Root_SDK
+    echo "$INSTALLDIR/sdk/idl"         >>$DESTDIR/gid_Module_Root_SDK
+    echo "$INSTALLDIR/sdk/docs"        >>$DESTDIR/gid_Module_Root_SDK
+    echo "$INSTALLDIR/sdk/index.html"  >>$DESTDIR/gid_Module_Root_SDK
+    echo "$DOCDIR/sdk/examples"                                 >>$DESTDIR/gid_Module_Root_SDK
+
+    # generate default profiles
+    sed -e "s,@OO_SDK_NAME@,libreoffice${PRODUCTVERSION}_sdk," \
+        -e "s,@OO_SDK_HOME@,$INSTALLDIR/sdk," \
+        -e "s,@OFFICE_HOME@,$INSTALLDIR," \
+        -e "s,@OO_SDK_MAKE_HOME@,$(dirname $(command -v make))," \
+        -e "s,@OO_SDK_ZIP_HOME@,$(dirname $(command -v zip))," \
+        -e "s,@OO_SDK_CPP_HOME@,$(dirname $(command -v cpp))," \
+        -e "s,@OO_SDK_SED_HOME@,$(dirname $(command -v sed))," \
+        -e "s,@OO_SDK_CAT_HOME@,$(dirname $(command -v cat))," \
+        -e "s,@OO_SDK_JAVA_HOME@,$JAVA_HOME," \
+        -e "s,@OO_SDK_OUTPUT_DIR@,\$HOME," \
+        -e "s,@SDK_AUTO_DEPLOYMENT@,NO," \
+            $DESTDIR$INSTALLDIR/sdk/setsdkenv_unix.sh.in \
+        > $DESTDIR$INSTALLDIR/sdk/setsdkenv_unix.sh
+    chmod 755 $DESTDIR$INSTALLDIR/sdk/setsdkenv_unix.sh
+    echo $INSTALLDIR/sdk/setsdkenv_unix.sh >>$DESTDIR/gid_Module_Root_SDK
+
+fi

Property changes on: radix-1.9/sources/packages/x/libreoffice/create-24.2.0.3-odk-idl-patch/libreoffice-24.2.0.3-new/bin/distro-install-sdk
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/packages/x/libreoffice/patches/README
===================================================================
--- radix-1.9/sources/packages/x/libreoffice/patches/README	(revision 370)
+++ radix-1.9/sources/packages/x/libreoffice/patches/README	(revision 371)
@@ -1,16 +1,16 @@
 
 /* begin *
 
-   libreoffice-7.6.2.1-isystem.patch - Do not use -isystem option for system includes.
+   libreoffice-24.2.0.3-isystem.patch - Do not use -isystem option for system includes.
 
-   libreoffice-7.6.2.1-odk-idl.patch - The SDK no longer ships an idl/ sub-directory
-                                       containing the udkap and offapi .idl files (as,
-                                       unlike idlc, unoidl-write does not need them).
-                                       odk/config/cfgWin.js had to be adapted to look
-                                       (somewhat arbitrarily) for an examples/
-                                       sub-directory instead of idl/ when checking for
-                                       'an sdk folder'.  gb_UnoApi_package_idlfiles
-                                       became unused and has been removed.
+   libreoffice-24.2.0.3-odk-idl.patch - The SDK no longer ships an idl/ sub-directory
+                                        containing the udkap and offapi .idl files (as,
+                                        unlike idlc, unoidl-write does not need them).
+                                        odk/config/cfgWin.js had to be adapted to look
+                                        (somewhat arbitrarily) for an examples/
+                                        sub-directory instead of idl/ when checking for
+                                        'an sdk folder'.  gb_UnoApi_package_idlfiles
+                                        became unused and has been removed.
    See:
    ---
    https://wiki.documentfoundation.org/ReleaseNotes/7.5#Feature_Removal_/_Deprecation