From 193192ca77bffddd241b6706df21b5e8bccc4cce Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 24 Apr 2020 12:20:25 +0200 Subject: gnu: llvm: Add 10.0.0. * gnu/packages/llvm.scm (llvm-10, clang-runtime-10, clang-10) (clang-toolchain-10, llvm-9, clang-runtime-9, clang-9) (clang-toolchain-9): New variables. (llvm, clang, clang-runtime, clang-toolchain): Redefine as aliases to the '-9' bindings. * gnu/packages/patches/clang-10.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 1 + gnu/packages/llvm.scm | 54 ++++++++++---- .../patches/clang-10.0-libc-search-path.patch | 84 ++++++++++++++++++++++ 3 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 gnu/packages/patches/clang-10.0-libc-search-path.patch diff --git a/gnu/local.mk b/gnu/local.mk index a6e1ed2d37..d42f17f41b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -805,6 +805,7 @@ dist_patch_DATA = \ %D%/packages/patches/clang-6.0-libc-search-path.patch \ %D%/packages/patches/clang-7.0-libc-search-path.patch \ %D%/packages/patches/clang-9.0-libc-search-path.patch \ + %D%/packages/patches/clang-10.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/classpath-aarch64-support.patch \ diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 7236567a5e..d6c519bcbd 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2016, 2018 Eric Bavier ;;; Copyright © 2015 Mark H Weaver -;;; Copyright © 2015, 2017, 2018, 2019 Ludovic Courtès +;;; Copyright © 2015, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Dennis Mungai ;;; Copyright © 2016, 2018, 2019, 2020 Ricardo Wurmus ;;; Copyright © 2017 Roel Janssen @@ -84,17 +84,17 @@ as \"x86_64-linux\"." (string-append "https://releases.llvm.org/" version "/" component "-" version ".src.tar.xz"))) -(define-public llvm +(define-public llvm-10 (package (name "llvm") - (version "9.0.1") + (version "10.0.0") (source (origin (method url-fetch) (uri (llvm-download-uri "llvm" version)) (sha256 (base32 - "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880")))) + "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz")))) (build-system cmake-build-system) (native-inputs `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2 @@ -368,23 +368,49 @@ output), and Binutils.") ("libc-debug" ,glibc "debug") ("libc-static" ,glibc "static"))))) -(define-public clang-runtime +(define-public clang-runtime-10 + (clang-runtime-from-llvm + llvm-10 + "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba")) + +(define-public clang-10 + (clang-from-llvm llvm-10 clang-runtime-10 + "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8" + #:patches '("clang-10.0-libc-search-path.patch"))) + +(define-public clang-toolchain-10 + (make-clang-toolchain clang-10)) + +(define-public llvm-9 + (package + (inherit llvm-10) + (version "9.0.1") + (source + (origin + (method url-fetch) + (uri (llvm-download-uri "llvm" version)) + (sha256 + (base32 + "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880")))))) + +(define-public clang-runtime-9 (clang-runtime-from-llvm - llvm + llvm-9 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2")) -(define-public clang - (clang-from-llvm llvm clang-runtime +(define-public clang-9 + (clang-from-llvm llvm-9 clang-runtime-9 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p" #:patches '("clang-9.0-libc-search-path.patch"))) -(define-public clang-toolchain - (make-clang-toolchain clang)) +(define-public clang-toolchain-9 + (make-clang-toolchain clang-9)) -(define-public llvm-9 llvm) -(define-public clang-runtime-9 clang-runtime) -(define-public clang-9 clang) -(define-public clang-toolchain-9 clang-toolchain) +;; Default LLVM and Clang version. +(define-public llvm llvm-9) +(define-public clang-runtime clang-runtime-9) +(define-public clang clang-9) +(define-public clang-toolchain clang-toolchain-9) (define-public llvm-8 (package diff --git a/gnu/packages/patches/clang-10.0-libc-search-path.patch b/gnu/packages/patches/clang-10.0-libc-search-path.patch new file mode 100644 index 0000000000..966e40b93c --- /dev/null +++ b/gnu/packages/patches/clang-10.0-libc-search-path.patch @@ -0,0 +1,84 @@ +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 non-Guix systems. + +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index bff1ab10..79e1477e 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -240,6 +240,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + .str()); + } + ++// 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()) { +@@ -306,6 +309,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + + if (IsAndroid || Distro.IsOpenSUSE()) + ExtraOpts.push_back("--enable-new-dtags"); ++#endif // Guix + + // 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. +@@ -363,7 +367,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // the cross. Note that GCC does include some of these directories in some + // configurations but this seems somewhere between questionable and simply + // a bug. +- if (StringRef(LibPath).startswith(SysRoot)) { ++ if (0) { + addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths); + addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths); + } +@@ -382,6 +386,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); + addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths); + ++// This requires the commented distro tweaks above. ++#if 0 + if (IsAndroid) { + // Android sysroots contain a library directory for each supported OS + // version as well as some unversioned libraries in the usual multiarch +@@ -410,10 +416,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths); + addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths); + } ++#endif + + // Try walking via the GCC triple path in case of biarch or multiarch GCC + // installations with strange symlinks. + if (GCCInstallation.isValid()) { ++ ++// The following code would end up adding things like ++// "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path. ++#if 0 + addPathIfExists(D, + SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + + "/../../" + OSLibDir, +@@ -426,6 +437,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + BiarchSibling.gccSuffix(), + Paths); + } ++#endif + + // See comments above on the multilib variant for details of why this is + // included even from outside the sysroot. +@@ -450,8 +462,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + if (StringRef(D.Dir).startswith(SysRoot)) + addPathIfExists(D, D.Dir + "/../lib", Paths); + +- addPathIfExists(D, SysRoot + "/lib", Paths); +- addPathIfExists(D, SysRoot + "/usr/lib", Paths); ++ // 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); + } + + ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const { -- cgit v1.2.3