From: Sarah Morgensen via Guix-patches via <guix-patches@gnu.org>
To: 49019@debbugs.gnu.org
Subject: [bug#49019] [PATCH 1/1] gnu: Add gccgo-10.
Date: Mon, 14 Jun 2021 08:48:24 -0700 [thread overview]
Message-ID: <20210614154824.3465-1-iskarian@mgsn.dev> (raw)
In-Reply-To: <20210614041653.3085-1-iskarian@mgsn.dev>
Generate gccgo with MAKE-GCCGO to factorize phases, and to fix the
cyclic dependency between out and lib (caused by libgo embedding the
gotools path) that was worked around in
<https://issues.guix.gnu.org/18101>.
* gnu/packages/gcc.scm (custom-gcc-gccgo): New procedure.
(make-gccgo): New procedure.
(gccgo-10): New variable.
---
gnu/packages/gcc.scm | 77 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index 1fd5710e57..df2ba729d8 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -11,6 +11,7 @@
;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -744,6 +745,42 @@ as the 'native-search-paths' field."
".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
#t))))))))
+(define* (custom-gcc-gccgo gcc name languages
+ #:optional
+ (search-paths (package-native-search-paths gcc))
+ #:key (separate-lib-output? #t))
+ ;; TODO: remove CUSTOM-GCC-GCCGO when regex changes for CUSTOM-GCC are
+ ;; merged into master <https://issues.guix.gnu.org/49010>
+ "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
+as the 'native-search-paths' field."
+ (package (inherit gcc)
+ (name name)
+ (outputs (if separate-lib-output?
+ (package-outputs gcc)
+ (delete "lib" (package-outputs gcc))))
+ (native-search-paths search-paths)
+ (properties (alist-delete 'hidden? (package-properties gcc)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments gcc)
+ ((#:modules modules %gnu-build-system-modules)
+ `(,@modules
+ (srfi srfi-1)
+ (srfi srfi-26)
+ (ice-9 regex)))
+ ((#:configure-flags flags)
+ `(cons (string-append "--enable-languages="
+ ,(string-join languages ","))
+ (remove (cut string-match "--enable-languages.*" <>)
+ ,flags)))
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'install 'remove-broken-or-conflicting-files
+ (lambda* (#:key outputs #:allow-other-keys)
+ (for-each
+ delete-file
+ (find-files (string-append (assoc-ref outputs "out") "/bin")
+ ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|lto)(-.*)?$"))))))))))
+
(define %generic-search-paths
;; This is the language-neutral search path for GCC. Entries in $CPATH are
;; not considered "system headers", which means GCC can raise warnings for
@@ -813,6 +850,43 @@ It can also be used for ahead-of-time code generation for building standalone
compilers. The just-in-time (jit) part of the name is now something of a
misnomer.")))
+(define (make-gccgo gcc)
+ "Return a gccgo package based on GCC."
+ (let ((gccgo (custom-gcc-gccgo gcc "gccgo" '("go") %generic-search-paths)))
+ (package
+ (inherit gccgo)
+ (synopsis "Go frontend to GCC")
+ (description
+ "This package is part of the GNU Compiler Collection and
+provides the GNU compiler for the Go programming language.")
+ (arguments
+ (substitute-keyword-arguments (package-arguments gccgo)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'install 'wrap-go-with-tool-path
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (exedir (string-append out "/libexec/gcc"))
+ (tooldir (dirname (car (find-files exedir "^cgo$")))))
+ (wrap-program (string-append out "/bin/go")
+ `("GCCGOTOOLDIR" =
+ (,(string-append "${GCCGOTOOLDIR-" tooldir "}")))
+ `("GOROOT" =
+ (,(string-append "${GOROOT-" out "}")))))))
+ (add-before 'configure 'fix-gotools-runpath
+ (lambda _
+ (substitute* "gotools/Makefile.in"
+ (("AM_LDFLAGS =" all)
+ (string-append all " -Wl,-rpath=$(libdir) ")))))
+ (add-before 'configure 'remove-tool-reference-from-libgo
+ (lambda _
+ (substitute* "libgo/Makefile.in"
+ (("(GccgoToolDir = \\\")[^\\\"]+" _ start)
+ (string-append start "/nonexistent"))
+ (("(DefaultGoroot = \\\")[^\\\"]+" _ start)
+ (string-append start "/nonexistent"))
+ (("(defaultGOROOTValue.*?return `)[^`]+" _ start)
+ (string-append start "/nonexistent"))))))))))))
(define-public gccgo-4.9
(custom-gcc (package
@@ -828,6 +902,9 @@ provides the GNU compiler for the Go programming language."))
;; a cyclic dependency. <http://debbugs.gnu.org/18101>
#:separate-lib-output? #f))
+(define-public gccgo-10
+ (make-gccgo gcc-10))
+
(define %objc-search-paths
(list (search-path-specification
(variable "OBJC_INCLUDE_PATH")
--
2.31.1
next prev parent reply other threads:[~2021-06-14 15:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-14 4:16 [bug#49019] [PATCH 0/1] gnu: Add gccgo-10 Sarah Morgensen via Guix-patches via
2021-06-14 15:48 ` Sarah Morgensen via Guix-patches via [this message]
2021-06-28 19:22 ` bug#49019: [PATCH 1/1] " Efraim Flashner
2021-06-21 13:25 ` [bug#49019] [PATCH 0/1] " Efraim Flashner
2021-06-21 21:32 ` iskarian--- via Guix-patches via
2021-06-28 19:22 ` Efraim Flashner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210614154824.3465-1-iskarian@mgsn.dev \
--to=guix-patches@gnu.org \
--cc=49019@debbugs.gnu.org \
--cc=iskarian@mgsn.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.