unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#68133] [PATCH] gnu: glew: Fix cross-compiling.
@ 2023-12-30  4:53 Zheng Junjie
  2024-01-03 14:25 ` Mathieu Othacehe
  0 siblings, 1 reply; 6+ messages in thread
From: Zheng Junjie @ 2023-12-30  4:53 UTC (permalink / raw)
  To: 68133

gnu/packages/gl.scm(glew):
[arguments]<#:make-flags>: when cross-compiling, use {cc,strip}-for-target.

Change-Id: I365f6635120a85359083beb88cb138f09a99fe33
---
 gnu/packages/gl.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index 192b5e84e0..56a1def37a 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -690,7 +690,12 @@ (define-public glew
                   #t))))
     (build-system gnu-build-system)
     (arguments
-     (list #:make-flags #~(list (string-append "GLEW_PREFIX=" #$output)
+     (list #:make-flags #~(list #$@(if (%current-target-system)
+                                       #~((string-append "CC=" #$(cc-for-target))
+                                          (string-append "LD=" #$(cc-for-target))
+                                          (string-append "STRIP=" #$(strip-for-target)))
+                                       #~())
+                                (string-append "GLEW_PREFIX=" #$output)
                                 (string-append "GLEW_DEST=" #$output))
            #:phases
            #~(modify-phases %standard-phases

base-commit: f76ca2b0e894c244d5011a32b30dee8fd874e322
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#68133] [PATCH] gnu: glew: Fix cross-compiling.
  2023-12-30  4:53 [bug#68133] [PATCH] gnu: glew: Fix cross-compiling Zheng Junjie
@ 2024-01-03 14:25 ` Mathieu Othacehe
  2024-01-04 12:40   ` Zheng Junjie
  0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Othacehe @ 2024-01-03 14:25 UTC (permalink / raw)
  To: Zheng Junjie; +Cc: 68133


Hello,

> gnu/packages/gl.scm(glew):
> [arguments]<#:make-flags>: when cross-compiling, use {cc,strip}-for-target.

When running:

./pre-inst-env guix build --target=aarch64-linux-gnu glew

I have the following error message:

--8<---------------cut here---------------start------------->8---
Run-time dependency libudev found: NO (tried pkgconfig and cmake)

../mesa-23.2.1/meson.build:1682:13: ERROR: Failed running '/gnu/store/fzmc9w4i1lyqi0v62w5jpdxi6h9cbnyh-llvm-for-mesa-15.0.7/bin/llvm-config', binary or interpreter not executable.
Possibly wrong architecture or the executable bit is not set.

A full log can be found at /tmp/guix-build-mesa-23.2.1.drv-0/build/meson-logs/meson-log.txt
error: in phase 'configure': uncaught exception:
--8<---------------cut here---------------end--------------->8---

Did I miss something?

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#68133] [PATCH] gnu: glew: Fix cross-compiling.
  2024-01-03 14:25 ` Mathieu Othacehe
@ 2024-01-04 12:40   ` Zheng Junjie
  2024-01-09  9:35     ` bug#68133: " Mathieu Othacehe
  0 siblings, 1 reply; 6+ messages in thread
From: Zheng Junjie @ 2024-01-04 12:40 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: Efraim Flashner, 68133

[-- Attachment #1: Type: text/plain, Size: 929 bytes --]


Mathieu Othacehe <othacehe@gnu.org> writes:

> Hello,
>
>> gnu/packages/gl.scm(glew):
>> [arguments]<#:make-flags>: when cross-compiling, use {cc,strip}-for-target.
>
> When running:
>
> ./pre-inst-env guix build --target=aarch64-linux-gnu glew
>
> I have the following error message:
>
> Run-time dependency libudev found: NO (tried pkgconfig and cmake)
>
> ../mesa-23.2.1/meson.build:1682:13: ERROR: Failed running '/gnu/store/fzmc9w4i1lyqi0v62w5jpdxi6h9cbnyh-llvm-for-mesa-15.0.7/bin/llvm-config', binary or interpreter not executable.
> Possibly wrong architecture or the executable bit is not set.
>
> A full log can be found at /tmp/guix-build-mesa-23.2.1.drv-0/build/meson-logs/meson-log.txt
> error: in phase 'configure': uncaught exception:
>
> Did I miss something?

i think because binfmt leak into build environment, so host's
llvm-config can executed.
please try this patch, use meson's cmake module to find llvm.


[-- Attachment #2: 0001-gnu-mesa-fix-cross-compiling.patch --]
[-- Type: text/x-patch, Size: 6151 bytes --]

From 015ac9468acefe959dea570fc1661bcbce6ebaf8 Mon Sep 17 00:00:00 2001
Message-ID: <015ac9468acefe959dea570fc1661bcbce6ebaf8.1704372069.git.zhengjunjie@iscas.ac.cn>
From: Zheng Junjie <zhengjunjie@iscas.ac.cn>
Date: Thu, 4 Jan 2024 20:33:13 +0800
Subject: [PATCH] gnu: mesa: fix cross-compiling.

* gnu/packages/gl.scm(mesa)[native-inputs]: when cross-compile, add
cmake-minimal-cross.
[arguments]: adjust fix-cross-compiling to find llvm.

* gnu/packages/llvm.scm(llvm-for-mesa)
[arguments]<#:configure-flags>: When cross-compile, set
-DBUILD_SHARED_LIBS:BOOL=TRUE and -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE,
remove -DLLVM_LINK_LLVM_DYLIB.* .
<#:phases>: when cross-compile, remove delete-static-libraries phase.

Change-Id: If10dec7695e62604e080230e10f2b8d7167f660b
---
 gnu/packages/gl.scm   | 17 +++++++++++------
 gnu/packages/llvm.scm | 28 +++++++++++++++++++---------
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index b0ee413acd..91fa8f642f 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -18,7 +18,7 @@
 ;;; Copyright © 2021, 2022, 2023 John Kehayias <john.kehayias@protonmail.com>
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2023 Kaelyn Takata <kaelyn.alexi@protonmail.com>
-;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
+;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -62,6 +62,7 @@ (define-module (gnu packages gl)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix hg-download)
+  #:use-module (gnu packages cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system meson)
@@ -338,7 +339,8 @@ (define-public mesa
             python-wrapper
             (@ (gnu packages base) which)
             (if (%current-target-system)
-              (list pkg-config-for-build
+              (list cmake-minimal-cross
+                    pkg-config-for-build
                     wayland
                     wayland-protocols)
               '())))
@@ -415,10 +417,13 @@ (define-public mesa
        #~(modify-phases %standard-phases
          #$@(if (%current-target-system)
               #~((add-after 'unpack 'fix-cross-compiling
-                   (lambda* (#:key inputs #:allow-other-keys)
-                     ;; It isn't a problem to use the host's llvm-config.
-                     (setenv "LLVM_CONFIG"
-                             (search-input-file inputs "/bin/llvm-config")))))
+                   (lambda* (#:key native-inputs #:allow-other-keys)
+                     ;; when cross compile, we use cmake to find llvm, not llvm-config,
+                     ;; because llvm-conifg cannot be executed
+                     ;; see https://github.com/llvm/llvm-project/issues/58984
+                     (setenv "CMAKE"
+                             (search-input-file
+                              native-inputs "/bin/cmake")))))
               #~())
          (add-after 'unpack 'disable-failing-test
            (lambda _
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 6abd1a67d7..a3176c6dae 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -27,6 +27,7 @@
 ;;; Copyright © 2022 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2022 Zhu Zihao <all_but_last@163.com>
 ;;; Copyright © 2023 Hilton Chain <hako@ultrarare.space>
+;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2169,20 +2170,29 @@ (define-public llvm-for-mesa
               ;; AMDGPU is needed by the vulkan drivers.
               #$(string-append "-DLLVM_TARGETS_TO_BUILD="
                                (system->llvm-target) ";AMDGPU")
+              #$@(if (%current-target-system)
+                     '("-DBUILD_SHARED_LIBS:BOOL=TRUE"
+                       "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE")
+                    '())
               ;; Skipping tools and utils decreases the output by ~100 MiB.
               "-DLLVM_BUILD_TOOLS=NO"
-              (remove (cut string-match
-                           "-DLLVM_(TARGETS_TO_BUILD|INSTALL_UTILS).*" <>)
+              (remove
+               (cut string-match
+                    #$(if (%current-target-system)
+                          "-DLLVM_(LINK_LLVM_DYLIB|TARGETS_TO_BUILD|INSTALL_UTILS).*"
+                          "-DLLVM_(TARGETS_TO_BUILD|INSTALL_UTILS).*") <>)
                       #$cf)))
          ((#:phases phases '%standard-phases)
           #~(modify-phases #$phases
-              (add-after 'install 'delete-static-libraries
-                ;; If these are just relocated then llvm-config can't find them.
-                (lambda* (#:key outputs #:allow-other-keys)
-                  (for-each delete-file
-                            (find-files (string-append
-                                          (assoc-ref outputs "out") "/lib")
-                                        "\\.a$"))))
+              #$@(if (%current-target-system)
+                     '()
+                     #~((add-after 'install 'delete-static-libraries
+                          ;; If these are just relocated then llvm-config can't find them.
+                          (lambda* (#:key outputs #:allow-other-keys)
+                            (for-each delete-file
+                                      (find-files (string-append
+                                                   (assoc-ref outputs "out") "/lib")
+                                                  "\\.a$"))))))
               ;; llvm-config is how mesa and others find the various
               ;; libraries and headers they use.
               (add-after 'install 'build-and-install-llvm-config

base-commit: 7b0863f07a113caef26fea13909bd97d250b629e
prerequisite-patch-id: b3a67130858eb3c97f43099cb3b2f7978d5f1a79
prerequisite-patch-id: 007807771d1614f2e42f5df56b7d1875b1966031
-- 
2.41.0


[-- Attachment #3: Type: text/plain, Size: 26 bytes --]


>
> Thanks,
>
> Mathieu


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#68133: [PATCH] gnu: glew: Fix cross-compiling.
  2024-01-04 12:40   ` Zheng Junjie
@ 2024-01-09  9:35     ` Mathieu Othacehe
  2024-01-10 12:19       ` [bug#68133] [PATCH] gnu: mesa: Fix cross-compiling again Z572
  0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Othacehe @ 2024-01-09  9:35 UTC (permalink / raw)
  To: Zheng Junjie; +Cc: Efraim Flashner, 68133-done


Hello,

> * gnu/packages/gl.scm(mesa)[native-inputs]: when cross-compile, add
> cmake-minimal-cross.
> [arguments]: adjust fix-cross-compiling to find llvm.
>
> * gnu/packages/llvm.scm(llvm-for-mesa)
> [arguments]<#:configure-flags>: When cross-compile, set
> -DBUILD_SHARED_LIBS:BOOL=TRUE and -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE,
> remove -DLLVM_LINK_LLVM_DYLIB.* .
> <#:phases>: when cross-compile, remove delete-static-libraries phase.

I amended the commit message and applied,

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#68133] [PATCH] gnu: mesa: Fix cross-compiling again.
  2024-01-09  9:35     ` bug#68133: " Mathieu Othacehe
@ 2024-01-10 12:19       ` Z572
  2024-01-10 14:30         ` Mathieu Othacehe
  0 siblings, 1 reply; 6+ messages in thread
From: Z572 @ 2024-01-10 12:19 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 68133, efraim

[-- Attachment #1: Type: text/plain, Size: 802 bytes --]


Mathieu Othacehe <othacehe@gnu.org> writes:

> Hello,
>
>> * gnu/packages/gl.scm(mesa)[native-inputs]: when cross-compile, add
>> cmake-minimal-cross.
>> [arguments]: adjust fix-cross-compiling to find llvm.
>>
>> * gnu/packages/llvm.scm(llvm-for-mesa)
>> [arguments]<#:configure-flags>: When cross-compile, set
>> -DBUILD_SHARED_LIBS:BOOL=TRUE and -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE,
>> remove -DLLVM_LINK_LLVM_DYLIB.* .
>> <#:phases>: when cross-compile, remove delete-static-libraries phase.
>
> I amended the commit message and applied,
>
> Thanks,
>
> Mathieu

after mesa-updates merge, mesa's meson.build use config-tool method to
find llvm, so cross compile break again, this patch fix it.

``` meson.build
1712|    method : host_machine.system() == 'windows' ? 'auto' : 'config-tool',
```


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-mesa-fix-cross-compiling-again.patch --]
[-- Type: text/x-patch, Size: 1328 bytes --]

From c7b0f3a8f4886da8a3b120758409abf3777a82f8 Mon Sep 17 00:00:00 2001
Message-ID: <c7b0f3a8f4886da8a3b120758409abf3777a82f8.1704889051.git.zhengjunjie@iscas.ac.cn>
From: Zheng Junjie <zhengjunjie@iscas.ac.cn>
Date: Wed, 10 Jan 2024 20:14:32 +0800
Subject: [PATCH] gnu: mesa: fix cross-compiling again.

* gnu/packages/gl.scm(mesa)[arguments]<#:phases>: when cross compiling, force
use cmake method to find llvm.

Change-Id: I27f6f4d9d71028c15588eeade48d3a918c042b9c
---
 gnu/packages/gl.scm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index 7998142b4d..49dc878c02 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -421,6 +421,9 @@ (define-public mesa
                      ;; When cross compiling, we use cmake to find llvm, not
                      ;; llvm-config, because llvm-config cannot be executed
                      ;; see https://github.com/llvm/llvm-project/issues/58984
+                     (substitute* "meson.build"
+                       (("method : host_machine\\.system.*")
+                        "method : 'cmake',\n"))
                      (setenv "CMAKE"
                              (search-input-file
                               native-inputs "/bin/cmake")))))

base-commit: e541f9593f8bfc84b6140c2408b393243289fae6
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#68133] [PATCH] gnu: mesa: Fix cross-compiling again.
  2024-01-10 12:19       ` [bug#68133] [PATCH] gnu: mesa: Fix cross-compiling again Z572
@ 2024-01-10 14:30         ` Mathieu Othacehe
  0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Othacehe @ 2024-01-10 14:30 UTC (permalink / raw)
  To: Z572; +Cc: 68133, efraim


Hello,

> after mesa-updates merge, mesa's meson.build use config-tool method to
> find llvm, so cross compile break again, this patch fix it.
>
> ``` meson.build
> 1712|    method : host_machine.system() == 'windows' ? 'auto' : 'config-tool',
> ```

Applied with an amended commit message,

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-10 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-30  4:53 [bug#68133] [PATCH] gnu: glew: Fix cross-compiling Zheng Junjie
2024-01-03 14:25 ` Mathieu Othacehe
2024-01-04 12:40   ` Zheng Junjie
2024-01-09  9:35     ` bug#68133: " Mathieu Othacehe
2024-01-10 12:19       ` [bug#68133] [PATCH] gnu: mesa: Fix cross-compiling again Z572
2024-01-10 14:30         ` Mathieu Othacehe

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).