diff mbox series

[bug#54235,v2,2/3] gnu: Add ck.

Message ID 20220308043809.31394-2-maxim.cournoyer@gmail.com
State Accepted
Headers show
Series [bug#54235,v2,1/3] gnu: docbook-xml-4.1.2: Install an XML catalog file. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Maxim Cournoyer March 8, 2022, 4:38 a.m. UTC
* gnu/packages/c.scm (ck): New variable.
---
 gnu/packages/c.scm | 81 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

Comments

M March 8, 2022, 9:39 a.m. UTC | #1
Maxim Cournoyer schreef op ma 07-03-2022 om 23:38 [-0500]:
> +              ;; TODO: Move AR-FOR-TARGET and LD-FOR-TARGET to (guix utils).
> +              (define* (ar-for-target #:optional (target #$(%current-target-system)))
> +                (if target
> +                    (string-append target "-ar")
> +                    "ar"))

I'm wondering, why not just do this now (in a separate patch)?
(guix utils) isn't (guix build utils), there are no rebuilding
concerns.

Greetings,
Maxime.
M March 8, 2022, 9:45 a.m. UTC | #2
Maxim Cournoyer schreef op ma 07-03-2022 om 23:38 [-0500]:
> +              (define (gnu-triplet->machine target)
> +                (letrec-syntax
> +                    ((matches (syntax-rules (=>)
> +                                ((_ (target-prefix => machine) rest ...)
> +                                 (if (string-prefix? target-prefix target)
> +                                     machine
> +                                     (matches rest ...)))
> +                                ((_)
> +                                 (error "unsupported target" target)))))
> +                  ;; This basically reproduces the logic handling the
> +                  ;; PLATFORM variable in the configure script.
> +                  (matches ("x86_64"      => "x86_64")
> +                           ("i586"        => "x86")
> +                           ("i686"        => "x86")
> +                           ("aarch64"     => "aarch64")
> +                           ("arm"         => "arm")
> +                           ("ppc64"       => "ppc64")
> +                           ("ppc"         => "ppc")
> +                           ("s390x"       => "s390x")
> +                           ("sparc64"     => "sparcv9"))))

I would move this outside the build code, such that new targets can be
added without having to rebuild ck and dependents.  Also, there are a
few 'target-foo?' procedures in (guix utils) that can be used here (if
it were moved outisde the build code).


Greetings,
Maxime.
M March 8, 2022, 9:49 a.m. UTC | #3
Maxim Cournoyer schreef op ma 07-03-2022 om 23:38 [-0500]:
> +              ;; The custom configure script doesn't make cross-compilation
> +              ;; adjustments itself, so manually set the archiver, compiler
> +              ;; and linker.  Even then, it is still broken and doesn't
> +              ;; actually build any binary (see:
> +              ;; https://github.com/concurrencykit/ck/issues/191).

Since cross-compilation is currently broken, I think it would be
acceptable to not attempt it in Guix, though I would like a nice
comment and error instead of silently producing the wrong binaries:

  (when target
    ;; See <https://github.com/concurrencykit/ck/issues/191>
    ;; and <https://issues.guix.gnu.org/54235>.
    (error "ck is currently not cross-compilable"))

Greetings,
Maxime.
Maxim Cournoyer March 8, 2022, 2:36 p.m. UTC | #4
Hi Maxime,

Maxime Devos <maximedevos@telenet.be> writes:

> Maxim Cournoyer schreef op ma 07-03-2022 om 23:38 [-0500]:
>> +              ;; TODO: Move AR-FOR-TARGET and LD-FOR-TARGET to (guix utils).
>> +              (define* (ar-for-target #:optional (target #$(%current-target-system)))
>> +                (if target
>> +                    (string-append target "-ar")
>> +                    "ar"))
>
> I'm wondering, why not just do this now (in a separate patch)?
> (guix utils) isn't (guix build utils), there are no rebuilding
> concerns.

Indeed.  Done in v3.

Thanks!

Maxim
Maxim Cournoyer March 8, 2022, 2:38 p.m. UTC | #5
Hi,

Maxime Devos <maximedevos@telenet.be> writes:

> Maxim Cournoyer schreef op ma 07-03-2022 om 23:38 [-0500]:
>> +              (define (gnu-triplet->machine target)
>> +                (letrec-syntax
>> +                    ((matches (syntax-rules (=>)
>> +                                ((_ (target-prefix => machine) rest ...)
>> +                                 (if (string-prefix? target-prefix target)
>> +                                     machine
>> +                                     (matches rest ...)))
>> +                                ((_)
>> +                                 (error "unsupported target" target)))))
>> +                  ;; This basically reproduces the logic handling the
>> +                  ;; PLATFORM variable in the configure script.
>> +                  (matches ("x86_64"      => "x86_64")
>> +                           ("i586"        => "x86")
>> +                           ("i686"        => "x86")
>> +                           ("aarch64"     => "aarch64")
>> +                           ("arm"         => "arm")
>> +                           ("ppc64"       => "ppc64")
>> +                           ("ppc"         => "ppc")
>> +                           ("s390x"       => "s390x")
>> +                           ("sparc64"     => "sparcv9"))))
>
> I would move this outside the build code, such that new targets can be
> added without having to rebuild ck and dependents.

Done!

> Also, there are a few 'target-foo?' procedures in (guix utils) that can be used here (if
> it were moved outisde the build code).

I left the code as-is, as it seemed more uniform this way.

Thanks,

Maxim
Maxim Cournoyer March 8, 2022, 2:38 p.m. UTC | #6
Hi,

Maxime Devos <maximedevos@telenet.be> writes:

> Maxim Cournoyer schreef op ma 07-03-2022 om 23:38 [-0500]:
>> +              ;; The custom configure script doesn't make cross-compilation
>> +              ;; adjustments itself, so manually set the archiver, compiler
>> +              ;; and linker.  Even then, it is still broken and doesn't
>> +              ;; actually build any binary (see:
>> +              ;; https://github.com/concurrencykit/ck/issues/191).
>
> Since cross-compilation is currently broken, I think it would be
> acceptable to not attempt it in Guix, though I would like a nice
> comment and error instead of silently producing the wrong binaries:
>
>   (when target
>     ;; See <https://github.com/concurrencykit/ck/issues/191>
>     ;; and <https://issues.guix.gnu.org/54235>.
>     (error "ck is currently not cross-compilable"))

I agree.  Done!

Maxim
diff mbox series

Patch

diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index e53a7c865f..5fc923790a 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -38,6 +38,7 @@  (define-module (gnu packages c)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
+  #:use-module (guix store)
   #:use-module (gnu packages)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bootstrap)
@@ -896,6 +897,86 @@  (define-public aws-c-mqtt
     (home-page "https://github.com/awslabs/aws-c-mqtt")
     (license license:asl2.0)))
 
+(define-public ck
+  (package
+    (name "ck")
+    (version "0.7.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/concurrencykit/ck")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "020yzfpvymdc8lc44znlnxmxb8mvp42g4nb4p8k814klazqvwh0x"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'configure
+            ;; ck uses a custom configure script that stumbles on
+            ;; '--enable-fast-install', among other things.
+            (lambda* (#:key parallel-build? #:allow-other-keys)
+              ;; TODO: Move AR-FOR-TARGET and LD-FOR-TARGET to (guix utils).
+              (define* (ar-for-target #:optional (target #$(%current-target-system)))
+                (if target
+                    (string-append target "-ar")
+                    "ar"))
+              (define* (ld-for-target #:optional (target #$(%current-target-system)))
+                (if target
+                    (string-append target "-ld")
+                    "ld"))
+              (define (gnu-triplet->machine target)
+                (letrec-syntax
+                    ((matches (syntax-rules (=>)
+                                ((_ (target-prefix => machine) rest ...)
+                                 (if (string-prefix? target-prefix target)
+                                     machine
+                                     (matches rest ...)))
+                                ((_)
+                                 (error "unsupported target" target)))))
+                  ;; This basically reproduces the logic handling the
+                  ;; PLATFORM variable in the configure script.
+                  (matches ("x86_64"      => "x86_64")
+                           ("i586"        => "x86")
+                           ("i686"        => "x86")
+                           ("aarch64"     => "aarch64")
+                           ("arm"         => "arm")
+                           ("ppc64"       => "ppc64")
+                           ("ppc"         => "ppc")
+                           ("s390x"       => "s390x")
+                           ("sparc64"     => "sparcv9"))))
+              (define target-machine (and=> #$(%current-target-system)
+                                            gnu-triplet->machine))
+              ;; The custom configure script doesn't make cross-compilation
+              ;; adjustments itself, so manually set the archiver, compiler
+              ;; and linker.  Even then, it is still broken and doesn't
+              ;; actually build any binary (see:
+              ;; https://github.com/concurrencykit/ck/issues/191).
+              (setenv "AR" (ar-for-target))
+              (setenv "CC" #$(cc-for-target))
+              (setenv "LD" (ld-for-target))
+              (apply invoke "./configure"
+                     `(,@(if target-machine
+                             (list (string-append "--profile=" target-machine))
+                             '())
+                       ,(string-append "--prefix=" #$output)
+                       ,(string-append "--mandir=" #$output "/share/man")
+                       ,(string-append "--cores="
+                                       (if parallel-build?
+                                           (number->string (parallel-job-count))
+                                           "1")))))))))
+    (home-page "https://github.com/concurrencykit/ck")
+    (synopsis "C library for concurrent systems")
+    (description "Concurrency Kit (@code{ck}) provides concurrency primitives,
+safe memory reclamation mechanisms and non-blocking (including lock-free) data
+structures designed to aid in the research, design and implementation of high
+performance concurrent systems developed in C99+.")
+    (license (list license:bsd-2        ;everything except...
+                   license:asl2.0))))   ;src/ck_hp.c
+
 (define-public utf8-h
   ;; The latest tag is used as there is no release.
   (let ((commit "500d4ea9f4c3449e5243c088d8af8700f7189734")