Subject: [PATCH] gnu: Add libgccjit.

From: "LaFreniere, Joseph" <[email-masked]>
Date: Thu, 12 Mar 2020 16:56:33 -0500

Patch file is attached.  I have no experience building or 
packaging GCC, so any feedback is appreciated.  That being said, I 
_believe_ this recipe follows the build instructions at 
https://gcc.gnu.org/onlinedocs/jit/internals/index.html#packaging-notes 
correctly.

This is toward the eventual goal of packaging gccemacs 
(https://akrl.sdf.org/gccemacs.html).

--
Joseph LaFreniere
>From 8b08b302f6bf601f5c95513a56b7b0b54b0dc95c Mon Sep 17 00:00:00 2001
From: Joseph LaFreniere <[email-masked]>
Date: Wed, 11 Mar 2020 21:48:59 -0500
Subject: [PATCH] gnu: Add libgccjit.

* gnu/packages/gcc.scm (libgccjit): New variable.
---
 gnu/packages/gcc.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index ead50bb1dc..03fdeb02e1 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -690,6 +690,34 @@ as the 'native-search-paths' field."
   ;; report two gfortran@5 that are in fact identical.
   gfortran-7)
 
+(define-public libgccjit
+  (package
+    (inherit gcc-9)
+    (name "libgccjit")
+    (outputs (delete "lib" (package-outputs gcc)))
+    (properties (alist-delete 'hidden? (package-properties gcc)))
+    (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)
+        `(append `("--enable-host-shared"
+                   ,(string-append "--enable-languages=jit"))
+                 (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|gcc-.*)"))
+               #t))))))))
+
+
 (define-public gccgo-4.9
   (custom-gcc gcc-4.9 "gccgo" '("go")
               %generic-search-paths
-- 
2.25.1