guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/16: gnu: swi-prolog: Fix cross-compilation.


From: guix-commits
Subject: 03/16: gnu: swi-prolog: Fix cross-compilation.
Date: Fri, 11 Mar 2022 23:43:24 -0500 (EST)

apteryx pushed a commit to branch master
in repository guix.

commit 99a546df1fc10a16b565a27704807289ce11b3cd
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Fri Mar 4 13:00:59 2022 +0000

    gnu: swi-prolog: Fix cross-compilation.
    
    * gnu/package/prolog.scm (swi-prolog)
    [inputs]: Add bash-minimal.  Move perl, pkg-config and texinfo to...
    [native-inputs]: ... here.
    [tests?]: Remove argument.
    [configure-flags]: Set BSD_SIGNALS, PROG_SWIPL, QSORT_R_GNU and 
CMAKE_HOST_CC
    when cross-compiling.
    [phases]{fix-cross-references}: New phase.
    {delete-failing-tests}: Strip trailing #t and simplify the deletion of the
    "save" directory.
    
    Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
    Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
 gnu/packages/prolog.scm | 76 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 56 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/prolog.scm b/gnu/packages/prolog.scm
index 4eb0f4d3b6..6aa01ce871 100644
--- a/gnu/packages/prolog.scm
+++ b/gnu/packages/prolog.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,12 +22,15 @@
 
 (define-module (gnu packages prolog)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
+  #:use-module (guix utils)
   #:use-module (gnu packages backup)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages image)
@@ -97,36 +101,68 @@ manner.  It also features an interactive interpreter.")
     (build-system cmake-build-system)
     (arguments
      `(#:parallel-build? #t
-       #:tests? #t
        #:configure-flags
-       (list "-DINSTALL_DOCUMENTATION=ON"
-             "-DSWIPL_INSTALL_IN_LIB=OFF") ; FIXME: Breaks RUNPATH validation.
+       ,#~(list
+           #$@(if (%current-target-system)
+                  ;; Set this manually, otherwise CMake would need to
+                  ;; run a cross-compiled binary, which it can't do.
+                  ;; These values were found on a Linux system.
+                  #~("-DBSD_SIGNALS=1" "-DQSORT_R_GNU=1"
+                     ;; If absent, the non-existent 'cc' is used.
+                     "-DCMAKE_HOST_CC=gcc"
+                     ;; swi-prolog needs a native copy of itself for
+                     ;; cross-compilation.
+                     "-DSWIPL_NATIVE_FRIEND=/nowhere"
+                     (string-append "-DPROG_SWIPL="
+                                    #+(this-package-native-input "swi-prolog")
+                                    "/bin/swipl"))
+                  #~())
+           "-DINSTALL_DOCUMENTATION=ON"
+           "-DSWIPL_INSTALL_IN_LIB=OFF") ; FIXME: Breaks RUNPATH validation.
        #:phases
-       (modify-phases %standard-phases
-         ;; XXX: Delete the test phase that attempts to write to the
-         ;; immutable store.
-         (add-after 'unpack 'delete-failing-tests
-           (lambda _
-             (substitute* "src/CMakeLists.txt"
-               ((" save") ""))
-             (substitute* "src/test.pl"
-               (("testdir\\('Tests/save'\\).") ""))
-             (with-directory-excursion "src/Tests"
-               (for-each delete-file-recursively
-                         '("save")))
-             #t)))))
+       ,#~(modify-phases %standard-phases
+            ;; XXX: Delete the test phase that attempts to write to the
+            ;; immutable store.
+            (add-after 'unpack 'delete-failing-tests
+              (lambda _
+                (substitute* "src/CMakeLists.txt"
+                  ((" save") ""))
+                (substitute* "src/test.pl"
+                  (("testdir\\('Tests/save'\\).") ""))
+                (delete-file-recursively "src/Tests/save")))
+            #$@(if (%current-target-system)
+                   ;; Prevent man_server.pl and swipl-lfr.pl from keeping a
+                   ;; reference to the native swi-prolog.
+                   ;; FIXME: libswipl.so and swipl-ld keep a reference to the
+                   ;; cross-compiler.
+                   #~((add-after 'install 'fix-cross-references
+                        (lambda _
+                          (define bin `(,(string-append #$output "/bin")))
+                          (for-each (lambda (file) (patch-shebang file bin))
+                                    (find-files #$output ".pl$")))))
+                   #~()))))
     (native-inputs
-     `(("zlib" ,zlib)
+     `(,@(if (%current-target-system)
+             (begin
+               (unless (equal? (target-64bit?)
+                               (target-64bit? (%current-system)))
+                 (error "swi-prolog requires --system and --target to have \
+the same word size"))
+               `(("swi-prolog" ,this-package)))
+             '())
+       ("texinfo" ,texinfo)
+       ("perl" ,perl)
+       ("pkg-config" ,pkg-config)))
+    (inputs
+     `(("bash-minimal" ,bash-minimal)   ;for some scripts in 'lib'
+       ("zlib" ,zlib)
        ("gmp" ,gmp)
        ("readline" ,readline)
-       ("texinfo" ,texinfo)
        ("libarchive" ,libarchive)
        ("libunwind" ,libunwind)
        ("libjpeg" ,libjpeg-turbo)
        ("libxft" ,libxft)
        ("fontconfig" ,fontconfig)
-       ("perl" ,perl)
-       ("pkg-config" ,pkg-config)
        ("openssl" ,openssl)))
     (home-page "https://www.swi-prolog.org/";)
     (synopsis "ISO/Edinburgh-style Prolog interpreter")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]