about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpjotrp2026-04-10 17:38:29 +0200
committerpjotrp2026-04-10 17:38:29 +0200
commitf67dfd7e114f412b088ff673c24208e88ee7947c (patch)
tree23d3996a291d6fd09b46b71cec1799bcc935a39c
parent79310651d0bf69e97924b4f2a4743bc4634819dd (diff)
downloadguix-bioinformatics-f67dfd7e114f412b088ff673c24208e88ee7947c.tar.gz
Allow for tuning of C++ and Rust packages --tune=native HEAD main
-rw-r--r--README.org2
-rw-r--r--gn/packages/pangenome-rust.scm51
2 files changed, 45 insertions, 8 deletions
diff --git a/README.org b/README.org
index 5d7cc33..2ab2229 100644
--- a/README.org
+++ b/README.org
@@ -73,7 +73,7 @@ root with
 
 All important packages are listed in manifest.scm.example. Test with
 
-: guix build -L . -m manifest.scm.example
+: guix build -L . -m manifest.scm.example --tune=native
 
 * An important note on AI
 
diff --git a/gn/packages/pangenome-rust.scm b/gn/packages/pangenome-rust.scm
index 3e9d8cc..00155bd 100644
--- a/gn/packages/pangenome-rust.scm
+++ b/gn/packages/pangenome-rust.scm
@@ -34,6 +34,27 @@
   (crate-source "anyhow" "1.0.66"
                 "1xj3ahmwjlbiqsajhkaa0q6hqwb4l3l5rkfxa7jk1498r3fn2qi1"))
 
+;; Phase snippet to set RUSTFLAGS for CPU tuning.
+;; Detects the tuning CPU from PATH (tuning-compiler-<cpu> directory)
+;; and sets RUSTFLAGS=-C target-cpu=<cpu>.
+(define %rust-tuning-phase
+  #~(add-before 'build 'set-rust-target-cpu
+      (lambda _
+        (let loop ((dirs (string-split (or (getenv "PATH") "") #\:)))
+          (if (null? dirs)
+              #t
+              (let ((base (basename (dirname (car dirs)))))
+                (if (string-contains base "tuning-compiler-")
+                    (let ((cpu (substring base
+                                         (+ (string-contains base "tuning-compiler-")
+                                            (string-length "tuning-compiler-")))))
+                      (setenv "RUSTFLAGS"
+                              (string-append (or (getenv "RUSTFLAGS") "")
+                                             " -C target-cpu=" cpu))
+                      (format #t "  RUSTFLAGS set for CPU tuning: ~a~%" (getenv "RUSTFLAGS")))
+                    (loop (cdr dirs)))))))))
+
+
 (define rust-autocfg-1.1.0
   (crate-source "autocfg" "1.1.0"
                 "1ylp3cb47ylzabimazvbz9ms6ap784zhb6syaz6c1jqpmcmq0s6l"))
@@ -3287,7 +3308,9 @@
                  (base32
                   "1kv1abwwj1m5d7y61ymrrj309bg543vk5dlfq56h5d4qswmb7zyv"))))
       (build-system cargo-build-system)
-      (arguments (list #:install-source? #f))
+      (arguments (list #:install-source? #f
+                       #:phases #~(modify-phases %standard-phases
+                                    #$%rust-tuning-phase)))
       ;; No upstream test data; tests require GFA/BAM input files.
       (inputs (cargo-inputs 'gfainject #:module '(gn packages pangenome-rust)))
       (properties '((tunable? . #t)))
@@ -3316,7 +3339,9 @@ names must match the path names in the GFA.")
                   "0nzhgg7sqalrpl1mzlp0rvaj4dgcwghv1jngcsfqqk1mhx4hvj0n"))))
       (build-system cargo-build-system)
       (arguments
-       (list #:install-source? #f))
+       (list #:install-source? #f
+             #:phases #~(modify-phases %standard-phases
+                          #$%rust-tuning-phase)))
       (inputs (cargo-inputs 'onecode #:module '(gn packages pangenome-rust)))
       (properties '((tunable? . #t)))
       (home-page "https://github.com/pangenome/onecode-rs")
@@ -3352,7 +3377,9 @@ data.  The C library (ONElib) is bundled and compiled at build time.")
              #:tests? #f
              #:cargo-build-flags ''("--release" "--package" "ragc-cli")
              ;; Workspace root has no [[bin]], must specify the CLI member
-             #:cargo-install-paths ''("ragc-cli")))
+             #:cargo-install-paths ''("ragc-cli")
+             #:phases #~(modify-phases %standard-phases
+                          #$%rust-tuning-phase)))
       (properties '((tunable? . #t)))
       (home-page "https://github.com/AndreaGuarracino/ragc")
       (synopsis "Genome compression tool implementing the AGC format in Rust")
@@ -3386,6 +3413,7 @@ similar genome sequences and is compatible with the C++ AGC format.")
              #:tests? #f
              #:phases
              #~(modify-phases %standard-phases
+                 #$%rust-tuning-phase
                  (add-after 'unpack 'fix-sources
                    ;; Cargo.toml uses a git source for onecode but Cargo.lock
                    ;; resolved it to the registry version 0.1.0.
@@ -3596,6 +3624,7 @@ sequences to accelerate the alignment process.")
         #:install-source? #f
         #:phases
         #~(modify-phases %standard-phases
+            #$%rust-tuning-phase
             ;; The ragc workspace root has no [package] so crate-src? returns #f
             ;; and configure skips it.  Copy it manually.
             (add-before 'build 'copy-ragc-workspace
@@ -3814,7 +3843,9 @@ and alignments for analysis.  It can also compute graphs for the sequences.")
                  (base32
                   "0r51kz2vwmj8kkxr1az45g68m0acn652mcddsscc78m78yxh85v1"))))
       (build-system cargo-build-system)
-      (arguments (list #:install-source? #f))
+      (arguments (list #:install-source? #f
+                       #:phases #~(modify-phases %standard-phases
+                                    #$%rust-tuning-phase)))
       (inputs (cargo-inputs 'gfautil #:module '(gn packages pangenome-rust)))
       (properties '((tunable? . #t)))
       (home-page "https://github.com/pangenome/rs-gfa-utils")
@@ -3839,7 +3870,9 @@ Graphical Fragment Assembly} files and related formats.")
          (base32 "0yn8i70ww3x544qm4fwr33vklsxf3fvivpfpv46prkfz9hsmd9ps"))))
     (build-system cargo-build-system)
     (arguments
-     `(#:install-source? #f))
+     (list #:install-source? #f
+           #:phases #~(modify-phases %standard-phases
+                        #$%rust-tuning-phase)))
     (inputs (cargo-inputs 'gfaffix
                           #:module '(gn packages pangenome-rust)))
     (properties '((tunable? . #t)))
@@ -3865,7 +3898,9 @@ collapses them into a non-redundant graph structure.")
                 (sha256
                  (base32 "0di2psh0ls7jlbnqs7k71p55f73pn23a09k1h3ril7gwjcrzr3rk"))))
       (build-system cargo-build-system)
-      (arguments (list #:install-source? #f))
+      (arguments (list #:install-source? #f
+                       #:phases #~(modify-phases %standard-phases
+                                    #$%rust-tuning-phase)))
       (inputs (cargo-inputs 'gafpack #:module '(gn packages pangenome-rust)))
       (properties '((tunable? . #t)))
       (home-page "https://github.com/ekg/gafpack")
@@ -3890,7 +3925,9 @@ maps useful in haplotype-based genotyping.")
               (sha256
                (base32 "0sk2ab22z6qa00j1w8a8f5kbb7q2xb10fhd32zy4lh351v3mqmyg"))))
     (build-system cargo-build-system)
-    (arguments (list #:install-source? #f))
+    (arguments (list #:install-source? #f
+                     #:phases #~(modify-phases %standard-phases
+                                  #$%rust-tuning-phase)))
     (inputs (cargo-inputs 'vcfbub #:module '(gn packages pangenome-rust)))
     (properties '((tunable? . #t)))
     (home-page "https://github.com/pangenome/vcfbub")