diff mbox series

[bug#72553,1/4] gnu: rust: Add profiling support.

Message ID 0917fd5934be09855e7baec9901fa090d98a524b.1723273907.git.mail@cbaines.net
State New
Headers show
Series Several patches removed from core-updates | expand

Commit Message

Christopher Baines Aug. 10, 2024, 7:11 a.m. UTC
From: Milkey Mouse <milkeymouse@meme.institute>

* gnu/packages/rust.scm (rust-1.52)
[phases] <unpack-profiler-rt, enable-profiling>: New phases.

Change-Id: Iecb4aef518e52f71ff7f539778bf0341288a3458
---
 gnu/packages/rust.scm | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)


base-commit: ce055b806eaff8fec329c30ae0deb82c50a86240
diff mbox series

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 12529d2420..4a3ad99e88 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1216,11 +1216,24 @@  (define-public rust
                (lambda* (#:key outputs #:allow-other-keys)
                  (let ((out (assoc-ref outputs "out")))
                    (substitute* "src/bootstrap/src/core/builder.rs"
-                      ((" = rpath.*" all)
-                       (string-append all
-                                      "                "
-                                      "rustflags.arg(\"-Clink-args=-Wl,-rpath="
-                                      out "/lib\");\n"))))))
+                     ((" = rpath.*" all)
+                      (string-append all
+                                     "                "
+                                     "rustflags.arg(\"-Clink-args=-Wl,-rpath="
+                                     out "/lib\");\n"))))))
+             (add-after 'unpack 'unpack-profiler-rt
+               ;; Copy compiler-rt sources to where libprofiler_builtins looks
+               ;; for its vendored copy.  Keep the clang-runtime version in
+               ;; sync with the LLVM version used to build Rust.
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (mkdir-p "src/llvm-project/compiler-rt")
+                 (invoke "tar" "-xf" #$(package-source clang-runtime-15)
+                   "-C" "src/llvm-project/compiler-rt" "--strip-components=1")))
+             (add-after 'enable-codegen-tests 'enable-profiling
+               (lambda _
+                 (substitute* "config.toml"
+                   (("^profiler =.*$") "")
+                   (("\\[build\\]") "\n[build]\nprofiler = true\n"))))
              (add-after 'configure 'add-gdb-to-config
                (lambda* (#:key inputs #:allow-other-keys)
                  (let ((gdb (assoc-ref inputs "gdb")))
@@ -1236,7 +1249,7 @@  (define-public rust
                                            (number->string (parallel-job-count))
                                            "1"))))
                    (invoke "./x.py" job-spec "build"
-                           "library/std"    ;rustc
+                           "library/std" ;rustc
                            "src/tools/cargo"
                            "src/tools/clippy"
                            "src/tools/rust-analyzer"