Package: guix-patches;
Reported by: Julien Lepiller <julien <at> lepiller.eu>
Date: Thu, 3 Mar 2022 16:04:02 UTC
Severity: normal
Tags: patch
To reply to this bug, email your comments to 54239 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:04:02 GMT) Full text and rfc822 format available.Julien Lepiller <julien <at> lepiller.eu>
:guix-patches <at> gnu.org
.
(Thu, 03 Mar 2022 16:04:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: guix-patches <at> gnu.org Subject: [PATCH] gnu: Add cross-clang. Date: Thu, 3 Mar 2022 17:02:52 +0100
Hi Guix! This small patch series adds cross-clang, a cross-compiler version of clang. Clang doesn't really make a distinction between a native and a cross-build, it is already a cross-compiler, but this ensures that: 1. it actually works 2. it targets (%current-target-architecture) by default The rest of the series ensures that libcxx and libcxxabi can be cross-compiled with it.
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:09:02 GMT) Full text and rfc822 format available.Message #8 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH 1/5] gnu: Add cross-llvm. Date: Thu, 3 Mar 2022 17:07:43 +0100
* gnu/packages/llvm.scm (cross-llvm): New variable. --- gnu/packages/llvm.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index eb949bed1b..d6e9846699 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -18,7 +18,7 @@ ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2021 Maxime Devos <maximedevos <at> telenet.be> ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> -;;; Copyright © 2021 Julien Lepiller <julien <at> lepiller.eu> +;;; Copyright © 2021, 2022 Julien Lepiller <julien <at> lepiller.eu> ;;; Copyright © 2021 Lars-Dominik Braun <lars <at> 6xq.net> ;;; Copyright © 2021 Guillaume Le Vaillant <glv <at> posteo.net> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> @@ -74,7 +74,8 @@ (define-module (gnu packages llvm) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (make-lld-wrapper - system->llvm-target)) + system->llvm-target + cross-llvm)) (define* (system->llvm-target #:optional (system (or (and=> (%current-target-system) @@ -99,6 +100,22 @@ (define* (system->llvm-target #:optional ("i686" => "X86") ("i586" => "X86")))) +(define (cross-llvm llvm target) + "Return a native LLVM package that targets a different system. The resulting +libraries are running on the host but target a different system by default. +This packge can be used to control clang's default target." + (package + (inherit llvm) + (arguments + (substitute-keyword-arguments (package-arguments llvm) + ((#:configure-flags flags) + #~(append + (list + (string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" #$target) + (string-append "-DLLVM_TARGET_ARCH=" + #$(system->llvm-target (gnu-triplet->nix-system target)))) + #$flags)))))) + (define (llvm-uri component version) ;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz' ;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name. -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:09:02 GMT) Full text and rfc822 format available.Message #11 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH 2/5] gnu: Add cross-clang. Date: Thu, 3 Mar 2022 17:07:44 +0100
* gnu/packages/llvm.scm (cross-clang): New variable. --- gnu/packages/llvm.scm | 125 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index d6e9846699..c02f8e5c7a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -54,6 +54,7 @@ (define-module (gnu packages llvm) #:use-module (guix build-system trivial) #:use-module (gnu packages) #:use-module (gnu packages base) + #:use-module (gnu packages cross-base) #:use-module (gnu packages gcc) #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker #:use-module (gnu packages check) ;python-lit @@ -75,7 +76,8 @@ (define-module (gnu packages llvm) #:use-module (ice-9 match) #:export (make-lld-wrapper system->llvm-target - cross-llvm)) + cross-llvm + cross-clang)) (define* (system->llvm-target #:optional (system (or (and=> (%current-target-system) @@ -1023,6 +1025,127 @@ (define-public clang-runtime clang-runtime-13) (define-public clang clang-13) (define-public clang-toolchain clang-toolchain-13) +(define* (cross-clang target + #:optional + (libc (cross-libc target)) + (xgcc (cross-gcc target + #:xbinutils (cross-binutils target) + #:libc (cross-libc target))) + (clang clang)) + "Return a cross-clang compiler for target." + (package + (inherit clang) + (version (package-version clang)) + ;; Support the same variables as clang, even in cross-compilation context. + ;; Clang does not make a difference between native and cross-compilation. + (search-paths + (append + (list + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files '("lib" "lib64")))) + (package-native-search-paths clang))) + (native-search-paths '()) + (arguments + (substitute-keyword-arguments (package-arguments clang) + ((#:configure-flags _) + `(list "-DCLANG_INCLUDE_TESTS=True" + (string-append "-DGCC_INSTALL_PREFIX=" + (assoc-ref %build-inputs "cross-gcc-lib")) + (string-append "-DC_INCLUDE_DIRS=" + (assoc-ref %build-inputs "target-libc") + "/include"))) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'add-missing-libdir + (lambda _ + ;; cross-gcc installs its libraries in <target>/lib instead of + ;; lib. + (substitute* "lib/Driver/ToolChain.cpp" + (("\"-L\"\\) \\+ LibPath\\)\\);") + ,(string-append "\"-L\") + LibPath)); + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-L\") + " + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" + target "/lib\"))); + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-rpath=\") + " + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" + target "/lib\")));"))))) + (add-after 'unpack 'support-cross-library-path + (lambda _ + ;; LIBRARY_PATH is only supported for native builds, but we still + ;; need it (or CROSS_LIBRARY_PATH to be precise) when + ;; cross-compiling + (substitute* "lib/Driver/ToolChains/CommonArgs.cpp" + (("LIBRARY_PATH\"") + "LIBRARY_PATH\"); + } else { + addDirectoryList(Args, CmdArgs, \"-L\", \"CROSS_LIBRARY_PATH\"")))) + (replace 'set-glibc-file-names + (lambda* (#:key inputs #:allow-other-keys) + (let ((libc (assoc-ref inputs "target-libc")) + (compiler-rt (assoc-ref inputs "clang-runtime")) + (gcc (assoc-ref inputs "cross-gcc"))) + (setenv "LIBRARY_PATH" + (string-append + (assoc-ref inputs "libc") "/lib:" (getenv "LIBRARY_PATH"))) + ,@(cond + ((version>=? version "6.0") + `(;; Link to libclang_rt files from clang-runtime. + (substitute* "lib/Driver/ToolChain.cpp" + (("getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\""))) + + ;; Make "LibDir" refer to <glibc>/lib so that it + ;; uses the right dynamic linker file name. + (substitute* "lib/Driver/ToolChains/Linux.cpp" + (("(^[[:blank:]]+LibDir = ).*" _ declaration) + (string-append declaration "\"" libc "/lib\";\n")) + + ;; Make clang look for libstdc++ in the right + ;; location. + (("LibStdCXXIncludePathCandidates\\[\\] = \\{") + (string-append + "LibStdCXXIncludePathCandidates[] = { \"" gcc + "/include/c++\",")) + + ;; Make sure libc's libdir is on the search path, to + ;; allow crt1.o & co. to be found. + (("@GLIBC_LIBDIR@") + (string-append libc "/lib"))))) + (else + `((substitute* "lib/Driver/Tools.cpp" + ;; Patch the 'getLinuxDynamicLinker' function so that + ;; it uses the right dynamic linker file name. + (("/lib64/ld-linux-x86-64.so.2") + (string-append libc ,(glibc-dynamic-linker)))) + + ;; Link to libclang_rt files from clang-runtime. + ;; This substitution needed slight adjustment in 3.8. + ,@(if (version>=? version "3.8") + '((substitute* "lib/Driver/Tools.cpp" + (("TC\\.getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\"")))) + '((substitute* "lib/Driver/ToolChain.cpp" + (("getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\""))))) + + ;; Make sure libc's libdir is on the search path, to + ;; allow crt1.o & co. to be found. + (substitute* "lib/Driver/ToolChains.cpp" + (("@GLIBC_LIBDIR@") + (string-append libc "/lib"))))))))))))) + (inputs + `(("target-libc" ,libc) + ("cross-gcc-lib" ,xgcc "lib") + ("cross-gcc" ,xgcc) + ,@(package-inputs clang))) + (propagated-inputs + (modify-inputs (package-propagated-inputs clang) + (replace "llvm" + (cross-llvm + (car (assoc-ref (package-propagated-inputs clang) "llvm")) + target)))))) + (define-public llvm-for-rocm (package ;; Actually based on LLVM 13 as of v4.3, but llvm-12 works just fine. -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:09:02 GMT) Full text and rfc822 format available.Message #14 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH 3/5] gnu: libcxx: Allow cross-compilation. Date: Thu, 3 Mar 2022 17:07:45 +0100
* gnu/packages/llvm.scm (libcxx)[native-inputs]: Use cross-clang for cross-compilation. Move llvm to... [inputs]: ...here. [arguments]: adjust CROSS_INCLUDE_PATH when cross-compiling. (libcxx-6)[native-inputs]: Use cross-clang for cross-compilation. Move llvm to... [inputs]: ...here. --- gnu/packages/llvm.scm | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index c02f8e5c7a..9b5e495d08 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1026,7 +1026,7 @@ (define-public clang clang-13) (define-public clang-toolchain clang-toolchain-13) (define* (cross-clang target - #:optional + #:key (libc (cross-libc target)) (xgcc (cross-gcc target #:xbinutils (cross-binutils target) @@ -1343,8 +1343,9 @@ (define-public libcxx `(#:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH - (lambda* (#:key inputs #:allow-other-keys) - (let ((gcc (assoc-ref inputs "gcc"))) + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (let ((gcc (or (assoc-ref (or native-inputs inputs) "gcc"))) + (cross-gcc (assoc-ref native-inputs "cross-gcc"))) ;; Hide GCC's C++ headers so that they do not interfere with ;; the ones we are attempting to build. (setenv "CPLUS_INCLUDE_PATH" @@ -1352,12 +1353,23 @@ (define-public libcxx (string-split (getenv "CPLUS_INCLUDE_PATH") #\:)) ":")) + (when cross-gcc + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join (delete (string-append cross-gcc "/include/c++") + (string-split (getenv "CPLUS_INCLUDE_PATH") + #\:)) + ":")) + (format #t + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH"))) (format #t "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" - (getenv "CPLUS_INCLUDE_PATH")) - #t)))))) + (getenv "CPLUS_INCLUDE_PATH")))))))) + (inputs (list llvm-9)) (native-inputs - (list clang llvm)) + (list (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang-9) + clang-9))) (home-page "https://libcxx.llvm.org") (synopsis "C++ standard library") (description @@ -1378,8 +1390,11 @@ (define-public libcxx-6 (sha256 (base32 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) + (inputs (list llvm-6)) (native-inputs - (list clang-6 llvm-6)))) + (list (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang-6) + clang-6))))) (define-public libcxxabi-6 (package -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:09:03 GMT) Full text and rfc822 format available.Message #17 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH 4/5] gnu: libcxxabi-6: Allow cross-compilation. Date: Thu, 3 Mar 2022 17:07:46 +0100
* gnu/packages/llvm.scm (libcxxabi-6)[native-inputs]: Use cross-clang for cross-compilation. Move llvm and libcxx to... [inputs]: ...here. [arguments]<adjust-CPLUS_INCLUDE_PATH>: Also adjust CROSS_CPLUS_INCLUDE_PATH when necessary. --- gnu/packages/llvm.scm | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 9b5e495d08..63b55ef3df 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1422,19 +1422,43 @@ (define-public libcxxabi-6 (modify-phases (@ (guix build cmake-build-system) %standard-phases) (add-after 'unpack 'chdir (lambda _ (chdir "libcxxabi"))) - (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH - (lambda* (#:key inputs #:allow-other-keys) - (let ((gcc (assoc-ref inputs "gcc"))) + (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (define (delete* what lst) + (if (null? what) + lst + (delete* (cdr what) (delete (car what) lst)))) + + (let ((gcc (or (assoc-ref inputs "gcc") (assoc-ref native-inputs "gcc"))) + (cross-gcc (assoc-ref native-inputs "cross-gcc"))) ;; Hide GCC's C++ headers so that they do not interfere with ;; the ones we are attempting to build. (setenv "CPLUS_INCLUDE_PATH" (string-join (cons (string-append (assoc-ref inputs "libcxx") "/include/c++/v1") - (delete (string-append gcc "/include/c++") - (string-split (getenv "CPLUS_INCLUDE_PATH") - #\:))) + (delete* + `(,(string-append gcc "/include/c++") + ,@(if cross-gcc + `(,(string-append cross-gcc "/include/c++")) + '())) + (string-split (getenv "CPLUS_INCLUDE_PATH") + #\:))) ":")) + (when cross-gcc + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join + (cons (string-append + (assoc-ref inputs "libcxx") "/include/c++/v1") + (delete* + (list (string-append cross-gcc "/include/c++") + (string-append gcc "/include/c++")) + (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") + #\:))) + ":")) + (format #true + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH"))) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH"))))) @@ -1444,8 +1468,11 @@ (define-public libcxxabi-6 (assoc-ref outputs "out") "/include"))) (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) + (inputs (list llvm-6 libcxx-6)) (native-inputs - (list clang-6 llvm-6 libcxx-6)) + (list (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang-6) + clang-6))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:09:03 GMT) Full text and rfc822 format available.Message #20 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH 5/5] gnu: Add libcxxabi-9. Date: Thu, 3 Mar 2022 17:07:47 +0100
* gnu/packages/llvm.scm (libcxxabi-9): New variable. (libcxxabi-6): Inherit from it. --- gnu/packages/llvm.scm | 72 +++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 63b55ef3df..f1631bbe70 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1396,20 +1396,17 @@ (define-public libcxx-6 (cross-clang (%current-target-system) #:clang clang-6) clang-6))))) -(define-public libcxxabi-6 +(define-public libcxxabi-9 (package (name "libcxxabi") - (version "6.0.1") + (version (package-version clang-9)) (source (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/llvm/llvm-project") - (commit (string-append "llvmorg-" version)))) - (file-name (git-file-name name version)) + (method url-fetch) + (uri (llvm-uri "libcxxabi" version)) (sha256 (base32 - "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g")))) + "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8")))) (build-system cmake-build-system) (arguments `(#:configure-flags @@ -1420,8 +1417,6 @@ (define-public libcxxabi-6 "-DCMAKE_CXX_COMPILER=clang++") #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) - (add-after 'unpack 'chdir - (lambda _ (chdir "libcxxabi"))) (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs native-inputs #:allow-other-keys) (define (delete* what lst) @@ -1455,10 +1450,10 @@ (define-public libcxxabi-6 (string-append gcc "/include/c++")) (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") #\:))) - ":")) - (format #true - "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" - (getenv "CROSS_CPLUS_INCLUDE_PATH"))) + ":"))) + (format #true + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH")) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH"))))) @@ -1466,13 +1461,19 @@ (define-public libcxxabi-6 (lambda* (#:key outputs #:allow-other-keys) (let ((include-dir (string-append (assoc-ref outputs "out") "/include"))) - (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) - (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) - (inputs (list llvm-6 libcxx-6)) + (mkdir-p include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/__cxxabi_config.h") + include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/cxxabi.h") + include-dir))))))) + (inputs + (list llvm-9 libcxx)) (native-inputs (list (if (%current-target-system) - (cross-clang (%current-target-system) #:clang clang-6) - clang-6))) + (cross-clang (%current-target-system) #:clang clang-9) + clang-9))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description @@ -1480,6 +1481,39 @@ (define-public libcxxabi-6 standard C++ library.") (license license:expat))) +(define-public libcxxabi-6 + (package + (inherit libcxxabi-9) + (name "libcxxabi") + (version "6.0.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/llvm/llvm-project") + (commit (string-append "llvmorg-" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g")))) + (arguments + (substitute-keyword-arguments (package-arguments libcxxabi-9) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'chdir + (lambda _ (chdir "libcxxabi"))) + (replace 'install-headers + (lambda* (#:key outputs #:allow-other-keys) + (let ((include-dir (string-append + (assoc-ref outputs "out") "/include"))) + (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) + (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))) + (inputs (list llvm-6 libcxx-6)) + (native-inputs + (list (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang-6) + clang-6))))) + (define-public libcxx+libcxxabi-6 (package (inherit libcxx-6) -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 16:41:02 GMT) Full text and rfc822 format available.Message #23 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Thu, 03 Mar 2022 17:40:36 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op do 03-03-2022 om 17:02 [+0100]: > Hi Guix! > > This small patch series adds cross-clang, a cross-compiler version of > clang. Clang doesn't really make a distinction between a native and a > cross-build, it is already a cross-compiler, but this ensures that: > > 1. it actually works > 2. it targets (%current-target-architecture) by default Do you mean (%current-target-system)? Also, WDYT of making 'cross-clang' a memoising procedure, such that there's only one package object for a cross-clang of a fixed target system (and version)? > (native-inputs > - (list clang llvm)) > + (list (if (%current-target-system) > + (cross-clang (%current-target-system) #:clang clang-9) > + clang-9))) Probably a few other packages built with clang need such a thing as well. How about making doing the right thing a bit easier? Suggestion: introduce a 'clang-for-target' procedure, automatically returning the right clang: (define (clang-for-target #:optional (clang clang)) (if (%current-target-system) (cross-clang [...]) clang)) ; not cross-compiling then packages just need to do (native-inputs (list (clang-for-target) libfoo libbar ...)) The rest of the series ensures that libcxx and libcxxabi can be cross-compiled with it. Customarily, cross-compilers are named $TARGET-foo. WDYT of renaming the clang binary to '$TARGET-clang', such that a package can have both a native clang and a cross-clang in native-inputs if desired? Also, Autoconf looks for $TARGET-compiler, where compiler is at least gcc, but possibly also clang And perhaps the package name can be changed '$TARGET-clang' like done for gcc? > + ;; Support the same variables as clang, even in cross-compilation > + ;; context. > + ;; Clang does not make a difference between native and > + ;; cross-compilation. Upstream clang doesn't, but this is in a 'cross-clang' procedure, so I think it would make sense for Guix' cross-clang to ignore LIBRARY_PATH and only use CROSS_LIBRARY_PATH. Mixing up C_INCLUDE_PATH and CROSS_C_INCLUDE_PATH (& friends) is unlikely to lead anything good, e.g. include/bits/setjmp.h is architecture-dependent. > + (files '("lib" "lib64")))) I don't think Guix does a "lib" / "lib64" split, "lib" might be sufficient. At least, there are a few comments like ;; Force powerpc libdir to be /lib and not /lib64 in Guix (though the gcc packages still includes "lib64" but maybe that's only due to historical reasons). How does this patch series interact with 'with-c-toolchain'? Would "guix build hello --target=aarch64-linux-gnu --with-c-toolchain=..." succesfully compile 'hello' with clang? Greetings, Maxime.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 18:36:01 GMT) Full text and rfc822 format available.Message #26 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Maxime Devos <maximedevos <at> telenet.be> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Thu, 3 Mar 2022 19:35:03 +0100
Le Thu, 03 Mar 2022 17:40:36 +0100, Maxime Devos <maximedevos <at> telenet.be> a écrit : > Julien Lepiller schreef op do 03-03-2022 om 17:02 [+0100]: > > Hi Guix! > > > > This small patch series adds cross-clang, a cross-compiler version > > of clang. Clang doesn't really make a distinction between a native > > and a cross-build, it is already a cross-compiler, but this ensures > > that: > > > > 1. it actually works > > 2. it targets (%current-target-architecture) by default > > Do you mean (%current-target-system)? yes, that's what I meant. > > Also, WDYT of making 'cross-clang' a memoising procedure, such > that there's only one package object for a cross-clang of a fixed > target system (and version)? I don't know how to do that. Are there some examples around? > > > (native-inputs > > - (list clang llvm)) > > + (list (if (%current-target-system) > > + (cross-clang (%current-target-system) #:clang > > clang-9) > > + clang-9))) > > Probably a few other packages built with clang need such a thing as > well. How about making doing the right thing a bit easier? > Suggestion: introduce a 'clang-for-target' procedure, automatically > returning the right clang: > > (define (clang-for-target #:optional (clang clang)) > (if (%current-target-system) > (cross-clang [...]) > clang)) ; not cross-compiling > > then packages just need to do > > (native-inputs (list (clang-for-target) libfoo libbar ...)) Great idea, I implemented that procedure. > > The rest of the series ensures that libcxx and libcxxabi can be > cross-compiled with it. > > Customarily, cross-compilers are named $TARGET-foo. WDYT of > renaming the clang binary to '$TARGET-clang', such that a package > can have both a native clang and a cross-clang in native-inputs if > desired? Also, Autoconf looks for $TARGET-compiler, where compiler is > at least gcc, but possibly also clang > > And perhaps the package name can be changed '$TARGET-clang' like done > for gcc? I can do that, but I don't think it'll be recognized by cmake. It's building right now, and I'll have a try. > > + ;; Support the same variables as clang, even in cross-compilation > > + ;; context. > > + ;; Clang does not make a difference between native and > > + ;; cross-compilation. > > Upstream clang doesn't, but this is in a 'cross-clang' procedure, > so I think it would make sense for Guix' cross-clang to ignore > LIBRARY_PATH and only use CROSS_LIBRARY_PATH. Mixing up > C_INCLUDE_PATH and CROSS_C_INCLUDE_PATH (& friends) is unlikely > to lead anything good, e.g. include/bits/setjmp.h is > architecture-dependent. > OK, fixed. > > + (files '("lib" "lib64")))) > > I don't think Guix does a "lib" / "lib64" split, "lib" might > be sufficient. At least, there are a few comments like > > ;; Force powerpc libdir to be /lib and not /lib64 > > in Guix (though the gcc packages still includes "lib64" but > maybe that's only due to historical reasons). I saw that in GCC, so I just used the same specification, but just '("lib") is fine with me. Fixed. > How does this patch series interact with 'with-c-toolchain'? > Would "guix build hello --target=aarch64-linux-gnu > --with-c-toolchain=..." succesfully compile 'hello' with clang? It won't work, just like it doesn't work for gcc-toolchain. When you do (without my patches): guix build hello --with-c-toolchain=hello=clang-toolchain --target=i686-unknown-linux-gnu it builds, but that's because --with-c-toolchain replaces "gcc" (and friends), but the cross package uses "cross-gcc". guix build hello --with-c-toolchain=hello=gcc-toolchain <at> 7 --target=i686-unknown-linux-gnu also builds, but uses the latest gcc instead of gcc-toolchain <at> 7. Will send v2 shortly, after I've tested the rename works. > Greetings, > Maxime.
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 19:00:02 GMT) Full text and rfc822 format available.Message #29 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Thu, 03 Mar 2022 19:59:17 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op do 03-03-2022 om 19:35 [+0100]: > > > > Also, WDYT of making 'cross-clang' a memoising procedure, such > > that there's only one package object for a cross-clang of a fixed > > target system (and version)? > > I don't know how to do that. Are there some examples around? Search for 'cross-pkg-config' and 'standard-cross-packages'. Greetings, Maxime.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 21:11:02 GMT) Full text and rfc822 format available.Message #32 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Pierre Langlois <pierre.langlois <at> gmx.com> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org, guix-patches <at> gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Thu, 03 Mar 2022 20:51:01 +0000
[Message part 1 (text/plain, inline)]
Hi Julien, Julien Lepiller <julien <at> lepiller.eu> writes: > Hi Guix! > > This small patch series adds cross-clang, a cross-compiler version of > clang. Clang doesn't really make a distinction between a native and a > cross-build, it is already a cross-compiler, but this ensures that: > > 1. it actually works > 2. it targets (%current-target-architecture) by default > > The rest of the series ensures that libcxx and libcxxabi can be > cross-compiled with it. That's really cool! Out of curiosity, what target are you interested in that clang supports and GCC doesn't? For instance I'm interested in WebAssembly, and I've actually been contemplating how we could improve support for cross-compilers based on Clang in Guix, to be able to provide a working WebAssembly toolchain. For context, such a toolchain will be needed to enable potential use of WebAssembly in IceCat, for security purposes, see https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/ I actually have a toolchain that works already, which targets the wasm32-wasi-unknown triplet, but I wasn't convinced the way I did it was the right way to go long term, so it needs more work. I'm attaching the patch in case there's anything useful to you in there already! The approach I took was to create wrappers around clang/clang++ in order to set the correct include paths, and then provide an isolated sysroot for wasm32-wasi using union-build. This will work for IceCat, where their should be a flag to pass a sysroot path, but we should be able to do better in Guix. I though I'd share in case that's helpful! I'll take a look at your patches to see if I can build on top of them for a future WebAssembly toolchain in Guix. Thanks, Pierre
[signature.asc (application/pgp-signature, inline)]
[0001-gnu-Add-wasm32-wasi-clang-toolchain.patch (text/x-patch, inline)]
From 7d3c2a54ad66d5c4b2aa96eb946537fac1a5ae75 Mon Sep 17 00:00:00 2001 From: Pierre Langlois <pierre.langlois <at> gmx.com> Date: Sun, 16 Jan 2022 16:55:59 +0000 Subject: [PATCH] gnu: Add wasm32-wasi-clang-toolchain. WIP --- gnu/local.mk | 1 + gnu/packages/llvm.scm | 1 + gnu/packages/wasm.scm | 273 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+) create mode 100644 gnu/packages/wasm.scm diff --git a/gnu/local.mk b/gnu/local.mk index b7339ff472..952786827f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -603,6 +603,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/vpn.scm \ %D%/packages/vulkan.scm \ %D%/packages/w3m.scm \ + %D%/packages/wasm.scm \ %D%/packages/wdiff.scm \ %D%/packages/web.scm \ %D%/packages/web-browsers.scm \ diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index eb949bed1b..8821b2b6a7 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -74,6 +74,7 @@ (define-module (gnu packages llvm) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (make-lld-wrapper + clang-from-llvm system->llvm-target)) (define* (system->llvm-target #:optional diff --git a/gnu/packages/wasm.scm b/gnu/packages/wasm.scm new file mode 100644 index 0000000000..f9f73505ef --- /dev/null +++ b/gnu/packages/wasm.scm @@ -0,0 +1,273 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Pierre Langlois <pierre.langlois <at> gmx.com> +;;; +;;; This file is 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 (gnu packages wasm) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix utils) + #:use-module (guix build-system cmake) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module (gnu packages base) + #:use-module (gnu packages bash) + #:use-module (gnu packages compression) + #:use-module (gnu packages llvm) + #:use-module (gnu packages python)) + +(define-public wasi-libc + (let ((commit "ad5133410f66b93a2381db5b542aad5e0964db96") + (revision "1")) + (package + (name "wasi-libc") + (version (git-version "0.1-alpha" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/WebAssembly/wasi-libc") + (commit commit) + (recursive? #t))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "146jamq2q24vxjfpcwlqj84wzc80cbpbg0ns2wimyvzbanah48j6")))) + (build-system gnu-build-system) + (native-inputs (list clang-13)) + (arguments + (list #:tests? #f ;No test suite + #:phases + #~(modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'set-sysroot-include + (lambda _ + (setenv "C_INCLUDE_PATH" + (string-append (getcwd) "/sysroot/include")))) + (add-before 'install 'set-install-dir + (lambda _ + (setenv "INSTALL_DIR" + (string-append #$output "/wasm32-wasi"))))))) + (home-page "https://wasi.dev") + (synopsis "WASI libc implementation for WebAssembly") + (description + "WASI Libc is a libc for WebAssembly programs built on top of WASI +system calls. It provides a wide array of POSIX-compatible C APIs, including +support for standard I/O, file I/O, filesystem manipulation, memory +management, time, string, environment variables, program startup, and many +other APIs.") + (license (list + ;; For wasi-libc, with LLVM exceptions + license:asl2.0 + ;; For malloc.c. + license:cc0 + ;; For cloudlibc. + license:bsd-2 + ;; For wasi-libc and musl-libc. + license:expat))))) + +(define-public wasm32-wasi-clang-runtime + (package (inherit clang-runtime-13) + (native-inputs + (list clang-13 wasi-libc)) + (inputs (list llvm-13)) + (arguments + (list + #:build-type "Release" + #:tests? #f + ;; Stripping binaries breaks wasm linking, resulting in the following + ;; error: "archive has no index; run ranlib to add one". + #:strip-binaries? #f + #:configure-flags + #~(list "-DCMAKE_C_COMPILER=clang" + "-DCMAKE_C_COMPILER_TARGET=wasm32-wasi" + (string-append + "-DCMAKE_SYSROOT=" #$wasi-libc "/wasm32-wasi") + (string-append + "-DCMAKE_C_FLAGS=-I " #$wasi-libc "/wasm32-wasi/include") + + "-DCOMPILER_RT_OS_DIR=wasi" + + "-DCOMPILER_RT_BAREMETAL_BUILD=On" + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=On" + + ;; WASM only needs libclang_rt.builtins-wasm32.a from + ;; compiler-rt. + (string-append "../compiler-rt-" + #$(package-version clang-runtime-13) + ".src/lib/builtins")))))) + +;; FIXME: Ideally we wouldn't need to build a separate compiler because clang +;; can support multiple targets at runtime. However Guix patches the default +;; clang with a specific clang-runtime package. It would be good to improve +;; upstream Guix's support for cross-compiling with clang. + +(define clang-from-llvm (@@ (gnu packages llvm) clang-from-llvm)) + +(define-public wasm32-wasi-clang + (let ((base (clang-from-llvm llvm-13 wasm32-wasi-clang-runtime + "1j8pr5kk8iqyb4jds3yl7c6x672617h4ngkpl4575j7mk4nrwykq"))) + (package (inherit base) + (name "wasm32-wasi-clang") + (inputs + (modify-inputs (package-inputs base) + (prepend wasi-libc))) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:configure-flags flags) + #~(list "-DCLANG_INCLUDE_TESTS=True" + ;; Use a sane default include directory. + (string-append "-DC_INCLUDE_DIRS=" + #$wasi-libc + "/wasm32-wasi/include"))) + ((#:phases phases) + `(modify-phases ,phases + (delete 'symlink-cfi_ignorelist)))))))) + +(define-public wasm32-wasi-libcxx + (package + (name "wasm32-wasi-libcxx") + (version "13.0.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/llvm/llvm-project") + (commit (string-append "llvmorg-" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0cjl0vssi4y2g4nfr710fb6cdhxmn5r0vis15sf088zsc5zydfhw")))) + (build-system cmake-build-system) + (arguments + (list + #:configure-flags + #~(list (string-append "-S ../source/runtimes") + + "-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi" + + (string-append + "-DCMAKE_SYSROOT=" #$wasi-libc "/wasm32-wasi") + + (string-append + "-DCMAKE_INCLUDE_PATH=" #$wasi-libc "/wasm32-wasi/include") + + (string-append + "-DCMAKE_STAGING_PREFIX=" #$output "/wasm32-wasi") + + "-DCMAKE_C_COMPILER=clang" + "-DCMAKE_C_COMPILER_WORKS=ON" + "-DCMAKE_CXX_COMPILER=clang++" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + "-DCMAKE_C_COMPILER_TARGET=wasm32-wasi" + "-DCMAKE_CXX_COMPILER_TARGET=wasm32-wasi" + + "-DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasi" + + "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" + "-DLIBCXX_ENABLE_SHARED=OFF" + "-DLIBCXX_ENABLE_THREADS=OFF" + "-DLIBCXX_ENABLE_FILESYSTEM=OFF" + + "-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi" + + "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" + "-DLIBCXXABI_ENABLE_SHARED=OFF" + "-DLIBCXXABI_ENABLE_THREADS=OFF" + "-DLIBCXXABI_ENABLE_FILESYSTEM=OFF") + #:tests? #f + #:phases + #~(modify-phases %standard-phases + (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH + (lambda _ + (setenv "CPLUS_INCLUDE_PATH" + (string-append #$wasi-libc "/wasm32-wasi/include:" + (getenv "CPLUS_INCLUDE_PATH")))))))) + (native-inputs + (list wasm32-wasi-clang lld python)) + (inputs + (list wasi-libc)) + (home-page "https://libcxx.llvm.org") + (synopsis "C++ standard library, for WebAssembly") + (description + "This package provides an implementation of the C++ standard library for +use with Clang, targeting C++11, C++14 and above. This package targets +WebAssembly with WASI.") + (license license:expat))) + +(define-public wasm32-wasi-clang-toolchain + (package + (name "wasm32-wasi-clang-toolchain") + (version (package-version wasm32-wasi-clang)) + (source #f) + (build-system trivial-build-system) + (arguments + (list + #:builder + (with-imported-modules '((guix build union) + (guix build utils)) + #~(begin + (use-modules (guix build union) + (guix build utils)) + (union-build #$output + (list #$wasm32-wasi-clang-runtime + #$wasi-libc + #$wasm32-wasi-libcxx)) + (mkdir-p (string-append #$output "/bin")) + + ;; We provide clang and clang++ via a wrapped program that sets + ;; include paths correctly so that it does not include paths from + ;; the host. + + ;; FIXME: Review how we can provide better support for + ;; cross-compiling with clang in Guix, maybe adding support for + ;; the CROSS_C_INCLUDE_PATH and CROSS_CPLUS_INCLUDE_PATH + ;; environment variables like GCC. + + (for-each + (lambda (bin) + (symlink (string-append #$wasm32-wasi-clang bin) + (string-append #$output bin)) + (wrap-program (string-append #$output bin) + #:sh (string-append #$bash-minimal "/bin/bash") + `("C_INCLUDE_PATH" ":" = + (,(string-append #$output "/wasm32-wasi/include"))) + `("CPLUS_INCLUDE_PATH" ":" = + ;; Make sure inclure/c++/v1 comes first for #include_next + ;; to work. + (,(string-append #$output "/wasm32-wasi/include/c++/v1") + ,(string-append #$output "/wasm32-wasi/include"))))) + '("/bin/clang" "/bin/clang++")) + + (symlink (string-append #$lld "/bin/wasm-ld") + (string-append #$output "/bin/wasm-ld")))))) + (inputs + (list bash-minimal + lld + wasm32-wasi-clang + wasm32-wasi-clang-runtime + wasi-libc + wasm32-wasi-libcxx)) + (license (cons + (package-license wasm32-wasi-clang) + (package-license wasi-libc))) + (home-page "https://clang.llvm.org") + (synopsis "Complete Clang toolchain for C/C++ development, for WebAssembly.") + (description "This package provides a complete Clang toolchain for C/C++ +development targeting WebAssembly with WASI. This includes Clang, as well as +libc, libc++ and wasm-ld."))) -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 21:11:02 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 21:12:02 GMT) Full text and rfc822 format available.Message #38 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Maxime Devos <maximedevos <at> telenet.be> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Thu, 3 Mar 2022 22:11:36 +0100
Le Thu, 03 Mar 2022 19:59:17 +0100, Maxime Devos <maximedevos <at> telenet.be> a écrit : > Julien Lepiller schreef op do 03-03-2022 om 19:35 [+0100]: > > > > > > Also, WDYT of making 'cross-clang' a memoising procedure, such > > > that there's only one package object for a cross-clang of a fixed > > > target system (and version)? > > > > I don't know how to do that. Are there some examples around? > > Search for 'cross-pkg-config' and 'standard-cross-packages'. > > Greetings, > Maxime. Thanks! I used mlambda, I think it should work :) So I tried renaming clang to <target>-clang, but then I noticed the build of libcxxabi fails: -- The CXX compiler identification is unknown -- The C compiler identification is unknown CMake Error at CMakeLists.txt:21 (project): The CMAKE_CXX_COMPILER: clang++ is not a full path and was not found in the PATH. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. This is because it really expects clang, not <target>-clang. The autotools might be smarter (haven't tested), but they're the only one. I don't want to substitute* every CMakeList.txt to make sure they understand what we're the only ones to do. Furthermore, clang is already a cross-compiler, and cross-clang only makes it work in the context of guix packaging and changes the default target for convenience. Outside of a guix package, although not very convenient, our clang package already works like everyone else's I think. I don't think it makes sense to have clang AND i586-gnu-clang in your profile. Also, cross-clang just like cross-gcc is not accessible from the CLI. WDYT?
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Thu, 03 Mar 2022 21:21:02 GMT) Full text and rfc822 format available.Message #41 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Pierre Langlois <pierre.langlois <at> gmx.com> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Thu, 03 Mar 2022 22:20:45 +0100
[Message part 1 (text/plain, inline)]
Oh wow! I need clang for Android: it's only tested and built with clang, and some of the packages don't build with gcc. I don't really need any fancy target, but one of the goals I had was to be able to cross-build my android packages, hence this cross-compiler. A wasm cross-compiler would be awesome! On March 3, 2022 9:51:01 PM GMT+01:00, Pierre Langlois <pierre.langlois <at> gmx.com> wrote: >Hi Julien, > >Julien Lepiller <julien <at> lepiller.eu> writes: > >> Hi Guix! >> >> This small patch series adds cross-clang, a cross-compiler version of >> clang. Clang doesn't really make a distinction between a native and a >> cross-build, it is already a cross-compiler, but this ensures that: >> >> 1. it actually works >> 2. it targets (%current-target-architecture) by default >> >> The rest of the series ensures that libcxx and libcxxabi can be >> cross-compiled with it. > >That's really cool! Out of curiosity, what target are you interested in >that clang supports and GCC doesn't? For instance I'm interested in >WebAssembly, and I've actually been contemplating how we could improve >support for cross-compilers based on Clang in Guix, to be able to >provide a working WebAssembly toolchain. > >For context, such a toolchain will be needed to enable potential use of >WebAssembly in IceCat, for security purposes, see >https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/ > >I actually have a toolchain that works already, which targets the >wasm32-wasi-unknown triplet, but I wasn't convinced the way I did it was >the right way to go long term, so it needs more work. I'm attaching the >patch in case there's anything useful to you in there already! > >The approach I took was to create wrappers around clang/clang++ in order >to set the correct include paths, and then provide an isolated sysroot >for wasm32-wasi using union-build. This will work for IceCat, where >their should be a flag to pass a sysroot path, but we should be able to >do better in Guix. > >I though I'd share in case that's helpful! I'll take a look at your >patches to see if I can build on top of them for a future WebAssembly >toolchain in Guix. > >Thanks, >Pierre >
[Message part 2 (text/html, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 10:01:02 GMT) Full text and rfc822 format available.Message #44 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v2 1/5] gnu: Add cross-llvm. Date: Fri, 4 Mar 2022 10:59:49 +0100
* gnu/packages/llvm.scm (cross-llvm): New variable. --- gnu/packages/llvm.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index eb949bed1b..d6e9846699 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -18,7 +18,7 @@ ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2021 Maxime Devos <maximedevos <at> telenet.be> ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> -;;; Copyright © 2021 Julien Lepiller <julien <at> lepiller.eu> +;;; Copyright © 2021, 2022 Julien Lepiller <julien <at> lepiller.eu> ;;; Copyright © 2021 Lars-Dominik Braun <lars <at> 6xq.net> ;;; Copyright © 2021 Guillaume Le Vaillant <glv <at> posteo.net> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> @@ -74,7 +74,8 @@ (define-module (gnu packages llvm) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (make-lld-wrapper - system->llvm-target)) + system->llvm-target + cross-llvm)) (define* (system->llvm-target #:optional (system (or (and=> (%current-target-system) @@ -99,6 +100,22 @@ (define* (system->llvm-target #:optional ("i686" => "X86") ("i586" => "X86")))) +(define (cross-llvm llvm target) + "Return a native LLVM package that targets a different system. The resulting +libraries are running on the host but target a different system by default. +This packge can be used to control clang's default target." + (package + (inherit llvm) + (arguments + (substitute-keyword-arguments (package-arguments llvm) + ((#:configure-flags flags) + #~(append + (list + (string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" #$target) + (string-append "-DLLVM_TARGET_ARCH=" + #$(system->llvm-target (gnu-triplet->nix-system target)))) + #$flags)))))) + (define (llvm-uri component version) ;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz' ;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name. -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 10:01:02 GMT) Full text and rfc822 format available.Message #47 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v2 2/5] gnu: Add cross-clang. Date: Fri, 4 Mar 2022 10:59:50 +0100
* gnu/packages/llvm.scm (cross-clang): New variable. --- gnu/packages/llvm.scm | 144 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 1 deletion(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index d6e9846699..c277e2ac35 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -54,6 +54,7 @@ (define-module (gnu packages llvm) #:use-module (guix build-system trivial) #:use-module (gnu packages) #:use-module (gnu packages base) + #:use-module (gnu packages cross-base) #:use-module (gnu packages gcc) #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker #:use-module (gnu packages check) ;python-lit @@ -75,7 +76,9 @@ (define-module (gnu packages llvm) #:use-module (ice-9 match) #:export (make-lld-wrapper system->llvm-target - cross-llvm)) + cross-llvm + cross-clang + clang-for-target)) (define* (system->llvm-target #:optional (system (or (and=> (%current-target-system) @@ -1023,6 +1026,145 @@ (define-public clang-runtime clang-runtime-13) (define-public clang clang-13) (define-public clang-toolchain clang-toolchain-13) +(define* (cross-clang target + #:key + (libc (cross-libc target)) + (xgcc (cross-gcc target + #:xbinutils (cross-binutils target) + #:libc (cross-libc target))) + (clang clang)) + "Return a cross-clang compiler for target." + (define cross-clang-aux + (mlambda (target libc xgcc clang) + (package + (inherit clang) + (name (string-append "clang-cross-" target)) + (version (package-version clang)) + ;; Support the same variables as clang, even in cross-compilation context. + ;; Clang does not make a difference between native and cross-compilation. + (search-paths + (list + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files '("lib"))) + (search-path-specification + (variable "CROSS_C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_CPLUS_INCLUDE_PATH") + (files '("include/c++" "include"))))) + (native-search-paths '()) + (arguments + (substitute-keyword-arguments (package-arguments clang) + ((#:configure-flags _) + `(list "-DCLANG_INCLUDE_TESTS=True" + (string-append "-DGCC_INSTALL_PREFIX=" + (assoc-ref %build-inputs "cross-gcc-lib")) + (string-append "-DC_INCLUDE_DIRS=" + (assoc-ref %build-inputs "target-libc") + "/include"))) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'add-missing-libdir + (lambda _ + ;; cross-gcc installs its libraries in <target>/lib instead of + ;; lib. + (substitute* "lib/Driver/ToolChain.cpp" + (("\"-L\"\\) \\+ LibPath\\)\\);") + ,(string-append "\"-L\") + LibPath)); + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-L\") + " + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" + target "/lib\"))); + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-rpath=\") + " + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" + target "/lib\")));"))))) + (add-after 'unpack 'support-cross-include-path + (lambda _ + (substitute* "lib/Driver/ToolChains/Clang.cpp" + (("C_INCLUDE_PATH") "CROSS_C_INCLUDE_PATH") + (("CPLUS_INCLUDE_PATH") "CROSS_CPLUS_INCLUDE_PATH")))) + (add-after 'unpack 'support-cross-library-path + (lambda _ + ;; LIBRARY_PATH is only supported for native builds, but we still + ;; need it (or CROSS_LIBRARY_PATH to be precise) when + ;; cross-compiling + (substitute* "lib/Driver/ToolChains/CommonArgs.cpp" + (("LIBRARY_PATH\"") + "LIBRARY_PATH\"); + } else { + addDirectoryList(Args, CmdArgs, \"-L\", \"CROSS_LIBRARY_PATH\"")))) + (replace 'set-glibc-file-names + (lambda* (#:key inputs #:allow-other-keys) + (let ((libc (assoc-ref inputs "target-libc")) + (compiler-rt (assoc-ref inputs "clang-runtime")) + (gcc (assoc-ref inputs "cross-gcc"))) + (setenv "LIBRARY_PATH" + (string-append + (assoc-ref inputs "libc") "/lib:" (getenv "LIBRARY_PATH"))) + ,@(cond + ((version>=? version "6.0") + `(;; Link to libclang_rt files from clang-runtime. + (substitute* "lib/Driver/ToolChain.cpp" + (("getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\""))) + + ;; Make "LibDir" refer to <glibc>/lib so that it + ;; uses the right dynamic linker file name. + (substitute* "lib/Driver/ToolChains/Linux.cpp" + (("(^[[:blank:]]+LibDir = ).*" _ declaration) + (string-append declaration "\"" libc "/lib\";\n")) + + ;; Make clang look for libstdc++ in the right + ;; location. + (("LibStdCXXIncludePathCandidates\\[\\] = \\{") + (string-append + "LibStdCXXIncludePathCandidates[] = { \"" gcc + "/include/c++\",")) + + ;; Make sure libc's libdir is on the search path, to + ;; allow crt1.o & co. to be found. + (("@GLIBC_LIBDIR@") + (string-append libc "/lib"))))) + (else + `((substitute* "lib/Driver/Tools.cpp" + ;; Patch the 'getLinuxDynamicLinker' function so that + ;; it uses the right dynamic linker file name. + (("/lib64/ld-linux-x86-64.so.2") + (string-append libc ,(glibc-dynamic-linker)))) + + ;; Link to libclang_rt files from clang-runtime. + ;; This substitution needed slight adjustment in 3.8. + ,@(if (version>=? version "3.8") + '((substitute* "lib/Driver/Tools.cpp" + (("TC\\.getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\"")))) + '((substitute* "lib/Driver/ToolChain.cpp" + (("getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\""))))) + + ;; Make sure libc's libdir is on the search path, to + ;; allow crt1.o & co. to be found. + (substitute* "lib/Driver/ToolChains.cpp" + (("@GLIBC_LIBDIR@") + (string-append libc "/lib"))))))))))))) + (inputs + `(("target-libc" ,libc) + ("cross-gcc-lib" ,xgcc "lib") + ("cross-gcc" ,xgcc) + ,@(package-inputs clang))) + (propagated-inputs + (modify-inputs (package-propagated-inputs clang) + (replace "llvm" + (cross-llvm + (car (assoc-ref (package-propagated-inputs clang) "llvm")) + target))))))) + (cross-clang-aux target libc xgcc clang)) + +(define* (clang-for-target #:optional (clang clang)) + (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang) + clang)) + (define-public llvm-for-rocm (package ;; Actually based on LLVM 13 as of v4.3, but llvm-12 works just fine. -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 10:01:02 GMT) Full text and rfc822 format available.Message #50 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v2 3/5] gnu: libcxx: Allow cross-compilation. Date: Fri, 4 Mar 2022 10:59:51 +0100
* gnu/packages/llvm.scm (libcxx)[native-inputs]: Move llvm to... [inputs]: ...here. [arguments]: adjust CROSS_INCLUDE_PATH when cross-compiling. (libcxx-6)[native-inputs]: Move llvm to... [inputs]: ...here. --- gnu/packages/llvm.scm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index c277e2ac35..137bc99f35 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1362,8 +1362,9 @@ (define-public libcxx `(#:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH - (lambda* (#:key inputs #:allow-other-keys) - (let ((gcc (assoc-ref inputs "gcc"))) + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (let ((gcc (or (assoc-ref (or native-inputs inputs) "gcc"))) + (cross-gcc (assoc-ref native-inputs "cross-gcc"))) ;; Hide GCC's C++ headers so that they do not interfere with ;; the ones we are attempting to build. (setenv "CPLUS_INCLUDE_PATH" @@ -1371,12 +1372,19 @@ (define-public libcxx (string-split (getenv "CPLUS_INCLUDE_PATH") #\:)) ":")) + (when cross-gcc + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join (delete (string-append cross-gcc "/include/c++") + (string-split (getenv "CPLUS_INCLUDE_PATH") + #\:)) + ":")) + (format #t + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH"))) (format #t "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" - (getenv "CPLUS_INCLUDE_PATH")) - #t)))))) - (native-inputs - (list clang llvm)) + (getenv "CPLUS_INCLUDE_PATH")))))))) + (inputs (list llvm-9)) (home-page "https://libcxx.llvm.org") (synopsis "C++ standard library") (description @@ -1397,8 +1405,7 @@ (define-public libcxx-6 (sha256 (base32 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) - (native-inputs - (list clang-6 llvm-6)))) + (inputs (list llvm-6)))) (define-public libcxxabi-6 (package -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 10:01:03 GMT) Full text and rfc822 format available.Message #53 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v2 4/5] gnu: libcxxabi-6: Allow cross-compilation. Date: Fri, 4 Mar 2022 10:59:52 +0100
* gnu/packages/llvm.scm (libcxxabi-6)[native-inputs]: Use clang-for-target for cross-compilation. Move llvm and libcxx to... [inputs]: ...here. [arguments]<adjust-CPLUS_INCLUDE_PATH>: Also adjust CROSS_CPLUS_INCLUDE_PATH when necessary. --- gnu/packages/llvm.scm | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 137bc99f35..e00e92aa8c 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1433,19 +1433,43 @@ (define-public libcxxabi-6 (modify-phases (@ (guix build cmake-build-system) %standard-phases) (add-after 'unpack 'chdir (lambda _ (chdir "libcxxabi"))) - (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH - (lambda* (#:key inputs #:allow-other-keys) - (let ((gcc (assoc-ref inputs "gcc"))) + (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (define (delete* what lst) + (if (null? what) + lst + (delete* (cdr what) (delete (car what) lst)))) + + (let ((gcc (or (assoc-ref inputs "gcc") (assoc-ref native-inputs "gcc"))) + (cross-gcc (assoc-ref native-inputs "cross-gcc"))) ;; Hide GCC's C++ headers so that they do not interfere with ;; the ones we are attempting to build. (setenv "CPLUS_INCLUDE_PATH" (string-join (cons (string-append (assoc-ref inputs "libcxx") "/include/c++/v1") - (delete (string-append gcc "/include/c++") - (string-split (getenv "CPLUS_INCLUDE_PATH") - #\:))) + (delete* + `(,(string-append gcc "/include/c++") + ,@(if cross-gcc + `(,(string-append cross-gcc "/include/c++")) + '())) + (string-split (getenv "CPLUS_INCLUDE_PATH") + #\:))) ":")) + (when cross-gcc + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join + (cons (string-append + (assoc-ref inputs "libcxx") "/include/c++/v1") + (delete* + (list (string-append cross-gcc "/include/c++") + (string-append gcc "/include/c++")) + (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") + #\:))) + ":")) + (format #true + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH"))) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH"))))) @@ -1455,8 +1479,8 @@ (define-public libcxxabi-6 (assoc-ref outputs "out") "/include"))) (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) - (native-inputs - (list clang-6 llvm-6 libcxx-6)) + (inputs (list llvm-6 libcxx-6)) + (native-inputs (list (clang-for-target clang-6))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 10:01:03 GMT) Full text and rfc822 format available.Message #56 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v2 5/5] gnu: Add libcxxabi-9. Date: Fri, 4 Mar 2022 10:59:53 +0100
* gnu/packages/llvm.scm (libcxxabi-9): New variable. (libcxxabi-6): Inherit from it. --- gnu/packages/llvm.scm | 69 ++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index e00e92aa8c..47fd8e2442 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1407,20 +1407,17 @@ (define-public libcxx-6 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) (inputs (list llvm-6)))) -(define-public libcxxabi-6 +(define-public libcxxabi-9 (package (name "libcxxabi") - (version "6.0.1") + (version (package-version clang-9)) (source (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/llvm/llvm-project") - (commit (string-append "llvmorg-" version)))) - (file-name (git-file-name name version)) + (method url-fetch) + (uri (llvm-uri "libcxxabi" version)) (sha256 (base32 - "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g")))) + "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8")))) (build-system cmake-build-system) (arguments `(#:configure-flags @@ -1431,8 +1428,6 @@ (define-public libcxxabi-6 "-DCMAKE_CXX_COMPILER=clang++") #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) - (add-after 'unpack 'chdir - (lambda _ (chdir "libcxxabi"))) (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs native-inputs #:allow-other-keys) (define (delete* what lst) @@ -1466,10 +1461,10 @@ (define-public libcxxabi-6 (string-append gcc "/include/c++")) (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") #\:))) - ":")) - (format #true - "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" - (getenv "CROSS_CPLUS_INCLUDE_PATH"))) + ":"))) + (format #true + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH")) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH"))))) @@ -1477,10 +1472,15 @@ (define-public libcxxabi-6 (lambda* (#:key outputs #:allow-other-keys) (let ((include-dir (string-append (assoc-ref outputs "out") "/include"))) - (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) - (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) - (inputs (list llvm-6 libcxx-6)) - (native-inputs (list (clang-for-target clang-6))) + (mkdir-p include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/__cxxabi_config.h") + include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/cxxabi.h") + include-dir))))))) + (inputs (list llvm-9 libcxx)) + (native-inputs (list (clang-for-target clang-9))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description @@ -1488,6 +1488,39 @@ (define-public libcxxabi-6 standard C++ library.") (license license:expat))) +(define-public libcxxabi-6 + (package + (inherit libcxxabi-9) + (name "libcxxabi") + (version "6.0.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/llvm/llvm-project") + (commit (string-append "llvmorg-" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g")))) + (arguments + (substitute-keyword-arguments (package-arguments libcxxabi-9) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'chdir + (lambda _ (chdir "libcxxabi"))) + (replace 'install-headers + (lambda* (#:key outputs #:allow-other-keys) + (let ((include-dir (string-append + (assoc-ref outputs "out") "/include"))) + (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) + (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))) + (inputs (list llvm-6 libcxx-6)) + (native-inputs + (list (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang-6) + clang-6))))) + (define-public libcxx+libcxxabi-6 (package (inherit libcxx-6) -- 2.34.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 19:41:01 GMT) Full text and rfc822 format available.Message #59 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Pierre Langlois <pierre.langlois <at> gmx.com> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org, guix-patches <at> gnu.org Subject: Re: [bug#54239] [PATCH v2 1/5] gnu: Add cross-llvm. Date: Fri, 04 Mar 2022 19:34:07 +0000
[Message part 1 (text/plain, inline)]
Hi Julien, Julien Lepiller <julien <at> lepiller.eu> writes: > * gnu/packages/llvm.scm (cross-llvm): New variable. Do you really need to define a cross package for LLVM? In my experience it was possible to use the same llvm libraries for native and cross compilation. By default LLVM builds support for all supported targets (provided they are not "experimental" IIRC). Whereas for the clang package, at the moment it does have to be built for a specific target IIUC. I hope that one day we could have the same clang for native and cross compilation in Guix, but I don't think it can work without some serious re-design of how cross-compilation works. I've been trying to think about it but I don't yet have a good understanding of it. Thanks, Pierre
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 19:41:02 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 19:51:01 GMT) Full text and rfc822 format available.Message #65 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 5/5] gnu: Add libcxxabi-9. Date: Fri, 04 Mar 2022 20:50:43 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op vr 04-03-2022 om 10:59 [+0100]: > + (list (if (%current-target-system) > + (cross-clang (%current-target-system) #:clang clang-6) > + clang-6))))) Could the new procedure could 'clang-for-target' be used here? Likewise for a few other packages (e.g. hedgewards), but those could be left for future patches. Greetings, Maxime
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 19:54:02 GMT) Full text and rfc822 format available.Message #68 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 2/5] gnu: Add cross-clang. Date: Fri, 04 Mar 2022 20:53:10 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op vr 04-03-2022 om 10:59 [+0100]: > + ((#:configure-flags _) > + `(list "-DCLANG_INCLUDE_TESTS=True" This is a bit fragile. If the definition of the 'clang' package mad the #:configure-flags a gexp, then this would fail because of the 'sexp->gexp' optimisation in 'cmake-build-system'. As such, I recommend #~(list "-DCLANG_INCLUDE_TESTS=True" ...) here instead of sexp quasiquoting. Greetings, Maxime.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 19:55:02 GMT) Full text and rfc822 format available.Message #71 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 2/5] gnu: Add cross-clang. Date: Fri, 04 Mar 2022 20:54:22 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op vr 04-03-2022 om 10:59 [+0100]: > + `((substitute* "lib/Driver/Tools.cpp" > + ;; Patch the 'getLinuxDynamicLinker' function so that > + ;; it uses the right dynamic linker file name. > + (("/lib64/ld-linux-x86-64.so.2") > + (string-append libc ,(glibc-dynamic-linker)))) Do we need something similar for non-x86-64 architectures as well? Greetings, Maxime.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 19:57:02 GMT) Full text and rfc822 format available.Message #74 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 2/5] gnu: Add cross-clang. Date: Fri, 04 Mar 2022 20:56:11 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op vr 04-03-2022 om 10:59 [+0100]: > + (else > + `((substitute* "lib/Driver/Tools.cpp" > + ;; Patch the 'getLinuxDynamicLinker' function so that > + ;; it uses the right dynamic linker file name. > + (("/lib64/ld-linux-x86-64.so.2") > + (string-append libc ,(glibc-dynamic-linker)))) Shouldn't we use the architecture that the cross-clang is targetting be passed to 'glibc-dynamic-linker' instead of the architecture that the cross-clang will run on? Greetings, Maxime.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 20:01:02 GMT) Full text and rfc822 format available.Message #77 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 2/5] gnu: Add cross-clang. Date: Fri, 04 Mar 2022 21:00:54 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op vr 04-03-2022 om 10:59 [+0100]: > + #:use-module (gnu packages cross-base) Most of the time, we aren't cross-compiling. So WDYT of autoloading this module? It's rather unusual to do this in (gnu packages ...), but there does not appear to be any reason for this to be impossible to do. Another option would be using 'module-ref' like (guix build-system ...) does. Greetings, Maxime.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Fri, 04 Mar 2022 20:06:02 GMT) Full text and rfc822 format available.Message #80 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH] gnu: Add cross-clang. Date: Fri, 04 Mar 2022 21:05:12 +0100
[Message part 1 (text/plain, inline)]
Julien Lepiller schreef op do 03-03-2022 om 19:35 [+0100]: > It won't work, just like it doesn't work for gcc-toolchain. When you do > (without my patches): > > guix build hello --with-c-toolchain=hello=clang-toolchain > --target=i686-unknown-linux-gnu > > it builds, but that's because --with-c-toolchain replaces "gcc" > (and friends), but the cross package uses "cross-gcc". > > guix build hello --with-c-toolchain=hello=gcc-toolchain <at> 7 > --target=i686-unknown-linux-gnu > > also builds, but uses the latest gcc instead of gcc-toolchain <at> 7. In that case, could this limitation be documented in @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain} in the manual? Modifying (guix transformations) to also replace the cross-toolchain would be even better. Greetings, Maxime
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 08:25:02 GMT) Full text and rfc822 format available.Message #83 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Pierre Langlois <pierre.langlois <at> gmx.com> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 1/5] gnu: Add cross-llvm. Date: Sat, 5 Mar 2022 09:24:45 +0100
Le Fri, 04 Mar 2022 19:34:07 +0000, Pierre Langlois <pierre.langlois <at> gmx.com> a écrit : > Hi Julien, > > Julien Lepiller <julien <at> lepiller.eu> writes: > > > * gnu/packages/llvm.scm (cross-llvm): New variable. > > Do you really need to define a cross package for LLVM? In my > experience it was possible to use the same llvm libraries for native > and cross compilation. By default LLVM builds support for all > supported targets (provided they are not "experimental" IIRC). No, I don't think it's required. I only need it so I can define a default target that's different from the host. > > Whereas for the clang package, at the moment it does have to be built > for a specific target IIUC. I hope that one day we could have the same > clang for native and cross compilation in Guix, but I don't think it > can work without some serious re-design of how cross-compilation > works. I've been trying to think about it but I don't yet have a good > understanding of it. You can use --target to control which target clang builds for (although I don't know if our clang package can work like that). I wanted to have a default target though, because passing --target all the time is cumbersome and we would have to adjust all recipes to pass the flag. With the default target set appropriately, (clang-for-target) will always produce binaries for the correct architecture, whether cross-compiling or not. > > Thanks, > Pierre >
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 08:31:02 GMT) Full text and rfc822 format available.Message #86 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Maxime Devos <maximedevos <at> telenet.be> Cc: 54239 <at> debbugs.gnu.org Subject: Re: [bug#54239] [PATCH v2 2/5] gnu: Add cross-clang. Date: Sat, 5 Mar 2022 09:30:10 +0100
Le Fri, 04 Mar 2022 20:54:22 +0100, Maxime Devos <maximedevos <at> telenet.be> a écrit : > Julien Lepiller schreef op vr 04-03-2022 om 10:59 [+0100]: > > + `((substitute* "lib/Driver/Tools.cpp" > > + ;; Patch the 'getLinuxDynamicLinker' > > function so that > > + ;; it uses the right dynamic linker > > file name. > > + (("/lib64/ld-linux-x86-64.so.2") > > + (string-append libc > > ,(glibc-dynamic-linker)))) > > Do we need something similar for non-x86-64 architectures as well? > > Greetings, > Maxime. I don't know about that. This phase is mostly copied from clang itself.
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 13:11:02 GMT) Full text and rfc822 format available.Message #89 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Pierre Langlois <pierre.langlois <at> gmx.com> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org, Pierre Langlois <pierre.langlois <at> gmx.com> Subject: Re: [bug#54239] [PATCH v2 1/5] gnu: Add cross-llvm. Date: Sat, 05 Mar 2022 13:02:48 +0000
[Message part 1 (text/plain, inline)]
Julien Lepiller <julien <at> lepiller.eu> writes: > Le Fri, 04 Mar 2022 19:34:07 +0000, > Pierre Langlois <pierre.langlois <at> gmx.com> a écrit : > >> Hi Julien, >> >> Julien Lepiller <julien <at> lepiller.eu> writes: >> >> > * gnu/packages/llvm.scm (cross-llvm): New variable. >> >> Do you really need to define a cross package for LLVM? In my >> experience it was possible to use the same llvm libraries for native >> and cross compilation. By default LLVM builds support for all >> supported targets (provided they are not "experimental" IIRC). > > No, I don't think it's required. I only need it so I can define a > default target that's different from the host. > >> >> Whereas for the clang package, at the moment it does have to be built >> for a specific target IIUC. I hope that one day we could have the same >> clang for native and cross compilation in Guix, but I don't think it >> can work without some serious re-design of how cross-compilation >> works. I've been trying to think about it but I don't yet have a good >> understanding of it. > > You can use --target to control which target clang builds for (although > I don't know if our clang package can work like that). I wanted to have > a default target though, because passing --target all the time is > cumbersome and we would have to adjust all recipes to pass the flag. > With the default target set appropriately, (clang-for-target) will > always produce binaries for the correct architecture, whether > cross-compiling or not. > Ah I see, that makes sense! I suppose a possible alternative could be to define a wrapper around clang to pass the `--target=<triplet>' option by default, but that might be a bit ugly (although we already have a ld-wrapper). Thanks, Pierre
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 14:41:02 GMT) Full text and rfc822 format available.Message #92 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Pierre Langlois <pierre.langlois <at> gmx.com> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org, guix-patches <at> gnu.org Subject: Re: [bug#54239] [PATCH v2 1/5] gnu: Add cross-llvm. Date: Sat, 05 Mar 2022 14:00:32 +0000
[Message part 1 (text/plain, inline)]
Julien Lepiller <julien <at> lepiller.eu> writes: > * gnu/packages/llvm.scm (cross-llvm): New variable. > --- > gnu/packages/llvm.scm | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm > index eb949bed1b..d6e9846699 100644 > --- a/gnu/packages/llvm.scm > +++ b/gnu/packages/llvm.scm > @@ -18,7 +18,7 @@ > ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> > ;;; Copyright © 2021 Maxime Devos <maximedevos <at> telenet.be> > ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> > -;;; Copyright © 2021 Julien Lepiller <julien <at> lepiller.eu> > +;;; Copyright © 2021, 2022 Julien Lepiller <julien <at> lepiller.eu> > ;;; Copyright © 2021 Lars-Dominik Braun <lars <at> 6xq.net> > ;;; Copyright © 2021 Guillaume Le Vaillant <glv <at> posteo.net> > ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> > @@ -74,7 +74,8 @@ (define-module (gnu packages llvm) > #:use-module (srfi srfi-1) > #:use-module (ice-9 match) > #:export (make-lld-wrapper > - system->llvm-target)) > + system->llvm-target > + cross-llvm)) > > (define* (system->llvm-target #:optional > (system (or (and=> (%current-target-system) > @@ -99,6 +100,22 @@ (define* (system->llvm-target #:optional > ("i686" => "X86") > ("i586" => "X86")))) > > +(define (cross-llvm llvm target) > + "Return a native LLVM package that targets a different system. The resulting > +libraries are running on the host but target a different system by default. > +This packge can be used to control clang's default target." > + (package > + (inherit llvm) > + (arguments > + (substitute-keyword-arguments (package-arguments llvm) > + ((#:configure-flags flags) > + #~(append > + (list > + (string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" #$target) > + (string-append "-DLLVM_TARGET_ARCH=" > + #$(system->llvm-target (gnu-triplet->nix-system target)))) While playing with trying to use this series to build a WebAssembly cross-compiler, I /think/ we have a bug here, and also in master, when it comes to setting LLVM_TARGET_ARCH. It's a bit confusing though, the documentation is as follows: --8<---------------cut here---------------start------------->8--- LLVM_TARGET_ARCH:STRING LLVM target to use for native code generation. This is required for JIT generation. It defaults to “host”, meaning that it shall pick the architecture of the machine where LLVM is being built. If you are cross-compiling, set it to the target architecture name. --8<---------------cut here---------------end--------------->8--- It's not clear what naming scheme the variable needs, is it the internal LLVM target name or the triplet? I think it's architecture part of the triplet...ish? But instead we pass it the internal target name. It still works at the moment because whenever LLVM_TARGET_ARCH is used, the cmake code looks quite permissive and tries to do the right thing by turning the string lowercase and matching common names (hence the "...ish" :-) ). https://github.com/llvm/llvm-project/blob/24f88f57de588817bd21e799e2ac1069c025674c/llvm/cmake/config-ix.cmake#L420 So if I try and add WebAssembly into the mix, the architecure name is wasm32, but the LLVM target is called WebAssembly, and the lowercase version of it doesn't work :-( | nix-system | LLVM target | LLVM target lowercase | Does it match? | |------------+-------------+-----------------------+----------------| | aarch64 | AArch64 | aarch64 | Y | | armhf | ARM | arm | Y | | mips64el | Mips | mips | Y | | powerpc | PowerPC | powerpc | Y | | riscv | RISCV | riscv | Y | | x86_64 | X86 | x86 | Y | | i686 | X86 | x86 | Y | | i586 | X86 | x86 | Y | |------------+-------------+-----------------------+----------------| | wasm32 | WebAssembly | webassembly | N :-( | I /think/ we might want to use the nix-system instead of the LLVM target for LLVM_TARGET_ARCH: --8<---------------cut here---------------start------------->8--- (string-append "-DLLVM_TARGET_ARCH=" #$(gnu-triplet->nix-system target))) --8<---------------cut here---------------end--------------->8--- But I'm not sure, it might not work for mips64el for example, so we could need yet-another-mapping. Given it works as it is today with the current set of supported targets, we don't necessarily need to fix it now. I'll be happy to take a look later when eventually adding support for the wasm32-wasi toolchain in Guix. Thanks, Pierre
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 14:42:01 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 16:22:01 GMT) Full text and rfc822 format available.Message #98 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Pierre Langlois <pierre.langlois <at> gmx.com> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org, guix-patches <at> gnu.org Subject: Re: [bug#54239] [PATCH v2 2/5] gnu: Add cross-clang. Date: Sat, 05 Mar 2022 16:05:43 +0000
[Message part 1 (text/plain, inline)]
Hi, A couple of comments from me while testing this trying to build a cross-toolchain with llvm-13. Hope this is helpful! Julien Lepiller <julien <at> lepiller.eu> writes: > * gnu/packages/llvm.scm (cross-clang): New variable. > --- > gnu/packages/llvm.scm | 144 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 143 insertions(+), 1 deletion(-) > > diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm > index d6e9846699..c277e2ac35 100644 > --- a/gnu/packages/llvm.scm > +++ b/gnu/packages/llvm.scm > @@ -54,6 +54,7 @@ (define-module (gnu packages llvm) > #:use-module (guix build-system trivial) > #:use-module (gnu packages) > #:use-module (gnu packages base) > + #:use-module (gnu packages cross-base) > #:use-module (gnu packages gcc) > #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker > #:use-module (gnu packages check) ;python-lit > @@ -75,7 +76,9 @@ (define-module (gnu packages llvm) > #:use-module (ice-9 match) > #:export (make-lld-wrapper > system->llvm-target > - cross-llvm)) > + cross-llvm > + cross-clang > + clang-for-target)) > > (define* (system->llvm-target #:optional > (system (or (and=> (%current-target-system) > @@ -1023,6 +1026,145 @@ (define-public clang-runtime clang-runtime-13) > (define-public clang clang-13) > (define-public clang-toolchain clang-toolchain-13) > > +(define* (cross-clang target > + #:key > + (libc (cross-libc target)) > + (xgcc (cross-gcc target > + #:xbinutils (cross-binutils target) > + #:libc (cross-libc target))) > + (clang clang)) > + "Return a cross-clang compiler for target." > + (define cross-clang-aux > + (mlambda (target libc xgcc clang) > + (package > + (inherit clang) > + (name (string-append "clang-cross-" target)) > + (version (package-version clang)) > + ;; Support the same variables as clang, even in cross-compilation context. > + ;; Clang does not make a difference between native and cross-compilation. > + (search-paths > + (list > + (search-path-specification > + (variable "CROSS_LIBRARY_PATH") > + (files '("lib"))) > + (search-path-specification > + (variable "CROSS_C_INCLUDE_PATH") > + (files '("include"))) > + (search-path-specification > + (variable "CROSS_CPLUS_INCLUDE_PATH") > + (files '("include/c++" "include"))))) > + (native-search-paths '()) > + (arguments > + (substitute-keyword-arguments (package-arguments clang) > + ((#:configure-flags _) > + `(list "-DCLANG_INCLUDE_TESTS=True" > + (string-append "-DGCC_INSTALL_PREFIX=" > + (assoc-ref %build-inputs "cross-gcc-lib")) > + (string-append "-DC_INCLUDE_DIRS=" > + (assoc-ref %build-inputs "target-libc") > + "/include"))) > + ((#:phases phases) > + `(modify-phases ,phases > + (add-after 'unpack 'add-missing-libdir > + (lambda _ > + ;; cross-gcc installs its libraries in <target>/lib instead of > + ;; lib. > + (substitute* "lib/Driver/ToolChain.cpp" > + (("\"-L\"\\) \\+ LibPath\\)\\);") > + ,(string-append "\"-L\") + LibPath)); > + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-L\") + " > + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" > + target "/lib\"))); > + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-rpath=\") + " > + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" > + target "/lib\")));"))))) > + (add-after 'unpack 'support-cross-include-path > + (lambda _ > + (substitute* "lib/Driver/ToolChains/Clang.cpp" > + (("C_INCLUDE_PATH") "CROSS_C_INCLUDE_PATH") > + (("CPLUS_INCLUDE_PATH") "CROSS_CPLUS_INCLUDE_PATH")))) > + (add-after 'unpack 'support-cross-library-path > + (lambda _ > + ;; LIBRARY_PATH is only supported for native builds, but we still > + ;; need it (or CROSS_LIBRARY_PATH to be precise) when > + ;; cross-compiling > + (substitute* "lib/Driver/ToolChains/CommonArgs.cpp" > + (("LIBRARY_PATH\"") > + "LIBRARY_PATH\"); > + } else { > + addDirectoryList(Args, CmdArgs, \"-L\", \"CROSS_LIBRARY_PATH\"")))) Testing this with llvm-13, this substitution doesn't look quite right and causes the build to fail, they might have removed braces between versions: https://github.com/llvm/llvm-project/blob/release/13.x/clang/lib/Driver/ToolChains/CommonArgs.cpp#L236 Doing a blame points to this commit, which suggest it's changed with LLVM 10 release I believe. https://github.com/llvm/llvm-project/commit/7dbdc8de183e7aa2dc0a9c3a4f473142ddd460bf, > + (replace 'set-glibc-file-names > + (lambda* (#:key inputs #:allow-other-keys) > + (let ((libc (assoc-ref inputs "target-libc")) > + (compiler-rt (assoc-ref inputs "clang-runtime")) Quick question, compiler-rt here is the host's runtime right? Do we not need to cross-compile it as well? It's not always clear to me what is part of compiler-rt vs libc vs libgcc, it could be target-dependent. For example when trying to target WebAssembly, I needed a cross-compiled compiler-rt to provide the libclang_rt.builtins-wasm32.a library. > + (gcc (assoc-ref inputs "cross-gcc"))) > + (setenv "LIBRARY_PATH" > + (string-append > + (assoc-ref inputs "libc") "/lib:" (getenv "LIBRARY_PATH"))) > + ,@(cond > + ((version>=? version "6.0") > + `(;; Link to libclang_rt files from clang-runtime. > + (substitute* "lib/Driver/ToolChain.cpp" > + (("getDriver\\(\\)\\.ResourceDir") > + (string-append "\"" compiler-rt "\""))) > + > + ;; Make "LibDir" refer to <glibc>/lib so that it > + ;; uses the right dynamic linker file name. > + (substitute* "lib/Driver/ToolChains/Linux.cpp" > + (("(^[[:blank:]]+LibDir = ).*" _ declaration) > + (string-append declaration "\"" libc "/lib\";\n")) > + > + ;; Make clang look for libstdc++ in the right > + ;; location. > + (("LibStdCXXIncludePathCandidates\\[\\] = \\{") > + (string-append > + "LibStdCXXIncludePathCandidates[] = { \"" gcc > + "/include/c++\",")) > + > + ;; Make sure libc's libdir is on the search path, to > + ;; allow crt1.o & co. to be found. > + (("@GLIBC_LIBDIR@") > + (string-append libc "/lib"))))) > + (else > + `((substitute* "lib/Driver/Tools.cpp" > + ;; Patch the 'getLinuxDynamicLinker' function so that > + ;; it uses the right dynamic linker file name. > + (("/lib64/ld-linux-x86-64.so.2") > + (string-append libc ,(glibc-dynamic-linker)))) > + > + ;; Link to libclang_rt files from clang-runtime. > + ;; This substitution needed slight adjustment in 3.8. > + ,@(if (version>=? version "3.8") > + '((substitute* "lib/Driver/Tools.cpp" > + (("TC\\.getDriver\\(\\)\\.ResourceDir") > + (string-append "\"" compiler-rt "\"")))) > + '((substitute* "lib/Driver/ToolChain.cpp" > + (("getDriver\\(\\)\\.ResourceDir") > + (string-append "\"" compiler-rt "\""))))) > + > + ;; Make sure libc's libdir is on the search path, to > + ;; allow crt1.o & co. to be found. > + (substitute* "lib/Driver/ToolChains.cpp" > + (("@GLIBC_LIBDIR@") > + (string-append libc "/lib"))))))))))))) > + (inputs > + `(("target-libc" ,libc) > + ("cross-gcc-lib" ,xgcc "lib") > + ("cross-gcc" ,xgcc) > + ,@(package-inputs clang))) > + (propagated-inputs > + (modify-inputs (package-propagated-inputs clang) > + (replace "llvm" > + (cross-llvm > + (car (assoc-ref (package-propagated-inputs clang) "llvm")) > + target))))))) > + (cross-clang-aux target libc xgcc clang)) > + > +(define* (clang-for-target #:optional (clang clang)) > + (if (%current-target-system) > + (cross-clang (%current-target-system) #:clang clang) > + clang)) > + > (define-public llvm-for-rocm > (package > ;; Actually based on LLVM 13 as of v4.3, but llvm-12 works just fine.
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 05 Mar 2022 16:22:02 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 21 May 2022 13:42:02 GMT) Full text and rfc822 format available.Message #104 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: Julien Lepiller <julien <at> lepiller.eu> Cc: 54239 <at> debbugs.gnu.org, Pierre Langlois <pierre.langlois <at> gmx.com>, Maxime Devos <maximedevos <at> telenet.be> Subject: Re: bug#54239: [PATCH] gnu: Add cross-clang. Date: Sat, 21 May 2022 15:41:27 +0200
Hello Julien and all, Looks like quite a lot of work has gone into this patch series. What’s the status? It would be nice to push it past the finish line! TIA, Ludo’.
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:45:01 GMT) Full text and rfc822 format available.Message #107 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Ludovic Courtès <ludo <at> gnu.org> Cc: 54239 <at> debbugs.gnu.org, Pierre Langlois <pierre.langlois <at> gmx.com>, Maxime Devos <maximedevos <at> telenet.be> Subject: Re: bug#54239: [PATCH] gnu: Add cross-clang. Date: Sat, 16 Jul 2022 21:44:24 +0200
So, I tried using only a wrapper around clang to pass --target. However, this doesn't seem to be enough: the code disables LIBRARY_PATH when cross-compiling and it picks up the wrong gcc:lib and libc headers. Instead, I tried to improve the previous patches, and here is v3. To reply (maybe again) to remarks on the previous version: - no it's not necessary to build a specific llvm package, but that way we make sure that the default target is the one we want, so we don't have to change the instructions for packages that use it, or to use a wrapper to pass the --target argument. Maybe a wrapper could work better though. - clang-for-target was added in the patch that adds cross-clang. - the configure flags are now a gexp - I kept the substitute for "/lib64/ld-linux-x86-64.so.2", it's the same instructions as in clang, so I prefer not to change it. It's a bit sad that we'll have to change in both places if needed :/ - (gnu packages cross-base) is autoloaded now - I'll leave documenting limitations of package-with-c-toolchain (or improving it) to another time. - I have no idea how to make it work for wasm, but that can probably be fixed another time. Also, it's not listed in supported targets, and guix doesn't let me build for that target anymore. - Fixed build issues for clang >=10. I also agree that clang-runtime should be cross-compiled. It is a propagated-input, but cross-clang is a native package that is a cross-compiler for another architecture, so the inputs are native too. Since I couldn't figure out how to make a package for a given target, I added a transformation to (guix build-system) that replaces the keywords to force a package to build for a given architecture. Also, I added libcxx and libcxxabi 12 at the end because I need them for the newer versions of android tools.
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:01 GMT) Full text and rfc822 format available.Message #110 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 01/10] guix: Add build-system transformation for target. Date: Sat, 16 Jul 2022 21:47:58 +0200
* guix/build-system.scm (build-system-with-target): New procedure. --- guix/build-system.scm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/guix/build-system.scm b/guix/build-system.scm index 76d670995c..7d864423e3 100644 --- a/guix/build-system.scm +++ b/guix/build-system.scm @@ -18,6 +18,7 @@ (define-module (guix build-system) #:use-module (guix records) + #:use-module (guix utils) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (build-system @@ -40,7 +41,8 @@ (define-module (guix build-system) make-bag - build-system-with-c-toolchain)) + build-system-with-c-toolchain + build-system-with-target)) (define-record-type* <build-system> build-system make-build-system build-system? @@ -129,3 +131,20 @@ (define (lower* . args) (build-system (inherit bs) (lower lower*))) + +(define (build-system-with-target bs target) + "Return a variant of @var{bs}, a build system, that user @var{target} instead +of the default target." + (define lower + (build-system-lower bs)) + + (define (lower* . args) + (parameterize ((%current-target-system target)) + (apply lower + (append + (strip-keyword-arguments (list #:target) args) + (list #:target target))))) + + (build-system + (inherit bs) + (lower lower*))) -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:02 GMT) Full text and rfc822 format available.Message #113 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 02/10] gnu: clang-runtime: Fix cross-compilation. Date: Sat, 16 Jul 2022 21:47:59 +0200
* gnu/packages/llvm.scm (clang-runtime-from-llvm): Sanitie CROSS_CPLUS_INCLUDE_PATH in the same way as CPLUS_INCLUDE_PATH. --- gnu/packages/llvm.scm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 5a2f411eb2..6428391650 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -141,7 +141,7 @@ (define* (clang-runtime-from-llvm llvm ;; Work around https://issues.guix.info/issue/36882. We need to ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded ;; in GCC, at the bottom of GCC include search-path is used. - (lambda* (#:key inputs #:allow-other-keys) + (lambda* (#:key inputs target #:allow-other-keys) (let* ((filters '("libc")) (input-directories (filter-map (lambda (input) @@ -153,7 +153,20 @@ (define* (clang-runtime-from-llvm llvm (set-path-environment-variable "CPLUS_INCLUDE_PATH" '("include") input-directories) - #t)))))) + (when target + (let ((libc (assoc-ref inputs "cross-libc"))) + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join + (filter + (lambda (path) + (and + (not (equal? path + (string-append libc "/include"))) + (string-suffix? "include" path))) + + (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") + #\:)) + ":")))))))))) (home-page "https://compiler-rt.llvm.org") (synopsis "Runtime library for Clang/LLVM") (description -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:02 GMT) Full text and rfc822 format available.Message #116 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 03/10] gnu: llvm-9: Fix cross-compilation. Date: Sat, 16 Jul 2022 21:48:00 +0200
`(package-arguments llvm-10)' evaluates `this-package' in the context of llvm-10. `llvm-tblgen' in llvm-10 is not compatible with llvm-9, so copy the configure-flags from llvm-12 to make sure `this-package' is evaluated here. * gnu/packages/llvm.scm (llvm-9)[arguments]: Fix cross-compilation. --- gnu/packages/llvm.scm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 6428391650..2aec2925cf 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -973,7 +973,30 @@ (define-public llvm-9 "if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES \"riscv64\")\n" " target_link_libraries(dsymutil PRIVATE atomic)\n" "endif()")))))))) - (package-arguments llvm-10))))) + (substitute-keyword-arguments (package-arguments llvm-10) + ((#:configure-flags _) + #~(#$(if (%current-target-system) + #~quasiquote + #~quote) + ;; These options are required for cross-compiling LLVM according to + ;; https://llvm.org/docs/HowToCrossCompileLLVM.html. + (#$@(if (%current-target-system) + #~(,(string-append "-DLLVM_TABLEGEN=" + #+(file-append this-package + "/bin/llvm-tblgen")) + #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" + (%current-target-system)) + #$(string-append "-DLLVM_TARGET_ARCH=" + (system->llvm-target)) + #$(string-append "-DLLVM_TARGETS_TO_BUILD=" + (system->llvm-target))) + #~()) + "-DCMAKE_SKIP_BUILD_RPATH=FALSE" + "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE" + "-DBUILD_SHARED_LIBS:BOOL=TRUE" + "-DLLVM_ENABLE_FFI:BOOL=TRUE" + "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities + "-DLLVM_INSTALL_UTILS=ON")))))))) ; Needed for rustc. (define-public clang-runtime-9 (clang-runtime-from-llvm -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:03 GMT) Full text and rfc822 format available.Message #119 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 04/10] gnu: Add cross-llvm. Date: Sat, 16 Jul 2022 21:48:01 +0200
* gnu/packages/llvm.scm (cross-llvm): New variable. --- gnu/packages/llvm.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 2aec2925cf..caf8264bef 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -18,7 +18,7 @@ ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2021, 2022 Maxime Devos <maximedevos <at> telenet.be> ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> -;;; Copyright © 2021 Julien Lepiller <julien <at> lepiller.eu> +;;; Copyright © 2021, 2022 Julien Lepiller <julien <at> lepiller.eu> ;;; Copyright © 2021 Lars-Dominik Braun <lars <at> 6xq.net> ;;; Copyright © 2021, 2022 Guillaume Le Vaillant <glv <at> posteo.net> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> @@ -76,7 +76,8 @@ (define-module (gnu packages llvm) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (make-lld-wrapper - system->llvm-target)) + system->llvm-target + cross-llvm)) (define* (system->llvm-target #:optional (system (or (and=> (%current-target-system) @@ -101,6 +102,22 @@ (define* (system->llvm-target #:optional ("i686" => "X86") ("i586" => "X86")))) +(define (cross-llvm llvm target) + "Return a native LLVM package that targets a different system. The resulting +libraries are running on the host but target a different system by default. +This packge can be used to control clang's default target." + (package + (inherit llvm) + (arguments + (substitute-keyword-arguments (package-arguments llvm) + ((#:configure-flags flags) + #~(append + (list + (string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" #$target) + (string-append "-DLLVM_TARGET_ARCH=" + #$(system->llvm-target (gnu-triplet->nix-system target)))) + #$flags)))))) + (define (llvm-uri component version) ;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz' ;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name. -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:03 GMT) Full text and rfc822 format available.Message #122 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 05/10] gnu: Add cross-clang. Date: Sat, 16 Jul 2022 21:48:02 +0200
* gnu/packages/llvm.scm (cross-clang): New variable. --- gnu/packages/llvm.scm | 169 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 168 insertions(+), 1 deletion(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index caf8264bef..560a64840a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -48,6 +48,7 @@ (define-module (gnu packages llvm) #:use-module (guix git-download) #:use-module (guix memoization) #:use-module (guix utils) + #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (guix build-system cmake) #:use-module (guix build-system emacs) @@ -75,9 +76,12 @@ (define-module (gnu packages llvm) #:use-module (gnu packages xml) #:use-module (srfi srfi-1) #:use-module (ice-9 match) + #:autoload (gnu packages cross-base) (cross-libc cross-gcc cross-binutils) #:export (make-lld-wrapper system->llvm-target - cross-llvm)) + cross-llvm + cross-clang + clang-for-target)) (define* (system->llvm-target #:optional (system (or (and=> (%current-target-system) @@ -1263,6 +1267,169 @@ (define-public clang-runtime clang-runtime-13) (define-public clang clang-13) (define-public clang-toolchain clang-toolchain-13) +(define* (cross-clang target + #:key + (libc (cross-libc target)) + (xgcc (cross-gcc target + #:xbinutils (cross-binutils target) + #:libc (cross-libc target))) + (clang clang)) + "Return a cross-clang compiler for target." + (define cross-clang-aux + (mlambda (target libc xgcc clang) + (package + (inherit clang) + (name (string-append "clang-cross-" target)) + (version (package-version clang)) + ;; Support the same variables as clang, even in cross-compilation context. + ;; Clang does not make a difference between native and cross-compilation. + (search-paths + (list + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files '("lib"))) + (search-path-specification + (variable "CROSS_C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_CPLUS_INCLUDE_PATH") + (files '("include/c++" "include"))))) + (native-search-paths '()) + (arguments + (substitute-keyword-arguments (package-arguments clang) + ((#:configure-flags _) + #~(list "-DCLANG_INCLUDE_TESTS=True" + (string-append "-DGCC_INSTALL_PREFIX=" + (assoc-ref %build-inputs "cross-gcc-lib")) + (string-append "-DC_INCLUDE_DIRS=" + (assoc-ref %build-inputs "target-libc") + "/include"))) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'add-missing-libdir + (lambda _ + ;; cross-gcc installs its libraries in <target>/lib instead of + ;; lib. + (substitute* "lib/Driver/ToolChain.cpp" + (("\"-L\"\\) \\+ LibPath\\)\\);") + ,(string-append "\"-L\") + LibPath)); + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-L\") + " + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" + target "/lib\"))); + CmdArgs.push_back(Args.MakeArgString(StringRef(\"-rpath=\") + " + "StringRef(GCC_INSTALL_PREFIX) + StringRef(\"/" + target "/lib\")));"))))) + (add-after 'unpack 'support-cross-include-path + (lambda _ + (substitute* ,(if (version>=? version "6.0") + "lib/Driver/ToolChains/Clang.cpp" + "lib/Driver/Tools.cpp") + (("C_INCLUDE_PATH") "CROSS_C_INCLUDE_PATH") + (("CPLUS_INCLUDE_PATH") "CROSS_CPLUS_INCLUDE_PATH")))) + (add-after 'unpack 'support-cross-library-path + (lambda _ + ;; LIBRARY_PATH is only supported for native builds, but we still + ;; need it (or CROSS_LIBRARY_PATH to be precise) when + ;; cross-compiling + ,(cond + ((version>=? version "10") + `(substitute* "lib/Driver/ToolChains/CommonArgs.cpp" + (("LIBRARY_PATH\"") + "LIBRARY_PATH\"); + else + addDirectoryList(Args, CmdArgs, \"-L\", \"CROSS_LIBRARY_PATH\""))) + ((version>=? version "6.0") + `(substitute* "lib/Driver/ToolChains/CommonArgs.cpp" + (("LIBRARY_PATH\"") + "LIBRARY_PATH\"); + } else { + addDirectoryList(Args, CmdArgs, \"-L\", \"CROSS_LIBRARY_PATH\""))) + (else + `(substitute* "lib/Driver/Tools.cpp" + (("LIBRARY_PATH\"") + "LIBRARY_PATH\"); + else + addDirectoryList(Args, CmdArgs, \"-L\", \"CROSS_LIBRARY_PATH\"")))))) + (replace 'set-glibc-file-names + (lambda* (#:key inputs #:allow-other-keys) + (let ((libc (assoc-ref inputs "target-libc")) + (compiler-rt (assoc-ref inputs "clang-runtime")) + (gcc (assoc-ref inputs "cross-gcc"))) + (setenv "LIBRARY_PATH" + (string-append + (assoc-ref inputs "libc") "/lib:" (getenv "LIBRARY_PATH"))) + ,@(cond + ((version>=? version "6.0") + `(;; Link to libclang_rt files from clang-runtime. + (substitute* "lib/Driver/ToolChain.cpp" + (("getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\""))) + + ;; Make "LibDir" refer to <glibc>/lib so that it + ;; uses the right dynamic linker file name. + (substitute* "lib/Driver/ToolChains/Linux.cpp" + (("(^[[:blank:]]+LibDir = ).*" _ declaration) + (string-append declaration "\"" libc "/lib\";\n")) + + ;; Make clang look for libstdc++ in the right + ;; location. + (("LibStdCXXIncludePathCandidates\\[\\] = \\{") + (string-append + "LibStdCXXIncludePathCandidates[] = { \"" gcc + "/include/c++\",")) + + ;; Make sure libc's libdir is on the search path, to + ;; allow crt1.o & co. to be found. + (("@GLIBC_LIBDIR@") + (string-append libc "/lib"))))) + (else + `((substitute* "lib/Driver/Tools.cpp" + ;; Patch the 'getLinuxDynamicLinker' function so that + ;; it uses the right dynamic linker file name. + (("/lib64/ld-linux-x86-64.so.2") + (string-append libc ,(glibc-dynamic-linker)))) + + ;; Link to libclang_rt files from clang-runtime. + ;; This substitution needed slight adjustment in 3.8. + ,@(if (version>=? version "3.8") + '((substitute* "lib/Driver/Tools.cpp" + (("TC\\.getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\"")))) + '((substitute* "lib/Driver/ToolChain.cpp" + (("getDriver\\(\\)\\.ResourceDir") + (string-append "\"" compiler-rt "\""))))) + + ;; Make sure libc's libdir is on the search path, to + ;; allow crt1.o & co. to be found. + (substitute* "lib/Driver/ToolChains.cpp" + (("@GLIBC_LIBDIR@") + (string-append libc "/lib"))))))))))))) + (inputs + `(("target-libc" ,libc) + ("cross-gcc-lib" ,xgcc "lib") + ("cross-gcc" ,xgcc) + ,@(package-inputs clang))) + (propagated-inputs + (modify-inputs (package-propagated-inputs clang) + (replace "clang-runtime" + (let ((base (car (assoc-ref (package-propagated-inputs clang) + "clang-runtime")))) + (package + (inherit base) + (build-system (build-system-with-target + (package-build-system base) + target))))) + (replace "llvm" + (cross-llvm + (car (assoc-ref (package-propagated-inputs clang) "llvm")) + target))))))) + (cross-clang-aux target libc xgcc clang)) + +(define* (clang-for-target #:optional (clang clang)) + (if (%current-target-system) + (cross-clang (%current-target-system) #:clang clang) + clang)) + (define-public llvm-for-rocm (package ;; Based on LLVM 14 as of v5.0.0 -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:03 GMT) Full text and rfc822 format available.Message #125 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 06/10] gnu: libcxx: Allow cross-compilation. Date: Sat, 16 Jul 2022 21:48:03 +0200
* gnu/packages/llvm.scm (libcxx)[native-inputs]: Move llvm to... [inputs]: ...here. [arguments]: adjust CROSS_INCLUDE_PATH when cross-compiling. (libcxx-6)[native-inputs]: Move llvm to... [inputs]: ...here. --- gnu/packages/llvm.scm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 560a64840a..96620f1c3c 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1640,8 +1640,9 @@ (define-public libcxx `(#:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH - (lambda* (#:key inputs #:allow-other-keys) - (let ((gcc (assoc-ref inputs "gcc"))) + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (let ((gcc (or (assoc-ref (or native-inputs inputs) "gcc"))) + (cross-gcc (assoc-ref native-inputs "cross-gcc"))) ;; Hide GCC's C++ headers so that they do not interfere with ;; the ones we are attempting to build. (setenv "CPLUS_INCLUDE_PATH" @@ -1649,12 +1650,19 @@ (define-public libcxx (string-split (getenv "CPLUS_INCLUDE_PATH") #\:)) ":")) + (when cross-gcc + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join (delete (string-append cross-gcc "/include/c++") + (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") + #\:)) + ":")) + (format #t + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH"))) (format #t "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" - (getenv "CPLUS_INCLUDE_PATH")) - #t)))))) - (native-inputs - (list clang llvm)) + (getenv "CPLUS_INCLUDE_PATH")))))))) + (inputs (list llvm-9)) (home-page "https://libcxx.llvm.org") (synopsis "C++ standard library") (description @@ -1675,8 +1683,7 @@ (define-public libcxx-6 (sha256 (base32 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) - (native-inputs - (list clang-6 llvm-6)))) + (inputs (list llvm-6)))) (define-public libcxxabi-6 (package -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:04 GMT) Full text and rfc822 format available.Message #128 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 07/10] gnu: libcxxabi-6: Allow cross-compilation. Date: Sat, 16 Jul 2022 21:48:04 +0200
* gnu/packages/llvm.scm (libcxxabi-6)[native-inputs]: Use clang-for-target for cross-compilation. Move llvm and libcxx to... [inputs]: ...here. [arguments]<adjust-CPLUS_INCLUDE_PATH>: Also adjust CROSS_CPLUS_INCLUDE_PATH when necessary. --- gnu/packages/llvm.scm | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 96620f1c3c..ba48897c8b 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1711,19 +1711,43 @@ (define-public libcxxabi-6 (modify-phases (@ (guix build cmake-build-system) %standard-phases) (add-after 'unpack 'chdir (lambda _ (chdir "libcxxabi"))) - (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH - (lambda* (#:key inputs #:allow-other-keys) - (let ((gcc (assoc-ref inputs "gcc"))) + (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (define (delete* what lst) + (if (null? what) + lst + (delete* (cdr what) (delete (car what) lst)))) + + (let ((gcc (or (assoc-ref inputs "gcc") (assoc-ref native-inputs "gcc"))) + (cross-gcc (assoc-ref native-inputs "cross-gcc"))) ;; Hide GCC's C++ headers so that they do not interfere with ;; the ones we are attempting to build. (setenv "CPLUS_INCLUDE_PATH" (string-join (cons (string-append (assoc-ref inputs "libcxx") "/include/c++/v1") - (delete (string-append gcc "/include/c++") - (string-split (getenv "CPLUS_INCLUDE_PATH") - #\:))) + (delete* + `(,(string-append gcc "/include/c++") + ,@(if cross-gcc + `(,(string-append cross-gcc "/include/c++")) + '())) + (string-split (getenv "CPLUS_INCLUDE_PATH") + #\:))) ":")) + (when cross-gcc + (setenv "CROSS_CPLUS_INCLUDE_PATH" + (string-join + (cons (string-append + (assoc-ref inputs "libcxx") "/include/c++/v1") + (delete* + (list (string-append cross-gcc "/include/c++") + (string-append gcc "/include/c++")) + (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") + #\:))) + ":")) + (format #true + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH"))) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH"))))) @@ -1733,8 +1757,8 @@ (define-public libcxxabi-6 (assoc-ref outputs "out") "/include"))) (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) - (native-inputs - (list clang-6 llvm-6 libcxx-6)) + (inputs (list llvm-6 libcxx-6)) + (native-inputs (list (clang-for-target clang-6))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:04 GMT) Full text and rfc822 format available.Message #131 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 08/10] gnu: Add libcxxabi-9. Date: Sat, 16 Jul 2022 21:48:05 +0200
* gnu/packages/llvm.scm (libcxxabi-9): New variable. (libcxxabi-6): Inherit from it. --- gnu/packages/llvm.scm | 66 +++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index ba48897c8b..77c3ab73e0 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1685,20 +1685,17 @@ (define-public libcxx-6 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) (inputs (list llvm-6)))) -(define-public libcxxabi-6 +(define-public libcxxabi-9 (package (name "libcxxabi") - (version "6.0.1") + (version (package-version clang-9)) (source (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/llvm/llvm-project") - (commit (string-append "llvmorg-" version)))) - (file-name (git-file-name name version)) + (method url-fetch) + (uri (llvm-uri "libcxxabi" version)) (sha256 (base32 - "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g")))) + "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8")))) (build-system cmake-build-system) (arguments `(#:configure-flags @@ -1709,8 +1706,6 @@ (define-public libcxxabi-6 "-DCMAKE_CXX_COMPILER=clang++") #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) - (add-after 'unpack 'chdir - (lambda _ (chdir "libcxxabi"))) (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs native-inputs #:allow-other-keys) (define (delete* what lst) @@ -1744,10 +1739,10 @@ (define (delete* what lst) (string-append gcc "/include/c++")) (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH") #\:))) - ":")) - (format #true - "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" - (getenv "CROSS_CPLUS_INCLUDE_PATH"))) + ":"))) + (format #true + "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%" + (getenv "CROSS_CPLUS_INCLUDE_PATH")) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH"))))) @@ -1755,10 +1750,15 @@ (define (delete* what lst) (lambda* (#:key outputs #:allow-other-keys) (let ((include-dir (string-append (assoc-ref outputs "out") "/include"))) - (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) - (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) - (inputs (list llvm-6 libcxx-6)) - (native-inputs (list (clang-for-target clang-6))) + (mkdir-p include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/__cxxabi_config.h") + include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/cxxabi.h") + include-dir))))))) + (inputs (list llvm-9 libcxx)) + (native-inputs (list (clang-for-target clang-9))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description @@ -1766,6 +1766,36 @@ (define (delete* what lst) standard C++ library.") (license license:expat))) +(define-public libcxxabi-6 + (package + (inherit libcxxabi-9) + (name "libcxxabi") + (version "6.0.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/llvm/llvm-project") + (commit (string-append "llvmorg-" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g")))) + (arguments + (substitute-keyword-arguments (package-arguments libcxxabi-9) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'chdir + (lambda _ (chdir "libcxxabi"))) + (replace 'install-headers + (lambda* (#:key outputs #:allow-other-keys) + (let ((include-dir (string-append + (assoc-ref outputs "out") "/include"))) + (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) + (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))) + (inputs (list llvm-6 libcxx-6)) + (native-inputs (list (clang-for-target clang-6))))) + (define-public libcxx+libcxxabi-6 (package (inherit libcxx-6) -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:04 GMT) Full text and rfc822 format available.Message #134 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 09/10] gnu: Add libcxx-12. Date: Sat, 16 Jul 2022 21:48:06 +0200
* gnu/packages/llvm.scm (libcxx): Rename to... (libcxx-9): ...this. (libcxx-12): New variable. --- gnu/packages/llvm.scm | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 77c3ab73e0..4f0b57a990 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1624,21 +1624,24 @@ (define-public lldb (properties `((release-monitoring-url . ,%llvm-release-monitoring-url))) (license license:asl2.0))) ;with LLVM exceptions -(define-public libcxx +(define-public libcxx-12 (package (name "libcxx") - (version "9.0.1") + (version (package-version llvm-12)) (source (origin (method url-fetch) - (uri (llvm-uri "libcxx" version)) + (uri (llvm-uri "llvm-project" version)) (sha256 (base32 - "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089")))) + "03ps7akvbkxxa4xzal49v7lw3bz41zmjsp6fa7cslxrns5fb570j")))) (build-system cmake-build-system) (arguments `(#:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) + (add-after 'unpack 'chdir + (lambda _ + (chdir "libcxx"))) (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs native-inputs #:allow-other-keys) (let ((gcc (or (assoc-ref (or native-inputs inputs) "gcc"))) @@ -1662,7 +1665,8 @@ (define-public libcxx (format #t "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH")))))))) - (inputs (list llvm-9)) + (inputs (list llvm-12)) + (native-inputs (list python)) (home-page "https://libcxx.llvm.org") (synopsis "C++ standard library") (description @@ -1671,14 +1675,32 @@ (define-public libcxx (properties `((release-monitoring-url . ,%llvm-release-monitoring-url))) (license license:expat))) +(define-public libcxx-9 + (package + (inherit libcxx-12) + (version (package-version llvm-9)) + (source + (origin + (method url-fetch) + (uri (llvm-uri "libcxx" version)) + (sha256 + (base32 + "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089")))) + (arguments + (substitute-keyword-arguments (package-arguments libcxx-12) + ((#:phases phases) + `(modify-phases ,phases + (delete 'chdir))))) + (inputs (list llvm-9)))) + ;; Libcxx files specifically used by PySide2. (define-public libcxx-6 (package - (inherit libcxx) + (inherit libcxx-9) (version (package-version llvm-6)) (source (origin - (inherit (package-source libcxx)) + (inherit (package-source libcxx-9)) (uri (llvm-uri "libcxx" version)) (sha256 (base32 @@ -1757,7 +1779,7 @@ (define (delete* what lst) (install-file ,(string-append "../libcxxabi-" version ".src/include/cxxabi.h") include-dir))))))) - (inputs (list llvm-9 libcxx)) + (inputs (list llvm-9 libcxx-9)) (native-inputs (list (clang-for-target clang-9))) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Sat, 16 Jul 2022 19:49:05 GMT) Full text and rfc822 format available.Message #137 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: 54239 <at> debbugs.gnu.org Subject: [PATCH v3 10/10] gnu: Add libcxxabi-12. Date: Sat, 16 Jul 2022 21:48:07 +0200
* gnu/packages/llvm.scm (libcxxabi-12): New variable. (libcxxabi-9): Inherit from it. --- gnu/packages/llvm.scm | 53 +++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 4f0b57a990..72fef43a5f 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1707,17 +1707,17 @@ (define-public libcxx-6 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) (inputs (list llvm-6)))) -(define-public libcxxabi-9 +(define-public libcxxabi-12 (package (name "libcxxabi") - (version (package-version clang-9)) + (version (package-version clang-12)) (source (origin (method url-fetch) - (uri (llvm-uri "libcxxabi" version)) + (uri (llvm-uri "llvm-project" version)) (sha256 (base32 - "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8")))) + "03ps7akvbkxxa4xzal49v7lw3bz41zmjsp6fa7cslxrns5fb570j")))) (build-system cmake-build-system) (arguments `(#:configure-flags @@ -1728,6 +1728,9 @@ (define-public libcxxabi-9 "-DCMAKE_CXX_COMPILER=clang++") #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) + (add-after 'unpack 'chdir + (lambda _ + (chdir "libcxxabi"))) (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs native-inputs #:allow-other-keys) (define (delete* what lst) @@ -1773,14 +1776,10 @@ (define (delete* what lst) (let ((include-dir (string-append (assoc-ref outputs "out") "/include"))) (mkdir-p include-dir) - (install-file ,(string-append "../libcxxabi-" version - ".src/include/__cxxabi_config.h") - include-dir) - (install-file ,(string-append "../libcxxabi-" version - ".src/include/cxxabi.h") - include-dir))))))) - (inputs (list llvm-9 libcxx-9)) - (native-inputs (list (clang-for-target clang-9))) + (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir) + (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))) + (inputs (list llvm-12 libcxx-12)) + (native-inputs (list (clang-for-target clang-12) python)) (home-page "https://libcxxabi.llvm.org") (synopsis "C++ standard library support") (description @@ -1788,6 +1787,36 @@ (define (delete* what lst) standard C++ library.") (license license:expat))) +(define-public libcxxabi-9 + (package + (inherit libcxxabi-12) + (version (package-version clang-9)) + (source + (origin + (method url-fetch) + (uri (llvm-uri "libcxxabi" version)) + (sha256 + (base32 + "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8")))) + (arguments + (substitute-keyword-arguments (package-arguments libcxxabi-12) + ((#:phases phases) + `(modify-phases ,phases + (delete 'chdir) + (replace 'install-headers + (lambda* (#:key outputs #:allow-other-keys) + (let ((include-dir (string-append + (assoc-ref outputs "out") "/include"))) + (mkdir-p include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/__cxxabi_config.h") + include-dir) + (install-file ,(string-append "../libcxxabi-" version + ".src/include/cxxabi.h") + include-dir)))))))) + (inputs (list llvm-9 libcxx-9)) + (native-inputs (list (clang-for-target clang-9))))) + (define-public libcxxabi-6 (package (inherit libcxxabi-9) -- 2.37.0
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Tue, 19 Jul 2022 19:55:01 GMT) Full text and rfc822 format available.Message #140 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Maxime Devos <maximedevos <at> telenet.be> To: Julien Lepiller <julien <at> lepiller.eu>, Ludovic Courtès <ludo <at> gnu.org> Cc: 54239 <at> debbugs.gnu.org, Pierre Langlois <pierre.langlois <at> gmx.com> Subject: Re: bug#54239: [PATCH] gnu: Add cross-clang. Date: Tue, 19 Jul 2022 21:54:16 +0200
[Message part 1 (text/plain, inline)]
On 16-07-2022 21:44, Julien Lepiller wrote: > Since I couldn't figure out how to make a package for a given target, I > added a transformation to (guix build-system) that replaces the > keywords to force a package to build for a given architecture. Try: scheme@(guix-user)> ,build (with-parameters ((%current-target-system "aarch64-linux-gnu")) (specification->package "hello")) [...] $3 = "/gnu/store/rys78r4j72zh45xchq87x2y30ya8mzvi-hello-2.12.1" Greetings, Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]
guix-patches <at> gnu.org
:bug#54239
; Package guix-patches
.
(Tue, 19 Jul 2022 20:43:02 GMT) Full text and rfc822 format available.Message #143 received at 54239 <at> debbugs.gnu.org (full text, mbox):
From: Julien Lepiller <julien <at> lepiller.eu> To: Maxime Devos <maximedevos <at> telenet.be> Cc: 54239 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>, Pierre Langlois <pierre.langlois <at> gmx.com> Subject: Re: bug#54239: [PATCH] gnu: Add cross-clang. Date: Tue, 19 Jul 2022 22:42:11 +0200
Le Tue, 19 Jul 2022 21:54:16 +0200, Maxime Devos <maximedevos <at> telenet.be> a écrit : > On 16-07-2022 21:44, Julien Lepiller wrote: > > Since I couldn't figure out how to make a package for a given > > target, I added a transformation to (guix build-system) that > > replaces the keywords to force a package to build for a given > > architecture. > > > Try: > > scheme@(guix-user)> ,build (with-parameters ((%current-target-system > "aarch64-linux-gnu")) (specification->package "hello")) > > [...] > > $3 = "/gnu/store/rys78r4j72zh45xchq87x2y30ya8mzvi-hello-2.12.1" > > Greetings, > > Maxime. > Thanks, that was a lot easier than I thought. So I removed the first patch and changed to (with-parameters ((%current-target-system target)) base) in cross-clang.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.