From 855e34d44f02c80850434be12714726385e47dc3 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Wed, 22 Sep 2021 22:22:43 +0200 Subject: gnu: LLVM, Clang: Update to 12.0.1. * gnu/packages/patches/clang-12-tools-extra-directory.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/llvm.scm (llvm-12, clang-runtime-12): Update to 12.0.1. (clang-12): Likewise. Remove obsolete patch. --- gnu/packages/llvm.scm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'gnu/packages/llvm.scm') diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 3805f4e107..de964b020d 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -480,14 +480,14 @@ output), and Binutils.") (define-public llvm-12 (package (name "llvm") - (version "12.0.0") + (version "12.0.1") (source (origin (method url-fetch) (uri (llvm-uri "llvm" version)) (sha256 (base32 - "0l4b79gwfvxild974aigcq1yigypjsk2j5p59syhl6ksd744gp29")))) + "1pzx9zrmd7r3481sbhwvkms68fwhffpp4mmz45dgrkjpyl2q96kx")))) (build-system cmake-build-system) (outputs '("out" "opt-viewer")) (native-inputs @@ -542,22 +542,20 @@ of programming tools as well as libraries with equivalent functionality.") (define-public clang-runtime-12 (clang-runtime-from-llvm llvm-12 - "0d444qihq9jhqnfv003cr704v363va72zl6qaw2algj1c85cva45")) + "1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l")) (define-public clang-12 (clang-from-llvm llvm-12 clang-runtime-12 - "1vd9rhhrd8ghdg111lac7w8by71y9l14yh5zxfijsm6lj4p4avp2" + "0px4gl27az6cdz6adds89qzdwb1cqpjsfvrldbz9qvpmphrj34bf" #:patches '("clang-11.0-libc-search-path.patch") #:tools-extra (origin (method url-fetch) (uri (llvm-uri "clang-tools-extra" (package-version llvm-12))) - (patches - (search-patches "clang-12-tools-extra-directory.patch")) (sha256 (base32 - "0p3dzr0qa7mar83y66xa5m5apynf6ia0lsdsq6axwnm64ysy0hdd"))))) + "1r9a4fdz9ci58b5z2inwvm4z4cdp6scrivnaw05dggkxz7yrwrb5"))))) (define-public clang-toolchain-12 (make-clang-toolchain clang-12)) -- cgit v1.2.3 From 33783d9009cb6f5b9cfa433822037e28ca9c9a00 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Wed, 22 Sep 2021 22:24:25 +0200 Subject: gnu: Add libunwind-headers. * gnu/packages/llvm.scm (libunwind-headers): New public variable. --- gnu/packages/llvm.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gnu/packages/llvm.scm') diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index de964b020d..5bb521b95f 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -918,6 +918,34 @@ of programming tools as well as libraries with equivalent functionality.") ,@(package-properties llvm-12))))) + +(define-public libunwind-headers + (package + (name "libunwind-headers") + (version "12.0.1") + (source (origin + (method url-fetch) + (uri (llvm-uri "libunwind" version)) + (sha256 + (base32 + "192ww6n81lj2mb9pj4043z79jp3cf58a9c2qrxjwm5c3a64n1shb")))) + (build-system cmake-build-system) + (arguments + '(#:phases (modify-phases (map (lambda (phase) + (assq phase %standard-phases)) + '(set-paths unpack)) + (add-after 'unpack 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (mkdir out) + (copy-recursively "include" + (string-append out "/include")))))))) + (home-page "https://clang.llvm.org/docs/Toolchain.html") + (synopsis "LLVM libunwind header files") + (description + "This package contains header files for the LLVM C++ unwinding library.") + (license license:asl2.0))) ;with LLVM exceptions + (define-public lld (package (name "lld") -- cgit v1.2.3 From a7283c1d143f843266a0af3f564a86c0cef1ba7b Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Wed, 22 Sep 2021 22:24:53 +0200 Subject: gnu: lld: Update to 12.0.1. * gnu/packages/llvm.scm (lld): Update to 12.0.1. [native-inputs]: Add LIBUNWIND-HEADERS. --- gnu/packages/llvm.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gnu/packages/llvm.scm') diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 5bb521b95f..f479af39d7 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -949,16 +949,20 @@ of programming tools as well as libraries with equivalent functionality.") (define-public lld (package (name "lld") - (version "11.0.0") + (version "12.0.1") (source (origin (method url-fetch) (uri (llvm-uri "lld" version)) (sha256 (base32 - "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg")))) + "0qg3fgc7wj34hdkqn21y03zcmsdd01szhhm1hfki63iifrm3y2v9")))) (build-system cmake-build-system) + (native-inputs + ;; Note: check to see + ;; whether this is still necessary. + `(("libunwind-headers" ,libunwind-headers))) (inputs - `(("llvm" ,llvm-11))) + `(("llvm" ,llvm-12))) (arguments `(#:build-type "Release" ;; TODO: Tests require the lit tool, which isn't installed by the LLVM -- cgit v1.2.3 From 88f4f1f5af0ecae3ce9c4a894eed569de8e1221e Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Wed, 22 Sep 2021 22:25:34 +0200 Subject: gnu: lldb: Update to 12.0.1. * gnu/packages/llvm.scm (lldb): Update to 12.0.1. [inputs]: Change from LLVM-11 and CLANG-11 to LLVM-12 and CLANG-12. --- gnu/packages/llvm.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gnu/packages/llvm.scm') diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index f479af39d7..37626edff7 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -977,13 +977,13 @@ components which highly leverage existing libraries in the larger LLVM Project." (define-public lldb (package (name "lldb") - (version "11.0.0") + (version "12.0.1") (source (origin (method url-fetch) (uri (llvm-uri "lldb" version)) (sha256 (base32 - "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45")))) + "0g3pj1m3chafavpr35r9fynm85y2hdyla6klj0h28khxs2613i78")))) (build-system cmake-build-system) (arguments `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++"))) @@ -991,8 +991,8 @@ components which highly leverage existing libraries in the larger LLVM Project." `(("pkg-config" ,pkg-config) ("swig" ,swig))) (inputs - `(("clang" ,clang-11) - ("llvm" ,llvm-11) + `(("clang" ,clang-12) + ("llvm" ,llvm-12) ;; Optional (but recommended) inputs. ("curses" ,ncurses) -- cgit v1.2.3 From 66caab54b9a499097794460eee79d70f17d3d73c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 8 Oct 2021 22:41:30 +0200 Subject: gnu: clang@7, clang@8: Do not refer to /lib on foreign distros. Partly fixes . * gnu/packages/patches/clang-7.0-libc-search-path.patch: Update. * gnu/packages/patches/clang-8.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/llvm.scm (clang-8): Use it. --- gnu/local.mk | 1 + gnu/packages/llvm.scm | 2 +- .../patches/clang-7.0-libc-search-path.patch | 82 +++++++++++-------- .../patches/clang-8.0-libc-search-path.patch | 94 ++++++++++++++++++++++ 4 files changed, 143 insertions(+), 36 deletions(-) create mode 100644 gnu/packages/patches/clang-8.0-libc-search-path.patch (limited to 'gnu/packages/llvm.scm') diff --git a/gnu/local.mk b/gnu/local.mk index b1f0cab55e..1f036beee5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -932,6 +932,7 @@ dist_patch_DATA = \ %D%/packages/patches/clang-3.8-libc-search-path.patch \ %D%/packages/patches/clang-6.0-libc-search-path.patch \ %D%/packages/patches/clang-7.0-libc-search-path.patch \ + %D%/packages/patches/clang-8.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-11.0-libc-search-path.patch \ diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 37626edff7..3e0450cb04 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -681,7 +681,7 @@ of programming tools as well as libraries with equivalent functionality.") (define-public clang-8 (clang-from-llvm llvm-8 clang-runtime-8 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08" - #:patches '("clang-7.0-libc-search-path.patch"))) + #:patches '("clang-8.0-libc-search-path.patch"))) (define-public clang-toolchain-8 (make-clang-toolchain clang-8)) diff --git a/gnu/packages/patches/clang-7.0-libc-search-path.patch b/gnu/packages/patches/clang-7.0-libc-search-path.patch index 07ff8c90bd..cb7088eda4 100644 --- a/gnu/packages/patches/clang-7.0-libc-search-path.patch +++ b/gnu/packages/patches/clang-7.0-libc-search-path.patch @@ -4,8 +4,39 @@ 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-GuixSD systems. +to make sure Clang also works on foreign distros. +diff --git a/lib/Driver/Distro.cpp b/lib/Driver/Distro.cpp +index 2c4d44f..0493b0a 100644 +--- a/lib/Driver/Distro.cpp ++++ b/lib/Driver/Distro.cpp +@@ -18,6 +18,10 @@ using namespace clang::driver; + using namespace clang; + + static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) { ++ // The compiler should always behave the same, even when used via Guix on a ++ // foreign distro. ++ return Distro::UnknownDistro; ++ + llvm::ErrorOr> File = + VFS.getBufferForFile("/etc/lsb-release"); + if (File) { +diff --git a/lib/Driver/ToolChains/Cuda.cpp b/lib/Driver/ToolChains/Cuda.cpp +index 7fb4ae4..cb21344 100644 +--- a/lib/Driver/ToolChains/Cuda.cpp ++++ b/lib/Driver/ToolChains/Cuda.cpp +@@ -66,6 +66,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/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index f8f3623..36dc722 100644 --- a/lib/Driver/ToolChains/Linux.cpp +++ b/lib/Driver/ToolChains/Linux.cpp @@ -225,7 +225,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) @@ -27,56 +58,37 @@ to make sure Clang also works on non-GuixSD systems. // 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. -@@ -342,7 +345,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); +@@ -348,6 +351,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) } -@@ -361,6 +364,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 -@@ -389,10 +394,14 @@ 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 ++#if 0 + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent library paths to + // those searched. +@@ -393,6 +397,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) // 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, -@@ -405,6 +414,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. -@@ -429,8 +439,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) +@@ -428,9 +434,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // directory ('Dir' below) or the ResourceDir. if (StringRef(D.Dir).startswith(SysRoot)) addPathIfExists(D, D.Dir + "/../lib", Paths); - -- addPathIfExists(D, SysRoot + "/lib", Paths); -- addPathIfExists(D, 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); + +- addPathIfExists(D, SysRoot + "/lib", Paths); +- addPathIfExists(D, SysRoot + "/usr/lib", Paths); ++ // Add GCC's lib/ directory so libstdc++.so can be found. ++ addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths); } bool Linux::HasNativeLLVMSupport() const { return true; } diff --git a/gnu/packages/patches/clang-8.0-libc-search-path.patch b/gnu/packages/patches/clang-8.0-libc-search-path.patch new file mode 100644 index 0000000000..2003fef217 --- /dev/null +++ b/gnu/packages/patches/clang-8.0-libc-search-path.patch @@ -0,0 +1,94 @@ +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/lib/Driver/Distro.cpp b/lib/Driver/Distro.cpp +index 396d0bee..90e06613 100644 +--- a/lib/Driver/Distro.cpp ++++ b/lib/Driver/Distro.cpp +@@ -19,6 +19,10 @@ using namespace clang::driver; + using namespace clang; + + 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; ++ + llvm::ErrorOr> File = + VFS.getBufferForFile("/etc/lsb-release"); + if (File) { +diff --git a/lib/Driver/ToolChains/Cuda.cpp b/lib/Driver/ToolChains/Cuda.cpp +index 57b8d434..57339f1a 100644 +--- a/lib/Driver/ToolChains/Cuda.cpp ++++ b/lib/Driver/ToolChains/Cuda.cpp +@@ -68,6 +68,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/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 65ab9b2d..5ed28e0a 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -233,7 +233,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + + GCCInstallation.getTriple().str() + "/bin") + .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()); + + if (Distro.IsAlpineLinux() || Triple.isAndroid()) { +@@ -304,6 +306,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. +@@ -366,6 +369,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + } + } + ++#if 0 + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent library paths to + // those searched. +@@ -411,6 +415,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // 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. + addPathIfExists(D, + SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + + "/../../" + OSLibDir, +@@ -446,9 +452,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // directory ('Dir' below) or the ResourceDir. + if (StringRef(D.Dir).startswith(SysRoot)) + addPathIfExists(D, D.Dir + "/../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); + +- addPathIfExists(D, SysRoot + "/lib", Paths); +- addPathIfExists(D, SysRoot + "/usr/lib", Paths); ++ // Add GCC's lib/ directory so libstdc++.so can be found. ++ addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths); + } + + ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const { -- cgit v1.2.3 From b37fe44b7db3a68f961d07ab010fd1e8220dc50d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 9 Oct 2021 00:39:04 +0200 Subject: gnu: clang@11, clang@12: Do not refer to /lib on foreign distros. Partly fixes . * gnu/packages/patches/clang-11.0-libc-search-path.patch: Update. * gnu/packages/patches/clang-12.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/llvm.scm (clang-12): Use it. --- gnu/local.mk | 1 + gnu/packages/llvm.scm | 2 +- .../patches/clang-11.0-libc-search-path.patch | 101 ++++++++++----------- .../patches/clang-12.0-libc-search-path.patch | 84 +++++++++++++++++ 4 files changed, 134 insertions(+), 54 deletions(-) create mode 100644 gnu/packages/patches/clang-12.0-libc-search-path.patch (limited to 'gnu/packages/llvm.scm') diff --git a/gnu/local.mk b/gnu/local.mk index 1f036beee5..bb3063c4ac 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -936,6 +936,7 @@ dist_patch_DATA = \ %D%/packages/patches/clang-9.0-libc-search-path.patch \ %D%/packages/patches/clang-10.0-libc-search-path.patch \ %D%/packages/patches/clang-11.0-libc-search-path.patch \ + %D%/packages/patches/clang-12.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 3e0450cb04..a79998e5ac 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -547,7 +547,7 @@ of programming tools as well as libraries with equivalent functionality.") (define-public clang-12 (clang-from-llvm llvm-12 clang-runtime-12 "0px4gl27az6cdz6adds89qzdwb1cqpjsfvrldbz9qvpmphrj34bf" - #:patches '("clang-11.0-libc-search-path.patch") + #:patches '("clang-12.0-libc-search-path.patch") #:tools-extra (origin (method url-fetch) diff --git a/gnu/packages/patches/clang-11.0-libc-search-path.patch b/gnu/packages/patches/clang-11.0-libc-search-path.patch index c014de179d..d0581d3a29 100644 --- a/gnu/packages/patches/clang-11.0-libc-search-path.patch +++ b/gnu/packages/patches/clang-11.0-libc-search-path.patch @@ -4,48 +4,47 @@ 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. +to make sure Clang also works on foreign distros. -diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp ---- a/lib/Driver/ToolChains/Gnu.cpp -+++ b/lib/Driver/ToolChains/Gnu.cpp -@@ -2797,7 +2797,7 @@ void Generic_GCC::AddMultilibPaths(const Driver &D, - // 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); - } -@@ -2811,6 +2811,10 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D, - // 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, -@@ -2823,6 +2827,7 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D, - D, GCCInstallation.getInstallPath() + BiarchSibling.gccSuffix(), - Paths); - } -+#endif // Guix +diff --git a/lib/Driver/Distro.cpp b/lib/Driver/Distro.cpp +index 4d58ad1a..6f638eca 100644 +--- a/lib/Driver/Distro.cpp ++++ b/lib/Driver/Distro.cpp +@@ -21,6 +21,10 @@ using namespace clang; - // See comments above on the multilib variant for details of why this is - // included even from outside the sysroot. + static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS, + const llvm::Triple &TargetOrHost) { ++ // The compiler should always behave the same, even when used via Guix on a ++ // foreign distro. ++ return Distro::UnknownDistro; ++ + // If we don't target Linux, no need to check the distro. This saves a few + // OS calls. + if (!TargetOrHost.isOSLinux()) +diff --git a/lib/Driver/ToolChains/Cuda.cpp b/lib/Driver/ToolChains/Cuda.cpp +index 110a0bca..42b9f7b7 100644 +--- a/lib/Driver/ToolChains/Cuda.cpp ++++ b/lib/Driver/ToolChains/Cuda.cpp +@@ -67,6 +67,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/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 18035047..ace8f443 100644 --- a/lib/Driver/ToolChains/Linux.cpp +++ b/lib/Driver/ToolChains/Linux.cpp @@ -219,6 +219,9 @@ 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. ++ // 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); @@ -54,36 +53,32 @@ diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp if (IsAndroid || Distro.IsOpenSUSE()) ExtraOpts.push_back("--enable-new-dtags"); -+#endif // Guix ++#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. -@@ -310,6 +314,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); +@@ -297,6 +301,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) -+// 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 -@@ -338,6 +344,7 @@ 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 // Guix - - Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths); + Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths); -@@ -349,8 +356,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) ++#if 0 + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent library paths to + // those searched. +@@ -348,9 +353,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // directory ('Dir' below) or the ResourceDir. if (StringRef(D.Dir).startswith(SysRoot)) addPathIfExists(D, D.Dir + "/../lib", Paths); - -- addPathIfExists(D, SysRoot + "/lib", Paths); -- addPathIfExists(D, 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); + +- addPathIfExists(D, SysRoot + "/lib", Paths); +- addPathIfExists(D, SysRoot + "/usr/lib", Paths); ++ // Add GCC's lib/ directory so libstdc++.so can be found. ++ addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths); } ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const { diff --git a/gnu/packages/patches/clang-12.0-libc-search-path.patch b/gnu/packages/patches/clang-12.0-libc-search-path.patch new file mode 100644 index 0000000000..38de275048 --- /dev/null +++ b/gnu/packages/patches/clang-12.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 foreign distros. + +diff --git a/lib/Driver/Distro.cpp b/lib/Driver/Distro.cpp +index ee4fe841..f0313bbe 100644 +--- a/lib/Driver/Distro.cpp ++++ b/lib/Driver/Distro.cpp +@@ -93,6 +93,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/lib/Driver/ToolChains/Cuda.cpp b/lib/Driver/ToolChains/Cuda.cpp +index d14776c5..88bc3ccd 100644 +--- a/lib/Driver/ToolChains/Cuda.cpp ++++ b/lib/Driver/ToolChains/Cuda.cpp +@@ -119,6 +119,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/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 9663a739..107f96d6 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -223,6 +223,9 @@ 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()) { +@@ -288,6 +291,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. +@@ -301,6 +305,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + + Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths); + ++#if 0 + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent library paths to + // those searched. +@@ -352,9 +357,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + // directory ('Dir' below) or the ResourceDir. + if (StringRef(D.Dir).startswith(SysRoot)) + addPathIfExists(D, D.Dir + "/../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); + +- addPathIfExists(D, SysRoot + "/lib", Paths); +- addPathIfExists(D, SysRoot + "/usr/lib", Paths); ++ // Add GCC's lib/ directory so libstdc++.so can be found. ++ addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths); + } + + ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const { -- cgit v1.2.3