1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

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>
This commit is contained in:
Efraim Flashner
2026-03-04 17:44:22 +02:00
parent 3691bb640d
commit 7095f1b42e
2 changed files with 150 additions and 36 deletions

View File

@@ -752,6 +752,10 @@
(crate-source "arbitrary" "1.4.2"
"1wcbi4x7i3lzcrkjda4810nqv03lpmvfhb0a85xrq1mbqjikdl63"))
(define rust-arbitrary-int-1.2.7
(crate-source "arbitrary-int" "1.2.7"
"0vgl3n5zzpdn2hxpz6gqk8zg2psk5gwyjzsgpngzd9iqwc1w0ky8"))
(define rust-arboard-3.5.0
(crate-source "arboard" "3.5.0"
"0w1yqcx51153hy5w3y0702xjc9nmlhncw9f5l0rdwbl62pvj3py1"))
@@ -1476,6 +1480,10 @@
(crate-source "attribute-derive-macro" "0.10.3"
"06zph2lyllkp6g1lsv7v4p84dnglbw2gw58r9fpn1d6m1ynm6fs6"))
(define rust-attrs-0.2.9
(crate-source "attrs" "0.2.9"
"0pvy6b7arfr2f6awwkw6k1hc8sxidjxhj1fyyf2m5rixyi07s81a"))
(define rust-atty-0.2.11
(crate-source "atty" "0.2.11"
"0lln6vaczj521qqjbaqnb81w5p6xk4fjfkg33r0m22cm4f3mnzcs"))
@@ -2174,6 +2182,14 @@
(crate-source "bigdecimal" "0.4.10"
"159nc0bs6bbzxrpfxbnn83ccyzq8bc2ia40zd22ssfjvavqnfs2d"))
(define rust-bilge-0.2.0
(crate-source "bilge" "0.2.0"
"0mvvwq9caiq701bmmwyd4q4pc8c69i5zaj3zdk6ya7gqxgc7ww6w"))
(define rust-bilge-impl-0.2.0
(crate-source "bilge-impl" "0.2.0"
"1n5jml0c1z0np76ms0h5rxx19krblz46h84wycx29b9q4001xcgy"))
(define rust-binascii-0.1.4
(crate-source "binascii" "0.1.4"
"0wnaglgl72pn5ilv61q6y34w76gbg7crb8ifqk6lsxnq2gajjg9q"))
@@ -7405,6 +7421,10 @@
(crate-source "ego-tree" "0.10.0"
"1n2csy99chk5v5vzjl0ff79vxpxhl76xmcb3aj6brrzzipmjz5xj"))
(define rust-either-1.12.0
(crate-source "either" "1.12.0"
"12xmhlrv5gfsraimh6xaxcmb0qh6cc7w7ap4sw40ky9wfm095jix"))
(define rust-either-1.13.0
(crate-source "either" "1.13.0"
"1w2c1mybrd7vljyxk77y9f4w9dyjrmp3yp82mk7bcm8848fazcb0"))
@@ -8636,6 +8656,10 @@
"0aqxjgghmn8javsc5jcvx8lqpcrzajndl7v6q1j47zz87xmy2mrf"
#:snippet '(delete-file-recursively "images")))
(define rust-foreign-0.3.1
(crate-source "foreign" "0.3.1"
"0ijqb18gllqr0319brxsrjdb036cgaf81wc6ygd21ly9x1dipjhp"))
(define rust-foreign-types-0.3.2
(crate-source "foreign-types" "0.3.2"
"1cgk0vyd7r45cj769jym4a6s7vwshvd0z4bqrb92q1fwibmkkwzn"))
@@ -15649,6 +15673,10 @@
(crate-source "libc" "0.2.155"
"0z44c53z54znna8n322k5iwg80arxxpdzjj5260pxxzc9a58icwp"))
(define rust-libc-0.2.162
(crate-source "libc" "0.2.162"
"1633a00yyx45kzx9r54fndvr8njsjqyr7zl12mzgsmgyczg8glhq"))
(define rust-libc-0.2.169
(crate-source "libc" "0.2.169"
"02m253hs8gw0m1n8iyrsc4n15yzbqwhddi7w1l0ds7i92kdsiaxm"))
@@ -30283,6 +30311,10 @@
"0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k"
#:snippet '(delete-file-recursively "tests")))
(define rust-unicode-ident-1.0.12-unpatched
(crate-source "unicode-ident" "1.0.12"
"0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k"))
(define rust-unicode-ident-1.0.13
(crate-source "unicode-ident" "1.0.13"
"1zm1xylzsdfvm2a5ib9li3g5pp7qnkv4amhspydvgbmd9k6mc6z9"
@@ -68185,6 +68217,43 @@
rust-windows-result-0.4.1
rust-windows-strings-0.5.1
rust-zxcvbn-3.1.0))
(qemu =>
(list rust-anyhow-1.0.98
rust-arbitrary-int-1.2.7
rust-attrs-0.2.9
rust-bilge-0.2.0
rust-bilge-impl-0.2.0
rust-cfg-expr-0.20.3
rust-either-1.12.0
rust-equivalent-1.0.2
rust-foreign-0.3.1
rust-glib-sys-0.21.2
rust-hashbrown-0.16.0
rust-heck-0.5.0
rust-indexmap-2.11.4
rust-itertools-0.11.0
rust-libc-0.2.162
rust-memchr-2.7.6
rust-pkg-config-0.3.32
rust-proc-macro-error-1.0.4
rust-proc-macro-error-attr-1.0.4
rust-proc-macro2-1.0.95
rust-quote-1.0.36
rust-serde-1.0.226
rust-serde-core-1.0.226
rust-serde-derive-1.0.226
rust-serde-spanned-0.6.9
rust-smallvec-1.15.1
rust-syn-2.0.104
rust-system-deps-7.0.5
rust-target-lexicon-0.13.2
rust-toml-0.8.23
rust-toml-datetime-0.6.11
rust-toml-edit-0.22.27
rust-unicode-ident-1.0.12-unpatched
rust-version-compare-0.2.0
rust-version-check-0.9.4
rust-winnow-0.7.13))
(rabbitmqadmin =>
(list rust-addr2line-0.24.2
rust-adler2-2.0.1

View File

@@ -161,6 +161,8 @@
#:use-module (gnu packages ruby)
#:use-module (gnu packages ruby-check)
#:use-module (gnu packages ruby-xyz)
#:use-module (gnu packages rust)
#:use-module (gnu packages rust-apps)
#:use-module (gnu packages rsync)
#:use-module (gnu packages sdl)
#:use-module (gnu packages selinux)
@@ -217,6 +219,9 @@
(modules '((guix build utils)))
(snippet
'(begin
;; Delete the bundled rust crates.
(delete-file-recursively "subprojects/packagecache")
(mkdir-p "subprojects/packagecache")
;; TODO: Scrub all firmwares from this directory!
(with-directory-excursion "pc-bios"
;; Delete firmwares provided by SeaBIOS.
@@ -261,28 +266,34 @@
"share/qemu/pxe-virtio.rom"))
#~((string-append #$output "/share/qemu"))))
(out #$output))
(list (string-append "--cc=" gcc)
;; Some architectures insist on using HOST_CC.
(string-append "--host-cc=" gcc)
(string-append "--prefix=" out)
"--sysconfdir=/etc"
"--enable-fdt=system"
(string-append "--firmwarepath=" out "/share/qemu:"
(dirname seabios) ":"
(dirname ipxe) ":"
(dirname openbios) ":"
(dirname opensbi))
(string-append "--smbd=" out "/libexec/samba-wrapper")
"--disable-debug-info" ;for space considerations
;; The binaries need to be linked against -lrt.
(string-append "--extra-ldflags=-lrt")))
(cons* (string-append "--cc=" gcc)
;; Some architectures insist on using HOST_CC.
(string-append "--host-cc=" gcc)
(string-append "--prefix=" out)
"--sysconfdir=/etc"
"--enable-fdt=system"
(string-append "--firmwarepath=" out "/share/qemu:"
(dirname seabios) ":"
(dirname ipxe) ":"
(dirname openbios) ":"
(dirname opensbi))
(string-append "--smbd=" out "/libexec/samba-wrapper")
"--disable-debug-info" ;for space considerations
;; The binaries need to be linked against -lrt.
(string-append "--extra-ldflags=-lrt")
#$@(if (this-package-native-input "rust")
#~((list "--enable-rust"))
#~((list)))))
;; Make build and test output verbose to facilitate investigation upon failure.
#:make-flags #~'("V=1")
#:modules `((srfi srfi-1)
(srfi srfi-26)
(ice-9 ftw)
(ice-9 match)
((guix build cargo-build-system) #:prefix cargo:)
,@%default-gnu-modules)
#:imported-modules `(,@%cargo-build-system-modules
,@%default-gnu-imported-modules)
#:phases
#~(modify-phases %standard-phases
;; Since we removed the bundled firmwares above, many tests
@@ -325,6 +336,29 @@
"\"~a\",~%" file))
allowed-differences)
(close-port allowed-differences-whitelist))))
#$@(if (this-package-native-input "rust")
#~((add-after 'unpack 'prepare-rust-crates
(lambda args
(apply (assoc-ref cargo:%standard-phases
'prepare-rust-crates)
args)
;; Use /tmp/rust-crates as the source.
(substitute* (find-files "subprojects" "-rs\\.wrap$")
(("source_url = (.*)" _ url)
(let ((split-url (string-split url #\/)))
(string-append
"source_url = file:///tmp/rust-crates/rust-"
(list-ref split-url 6) "-"
(list-ref split-url 7) ".tar.gz\n"))))
;; "Download" the packages.
(for-each
(lambda (wrapper)
(invoke "meson" "subprojects" "download"
(string-drop-right wrapper 5)))
(scandir "subprojects"
(lambda (file)
(string-suffix? "-rs.wrap" file)))))))
#~())
;; If the ipxe firmware isn't available, remove it from the list
;; of files expected to be available and remove some of the tests.
#$@(if (not (this-package-input "ipxe-qemu"))
@@ -587,27 +621,38 @@ exec smbd $@")))
zlib
`(,zstd "lib"))))
(native-inputs
;; Note: acpica is here only to pretty-print firmware differences with IASL
;; (see the replace-firmwares phase above).
(list acpica
bison
flex
gettext-minimal
`(,glib "bin") ;gtester, etc.
meson
ninja
perl
pkg-config
python-wrapper
python-sphinx
python-sphinx-rtd-theme
python-tomli
texinfo
;; The following static libraries are required to build
;; the static output of QEMU.
`(,glib "static")
`(,pcre2 "static")
`(,zlib "static")))
(append
;; The rust code doesn't seem to be in use yet.
(if #f ;(supported-package? rust)
(append
(cons* rust
rust-bindgen-cli
(cargo-inputs 'qemu))
(or (and=> (%current-target-system)
(compose list make-rust-sysroot))
'()))
'())
;; Note: acpica is here only to pretty-print firmware differences with
;; IASL (see the replace-firmwares phase above).
(list acpica
bison
flex
gettext-minimal
`(,glib "bin") ;gtester, etc.
meson
ninja
perl
pkg-config
python-wrapper
python-sphinx
python-sphinx-rtd-theme
python-tomli
texinfo
;; The following static libraries are required to build
;; the static output of QEMU.
`(,glib "static")
`(,pcre2 "static")
`(,zlib "static"))))
(home-page "https://www.qemu.org")
(synopsis "Machine emulator and virtualizer")
(description