[PATCH 1/2] gnu: Add mimalloc.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • phodina
Owner
unassigned
Submitted by
phodina
Severity
normal
P
P
phodina wrote on 28 Jan 2022 11:50
(name . Guix Patches)(address . guix-patches@gnu.org)
qaDpUx3eTPOe6YGDi2adlrsNfLvUiS-I75wfpquCZfFCHe18UNqxU1xGYJnqhXwpBUkaXXISiR7IxgFT1N9NzDgpit9ytnePdTaVJMhGhGA=@protonmail.com
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
Attachment: file
From 67fd2d0a9ffa2a13e5b289c9f4cd7f9dd85a91c6 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Wed, 29 Dec 2021 22:41:47 +0100
Subject: [PATCH 1/2] gnu: Add mimalloc.

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

Toggle diff (52 lines)
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 <phodina@protonmail.com>
Date: Wed, 29 Dec 2021 22:42:48 +0100
Subject: [PATCH 2/2] gnu: Add mold.

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

Toggle diff (86 lines)
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
L
L
Ludovic Courtès wrote on 12 Feb 2023 01:47
Re: bug#60754: [PATCH 1/2] gnu: Add mold.
(name . Zhu Zihao)(address . all_but_last@163.com)
87357bn209.fsf_-_@gnu.org
Hi,

Zhu Zihao <all_but_last@163.com> skribis:

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

[...]

Toggle quote (4 lines)
> * 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’.
Toggle diff (20 lines)
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
Closed
?