git: 31821073e950 - main - cad/nvc: fix build on powerpc*

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Wed, 10 Aug 2022 17:22:11 UTC
The branch main has been updated by pkubaj:

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

commit 31821073e95009cdfd29e7c1dbeb3c1132d00421
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2022-08-10 16:54:59 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2022-08-10 17:20:22 +0000

    cad/nvc: fix build on powerpc*
    
    1. Add machine context for powerpc*.
    2. Disable LTO on powerpc64.
---
 cad/nvc/Makefile                          |  6 ++++++
 cad/nvc/files/patch-thirdparty_cpustate.c | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/cad/nvc/Makefile b/cad/nvc/Makefile
index 586bb2a20971..614134eb577c 100644
--- a/cad/nvc/Makefile
+++ b/cad/nvc/Makefile
@@ -45,6 +45,12 @@ CONFIGURE_WRKSRC=	${BUILD_DIR}
 INSTALL_WRKSRC=		${BUILD_DIR}
 CONFIGURE_CMD=		${WRKSRC}/configure
 
+.include <bsd.port.options.mk>
+
+.if ${ARCH} == powerpc64
+CONFIGURE_ARGS+=	--enable-lto=no
+.endif
+
 post-install:
 	@${FIND} ${STAGEDIR}${PREFIX} -name "*.so" | ${XARGS} ${STRIP_CMD}
 
diff --git a/cad/nvc/files/patch-thirdparty_cpustate.c b/cad/nvc/files/patch-thirdparty_cpustate.c
new file mode 100644
index 000000000000..074770c7d712
--- /dev/null
+++ b/cad/nvc/files/patch-thirdparty_cpustate.c
@@ -0,0 +1,16 @@
+--- thirdparty/cpustate.c.orig	2022-08-10 16:48:11 UTC
++++ thirdparty/cpustate.c
+@@ -103,6 +103,13 @@ void fill_cpu_state(struct cpu_state *cpu, ucontext_t 
+ 
+    for (int i = 0; i < 16; i++)
+       cpu->regs[i] = uc->uc_mcontext._gregs[i];
++
++#elif defined __FreeBSD__ && defined __powerpc__
++   cpu->pc = uc->uc_mcontext.mc_srr0;
++   cpu->sp = uc->uc_mcontext.mc_gpr[1];
++
++   for (int i = 0; i < 31; i++)
++      cpu->regs[i] = uc->uc_mcontext.mc_gpr[i];
+ #elif defined __OpenBSD__ && defined __x86_64__
+    cpu->pc = uc->sc_rip;
+    cpu->sp = uc->sc_rsp;