From patchwork Fri Jan 19 04:40:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 59114 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 C4FC627BBE9; Fri, 19 Jan 2024 04:43:18 +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_H5,RCVD_IN_MSPIKE_WL,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 10AE227BBEB for ; Fri, 19 Jan 2024 04:43:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQgig-0007Qe-83; Thu, 18 Jan 2024 23:43:07 -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 1rQgia-0007PZ-VV for guix-patches@gnu.org; Thu, 18 Jan 2024 23:43:01 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQgia-00087t-NL for guix-patches@gnu.org; Thu, 18 Jan 2024 23:43:00 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rQgic-0004cr-Ma for guix-patches@gnu.org; Thu, 18 Jan 2024 23:43:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68554] [PATCH v3 3/6] gnu: Add dmd. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 Jan 2024 04:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68554 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68554@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 68554-submit@debbugs.gnu.org id=B68554.170563933017657 (code B ref 68554); Fri, 19 Jan 2024 04:43:02 +0000 Received: (at 68554) by debbugs.gnu.org; 19 Jan 2024 04:42:10 +0000 Received: from localhost ([127.0.0.1]:57191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQghl-0004ae-Oa for submit@debbugs.gnu.org; Thu, 18 Jan 2024 23:42:10 -0500 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:43231) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQghd-0004Yv-PL for 68554@debbugs.gnu.org; Thu, 18 Jan 2024 23:42:02 -0500 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-429be9fe952so11189911cf.0 for <68554@debbugs.gnu.org>; Thu, 18 Jan 2024 20:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705639314; x=1706244114; darn=debbugs.gnu.org; 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=Y/Xq/Obh5Cb5Zult8RCLZDGrgJUoxTOjOwvqiLaeygA=; b=K1ukpqCto/09Ntw1I0SA4Y7E+0yW+gV87r02dq9gV8Z4TtTFMSnLy3bHKxIiE7mVpg MXZPBbf0Dm7GECZ0EnBGgHpFmcJNLIWbpwMEWEIRGpaOGoaAfIX8cVgmb3QiLl2vBIT/ aOUnfm76hN94ESLQZ4w1v+apqBSAX36sk6CoTujjm/A5LLxnhcYW2VLs2q1XE9khL/V0 ZQ2tv0xqd97dr6tn8CI6u8g8LjeihW7LhJpNjzwXZO4REk2yzlaPSNrSMKThVSUyStgO X8oFgeS4BDX2jkvvzyxEMQnRerHo02Dp3UCiluQSbPqo3EGdjOIFVsOLu4IAS5NWS0qy 1drQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705639314; x=1706244114; 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=Y/Xq/Obh5Cb5Zult8RCLZDGrgJUoxTOjOwvqiLaeygA=; b=Z0rCZEdtB8yS21Ixue8gEEdmnGdM2OMlYTyfL7lTBIRBTM1pPaVULglD7jIT0N//4d JqMyW37+XnPL8WR/Ng7mSSf4LsJbO7pkKoWQIJuXZHgMoKRLMP0kU7jOX1EO5Um8MRXR xVNFbLp3fqF1wGw6BQKffJNovOZ9SvLluMAlTkeVXfJg/A5oDogp+d3kbZJkQLxG1lAp VlysbpeiEkgBnFoGJUWCL0m+olAP8RbcNjF4qmkcBMIr0WakOZ713gQjenAkws8ZjETe 2sMuOepXIsdUwujC05BCgaaooa3EBdQsyOvEcjjwJxn/ahGYZKmbODf/ZNVaAkSaYE/D HeSQ== X-Gm-Message-State: AOJu0Yy3P+kwktfG6ex6BI6s69yBBS6RJkSuhGvHjYTARzH5k51O96Qp GQMhsDjrom22sF5Bwkh9P4S3fB0wwpojg7uX3FG75IwiRKdCwEW9HAcCaSTXSQs= X-Google-Smtp-Source: AGHT+IGRl8utE7WIKTowSJkQR8qvATi43vw5q+7mGwpbISmcHCiCBcX5U7MgTjaYt0FadJmaxx7zYw== X-Received: by 2002:a05:622a:180d:b0:42a:9c3:84b2 with SMTP id t13-20020a05622a180d00b0042a09c384b2mr741691qtc.9.1705639313959; Thu, 18 Jan 2024 20:41:53 -0800 (PST) Received: from localhost.localdomain (dsl-10-132-160.b2b2c.ca. [72.10.132.160]) by smtp.gmail.com with ESMTPSA id z10-20020a05622a124a00b0042a11ed1240sm1866870qtx.92.2024.01.18.20.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 20:41:53 -0800 (PST) From: Maxim Cournoyer Date: Thu, 18 Jan 2024 23:40:41 -0500 Message-ID: <33263f493ea13d0a468a73c9b704e1a0496c0a91.1705639243.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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/dlang.scm (dmd-bootstrap, dmd): New variables. Change-Id: I53e00a429e2084a392341ef1bc7ea63f0fcaaab4 --- Changes in v3: - Add packages built from dmd and D demangling support to qt-creator Changes in v2: - Build make flags via inheritance... - Fixing the missing SYSCONFDIR make flag gnu/packages/dlang.scm | 165 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/gnu/packages/dlang.scm b/gnu/packages/dlang.scm index 5c9766110d..f8060fa0c3 100644 --- a/gnu/packages/dlang.scm +++ b/gnu/packages/dlang.scm @@ -358,6 +358,171 @@ (define-public ldc `(("clang" ,clang-14) ;propagates llvm and clang-runtime ("python-lit" ,python-lit)))))) +;;; Bootstrap version of phobos that is built with GDC, using GDC's standard +;;; library. +(define dmd-bootstrap + (package + ;; This package is purposefully named just "dmd" and not "dmd-bootstrap", + ;; as the final dmd package rewrites references from this one to itself, + ;; and their names must have the same length to avoid corrupting the + ;; binary. + (name "dmd") + (version "2.106.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/dlang/dmd") + (commit (string-append "v" version)))) + (file-name (git-file-name "dmd" version)) + (sha256 + (base32 + "1bq4jws1vns2jjzfz7biyngrx9y5pvvgklymhrvb5kvbzky1ldmy")))) + (build-system gnu-build-system) + (arguments + (list + #:disallowed-references (list (gexp-input (canonical-package gcc) + "lib")) + ;; Disable tests, as gdmd cannot cope with some arguments used such as + ;; '-conf'. + #:tests? #f + #:test-target "test" + #:make-flags + #~(list (string-append "CC=" #$(cc-for-target)) + ;; XXX: Proceed despite conflicts from symbols provided by both + ;; the source built and GDC. + "DFLAGS=-L--allow-multiple-definition" + "ENABLE_RELEASE=1" + (string-append "HOST_CXX=" #$(cxx-for-target)) + "HOST_DMD=gdmd" + (string-append "INSTALL_DIR=" #$output) + ;; Do not build the shared libphobos2.so library, to avoid + ;; retaining a reference to gcc:lib. + "SHARED=0" + (string-append "SYSCONFDIR=" #$output "/etc") + "VERBOSE=1" + "-f" "posix.mak") + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'copy-phobos-source-and-chdir + ;; Start with building phobos, which in turns will automatically + ;; build druntime and dmd. A minimal dmd command is still + ;; required to do so, which is why we need dmd-bootstrap-0. + (lambda _ + (symlink "." "dmd") ;to please the build system expected layout + (copy-recursively + #$(origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/dlang/phobos") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1yw7nb5d78cx9m7sfibv7rfc7wj3w0dw9mfk3d269qpfpnwzs4n9"))) + "phobos") + (chdir "phobos"))) + (add-after 'copy-phobos-source-and-chdir 'adjust-phobos-install-dirs + (lambda _ + (substitute* "posix.mak" + ;; Install to lib directory, not to e.g. 'linux/lib64'. + (("\\$\\(INSTALL_DIR)/\\$\\(OS)/\\$\\(lib_dir)") + (string-append #$output "/lib")) + ;; Do not install license file, already done by the gnu build + ;; system. + ((".*\\$\\(INSTALL_DIR)/phobos-LICENSE.txt.*") "")))) + (delete 'configure) + (add-after 'install 'install-druntime + (lambda args + (chdir "../druntime") + (apply (assoc-ref %standard-phases 'install) args) + (chdir ".."))) + (add-after 'install-druntime 'install-includes + (lambda _ + ;; Normalize the include files prefix to include/dmd. + (let ((include-dir (string-append #$output "/include/dmd"))) + (mkdir-p include-dir) + (rename-file (string-append #$output "/src/phobos") + (string-append include-dir)) + (copy-recursively "druntime/import" include-dir)) + (delete-file-recursively (string-append #$output "/src")))) + (add-after 'install-druntime 'install-dmd + (assoc-ref %standard-phases 'install)) + (add-after 'install-license-files 'refine-install-layout + (lambda _ + (let* ((docdir (string-append #$output "/share/doc/" + (strip-store-file-name #$output))) + ;; The dmd binary gets installed to + ;; e.g. /linux/bin64/dmd. + (dmd (car (find-files #$output "^dmd$"))) + (dmd.conf (car (find-files #$output "^dmd.conf$"))) + (os-dir (dirname (dirname dmd)))) + ;; Move samples from root to the doc directory. + (rename-file (string-append #$output "/samples") + (string-append docdir "/samples")) + ;; Remove duplicate license file. + (delete-file (string-append #$output + "/dmd-boostlicense.txt")) + ;; Move dmd binary and dmd.conf. + (install-file dmd (string-append #$output "/bin")) + (install-file dmd.conf (string-append #$output "/etc")) + (delete-file-recursively os-dir)))) + (add-after 'refine-install-layout 'patch-dmd.conf + (lambda* (#:key outputs #:allow-other-keys) + (substitute* (search-input-file outputs "etc/dmd.conf") + (("lib(32|64)") + "lib") + (("\\.\\./src/(phobos|druntime/import)") + "include/dmd"))))))) + (native-inputs (list gdmd which)) + (home-page "https://github.com/dlang/dmd") + (synopsis "Reference D Programming Language compiler") + (description "@acronym{DMD, Digital Mars D compiler} is the reference +compiler for the D programming language.") + (license license:boost1.0))) + +;;; Second bootstrap of DMD, built using dmd-bootstrap, with its shared +;;; libraries preserved. +(define-public dmd + (package + (inherit dmd-bootstrap) + (arguments + (substitute-keyword-arguments + (strip-keyword-arguments + '(#:tests?) ;reinstate tests + (package-arguments dmd-bootstrap)) + ((#:disallowed-references _ ''()) + (list dmd-bootstrap)) + ((#:modules _ ''()) + '((guix build gnu-build-system) + (guix build utils) + (srfi srfi-1))) ;for fold + ((#:make-flags flags ''()) + #~(fold delete #$flags '("DFLAGS=-L--allow-multiple-definition" + "HOST_DMD=gdmd" + "SHARED=0"))) + ((#:phases phases '%standard-phases) + #~(modify-phases #$phases + (add-after 'patch-dmd.conf 'rewrite-references-to-bootstrap + ;; DMD keeps references to include files used to build a + ;; binary. Rewrite those of dmd-bootstrap to itself, to reduce + ;; its closure size. + (lambda* (#:key native-inputs inputs outputs + #:allow-other-keys) + (let ((dmd (search-input-file outputs "bin/dmd")) + (dmd-bootstrap (dirname + (dirname + (search-input-file + (or native-inputs inputs) + "bin/dmd"))))) + ;; XXX: Use sed, as replace-store-references wouldn't + ;; replace the references, while substitute* throws an + ;; error. + (invoke "sed" "-i" + (format #f "s,~a,~a,g" dmd-bootstrap #$output) + dmd)))))))) + (native-inputs (modify-inputs (package-native-inputs dmd-bootstrap) + (replace "gdmd" dmd-bootstrap))))) + (define-public dub (package (name "dub")