Re: [PATCH] gnu: Add GCC front ends for Fortran, Go, Objective C, and Objective C++.

2013-11-01 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>> ‘ld-wrapper’ is a wrapper around the linker that adds a -rpath argument
>> for each -l argument (see the top of ld-wrapper.scm), such that all the
>> needed libraries are in the resulting binary’s RUNPATH.
>
> Could you show how it helps to avoid the need to set environment
> variables?

In the general case, you wouldn’t want to type:

  export LD_LIBRARY_PATH=/nix/store/foo:/nix/store/bar:...

More importantly, you could easily get it wrong, leading to crashes or
random behavior.

Setting RUNPATH at build time allows us to live our computing life in
peace and harmony.

HTH.  :-)

Ludo’.



Re: [PATCH] gnu: Add GCC front ends for Fortran, Go, Objective C, and Objective C++.

2013-11-01 Thread Nikita Karetnikov
> ‘ld-wrapper’ is a wrapper around the linker that adds a -rpath argument
> for each -l argument (see the top of ld-wrapper.scm), such that all the
> needed libraries are in the resulting binary’s RUNPATH.

Could you show how it helps to avoid the need to set environment
variables?

> Please add a docstring here, and then OK to push.

I’ve just pushed.  Please test.


pgptsjUuQptj6.pgp
Description: PGP signature


Re: [PATCH] gnu: Add GCC front ends for Fortran, Go, Objective C, and Objective C++.

2013-10-31 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>>> If you want to test any of the front-ends, don’t forget to set
>>> LIBRARY_PATH and LD_LIBRARY_PATH, like so:
>>>
>>> $ export 
>>> LIBRARY_PATH=/nix/store/wmaxqx3p658v2yqjv00mss2shvn23h7a-glibc-2.18/lib
>>> $ export 
>>> LD_LIBRARY_PATH=/nix/store/kvhg0fszagsx5y80sq79bkmb7yqvjfmd-gcc-go-4.8.1/lib
>
>> I guess that’s unnecessary when using ‘ld-wrapper’.
>
> I know nothing about it.  Could you elaborate?

‘ld-wrapper’ is a wrapper around the linker that adds a -rpath argument
for each -l argument (see the top of ld-wrapper.scm), such that all the
needed libraries are in the resulting binary’s RUNPATH.

> I tested each front end using the “hello, world” program.  Is it enough?

Yes.

> From be260e7d9d4a7592129c0369eee52b156170d1cf Mon Sep 17 00:00:00 2001
> From: Nikita Karetnikov 
> Date: Thu, 31 Oct 2013 19:54:36 +
> Subject: [PATCH] gnu: Add GCC front ends for Fortran, Go, Objective C, and
>  Objective C++.
>
> * gnu/packages/gcc.scm (custom-gcc, gfortran-4.8, gccgo-4.8)
>   (gcc-objc-4.8, gcc-objc++-4.8): New variables.
> ---
>  gnu/packages/gcc.scm |   29 +
>  1 file changed, 29 insertions(+)
>
> diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
> index dde0f0d..60bc5bb 100644
> --- a/gnu/packages/gcc.scm
> +++ b/gnu/packages/gcc.scm
> @@ -27,6 +27,7 @@
>#:use-module (guix packages)
>#:use-module (guix download)
>#:use-module (guix build-system gnu)
> +  #:use-module (guix utils)
>#:use-module (ice-9 regex))
>  
>  (define %gcc-infrastructure
> @@ -211,6 +212,34 @@ Go.  It also includes standard libraries for these 
> languages.")
>(base32
> "1j6dwgby4g3p3lz7zkss32ghr45zpdidrg8xvazvn91lqxv25p09"))
>  
> +(define (custom-gcc gcc name languages)

Please add a docstring here, and then OK to push.

Thank you!

Ludo’.



[PATCH] gnu: Add GCC front ends for Fortran, Go, Objective C, and Objective C++.

2013-10-31 Thread Nikita Karetnikov
>> If you want to test any of the front-ends, don’t forget to set
>> LIBRARY_PATH and LD_LIBRARY_PATH, like so:
>>
>> $ export 
>> LIBRARY_PATH=/nix/store/wmaxqx3p658v2yqjv00mss2shvn23h7a-glibc-2.18/lib
>> $ export 
>> LD_LIBRARY_PATH=/nix/store/kvhg0fszagsx5y80sq79bkmb7yqvjfmd-gcc-go-4.8.1/lib

> I guess that’s unnecessary when using ‘ld-wrapper’.

I know nothing about it.  Could you elaborate?

I tested each front end using the “hello, world” program.  Is it enough?

It was necessary to set some environment variables.  An example for
Fortran:

LIBRARY_PATH=/nix/var/nix/profiles/default/guix-profile/lib
LD_LIBRARY_PATH=/nix/store/jh5shyx6pg7m0dibdgl202pj7ryp5nvq-gfortran-4.8.2/lib
CPATH=/nix/var/nix/profiles/default/guix-profile/include
PATH=/nix/var/nix/profiles/default/guix-profile/bin:$PATH

May I push this patch to ‘master’?

From be260e7d9d4a7592129c0369eee52b156170d1cf Mon Sep 17 00:00:00 2001
From: Nikita Karetnikov 
Date: Thu, 31 Oct 2013 19:54:36 +
Subject: [PATCH] gnu: Add GCC front ends for Fortran, Go, Objective C, and
 Objective C++.

* gnu/packages/gcc.scm (custom-gcc, gfortran-4.8, gccgo-4.8)
  (gcc-objc-4.8, gcc-objc++-4.8): New variables.
---
 gnu/packages/gcc.scm |   29 +
 1 file changed, 29 insertions(+)

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index dde0f0d..60bc5bb 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -27,6 +27,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix utils)
   #:use-module (ice-9 regex))
 
 (define %gcc-infrastructure
@@ -211,6 +212,34 @@ Go.  It also includes standard libraries for these languages.")
   (base32
"1j6dwgby4g3p3lz7zkss32ghr45zpdidrg8xvazvn91lqxv25p09"))
 
+(define (custom-gcc gcc name languages)
+  (package (inherit gcc)
+(name name)
+(arguments
+ (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
+(guix build utils)
+(ice-9 regex)
+(srfi srfi-1)
+(srfi srfi-26))
+   ,@(package-arguments gcc))
+   ((#:configure-flags flags)
+`(cons (string-append "--enable-languages="
+  ,(string-join languages ","))
+   (remove (cut string-match "--enable-languages.*" <>)
+   ,flags)))
+
+(define-public gfortran-4.8
+  (custom-gcc gcc-4.8 "gfortran" '("fortran")))
+
+(define-public gccgo-4.8
+  (custom-gcc gcc-4.8 "gccgo" '("go")))
+
+(define-public gcc-objc-4.8
+  (custom-gcc gcc-4.8 "gcc-objc" '("objc")))
+
+(define-public gcc-objc++-4.8
+  (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")))
+
 (define-public isl
   (package
 (name "isl")
-- 
1.7.9.5



pgp7VJPfHUErO.pgp
Description: PGP signature


Re: GCC front-ends

2013-10-29 Thread Ludovic Courtès
Andreas Enge  skribis:

> On Mon, Oct 28, 2013 at 02:07:45PM +0100, Ludovic Courtès wrote:
>> I wonder if this would also be an opportunity to do that fixed-point
>> thing while we’re at rebuilding everything.  Or is it too ambitious?
>
> Only you can tell, as you have been doing a lot of work on it! Why not
> give it a try?

Right, let’s try, and consider it an optional goal for 0.5.

Ludo’.



Re: GCC front-ends

2013-10-29 Thread Andreas Enge
On Mon, Oct 28, 2013 at 02:07:45PM +0100, Ludovic Courtès wrote:
> I wonder if this would also be an opportunity to do that fixed-point
> thing while we’re at rebuilding everything.  Or is it too ambitious?

Only you can tell, as you have been doing a lot of work on it! Why not
give it a try?

Andreas




Re: GCC front-ends

2013-10-28 Thread Nikita Karetnikov
> Argh, you also need (srfi srfi-26) for ‘cut’, sorry about that.

Hm, I’ve added the module, but I still get the same error.


pgp_x9KZwHIvm.pgp
Description: PGP signature


Re: GCC front-ends

2013-10-28 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>> That’s a bug, which may have been fixed in 4.8.2 no?  I’d rather not
>> workaround that if it’s been/being fixed.
>
> No, it has not been fixed.  Well, the previous patch didn’t contain any
> workarounds.  However, users would have to pass ‘-g’ each time they
> decide to compile anything.  Otherwise, their binaries will not work.
> Can we do anything about it?

I’d say that it’s not our business (above all, I’m surprised the Go
front-end is this broken.)

>> So the mapping has to be done in builder-side code, not in host-side
>> code, like ‘gcc-cross-boot0’ does.
>
>> Something like:
>
>>   `(cons "--enable-languages=" ,(string-join languages ",")
>>  (remove (cut string-match "--enable-languages.*" <>) ,flags))
>
> (define (custom-gcc gcc name languages)
>   (package (inherit gcc)
> (name name)
> (arguments
>  (substitute-keyword-arguments (package-arguments gcc)
>((#:configure-flags flags)
> `(cons "--enable-languages=" ,(string-join languages ",")
>(remove (cut string-match "--enable-languages.*" <>)
>,flags)))
>((#:modules _)
> '((guix build gnu-build-system)
>   (guix build utils)
>   (srfi srfi-1)))
>
> (define-public gfortran-4.8
>   (custom-gcc gcc-4.8 "gfortran" '("fortran")))
>
> The above code fails.

Argh, you also need (srfi srfi-26) for ‘cut’, sorry about that.

HTH,
Ludo’.



Re: GCC front-ends

2013-10-28 Thread Nikita Karetnikov
> That’s a bug, which may have been fixed in 4.8.2 no?  I’d rather not
> workaround that if it’s been/being fixed.

No, it has not been fixed.  Well, the previous patch didn’t contain any
workarounds.  However, users would have to pass ‘-g’ each time they
decide to compile anything.  Otherwise, their binaries will not work.
Can we do anything about it?

> GNAT and GCJ are definitely trickier, so I’d suggest to leave them for now.

OK.

> So the mapping has to be done in builder-side code, not in host-side
> code, like ‘gcc-cross-boot0’ does.

> Something like:

>   `(cons "--enable-languages=" ,(string-join languages ",")
>  (remove (cut string-match "--enable-languages.*" <>) ,flags))

(define (custom-gcc gcc name languages)
  (package (inherit gcc)
(name name)
(arguments
 (substitute-keyword-arguments (package-arguments gcc)
   ((#:configure-flags flags)
`(cons "--enable-languages=" ,(string-join languages ",")
   (remove (cut string-match "--enable-languages.*" <>)
   ,flags)))
   ((#:modules _)
'((guix build gnu-build-system)
  (guix build utils)
  (srfi srfi-1)))

(define-public gfortran-4.8
  (custom-gcc gcc-4.8 "gfortran" '("fortran")))

The above code fails.

Backtrace:
In ice-9/boot-9.scm:
 157: 14 [catch #t # ...]
In unknown file:
   ?: 13 [apply-smob/1 #]
In ice-9/boot-9.scm:
  63: 12 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 11 [eval # #]
In ice-9/boot-9.scm:
2320: 10 [save-module-excursion #]
3966: 9 [#]
1645: 8 [%start-stack load-stack ...]
1650: 7 [#]
In unknown file:
   ?: 6 [primitive-load 
"/nix/store/m8axi2v9cbj2s0kfpifxp874sxplwwwg-gfortran-4.8.2-guile-builder"]
In ice-9/eval.scm:
 387: 5 [eval # ()]
 387: 4 [eval # ()]
 387: 3 [eval # ()]
 386: 2 [eval # ()]
 393: 1 [eval # ()]
In unknown file:
   ?: 0 [memoize-variable-access! # #]

ERROR: In procedure memoize-variable-access!:
ERROR: Unbound variable: remove


pgpe4lqlTFSoF.pgp
Description: PGP signature


Re: GCC front-ends

2013-10-28 Thread Ludovic Courtès
Andreas Enge  skribis:

> On Sat, Oct 26, 2013 at 10:08:04PM +0200, Ludovic Courtès wrote:
>> That’s a bug, which may have been fixed in 4.8.2 no?  I’d rather not
>> workaround that if it’s been/being fixed.
>
> Speaking of which, should we maybe switch to 4.8.2 for building the
> distribution? Now would be the right time to update core-updates.

Yes, definitely.

I wanted to test 4.8.2 in master first, but for that I was waiting for
Nikita’s work to avoid any disruption.

> Mark also suggested a new set of bootstrap-tarballs with a common date
> and common versions of all programs for all architectures, including
> mips.

Probably a good idea.

I wonder if this would also be an opportunity to do that fixed-point
thing while we’re at rebuilding everything.  Or is it too ambitious?

Ludo’.



Re: GCC front-ends

2013-10-27 Thread Andreas Enge
On Sat, Oct 26, 2013 at 10:08:04PM +0200, Ludovic Courtès wrote:
> That’s a bug, which may have been fixed in 4.8.2 no?  I’d rather not
> workaround that if it’s been/being fixed.

Speaking of which, should we maybe switch to 4.8.2 for building the
distribution? Now would be the right time to update core-updates.
Mark also suggested a new set of bootstrap-tarballs with a common date
and common versions of all programs for all architectures, including mips.

Andreas




Re: GCC front-ends

2013-10-26 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>> I guess this triggers a complete rebuild, right?  (That means it would
>> go in ‘core-updates’.)
>
>> Using the ‘substitute-keyword-arguments’ hack as in base.scm would allow
>> you to avoid that.
>
>> Also, the ‘origin’ thing should be factorized:
>
>>   (define (gcc-source version)
>> (origin ...))
>
>> It’s good that you’re tackling this!  Then we can also build the
>> Objective-C front-end, and then start GNUstepping.
>
> What do you think about the attached diff?  Is there a way to avoid
> multiple ‘map’s?

See below.

> What about the names of the packages?  For example, ‘gcc-fortran’ is
> usually called ‘gfortran’, ‘gcc-go’ is called ‘gccgo’, etc.  Should we
> use these names?  How should we call ‘gcc-objc’, then?

I’d say ‘gfortran’ and ‘gccgo’, and perhaps ‘gcc-objective-c’?

> If you want to test any of the front-ends, don’t forget to set
> LIBRARY_PATH and LD_LIBRARY_PATH, like so:
>
> $ export 
> LIBRARY_PATH=/nix/store/wmaxqx3p658v2yqjv00mss2shvn23h7a-glibc-2.18/lib
> $ export 
> LD_LIBRARY_PATH=/nix/store/kvhg0fszagsx5y80sq79bkmb7yqvjfmd-gcc-go-4.8.1/lib

I guess that’s unnecessary when using ‘ld-wrapper’.

> Notes:
>
> 1. The Go front-end requires ‘-g’ (see [1]).

That’s a bug, which may have been fixed in 4.8.2 no?  I’d rather not
workaround that if it’s been/being fixed.

> 4. The Ada front-end requires GNAT [3] (see [4]).
>
> 5. Not sure why the Java front-end fails:

GNAT and GCJ are definitely trickier, so I’d suggest to leave them for now.

> +(define (custom-gcc gcc name languages)
> +  (package (inherit gcc)
> +(name name)
> +(arguments
> + (substitute-keyword-arguments (package-arguments gcc)
> +   ((#:configure-flags flags)
> +(map (lambda (x)
> +   (if (list? x)
> +   (map (lambda (y)
> +  (if (equal? "--enable-languages=c,c++" y)
> +  (string-append "--enable-languages="
> + languages)
> +  y))
> +x)
> +   x))
> + flags))

That’s unreliable because FLAGS is actually a quoted expression, like

  '(cons "--with-foo" (list "--with-bar"))

So the mapping has to be done in builder-side code, not in host-side
code, like ‘gcc-cross-boot0’ does.

Something like:

  `(cons "--enable-languages=" ,(string-join languages ",")
 (remove (cut string-match "--enable-languages.*" <>) ,flags))

(Note that “c,c++” can be omitted since it’s always enabled.)

Thanks,
Ludo’.



GCC front-ends (was: GFortran can’t find system headers)

2013-10-19 Thread Nikita Karetnikov
> I guess this triggers a complete rebuild, right?  (That means it would
> go in ‘core-updates’.)

> Using the ‘substitute-keyword-arguments’ hack as in base.scm would allow
> you to avoid that.

> Also, the ‘origin’ thing should be factorized:

>   (define (gcc-source version)
> (origin ...))

> It’s good that you’re tackling this!  Then we can also build the
> Objective-C front-end, and then start GNUstepping.

What do you think about the attached diff?  Is there a way to avoid
multiple ‘map’s?

What about the names of the packages?  For example, ‘gcc-fortran’ is
usually called ‘gfortran’, ‘gcc-go’ is called ‘gccgo’, etc.  Should we
use these names?  How should we call ‘gcc-objc’, then?

If you want to test any of the front-ends, don’t forget to set
LIBRARY_PATH and LD_LIBRARY_PATH, like so:

$ export LIBRARY_PATH=/nix/store/wmaxqx3p658v2yqjv00mss2shvn23h7a-glibc-2.18/lib
$ export 
LD_LIBRARY_PATH=/nix/store/kvhg0fszagsx5y80sq79bkmb7yqvjfmd-gcc-go-4.8.1/lib

Notes:

1. The Go front-end requires ‘-g’ (see [1]).

2. “GFORTRAN guesses the source code formatting based on the file
   extension. For .f90 files, it will assume it's working with FORTRAN
   90 source code and use free formatting rules. For .f and .for files,
   it will assume the file is F77 source code and use fixed formatting
   rules.” [2]

3. If you want to compile Objective-C or Objective-C++, pass ‘-x ’
   to ‘gcc’.

4. The Ada front-end requires GNAT [3] (see [4]).

5. Not sure why the Java front-end fails:

   libtool: link: ( cd ".libs" && rm -f "libquadmath.la" && ln -s 
"../libquadmath.la" "libquadmath.la" )
   make[3]: Leaving directory 
`/tmp/nix-build-gcc-java-4.8.1.drv-0/build/i686-pc-linux-gnu/libquadmath'
   make[2]: Leaving directory 
`/tmp/nix-build-gcc-java-4.8.1.drv-0/build/i686-pc-linux-gnu/libquadmath'
   make[1]: Leaving directory `/tmp/nix-build-gcc-java-4.8.1.drv-0/build'
   make: *** [all] Error 2
   phase `build' failed after 2229 seconds
   note: keeping build directory `/tmp/nix-build-gcc-java-4.8.1.drv-0'
   builder for `/nix/store/wlqwyy9k9mbl3wpy9jq08k91qq23f4kp-gcc-java-4.8.1.drv' 
failed with exit code 1
   @ build-failed 
/nix/store/wlqwyy9k9mbl3wpy9jq08k91qq23f4kp-gcc-java-4.8.1.drv - 1 builder for 
`/nix/store/wlqwyy9k9mbl3wpy9jq08k91qq23f4kp-gcc-java-4.8.1.drv' failed with 
exit code 1
   guix build: error: build failed: build of 
`/nix/store/wlqwyy9k9mbl3wpy9jq08k91qq23f4kp-gcc-java-4.8.1.drv' failed

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57194
[2] http://ubuntuforums.org/showthread.php?t=853105
[3] https://www.gnu.org/software/gnat/
[4] http://gcc.gnu.org/ml/gcc/2007-11/msg00091.html

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index cececca..c2742fb 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -26,6 +26,7 @@
   #:use-module (gnu packages texinfo)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (ice-9 regex))
 
@@ -211,6 +212,41 @@ Go.  It also includes standard libraries for these languages.")
   (base32
"04sqn0ds17ys8l6zn7vyyvjz1a7hsk4zb0381vlw9wnr7az48nsl"))
 
+(define (custom-gcc gcc name languages)
+  (package (inherit gcc)
+(name name)
+(arguments
+ (substitute-keyword-arguments (package-arguments gcc)
+   ((#:configure-flags flags)
+(map (lambda (x)
+   (if (list? x)
+   (map (lambda (y)
+  (if (equal? "--enable-languages=c,c++" y)
+  (string-append "--enable-languages="
+ languages)
+  y))
+x)
+   x))
+ flags))
+
+;; (define-public gcc-ada-4.8
+;;   (custom-gcc gcc-4.8 "gcc-ada" "ada"))
+
+(define-public gcc-fortran-4.8
+  (custom-gcc gcc-4.8 "gcc-fortran" "fortran"))
+
+(define-public gcc-go-4.8
+  (custom-gcc gcc-4.8 "gcc-go" "go"))
+
+;; (define-public gcc-java-4.8
+;;   (custom-gcc gcc-4.8 "gcc-java" "java"))
+
+(define-public gcc-objc-4.8
+  (custom-gcc gcc-4.8 "gcc-objc" "objc"))
+
+(define-public gcc-objc++-4.8
+  (custom-gcc gcc-4.8 "gcc-objc++" "obj-c++"))
+
 (define-public isl
   (package
 (name "isl")


pgpkXvlDm4gbN.pgp
Description: PGP signature