From fd922e259d430ed5617a541ea2d4f5f76eb1c1c0 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Thu, 23 Sep 2021 23:08:25 +0200 Subject: [PATCH 2/6] gnu: llvm: Let it cross-compile. The derivation when compiling natively remains the same, so this doesn't cause any rebuilds. * gnu/packages/llvm.scm (llvm-12)[arguments]<#:configure-flags>: Set LLVM_TABLEGEN, LLVM_DEFAULT_TARGET_TRIPLE, LLVM_TARGET_ARCH and LLVM_TARGETS_TO_BUILD when cross-compiling. --- gnu/packages/llvm.scm | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 7cfa02ec99..3d62965cb8 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -17,6 +17,7 @@ ;;; Copyright © 2020 Giacomo Leidi ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2020 Maxim Cournoyer +;;; Copyright © 2021 Maxime Devos ;;; Copyright © 2021 Julien Lepiller ;;; Copyright © 2021 Lars-Dominik Braun ;;; @@ -39,6 +40,7 @@ #:use-module (guix packages) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix download) + #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix memoization) #:use-module (guix utils) @@ -498,13 +500,30 @@ output), and Binutils.") (propagated-inputs `(("zlib" ,zlib))) ;to use output from llvm-config (arguments - `(#:configure-flags '("-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. - + ;; TODO(core-updates): Unconditionally use quasiquote + `(#: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. ;; Don't use '-g' during the build, to save space. #:build-type "Release" #:phases -- 2.33.0