git: fb689b1fc5d3 - main - www/chromium: update to 117.0.5938.88 and unbreak on arm64 and i386

From: Robert Nagy <rnagy_at_FreeBSD.org>
Date: Sun, 17 Sep 2023 19:45:21 UTC
The branch main has been updated by rnagy:

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

commit fb689b1fc5d35bbb0de04fecb4bd93b445dab160
Author:     Robert Nagy <rnagy@FreeBSD.org>
AuthorDate: 2023-09-17 19:43:59 +0000
Commit:     Robert Nagy <rnagy@FreeBSD.org>
CommitDate: 2023-09-17 19:45:06 +0000

    www/chromium: update to 117.0.5938.88 and unbreak on arm64 and i386
---
 www/chromium/Makefile                              |  2 +-
 www/chromium/distinfo                              | 14 +++---
 ...m_source_libaom_aom__ports_aarch64__cpudetect.c | 39 +++++++++++++++++
 .../files/patch-third__party_zlib_BUILD.gn         | 24 +++++++++-
 .../files/patch-third__party_zlib_cpu__features.c  | 51 ++++++++++++++++++++++
 www/chromium/files/patch-v8_BUILD.gn               | 19 ++++++--
 6 files changed, 136 insertions(+), 13 deletions(-)

diff --git a/www/chromium/Makefile b/www/chromium/Makefile
index e4b5e6eb52aa..7f20e5023b47 100644
--- a/www/chromium/Makefile
+++ b/www/chromium/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	chromium
-PORTVERSION=	117.0.5938.62
+PORTVERSION=	117.0.5938.88
 CATEGORIES=	www wayland
 MASTER_SITES=	https://commondatastorage.googleapis.com/chromium-browser-official/ \
 		https://nerd.hu/distfiles/:external
diff --git a/www/chromium/distinfo b/www/chromium/distinfo
index c4b0ecaab7c7..1ae7f631e473 100644
--- a/www/chromium/distinfo
+++ b/www/chromium/distinfo
@@ -1,9 +1,9 @@
-TIMESTAMP = 1694607972
-SHA256 (chromium-117.0.5938.62.tar.xz) = 8b8c697208ef9fe014de112c62ebd19268cd6cd9430838700afa985c715175d7
-SIZE (chromium-117.0.5938.62.tar.xz) = 3135390052
-SHA256 (chrome-linux-117.0.5938.62-llvm13.profdata.tar.xz) = a5430aa2d0f3025dc6b28ea8caf34c9014aa929916f64392b3d335edfe342c2e
-SIZE (chrome-linux-117.0.5938.62-llvm13.profdata.tar.xz) = 28703740
-SHA256 (chromium-117.0.5938.62-testdata.tar.xz) = 7d99eec432a679f154312491d5717b5689af9ac69927d35b66812c2399f91141
-SIZE (chromium-117.0.5938.62-testdata.tar.xz) = 269863964
+TIMESTAMP = 1694973247
+SHA256 (chromium-117.0.5938.88.tar.xz) = 4691d80039e4155d1a3c4676ee68a1e526ddad61a3cf59f65d596a1a2d56c906
+SIZE (chromium-117.0.5938.88.tar.xz) = 3131921384
+SHA256 (chrome-linux-117.0.5938.88-llvm13.profdata.tar.xz) = bca65375450523219e2f96cf851fb6b8f5125a99f8688f2f728ae63d1abcd149
+SIZE (chrome-linux-117.0.5938.88-llvm13.profdata.tar.xz) = 28704844
+SHA256 (chromium-117.0.5938.88-testdata.tar.xz) = c5256997647bcb05a4b829d99e9efcfa7e1bc46b44a9feceb67a91856ed54085
+SIZE (chromium-117.0.5938.88-testdata.tar.xz) = 269473360
 SHA256 (test_fonts-336e775eec536b2d785cc80eff6ac39051931286.tar.gz) = a2ca2962daf482a8f943163541e1c73ba4b2694fabcd2510981f2db4eda493c8
 SIZE (test_fonts-336e775eec536b2d785cc80eff6ac39051931286.tar.gz) = 32624734
diff --git a/www/chromium/files/patch-third__party_libaom_source_libaom_aom__ports_aarch64__cpudetect.c b/www/chromium/files/patch-third__party_libaom_source_libaom_aom__ports_aarch64__cpudetect.c
new file mode 100644
index 000000000000..5ed2c2b9a391
--- /dev/null
+++ b/www/chromium/files/patch-third__party_libaom_source_libaom_aom__ports_aarch64__cpudetect.c
@@ -0,0 +1,39 @@
+--- third_party/libaom/source/libaom/aom_ports/aarch64_cpudetect.c.orig	2023-09-17 18:22:45 UTC
++++ third_party/libaom/source/libaom/aom_ports/aarch64_cpudetect.c
+@@ -85,13 +85,35 @@ static int arm_get_cpu_caps(void) {
+   return flags;
+ }
+ 
+-#elif defined(ANDROID_USE_CPU_FEATURES_LIB)
++#elif defined(ANDROID_USE_CPU_FEATURES_LIB) || defined(__FreeBSD__)
+ 
+ static int arm_get_cpu_caps(void) {
+   int flags = 0;
+ #if HAVE_NEON
+   flags |= HAS_NEON;  // Neon is mandatory in Armv8.0-A.
+ #endif  // HAVE_NEON
++  return flags;
++}
++
++#elif defined(__OpenBSD__)
++#include <sys/sysctl.h>
++#include <machine/cpu.h>
++#include <machine/armreg.h>
++
++static int arm_get_cpu_caps(void) {
++  int flags = 0;
++  int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 };
++  uint64_t cpu_id = 0;
++  size_t len = sizeof(cpu_id);
++
++  flags |= HAS_NEON;  // Neon is mandatory in Armv8.0-A.
++
++  if (sysctl(isar0_mib, 2, &cpu_id, &len, NULL, 0) < 0)
++    return flags;
++
++  if (ID_AA64ISAR0_AES(cpu_id) >= ID_AA64ISAR0_CRC32_BASE)
++    flags |= HAS_ARM_CRC32;
++
+   return flags;
+ }
+ 
diff --git a/www/chromium/files/patch-third__party_zlib_BUILD.gn b/www/chromium/files/patch-third__party_zlib_BUILD.gn
index 9aae0c6b9b41..2e47f5d3c133 100644
--- a/www/chromium/files/patch-third__party_zlib_BUILD.gn
+++ b/www/chromium/files/patch-third__party_zlib_BUILD.gn
@@ -1,6 +1,26 @@
---- third_party/zlib/BUILD.gn.orig	2023-09-13 12:11:42 UTC
+--- third_party/zlib/BUILD.gn.orig	2023-09-17 18:22:45 UTC
 +++ third_party/zlib/BUILD.gn
-@@ -408,7 +408,7 @@ static_library("minizip") {
+@@ -127,7 +127,7 @@ if (use_arm_neon_optimizations) {
+     defines = [ "CRC32_ARMV8_CRC32" ]
+     if (is_android) {
+       defines += [ "ARMV8_OS_ANDROID" ]
+-    } else if (is_linux || is_chromeos) {
++    } else if ((is_linux || is_chromeos) && !is_bsd) {
+       defines += [ "ARMV8_OS_LINUX" ]
+     } else if (is_mac) {
+       defines += [ "ARMV8_OS_MACOS" ]
+@@ -137,6 +137,10 @@ if (use_arm_neon_optimizations) {
+       defines += [ "ARMV8_OS_FUCHSIA" ]
+     } else if (is_win) {
+       defines += [ "ARMV8_OS_WINDOWS" ]
++    } else if (is_openbsd) {
++      defines += [ "ARMV8_OS_OPENBSD" ]
++    } else if (is_freebsd) {
++      defines += [ "ARMV8_OS_FREEBSD" ]
+     } else {
+       assert(false, "Unsupported ARM OS")
+     }
+@@ -408,7 +412,7 @@ static_library("minizip") {
      ]
    }
  
diff --git a/www/chromium/files/patch-third__party_zlib_cpu__features.c b/www/chromium/files/patch-third__party_zlib_cpu__features.c
new file mode 100644
index 000000000000..888381dfafd9
--- /dev/null
+++ b/www/chromium/files/patch-third__party_zlib_cpu__features.c
@@ -0,0 +1,51 @@
+--- third_party/zlib/cpu_features.c.orig	2023-09-17 18:22:45 UTC
++++ third_party/zlib/cpu_features.c
+@@ -35,7 +35,8 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;
+ 
+ #ifndef CPU_NO_SIMD
+ 
+-#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_IOS)
++#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_IOS) || \
++    defined(ARMV8_OS_OPENBSD) || defined(ARMV8_OS_FREEBSD)
+ #include <pthread.h>
+ #endif
+ 
+@@ -52,6 +53,10 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;
+ #include <windows.h>
+ #elif defined(ARMV8_OS_IOS)
+ #include <sys/sysctl.h>
++#elif defined(ARMV8_OS_OPENBSD)
++#include <sys/sysctl.h>
++#include <machine/cpu.h>
++#include <machine/armreg.h>
+ #elif !defined(_MSC_VER)
+ #include <pthread.h>
+ #else
+@@ -62,7 +67,8 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;
+ static void _cpu_check_features(void);
+ #endif
+ 
+-#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) || defined(ARMV8_OS_IOS)
++#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) || defined(ARMV8_OS_IOS) || \
++    defined(ARMV8_OS_OPENBSD) || defined(ARMV8_OS_FREEBSD)
+ #if !defined(ARMV8_OS_MACOS)
+ // _cpu_check_features() doesn't need to do anything on mac/arm since all
+ // features are known at build time, so don't call it.
+@@ -115,6 +121,17 @@ static void _cpu_check_features(void)
+     unsigned long features = getauxval(AT_HWCAP2);
+     arm_cpu_enable_crc32 = !!(features & HWCAP2_CRC32);
+     arm_cpu_enable_pmull = !!(features & HWCAP2_PMULL);
++#elif defined(ARMV8_OS_OPENBSD)
++    int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 };
++    uint64_t cpu_id = 0;
++    size_t len = sizeof(cpu_id);
++    if (sysctl(isar0_mib, 2, &cpu_id, &len, NULL, 0) < 0)
++        return;
++    if (ID_AA64ISAR0_AES(cpu_id) >= ID_AA64ISAR0_AES_PMULL)
++        arm_cpu_enable_pmull = 1;
++
++    if (ID_AA64ISAR0_AES(cpu_id) >= ID_AA64ISAR0_CRC32_BASE)
++        arm_cpu_enable_crc32 = 1;
+ #elif defined(ARMV8_OS_FUCHSIA)
+     uint32_t features;
+     zx_status_t rc = zx_system_get_features(ZX_FEATURE_KIND_CPU, &features);
diff --git a/www/chromium/files/patch-v8_BUILD.gn b/www/chromium/files/patch-v8_BUILD.gn
index fc35839b7f08..f30f452c62d4 100644
--- a/www/chromium/files/patch-v8_BUILD.gn
+++ b/www/chromium/files/patch-v8_BUILD.gn
@@ -1,4 +1,4 @@
---- v8/BUILD.gn.orig	2023-09-13 12:11:42 UTC
+--- v8/BUILD.gn.orig	2023-09-17 18:22:45 UTC
 +++ v8/BUILD.gn
 @@ -1404,6 +1404,14 @@ config("toolchain") {
    } else if (target_os == "chromeos") {
@@ -27,7 +27,20 @@
      }
  
      if (v8_enable_builtins_profiling) {
-@@ -6081,7 +6094,7 @@ v8_component("v8_libbase") {
+@@ -2353,6 +2366,12 @@ template("run_mksnapshot") {
+       if (!v8_enable_builtins_profiling && v8_enable_builtins_reordering) {
+         args += [ "--reorder-builtins" ]
+       }
++
++      if (v8_current_cpu == "x86") {
++        args -= [
++          "--abort-on-bad-builtin-profile-data",
++        ]
++      }
+     }
+ 
+     # This is needed to distinguish between generating code for the simulator
+@@ -6081,7 +6100,7 @@ v8_component("v8_libbase") {
      }
    }
  
@@ -36,7 +49,7 @@
      sources += [
        "src/base/debug/stack_trace_posix.cc",
        "src/base/platform/platform-linux.cc",
-@@ -6092,6 +6105,18 @@ v8_component("v8_libbase") {
+@@ -6092,6 +6111,18 @@ v8_component("v8_libbase") {
        "dl",
        "rt",
      ]