From e4b78268b76e3fd9cc40b80e32d80e78cd97d050 Mon Sep 17 00:00:00 2001 From: Artur Sinila Date: Tue, 29 Jun 2021 03:31:54 +0300 Subject: [PATCH] New package: mold-0.1.1 --- srcpkgs/mold/patches/00-makefile.patch | 74 ++++++++++++++++++++++++++ srcpkgs/mold/template | 36 +++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 srcpkgs/mold/patches/00-makefile.patch create mode 100644 srcpkgs/mold/template diff --git a/srcpkgs/mold/patches/00-makefile.patch b/srcpkgs/mold/patches/00-makefile.patch new file mode 100644 index 000000000000..116b4b9d95c4 --- /dev/null +++ b/srcpkgs/mold/patches/00-makefile.patch @@ -0,0 +1,74 @@ +--- b/Makefile ++++ a/Makefile +@@ -1,7 +1,7 @@ CC = clang + CXX = clang++ + + MIMALLOC_LIB = mimalloc/out/release/libmimalloc.a +-GIT_HASH = $(shell [ -d .git ] && git rev-parse HEAD) ++GIT_HASH ?= $(shell [ -d .git ] && git rev-parse HEAD) + + CPPFLAGS = -g -Imimalloc/include -pthread -std=c++20 \ + -Wno-deprecated-volatile \ +@@ -9,7 +9,7 @@ CPPFLAGS = -g -Imimalloc/include -pthread -std=c++20 \ + -DMOLD_VERSION=\"0.1.1\" \ + -DGIT_HASH=\"$(GIT_HASH)\" \ + $(EXTRA_CPPFLAGS) +-LDFLAGS = $(EXTRA_LDFLAGS) ++LDFLAGS += $(EXTRA_LDFLAGS) + LIBS = -Wl,-as-needed -lcrypto -pthread -ltbb -lz -lxxhash -ldl + OBJS = main.o object_file.o input_sections.o output_chunks.o \ + mapfile.o perf.o linker_script.o archive_file.o output_file.o \ +@@ -40,7 +40,11 @@ else + # By default, we want to use mimalloc as a memory allocator. + # Since replacing the standard malloc is not compatible with ASAN, + # we do that only when ASAN is not enabled. +- LDFLAGS += -Wl,-whole-archive $(MIMALLOC_LIB) -Wl,-no-whole-archive ++ ifndef SYSTEM_MIMALLOC ++ LIBS += -Wl,-whole-archive $(MIMALLOC_LIB) -Wl,-no-whole-archive ++ else ++ LIBS += -lmimalloc ++ endif + endif + + ifeq ($(TSAN), 1) +@@ -50,7 +54,7 @@ endif + + all: mold mold-wrapper.so + +-mold: $(OBJS) $(MIMALLOC_LIB) +- $(CXX) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS) $(LIBS) ++mold: $(OBJS) ++ $(CXX) $(CXXFLAGS) $(OBJS) -o $@ $(LDFLAGS) $(LIBS) + + mold-wrapper.so: mold-wrapper.c Makefile +@@ -71,20 +75,21 @@ test tests check: all + for i in test/*.sh; do $$i || exit 1; done + + install: all +- install -m 755 mold $(PREFIX)/bin ++ install -m 755 mold $(DESTDIR)$(PREFIX)/bin + strip $(PREFIX)/bin/mold + +- install -m 755 -d $(PREFIX)/lib/mold +- install -m 644 mold-wrapper.so $(PREFIX)/lib/mold +- strip $(PREFIX)/lib/mold/mold-wrapper.so ++ install -m 755 -d $(DESTDIR)$(PREFIX)/lib/mold ++ install -m 644 mold-wrapper.so $(DESTDIR)$(PREFIX)/lib/mold ++ strip $(DESTDIR)$(PREFIX)/lib/mold/mold-wrapper.so + +- install -m 644 docs/mold.1 $(PREFIX)/share/man/man1 +- rm -f $(PREFIX)/share/man/man1/mold.1.gz +- gzip -9 $(PREFIX)/share/man/man1/mold.1 ++ install -m 755 -d $(DESTDIR)$(PREFIX)/share/man/man1 ++ install -m 644 docs/mold.1 $(DESTDIR)$(PREFIX)/share/man/man1 ++ rm -f $(DESTDIR)$(PREFIX)/share/man/man1/mold.1.gz ++ gzip -9 $(DESTDIR)$(PREFIX)/share/man/man1/mold.1 + + uninstall: +- rm -rf $(PREFIX)/bin/mold $(PREFIX)/share/man/man1/mold.1.gz \ +- $(PREFIX)/lib/mold ++ rm -rf $(DESTDIR)$(PREFIX)/bin/mold $(DESTDIR)$(PREFIX)/share/man/man1/mold.1.gz \ ++ $(DESTDIR)$(PREFIX)/lib/mold + + clean: + rm -f *.o *~ mold mold-wrapper.so diff --git a/srcpkgs/mold/template b/srcpkgs/mold/template new file mode 100644 index 000000000000..9258c390deda --- /dev/null +++ b/srcpkgs/mold/template @@ -0,0 +1,36 @@ +# Template file for 'mold' +pkgname=mold +version=0.9.1 +revision=1 +build_style=gnu-makefile +make_build_args="SYSTEM_MIMALLOC=1" +hostmakedepends="clang" +makedepends="mimalloc-devel openssl-devel xxHash-devel tbb-devel" +short_desc="High performance drop-in replacement for existing Unix linkers" +maintainer="Artur Sinila " +license="AGPL-3.0-or-later" +homepage="https://github.com/rui314/mold" +changelog="https://github.com/rui314/mold/releases" +distfiles="https://github.com/rui314/mold/archive/refs/tags/v${version}.tar.gz" +checksum=02b156de6cd2d94fea4eed9748a7c96955673d810ec672359f603f2f90e2990d +_commit_hash=9a09c777d9460ebe7eb498d1cc0327915f8bbcdc + +pre_build() { + # gcc 10.2 doesn't fully support C++20 + export CXX=clang++ + + # "non-PIE executable found in PIE build" without these lines + CXXFLAGS+=" -fPIC" + LDFLAGS+=" -pie" + + # commit hash for --version + export GIT_HASH=$_commit_hash +} + +pre_install() { + vmkdir usr/bin +} + +post_install() { + vlicense LICENSE +}