git: 066616dbf5bc - 2023Q1 - www/{*chromium,iridium}: restrict usage of preserve_most to clang 17

From: Robert Nagy <rnagy_at_FreeBSD.org>
Date: Wed, 15 Mar 2023 10:59:36 UTC
The branch 2023Q1 has been updated by rnagy:

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

commit 066616dbf5bcc072b0104ddf7f33863085e53e0a
Author:     Robert Nagy <rnagy@FreeBSD.org>
AuthorDate: 2023-03-15 07:55:45 +0000
Commit:     Robert Nagy <rnagy@FreeBSD.org>
CommitDate: 2023-03-15 10:59:30 +0000

    www/{*chromium,iridium}: restrict usage of preserve_most to clang 17
    
    the preserve_most attribute usage < clang 17 is causing weird runtime
    issues in v8 and this commit backports a v8 commit that disables the
    usage of this attribute with such compilers
    
    Approved by:    rene (mentor)
    Obtained from:  https://chromium.googlesource.com/v8/v8/+/ab12885a59d86d43a624ffaf6d56ca0d34e8e8bb
    
    (cherry picked from commit 23607969b871fab90e3f809183f6f9fcead30eda)
---
 www/chromium/Makefile                              |  1 +
 www/chromium/files/patch-v8_include_v8config.h     | 32 ++++++++++++++++------
 www/iridium/Makefile                               |  1 +
 www/iridium/files/patch-v8_include_v8config.h      | 32 ++++++++++++++++------
 www/ungoogled-chromium/Makefile                    |  1 +
 .../files/patch-v8_include_v8config.h              | 32 ++++++++++++++++------
 6 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/www/chromium/Makefile b/www/chromium/Makefile
index 471ca6e5a946..338776bd5b5a 100644
--- a/www/chromium/Makefile
+++ b/www/chromium/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	chromium
 PORTVERSION=	111.0.5563.64
+PORTREVISION=	1
 CATEGORIES=	www wayland
 MASTER_SITES=	https://commondatastorage.googleapis.com/chromium-browser-official/ \
 		https://nerd.hu/distfiles/:external
diff --git a/www/chromium/files/patch-v8_include_v8config.h b/www/chromium/files/patch-v8_include_v8config.h
index 1f906768877c..2731df78fdac 100644
--- a/www/chromium/files/patch-v8_include_v8config.h
+++ b/www/chromium/files/patch-v8_include_v8config.h
@@ -1,4 +1,4 @@
---- v8/include/v8config.h.orig	2022-04-21 18:48:31 UTC
+--- v8/include/v8config.h.orig	2023-03-15 07:46:50 UTC
 +++ v8/include/v8config.h
 @@ -183,6 +183,8 @@ path. Add it with -I<path> to the command line
    && !defined(V8_TARGET_OS_FUCHSIA) \
@@ -18,12 +18,10 @@
    || defined(V8_TARGET_OS_MACOS) \
    || defined(V8_TARGET_OS_WIN)
  #  error A target OS is defined but V8_HAVE_TARGET_OS is unset.
-@@ -214,6 +218,16 @@ path. Add it with -I<path> to the command line
- 
- #ifdef V8_OS_LINUX
+@@ -216,6 +220,16 @@ path. Add it with -I<path> to the command line
  # define V8_TARGET_OS_LINUX
-+#endif
-+
+ #endif
+ 
 +#ifdef V8_OS_OPENBSD
 +# define V8_TARGET_OS_OPENBSD
 +# define V8_TARGET_OS_BSD
@@ -32,6 +30,24 @@
 +#ifdef V8_OS_FREEBSD
 +# define V8_TARGET_OS_OPENBSD
 +# define V8_TARGET_OS_BSD
- #endif
- 
++#endif
++
  #ifdef V8_OS_MACOS
+ # define V8_TARGET_OS_MACOS
+ #endif
+@@ -351,10 +365,14 @@ path. Add it with -I<path> to the command line
+ // - component builds fail because _dl_runtime_resolve clobbers registers,
+ // - we see crashes on arm64 on Windows (https://crbug.com/1409934), which can
+ //   hopefully be fixed in the future.
++// Additionally, the initial implementation in clang <= 16 overwrote the return
++// register(s) in the epilogue of a preserve_most function, so we only use
++// preserve_most in clang >= 17 (see https://reviews.llvm.org/D143425).
+ #if (defined(_M_X64) || defined(__x86_64__)            /* x64 (everywhere) */  \
+      || ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */    \
+          && !defined(_WIN32)))                         /* not on windows */    \
+-     && !defined(COMPONENT_BUILD)                      /* no component build */
++     && !defined(COMPONENT_BUILD)                      /* no component build */\
++     && __clang_major__ >= 17                          /* clang >= 17 */
+ # define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most))
+ #endif
+ # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
diff --git a/www/iridium/Makefile b/www/iridium/Makefile
index bb409df57aff..3715619dfa56 100644
--- a/www/iridium/Makefile
+++ b/www/iridium/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	iridium
 PORTVERSION=	2023.03.111
+PORTREVISION=	1
 CATEGORIES=	www wayland
 MASTER_SITES=	https://downloads.iridiumbrowser.de/source/
 PKGNAMESUFFIX=	-browser
diff --git a/www/iridium/files/patch-v8_include_v8config.h b/www/iridium/files/patch-v8_include_v8config.h
index 1fbdf5604eab..2731df78fdac 100644
--- a/www/iridium/files/patch-v8_include_v8config.h
+++ b/www/iridium/files/patch-v8_include_v8config.h
@@ -1,4 +1,4 @@
---- v8/include/v8config.h.orig	2022-10-05 07:34:01 UTC
+--- v8/include/v8config.h.orig	2023-03-15 07:46:50 UTC
 +++ v8/include/v8config.h
 @@ -183,6 +183,8 @@ path. Add it with -I<path> to the command line
    && !defined(V8_TARGET_OS_FUCHSIA) \
@@ -18,12 +18,10 @@
    || defined(V8_TARGET_OS_MACOS) \
    || defined(V8_TARGET_OS_WIN)
  #  error A target OS is defined but V8_HAVE_TARGET_OS is unset.
-@@ -214,6 +218,16 @@ path. Add it with -I<path> to the command line
- 
- #ifdef V8_OS_LINUX
+@@ -216,6 +220,16 @@ path. Add it with -I<path> to the command line
  # define V8_TARGET_OS_LINUX
-+#endif
-+
+ #endif
+ 
 +#ifdef V8_OS_OPENBSD
 +# define V8_TARGET_OS_OPENBSD
 +# define V8_TARGET_OS_BSD
@@ -32,6 +30,24 @@
 +#ifdef V8_OS_FREEBSD
 +# define V8_TARGET_OS_OPENBSD
 +# define V8_TARGET_OS_BSD
- #endif
- 
++#endif
++
  #ifdef V8_OS_MACOS
+ # define V8_TARGET_OS_MACOS
+ #endif
+@@ -351,10 +365,14 @@ path. Add it with -I<path> to the command line
+ // - component builds fail because _dl_runtime_resolve clobbers registers,
+ // - we see crashes on arm64 on Windows (https://crbug.com/1409934), which can
+ //   hopefully be fixed in the future.
++// Additionally, the initial implementation in clang <= 16 overwrote the return
++// register(s) in the epilogue of a preserve_most function, so we only use
++// preserve_most in clang >= 17 (see https://reviews.llvm.org/D143425).
+ #if (defined(_M_X64) || defined(__x86_64__)            /* x64 (everywhere) */  \
+      || ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */    \
+          && !defined(_WIN32)))                         /* not on windows */    \
+-     && !defined(COMPONENT_BUILD)                      /* no component build */
++     && !defined(COMPONENT_BUILD)                      /* no component build */\
++     && __clang_major__ >= 17                          /* clang >= 17 */
+ # define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most))
+ #endif
+ # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
diff --git a/www/ungoogled-chromium/Makefile b/www/ungoogled-chromium/Makefile
index a31212f0f63b..c73557218838 100644
--- a/www/ungoogled-chromium/Makefile
+++ b/www/ungoogled-chromium/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	ungoogled-chromium
 PORTVERSION=	111.0.5563.64
+PORTREVISION=	1
 UGVERSION=	${DISTVERSION}-1
 CATEGORIES=	www wayland
 MASTER_SITES=	https://commondatastorage.googleapis.com/chromium-browser-official/ \
diff --git a/www/ungoogled-chromium/files/patch-v8_include_v8config.h b/www/ungoogled-chromium/files/patch-v8_include_v8config.h
index 2b0ab6a4089c..2731df78fdac 100644
--- a/www/ungoogled-chromium/files/patch-v8_include_v8config.h
+++ b/www/ungoogled-chromium/files/patch-v8_include_v8config.h
@@ -1,4 +1,4 @@
---- v8/include/v8config.h.orig	2022-10-01 07:40:07 UTC
+--- v8/include/v8config.h.orig	2023-03-15 07:46:50 UTC
 +++ v8/include/v8config.h
 @@ -183,6 +183,8 @@ path. Add it with -I<path> to the command line
    && !defined(V8_TARGET_OS_FUCHSIA) \
@@ -18,12 +18,10 @@
    || defined(V8_TARGET_OS_MACOS) \
    || defined(V8_TARGET_OS_WIN)
  #  error A target OS is defined but V8_HAVE_TARGET_OS is unset.
-@@ -214,6 +218,16 @@ path. Add it with -I<path> to the command line
- 
- #ifdef V8_OS_LINUX
+@@ -216,6 +220,16 @@ path. Add it with -I<path> to the command line
  # define V8_TARGET_OS_LINUX
-+#endif
-+
+ #endif
+ 
 +#ifdef V8_OS_OPENBSD
 +# define V8_TARGET_OS_OPENBSD
 +# define V8_TARGET_OS_BSD
@@ -32,6 +30,24 @@
 +#ifdef V8_OS_FREEBSD
 +# define V8_TARGET_OS_OPENBSD
 +# define V8_TARGET_OS_BSD
- #endif
- 
++#endif
++
  #ifdef V8_OS_MACOS
+ # define V8_TARGET_OS_MACOS
+ #endif
+@@ -351,10 +365,14 @@ path. Add it with -I<path> to the command line
+ // - component builds fail because _dl_runtime_resolve clobbers registers,
+ // - we see crashes on arm64 on Windows (https://crbug.com/1409934), which can
+ //   hopefully be fixed in the future.
++// Additionally, the initial implementation in clang <= 16 overwrote the return
++// register(s) in the epilogue of a preserve_most function, so we only use
++// preserve_most in clang >= 17 (see https://reviews.llvm.org/D143425).
+ #if (defined(_M_X64) || defined(__x86_64__)            /* x64 (everywhere) */  \
+      || ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */    \
+          && !defined(_WIN32)))                         /* not on windows */    \
+-     && !defined(COMPONENT_BUILD)                      /* no component build */
++     && !defined(COMPONENT_BUILD)                      /* no component build */\
++     && __clang_major__ >= 17                          /* clang >= 17 */
+ # define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most))
+ #endif
+ # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))