all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 'guix build --target=' handling questions
@ 2017-02-21 21:40 Sergei Trofimovich
  2017-02-22 22:54 ` Sergei Trofimovich
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Trofimovich @ 2017-02-21 21:40 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]

Hia!

Before asking my questions I'll setup the scene first.

The scene:

I'm playing with cross-compiler support in guix.

[ x86_64 -> alpha target as an example with
  this tiny patch: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25799 ]

I've stumbled upon the two cases: working[1] and non-working[2].

[1] working:
  $ ./pre-inst-env guix build --check re2c --target=alpha-unknown-linux-gnu --no-grafts
  ...
  /gnu/store/15ibxf5xzcqzfx0xgb5s6qa5z2ah3avg-re2c-0.16
  $ file /gnu/store/15ibxf5xzcqzfx0xgb5s6qa5z2ah3avg-re2c-0.16/bin/re2c 
  /gnu/store/15ibxf5xzcqzfx0xgb5s6qa5z2ah3avg-re2c-0.16/bin/re2c: ELF 64-bit LSB executable,
Works as expected.

[2] non-working:
  $ ./pre-inst-env guix build --check re2 --target=alpha-unknown-linux-gnu --no-grafts
  ...
  /gnu/store/mg474j0gx56fdl6wrpaxxxwsdknl7k2i-re2-2017-01-01
  $ file /gnu/store/mg474j0gx56fdl6wrpaxxxwsdknl7k2i-re2-2017-01-01/lib/libre2.so.0.0.0 
  /gnu/store/mg474j0gx56fdl6wrpaxxxwsdknl7k2i-re2-2017-01-01/lib/libre2.so.0.0.0: ELF 64-bit LSB shared object, x86-64

It seems that re2 derivation ignores --target
and builds it's library with host compiler, not target compiler.

Relevant re2 package snippet from
    http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/regex.scm#n27

     (build-system gnu-build-system)
     (arguments
      `(#:test-target "test"
        ;; There is no configure step, but the Makefile respects a prefix.
        #:make-flags (list (string-append "prefix=" %output))
        #:phases
        (modify-phases %standard-phases
          (delete 'configure)

As we see here definition skips ./configure step (that's ok)
and does not pass CXX=${target}-g++ to make flag.

I wonder what are the possible options to override CXX here?

Makefile for re2 is very straightforward:
    CXX?=g++
    ...
    obj/%.o: %.cc $(HFILES)
    <tab>@mkdir -p $$(dirname $@)
    <tab>$(CXX) -c -o $@ $(CPPFLAGS) $(RE2_CXXFLAGS) $(CXXFLAGS) -DNDEBUG $*.cc
    ...
    obj/so/libre2.$(SOEXT): $(SOFILES)
    <tab>@mkdir -p obj/so
    <tab>$(MAKE_SHARED_LIBRARY) -o obj/so/libre2.$(SOEXTVER) $(SOFILES)
    <tab>ln -sf libre2.$(SOEXTVER) $@

Question time:

- Is there a way to run 'guix environment --target=' in the same way as 'guix build --target='
  sets it up? I'd like to see how both compilers are supposed to be present in there.

- Why default g++ in PATH is the host g++ and not target g++?
  Target seems to make most sense if no explicit compiler is specified.

- How to actually set CXX to point to target g++?
  It looks like implicitly there already both host (through native-inputs)
  and target (through build-inputs) compilers available.
  I would expect something like
      #:make-flags (list (string-append "CXX=" <.?.>)) 
  What should be in place of that "<.?.>" to refer to target g++?

Thank you!

-- 

  Sergei

[-- Attachment #2: Цифровая подпись OpenPGP --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

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

* Re: 'guix build --target=' handling questions
  2017-02-21 21:40 'guix build --target=' handling questions Sergei Trofimovich
@ 2017-02-22 22:54 ` Sergei Trofimovich
  2017-02-23 17:07   ` John Darrington
  2017-03-06 16:04   ` Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Sergei Trofimovich @ 2017-02-22 22:54 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2649 bytes --]

> Question time:
> 
> - Is there a way to run 'guix environment --target=' in the same way as 'guix build --target='
>   sets it up? I'd like to see how both compilers are supposed to be present in there.
>
> - Why default g++ in PATH is the host g++ and not target g++?
>   Target seems to make most sense if no explicit compiler is specified.
> 
> - How to actually set CXX to point to target g++?
>   It looks like implicitly there already both host (through native-inputs)
>   and target (through build-inputs) compilers available.
>   I would expect something like
>       #:make-flags (list (string-append "CXX=" <.?.>)) 
>   What should be in place of that "<.?.>" to refer to target g++?

I think I've found a workaround at least for my third question.

Both host and target compilers are available as g++ and ${target}-g++.

Thus the following workaround seems to work:

diff --git a/gnu/packages/regex.scm b/gnu/packages/regex.scm
index f04cba706..a8fa689ab 100644
--- a/gnu/packages/regex.scm
+++ b/gnu/packages/regex.scm
@@ -20,11 +20,13 @@

 (define-module (gnu packages regex)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (guix utils) ; for %current-target-system
+  )

 (define-public re2
    (package
      (name "re2")
      (version "2017-01-01")
@@ -40,11 +42,15 @@
                  "0yij1ajh66h3pj3kfz7y0ldrsww8rlpjzaavyr5lchl98as1jq74"))))
      (build-system gnu-build-system)
      (arguments
       `(#:test-target "test"
         ;; There is no configure step, but the Makefile respects a prefix.
-        #:make-flags (list (string-append "prefix=" %output))
+        #:make-flags (list (string-append "prefix=" %output)
+                           (string-append "CXX=" ,(string-append (if (%current-target-system)
+                                                                     (string-append (%current-target-system) "-")
+                                                                     "")
+                                                                 "g++")))
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)
           (add-after 'install 'delete-static-library
             (lambda* (#:key outputs #:allow-other-keys)

It looks clumsy and potentially requires more tools to be wrapped like that.

At least 'ar' for this package. Perhaps there is a function that already
adds a "${target}-" and I've missed it?

-- 

  Sergei

[-- Attachment #2: Цифровая подпись OpenPGP --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

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

* Re: 'guix build --target=' handling questions
  2017-02-22 22:54 ` Sergei Trofimovich
@ 2017-02-23 17:07   ` John Darrington
  2017-03-06 16:04   ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: John Darrington @ 2017-02-23 17:07 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2224 bytes --]

On Wed, Feb 22, 2017 at 10:54:22PM +0000, Sergei Trofimovich wrote:
     
      (define-module (gnu packages regex)
        #:use-module ((guix licenses) #:prefix license:)
        #:use-module (guix packages)
        #:use-module (guix download)
     -  #:use-module (guix build-system gnu))
     +  #:use-module (guix build-system gnu)
     +  #:use-module (guix utils) ; for %current-target-system
     +  )
     
      (define-public re2
         (package
           (name "re2")
           (version "2017-01-01")
     @@ -40,11 +42,15 @@
                       "0yij1ajh66h3pj3kfz7y0ldrsww8rlpjzaavyr5lchl98as1jq74"))))
           (build-system gnu-build-system)
           (arguments
            `(#:test-target "test"
              ;; There is no configure step, but the Makefile respects a prefix.
     -        #:make-flags (list (string-append "prefix=" %output))
     +        #:make-flags (list (string-append "prefix=" %output)
     +                           (string-append "CXX=" ,(string-append (if (%current-target-system)
     +                                                                     (string-append (%current-target-system) "-")
     +                                                                     "")
     +                                                                 "g++")))
              #:phases
              (modify-phases %standard-phases
                (delete 'configure)
                (add-after 'install 'delete-static-library
                  (lambda* (#:key outputs #:allow-other-keys)
     
     It looks clumsy and potentially requires more tools to be wrapped like that.
     
     At least 'ar' for this package. Perhaps there is a function that already
     adds a "${target}-" and I've missed it?
     

So far as I'm aware there is no better solution than what you have proposed.  It is a common
problem for packages which don't provide a proper autoconf ./configure script.

J'



-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: 'guix build --target=' handling questions
  2017-02-22 22:54 ` Sergei Trofimovich
  2017-02-23 17:07   ` John Darrington
@ 2017-03-06 16:04   ` Ludovic Courtès
  2017-03-06 22:01     ` Sergei Trofimovich
  1 sibling, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2017-03-06 16:04 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: guix-devel

Sergei Trofimovich <slyfox@inbox.ru> skribis:

>> Question time:
>> 
>> - Is there a way to run 'guix environment --target=' in the same way as 'guix build --target='
>>   sets it up? I'd like to see how both compilers are supposed to be present in there.
>>
>> - Why default g++ in PATH is the host g++ and not target g++?
>>   Target seems to make most sense if no explicit compiler is specified.
>> 
>> - How to actually set CXX to point to target g++?
>>   It looks like implicitly there already both host (through native-inputs)
>>   and target (through build-inputs) compilers available.
>>   I would expect something like
>>       #:make-flags (list (string-append "CXX=" <.?.>)) 
>>   What should be in place of that "<.?.>" to refer to target g++?
>
> I think I've found a workaround at least for my third question.
>
> Both host and target compilers are available as g++ and ${target}-g++.
>
> Thus the following workaround seems to work:
>
> diff --git a/gnu/packages/regex.scm b/gnu/packages/regex.scm
> index f04cba706..a8fa689ab 100644
> --- a/gnu/packages/regex.scm
> +++ b/gnu/packages/regex.scm
> @@ -20,11 +20,13 @@
>
>  (define-module (gnu packages regex)
>    #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (guix packages)
>    #:use-module (guix download)
> -  #:use-module (guix build-system gnu))
> +  #:use-module (guix build-system gnu)
> +  #:use-module (guix utils) ; for %current-target-system
> +  )
>
>  (define-public re2
>     (package
>       (name "re2")
>       (version "2017-01-01")
> @@ -40,11 +42,15 @@
>                   "0yij1ajh66h3pj3kfz7y0ldrsww8rlpjzaavyr5lchl98as1jq74"))))
>       (build-system gnu-build-system)
>       (arguments
>        `(#:test-target "test"
>          ;; There is no configure step, but the Makefile respects a prefix.
> -        #:make-flags (list (string-append "prefix=" %output))
> +        #:make-flags (list (string-append "prefix=" %output)
> +                           (string-append "CXX=" ,(string-append (if (%current-target-system)
> +                                                                     (string-append (%current-target-system) "-")
> +                                                                     "")
> +                                                                 "g++")))

As John wrote, this is the right fix for this package.

If you can send it with ‘git send-email’ (see
<https://www.gnu.org/software/guix/manual/html_node/Submitting-Patches.html>),
I’ll apply it right away.  Otherwise I can do it on your behalf.

Thanks!

Ludo’.

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

* Re: 'guix build --target=' handling questions
  2017-03-06 16:04   ` Ludovic Courtès
@ 2017-03-06 22:01     ` Sergei Trofimovich
  2017-03-07 14:48       ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Trofimovich @ 2017-03-06 22:01 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 3040 bytes --]

On Mon, 06 Mar 2017 17:04:18 +0100
ludo@gnu.org (Ludovic Courtès) wrote:

> Sergei Trofimovich <slyfox@inbox.ru> skribis:
> 
> >> Question time:
> >> 
> >> - Is there a way to run 'guix environment --target=' in the same way as 'guix build --target='
> >>   sets it up? I'd like to see how both compilers are supposed to be present in there.
> >>
> >> - Why default g++ in PATH is the host g++ and not target g++?
> >>   Target seems to make most sense if no explicit compiler is specified.
> >> 
> >> - How to actually set CXX to point to target g++?
> >>   It looks like implicitly there already both host (through native-inputs)
> >>   and target (through build-inputs) compilers available.
> >>   I would expect something like
> >>       #:make-flags (list (string-append "CXX=" <.?.>)) 
> >>   What should be in place of that "<.?.>" to refer to target g++?  
> >
> > I think I've found a workaround at least for my third question.
> >
> > Both host and target compilers are available as g++ and ${target}-g++.
> >
> > Thus the following workaround seems to work:
> >
> > diff --git a/gnu/packages/regex.scm b/gnu/packages/regex.scm
> > index f04cba706..a8fa689ab 100644
> > --- a/gnu/packages/regex.scm
> > +++ b/gnu/packages/regex.scm
> > @@ -20,11 +20,13 @@
> >
> >  (define-module (gnu packages regex)
> >    #:use-module ((guix licenses) #:prefix license:)
> >    #:use-module (guix packages)
> >    #:use-module (guix download)
> > -  #:use-module (guix build-system gnu))
> > +  #:use-module (guix build-system gnu)
> > +  #:use-module (guix utils) ; for %current-target-system
> > +  )
> >
> >  (define-public re2
> >     (package
> >       (name "re2")
> >       (version "2017-01-01")
> > @@ -40,11 +42,15 @@
> >                   "0yij1ajh66h3pj3kfz7y0ldrsww8rlpjzaavyr5lchl98as1jq74"))))
> >       (build-system gnu-build-system)
> >       (arguments
> >        `(#:test-target "test"
> >          ;; There is no configure step, but the Makefile respects a prefix.
> > -        #:make-flags (list (string-append "prefix=" %output))
> > +        #:make-flags (list (string-append "prefix=" %output)
> > +                           (string-append "CXX=" ,(string-append (if (%current-target-system)
> > +                                                                     (string-append (%current-target-system) "-")
> > +                                                                     "")
> > +                                                                 "g++")))  
> 
> As John wrote, this is the right fix for this package.

Aha!

> If you can send it with ‘git send-email’ (see
> <https://www.gnu.org/software/guix/manual/html_node/Submitting-Patches.html>),

Sent as:
    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26004

About the 'guix environment --target=' / 'guix build --target=' part or question:

Would it make sense to have '--target=' support in 'guix environment' tool or is it
too tricky?

Thanks!

-- 

  Sergei

[-- Attachment #2: Цифровая подпись OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: 'guix build --target=' handling questions
  2017-03-06 22:01     ` Sergei Trofimovich
@ 2017-03-07 14:48       ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2017-03-07 14:48 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: guix-devel

Sergei Trofimovich <slyfox@inbox.ru> skribis:

> About the 'guix environment --target=' / 'guix build --target=' part or question:
>
> Would it make sense to have '--target=' support in 'guix environment' tool or is it
> too tricky?

I think it would make sense (at least without --ad-hoc) and shouldn’t be
too tricky.  You can file it on bug-guix so we remember!

Ludo’.

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

end of thread, other threads:[~2017-03-07 14:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 21:40 'guix build --target=' handling questions Sergei Trofimovich
2017-02-22 22:54 ` Sergei Trofimovich
2017-02-23 17:07   ` John Darrington
2017-03-06 16:04   ` Ludovic Courtès
2017-03-06 22:01     ` Sergei Trofimovich
2017-03-07 14:48       ` 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.