| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 |
|
| 21 | (define-module (gnu packages mold)
|
| 22 | #:use-module (guix gexp)
|
| 23 | #:use-module (guix packages)
|
| 24 | #:use-module (guix utils)
|
| 25 | #:use-module (guix git-download)
|
| 26 | #:use-module (guix build-system cmake)
|
| 27 | #:use-module (guix build-system trivial)
|
| 28 | #:use-module (gnu packages base)
|
| 29 | #:use-module (gnu packages c)
|
| 30 | #:use-module (gnu packages crypto)
|
| 31 | #:use-module (gnu packages digest)
|
| 32 | #:use-module (gnu packages oneapi)
|
| 33 | #:use-module (gnu packages tls)
|
| 34 | #:use-module (gnu packages compression)
|
| 35 | #:use-module ((guix licenses) #:prefix license:))
|
| 36 |
|
| 37 | (define-public mold
|
| 38 | (package
|
| 39 | (name "mold")
|
| 40 | (version "2.42.1")
|
| 41 | (source
|
| 42 | (origin
|
| 43 | (method git-fetch)
|
| 44 | (uri (git-reference
|
| 45 | (url "https://github.com/rui314/mold")
|
| 46 | (commit (string-append "v" version))))
|
| 47 | (file-name (git-file-name name version))
|
| 48 | (sha256
|
| 49 | (base32 "0bymmnsxpgzg6p4gygq0h7kil36izqqh5mhaa3bwkqdg258rdfyx"))
|
| 50 | (modules '((guix build utils)))
|
| 51 | (snippet
|
| 52 | #~(begin
|
| 53 | (for-each
|
| 54 | (lambda (x)
|
| 55 | (delete-file-recursively (string-append "third-party/" x)))
|
| 56 | '("blake3" "mimalloc" "tbb" "xxhash" "zlib" "zstd"))))))
|
| 57 | (build-system cmake-build-system)
|
| 58 | (arguments
|
| 59 | (list
|
| 60 | |
| 61 | |
| 62 | #:configure-flags #~(list #$@(if (target-64bit?)
|
| 63 | '("-DMOLD_USE_SYSTEM_MIMALLOC=ON")
|
| 64 | '("-DMOLD_USE_MIMALLOC=OFF"))
|
| 65 | "-DMOLD_USE_SYSTEM_TBB=ON")
|
| 66 | #:phases
|
| 67 | #~(modify-phases %standard-phases
|
| 68 | (add-before 'configure 'force-system-xxhash
|
| 69 | (lambda _
|
| 70 | (substitute* "lib/lib.h"
|
| 71 | (("#include \"../third-party/xxhash/xxhash.h\"")
|
| 72 | "#include <xxhash.h>"))))
|
| 73 | (add-before 'configure 'fix-compiler-name-in-test
|
| 74 | (lambda _
|
| 75 | (substitute* "test/common.inc"
|
| 76 | (("CC=\"\\$\\{TEST_CC:-cc\\}\"") "CC=gcc")
|
| 77 | (("CXX=\"\\$\\{TEST_CXX:-c\\+\\+\\}\"")
|
| 78 | "CXX=g++"))))
|
| 79 | (add-before 'configure 'disable-rpath-test
|
| 80 | (lambda _
|
| 81 | |
| 82 | |
| 83 | |
| 84 | (delete-file "test/rpath.sh"))))))
|
| 85 | (inputs
|
| 86 | (append
|
| 87 | (if (target-64bit?)
|
| 88 | (list mimalloc)
|
| 89 | '())
|
| 90 | (list libblake3 onetbb xxhash zlib `(,zstd "lib"))))
|
| 91 | (home-page "https://github.com/rui314/mold")
|
| 92 | (synopsis "Fast linker")
|
| 93 | (description
|
| 94 | "Mold is a faster drop-in replacement for existing linkers.
|
| 95 | It is designed to increase developer productivity by reducing build time,
|
| 96 | especially in rapid debug-edit-rebuild cycles.")
|
| 97 | (license license:agpl3)))
|
| 98 |
|
| 99 | (define* (make-mold-wrapper mold #:key mold-as-ld?)
|
| 100 | "Return a MOLD wrapper. When MOLD-AS-LD? is true, create a 'ld' symlink that
|
| 101 | points to 'mold'."
|
| 102 | (package
|
| 103 | (inherit mold)
|
| 104 | (name (if mold-as-ld? "mold-as-ld-wrapper" "mold-wrapper"))
|
| 105 | (source #f)
|
| 106 | (native-inputs '())
|
| 107 | (inputs (list (make-ld-wrapper "ld.mold-wrapper" #:binutils mold
|
| 108 | #:linker "ld.mold")
|
| 109 | (make-ld-wrapper "mold-wrapper" #:binutils mold #:linker
|
| 110 | "mold")))
|
| 111 | (propagated-inputs '())
|
| 112 | (build-system trivial-build-system)
|
| 113 | (arguments
|
| 114 | (list #:builder
|
| 115 | #~(let ((ld.mold (string-append #$(this-package-input
|
| 116 | "ld.mold-wrapper")
|
| 117 | "/bin/ld.mold"))
|
| 118 | (mold (string-append #$(this-package-input "mold-wrapper")
|
| 119 | "/bin/mold")))
|
| 120 | (mkdir #$output)
|
| 121 | (mkdir (string-append #$output "/bin"))
|
| 122 | (symlink ld.mold (string-append #$output "/bin/ld.mold"))
|
| 123 | (symlink mold (string-append #$output "/bin/mold"))
|
| 124 | (when #$mold-as-ld?
|
| 125 | (symlink ld.mold (string-append #$output "/bin/ld"))))))
|
| 126 | (synopsis "Mold linker wrapper")
|
| 127 | (description "This is a linker wrapper for Mold; like @code{ld-wrapper}, it
|
| 128 | wraps the linker to add any missing @code{-rpath} flags, and to detect any
|
| 129 | misuse of libraries outside of the store.")))
|
| 130 |
|
| 131 | (define-public mold-wrapper
|
| 132 | (make-mold-wrapper mold))
|
| 133 |
|
| 134 | (define-public mold-as-ld-wrapper
|
| 135 | (make-mold-wrapper mold #:mold-as-ld? #t))
|