all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Cross-compiling parts and not cross-compiling other parts of a package
@ 2017-09-04 13:57 Danny Milosavljevic
  2017-09-05 12:32 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Milosavljevic @ 2017-09-04 13:57 UTC (permalink / raw)
  To: guix-devel

Hi,

I've now needed custom modifications in order to enable cross-compilation of a part of a package in two packages, sunxi-tools and rustc.

Both have this part in a custom phase:

             (define (cross? x)
               (string-contains x "cross-"))
             (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
             (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
             (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
             (for-each
              (lambda (env-name)
                (let* ((env-value (getenv env-name))
                       (search-path (search-path-as-string->list env-value))
                       (new-search-path (filter (lambda (e) (not (cross? e)))
                                                search-path))
                       (new-env-value (list->search-path-as-string
                                       new-search-path ":")))
                  (setenv env-name new-env-value)))
              '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH"))

Would it be possible and advisable to have this as a default phase one day?

Regardless of whether default or not, it can then be used like this:

(native-inputs
...
       ("cross-gcc" ,(cross-gcc "i686-linux-gnu"
                      #:xbinutils (cross-binutils "i686-linux-gnu")
                      #:libc (cross-libc "i686-linux-gnu")))
       ("cross-libc" ,(cross-libc "i686-linux-gnu")))))

The cross-* compilers would use the CROSS_* environment variables and the native compiler would use the non-CROSS_* environment variables.

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

* Re: Cross-compiling parts and not cross-compiling other parts of a package
  2017-09-04 13:57 Cross-compiling parts and not cross-compiling other parts of a package Danny Milosavljevic
@ 2017-09-05 12:32 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-09-05 12:32 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> I've now needed custom modifications in order to enable cross-compilation of a part of a package in two packages, sunxi-tools and rustc.
>
> Both have this part in a custom phase:
>
>              (define (cross? x)
>                (string-contains x "cross-"))
>              (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
>              (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
>              (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
>              (for-each
>               (lambda (env-name)
>                 (let* ((env-value (getenv env-name))
>                        (search-path (search-path-as-string->list env-value))
>                        (new-search-path (filter (lambda (e) (not (cross? e)))
>                                                 search-path))
>                        (new-env-value (list->search-path-as-string
>                                        new-search-path ":")))
>                   (setenv env-name new-env-value)))
>               '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH"))
>
> Would it be possible and advisable to have this as a default phase one day?

Good question.  Probably not as a default, because in general you do
*not* want the CROSS_ search paths to be the same as the native search
paths.

Why it works at all in this case is a mystery to me.  For example, the
cross compiler probably picks up the native headers instead of the
target headers; in many cases they are the same, so that’s OK, but for
libc/Linux, they are different.  Likewise, it might be that ‘ld’ skips
incompatible libraries found in the search path, but that’s luck more
than anything else.

So it seems that this particular use case isn’t well served, but the
above snippet looks risky to me.

WDYT?

Ludo’.

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

end of thread, other threads:[~2017-09-05 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-04 13:57 Cross-compiling parts and not cross-compiling other parts of a package Danny Milosavljevic
2017-09-05 12:32 ` 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.