Subject: bug#53601: closed (Re: bug#60754: [PATCH 1/2] gnu: Add mold.)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 12 Feb 2023 00:48:03 +0000

Your bug report

#53601: [PATCH 1/2] gnu: Add mimalloc.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
53601: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53601
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#60754: [PATCH 1/2] gnu: Add mold.
From: Ludovic Courtès <[email-masked]>
To: Zhu Zihao <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Sun, 12 Feb 2023 01:47:18 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Zhu Zihao <[email-masked]> skribis:

> * gnu/local.mk (GNU_SYSTEM_MODULES): Add new file.
> * gnu/packages/mold.scm: New file.
> * gnu/packages/mold.scm (mold): New variable.

[...]

> * gnu/packages/mold.scm(make-mold-wrapper): New variable.
> (mold-wrapper): New variable.
> (mold-as-ld-wrapper): New variable.

Applied both with minor changes (see below), thanks.

I’m also closing the two other issues you mentioned that were adding
mold.  Please let us know if there’s something to borrow from them!

Ludo’.

diff --git a/gnu/packages/mold.scm b/gnu/packages/mold.scm
index 6514bd3b90..dfc452a329 100644
--- a/gnu/packages/mold.scm
+++ b/gnu/packages/mold.scm
@@ -77,12 +77,12 @@ (define-public mold
               (delete-file "test/elf/rpath.sh"))))))
     (inputs (list mimalloc openssl tbb xxhash zlib `(,zstd "lib")))
     (home-page "https://github.com/rui314/mold")
-    (synopsis "Faster drop-in replacement for Unix linkers")
+    (synopsis "Fast linker")
     (description
-     "Mold is a faster drop-in replacement for existing Unix linkers.
+     "Mold is a faster drop-in replacement for existing linkers.
 It is designed to increase developer productivity by reducing build time,
 especially in rapid debug-edit-rebuild cycles.")
-    (license license:agpl3+)))
+    (license license:agpl3)))
 
 (define* (make-mold-wrapper mold #:key mold-as-ld?)
   "Return a MOLD wrapper.  When MOLD-AS-LD? is true, create a 'ld' symlink that

Subject: [PATCH 1/2] gnu: Add mimalloc.
From: phodina <[email-masked]>
To: Guix Patches <[email-masked]>
Date: Fri, 28 Jan 2022 10:50:17 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

here is a patch set to add mold linker.

I've temporarily put the package definition into gnu/packages/raspberry-pi.scm as I'm unsure if it should go to gnu/packages/commencement.scm or somewhere else.

It would be be interesting to test it as a new default linker on such a large scale project.

Also there is currently one test failing so I've disabled the tests for now:

Testing mold-wrapper ... execl: No such file or directory
make[1]: *** [Makefile.linux:6: elf/mold-wrapper.sh] Error 1
make[1]: *** Waiting for unfinished jobs....

----
Petr

From 67fd2d0a9ffa2a13e5b289c9f4cd7f9dd85a91c6 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Wed, 29 Dec 2021 22:41:47 +0100
Subject: [PATCH 1/2] gnu: Add mimalloc.

* gnu/packages/WIP (mimalloc): Add new variable.

diff --git a/gnu/packages/raspberry-pi.scm b/gnu/packages/raspberry-pi.scm
index bb38b8b218..a0142c2333 100644
--- a/gnu/packages/raspberry-pi.scm
+++ b/gnu/packages/raspberry-pi.scm
@@ -29,6 +29,7 @@ (define-module (gnu packages raspberry-pi)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages embedded)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system cmake)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
@@ -42,6 +43,37 @@ (define-module (gnu packages raspberry-pi)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match))
 
+(define-public mimalloc
+  (package
+    (name "mimalloc")
+    (version "2.0.3")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/microsoft/mimalloc")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0avamijn2dcrkba291rmdiv6z0kjzkhc1vigcwmhk9h0cvsc0q44"))))
+    (build-system cmake-build-system)
+    (synopsis "Compact general purpose allocator")
+    (description "This package provides a drop-in replacement for malloc.
+It provides the following benefits:
+@enumerate
+@item small and consistent
+@item free list sharding
+@item free list multi-sharding
+@item eager page reset
+@item secure
+@item first-class heaps
+@item bounded
+@item fast
+@end enumerate
+")
+    (home-page "https://github.com/microsoft/mimalloc")
+    (license license:expat)))
+
 (define-public bcm2835
   (package
     (name "bcm2835")
-- 
2.34.0

From a1928e92512915a6d041da0195d6c2bb164f505d Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Wed, 29 Dec 2021 22:42:48 +0100
Subject: [PATCH 2/2] gnu: Add mold.

* gnu/packages/WIP (mold): New variable.

diff --git a/gnu/packages/raspberry-pi.scm b/gnu/packages/raspberry-pi.scm
index a0142c2333..b59ec822c9 100644
--- a/gnu/packages/raspberry-pi.scm
+++ b/gnu/packages/raspberry-pi.scm
@@ -22,11 +22,21 @@ (define-module (gnu packages raspberry-pi)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages digest)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages file)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages tbb)
+  #:use-module (gnu packages tls)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages embedded)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
@@ -74,6 +84,57 @@ (define-public mimalloc
     (home-page "https://github.com/microsoft/mimalloc")
     (license license:expat)))
 
+(define-public mold
+  (package
+    (name "mold")
+    (version "1.0.2")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/rui314/mold")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          (delete-file-recursively "third-party")))
+              (sha256
+               (base32
+                "08iiycbzb4324mnzph6m4y5kf700zhr66c0sq93k5sajm3xy8dfi"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list "SYSTEM_MIMALLOC=true" "SYSTEM_TBB=true"
+                          "SYSTEM_XXHASH=true"
+                          (string-append "PREFIX=" %output))
+       #:tests? #f ; failing test mold-wrapper
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-reference-to-cc
+           ;; This prevents errors like 'error: linker `cc` not found' when
+           ;; "cc" is not found on PATH.
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (let ((gcc (assoc-ref inputs "gcc")) (util-linux (assoc-ref
+                                                               inputs
+                                                               "util-linux")))
+               (substitute* "test/elf/exception.sh"
+                 (("`pwd`/../../mold") (string-append (getcwd) "/mold")))
+               (substitute* "test/elf/gc-sections.sh"
+                 (("`pwd`/../../mold") (string-append (getcwd) "/mold")))
+               (substitute* "test/elf/filler.sh"
+                 (("hexdump") (string-append util-linux "/bin/hexdump")))
+               (mkdir-p "/tmp/bin")
+               (symlink (string-append gcc "/bin/gcc") "/tmp/bin/cc")
+               (setenv "PATH"
+                       (string-append "/tmp/bin:"
+                                      (getenv "PATH"))))))
+         (delete 'configure))))
+    (native-inputs (list clang-12 gcc grep pkg-config util-linux xxhash))
+    (inputs (list mimalloc openssl python tbb zlib))
+    (synopsis "Modern Linker")
+    (description "This package provides a faster drop-in replacement for
+existing Unix linkers.")
+    (home-page "https://savannah.gnu.org/projects/patch/")
+    (license license:gpl3+)))
+
 (define-public bcm2835
   (package
     (name "bcm2835")
-- 
2.34.0