Cc: Maintainer

On 7/31/23 14:28, Christian Weisgerber wrote:
I managed to run a full bulk build on my T14 G3 with IBT.  Kudos
to Lenovo for engineering a laptop that can build for days on end
without melting down.

The following ports fail to build:

devel/ocaml-menhir              # OCaml
sysutils/opam                   # OCaml
x11/lablgtk3                    # OCaml

I included an uncommitted USE_NOBTICF fix for sysutils/findlib, but
there seems to remain another problem with some OCaml ports.

With the attached patch, I get a lang/ocaml that builds ocaml-menhir and
lablgtk3 successfully on my IBT enabled amd64 machine.

For sysutils/opam it should already be sufficient to use

MODULES+=lang/ocaml

for it to pick up NOBTCFI. However I tested with a slightly tweaked diff for opam 2.1.5 by chrisz@, so I'm attaching that for reference, too.

NB: I also applied naddy@'s findlib patch in my tests.
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/opam/Makefile,v
retrieving revision 1.25
diff -u -p -r1.25 Makefile
--- Makefile	16 Jan 2023 19:03:18 -0000	1.25
+++ Makefile	8 Aug 2023 19:43:09 -0000
@@ -2,7 +2,7 @@ COMMENT =		OCaml source-based package ma
 
 CATEGORIES =		sysutils devel
 
-V =			2.0.10
+V =			2.1.5
 PKGNAME =		opam-${V}
 DISTNAME =		opam-full-${V}
 
@@ -15,14 +15,11 @@ MAINTAINER =		Christopher Zimmermann <ch
 # LGPLv3
 PERMIT_PACKAGE =	Yes
 
+MODULES=		lang/ocaml
+
 WANTLIB =		${COMPILER_LIBCXX} c m
 
-BUILD_DEPENDS =		lang/ocaml \
-			sysutils/findlib \
-			devel/dune \
-			devel/ocaml-cppo \
-			archivers/bzip2 \
-			net/curl
+BUILD_DEPENDS =		archivers/bzip2
 
 RUN_DEPENDS =		archivers/unzip \
 			archivers/bzip2 \
@@ -31,11 +28,16 @@ RUN_DEPENDS =		archivers/unzip \
 			devel/gmake \
 			net/curl
 
+TEST_DEPENDS =		textproc/gdiff \
+			net/wget
+
 USE_GMAKE =		Yes
 
 CONFIGURE_ENV +=	CFLAGS="${CFLAGS}" \
 			LDFLAGS="${LDFLAGS}"
-CONFIGURE_STYLE =	gnu
+CONFIGURE_STYLE =	gnu autoreconf no-autoheader
+AUTOCONF_VERSION =	2.69
+AUTOMAKE_VERSION =	1.16
 
 ALL_TARGET =		lib-ext all
 INSTALL_TARGET =	install
@@ -51,5 +53,8 @@ post-install:
 		${docdir}/
 	${INSTALL_DATA_DIR} ${docdir}/pages
 	${INSTALL_DATA} ${WRKSRC}/doc/pages/*.md ${docdir}/pages
+
+pre-test:
+	ln -fs ${LOCALBASE}/bin/gdiff ${WRKDIR}/bin/diff
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/sysutils/opam/distinfo,v
retrieving revision 1.9
diff -u -p -r1.9 distinfo
--- distinfo	16 Jan 2023 19:03:18 -0000	1.9
+++ distinfo	8 Aug 2023 19:43:09 -0000
@@ -1,2 +1,2 @@
-SHA256 (opam-full-2.0.10.tar.gz) = O1dAuOHBvGXc+KohxOjNgc1qv+G/UuosxDZ8P4nVvkA=
-SIZE (opam-full-2.0.10.tar.gz) = 8173617
+SHA256 (opam-full-2.1.5.tar.gz) = CfjZ5BCy9XI8K/7b95cOOzBfUBeJX82RdZ8F51PdzqU=
+SIZE (opam-full-2.1.5.tar.gz) = 10801367
Index: patches/patch-Makefile_config_in
===================================================================
RCS file: patches/patch-Makefile_config_in
diff -N patches/patch-Makefile_config_in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-Makefile_config_in	8 Aug 2023 19:43:09 -0000
@@ -0,0 +1,13 @@
+don't use system wide installed ocaml packages
+
+Index: Makefile.config.in
+--- Makefile.config.in.orig
++++ Makefile.config.in
+@@ -17,7 +17,6 @@ OCAMLFIND = @OCAMLFIND@
+ OCAML = @OCAML@
+ OCAMLC = @OCAMLC@
+ OCAMLOPT = @OCAMLOPT@
+-DUNE = @DUNE@
+ DUNE_SECONDARY = @DUNE_SECONDARY@
+ LN_S = @LN_S@
+ 
Index: patches/patch-configure_ac
===================================================================
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure_ac	8 Aug 2023 19:43:09 -0000
@@ -0,0 +1,14 @@
+don't use system wide installed ocaml packages
+
+Index: configure.ac
+--- configure.ac.orig
++++ configure.ac
+@@ -255,8 +255,6 @@ AS_IF([test "x${enable_certificate_check}" = "xno"], [
+ 
+ AC_CHECK_PROGS(FETCH,[curl wget],no)
+ 
+-AC_CHECK_TOOL(DUNE,dune)
+-AC_CHECK_TOOL(CPPO,cppo)
+ AC_CHECK_TOOL(PATCH,patch)
+ AC_CHECK_TOOL(BUNZIP2,bunzip2)
+ 
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/sysutils/opam/pkg/PLIST,v
retrieving revision 1.3
diff -u -p -r1.3 PLIST
--- pkg/PLIST	11 Mar 2022 19:57:44 -0000	1.3
+++ pkg/PLIST	8 Aug 2023 19:43:09 -0000
@@ -24,6 +24,8 @@
 @man man/man1/opam-installer.1
 @man man/man1/opam-lint.1
 @man man/man1/opam-list.1
+@man man/man1/opam-lock.1
+@man man/man1/opam-option.1
 @man man/man1/opam-pin.1
 @man man/man1/opam-reinstall.1
 @man man/man1/opam-remote.1
@@ -46,6 +48,7 @@ share/doc/opam/depexts-plugins
 share/doc/opam/depopts-and-features
 share/doc/opam/pages/
 share/doc/opam/pages/About.md
+share/doc/opam/pages/Distribution.md
 share/doc/opam/pages/External_solvers.md
 share/doc/opam/pages/FAQ.md
 share/doc/opam/pages/Install.md
Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/ocaml/Makefile,v
retrieving revision 1.97
diff -u -p -r1.97 Makefile
--- Makefile	24 Jul 2023 12:16:05 -0000	1.97
+++ Makefile	8 Aug 2023 19:47:59 -0000
@@ -3,7 +3,7 @@ COMMENT =	   ML language with complete c
 # XXX Don't even think of updating ocaml alone.
 # Do check that the ports that depend on it still work, or repair them.
 VERSION=	4.12.1
-REVISION=	3
+REVISION=	4
 
 # if the ocaml compiler gains support for BTI, as well as
 # removing USE_NOBTCFI here (or changing to an arch-dependent
@@ -50,12 +50,15 @@ LDFLAGS +=	-L${LOCALBASE}/lib
 LDFLAGS+=		-Wl,-z,notext
 .endif
 
-USE_GMAKE=	Yes
+# We need to pass nobtcfi in LDFLAGS so that ocamlopt
+# will pick it up when building OCaml native binaries
+.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "arm64"
+LDFLAGS+=		-Wl,-z,nobtcfi
+.endif
 
-WANTLIB =		c iberty m pthread z
+USE_GMAKE=	Yes
 
-# for libbfd (used by ocamlobjinfo on .cmxs files)
-BUILD_DEPENDS +=	devel/gdb
+WANTLIB =		c m pthread
 
 .if ${PROPERTIES:Mocaml_native}
 ALL_TARGET=	world.opt
Index: patches/patch-Makefile_config_in
===================================================================
RCS file: patches/patch-Makefile_config_in
diff -N patches/patch-Makefile_config_in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-Makefile_config_in	8 Aug 2023 19:47:59 -0000
@@ -0,0 +1,28 @@
+Respect LDFLAGS, see upstream PR
+https://github.com/ocaml/ocaml/pull/10091
+
+Index: Makefile.config.in
+--- Makefile.config.in.orig
++++ Makefile.config.in
+@@ -76,6 +76,8 @@ AS_HAS_DEBUG_PREFIX_MAP=@as_has_debug_prefix_map@
+ # our own symbols):
+ OC_LDFLAGS=@oc_ldflags@
+ 
++LDFLAGS?=@LDFLAGS@
++
+ ### How to invoke the C preprocessor through the C compiler
+ CPP=@CPP@
+ 
+@@ -249,9 +251,10 @@ ifeq "$(TOOLCHAIN)" "msvc"
+           || mt -nologo -outputresource:$(1) -manifest $(1).manifest \
+           && rm -f $(1).manifest
+   MKEXE_BOOT=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OUTPUTEXE)$(1) $(2) \
+-    /link /subsystem:console $(OC_LDFLAGS) && ($(MERGEMANIFESTEXE))
++    /link /subsystem:console $(OC_LDFLAGS) $(LDFLAGS) && ($(MERGEMANIFESTEXE))
+ else
+-  MKEXE_BOOT=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_LDFLAGS) $(OUTPUTEXE)$(1) $(2)
++  MKEXE_BOOT=$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_LDFLAGS) $(LDFLAGS) \
++    $(OUTPUTEXE)$(1) $(2)
+ endif # ifeq "$(TOOLCHAIN)" "msvc"
+ 
+ # The following variables were defined only in the Windows-specific makefiles.
Index: patches/patch-configure_ac
===================================================================
RCS file: /cvs/ports/lang/ocaml/patches/patch-configure_ac,v
retrieving revision 1.12
diff -u -p -r1.12 patch-configure_ac
--- patches/patch-configure_ac	7 Nov 2022 16:33:55 -0000	1.12
+++ patches/patch-configure_ac	8 Aug 2023 19:47:59 -0000
@@ -1,6 +1,18 @@
+Respect LDFLAGS, see upstream PR
+https://github.com/ocaml/ocaml/pull/10091
+
 Index: configure.ac
 --- configure.ac.orig
 +++ configure.ac
+@@ -41,7 +41,7 @@ libraries_man_section=3
+ # ($OC_CFLAGS and $CFLAGS), but at the moment they are not taken into
+ # account on Windows, because flexlink, which is used to build
+ # executables on this platform, can not handle them.
+-mkexe="\$(CC) \$(OC_CFLAGS) \$(CFLAGS) \$(OC_LDFLAGS)"
++mkexe="\$(CC) \$(OC_CFLAGS) \$(CFLAGS) \$(OC_LDFLAGS) \$(LDFLAGS)"
+ 
+ # Flags for building executable files with debugging symbols
+ mkexedebugflag="-g"
 @@ -735,6 +735,11 @@ AS_CASE([$CC,$host],
  )
  
@@ -13,20 +25,22 @@ Index: configure.ac
  ## Program to use to install files
  AC_PROG_INSTALL
  
-@@ -867,10 +872,10 @@ AS_IF([test x"$enable_shared" != "xno"],
+@@ -867,10 +872,11 @@ AS_IF([test x"$enable_shared" != "xno"],
      [[*-*-linux*|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*\
      |*-*-openbsd*|*-*-netbsd*|*-*-dragonfly*|*-*-gnu*|*-*-haiku*]],
        [sharedlib_cflags="-fPIC"
-+      oc_ldflags="$oc_ldflags -Wl,-E"
-        AS_CASE([$CC,$host],
-            [gcc*,powerpc-*-linux*], [mksharedlib="$CC -shared -mbss-plt"],
+-       AS_CASE([$CC,$host],
+-           [gcc*,powerpc-*-linux*], [mksharedlib="$CC -shared -mbss-plt"],
 -           [mksharedlib="$CC -shared"])
--      oc_ldflags="$oc_ldflags -Wl,-E"
-+           [mksharedlib="$CC -shared $oc_ldflags"])
+       oc_ldflags="$oc_ldflags -Wl,-E"
++       AS_CASE([$CC,$host],
++           [gcc*,powerpc-*-linux*], 
++           [mksharedlib="$CC -shared -mbss-plt \$(LDFLAGS)"],
++           [mksharedlib="$CC -shared $oc_ldflags \$(LDFLAGS)"])
        rpath="-Wl,-rpath,"
        mksharedlibrpath="-Wl,-rpath,"
        natdynlinkopts="-Wl,-E"
-@@ -912,6 +917,7 @@ AS_IF([test x"$enable_shared" != "xno"],
+@@ -912,6 +918,7 @@ AS_IF([test x"$enable_shared" != "xno"],
      [earm*-*-netbsd*], [natdynlink=true],
      [aarch64-*-linux*], [natdynlink=true],
      [aarch64-*-freebsd*], [natdynlink=true],
@@ -34,7 +48,7 @@ Index: configure.ac
      [riscv*-*-linux*], [natdynlink=true])])
  
  # Try to work around the Skylake/Kaby Lake processor bug.
-@@ -1013,6 +1019,8 @@ AS_CASE([$host],
+@@ -1013,6 +1020,8 @@ AS_CASE([$host],
      [arch=arm64; system=linux],
    [aarch64-*-freebsd*],
      [arch=arm64; system=freebsd],

Reply via email to