git: 169f8a47c955 - main - devel/mold: New port: A Modern Linker

From: Ashish SHUKLA <ashish_at_FreeBSD.org>
Date: Tue, 08 Feb 2022 19:20:07 UTC
The branch main has been updated by ashish:

URL: https://cgit.FreeBSD.org/ports/commit/?id=169f8a47c95518b2001f322c63ffaee2011292c0

commit 169f8a47c95518b2001f322c63ffaee2011292c0
Author:     Ashish SHUKLA <ashish@FreeBSD.org>
AuthorDate: 2022-02-08 17:30:54 +0000
Commit:     Ashish SHUKLA <ashish@FreeBSD.org>
CommitDate: 2022-02-08 19:19:34 +0000

    devel/mold: New port: A Modern Linker
    
    mold is a faster drop-in replacement for existing Unix linkers. It
    is several times faster than LLVM lld linker, the second-fastest
    open-source linker which I originally created a few years ago.
    mold is created for increasing developer productivity by reducing
    build time especially in rapid debug-edit-rebuild cycles.
    
    WWW: https://github.com/rui314/mold
---
 devel/Makefile                  |  1 +
 devel/mold/Makefile             | 39 +++++++++++++++++++++++++++++++++++++++
 devel/mold/distinfo             |  3 +++
 devel/mold/files/patch-Makefile | 28 ++++++++++++++++++++++++++++
 devel/mold/pkg-descr            |  7 +++++++
 5 files changed, 78 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index 066ea28b57b3..70da30fcc9de 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -1582,6 +1582,7 @@
     SUBDIR += mm
     SUBDIR += mm-common
     SUBDIR += modd
+    SUBDIR += mold
     SUBDIR += mongo-c-driver
     SUBDIR += mono-addins
     SUBDIR += monotone
diff --git a/devel/mold/Makefile b/devel/mold/Makefile
new file mode 100644
index 000000000000..c74543a046bc
--- /dev/null
+++ b/devel/mold/Makefile
@@ -0,0 +1,39 @@
+PORTNAME=	mold
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.0.3
+CATEGORIES=	devel
+
+MAINTAINER=	ashish@FreeBSD.org
+COMMENT=	Modern Linker
+
+LICENSE=	AGPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+NOT_FOR_ARCHS=	armhf armv7 i386
+
+LIB_DEPENDS=	libtbb.so:devel/onetbb \
+		libmimalloc.so:devel/mimalloc
+
+USES=		gmake ssl
+MAKE_ENV+=	SYSTEM_TBB=1
+MAKE_ENV+=	SYSTEM_MIMALLOC=1
+MAKE_ENV+=	STRIP_CMD=${STRIP_CMD}
+CXXFLAGS+=	-I${LOCALBASE}/include
+LDFLAGS+=	-L${LOCALBASE}/lib
+MAKE_FLAGS+=	"CXXFLAGS=${CXXFLAGS}"
+MAKE_FLAGS+=	"LDFLAGS=${LDFLAGS}"
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	rui314
+PLIST_FILES=	bin/ld.mold \
+		bin/ld64.mold \
+		bin/mold \
+		lib/mold/mold-wrapper.so \
+		libexec/mold/ld \
+		share/man/man1/mold.1.gz
+
+post-patch:
+	${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX},' \
+		${WRKSRC}/Makefile
+
+.include <bsd.port.mk>
diff --git a/devel/mold/distinfo b/devel/mold/distinfo
new file mode 100644
index 000000000000..b435216c3d8b
--- /dev/null
+++ b/devel/mold/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1644335355
+SHA256 (rui314-mold-v1.0.3_GH0.tar.gz) = 488c12058b4c7c77bff94c6f919e40b2f12c304214e2e0d7d4833c21167837c0
+SIZE (rui314-mold-v1.0.3_GH0.tar.gz) = 4501162
diff --git a/devel/mold/files/patch-Makefile b/devel/mold/files/patch-Makefile
new file mode 100644
index 000000000000..dbe3a8d94b87
--- /dev/null
+++ b/devel/mold/files/patch-Makefile
@@ -0,0 +1,28 @@
+--- Makefile.orig	2022-02-08 16:00:48 UTC
++++ Makefile
+@@ -1,4 +1,4 @@
+-PREFIX = /usr/local
++PREFIX = %%PREFIX%%
+ BINDIR = $(PREFIX)/bin
+ LIBDIR = $(PREFIX)/lib
+ LIBEXECDIR = $(PREFIX)/libexec
+@@ -18,7 +18,7 @@ endif
+ 
+ # If you want to keep symbols in the installed binary, run make with
+ # `STRIP=true` to run /bin/true instead of the strip command.
+-STRIP = strip
++STRIP = $(STRIP_CMD)
+ 
+ SRCS=$(wildcard *.cc elf/*.cc macho/*.cc)
+ HEADERS=$(wildcard *.h elf/*.h macho/*.h)
+@@ -99,8 +99,8 @@ endif
+ 
+ # Use pkg-config to know where libcrypto resides.
+ ifneq ($(OS), Darwin)
+-  MOLD_CXXFLAGS += $(shell pkg-config --cflags-only-I openssl)
+-  MOLD_LDFLAGS += $(shell pkg-config --libs-only-L openssl) -lcrypto
++  MOLD_CXXFLAGS += -I${OPENSSLINC}
++  MOLD_LDFLAGS += -L${OPENSSLLIB} -lcrypto
+ endif
+ 
+ # '-latomic' flag is needed building on riscv64 system
diff --git a/devel/mold/pkg-descr b/devel/mold/pkg-descr
new file mode 100644
index 000000000000..2fe2c051957c
--- /dev/null
+++ b/devel/mold/pkg-descr
@@ -0,0 +1,7 @@
+mold is a faster drop-in replacement for existing Unix linkers. It
+is several times faster than LLVM lld linker, the second-fastest
+open-source linker which I originally created a few years ago.
+mold is created for increasing developer productivity by reducing
+build time especially in rapid debug-edit-rebuild cycles.
+
+WWW: https://github.com/rui314/mold