public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/mold/files/, sys-devel/mold/
Date: Tue, 14 Dec 2021 11:14:10 +0000 (UTC)	[thread overview]
Message-ID: <1639480442.cb38ac7fc6ad1953967241e3520eb754f263840e.sam@gentoo> (raw)

commit:     cb38ac7fc6ad1953967241e3520eb754f263840e
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 14 11:13:03 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 14 11:14:02 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cb38ac7f

sys-devel/mold: add live ebuild

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/mold-9999-build-respect-user-FLAGS.patch | 83 ++++++++++++++++++++++
 .../files/mold-9999-don-t-compress-man-page.patch  | 22 ++++++
 sys-devel/mold/mold-0.9.6-r2.ebuild                | 10 ++-
 .../{mold-0.9.6-r2.ebuild => mold-9999.ebuild}     | 49 +++++--------
 4 files changed, 130 insertions(+), 34 deletions(-)

diff --git a/sys-devel/mold/files/mold-9999-build-respect-user-FLAGS.patch b/sys-devel/mold/files/mold-9999-build-respect-user-FLAGS.patch
new file mode 100644
index 000000000000..ac218201b902
--- /dev/null
+++ b/sys-devel/mold/files/mold-9999-build-respect-user-FLAGS.patch
@@ -0,0 +1,83 @@
+https://github.com/rui314/mold/pull/135
+
+From: Sam James <sam@gentoo.org>
+Date: Tue, 14 Dec 2021 10:53:44 +0000
+Subject: [PATCH 1/2] build: respect user *FLAGS
+
+- Respect user CXXFLAGS
+- Rename CPPFLAGS (previously used in the sense of "flags for the C++ compiler") -> CXXFLAGS
+- CPPFLAGS is generally used for "flags for the C(++) preprocessor.", so let's
+  use it for that
+- Respect user LDFLAGS
+  (In one instance, we were respecting LDFLAGS, but doing it too late.
+  We need to pass LDFLAGS _before_ any objects in order for -Wl,--as-needed
+  to work correctly.)
+
+Signed-off-by: Sam James <sam@gentoo.org>
+--- a/Makefile
++++ b/Makefile
+@@ -17,10 +17,15 @@ STRIP ?= strip
+ 
+ OS ?= $(shell uname -s)
+ 
+-CPPFLAGS = -pthread -std=c++20 -fPIE -DMOLD_VERSION=\"0.9.6\" \
+-	   -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables \
+-	   -DLIBDIR="\"$(LIBDIR)\"" $(EXTRA_CPPFLAGS)
+-LDFLAGS += $(EXTRA_LDFLAGS)
++# Used for both C and C++
++COMMON_FLAGS = -pthread -fPIE -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
++
++CFLAGS ?= -O2
++CFLAGS += $(COMMON_FLAGS)
++
++CXXFLAGS ?= -O2
++CXXFLAGS += $(COMMON_FLAGS) -std=c++20
++CPPFLAGS += -DMOLD_VERSION=\"0.9.6\" -DLIBDIR="\"$(LIBDIR)\""
+ LIBS = -pthread -lz -lxxhash -ldl -lm
+ 
+ SRCS=$(wildcard *.cc elf/*.cc macho/*.cc)
+@@ -38,21 +43,19 @@ ifneq ($(GIT_HASH),)
+ endif
+ 
+ ifeq ($(DEBUG), 1)
+-  CPPFLAGS += -O0 -g
+-else
+-  CPPFLAGS += -O2
++  CXXFLAGS += -O0 -g
+ endif
+ 
+ ifeq ($(LTO), 1)
+-  CPPFLAGS += -flto -O3
++  CXXFLAGS += -flto -O3
+   LDFLAGS  += -flto
+ endif
+ 
+ ifeq ($(ASAN), 1)
+-  CPPFLAGS += -fsanitize=address
++  CXXFLAGS += -fsanitize=address
+   LDFLAGS  += -fsanitize=address
+ else ifeq ($(TSAN), 1)
+-  CPPFLAGS += -fsanitize=thread
++  CXXFLAGS += -fsanitize=thread
+   LDFLAGS  += -fsanitize=thread
+ else ifneq ($(OS), Darwin)
+   # By default, we want to use mimalloc as a memory allocator.
+@@ -89,15 +92,15 @@ endif
+ all: mold mold-wrapper.so
+ 
+ mold: $(OBJS) $(MIMALLOC_LIB) $(TBB_LIB)
+-	$(CXX) $(CPPFLAGS) $(OBJS) -o $@ $(LDFLAGS) $(LIBS)
++	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
+ 	ln -sf mold ld
+ 	ln -sf mold ld64.mold
+ 
+ mold-wrapper.so: elf/mold-wrapper.c Makefile
+-	$(CC) -fPIC -shared -o $@ $< -ldl
++	$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -shared -o $@ $(LDFLAGS) $< -ldl
+ 
+ out/%.o: %.cc $(HEADERS) Makefile out/elf/.keep out/macho/.keep
+-	$(CXX) $(CPPFLAGS) -c -o $@ $<
++	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
+ 
+ out/elf/.keep:
+ 	mkdir -p out/elf

diff --git a/sys-devel/mold/files/mold-9999-don-t-compress-man-page.patch b/sys-devel/mold/files/mold-9999-don-t-compress-man-page.patch
new file mode 100644
index 000000000000..23dd705b553a
--- /dev/null
+++ b/sys-devel/mold/files/mold-9999-don-t-compress-man-page.patch
@@ -0,0 +1,22 @@
+https://github.com/rui314/mold/pull/135
+
+From: Sam James <sam@gentoo.org>
+Date: Tue, 14 Dec 2021 11:01:19 +0000
+Subject: [PATCH 2/2] build: don't compress man page
+
+Negligible saving and downstream, distributions usually recompress or
+compress with their own specific options. Unconditionally compressing
+man pages, while well intended, usually creates more hassle there.
+
+Signed-off-by: Sam James <sam@gentoo.org>
+--- a/Makefile
++++ b/Makefile
+@@ -140,8 +140,6 @@ install: all
+ 
+ 	install -m 755 -d $D$(MANDIR)/man1
+ 	install -m 644 docs/mold.1 $D$(MANDIR)/man1
+-	rm -f $D$(MANDIR)/man1/mold.1.gz
+-	gzip -9 $D$(MANDIR)/man1/mold.1
+ 
+ 	ln -sf mold $D$(BINDIR)/ld.mold
+ 	ln -sf mold $D$(BINDIR)/ld64.mold

diff --git a/sys-devel/mold/mold-0.9.6-r2.ebuild b/sys-devel/mold/mold-0.9.6-r2.ebuild
index a8bb3b7a4246..ceaaeaf2af4f 100644
--- a/sys-devel/mold/mold-0.9.6-r2.ebuild
+++ b/sys-devel/mold/mold-0.9.6-r2.ebuild
@@ -7,11 +7,17 @@ inherit toolchain-funcs
 
 DESCRIPTION="A Modern Linker"
 HOMEPAGE="https://github.com/rui314/mold"
-SRC_URI="https://github.com/rui314/mold/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
+if [[ ${PV} == 9999 ]] ; then
+	EGIT_REPO_URI="https://github.com/rui314/mold.git"
+	inherit git-r3
+else
+	SRC_URI="https://github.com/rui314/mold/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="~amd64"
+fi
 
 LICENSE="AGPL-3"
 SLOT="0"
-KEYWORDS="~amd64"
+
 # Try again after 0.9.6
 RESTRICT="test"
 

diff --git a/sys-devel/mold/mold-0.9.6-r2.ebuild b/sys-devel/mold/mold-9999.ebuild
similarity index 55%
copy from sys-devel/mold/mold-0.9.6-r2.ebuild
copy to sys-devel/mold/mold-9999.ebuild
index a8bb3b7a4246..0a936b317bbc 100644
--- a/sys-devel/mold/mold-0.9.6-r2.ebuild
+++ b/sys-devel/mold/mold-9999.ebuild
@@ -7,11 +7,17 @@ inherit toolchain-funcs
 
 DESCRIPTION="A Modern Linker"
 HOMEPAGE="https://github.com/rui314/mold"
-SRC_URI="https://github.com/rui314/mold/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
+if [[ ${PV} == 9999 ]] ; then
+	EGIT_REPO_URI="https://github.com/rui314/mold.git"
+	inherit git-r3
+else
+	SRC_URI="https://github.com/rui314/mold/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="~amd64"
+fi
 
 LICENSE="AGPL-3"
 SLOT="0"
-KEYWORDS="~amd64"
+
 # Try again after 0.9.6
 RESTRICT="test"
 
@@ -25,37 +31,10 @@ RDEPEND=">=dev-cpp/tbb-2021.4.0:=
 DEPEND="${RDEPEND}"
 
 PATCHES=(
-	"${FILESDIR}"/${PN}-0.9.6-respect-flags.patch
-	"${FILESDIR}"/${PN}-0.9.6-fix-libdir-wrapper.patch
+	"${FILESDIR}"/${PN}-9999-build-respect-user-FLAGS.patch
+	"${FILESDIR}"/${PN}-9999-don-t-compress-man-page.patch
 )
 
-src_prepare() {
-	default
-
-	sed -i \
-		-e '/	strip/d' \
-		-e '/	gzip/d' \
-		-e "s:\$(DEST)/lib:\$(DEST)/$(get_libdir):" \
-		Makefile || die
-
-	# Drop on next release: bug #823653
-	# https://github.com/rui314/mold/issues/127
-	sed -i \
-		-e "s:/usr/lib64/mold/mold-wrapper.so:${EPREFIX}/usr/$(get_libdir)/mold/mold-wrapper.so:" \
-		elf/subprocess.cc || die
-
-	# Needs unpackaged dwarfutils
-	rm test/compressed-debug-info.sh \
-		test/compress-debug-sections.sh || die
-
-	# Seems to have been fixed in git (> 0.9.6)
-	# Broken atm?
-	rm test/mold-wrapper.sh || die
-
-	# Needs llvmgold
-	rm test/hello-static.sh || die
-}
-
 src_compile() {
 	tc-export CC CXX
 
@@ -65,7 +44,9 @@ src_compile() {
 		EXTRA_CFLAGS="${CFLAGS}" \
 		EXTRA_CXXFLAGS="${CXXFLAGS}" \
 		EXTRA_CPPFLAGS="${CPPFLAGS}" \
-		EXTRA_LDFLAGS="${LDFLAGS}"
+		EXTRA_LDFLAGS="${LDFLAGS}" \
+		STRIP="true"
+		LIBDIR="${EPREFIX}/usr/$(get_libdir)"
 }
 
 src_test() {
@@ -76,6 +57,8 @@ src_test() {
 		EXTRA_CXXFLAGS="${CXXFLAGS}" \
 		EXTRA_CPPFLAGS="${CPPFLAGS}" \
 		EXTRA_LDFLAGS="${LDFLAGS}" \
+		LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+		STRIP="true"
 		check
 }
 
@@ -88,5 +71,7 @@ src_install() {
 		EXTRA_CPPFLAGS="${CPPFLAGS}" \
 		EXTRA_LDFLAGS="${LDFLAGS}" \
 		DESTDIR="${ED}" \
+		LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+		STRIP="true" \
 		install
 }


             reply	other threads:[~2021-12-14 11:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 11:14 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-12-20  5:08 [gentoo-commits] repo/gentoo:master commit in: sys-devel/mold/files/, sys-devel/mold/ Sam James
2022-07-28 10:17 Sam James
2022-12-04  8:55 Matthew Smith
2023-07-29  4:43 Sam James
2023-11-13  2:11 Sam James
2024-04-30  7:03 Sam James
2024-06-24  0:32 Sam James
2024-09-02  5:14 Sam James
2024-12-09  5:54 Sam James
2024-12-20  6:10 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1639480442.cb38ac7fc6ad1953967241e3520eb754f263840e.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox