git: 9cdeb88eac13 - main - devel/electron12: fix build

From: Koichiro Iwao <meta_at_FreeBSD.org>
Date: Wed, 06 Oct 2021 12:12:18 UTC
The branch main has been updated by meta:

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

commit 9cdeb88eac13fab9aed2f3972cef30d229890bde
Author:     Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
AuthorDate: 2021-10-06 08:52:26 +0000
Commit:     Koichiro Iwao <meta@FreeBSD.org>
CommitDate: 2021-10-06 12:11:29 +0000

    devel/electron12: fix build
    
    In file included from ../../third_party/nasm/asm/assemble.c:178:
    ../../third_party/nasm/include/compiler.h:249:21: error: static declaration of 'mempcpy' follows non-static declaration
    static inline void *mempcpy(void *dst, const void *src, size_t n)
                        ^
    /usr/include/string.h:70:7: note: previous declaration is here
    void    *mempcpy(void * __restrict, const void * __restrict, size_t);
             ^
    
    PR:             257378
    Reported by:    Robert Cina <transitive@gmail.com>
    Tested by:      meta
    Approved by:    maintainer timeout (> 2 weeks)
    MFH:            2021Q4
---
 devel/electron12/Makefile                                     |  6 ++++++
 devel/electron12/files/extra-patch-no-mempcpy-nasm            | 11 +++++++++++
 .../files/patch-third__party_nasm_config_config-linux.h       |  9 ---------
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/devel/electron12/Makefile b/devel/electron12/Makefile
index 68c14d7abd54..05431df0af4f 100644
--- a/devel/electron12/Makefile
+++ b/devel/electron12/Makefile
@@ -152,6 +152,12 @@ GN_BOOTSTRAP_FLAGS=	--no-clean --no-rebuild --skip-generate-buildfiles
 .include "Makefile.version"
 .include <bsd.port.pre.mk>
 
+# Add extra-patch-no-mempcpy-nasm only when there's no mempcpy() in base.
+# Nested variable expansion avoids executing the test when not needed for
+# expanding EXTRA_PATCHES.
+EXTRA_PATCHES+=	${"${:!${GREP} mempcpy ${CROSS_SYSROOT}/usr/include/string.h \
+	|| ${TRUE}!}" == "":?${PATCHDIR}/extra-patch-no-mempcpy-nasm:}
+
 .if ${ARCH} == "amd64"
 PLIST_SUB+=	AMD64=""
 .else
diff --git a/devel/electron12/files/extra-patch-no-mempcpy-nasm b/devel/electron12/files/extra-patch-no-mempcpy-nasm
new file mode 100644
index 000000000000..d1ccea1bcd80
--- /dev/null
+++ b/devel/electron12/files/extra-patch-no-mempcpy-nasm
@@ -0,0 +1,11 @@
+--- third_party/nasm/config/config-linux.h.orig	2021-01-07 00:39:33 UTC
++++ third_party/nasm/config/config-linux.h
+@@ -336,7 +336,7 @@
+ #define HAVE_MEMORY_H 1
+ 
+ /* Define to 1 if you have the `mempcpy' function. */
+-#define HAVE_MEMPCPY 1
++/* #undef HAVE_MEMPCPY */
+ 
+ /* Define to 1 if you have a working `mmap' system call. */
+ #define HAVE_MMAP 1
diff --git a/devel/electron12/files/patch-third__party_nasm_config_config-linux.h b/devel/electron12/files/patch-third__party_nasm_config_config-linux.h
index 7c3e51e706d3..f005f98b1248 100644
--- a/devel/electron12/files/patch-third__party_nasm_config_config-linux.h
+++ b/devel/electron12/files/patch-third__party_nasm_config_config-linux.h
@@ -18,15 +18,6 @@
  
  /* Define to 1 if you have the `faccessat' function. */
  #define HAVE_FACCESSAT 1
-@@ -336,7 +336,7 @@
- #define HAVE_MEMORY_H 1
- 
- /* Define to 1 if you have the `mempcpy' function. */
--#define HAVE_MEMPCPY 1
-+/* #undef HAVE_MEMPCPY */
- 
- /* Define to 1 if you have a working `mmap' system call. */
- #define HAVE_MMAP 1
 @@ -411,7 +411,7 @@
  #define HAVE_SYSCONF 1