git: 84ef6c1c6125 - main - devel/ocaml-opam: Fix build on armv7.

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sat, 10 Feb 2024 13:48:12 UTC
The branch main has been updated by fuz:

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

commit 84ef6c1c612525c29dd4c271ea4e91c2d54074af
Author:     Benjamin Jacobs <freebsd@dev.thsi.be>
AuthorDate: 2024-02-07 18:10:46 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2024-02-10 13:42:26 +0000

    devel/ocaml-opam: Fix build on armv7.
    
    The LLVM assembler chokes on the assembly generated by the ARM32
    backend of OCAML. Fixed by forcing binutils on ARM32.
    
    The OCaml compiler generates text relocations on all of its supported
    32 bits architectures, however the configure script only sets the -z
    notext linker flag in the x86 case. This change makes sure that this
    flag is used for the other architectures by setting LDFLAGS in the
    environment of the configure script.
    
    This commit may fix armv6 and powerpc as well, but this hasn't been
    verified.
    
    PR:             261180
    MFH:            2024Q1
    Reported by:    fuz
    Approved by:    hannes@mehnert.org (maintainer)
---
 devel/ocaml-opam/Makefile | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/devel/ocaml-opam/Makefile b/devel/ocaml-opam/Makefile
index d7e060451647..e8274f7019dd 100644
--- a/devel/ocaml-opam/Makefile
+++ b/devel/ocaml-opam/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	opam
 DISTVERSION=	2.1.5
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 MASTER_SITES=	https://github.com/ocaml/opam/releases/download/${DISTVERSION}/
 PKGNAMEPREFIX=	ocaml-
@@ -12,13 +12,17 @@ WWW=		https://opam.ocaml.org/
 
 LICENSE=	LGPL21
 
-BROKEN_armv6=	ld: error: can't create dynamic relocation R_ARM_ABS32 against symbol: caml_program in readonly segment
-BROKEN_armv7=	ld: error: can't create dynamic relocation R_ARM_ABS32 against symbol: caml_program in readonly segment
-
 RUN_DEPENDS=	curl:ftp/curl \
-		gpatch:devel/patch
+		gpatch:devel/patch \
+		${RUN_DEPENDS_${ARCH}}
+RUN_DEPENDS_armv6=	${LOCALBASE}/bin/as:devel/binutils
+RUN_DEPENDS_armv7=	${LOCALBASE}/bin/as:devel/binutils
 
 USES=		gmake
+ARCH!=		uname -p
+.if ${ARCH} == armv6 || ${ARCH} == armv7
+USE_BINUTILS=	yes
+.endif
 
 GNU_CONFIGURE=	yes
 CONFIGURE_ARGS=	--disable-checks
@@ -26,6 +30,13 @@ CONFIGURE_ARGS=	--disable-checks
 MAKE_JOBS_UNSAFE=	yes
 ALL_TARGET=	cold-lib-ext cold-all
 
+LDFLAGS_armv6=	-Wl,-z,notext
+LDFLAGS_armv7=	-Wl,-z,notext
+LDFLAGS_powerpc=	-Wl,-z,notext
+LDFLAGS+=	${LDFLAGS_${ARCH}}
+
+NOPRECIOUSMAKEVARS=	yes
+
 OPTIONS_DEFINE=		DARCS GIT MERCURIAL RSYNC
 OPTIONS_DEFAULT=	GIT RSYNC
 NO_OPTIONS_SORT=	yes
@@ -37,10 +48,8 @@ GIT_RUN_DEPENDS=	git:devel/git
 MERCURIAL_RUN_DEPENDS=	${PY_MERCURIAL}
 RSYNC_RUN_DEPENDS=	rsync:net/rsync
 
-NOPRECIOUSMAKEVARS=	yes
-
 pre-configure:
-	cd ${WRKSRC} && ${MAKE_CMD} compiler
+	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} compiler)
 
 post-install:
 	@${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/opam-installer