all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using cross-compiler and host compiler in the same package
@ 2017-03-07 21:08 Danny Milosavljevic
  2017-03-19 16:25 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Milosavljevic @ 2017-03-07 21:08 UTC (permalink / raw)
  To: guix-devel

Hi,

I wanted to make sunxi-tools also compile the target tools.

If one is on a non-armhf architecture some of the programs need to be compiled with an armhf cross compiler and some (almost all) need to be compiled using the host compiler.  Since the cross compiler is called "arm-linux-gnueabihf-gcc" and not "gcc" (like the host compiler) that part is no problem.  However, I also require armhf libc (to be linked statically) and that doesn't work since one of the gccs always seems to pick up the wrong libc.

How can I fix it?

(define-module (wip admin)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages cross-base)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages pkg-config))

(define-public sunxi-tools
  (package
    (name "sunxi-toolsx")
    (version "1.4.2")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/linux-sunxi/"
                           "sunxi-tools/archive/v" version ".tar.gz"))
       (sha256
        (base32 "08iqwj95qw2s7ilhrdi2lkbc8dx64zk5lzz1qk587jr0lla81x41"))
       (modules '((guix build utils)))
       (snippet
        ;; Remove binaries contained in the tarball which are only for the
        ;; target and can be regenerated anyway.
        '(delete-file-recursively "bin"))
       (file-name (string-append name "-" version ".tar.gz"))))
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))))
    (inputs
     `(("libusb" ,libusb)))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f ; no tests exist
       #:make-flags (list (string-append "PREFIX="
                                         (assoc-ref %outputs "out"))
                          (string-append "CROSS_COMPILE="
                                         "arm-linux-gnueabihf-")
                          "CC=gcc"
                          "all")
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (replace 'install
           (lambda* (#:key make-flags #:allow-other-keys)
             (zero? (apply system* "make" "install-all" "install-misc"
                           make-flags)))))))
    (home-page "https://github.com/linux-sunxi/sunxi-tools")
    (synopsis "Hardware management tools for Allwinner computers")
    (description "This package contains tools for Allwinner devices:
@enumerate
@item @command{sunxi-fexc}, @command{bin2fex}, @command{fex2bin}: Compile
a textual description of a board (.fex) to a binary representation (.bin).
@item @command{sunxi-fel}: Puts an Allwinner device into FEL mode which
makes it register as a special USB device (rather than USB host).
You can then connect it to another computer and flash it from there.
@item @command{sunxi-nand-part}: Partitions NAND flash.
@item @command{sunxi-bootinfo}: Reads out boot0 and boot1 (Allwinner
bootloader) parameters.
@item @command{sunxi-pio}: Sets GPIO parameters and oscillates a GPIO
@item @command{sunxi-meminfo}: Prints memory bus settings.
@item @command{sunxi-nand-image-builder}: Prepares raw NAND images.
@end enumerate")
    (license license:gpl2+)))

(Also, if I try to put that into gnu/packages/admin.scm , I get some circular module dependency problem again... sigh)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Using cross-compiler and host compiler in the same package
  2017-03-07 21:08 Using cross-compiler and host compiler in the same package Danny Milosavljevic
@ 2017-03-19 16:25 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-03-19 16:25 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi Danny,

Sorry for the delay…

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> I wanted to make sunxi-tools also compile the target tools.
>
> If one is on a non-armhf architecture some of the programs need to be compiled with an armhf cross compiler and some (almost all) need to be compiled using the host compiler.  Since the cross compiler is called "arm-linux-gnueabihf-gcc" and not "gcc" (like the host compiler) that part is no problem.  However, I also require armhf libc (to be linked statically) and that doesn't work since one of the gccs always seems to pick up the wrong libc.
>
> How can I fix it?

[...]

>     (native-inputs
>      `(("pkg-config" ,pkg-config)
>        ("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))))

‘cross-gcc’ takes an optional ‘libc’ argument.  Would it work to do:

  (let ((triplet "arm-linux-gnueabihf"))
    (cross-gcc triplet (cross-binutils triplet) (cross-libc triplet)))

?

> (Also, if I try to put that into gnu/packages/admin.scm , I get some circular module dependency problem again... sigh)

Hmm, not sure why this happens.

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-19 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-07 21:08 Using cross-compiler and host compiler in the same package Danny Milosavljevic
2017-03-19 16:25 ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.