summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2026-03-04 17:44:22 +0200
committerEfraim Flashner <efraim@flashner.co.il>2026-03-30 10:36:19 +0300
commit7095f1b42e5e4951a10c7a62caeb9d5578385a48 (patch)
tree791e0cd9ed2a38cafd04b29b0dc0506b5accb45d
parent3691bb640d33150d2ff3f8194e6f157325a8d5e4 (diff)
gnu: qemu: Prepare to build with rust.
* gnu/packages/virtualization.scm (qemu)[source]: Adjust snippet to remove bundled rust crates. [arguments]: Adjust configure-flags to build with rust when rust is in the build environment. Add a phase when rust is available to make the build system use the packaged rust crates. [native-inputs]: When building with rust add rust, rust-bindgen-cli, cargo-inputs qemu, and the cross-compiler for rust when needed. * gnu/packages/rust-crates.scm (qemu): New entry. Change-Id: Ib2f6fbd870740a674f6424e1e2800ca5dfa40aa7 Signed-off-by: John Kehayias <john@guixotic.coop>
-rw-r--r--gnu/packages/rust-crates.scm69
-rw-r--r--gnu/packages/virtualization.scm117
2 files changed, 150 insertions, 36 deletions
diff --git a/gnu/packages/rust-crates.scm b/gnu/packages/rust-crates.scm
index 787589ed23e..1a63f70f8d7 100644
--- a/gnu/packages/rust-crates.scm
+++ b/gnu/packages/rust-crates.scm
@@ -752,6 +752,10 @@
752 (crate-source "arbitrary" "1.4.2" 752 (crate-source "arbitrary" "1.4.2"
753 "1wcbi4x7i3lzcrkjda4810nqv03lpmvfhb0a85xrq1mbqjikdl63")) 753 "1wcbi4x7i3lzcrkjda4810nqv03lpmvfhb0a85xrq1mbqjikdl63"))
754 754
755(define rust-arbitrary-int-1.2.7
756 (crate-source "arbitrary-int" "1.2.7"
757 "0vgl3n5zzpdn2hxpz6gqk8zg2psk5gwyjzsgpngzd9iqwc1w0ky8"))
758
755(define rust-arboard-3.5.0 759(define rust-arboard-3.5.0
756 (crate-source "arboard" "3.5.0" 760 (crate-source "arboard" "3.5.0"
757 "0w1yqcx51153hy5w3y0702xjc9nmlhncw9f5l0rdwbl62pvj3py1")) 761 "0w1yqcx51153hy5w3y0702xjc9nmlhncw9f5l0rdwbl62pvj3py1"))
@@ -1476,6 +1480,10 @@
1476 (crate-source "attribute-derive-macro" "0.10.3" 1480 (crate-source "attribute-derive-macro" "0.10.3"
1477 "06zph2lyllkp6g1lsv7v4p84dnglbw2gw58r9fpn1d6m1ynm6fs6")) 1481 "06zph2lyllkp6g1lsv7v4p84dnglbw2gw58r9fpn1d6m1ynm6fs6"))
1478 1482
1483(define rust-attrs-0.2.9
1484 (crate-source "attrs" "0.2.9"
1485 "0pvy6b7arfr2f6awwkw6k1hc8sxidjxhj1fyyf2m5rixyi07s81a"))
1486
1479(define rust-atty-0.2.11 1487(define rust-atty-0.2.11
1480 (crate-source "atty" "0.2.11" 1488 (crate-source "atty" "0.2.11"
1481 "0lln6vaczj521qqjbaqnb81w5p6xk4fjfkg33r0m22cm4f3mnzcs")) 1489 "0lln6vaczj521qqjbaqnb81w5p6xk4fjfkg33r0m22cm4f3mnzcs"))
@@ -2174,6 +2182,14 @@
2174 (crate-source "bigdecimal" "0.4.10" 2182 (crate-source "bigdecimal" "0.4.10"
2175 "159nc0bs6bbzxrpfxbnn83ccyzq8bc2ia40zd22ssfjvavqnfs2d")) 2183 "159nc0bs6bbzxrpfxbnn83ccyzq8bc2ia40zd22ssfjvavqnfs2d"))
2176 2184
2185(define rust-bilge-0.2.0
2186 (crate-source "bilge" "0.2.0"
2187 "0mvvwq9caiq701bmmwyd4q4pc8c69i5zaj3zdk6ya7gqxgc7ww6w"))
2188
2189(define rust-bilge-impl-0.2.0
2190 (crate-source "bilge-impl" "0.2.0"
2191 "1n5jml0c1z0np76ms0h5rxx19krblz46h84wycx29b9q4001xcgy"))
2192
2177(define rust-binascii-0.1.4 2193(define rust-binascii-0.1.4
2178 (crate-source "binascii" "0.1.4" 2194 (crate-source "binascii" "0.1.4"
2179 "0wnaglgl72pn5ilv61q6y34w76gbg7crb8ifqk6lsxnq2gajjg9q")) 2195 "0wnaglgl72pn5ilv61q6y34w76gbg7crb8ifqk6lsxnq2gajjg9q"))
@@ -7405,6 +7421,10 @@
7405 (crate-source "ego-tree" "0.10.0" 7421 (crate-source "ego-tree" "0.10.0"
7406 "1n2csy99chk5v5vzjl0ff79vxpxhl76xmcb3aj6brrzzipmjz5xj")) 7422 "1n2csy99chk5v5vzjl0ff79vxpxhl76xmcb3aj6brrzzipmjz5xj"))
7407 7423
7424(define rust-either-1.12.0
7425 (crate-source "either" "1.12.0"
7426 "12xmhlrv5gfsraimh6xaxcmb0qh6cc7w7ap4sw40ky9wfm095jix"))
7427
7408(define rust-either-1.13.0 7428(define rust-either-1.13.0
7409 (crate-source "either" "1.13.0" 7429 (crate-source "either" "1.13.0"
7410 "1w2c1mybrd7vljyxk77y9f4w9dyjrmp3yp82mk7bcm8848fazcb0")) 7430 "1w2c1mybrd7vljyxk77y9f4w9dyjrmp3yp82mk7bcm8848fazcb0"))
@@ -8636,6 +8656,10 @@
8636 "0aqxjgghmn8javsc5jcvx8lqpcrzajndl7v6q1j47zz87xmy2mrf" 8656 "0aqxjgghmn8javsc5jcvx8lqpcrzajndl7v6q1j47zz87xmy2mrf"
8637 #:snippet '(delete-file-recursively "images"))) 8657 #:snippet '(delete-file-recursively "images")))
8638 8658
8659(define rust-foreign-0.3.1
8660 (crate-source "foreign" "0.3.1"
8661 "0ijqb18gllqr0319brxsrjdb036cgaf81wc6ygd21ly9x1dipjhp"))
8662
8639(define rust-foreign-types-0.3.2 8663(define rust-foreign-types-0.3.2
8640 (crate-source "foreign-types" "0.3.2" 8664 (crate-source "foreign-types" "0.3.2"
8641 "1cgk0vyd7r45cj769jym4a6s7vwshvd0z4bqrb92q1fwibmkkwzn")) 8665 "1cgk0vyd7r45cj769jym4a6s7vwshvd0z4bqrb92q1fwibmkkwzn"))
@@ -15649,6 +15673,10 @@
15649 (crate-source "libc" "0.2.155" 15673 (crate-source "libc" "0.2.155"
15650 "0z44c53z54znna8n322k5iwg80arxxpdzjj5260pxxzc9a58icwp")) 15674 "0z44c53z54znna8n322k5iwg80arxxpdzjj5260pxxzc9a58icwp"))
15651 15675
15676(define rust-libc-0.2.162
15677 (crate-source "libc" "0.2.162"
15678 "1633a00yyx45kzx9r54fndvr8njsjqyr7zl12mzgsmgyczg8glhq"))
15679
15652(define rust-libc-0.2.169 15680(define rust-libc-0.2.169
15653 (crate-source "libc" "0.2.169" 15681 (crate-source "libc" "0.2.169"
15654 "02m253hs8gw0m1n8iyrsc4n15yzbqwhddi7w1l0ds7i92kdsiaxm")) 15682 "02m253hs8gw0m1n8iyrsc4n15yzbqwhddi7w1l0ds7i92kdsiaxm"))
@@ -30283,6 +30311,10 @@
30283 "0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k" 30311 "0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k"
30284 #:snippet '(delete-file-recursively "tests"))) 30312 #:snippet '(delete-file-recursively "tests")))
30285 30313
30314(define rust-unicode-ident-1.0.12-unpatched
30315 (crate-source "unicode-ident" "1.0.12"
30316 "0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k"))
30317
30286(define rust-unicode-ident-1.0.13 30318(define rust-unicode-ident-1.0.13
30287 (crate-source "unicode-ident" "1.0.13" 30319 (crate-source "unicode-ident" "1.0.13"
30288 "1zm1xylzsdfvm2a5ib9li3g5pp7qnkv4amhspydvgbmd9k6mc6z9" 30320 "1zm1xylzsdfvm2a5ib9li3g5pp7qnkv4amhspydvgbmd9k6mc6z9"
@@ -68185,6 +68217,43 @@
68185 rust-windows-result-0.4.1 68217 rust-windows-result-0.4.1
68186 rust-windows-strings-0.5.1 68218 rust-windows-strings-0.5.1
68187 rust-zxcvbn-3.1.0)) 68219 rust-zxcvbn-3.1.0))
68220 (qemu =>
68221 (list rust-anyhow-1.0.98
68222 rust-arbitrary-int-1.2.7
68223 rust-attrs-0.2.9
68224 rust-bilge-0.2.0
68225 rust-bilge-impl-0.2.0
68226 rust-cfg-expr-0.20.3
68227 rust-either-1.12.0
68228 rust-equivalent-1.0.2
68229 rust-foreign-0.3.1
68230 rust-glib-sys-0.21.2
68231 rust-hashbrown-0.16.0
68232 rust-heck-0.5.0
68233 rust-indexmap-2.11.4
68234 rust-itertools-0.11.0
68235 rust-libc-0.2.162
68236 rust-memchr-2.7.6
68237 rust-pkg-config-0.3.32
68238 rust-proc-macro-error-1.0.4
68239 rust-proc-macro-error-attr-1.0.4
68240 rust-proc-macro2-1.0.95
68241 rust-quote-1.0.36
68242 rust-serde-1.0.226
68243 rust-serde-core-1.0.226
68244 rust-serde-derive-1.0.226
68245 rust-serde-spanned-0.6.9
68246 rust-smallvec-1.15.1
68247 rust-syn-2.0.104
68248 rust-system-deps-7.0.5
68249 rust-target-lexicon-0.13.2
68250 rust-toml-0.8.23
68251 rust-toml-datetime-0.6.11
68252 rust-toml-edit-0.22.27
68253 rust-unicode-ident-1.0.12-unpatched
68254 rust-version-compare-0.2.0
68255 rust-version-check-0.9.4
68256 rust-winnow-0.7.13))
68188 (rabbitmqadmin => 68257 (rabbitmqadmin =>
68189 (list rust-addr2line-0.24.2 68258 (list rust-addr2line-0.24.2
68190 rust-adler2-2.0.1 68259 rust-adler2-2.0.1
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 270565bb8ea..858a3fe92db 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -161,6 +161,8 @@
161 #:use-module (gnu packages ruby) 161 #:use-module (gnu packages ruby)
162 #:use-module (gnu packages ruby-check) 162 #:use-module (gnu packages ruby-check)
163 #:use-module (gnu packages ruby-xyz) 163 #:use-module (gnu packages ruby-xyz)
164 #:use-module (gnu packages rust)
165 #:use-module (gnu packages rust-apps)
164 #:use-module (gnu packages rsync) 166 #:use-module (gnu packages rsync)
165 #:use-module (gnu packages sdl) 167 #:use-module (gnu packages sdl)
166 #:use-module (gnu packages selinux) 168 #:use-module (gnu packages selinux)
@@ -217,6 +219,9 @@
217 (modules '((guix build utils))) 219 (modules '((guix build utils)))
218 (snippet 220 (snippet
219 '(begin 221 '(begin
222 ;; Delete the bundled rust crates.
223 (delete-file-recursively "subprojects/packagecache")
224 (mkdir-p "subprojects/packagecache")
220 ;; TODO: Scrub all firmwares from this directory! 225 ;; TODO: Scrub all firmwares from this directory!
221 (with-directory-excursion "pc-bios" 226 (with-directory-excursion "pc-bios"
222 ;; Delete firmwares provided by SeaBIOS. 227 ;; Delete firmwares provided by SeaBIOS.
@@ -261,28 +266,34 @@
261 "share/qemu/pxe-virtio.rom")) 266 "share/qemu/pxe-virtio.rom"))
262 #~((string-append #$output "/share/qemu")))) 267 #~((string-append #$output "/share/qemu"))))
263 (out #$output)) 268 (out #$output))
264 (list (string-append "--cc=" gcc) 269 (cons* (string-append "--cc=" gcc)
265 ;; Some architectures insist on using HOST_CC. 270 ;; Some architectures insist on using HOST_CC.
266 (string-append "--host-cc=" gcc) 271 (string-append "--host-cc=" gcc)
267 (string-append "--prefix=" out) 272 (string-append "--prefix=" out)
268 "--sysconfdir=/etc" 273 "--sysconfdir=/etc"
269 "--enable-fdt=system" 274 "--enable-fdt=system"
270 (string-append "--firmwarepath=" out "/share/qemu:" 275 (string-append "--firmwarepath=" out "/share/qemu:"
271 (dirname seabios) ":" 276 (dirname seabios) ":"
272 (dirname ipxe) ":" 277 (dirname ipxe) ":"
273 (dirname openbios) ":" 278 (dirname openbios) ":"
274 (dirname opensbi)) 279 (dirname opensbi))
275 (string-append "--smbd=" out "/libexec/samba-wrapper") 280 (string-append "--smbd=" out "/libexec/samba-wrapper")
276 "--disable-debug-info" ;for space considerations 281 "--disable-debug-info" ;for space considerations
277 ;; The binaries need to be linked against -lrt. 282 ;; The binaries need to be linked against -lrt.
278 (string-append "--extra-ldflags=-lrt"))) 283 (string-append "--extra-ldflags=-lrt")
284 #$@(if (this-package-native-input "rust")
285 #~((list "--enable-rust"))
286 #~((list)))))
279 ;; Make build and test output verbose to facilitate investigation upon failure. 287 ;; Make build and test output verbose to facilitate investigation upon failure.
280 #:make-flags #~'("V=1") 288 #:make-flags #~'("V=1")
281 #:modules `((srfi srfi-1) 289 #:modules `((srfi srfi-1)
282 (srfi srfi-26) 290 (srfi srfi-26)
283 (ice-9 ftw) 291 (ice-9 ftw)
284 (ice-9 match) 292 (ice-9 match)
293 ((guix build cargo-build-system) #:prefix cargo:)
285 ,@%default-gnu-modules) 294 ,@%default-gnu-modules)
295 #:imported-modules `(,@%cargo-build-system-modules
296 ,@%default-gnu-imported-modules)
286 #:phases 297 #:phases
287 #~(modify-phases %standard-phases 298 #~(modify-phases %standard-phases
288 ;; Since we removed the bundled firmwares above, many tests 299 ;; Since we removed the bundled firmwares above, many tests
@@ -325,6 +336,29 @@
325 "\"~a\",~%" file)) 336 "\"~a\",~%" file))
326 allowed-differences) 337 allowed-differences)
327 (close-port allowed-differences-whitelist)))) 338 (close-port allowed-differences-whitelist))))
339 #$@(if (this-package-native-input "rust")
340 #~((add-after 'unpack 'prepare-rust-crates
341 (lambda args
342 (apply (assoc-ref cargo:%standard-phases
343 'prepare-rust-crates)
344 args)
345 ;; Use /tmp/rust-crates as the source.
346 (substitute* (find-files "subprojects" "-rs\\.wrap$")
347 (("source_url = (.*)" _ url)
348 (let ((split-url (string-split url #\/)))
349 (string-append
350 "source_url = file:///tmp/rust-crates/rust-"
351 (list-ref split-url 6) "-"
352 (list-ref split-url 7) ".tar.gz\n"))))
353 ;; "Download" the packages.
354 (for-each
355 (lambda (wrapper)
356 (invoke "meson" "subprojects" "download"
357 (string-drop-right wrapper 5)))
358 (scandir "subprojects"
359 (lambda (file)
360 (string-suffix? "-rs.wrap" file)))))))
361 #~())
328 ;; If the ipxe firmware isn't available, remove it from the list 362 ;; If the ipxe firmware isn't available, remove it from the list
329 ;; of files expected to be available and remove some of the tests. 363 ;; of files expected to be available and remove some of the tests.
330 #$@(if (not (this-package-input "ipxe-qemu")) 364 #$@(if (not (this-package-input "ipxe-qemu"))
@@ -587,27 +621,38 @@ exec smbd $@")))
587 zlib 621 zlib
588 `(,zstd "lib")))) 622 `(,zstd "lib"))))
589 (native-inputs 623 (native-inputs
590 ;; Note: acpica is here only to pretty-print firmware differences with IASL 624 (append
591 ;; (see the replace-firmwares phase above). 625 ;; The rust code doesn't seem to be in use yet.
592 (list acpica 626 (if #f ;(supported-package? rust)
593 bison 627 (append
594 flex 628 (cons* rust
595 gettext-minimal 629 rust-bindgen-cli
596 `(,glib "bin") ;gtester, etc. 630 (cargo-inputs 'qemu))
597 meson 631 (or (and=> (%current-target-system)
598 ninja 632 (compose list make-rust-sysroot))
599 perl 633 '()))
600 pkg-config 634 '())
601 python-wrapper 635 ;; Note: acpica is here only to pretty-print firmware differences with
602 python-sphinx 636 ;; IASL (see the replace-firmwares phase above).
603 python-sphinx-rtd-theme 637 (list acpica
604 python-tomli 638 bison
605 texinfo 639 flex
606 ;; The following static libraries are required to build 640 gettext-minimal
607 ;; the static output of QEMU. 641 `(,glib "bin") ;gtester, etc.
608 `(,glib "static") 642 meson
609 `(,pcre2 "static") 643 ninja
610 `(,zlib "static"))) 644 perl
645 pkg-config
646 python-wrapper
647 python-sphinx
648 python-sphinx-rtd-theme
649 python-tomli
650 texinfo
651 ;; The following static libraries are required to build
652 ;; the static output of QEMU.
653 `(,glib "static")
654 `(,pcre2 "static")
655 `(,zlib "static"))))
611 (home-page "https://www.qemu.org") 656 (home-page "https://www.qemu.org")
612 (synopsis "Machine emulator and virtualizer") 657 (synopsis "Machine emulator and virtualizer")
613 (description 658 (description