gnu: Add make-llvm procedure.

* gnu/packages/llvm.scm (make-llvm): New procedure.
(llvm-15): Rewrite using make-llvm.

Change-Id: I8f7d7bd5cf8bbe86af8f4a75bf8aec09074c07dc
This commit is contained in:
Efraim Flashner 2025-01-26 16:01:30 +02:00
parent b821b3bedc
commit deb3562384
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -594,74 +594,78 @@ output), and Binutils.")
(sha256 (base32 (assoc-ref %llvm-monorepo-hashes version))) (sha256 (base32 (assoc-ref %llvm-monorepo-hashes version)))
(patches (map search-patch (assoc-ref %llvm-patches version))))) (patches (map search-patch (assoc-ref %llvm-patches version)))))
;;; TODO: Make the base llvm all other LLVM inherit from on core-updates. ;; A base llvm package that can be used for creating other llvm packages.
(define-public llvm-15 (define make-llvm
(package (mlambda (version)
(name "llvm") (package
(version "15.0.7") (name "llvm")
(source (llvm-monorepo version)) (version version)
(build-system cmake-build-system) (source (llvm-monorepo version))
(outputs '("out" "opt-viewer")) (build-system cmake-build-system)
(arguments (outputs '("out" "opt-viewer"))
(list (arguments
#:configure-flags (list
#~(list #:configure-flags
;; These options are required for cross-compiling LLVM according #~(list
;; to <https://llvm.org/docs/HowToCrossCompileLLVM.html>. ;; These options are required for cross-compiling LLVM according
#$@(if (%current-target-system) ;; to <https://llvm.org/docs/HowToCrossCompileLLVM.html>.
(or (and=> #$@(if (%current-target-system)
(system->llvm-target-arch) (or (and=>
(lambda (llvm-target-arch) (system->llvm-target-arch)
#~((string-append "-DLLVM_TABLEGEN=" (lambda (llvm-target-arch)
#+(file-append this-package #~((string-append "-DLLVM_TABLEGEN="
"/bin/llvm-tblgen")) #+(file-append this-package
#$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" "/bin/llvm-tblgen"))
(%current-target-system)) #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
#$(string-append "-DLLVM_TARGET_ARCH=" llvm-target-arch) (%current-target-system))
#$(string-append "-DLLVM_TARGETS_TO_BUILD=" #$(string-append "-DLLVM_TARGET_ARCH=" llvm-target-arch)
(system->llvm-target))))) #$(string-append "-DLLVM_TARGETS_TO_BUILD="
(raise (condition (system->llvm-target)))))
(&package-unsupported-target-error (raise (condition
(package this-package) (&package-unsupported-target-error
(target (%current-target-system)))))) (package this-package)
'()) (target (%current-target-system))))))
;; Note: sadly, the build system refuses the use of '())
;; -DBUILD_SHARED_LIBS=ON and the large static archives are needed to ;; Note: sadly, the build system refuses the use of
;; build clang-runtime, so we cannot delete them. ;; -DBUILD_SHARED_LIBS=ON and the large static archives are needed to
"-DLLVM_BUILD_LLVM_DYLIB=ON" ;; build clang-runtime, so we cannot delete them.
"-DLLVM_LINK_LLVM_DYLIB=ON" "-DLLVM_BUILD_LLVM_DYLIB=ON"
"-DLLVM_ENABLE_FFI=ON" "-DLLVM_LINK_LLVM_DYLIB=ON"
"-DLLVM_ENABLE_RTTI=ON" ;for some third-party utilities "-DLLVM_ENABLE_FFI=ON"
"-DLLVM_INSTALL_UTILS=ON" ;needed for rustc "-DLLVM_ENABLE_RTTI=ON" ;for some third-party utilities
"-DLLVM_PARALLEL_LINK_JOBS=1") ;cater to smaller build machines "-DLLVM_INSTALL_UTILS=ON" ;needed for rustc
;; Don't use '-g' during the build, to save space. "-DLLVM_PARALLEL_LINK_JOBS=1") ;cater to smaller build machines
#:build-type "Release" ;; Don't use '-g' during the build, to save space.
#:phases #:build-type "Release"
#~(modify-phases %standard-phases #:phases
(add-after 'unpack 'change-directory #~(modify-phases %standard-phases
(lambda _ (add-after 'unpack 'change-directory
(chdir "llvm"))) (lambda _
(add-after 'install 'install-opt-viewer (chdir "llvm")))
(lambda* (#:key outputs #:allow-other-keys) (add-after 'install 'install-opt-viewer
(let* ((opt-viewer-share (string-append #$output:opt-viewer (lambda* (#:key outputs #:allow-other-keys)
"/share"))) (let* ((opt-viewer-share (string-append #$output:opt-viewer
(mkdir-p opt-viewer-share) "/share")))
(rename-file (string-append #$output "/share/opt-viewer") (mkdir-p opt-viewer-share)
opt-viewer-share))))))) (rename-file (string-append #$output "/share/opt-viewer")
(native-inputs (list python-wrapper perl)) opt-viewer-share)))))))
(inputs (list libffi)) (native-inputs (list python-wrapper perl))
(propagated-inputs (list zlib)) ;to use output from llvm-config (inputs (list libffi))
(home-page "https://www.llvm.org") (propagated-inputs (list zlib)) ;to use output from llvm-config
(synopsis "Optimizing compiler infrastructure") (home-page "https://www.llvm.org")
(description (synopsis "Optimizing compiler infrastructure")
"LLVM is a compiler infrastructure designed for compile-time, link-time, (description
"LLVM is a compiler infrastructure designed for compile-time, link-time,
runtime, and idle-time optimization of programs from arbitrary programming runtime, and idle-time optimization of programs from arbitrary programming
languages. It currently supports compilation of C and C++ programs, using languages. It currently supports compilation of C and C++ programs, using
front-ends derived from GCC 4.0.1. A new front-end for the C family of front-ends derived from GCC 4.0.1. A new front-end for the C family of
languages is in development. The compiler infrastructure includes mirror sets languages is in development. The compiler infrastructure includes mirror sets
of programming tools as well as libraries with equivalent functionality.") of programming tools as well as libraries with equivalent functionality.")
(license license:asl2.0) (license license:asl2.0)
(properties `((release-monitoring-url . ,%llvm-release-monitoring-url))))) (properties `((release-monitoring-url . ,%llvm-release-monitoring-url))))))
(define-public llvm-15
(make-llvm "15.0.7"))
(define-public llvm-14 (define-public llvm-14
(package (package