~whereiseveryone/guixrus

guixrus/guixrus/packages/qbe.scm -rw-r--r-- 4.7 KiB
bf2ff435jgart add emacs-prelude-ivy 6 minutes ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 jgart <jgart@dismail.de>
;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
;;;
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guixrus packages qbe)
  #:use-module (guix build utils)
  #:use-module (guix gexp)
  #:use-module (guix build-system gnu)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages gcc))

(define-public qbe
  (let ((commit "2caa26e388b1c904d2f12fb09f84df7e761d8331")
        (revision "1"))
   (package
    (name "qbe")
    (version (git-version "0.0" revision commit))
    (source
     (origin
      (method git-fetch)
      (uri (git-reference
            (url "git://c9x.me/qbe")
            (commit commit)))
      (file-name (git-file-name name version))
      (patches
        (parameterize
           ((%patch-path
             (map
              (lambda (directory)
                (string-append directory "/guixrus/packages/patches"))
              %load-path)))
         (search-patches "qbe-makefile-add-target.patch")))
      (sha256
       (base32 "1gv03ym0gqrl4wkbhysa82025xwrkr1fg44z814b6vnggwlqgljc"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f ; Tests require a running qemu
       #:make-flags ,#~(list (string-append "CC=" #$(cc-for-target))
                             (string-append "PREFIX=" #$output)
                             (string-append "TARGET=" #$(or (%current-target-system)
                                                            (%current-system))))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure))))
    (supported-systems (list "x86_64-linux" "aarch64-linux" "riscv64-linux"))
    (synopsis "Simple, straightforward backend compiler")
    (description "QBE is a compiler backend with the goal of reaching 70% of the
performance of advanced compilers such as LLVM and GCC in only 10% of the code.")
    (home-page "https://c9x.me/compile/")
    (license license:expat))))

(define-public cproc
  (let ((commit "70fe9ef1810cc6c05bde9eb0970363c35fa7e802")
        (revision "1"))
    (package
     (name "cproc")
     (version (git-version "0.0" revision commit))
     (source
      (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://git.sr.ht/~mcf/cproc")
             (commit commit)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1qmgzll7z7mn587azkj4cizyyd8ii6iznfxpc66ja08140sbn9yx"))))
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags ,#~(list (string-append "CC=" #$(cc-for-target))
                              (string-append "PREFIX=" #$output))
        #:phases
        ,#~(modify-phases %standard-phases
             (replace 'configure
               (lambda* (#:key inputs outputs #:allow-other-keys)
                 (let ((out (assoc-ref outputs "out"))
                       (gcc-lib (assoc-ref inputs "gcc:lib"))
                       (ld #$(ld-for-target))
                       (host-system #$(nix-system->gnu-triplet (%current-system)))
                       (target-system
                        #$(nix-system->gnu-triplet (or (%current-target-system)
                                                       (%current-system)))))
                   (invoke "./configure"
                           (string-append "--prefix=" out)
                           (string-append "--host=" host-system)
                           (string-append "--target=" target-system)
                           (string-append "--with-ld=" ld)
                           (string-append "--with-gcc-libdir=" gcc-lib))))))))
     (inputs `(("qbe" ,qbe)
               ("gcc:lib" ,gcc "lib")))
     (supported-systems (list "x86_64-linux" "aarch64-linux"))
     (synopsis "Simple C11 compiler backed by QBE")
     (description "@code{cproc} is a C compiler using QBE as a backend.  It
currently supports C11 along with some GCC and C2x extensions.")
     (home-page "https://sr.ht/~mcf/cproc")
     (license license:expat))))