[PATCH 00/14] Add LLVM 16 and 17.

  • Done
  • quality assurance status badge
Details
3 participants
  • Efraim Flashner
  • Michael Ford
  • Hilton Chain
Owner
unassigned
Submitted by
Hilton Chain
Severity
normal
H
H
Hilton Chain wrote on 23 Oct 2023 14:28
(address . guix-patches@gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
cover.1698063805.git.hako@ultrarare.space
Hello Guix!

This series adds {llvm,clang-runtime,clang,libomp,clang-toolchain,lld}-{16,17}

I'm also intended to group packages with the same name together and make lower
versions the base that higher versions inherit from. But the number of
affected packages would require a new branch or go into core-updates, so I'll
send a new series for it.

Thanks

Hilton Chain (14):
gnu: clang-runtime-from-llvm: Adjust inputs for version 15 or later.
gnu: clang-runtime-from-llvm: Add phase for LLVM monorepo.
gnu: Add llvm-16.
gnu: Add clang-runtime-16.
gnu: Add clang-16.
gnu: Add libomp-16.
gnu: Add clang-toolchain-16.
gnu: Add lld-16.
gnu: Add llvm-17.
gnu: Add clang-runtime-17.
gnu: Add clang-17.
gnu: Add libomp-17.
gnu: Add clang-toolchain-17.
gnu: Add lld-17.

gnu/local.mk | 2 +
gnu/packages/llvm.scm | 147 ++++++++++++++----
.../patches/clang-16.0-libc-search-path.patch | 95 +++++++++++
.../patches/clang-17.0-libc-search-path.patch | 90 +++++++++++
4 files changed, 304 insertions(+), 30 deletions(-)
create mode 100644 gnu/packages/patches/clang-16.0-libc-search-path.patch
create mode 100644 gnu/packages/patches/clang-17.0-libc-search-path.patch


base-commit: b6619c5db410fb01e552c6168bd6bc7f41c6c993
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:36
[PATCH 01/14] gnu: clang-runtime-from-llvm: Adjust inputs for version 15 or later.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
baac0ddf1c2c36fcf97b3796bb38a2893fba6ba0.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-runtime-from-llvm)[native-inputs]: Add gcc-12
when version >= 15.
[inputs]: Add libffi when version >= 15.
(clang-runtime-15)[native-inputs,inputs]: Remove fields.

Change-Id: I4b385b937edbb7a2840b998b6dd3e31a17cb556f
---
gnu/packages/llvm.scm | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

Toggle diff (51 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index cd551f4e02..38c4047f48 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -26,6 +26,7 @@
;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
;;; Copyright © 2022 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2022 Zhu Zihao <all_but_last@163.com>
+;;; Copyright © 2023 Hilton Chain <hako@ultrarare.space>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -139,9 +140,19 @@ (define* (clang-runtime-from-llvm llvm
(patches (map search-patch patches)))
(llvm-monorepo (package-version llvm))))
(build-system cmake-build-system)
- (native-inputs (package-native-inputs llvm))
+ (native-inputs
+ (if (version>=? version "15")
+ ;; TODO: Remove this when GCC 12 is the default.
+ ;; libfuzzer fails to build with GCC 11
+ (modify-inputs (package-native-inputs llvm)
+ (prepend gcc-12))
+ (package-native-inputs llvm)))
(inputs
- (list llvm))
+ (append
+ (list llvm)
+ (if (version>=? version "15")
+ (list libffi)
+ '())))
(arguments
`(;; Don't use '-g' during the build to save space.
#:build-type "Release"
@@ -712,13 +723,7 @@ (define-public clang-runtime-15
#~(modify-phases #$phases
(add-after 'unpack 'change-directory
(lambda _
- (chdir "compiler-rt")))))))
- (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))))))
+ (chdir "compiler-rt"))))))))))
(define-public clang-runtime-14
(let ((template (clang-runtime-from-llvm llvm-14)))
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:36
[PATCH 02/14] gnu: clang-runtime-from-llvm: Add phase for LLVM monorepo.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
07785d53bcb056226595ed303d4669f43dba5970.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-runtime-from-llvm)[arguments]<#:phases>: Change
directory to "compiler-rt" for LLVM monorepo.
(clang-runtime-15,clang-runtime-14): Adjust accordingly.

Change-Id: I6a77c9d106439e4794b8531e2160e2c9ce63d86e
---
gnu/packages/llvm.scm | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)

Toggle diff (49 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 38c4047f48..97902fcf5c 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -161,6 +161,11 @@ (define* (clang-runtime-from-llvm llvm
(ice-9 match)
,@%cmake-build-system-modules)
#:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
+ ,@(if hash
+ '()
+ '((add-after 'unpack 'change-directory
+ (lambda _
+ (chdir "compiler-rt")))))
(add-after 'set-paths 'hide-glibc
;; Work around https://issues.guix.info/issue/36882. We need to
;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
@@ -714,28 +719,10 @@ (define-public llvm-14
("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"))))))))))
+ (clang-runtime-from-llvm llvm-15))
(define-public clang-runtime-14
- (let ((template (clang-runtime-from-llvm llvm-14)))
- (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"))))))))))
+ (clang-runtime-from-llvm llvm-14))
(define-public clang-15
(clang-from-llvm
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:36
[PATCH 03/14] gnu: Add llvm-16.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
09af827fbb41a351b4ce67e139505de43b2b03ca.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (llvm-16): New variable.
* gnu/packages/patches/clang-16.0-libc-search-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: I27738152ca95aeeef8d8b7150fdf14825b6b0b4d
---
gnu/local.mk | 1 +
gnu/packages/llvm.scm | 12 ++-
.../patches/clang-16.0-libc-search-path.patch | 95 +++++++++++++++++++
3 files changed, 106 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/clang-16.0-libc-search-path.patch

Toggle diff (148 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 43145caf80..d606cffd1f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1016,6 +1016,7 @@ dist_patch_DATA = \
%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-16.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 97902fcf5c..6014787efc 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -590,11 +590,13 @@ (define-public (make-clang-toolchain clang libomp)
(define %llvm-monorepo-hashes
'(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")
- ("15.0.7" . "12sggw15sxq1krh1mfk3c1f07h895jlxbcifpwk3pznh4m1rjfy2")))
+ ("15.0.7" . "12sggw15sxq1krh1mfk3c1f07h895jlxbcifpwk3pznh4m1rjfy2")
+ ("16.0.6" . "0jxmapg7shwkl88m4mqgfjv4ziqdmnppxhjz6vz51ycp2x4nmjky")))
(define %llvm-patches
'(("14.0.6" . ("clang-14.0-libc-search-path.patch"))
- ("15.0.7" . ("clang-15.0-libc-search-path.patch"))))
+ ("15.0.7" . ("clang-15.0-libc-search-path.patch"))
+ ("16.0.6" . ("clang-16.0-libc-search-path.patch"))))
(define (llvm-monorepo version)
(origin
@@ -1450,6 +1452,12 @@ (define-public clang-3.5
#:legacy-build-shared-libs? #t
#:patches '("clang-3.5-libc-search-path.patch")))
+(define-public llvm-16
+ (package
+ (inherit llvm-15)
+ (version "16.0.6")
+ (source (llvm-monorepo version))))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
diff --git a/gnu/packages/patches/clang-16.0-libc-search-path.patch b/gnu/packages/patches/clang-16.0-libc-search-path.patch
new file mode 100644
index 0000000000..282f58f03b
--- /dev/null
+++ b/gnu/packages/patches/clang-16.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/lib/Driver/Distro.cpp
+index 87a0c5a58511..86ea82eda4b5 100644
+--- a/clang/lib/Driver/Distro.cpp
++++ b/clang/lib/Driver/Distro.cpp
+@@ -98,6 +98,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/lib/Driver/ToolChains/Cuda.cpp
+index aa125bb308e8..8b86e144054c 100644
+--- a/clang/lib/Driver/ToolChains/Cuda.cpp
++++ b/clang/lib/Driver/ToolChains/Cuda.cpp
+@@ -124,6 +124,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/lib/Driver/ToolChains/Linux.cpp
+index c6fb290ffdb4..4736f4bb3392 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -189,6 +189,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()) {
+@@ -249,6 +253,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ #ifdef ENABLE_LINKER_BUILD_ID
+ ExtraOpts.push_back("--build-id");
++#endif
+ #endif
+
+ // The selection of paths to try here is designed to match the patterns which
+@@ -270,6 +275,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);
+
+@@ -298,9 +304,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.
+@@ -310,6 +318,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.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:36
[PATCH 04/14] gnu: Add clang-runtime-16.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
98ca328b441ac4fc6be92d28dd8101405695368c.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-runtime-16): New variable.

Change-Id: I8812e9e72b711505f7575cc3d62a9a009d25f641
---
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 6014787efc..0b1403deb6 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1458,6 +1458,9 @@ (define-public llvm-16
(version "16.0.6")
(source (llvm-monorepo version))))
+(define-public clang-runtime-16
+ (clang-runtime-from-llvm llvm-16))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 05/14] gnu: Add clang-16.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
e374a2df9c78f34f41ac9ddf57ff173a3878a530.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-16): New variable.

Change-Id: I0e62bced33d2ff5a3064917d4e95004d43dc56fb
---
gnu/packages/llvm.scm | 12 ++++++++++++
1 file changed, 12 insertions(+)

Toggle diff (25 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 0b1403deb6..f4b69a7141 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1461,6 +1461,18 @@ (define-public llvm-16
(define-public clang-runtime-16
(clang-runtime-from-llvm llvm-16))
+(define-public clang-16
+ (clang-from-llvm
+ llvm-16 clang-runtime-16
+ #:tools-extra
+ (origin
+ (method url-fetch)
+ (uri (llvm-uri "clang-tools-extra"
+ (package-version llvm-16)))
+ (sha256
+ (base32
+ "0cbgffciql06a1i0ybyyqbnkkr4g7x8cxaar5a5v3415vd27hk0p")))))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 06/14] gnu: Add libomp-16.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
81a0bc6ff849963633347ba59cc82a8a42cad260.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (libomp-16): New variable.

Change-Id: I2a396f7c7a4c0e35a15ed315c291b4298c0ee967
---
gnu/packages/llvm.scm | 10 ++++++++++
1 file changed, 10 insertions(+)

Toggle diff (23 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index f4b69a7141..5ba29e3236 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1473,6 +1473,16 @@ (define-public clang-16
(base32
"0cbgffciql06a1i0ybyyqbnkkr4g7x8cxaar5a5v3415vd27hk0p")))))
+(define-public libomp-16
+ (package
+ (inherit libomp-15)
+ (version (package-version llvm-16))
+ (source (llvm-monorepo version))
+ (native-inputs
+ (modify-inputs (package-native-inputs libomp-15)
+ (replace "clang" clang-16)
+ (replace "llvm" llvm-16)))))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 07/14] gnu: Add clang-toolchain-16.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
a60957dd7b6eca4362e6bd221546e8e4904287ff.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-toolchain-16): New variable.

Change-Id: I4bc7820b249ab93ff8b7143901c8e4220b7b8b5b
---
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 5ba29e3236..879e843e4a 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1483,6 +1483,9 @@ (define-public libomp-16
(replace "clang" clang-16)
(replace "llvm" llvm-16)))))
+(define-public clang-toolchain-16
+ (make-clang-toolchain clang-16 libomp-16))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 08/14] gnu: Add lld-16.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
52bfec31d16552c70a32a81303a6cad97220cca4.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (lld-16): New variable.

Change-Id: If34c0785531bc3603a56f18c18a8e4318cabc493
---
gnu/packages/llvm.scm | 7 +++++++
1 file changed, 7 insertions(+)

Toggle diff (20 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 879e843e4a..ee2131b0dd 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1630,6 +1630,13 @@ (define-public lld-11
(inputs (modify-inputs (package-inputs lld)
(replace "llvm" llvm-11)))))
+(define-public lld-16
+ (package
+ (inherit lld-15)
+ (version (package-version llvm-16))
+ (source (llvm-monorepo version))
+ (inputs (list llvm-16))))
+
(define-public lld lld-14)
(define* (make-lld-wrapper lld #:key lld-as-ld?)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 09/14] gnu: Add llvm-17.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
ec5f39a148242e8782220a753870e803056e0e0d.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (llvm-17): New variable.
* gnu/packages/patches/clang-17.0-libc-search-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: I8cdda0737b1137cf86887fb5b854e71977a88b6b
---
gnu/local.mk | 1 +
gnu/packages/llvm.scm | 12 ++-
.../patches/clang-17.0-libc-search-path.patch | 90 +++++++++++++++++++
3 files changed, 101 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/clang-17.0-libc-search-path.patch

Toggle diff (144 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index d606cffd1f..6057456c2b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1017,6 +1017,7 @@ dist_patch_DATA = \
%D%/packages/patches/clang-14.0-libc-search-path.patch \
%D%/packages/patches/clang-15.0-libc-search-path.patch \
%D%/packages/patches/clang-16.0-libc-search-path.patch \
+ %D%/packages/patches/clang-17.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 ee2131b0dd..eb806b9cf0 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -591,12 +591,14 @@ (define-public (make-clang-toolchain clang libomp)
(define %llvm-monorepo-hashes
'(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")
("15.0.7" . "12sggw15sxq1krh1mfk3c1f07h895jlxbcifpwk3pznh4m1rjfy2")
- ("16.0.6" . "0jxmapg7shwkl88m4mqgfjv4ziqdmnppxhjz6vz51ycp2x4nmjky")))
+ ("16.0.6" . "0jxmapg7shwkl88m4mqgfjv4ziqdmnppxhjz6vz51ycp2x4nmjky")
+ ("17.0.3" . "1fhrnsv87if7kbqmrsxy2r7ykx3gnr9lmbmvkhvycc91ii4ihybx")))
(define %llvm-patches
'(("14.0.6" . ("clang-14.0-libc-search-path.patch"))
("15.0.7" . ("clang-15.0-libc-search-path.patch"))
- ("16.0.6" . ("clang-16.0-libc-search-path.patch"))))
+ ("16.0.6" . ("clang-16.0-libc-search-path.patch"))
+ ("17.0.3" . ("clang-17.0-libc-search-path.patch"))))
(define (llvm-monorepo version)
(origin
@@ -1486,6 +1488,12 @@ (define-public libomp-16
(define-public clang-toolchain-16
(make-clang-toolchain clang-16 libomp-16))
+(define-public llvm-17
+ (package
+ (inherit llvm-15)
+ (version "17.0.3")
+ (source (llvm-monorepo version))))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
diff --git a/gnu/packages/patches/clang-17.0-libc-search-path.patch b/gnu/packages/patches/clang-17.0-libc-search-path.patch
new file mode 100644
index 0000000000..dd4d8cb998
--- /dev/null
+++ b/gnu/packages/patches/clang-17.0-libc-search-path.patch
@@ -0,0 +1,90 @@
+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/lib/Driver/Distro.cpp
+index 6e0087565941..c0a3ba7d7702 100644
+--- a/clang/lib/Driver/Distro.cpp
++++ b/clang/lib/Driver/Distro.cpp
+@@ -99,6 +99,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/lib/Driver/ToolChains/Cuda.cpp
+index 3a577650eb08..ca3373edc127 100644
+--- a/clang/lib/Driver/ToolChains/Cuda.cpp
++++ b/clang/lib/Driver/ToolChains/Cuda.cpp
+@@ -128,6 +128,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/lib/Driver/ToolChains/Linux.cpp
+index 1ba222bf83b1..28766c5ab792 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -220,6 +220,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()) {
+@@ -280,6 +284,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ #ifdef ENABLE_LINKER_BUILD_ID
+ ExtraOpts.push_back("--build-id");
++#endif
+ #endif
+
+ // The selection of paths to try here is designed to match the patterns which
+@@ -301,6 +306,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);
+
+@@ -329,11 +335,21 @@ 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
+ 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.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 10/14] gnu: Add clang-runtime-17.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
d4d6293ded077ac297ed5d1331ab13359454a744.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-runtime-17): New variable.

Change-Id: I675475e9f4914843283966f5c622cdb214d11e34
---
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 eb806b9cf0..06ecbf7e1b 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1494,6 +1494,9 @@ (define-public llvm-17
(version "17.0.3")
(source (llvm-monorepo version))))
+(define-public clang-runtime-17
+ (clang-runtime-from-llvm llvm-17))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 11/14] gnu: Add clang-17.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
c5b6bde7c17686bbb1ea427fe3291e0970e5c797.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-from-llvm)[arguments]: Include test runner in
CMakeLists.txt when version >= 17.
(clang-17): New variable.

Change-Id: Ia3cd8013d497b72522e95f6face5975bf79f93b3
---
gnu/packages/llvm.scm | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

Toggle diff (41 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 06ecbf7e1b..8dc87ad01b 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -358,6 +358,15 @@ (define* (clang-from-llvm llvm clang-runtime
(("@GLIBC_LIBDIR@")
(string-append libc "/lib"))))))
#t)))
+ ,@(if (version>=? version "17")
+ '((add-after 'unpack 'include-test-runner
+ (lambda _
+ (substitute* "CMakeLists.txt"
+ ((".*llvm_gtest" line)
+ (string-append
+ "add_subdirectory(${LLVM_THIRD_PARTY_DIR}/uni\
+ttest third-party/unittest)\n" line))))))
+ '())
;; 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
@@ -1497,6 +1506,18 @@ (define-public llvm-17
(define-public clang-runtime-17
(clang-runtime-from-llvm llvm-17))
+(define-public clang-17
+ (clang-from-llvm
+ llvm-17 clang-runtime-17
+ #:tools-extra
+ (origin
+ (method url-fetch)
+ (uri (llvm-uri "clang-tools-extra"
+ (package-version llvm-17)))
+ (sha256
+ (base32
+ "0an16xdc8rgrdf0dcq3sdg82ajyb00h4bff9n0gm7gqf48ds0da8")))))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 12/14] gnu: Add libomp-17.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
54d0c9a14d8d8a062b9e7f7a46429d7b93cc40ab.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (libomp-17): New variable.

Change-Id: I6ad09d8feff0053dfc811a741e00445dfecb311f
---
gnu/packages/llvm.scm | 10 ++++++++++
1 file changed, 10 insertions(+)

Toggle diff (23 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 8dc87ad01b..1f37f42a17 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1518,6 +1518,16 @@ (define-public clang-17
(base32
"0an16xdc8rgrdf0dcq3sdg82ajyb00h4bff9n0gm7gqf48ds0da8")))))
+(define-public libomp-17
+ (package
+ (inherit libomp-15)
+ (version (package-version llvm-17))
+ (source (llvm-monorepo version))
+ (native-inputs
+ (modify-inputs (package-native-inputs libomp-15)
+ (replace "clang" clang-17)
+ (replace "llvm" llvm-17)))))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 13/14] gnu: Add clang-toolchain-17.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
3e313afa60b31864c5ec78faaf9101f054c7a6af.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (clang-toolchain-17): New variable.

Change-Id: Iefec981c84249db0d1c740c156835dfea9030f47
---
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 1f37f42a17..795488abee 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1528,6 +1528,9 @@ (define-public libomp-17
(replace "clang" clang-17)
(replace "llvm" llvm-17)))))
+(define-public clang-toolchain-17
+ (make-clang-toolchain clang-17 libomp-17))
+
;; Default LLVM and Clang version.
(define-public libomp libomp-13)
(define-public llvm llvm-13)
--
2.41.0
H
H
Hilton Chain wrote on 23 Oct 2023 14:43
[PATCH 14/14] gnu: Add lld-17.
(address . 66701@debbugs.gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
bb20964e73efd61757f6487d40b2f63133f5606d.1698063805.git.hako@ultrarare.space
* gnu/packages/llvm.scm (lld-17): New variable.

Change-Id: Idbb84efc1c749179dfdb874390bfc1caf4e753d3
---
gnu/packages/llvm.scm | 7 +++++++
1 file changed, 7 insertions(+)

Toggle diff (20 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 795488abee..c3269ce013 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1682,6 +1682,13 @@ (define-public lld-16
(source (llvm-monorepo version))
(inputs (list llvm-16))))
+(define-public lld-17
+ (package
+ (inherit lld-15)
+ (version (package-version llvm-17))
+ (source (llvm-monorepo version))
+ (inputs (list llvm-17))))
+
(define-public lld lld-14)
(define* (make-lld-wrapper lld #:key lld-as-ld?)
--
2.41.0
M
M
Michael Ford wrote on 6 Nov 2023 15:47
Add LLVM 16 and 17.
(address . 66701@debbugs.gnu.org)
CAFyhPjXAcePCgxYB3hyQ=GJ+h5j0CHQ1+GmO3mJcnJ92pxTWBg@mail.gmail.com
Hi Hilton,

Awesome work.
Looking forward to making use of this in the near future.

Thanks,

Michael
E
E
Efraim Flashner wrote on 12 Nov 2023 15:14
(name . Hilton Chain)(address . hako@ultrarare.space)(address . 66701-done@debbugs.gnu.org)
ZVDd0QSOtwUPiIwN@3900XT
Thanks! Patches pushed.

--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmVQ3dEACgkQQarn3Mo9
g1EVShAAp4kabRxh4inptmd/W59zi5Vuu7HL0mDZxxSpfnXmB3bCZLZvOXiBNxRB
97M2z9PL6sWOrCWFtuJoi+IgvLwBX5moJsdnLMQpgEt9rmn8Q949yMNFzv/hMpeJ
ovFpsjxAW6/qdu2mhpVRfM0C0kEDqbLXkO4LiG17w2R6FTySdRXQwGv7OlIwrCTk
Gn9ixjX4Yxy2AV4SY/PUmppxcmTwjapxFB6G6KrxBglnE/MyrM5iIrD84fOaTq0/
+oU9Y3dvKRxWKXbdYEbo8vJeevLfTe9QXKz2WtpCr36Wu6cHx2lH//PcECFJX8MS
K611OdfkUqEgaxiOhGnEmjRv57l0sV6PxyKVp4mqCbgsXnczaScv9zl5t6o1Ig77
qujSHwMLEdu3Lt7sp8fuSeDyn4pAkXgmB59NAMex/6FpzOoY+Aw0X+e7X1WhTcxv
/qGeMuepAmEjWlMzZPGrcsjs3+zp2hgAjOIPz4io4Am+pE+Tq2IS9d8Hedp3/Uit
SEs8tMnrbeRkhp+gOSQy93jhAFgkMkGMSfBLLQuwnjRGJPRCepJvx63J9bNg3SeZ
0jTXVAr2gUv3xitWA0yO5fPr0C7cjmjJunt5k7aIc5CR5LPefE2XMumNByP+ki+o
Xf2IC04k3DXzYSon8/NUm9Yh/1XrGR3YHvrmaMtUHaEhL2mTrII=
=cPEB
-----END PGP SIGNATURE-----


Closed
?