NetBSD Problem Report #58427

From www@netbsd.org  Sun Jul 14 03:51:27 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3672D1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 14 Jul 2024 03:51:27 +0000 (UTC)
Message-Id: <20240714035125.D08021A923A@mollari.NetBSD.org>
Date: Sun, 14 Jul 2024 03:51:25 +0000 (UTC)
From: jonthn++pkgsrc@pinacea.com
Reply-To: jonthn++pkgsrc@pinacea.com
To: gnats-bugs@NetBSD.org
Subject: improve Lua module lpeg on Darwin (macOS)
X-Send-Pr-Version: www-1.0

>Number:         58427
>Category:       pkg
>Synopsis:       improve Lua module lpeg on Darwin (macOS)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 14 03:55:00 +0000 2024
>Originator:     jonathan buschmann
>Release:        
>Organization:
>Environment:
>Description:
Currently the module `lpeg` for macOS is built as a _bundle_ and this limits its usage to only be loaded within Lua interpreter. And forbids another library to link with it directly.

AFAIK building a dynamiclib works correctly on both Lua interpreter and for usage as a shared lib to link against.

For a _correct_ library on macOS its install_name is a key element so I only fix this part of the build it would be beneficial maybe to also create the ELF shared library name but not sure if it's requested/wished so I did not do this part.

See the patch below (it's mostly important for latest Neovim 0.10 see editors/neovim to work correctly)
>How-To-Repeat:

>Fix:
commit 303b3bdbaa6fb755f0c83ca9f41224701d37a8b6
Author: jonathan 'jonthn' buschmann <jonthn++pkgsrc@pinacea.com>
Date:   Sun Jul 14 10:08:05 2024 +0800

diff --git a/devel/lua-lpeg/Makefile b/devel/lua-lpeg/Makefile
index a45a8c1f596b..fbb3d9cb30ab 100644
--- a/devel/lua-lpeg/Makefile
+++ b/devel/lua-lpeg/Makefile
@@ -15,6 +15,10 @@ USE_TOOLS+=	gmake
 MAKE_FILE=	makefile
 TEST_TARGET=	test

+LUA_LINKER_MAGIC=       no
+
+MAKE_ENV+=	PATH_MODULE_LUA=${PREFIX:Q}/${LUA_CDIR}
+
 BUILD_TARGET.Darwin=	macosx
 BUILD_TARGET.*=		linux

diff --git a/devel/lua-lpeg/distinfo b/devel/lua-lpeg/distinfo
index cb9085b0e61d..e41dd6ad1007 100644
--- a/devel/lua-lpeg/distinfo
+++ b/devel/lua-lpeg/distinfo
@@ -3,4 +3,4 @@ $NetBSD: distinfo,v 1.12 2023/07/05 22:03:44 wiz Exp $
 BLAKE2s (lpeg-1.1.0.tar.gz) = d3681bbc523cb81bc921bb22ce5a4ccaae8ce593916ba17b573b788b05651e75
 SHA512 (lpeg-1.1.0.tar.gz) = 01b2a4ceb2d110e143603bc63c84a59736ea735dd0ed9866286ba115d41be48d09c9ff21c8e2327974d2296944f6508d50a5c3a18f26ac1d81b8b2fc41f61222
 Size (lpeg-1.1.0.tar.gz) = 78042 bytes
-SHA1 (patch-makefile) = e229f3278a5dde00a4ef6736459caca4deeacea6
+SHA1 (patch-makefile) = 5decdd02d1516a1ab5bb4cdcd853ea96320ebd53
diff --git a/devel/lua-lpeg/patches/patch-makefile b/devel/lua-lpeg/patches/patch-makefile
index 23ef0109fb5a..67e43329d302 100644
--- a/devel/lua-lpeg/patches/patch-makefile
+++ b/devel/lua-lpeg/patches/patch-makefile
@@ -1,11 +1,16 @@
 $NetBSD: patch-makefile,v 1.2 2019/03/25 22:55:18 wiz Exp $

-Honor LDFLAGS for RELRO builds.
+- Honor LDFLAGS for RELRO builds.
+- Darwin changed from Bundle to Dynamic Library

---- makefile.orig	2019-03-11 14:08:29.000000000 +0000
-+++ makefile
-@@ -36,7 +36,7 @@ macosx:
- 	$(MAKE) lpeg.so "DLLFLAGS = -bundle -undefined dynamic_lookup"
+--- makefile	2023-06-27 00:30:55
++++ makefile	2024-07-14 11:26:33
+@@ -36,10 +36,10 @@
+ 
+ # For Mac OS
+ macosx:
+-	$(MAKE) lpeg.so "DLLFLAGS = -bundle -undefined dynamic_lookup"
++	$(MAKE) lpeg.so "DLLFLAGS = -shared -undefined dynamic_lookup -compatibility_version 1.0.0 -current_version 1.1.0 -install_name $(PATH_MODULE_LUA)/lpeg.so"

  lpeg.so: $(FILES)
 -	env $(CC) $(DLLFLAGS) $(FILES) -o lpeg.so

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.