unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 54235@debbugs.gnu.org
Subject: [bug#54235] [PATCH 2/3] gnu: Add ck.
Date: Mon, 07 Mar 2022 23:06:52 -0500	[thread overview]
Message-ID: <87y21lt7dv.fsf@gmail.com> (raw)
In-Reply-To: <285844ee246d8678ab563af9372d3245303dbb28.camel@telenet.be> (Maxime Devos's message of "Mon, 07 Mar 2022 21:57:35 +0100")

Hi Maxime,

Maxime Devos <maximedevos@telenet.be> writes:

> Maxim Cournoyer schreef op ma 07-03-2022 om 13:57 [-0500]:
>> It seems to be handled alright as it is; at least I was able to build
>> with:
>> 
>> ./pre-inst-env guix build --target=arm-linux-gnueabihf ck
>> [...]
>> done with offloaded '/gnu/store/m1gv4a1q9cv3ig9v4bymb9wd9l6g93y3-ck-0.7.1.drv'
>> successfully built /gnu/store/m1gv4a1q9cv3ig9v4bymb9wd9l6g93y3-ck-0.7.1.drv
>> /gnu/store/n6ipif548pxk0319kpchpxa7h5z6pzcm-ck-0.7.1
>
> Unfortunately, that is a rather unreliable check.
> This only checks that 'ck' could be compiled, but it does not check
> that 'ck' was actually compiled for arm-linux-gnueabihf instead of
> (%current-system).  It might still be the case that 'gcc' is used
> instead of '$TARGET-gcc'
>
> Could you run 'file' against /gnu/store/[...]/bin/* to verify things?
> On my x86-64-linux-gnu system, for a native binary, I get:
>
> a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
> linked, interpreter /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-
> 2.33/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped
>
> I'm not sure what you would get for an arm-linux-gnueabihf but it
> probably should not include '64-bit' or 'x86-64'.
>
> Assuming you have QEMU emulation _disabled_, you can also try running
> the binary on your (presumably non-arm) system and verify that it fails
> to start.
>
> Greetings,
> Maxime.

I tried hard to have the custom configure script collaborating, but in
the end, it appears critically broken.  This is what I tried:

--8<---------------cut here---------------start------------->8---
1 file changed, 52 insertions(+), 9 deletions(-)
gnu/packages/c.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------

modified   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)
@@ -916,16 +917,58 @@ (define-public ck
       #~(modify-phases %standard-phases
           (replace 'configure
             ;; ck uses a custom configure script that stumbles on
-            ;; '--enable-fast-install'.
+            ;; '--enable-fast-install', among other things.
             (lambda* (#:key parallel-build? #:allow-other-keys)
-              (invoke "./configure"
-                      (string-append "--prefix=" #$output)
-                      (string-append "--mandir=" #$output "/share/man")
-                      "--use-cc-builtins"
-                      (string-append "--cores="
-                                     (if parallel-build?
-                                         (number->string (parallel-job-count))
-                                         "1"))))))))
+              ;; 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))
+              (setenv "LDFLAGS" "")
+              (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,
--8<---------------cut here---------------end--------------->8---

But due to the test setting COMPILER failing, it doesn't set any
ALL_LIBS and thus doesn't build anything (see:
https://github.com/concurrencykit/ck/issues/191).

I also tried patching COMPILER to hard-code it to gcc and export
COMPILER to gcc, but that doesn't work too; it seems the ordering of the
logic in script is wrong.

I'd still keep the changes in, which will make life easier if/when
upstream fixes their script.

Thanks,

Maxim




  parent reply	other threads:[~2022-03-08  4:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 13:53 [bug#54235] [PATCH 0/3] Add sysbench Maxim Cournoyer
2022-03-03 14:05 ` [bug#54235] [PATCH 1/3] gnu: docbook-xml-4.1.2: Install an XML catalog file Maxim Cournoyer
2022-03-03 14:05   ` [bug#54235] [PATCH 2/3] gnu: Add ck Maxim Cournoyer
2022-03-03 16:55     ` Maxime Devos
2022-03-07 18:57       ` Maxim Cournoyer
2022-03-07 20:57         ` Maxime Devos
2022-03-08  1:47           ` Maxim Cournoyer
2022-03-08  4:06           ` Maxim Cournoyer [this message]
2022-03-03 14:05   ` [bug#54235] [PATCH 3/3] gnu: Add sysbench Maxim Cournoyer
2022-03-03 16:42     ` Maxime Devos
2022-03-07 18:59       ` Maxim Cournoyer
2022-03-08  4:38 ` [bug#54235] [PATCH v2 1/3] gnu: docbook-xml-4.1.2: Install an XML catalog file Maxim Cournoyer
2022-03-08  4:38   ` [bug#54235] [PATCH v2 2/3] gnu: Add ck Maxim Cournoyer
2022-03-08  9:39     ` Maxime Devos
2022-03-08 14:36       ` Maxim Cournoyer
2022-03-08  9:45     ` Maxime Devos
2022-03-08 14:38       ` Maxim Cournoyer
2022-03-08  9:49     ` Maxime Devos
2022-03-08 14:38       ` Maxim Cournoyer
2022-03-08  4:38   ` [bug#54235] [PATCH v2 3/3] gnu: Add sysbench Maxim Cournoyer
2022-03-08  9:42     ` Maxime Devos
2022-03-08 14:39       ` Maxim Cournoyer
2022-03-08 17:27         ` Maxime Devos
2022-03-18  5:38           ` bug#54235: [PATCH 0/3] " Maxim Cournoyer
2022-03-08 14:36 ` [bug#54235] [PATCH v3 1/4] gnu: docbook-xml-4.1.2: Install an XML catalog file Maxim Cournoyer
2022-03-08 14:36   ` [bug#54235] [PATCH v3 2/4] utils: Add ar-for-target and ld-for-target procedures Maxim Cournoyer
2022-03-08 14:36   ` [bug#54235] [PATCH v3 3/4] gnu: Add ck Maxim Cournoyer
2022-03-08 14:36   ` [bug#54235] [PATCH v3 4/4] gnu: Add sysbench Maxim Cournoyer

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y21lt7dv.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=54235@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).