[PATCH 0/3] Add LLVM/Clang 15.0.4.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
M
M
Maxim Cournoyer wrote on 13 Nov 2022 05:53
(address . guix-patches@gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20221113045354.26955-1-maxim.cournoyer@gmail.com
Hi Guix,

This adds the latest clang, build with the supported configuration for a
shared library (DYLIB), and with some size reduction via stripping static
archives where possible.

Maxim Cournoyer (3):
gnu: Add llvm-15.
gnu: Add clang-runtime-15.
gnu: Add clang-15.

gnu/local.mk | 1 +
gnu/packages/llvm.scm | 153 +++++++++++++++++-
.../patches/clang-15.0-libc-search-path.patch | 95 +++++++++++
3 files changed, 247 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/clang-15.0-libc-search-path.patch

--
2.38.1
M
M
Maxim Cournoyer wrote on 13 Nov 2022 06:01
[PATCH 1/3] gnu: Add llvm-15.
(address . 59237@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20221113050200.27277-1-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (llvm-15): New variable.
* gnu/packages/patches/clang-15.0-libc-search-path.patch: New file.
* gnu/local.mk: Register it.
---
gnu/local.mk | 1 +
gnu/packages/llvm.scm | 69 +++++++++++++-
.../patches/clang-15.0-libc-search-path.patch | 95 +++++++++++++++++++
3 files changed, 163 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/clang-15.0-libc-search-path.patch

Toggle diff (204 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index e3e02314bb..6b6ada17a5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -976,6 +976,7 @@ dist_patch_DATA = \
%D%/packages/patches/clang-12.0-libc-search-path.patch \
%D%/packages/patches/clang-13.0-libc-search-path.patch \
%D%/packages/patches/clang-14.0-libc-search-path.patch \
+ %D%/packages/patches/clang-15.0-libc-search-path.patch \
%D%/packages/patches/clang-runtime-asan-build-fixes.patch \
%D%/packages/patches/clang-runtime-esan-build-fixes.patch \
%D%/packages/patches/clang-runtime-9-libsanitizer-mode-field.patch \
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 324149116b..0a35aed7c6 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -545,10 +545,12 @@ (define (make-clang-toolchain clang libomp)
("libc-static" ,glibc "static")))))
(define %llvm-monorepo-hashes
- '(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")))
+ '(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")
+ ("15.0.4" . "0j5kx4s970qzcjr83kk6776zzjqfshl61x9fagqz8kjxcjbpg8cj")))
(define %llvm-patches
- '(("14.0.6" . ("clang-14.0-libc-search-path.patch"))))
+ '(("14.0.6" . ("clang-14.0-libc-search-path.patch"))
+ ("15.0.4" . ("clang-15.0-libc-search-path.patch"))))
(define (llvm-monorepo version)
(origin
@@ -560,6 +562,69 @@ (define (llvm-monorepo version)
(sha256 (base32 (assoc-ref %llvm-monorepo-hashes version)))
(patches (map search-patch (assoc-ref %llvm-patches version)))))
+;;; TODO: Make the base llvm all other LLVM inherit from on core-updates.
+(define-public llvm-15
+ (package
+ (name "llvm")
+ (version "15.0.4")
+ (source (llvm-monorepo version))
+ (build-system cmake-build-system)
+ (outputs '("out" "opt-viewer"))
+ (arguments
+ (list
+ #:configure-flags
+ #~(list
+ ;; 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)))
+ '())
+ ;; Note: sadly, the build system refuses the use of
+ ;; -DBUILD_SHARED_LIBS=ON and the large static archives are needed to
+ ;; build clang-runtime, so we cannot delete them.
+ "-DLLVM_BUILD_LLVM_DYLIB=ON"
+ "-DLLVM_LINK_LLVM_DYLIB=ON"
+ "-DLLVM_ENABLE_FFI=ON"
+ "-DLLVM_ENABLE_RTTI=ON" ;for some third-party utilities
+ "-DLLVM_INSTALL_UTILS=ON" ;needed for rustc
+ "-DLLVM_PARALLEL_LINK_JOBS=1") ;cater to smaller build machines
+ ;; Don't use '-g' during the build, to save space.
+ #:build-type "Release"
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "llvm")))
+ (add-after 'install 'install-opt-viewer
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((opt-viewer-share (string-append #$output:opt-viewer
+ "/share")))
+ (mkdir-p opt-viewer-share)
+ (rename-file (string-append #$output "/share/opt-viewer")
+ opt-viewer-share)))))))
+ (native-inputs (list python-wrapper perl))
+ (inputs (list libffi))
+ (propagated-inputs (list zlib)) ;to use output from llvm-config
+ (home-page "https://www.llvm.org")
+ (synopsis "Optimizing compiler infrastructure")
+ (description
+ "LLVM is a compiler infrastructure designed for compile-time, link-time,
+runtime, and idle-time optimization of programs from arbitrary programming
+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
+languages is in development. The compiler infrastructure includes mirror sets
+of programming tools as well as libraries with equivalent functionality.")
+ (license license:asl2.0)
+ (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
+
(define-public llvm-14
(package
(name "llvm")
diff --git a/gnu/packages/patches/clang-15.0-libc-search-path.patch b/gnu/packages/patches/clang-15.0-libc-search-path.patch
new file mode 100644
index 0000000000..20726859b2
--- /dev/null
+++ b/gnu/packages/patches/clang-15.0-libc-search-path.patch
@@ -0,0 +1,95 @@
+Clang attempts to guess file names based on the OS and distro (yes!),
+but unfortunately, that doesn't work for us.
+
+This patch makes it easy to insert libc's $libdir so that Clang passes the
+correct absolute file name of crt1.o etc. to 'ld'. It also disables all
+the distro-specific stuff and removes the hard-coded FHS directory names
+to make sure Clang also works on foreign distros.
+
+diff --git a/clang/lib/Driver/Distro.cpp b/clang/libDriver/Distro.cpp
+index 1898667..35de813 100644
+--- a/clang/lib/Driver/Distro.cpp
++++ b/clang/libDriver/Distro.cpp
+@@ -97,6 +97,10 @@ static Distro::DistroType DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
+ }
+
+ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
++ // The compiler should always behave the same, even when used via Guix on a
++ // foreign distro.
++ return Distro::UnknownDistro;
++
+ Distro::DistroType Version = Distro::UnknownDistro;
+
+ // Newer freedesktop.org's compilant systemd-based systems
+diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/libDriver/ToolChains/Cuda.cpp
+index 7ad990d..e4da4d4 100644
+--- a/clang/lib/Driver/ToolChains/Cuda.cpp
++++ b/clang/libDriver/ToolChains/Cuda.cpp
+@@ -117,6 +117,9 @@ CudaInstallationDetector::CudaInstallationDetector(
+ const Driver &D, const llvm::Triple &HostTriple,
+ const llvm::opt::ArgList &Args)
+ : D(D) {
++ // Don't look for CUDA in /usr.
++ return;
++
+ struct Candidate {
+ std::string Path;
+ bool StrictChecking;
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/libDriver/ToolChains/Linux.cpp
+index ceb1a98..9d7a14a 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/libDriver/ToolChains/Linux.cpp
+@@ -188,6 +188,10 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ Generic_GCC::PushPPaths(PPaths);
+
++ // Comment out the distro-specific tweaks so that they don't bite when
++ // using Guix on a foreign distro.
++#if 0
++
+ Distro Distro(D.getVFS(), Triple);
+
+ if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
+@@ -256,6 +260,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ if (IsAndroid || Distro.IsOpenSUSE())
+ ExtraOpts.push_back("--enable-new-dtags");
++#endif
+
+ // The selection of paths to try here is designed to match the patterns which
+ // the GCC driver itself uses, as this is part of the GCC-compatible driver.
+@@ -276,6 +281,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+ }
+ Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
+
++#if 0
+ addPathIfExists(D, concat(SysRoot, "/lib", MultiarchTriple), Paths);
+ addPathIfExists(D, concat(SysRoot, "/lib/..", OSLibDir), Paths);
+
+@@ -304,9 +310,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+ addPathIfExists(D, concat(SysRoot, "/", OSLibDir, ABIName), Paths);
+ addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir, ABIName), Paths);
+ }
++#endif
+
+ Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
+
++#if 0
+ // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
+ // libc++.so in D.Dir+"/../lib/". Detect this path.
+ // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
+@@ -316,6 +324,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
+ addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
++#endif
++
++ // Add libc's lib/ directory to the search path, so that crt1.o, crti.o,
++ // and friends can be found.
++ addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
++
++ // Add GCC's lib/ directory so libstdc++.so can be found.
++ addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths);
+ }
+
+ ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
--
2.38.1
M
M
Maxim Cournoyer wrote on 13 Nov 2022 06:01
[PATCH 2/3] gnu: Add clang-runtime-15.
(address . 59237@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20221113050200.27277-2-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (clang-runtime-15): New variable.
---
gnu/packages/llvm.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (36 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 0a35aed7c6..d7b6207dc4 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -690,6 +690,29 @@ (define-public llvm-14
(license license:asl2.0)
(properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
+(define-public clang-runtime-15
+ (let ((template (clang-runtime-from-llvm llvm-15)))
+ (package
+ (inherit template)
+ (arguments
+ (substitute-keyword-arguments (package-arguments template)
+ ((#:phases phases '(@ (guix build cmake-build-system) %standard-phases))
+ #~(modify-phases #$phases
+ (add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "compiler-rt")))
+ (add-after 'install 'delete-static-libraries
+ ;; Reduce size from 33 MiB to 7.4 MiB.
+ (lambda _
+ (for-each delete-file
+ (find-files #$output "\\.a(\\.syms)?$"))))))))
+ (native-inputs
+ (modify-inputs (package-native-inputs template)
+ (prepend gcc-12))) ;libfuzzer fails to build with GCC 11
+ (inputs
+ (modify-inputs (package-inputs template)
+ (append libffi))))))
+
(define-public clang-runtime-14
(let ((template (clang-runtime-from-llvm llvm-14)))
(package
--
2.38.1
M
M
Maxim Cournoyer wrote on 13 Nov 2022 06:02
[PATCH 3/3] gnu: Add clang-15.
(address . 59237@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20221113050200.27277-3-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (clang-from-llvm*): New helper.
(clang-15): New variable.
---
gnu/packages/llvm.scm | 61 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)

Toggle diff (81 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index d7b6207dc4..12e1e642c6 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -422,6 +422,43 @@ (define* (clang-from-llvm llvm clang-runtime
license:asl2.0 ;with LLVM exceptions
license:ncsa))))
+;;; TODO: Integrate into original on core-updates, perhaps with an extra
+;;; option such as #:build-shared-libs? documented as a legacy feature.
+(define* (clang-from-llvm* llvm clang-runtime
+ #:optional hash
+ #:key (patches '()) tools-extra
+ (properties
+ (append `((release-monitoring-url
+ . ,%llvm-release-monitoring-url))
+ (clang-properties (package-version llvm)))))
+ "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
+given PATCHES. When TOOLS-EXTRA is given, it must point to the
+'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
+'modularize', and other tools."
+ (let ((base (clang-from-llvm llvm clang-runtime hash
+ #:patches patches #:tools-extra tools-extra
+ #:properties properties)))
+ (package
+ (inherit base)
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:phases phases ''%standard-phases)
+ #~(modify-phases #$phases
+ ;; Like the original, sans BUILD_SHARED_LIBS patching.
+ #$@(if tools-extra
+ #~((replace 'add-tools-extra
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Unpack the 'clang-tools-extra' tarball under
+ ;; tools/.
+ (let ((extra (assoc-ref inputs "clang-tools-extra")))
+ (invoke "tar" "xf" extra)
+ (rename-file #$(string-append
+ "clang-tools-extra-"
+ (string-delete #\- (package-version llvm))
+ ".src")
+ "tools/extra")))))
+ #~()))))))))
+
(define (clang-properties version)
"Return package properties for Clang VERSION."
`((compiler-cpu-architectures
@@ -729,6 +766,30 @@ (define-public clang-runtime-14
("gcc" ,gcc-11)
,@(package-native-inputs template))))))
+(define-public clang-15
+ (let ((template
+ (clang-from-llvm*
+ llvm-15 clang-runtime-15
+ #:tools-extra
+ (origin
+ (method url-fetch)
+ (uri (llvm-uri "clang-tools-extra"
+ (package-version llvm-15)))
+ (sha256
+ (base32
+ "03adxlh84if9p53m6izjsql500rjza9rng8akab2pdqibgrg73rh"))))))
+ (package
+ (inherit template)
+ (arguments
+ (substitute-keyword-arguments (package-arguments template)
+ ((#:configure-flags flags ''())
+ #~(cons "-DCLANG_LINK_CLANG_DYLIB=ON" #$flags))
+ ((#:phases phases '%standard-phases)
+ #~(modify-phases #$phases
+ (add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "clang"))))))))))
+
(define-public clang-14
(let ((template
(clang-from-llvm llvm-14 clang-runtime-14
--
2.38.1
L
L
Ludovic Courtès wrote on 15 Nov 2022 11:28
Re: bug#59237: [PATCH 0/3] Add LLVM/Clang 15.0.4.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
877czwo6k5.fsf_-_@gnu.org
Hi!

(Cc: Greg, who often takes care of those updates.)

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (6 lines)
> +;;; TODO: Make the base llvm all other LLVM inherit from on core-updates.
> +(define-public llvm-15
> + (package
> + (name "llvm")
> + (version "15.0.4")

Can we have ‘llvm-14’ inherit from this one, just so we don’t duplicate
‘synopsis’, etc.? (It overrides ‘arguments’, ‘inputs’, and all that
anyway so that should be transparent.)

Otherwise LGTM.

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 15 Nov 2022 11:33
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 59237@debbugs.gnu.org)
8735ako6bx.fsf_-_@gnu.org
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (3 lines)
> * gnu/packages/llvm.scm (clang-from-llvm*): New helper.
> (clang-15): New variable.

[...]

Toggle quote (10 lines)
> +;;; TODO: Integrate into original on core-updates, perhaps with an extra
> +;;; option such as #:build-shared-libs? documented as a legacy feature.
> +(define* (clang-from-llvm* llvm clang-runtime
> + #:optional hash
> + #:key (patches '()) tools-extra
> + (properties
> + (append `((release-monitoring-url
> + . ,%llvm-release-monitoring-url))
> + (clang-properties (package-version llvm)))))

[...]

Toggle quote (4 lines)
> + #~(modify-phases #$phases
> + ;; Like the original, sans BUILD_SHARED_LIBS patching.
> + #$@(if tools-extra

How about making it an option of ‘clang-from-llvm’ then, like suggested
above?

In ‘clang-from-llvm’, we’d have:

`((add-after 'unpack 'add-tools-extra
(lambda* …
,@(if tools-need-build-shared-libs-patch?
`((substitute* …))
'()
#t))))

That’d factorize things while avoiding a full rebuild.

Ludo’.
L
L
Ludovic Courtès wrote on 15 Nov 2022 11:34
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87y1scmrp6.fsf_-_@gnu.org
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (3 lines)
> * gnu/packages/llvm.scm (clang-from-llvm*): New helper.
> (clang-15): New variable.

I believe we’ll also need ‘libomp-15’ as discussed at

Ludo’.
M
M
Maxim Cournoyer wrote on 16 Nov 2022 15:18
[PATCH v2 0/5] Add LLVM/Clang 15.
(address . 59237@debbugs.gnu.org)
20221116141830.12398-1-maxim.cournoyer@gmail.com
This v2 series includes the following changes the following changes, based on
Ludovic's review:

* Reduce code duplication via conditional changes to the the clang-from-llvm
template procedure and inheritance.
* Add a libomp-15 package.
* Add a clang-toolchain-15 package.

Thanks!

Maxim Cournoyer (5):
gnu: Add llvm-15.
gnu: Add clang-runtime-15.
gnu: Add clang-15.
gnu: Add libomp-15.
gnu: Add clang-toolchain-15.

gnu/local.mk | 1 +
gnu/packages/llvm.scm | 288 +++++++++++++-----
.../patches/clang-15.0-libc-search-path.patch | 95 ++++++
3 files changed, 303 insertions(+), 81 deletions(-)
create mode 100644 gnu/packages/patches/clang-15.0-libc-search-path.patch


base-commit: 5512915c3bd62e061bd47d440da02e0826c1d0e7
--
2.38.1
M
M
Maxim Cournoyer wrote on 16 Nov 2022 15:18
[PATCH v2 1/5] gnu: Add llvm-15.
(address . 59237@debbugs.gnu.org)
20221116141830.12398-2-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (llvm-15): New variable.
(llvm-14): Inherit from it, removing duplicated fields.
* gnu/packages/patches/clang-15.0-libc-search-path.patch: New file.
* gnu/local.mk: Register it.
---
gnu/local.mk | 1 +
gnu/packages/llvm.scm | 93 +++++++++++++-----
.../patches/clang-15.0-libc-search-path.patch | 95 +++++++++++++++++++
3 files changed, 167 insertions(+), 22 deletions(-)
create mode 100644 gnu/packages/patches/clang-15.0-libc-search-path.patch

Toggle diff (240 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 71472f8410..4fcaa6801a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -977,6 +977,7 @@ dist_patch_DATA = \
%D%/packages/patches/clang-12.0-libc-search-path.patch \
%D%/packages/patches/clang-13.0-libc-search-path.patch \
%D%/packages/patches/clang-14.0-libc-search-path.patch \
+ %D%/packages/patches/clang-15.0-libc-search-path.patch \
%D%/packages/patches/clang-runtime-asan-build-fixes.patch \
%D%/packages/patches/clang-runtime-esan-build-fixes.patch \
%D%/packages/patches/clang-runtime-9-libsanitizer-mode-field.patch \
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 324149116b..5a64c712af 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -545,10 +545,12 @@ (define (make-clang-toolchain clang libomp)
("libc-static" ,glibc "static")))))
(define %llvm-monorepo-hashes
- '(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")))
+ '(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")
+ ("15.0.4" . "0j5kx4s970qzcjr83kk6776zzjqfshl61x9fagqz8kjxcjbpg8cj")))
(define %llvm-patches
- '(("14.0.6" . ("clang-14.0-libc-search-path.patch"))))
+ '(("14.0.6" . ("clang-14.0-libc-search-path.patch"))
+ ("15.0.4" . ("clang-15.0-libc-search-path.patch"))))
(define (llvm-monorepo version)
(origin
@@ -560,20 +562,74 @@ (define (llvm-monorepo version)
(sha256 (base32 (assoc-ref %llvm-monorepo-hashes version)))
(patches (map search-patch (assoc-ref %llvm-patches version)))))
-(define-public llvm-14
+;;; TODO: Make the base llvm all other LLVM inherit from on core-updates.
+(define-public llvm-15
(package
(name "llvm")
- (version "14.0.6")
+ (version "15.0.4")
(source (llvm-monorepo version))
(build-system cmake-build-system)
(outputs '("out" "opt-viewer"))
- (native-inputs
- `(("python" ,python-wrapper)
- ("perl" ,perl)))
- (inputs
- (list libffi))
- (propagated-inputs
- (list zlib)) ;to use output from llvm-config
+ (arguments
+ (list
+ #:configure-flags
+ #~(list
+ ;; 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)))
+ '())
+ ;; Note: sadly, the build system refuses the use of
+ ;; -DBUILD_SHARED_LIBS=ON and the large static archives are needed to
+ ;; build clang-runtime, so we cannot delete them.
+ "-DLLVM_BUILD_LLVM_DYLIB=ON"
+ "-DLLVM_LINK_LLVM_DYLIB=ON"
+ "-DLLVM_ENABLE_FFI=ON"
+ "-DLLVM_ENABLE_RTTI=ON" ;for some third-party utilities
+ "-DLLVM_INSTALL_UTILS=ON" ;needed for rustc
+ "-DLLVM_PARALLEL_LINK_JOBS=1") ;cater to smaller build machines
+ ;; Don't use '-g' during the build, to save space.
+ #:build-type "Release"
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "llvm")))
+ (add-after 'install 'install-opt-viewer
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((opt-viewer-share (string-append #$output:opt-viewer
+ "/share")))
+ (mkdir-p opt-viewer-share)
+ (rename-file (string-append #$output "/share/opt-viewer")
+ opt-viewer-share)))))))
+ (native-inputs (list python-wrapper perl))
+ (inputs (list libffi))
+ (propagated-inputs (list zlib)) ;to use output from llvm-config
+ (home-page "https://www.llvm.org")
+ (synopsis "Optimizing compiler infrastructure")
+ (description
+ "LLVM is a compiler infrastructure designed for compile-time, link-time,
+runtime, and idle-time optimization of programs from arbitrary programming
+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
+languages is in development. The compiler infrastructure includes mirror sets
+of programming tools as well as libraries with equivalent functionality.")
+ (license license:asl2.0)
+ (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
+
+(define-public llvm-14
+ (package
+ (inherit llvm-15)
+ (version "14.0.6")
+ (source (llvm-monorepo version))
(arguments
(list
#:configure-flags
@@ -613,17 +669,10 @@ (define-public llvm-14
(mkdir-p opt-viewer-share-dir)
(rename-file (string-append out "/share/opt-viewer")
opt-viewer-dir)))))))
- (home-page "https://www.llvm.org")
- (synopsis "Optimizing compiler infrastructure")
- (description
- "LLVM is a compiler infrastructure designed for compile-time, link-time,
-runtime, and idle-time optimization of programs from arbitrary programming
-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
-languages is in development. The compiler infrastructure includes mirror sets
-of programming tools as well as libraries with equivalent functionality.")
- (license license:asl2.0)
- (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
+
+ (native-inputs
+ `(("python" ,python-wrapper)
+ ("perl" ,perl)))))
(define-public clang-runtime-14
(let ((template (clang-runtime-from-llvm llvm-14)))
diff --git a/gnu/packages/patches/clang-15.0-libc-search-path.patch b/gnu/packages/patches/clang-15.0-libc-search-path.patch
new file mode 100644
index 0000000000..20726859b2
--- /dev/null
+++ b/gnu/packages/patches/clang-15.0-libc-search-path.patch
@@ -0,0 +1,95 @@
+Clang attempts to guess file names based on the OS and distro (yes!),
+but unfortunately, that doesn't work for us.
+
+This patch makes it easy to insert libc's $libdir so that Clang passes the
+correct absolute file name of crt1.o etc. to 'ld'. It also disables all
+the distro-specific stuff and removes the hard-coded FHS directory names
+to make sure Clang also works on foreign distros.
+
+diff --git a/clang/lib/Driver/Distro.cpp b/clang/libDriver/Distro.cpp
+index 1898667..35de813 100644
+--- a/clang/lib/Driver/Distro.cpp
++++ b/clang/libDriver/Distro.cpp
+@@ -97,6 +97,10 @@ static Distro::DistroType DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
+ }
+
+ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
++ // The compiler should always behave the same, even when used via Guix on a
++ // foreign distro.
++ return Distro::UnknownDistro;
++
+ Distro::DistroType Version = Distro::UnknownDistro;
+
+ // Newer freedesktop.org's compilant systemd-based systems
+diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/libDriver/ToolChains/Cuda.cpp
+index 7ad990d..e4da4d4 100644
+--- a/clang/lib/Driver/ToolChains/Cuda.cpp
++++ b/clang/libDriver/ToolChains/Cuda.cpp
+@@ -117,6 +117,9 @@ CudaInstallationDetector::CudaInstallationDetector(
+ const Driver &D, const llvm::Triple &HostTriple,
+ const llvm::opt::ArgList &Args)
+ : D(D) {
++ // Don't look for CUDA in /usr.
++ return;
++
+ struct Candidate {
+ std::string Path;
+ bool StrictChecking;
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/libDriver/ToolChains/Linux.cpp
+index ceb1a98..9d7a14a 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/libDriver/ToolChains/Linux.cpp
+@@ -188,6 +188,10 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ Generic_GCC::PushPPaths(PPaths);
+
++ // Comment out the distro-specific tweaks so that they don't bite when
++ // using Guix on a foreign distro.
++#if 0
++
+ Distro Distro(D.getVFS(), Triple);
+
+ if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
+@@ -256,6 +260,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ if (IsAndroid || Distro.IsOpenSUSE())
+ ExtraOpts.push_back("--enable-new-dtags");
++#endif
+
+ // The selection of paths to try here is designed to match the patterns which
+ // the GCC driver itself uses, as this is part of the GCC-compatible driver.
+@@ -276,6 +281,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+ }
+ Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
+
++#if 0
+ addPathIfExists(D, concat(SysRoot, "/lib", MultiarchTriple), Paths);
+ addPathIfExists(D, concat(SysRoot, "/lib/..", OSLibDir), Paths);
+
+@@ -304,9 +310,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+ addPathIfExists(D, concat(SysRoot, "/", OSLibDir, ABIName), Paths);
+ addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir, ABIName), Paths);
+ }
++#endif
+
+ Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
+
++#if 0
+ // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
+ // libc++.so in D.Dir+"/../lib/". Detect this path.
+ // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
+@@ -316,6 +324,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
+ addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
++#endif
++
++ // Add libc's lib/ directory to the search path, so that crt1.o, crti.o,
++ // and friends can be found.
++ addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
++
++ // Add GCC's lib/ directory so libstdc++.so can be found.
++ addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths);
+ }
+
+ ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
--
2.38.1
M
M
Maxim Cournoyer wrote on 16 Nov 2022 15:18
[PATCH v2 2/5] gnu: Add clang-runtime-15.
(address . 59237@debbugs.gnu.org)
20221116141830.12398-3-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (clang-runtime-15): New variable.
---
gnu/packages/llvm.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (36 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 5a64c712af..9f4f64e0d0 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -674,6 +674,29 @@ (define-public llvm-14
`(("python" ,python-wrapper)
("perl" ,perl)))))
+(define-public clang-runtime-15
+ (let ((template (clang-runtime-from-llvm llvm-15)))
+ (package
+ (inherit template)
+ (arguments
+ (substitute-keyword-arguments (package-arguments template)
+ ((#:phases phases '(@ (guix build cmake-build-system) %standard-phases))
+ #~(modify-phases #$phases
+ (add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "compiler-rt")))
+ (add-after 'install 'delete-static-libraries
+ ;; Reduce size from 33 MiB to 7.4 MiB.
+ (lambda _
+ (for-each delete-file
+ (find-files #$output "\\.a(\\.syms)?$"))))))))
+ (native-inputs
+ (modify-inputs (package-native-inputs template)
+ (prepend gcc-12))) ;libfuzzer fails to build with GCC 11
+ (inputs
+ (modify-inputs (package-inputs template)
+ (append libffi))))))
+
(define-public clang-runtime-14
(let ((template (clang-runtime-from-llvm llvm-14)))
(package
--
2.38.1
M
M
Maxim Cournoyer wrote on 16 Nov 2022 15:18
[PATCH v2 3/5] gnu: Add clang-15.
(address . 59237@debbugs.gnu.org)
20221116141830.12398-4-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (clang-from-llvm): Add LEGACY-BUILD-SHARED-LIBS?
argument and update doc.
[configure-flags]: Conditionally add -DCLANG_LINK_CLANG_DYLIB=ON.
[phases]{change-directory}: Conditionally add phase.
{add-tools-extra}: Conditionally patch AddClang.cmake file.
(clang-15): New variable.
(clang-14): Streamline.
(clang-13, clang-12, clang-11, clang-10, clang-9, clang-8, clang-7, clang-6)
(clang-3.9.1, clang-3.8, clang-3.7, clang-3.5): Set LEGACY-BUILD-SHARED-LIBS?
argument to #t.
---
gnu/packages/llvm.scm | 96 +++++++++++++++++++++++++++++--------------
1 file changed, 65 insertions(+), 31 deletions(-)

Toggle diff (232 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 9f4f64e0d0..2b958b060e 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -176,11 +176,14 @@ (define* (clang-from-llvm llvm clang-runtime
(properties
(append `((release-monitoring-url
. ,%llvm-release-monitoring-url))
- (clang-properties (package-version llvm)))))
+ (clang-properties (package-version llvm))))
+ (legacy-build-shared-libs? #f))
"Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
given PATCHES. When TOOLS-EXTRA is given, it must point to the
'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
-'modularize', and other tools."
+'modularize', and other tools. LEGACY-BUILD-SHARED-LIBS? is used to configure
+the package to use the legacy BUILD_SHARED_LIBS CMake option, which was used
+until LLVM/Clang 14."
(package
(name "clang")
(version (package-version llvm))
@@ -221,14 +224,17 @@ (define* (clang-from-llvm llvm clang-runtime
(string-append "-DC_INCLUDE_DIRS="
(assoc-ref %build-inputs "libc")
"/include")
- ,@(if (target-riscv64?)
- (list "-DLIBOMP_LIBFLAGS=-latomic"
- "-DCMAKE_SHARED_LINKER_FLAGS=-latomic")
- `()))
+ ,@(if (target-riscv64?)
+ (list "-DLIBOMP_LIBFLAGS=-latomic"
+ "-DCMAKE_SHARED_LINKER_FLAGS=-latomic")
+ `())
+ ,@(if legacy-build-shared-libs?
+ '()
+ (list "-DCLANG_LINK_CLANG_DYLIB=ON")))
,@(if (target-riscv64?)
- `(#:make-flags '("LDFLAGS=-latomic"))
- '())
+ `(#:make-flags '("LDFLAGS=-latomic"))
+ '())
;; Don't use '-g' during the build to save space.
#:build-type "Release"
@@ -247,9 +253,11 @@ (define* (clang-from-llvm llvm clang-runtime
(string-delete #\- (package-version llvm))
".src")
"tools/extra")
- ;; Build and link to shared libraries.
- (substitute* "cmake/modules/AddClang.cmake"
- (("BUILD_SHARED_LIBS") "True"))
+ ,@(if legacy-build-shared-libs?
+ ;; Build and link to shared libraries.
+ '((substitute* "cmake/modules/AddClang.cmake"
+ (("BUILD_SHARED_LIBS") "True")))
+ '())
#t))))
'())
(add-after 'unpack 'add-missing-triplets
@@ -323,6 +331,15 @@ (define* (clang-from-llvm llvm clang-runtime
(("@GLIBC_LIBDIR@")
(string-append libc "/lib"))))))
#t)))
+ ;; Awkwardly, multiple phases added after the same phase,
+ ;; e.g. unpack, get applied in the reverse order. In other
+ ;; words, adding 'change-directory last means it occurs
+ ;; first after the unpack phase.
+ ,@(if (version>=? version "14")
+ '((add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "clang"))))
+ '())
,@(if (version>=? version "10")
`((add-after 'install 'adjust-cmake-file
(lambda* (#:key outputs #:allow-other-keys)
@@ -713,26 +730,31 @@ (define-public clang-runtime-14
("gcc" ,gcc-11)
,@(package-native-inputs template))))))
+(define-public clang-15
+ (clang-from-llvm
+ llvm-15 clang-runtime-15
+ #:tools-extra
+ (origin
+ (method url-fetch)
+ (uri (llvm-uri "clang-tools-extra"
+ (package-version llvm-15)))
+ (sha256
+ (base32
+ "03adxlh84if9p53m6izjsql500rjza9rng8akab2pdqibgrg73rh")))))
+
(define-public clang-14
- (let ((template
- (clang-from-llvm llvm-14 clang-runtime-14
- #:tools-extra
- (origin
- (method url-fetch)
- (uri (llvm-uri "clang-tools-extra"
- (package-version llvm-14)))
- (sha256
- (base32
- "0rhq4wkmvr369nkk059skzzw7jx6qhzqhmiwmqg4sp66avzviwvw"))))))
- (package
- (inherit template)
- (arguments
- (substitute-keyword-arguments (package-arguments template)
- ((#:phases phases '(@ (guix build cmake-build-system) %standard-phases))
- #~(modify-phases #$phases
- (add-after 'unpack 'change-directory
- (lambda _
- (chdir "clang"))))))))))
+ (clang-from-llvm
+ llvm-14 clang-runtime-14
+ #:legacy-build-shared-libs? #t
+ #:tools-extra
+ (origin
+ (method url-fetch)
+ (uri (llvm-uri "clang-tools-extra"
+ (package-version llvm-14)))
+ (sha256
+ (base32
+ "0rhq4wkmvr369nkk059skzzw7jx6qhzqhmiwmqg4sp66avzviwvw")))))
+
(define-public libomp-14
(package
@@ -805,6 +827,7 @@ (define-public clang-runtime-13
(define-public clang-13
(clang-from-llvm llvm-13 clang-runtime-13
"1j8pr5kk8iqyb4jds3yl7c6x672617h4ngkpl4575j7mk4nrwykq"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-13.0-libc-search-path.patch")
#:tools-extra
(origin
@@ -919,6 +942,7 @@ (define-public clang-runtime-12
(define-public clang-12
(clang-from-llvm llvm-12 clang-runtime-12
"0px4gl27az6cdz6adds89qzdwb1cqpjsfvrldbz9qvpmphrj34bf"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-12.0-libc-search-path.patch")
#:tools-extra
(origin
@@ -973,6 +997,7 @@ (define-public clang-runtime-11
(define-public clang-11
(clang-from-llvm llvm-11 clang-runtime-11
"02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-11.0-libc-search-path.patch")
#:tools-extra
(origin
@@ -1029,12 +1054,13 @@ (define-public clang-runtime-10
(define-public clang-10
(clang-from-llvm llvm-10 clang-runtime-10
"091bvcny2lh32zy8f3m9viayyhb2zannrndni7325rl85cwgr6pr"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-10.0-libc-search-path.patch")
#:tools-extra
(origin
(method url-fetch)
(uri (llvm-uri "clang-tools-extra"
- (package-version llvm-10)))
+ (package-version llvm-10)))
(sha256
(base32
"06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh")))))
@@ -1098,6 +1124,7 @@ (define-public clang-runtime-9
(define-public clang-9
(clang-from-llvm llvm-9 clang-runtime-9
"0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-9.0-libc-search-path.patch")))
(define-public libomp-9
@@ -1141,6 +1168,7 @@ (define-public clang-runtime-8
(define-public clang-8
(clang-from-llvm llvm-8 clang-runtime-8
"0ihnbdl058gvl2wdy45p5am55bq8ifx8m9mhcsgj9ax8yxlzvvvh"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-8.0-libc-search-path.patch")))
(define-public libomp-8
@@ -1183,6 +1211,7 @@ (define-public clang-runtime-7
(define-public clang-7
(clang-from-llvm llvm-7 clang-runtime-7
"0vc4i87qwxnw9lci4ayws9spakg0z6w5w670snj9f8g5m9rc8zg9"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-7.0-libc-search-path.patch")))
(define-public libomp-7
@@ -1224,6 +1253,7 @@ (define-public clang-runtime-6
(define-public clang-6
(clang-from-llvm llvm-6 clang-runtime-6
"0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-6.0-libc-search-path.patch")))
(define-public libomp-6
@@ -1285,6 +1315,7 @@ (define-public clang-runtime-3.9.1
(define-public clang-3.9.1
(clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
"0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-3.8-libc-search-path.patch")))
(define-public llvm-3.8
@@ -1311,6 +1342,7 @@ (define-public clang-runtime-3.8
(define-public clang-3.8
(clang-from-llvm llvm-3.8 clang-runtime-3.8
"1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-3.8-libc-search-path.patch")))
(define-public llvm-3.7
@@ -1337,6 +1369,7 @@ (define-public clang-runtime-3.7
(define-public clang-3.7
(clang-from-llvm llvm-3.7 clang-runtime-3.7
"0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-3.5-libc-search-path.patch")))
(define-public llvm-3.6
@@ -1396,6 +1429,7 @@ (define-public clang-runtime-3.5
(define-public clang-3.5
(clang-from-llvm llvm-3.5 clang-runtime-3.5
"0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
+ #:legacy-build-shared-libs? #t
#:patches '("clang-3.5-libc-search-path.patch")))
;; Default LLVM and Clang version.
--
2.38.1
M
M
Maxim Cournoyer wrote on 16 Nov 2022 15:18
[PATCH v2 4/5] gnu: Add libomp-15.
(address . 59237@debbugs.gnu.org)
20221116141830.12398-5-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (libomp-15): New variable.
(libomp-14): Inherit from it.
[arguments]: Use substitute-keyword-arguments and override the
chdir-to-source-and-install-license phase. Remove redundant fields.
---
gnu/packages/llvm.scm | 75 ++++++++++++++++++++++++++-----------------
1 file changed, 46 insertions(+), 29 deletions(-)

Toggle diff (100 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 2b958b060e..528c2bc359 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -755,10 +755,44 @@ (define-public clang-14
(base32
"0rhq4wkmvr369nkk059skzzw7jx6qhzqhmiwmqg4sp66avzviwvw")))))
+(define-public libomp-15
+ (package
+ (name "libomp")
+ (version (package-version llvm-15))
+ (source (llvm-monorepo version))
+ (build-system cmake-build-system)
+ ;; XXX: Note this gets built with GCC because building with Clang itself
+ ;; fails (missing <atomic>, even when libcxx is added as an input.)
+ (arguments
+ (list
+ #:configure-flags
+ #~(list "-DLIBOMP_USE_HWLOC=ON"
+ "-DOPENMP_TEST_C_COMPILER=clang"
+ "-DOPENMP_TEST_CXX_COMPILER=clang++")
+ #:test-target "check-libomp"
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'chdir-to-source-and-install-license
+ (lambda _
+ (chdir "openmp")
+ (install-file "LICENSE.TXT"
+ (string-append #$output "/share/doc")))))))
+ (native-inputs (list clang-15 llvm-15 perl pkg-config python))
+ (inputs (list `(,hwloc "lib")))
+ (home-page "https://openmp.llvm.org")
+ (synopsis "OpenMP run-time support library")
+ (description "This package provides the run-time support library developed
+by the LLVM project for the OpenMP multi-theaded programming extension. This
+package notably provides @file{libgomp.so}, which is has a binary interface
+compatible with that of libgomp, the GNU Offloading and Multi Processing
+Library.")
+ (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)
+ (upstream-name . "openmp")))
+ (license license:expat)))
(define-public libomp-14
(package
- (name "libomp")
+ (inherit libomp-15)
(version (package-version llvm-14))
(source (origin
(method url-fetch)
@@ -767,36 +801,19 @@ (define-public libomp-14
(base32
"07zby3gwy5c8jssabrhjk3nsxlwipnm6sk4dsvck1l5d0br1ywsg"))
(file-name (string-append "libomp-" version ".tar.xz"))))
- (build-system cmake-build-system)
- ;; XXX: Note this gets built with GCC because building with Clang itself
- ;; fails (missing <atomic>, even when libcxx is added as an input.)
(arguments
- (list
- #:configure-flags #~(list "-DLIBOMP_USE_HWLOC=ON"
- "-DOPENMP_TEST_C_COMPILER=clang"
- "-DOPENMP_TEST_CXX_COMPILER=clang++")
- #:test-target "check-libomp"
- #:phases
- #~(modify-phases %standard-phases
- (add-after 'unpack 'chdir-to-source-and-install-license
- (lambda _
- (chdir #$(string-append "../openmp-" version ".src"))
- (install-file "LICENSE.TXT"
- (string-append #$output "/share/doc")))))))
+ (substitute-keyword-arguments (package-arguments libomp-15)
+ ((#:phases phases)
+ #~(modify-phases #$phases
+ (replace 'chdir-to-source-and-install-license
+ (lambda _
+ (chdir #$(string-append "../openmp-" version ".src"))
+ (install-file "LICENSE.TXT"
+ (string-append #$output "/share/doc"))))))))
(native-inputs
- (list clang-14 llvm-14 perl pkg-config python))
- (inputs
- (list `(,hwloc "lib")))
- (home-page "https://openmp.llvm.org")
- (synopsis "OpenMP run-time support library")
- (description
- "This package provides the run-time support library developed by the LLVM
-project for the OpenMP multi-theaded programming extension. This package
-notably provides @file{libgomp.so}, which is has a binary interface compatible
-with that of libgomp, the GNU Offloading and Multi Processing Library.")
- (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)
- (upstream-name . "openmp")))
- (license license:expat)))
+ (modify-inputs (package-native-inputs libomp-15)
+ (replace "clang" clang-14)
+ (replace "llvm" llvm-14)))))
(define-public clang-toolchain-14
(make-clang-toolchain clang-14 libomp-14))
--
2.38.1
M
M
Maxim Cournoyer wrote on 16 Nov 2022 15:18
[PATCH v2 5/5] gnu: Add clang-toolchain-15.
(address . 59237@debbugs.gnu.org)
20221116141830.12398-6-maxim.cournoyer@gmail.com
* gnu/packages/llvm.scm (clang-toolchain-15): New variable.
---
gnu/packages/llvm.scm | 3 +++
1 file changed, 3 insertions(+)

Toggle diff (16 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 528c2bc359..d315149c42 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -790,6 +790,9 @@ (define-public libomp-15
(upstream-name . "openmp")))
(license license:expat)))
+(define-public clang-toolchain-15
+ (make-clang-toolchain clang-15 libomp-15))
+
(define-public libomp-14
(package
(inherit libomp-15)
--
2.38.1
L
L
Ludovic Courtès wrote on 16 Nov 2022 16:21
Re: bug#59237: [PATCH 0/3] Add LLVM/Clang 15.0.4.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 59237@debbugs.gnu.org)
87a64rkjrk.fsf_-_@gnu.org
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (8 lines)
> This v2 series includes the following changes the following changes, based on
> Ludovic's review:
>
> * Reduce code duplication via conditional changes to the the clang-from-llvm
> template procedure and inheritance.
> * Add a libomp-15 package.
> * Add a clang-toolchain-15 package.

Perfect, LGTM!

Thanks,
Ludo’.
M
M
Maxim Cournoyer wrote on 16 Nov 2022 20:16
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 59237-done@debbugs.gnu.org)
87v8neiubk.fsf@gmail.com
Hello,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (14 lines)
> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> This v2 series includes the following changes the following changes, based on
>> Ludovic's review:
>>
>> * Reduce code duplication via conditional changes to the the clang-from-llvm
>> template procedure and inheritance.
>> * Add a libomp-15 package.
>> * Add a clang-toolchain-15 package.
>
> Perfect, LGTM!

Pushed with 83fb681658431362def447ec29876d565d49c9e5.

--
Thanks,
Maxim
Closed
?