From patchwork Wed Nov 16 14:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 44541 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F3A1327BBEC; Wed, 16 Nov 2022 14:19:41 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 66BD927BBE9 for ; Wed, 16 Nov 2022 14:19:39 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJFq-0000Ci-Qg; Wed, 16 Nov 2022 09:19:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovJFp-0000AY-8l for guix-patches@gnu.org; Wed, 16 Nov 2022 09:19:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovJFm-0000ZF-NZ for guix-patches@gnu.org; Wed, 16 Nov 2022 09:19:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ovJFm-0001UX-Hz for guix-patches@gnu.org; Wed, 16 Nov 2022 09:19:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59237] [PATCH v2 1/5] gnu: Add llvm-15. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 16 Nov 2022 14:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59237 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59237@debbugs.gnu.org Cc: ludo@gnu.org, Maxim Cournoyer Received: via spool by 59237-submit@debbugs.gnu.org id=B59237.16686083295663 (code B ref 59237); Wed, 16 Nov 2022 14:19:02 +0000 Received: (at 59237) by debbugs.gnu.org; 16 Nov 2022 14:18:49 +0000 Received: from localhost ([127.0.0.1]:56444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovJFZ-0001TF-2e for submit@debbugs.gnu.org; Wed, 16 Nov 2022 09:18:49 -0500 Received: from mail-qv1-f42.google.com ([209.85.219.42]:38834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovJFX-0001St-At for 59237@debbugs.gnu.org; Wed, 16 Nov 2022 09:18:48 -0500 Received: by mail-qv1-f42.google.com with SMTP id o8so11963684qvw.5 for <59237@debbugs.gnu.org>; Wed, 16 Nov 2022 06:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jjvx1acHjAqfo83kydNEnsr6wsxeHlfTuiEzZoYhEno=; b=lRphehqktUXweGT/f9OgGLXlPzmYhfp5ubFltbVCCAjy2954wwfF/ZnHob/nCo3kjw KASKq3/vpfZUdhMsm/PcDchY+77u1nNHvJsQpbVBHW7JHYV4LM30p1T5C+JYQNx18ibq ndqzFuG7s3WPIY98zI+87s0TrYIYcWsNnIGOMy1j8IAeWzfExn9zQs4Bh4zaNh1l7xkF ZkpUpCwv8/ZwFy4dy/n6I6xXrkj0ehNz7NWuKiu3XaGVUuCt14SkBkIcPBRxbhly89op tyOHygp1Y/n9nHLlS19aKH0aOMNrMgvtuOvERA/jfQYHWznvdHIVMnkh6hsavkkjaEC1 iP0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jjvx1acHjAqfo83kydNEnsr6wsxeHlfTuiEzZoYhEno=; b=amGqjOdxlxdy0uyXKcQPd++o+OAH1ArgzWyQ7SvFj4YDSNWjdpInvwRCOX0clI18mc DeIKg+qve2iOi38/dLmSqf2k5O5X18w1X99MusYvNMRstepRIcCQFFUxG4Sjr2mNOe9H qXHwbjKGaKX2UiDVGh/0gVg905xVBoNu8OATqVDyKJKg6WZ1d8aRz9DpcV1crFCUpLl9 DW5J22OKOfBkgu9rcSN5N/JCrHt2zh6Jx9/iqUFLpSWZWSbmjau0kr7dG8/FGM+rlLUZ zfRsrQDB47VLQWJ38Ft5LJA12rq3nkn0g04d9vrmK+i5YjNxyEO3KVocsp15RS//KoDS RMBg== X-Gm-Message-State: ANoB5pm7U/F7+bTDBLOgNKPm25+7EKduUsk+JFaWzSvcO0P4CO0dtHKR fgXhl8vXvkUK8e/RfpGS3yA2NxoIaT1MWw== X-Google-Smtp-Source: AA0mqf4eLN0OS4iUweV3p0ub3/S3zD6/l2fZaGSS6pMJlHzr7YbPYH56oTZ1lwE0AxiGGuiL6MNNjg== X-Received: by 2002:ad4:55e3:0:b0:4bc:13a3:9c82 with SMTP id bu3-20020ad455e3000000b004bc13a39c82mr20726108qvb.62.1668608321498; Wed, 16 Nov 2022 06:18:41 -0800 (PST) Received: from localhost.localdomain (dsl-10-133-21.b2b2c.ca. [72.10.133.21]) by smtp.gmail.com with ESMTPSA id n16-20020a05620a295000b006b640efe6dasm10006660qkp.132.2022.11.16.06.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 06:18:41 -0800 (PST) From: Maxim Cournoyer Date: Wed, 16 Nov 2022 09:18:26 -0500 Message-Id: <20221116141830.12398-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116141830.12398-1-maxim.cournoyer@gmail.com> References: <20221116141830.12398-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 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 . + #$@(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 {