diff mbox series

[bug#38436] gnu: Add gfortran-toolchain

Message ID m1zhfzgnn5.fsf@fastmail.net
State Accepted
Headers show
Series [bug#38436] gnu: Add gfortran-toolchain | expand

Commit Message

Konrad Hinsen Dec. 11, 2019, 10:30 a.m. UTC
* gnu/packages/commencement.scm: (gfortran-toolchain): New variable.
* gnu/packages/commencement.scm: (make-gcc-toolchain): Added argument "language"
---
 gnu/packages/commencement.scm | 54 ++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 16 deletions(-)

Comments

Ludovic Courtès Dec. 11, 2019, 11:12 a.m. UTC | #1
Hi Konrad,

Konrad Hinsen <konrad.hinsen@fastmail.net> skribis:

> * gnu/packages/commencement.scm: (gfortran-toolchain): New variable.
> * gnu/packages/commencement.scm: (make-gcc-toolchain): Added argument "language"

We’re almost there.  :-)

> +;; The synopsis and description must be literal strings (not constructed
> +;; using string-append or format) to make them translatable.
> +(define gcc-synopsis
> +  "Complete GCC tool chain for C/C++ development")
> +(define gcc-description
> +  "This package provides a complete GCC tool chain for C/C++ development to
> +be installed in user profiles.  This includes GCC, as well as libc (headers
> +and binaries, plus debugging symbols in the @code{debug} output), and
> +binutils.")
>  
>  (define* (make-gcc-toolchain gcc
> -                            #:optional
> -                            (libc #f))
> -  "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
> +                             #:optional
> +                             (synopsis gcc-synopsis)
> +                             (description gcc-description)

xgettext recognizes (synopsis "foo"), but it won’t catch the variables
defined above, because they’re not preceded by the ‘synopsis’ keyword or
anything.

That’s why I proposed in <https://issues.guix.gnu.org/issue/38436#2> to
arrange to keep the string wrapped in (synopsis …).

It’d be great if you could give it a spin, or I can make the change on
your behalf if you prefer.

Apologies for making something simple somewhat complicated!

Thanks,
Ludo’.
Konrad Hinsen Dec. 11, 2019, 8:34 p.m. UTC | #2
Hi Ludo,

> xgettext recognizes (synopsis "foo"), but it won’t catch the variables
> defined above, because they’re not preceded by the ‘synopsis’ keyword or
> anything.

OK, so what's the exact rule? If the literal string has to be right
after the symbol "synopsis", then your optional-arg approach shouldn't
work when the argument is supplied at the call site (in
gfortran-toolchain).

That would still leave the option of doing something like

  (define-public gfortran-toolchain
   (package (inherit (make-gcc-toolchain gfortran))
     (synopsis ...)
     (description ...)

Cheers,
  Konrad.
Ludovic Courtès Dec. 12, 2019, 1:20 p.m. UTC | #3
Hi Konrad,

Konrad Hinsen <konrad.hinsen@fastmail.net> skribis:

>> xgettext recognizes (synopsis "foo"), but it won’t catch the variables
>> defined above, because they’re not preceded by the ‘synopsis’ keyword or
>> anything.
>
> OK, so what's the exact rule? If the literal string has to be right
> after the symbol "synopsis", then your optional-arg approach shouldn't
> work when the argument is supplied at the call site (in
> gfortran-toolchain).

Good point!

The exact rule is given the the ‘--keyword’ options in
po/packages/Makevars.  Namely, xgettext will recognize:

  (synopsis "…")

Thus, something like:

  (define* (foo #:key (synopsis "…"))
    …)

works.

Now, for gfortran, you could resort to a not-so-fancy hack (used in
‘define-word-list-dictionary’ in (gnu packages aspell)) like this:

  (let-syntax ((synopsis (syntax-rules () ((_ str) str))))
    (make-gcc-toolchain gfortran #:synopsis (synopsis "…")))

Quite an effort for this little thing, but I couldn’t find of anything
simpler.

HTH,
Ludo’.
Konrad Hinsen Dec. 12, 2019, 3:19 p.m. UTC | #4
Hi Ludo,

> The exact rule is given the the ‘--keyword’ options in
> po/packages/Makevars.  Namely, xgettext will recognize:

Great, good to know!

>   (let-syntax ((synopsis (syntax-rules () ((_ str) str))))
>     (make-gcc-toolchain gfortran #:synopsis (synopsis "…")))
>
> Quite an effort for this little thing, but I couldn’t find of anything
> simpler.

It looks like I still don't understand how this works. Why wouldn't
the simpler

   (let ((synopsis (lambda (_) _)))
     (make-gcc-toolchain gfortran #:synopsis (synopsis "…")))

be sufficient? And is there a good reason to prefer such constructs
to

  (define-public gfortran-toolchain
   (package (inherit (make-gcc-toolchain gfortran))
     (synopsis ...)
     (description ...)

which I think expresses the intention more clearly?

Cheers,
  Konrad
Ludovic Courtès Dec. 12, 2019, 9:22 p.m. UTC | #5
Konrad Hinsen <konrad.hinsen@fastmail.net> skribis:

>>   (let-syntax ((synopsis (syntax-rules () ((_ str) str))))
>>     (make-gcc-toolchain gfortran #:synopsis (synopsis "…")))
>>
>> Quite an effort for this little thing, but I couldn’t find of anything
>> simpler.
>
> It looks like I still don't understand how this works. Why wouldn't
> the simpler
>
>    (let ((synopsis (lambda (_) _)))
>      (make-gcc-toolchain gfortran #:synopsis (synopsis "…")))

Ah yes, that would work too.

> be sufficient? And is there a good reason to prefer such constructs
> to
>
>   (define-public gfortran-toolchain
>    (package (inherit (make-gcc-toolchain gfortran))
>      (synopsis ...)
>      (description ...)
>
> which I think expresses the intention more clearly?

Oh I guess I had overlooked this proposal, I agree that it’s nicer.

Apologies for the confusion!

Ludo’.
Konrad Hinsen Dec. 13, 2019, 12:56 p.m. UTC | #6
Ludovic Courtès <ludo@gnu.org> writes:

> Oh I guess I had overlooked this proposal, I agree that it’s nicer.

Patch submitted. It's probably also the shortest possible
patch to get the desired result.

Cheers,
  Konrad
diff mbox series

Patch

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 68030376fc..e147836fc5 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -2517,16 +2517,29 @@  COREUTILS-FINAL vs. COREUTILS, etc."
 ;;; GCC toolchain.
 ;;;
 
-;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
-;; instantiated like this:
-;;
-;; (define-public gcc-glibc-2.27-toolchain
-;;   (make-gcc-toolchain gcc glibc-2.27))
+;;; Toolchain packages combine everything needed for compilation,
+;;; and ensure that ld-wrapper comes before binutils' ld in the
+;;; user's profile, as otherwise dynamic library lookup would not
+;;; work correctly.
+
+;; The synopsis and description must be literal strings (not constructed
+;; using string-append or format) to make them translatable.
+(define gcc-synopsis
+  "Complete GCC tool chain for C/C++ development")
+(define gcc-description
+  "This package provides a complete GCC tool chain for C/C++ development to
+be installed in user profiles.  This includes GCC, as well as libc (headers
+and binaries, plus debugging symbols in the @code{debug} output), and
+binutils.")
 
 (define* (make-gcc-toolchain gcc
-                            #:optional
-                            (libc #f))
-  "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
+                             #:optional
+                             (synopsis gcc-synopsis)
+                             (description gcc-description)
+                             (libc #f))
+  "Return a complete toolchain for GCC.  If SYNOPSIS and/or
+DESCRIPTION are given, use them for documentation instead of the
+defaults for the C/C++ toolchain. If LIBC is specified, target that libc."
   (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
         (libc (if libc libc glibc-final)))
     (package
@@ -2559,17 +2572,11 @@  COREUTILS-FINAL vs. COREUTILS, etc."
       (search-paths (package-search-paths gcc))
 
       (license (package-license gcc))
-      (synopsis "Complete GCC tool chain for C/C++ development")
-      (description
-       "This package provides a complete GCC tool chain for C/C++ development to
-be   installed in user profiles.  This includes GCC, as well as libc (headers
-an  d binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
+      (synopsis synopsis)
+      (description description)
       (home-page "https://gcc.gnu.org/")
       (outputs '("out" "debug" "static"))
 
-      ;; The main raison d'être of this "meta-package" is (1) to conveniently
-      ;; install everything that we need, and (2) to make sure ld-wrapper comes
-      ;; before Binutils' ld in the user's profile.
       (inputs `(("gcc" ,gcc)
                 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
                 ("binutils" ,binutils-final)
@@ -2601,4 +2608,19 @@  an  d binaries, plus debugging symbols in the @code{debug} output), and Binutils
 (define-public gcc-toolchain-9
   (make-gcc-toolchain gcc-9))
 
+;; Provide the Fortran toolchain package only for the version of gfortran that
+;; is used by Guix intenally to build Fortran libraries, because combining
+;; code compiled with different versions can cause problems.
+
+(define gfortran-synopsis
+  "Complete GCC tool chain for Fortran development")
+(define gfortran-description
+  "This package provides a complete GCC tool chain for Fortran development to
+be installed in user profiles.  This includes GCC, as well as libc (headers
+and binaries, plus debugging symbols in the @code{debug} output), and
+binutils.")
+
+(define-public gfortran-toolchain
+  (make-gcc-toolchain gfortran gfortran-synopsis gfortran-description))
+
 ;;; commencement.scm ends here