~ruther/guix-local

4e8eab6fe433ada4717250b4a682c4a8c79ced3e — Hilton Chain 1 year, 1 month ago 765a369
build/cargo: Accept rust-sysroot from native-inputs.

This is a workaround to support Rust cross-compilation in build systems other
than cargo-build-system.  Since there's no interface for target-inputs, using
native-inputs makes most sense.

* guix/build-system/cargo.scm (lower)[bag]<target-inputs>: Label rust-sysroot
with its package name.
* guix/build/cargo-build-system.scm (configure): Use it.
When cross-compiling, accept rust-sysroot from native-inputs if there's none
in inputs.

Change-Id: I5cb63c8c815d3a2c9f0ece01857254f6d0090dd1
2 files changed, 13 insertions(+), 5 deletions(-)

M guix/build-system/cargo.scm
M guix/build/cargo-build-system.scm
M guix/build-system/cargo.scm => guix/build-system/cargo.scm +2 -1
@@ 430,7 430,8 @@ any dependent crates. This can be a benefits:

                     ;; This provides a separate sysroot for the regular rustc
                     ,@(if target
                         `(("rust-sysroot" ,(rust-sysroot target)))
                         `((,(string-append "rust-sysroot-for-" target)
                            ,(rust-sysroot target)))
                         '())))
    (outputs outputs)
    (build (if target cargo-cross-build cargo-build))

M guix/build/cargo-build-system.scm => guix/build/cargo-build-system.scm +11 -4
@@ 157,7 157,7 @@ libraries or executables."
         (format #t "error: Possible pre-generated file found: ~a~%" file)))
     (find-files "." (negate empty-file?)))))

(define* (configure #:key source inputs
(define* (configure #:key source inputs native-inputs
                    target system
                    (cargo-target #f)
                    (vendor-dir "guix-vendor")


@@ 194,9 194,16 @@ libraries or executables."
  ;; For cross-building
  (when target
    (setenv "CARGO_BUILD_TARGET" cargo-target)
    (setenv "RUSTFLAGS" (string-append
                          (or (getenv "RUSTFLAGS") "")
                          " --sysroot " (assoc-ref inputs "rust-sysroot")))
    (setenv "RUSTFLAGS"
            (string-append
             (or (getenv "RUSTFLAGS") "")
             " --sysroot "
             (assoc-ref
              (append inputs
                      ;; Workaround for other build systems, as no interface
                      ;; is available for target-inputs.
                      (or native-inputs '()))
              (string-append "rust-sysroot-for-" target))))

    (setenv "PKG_CONFIG" (string-append target "-pkg-config"))