diff options
| author | Jonas Meeuws <jonas.meeuws@gmail.com> | 2026-08-06 20:24:35 +0200 |
|---|---|---|
| committer | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2026-08-22 16:49:17 +0200 |
| commit | 10e25d7691d6c5891fd94e7575543a3463bfa6f7 (patch) | |
| tree | d798ffa15dbd81ac5d25f823457e456a84b7f538 /gnu | |
| parent | 63b9c42462e7a55f7ae23e7f0d12d3cf57ac628d (diff) | |
gnu: dub: Remove compiler from runtime closure.
Reduce closure size from 1022.0 MiB to 198.4 MiB.
* gnu/packages/dlang.scm (remove-d-include-references-phase): New public
function.
(dub)[#:phases]: Add ‘remove-d-include-references’.
Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/packages/dlang.scm | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/gnu/packages/dlang.scm b/gnu/packages/dlang.scm index 4669b5bd616..5f27cb1df86 100644 --- a/gnu/packages/dlang.scm +++ b/gnu/packages/dlang.scm | |||
| @@ -63,6 +63,36 @@ | |||
| 63 | ;; Compilers and tooling for the D programming language. | 63 | ;; Compilers and tooling for the D programming language. |
| 64 | ;; Note: The GNU D compiler is defined in (gnu packages gcc) instead. | 64 | ;; Note: The GNU D compiler is defined in (gnu packages gcc) instead. |
| 65 | 65 | ||
| 66 | ;; Removes references to druntime and standard library source paths that may be | ||
| 67 | ;; printed in backtraces. | ||
| 68 | (define-public (remove-d-include-references-phase compiler) | ||
| 69 | #~(lambda* (#:key outputs #:allow-other-keys) | ||
| 70 | (for-each | ||
| 71 | (lambda (file) | ||
| 72 | ;; Set the last character of the hash to *. | ||
| 73 | (let* ((compiler #$compiler) | ||
| 74 | (char-offset (+ (string-length (%store-directory)) | ||
| 75 | (string-length "/") | ||
| 76 | %store-hash-string-length | ||
| 77 | -1)) | ||
| 78 | (patched (string-append | ||
| 79 | (string-take compiler char-offset) | ||
| 80 | "*" | ||
| 81 | (string-drop compiler (+ char-offset 1)))) | ||
| 82 | (sources-regex (string-append | ||
| 83 | "[[:alnum:]/_.\\-]*" | ||
| 84 | "/include/" | ||
| 85 | "[[:alnum:]/_.\\-]*" | ||
| 86 | "\\.d")) | ||
| 87 | (command (list "sed" "-i" | ||
| 88 | (format #f "s,~a\\(~a\\),~a\\1,g" | ||
| 89 | compiler sources-regex patched) | ||
| 90 | file))) | ||
| 91 | ;; XXX: Use sed, as substitute* fails on binary files. | ||
| 92 | (apply invoke command))) | ||
| 93 | (apply append (map find-files | ||
| 94 | (map cdr outputs)))))) | ||
| 95 | |||
| 66 | 96 | ||
| 67 | ;; LLVM-based D compiler | 97 | ;; LLVM-based D compiler |
| 68 | 98 | ||
| @@ -826,7 +856,10 @@ compiler for the D programming language.") | |||
| 826 | (find-files "." "\\.1$"))) | 856 | (find-files "." "\\.1$"))) |
| 827 | (install-file "scripts/bash-completion/dub.bash" bash-comp) | 857 | (install-file "scripts/bash-completion/dub.bash" bash-comp) |
| 828 | (install-file "scripts/fish-completion/dub.fish" fish-comp) | 858 | (install-file "scripts/fish-completion/dub.fish" fish-comp) |
| 829 | (install-file "scripts/zsh-completion/_dub" zsh-comp))))))) | 859 | (install-file "scripts/zsh-completion/_dub" zsh-comp)))) |
| 860 | (add-after 'install 'remove-d-include-references | ||
| 861 | #$(remove-d-include-references-phase | ||
| 862 | (this-package-native-input "ldc")))))) | ||
| 830 | (inputs | 863 | (inputs |
| 831 | (list curl)) | 864 | (list curl)) |
| 832 | (native-inputs | 865 | (native-inputs |
