From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 6ETOCYbMwWT1ogAASxT56A (envelope-from ) for ; Thu, 27 Jul 2023 03:46:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id OKS1CYbMwWT5jwAA9RJhRA (envelope-from ) for ; Thu, 27 Jul 2023 03:46:46 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B29EC316E2 for ; Thu, 27 Jul 2023 03:46:45 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=ngyro.com header.s=fm1 header.b=Ex9cYQmd; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm3 header.b=niUrkRTQ; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1690422406; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=sy+PA3HDY5X5Qqb09VXcEenla7dVDN3Tm/c1pFfkBg0=; b=bnHhaG5I+XYIr20thNujmP6YCd11yH5C/ifTM8adSdG1kYEU2AZWAYgeSDKgzIwJNFGLnA YS1ySTWlF/Qu8l65BjEuCuSzYy/dR5ckqzugpYTm4Fo58brNoU0AXuLcPQ4qi1tboQClCG 4zA/NEznVMATgHda/qNTX4wv6pOc3UxahE4KQJXxHm2vMpPtJTTS2KGI3AyD9kIpaz8GTM n2WQy7MMWgokKgSmDI13uVAN3zdpoHcuESBPWU3IVg0bdE3c9e9e2Zqso5WL/hBJH7W0tj mKj2uXgHcOmceAVQALX+rB306IoOjx0xFHfcqFGkVP+fP25V/HbUInjLpasqfA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1690422406; a=rsa-sha256; cv=none; b=L9WmI69JBCZycKFMl2WvkMjLWIakL7hXct9r1yY9bDgdvncK2gsBpJqd15HsYmoMS+K78j cquhNqYqaoUX2tjeXg9C3VLQPAYhUzKoQkdKPqnzV6gUXjjOwCAKCNV6OXXcLBWnA5pmAW ZB5W14KSO+3BdWgnYGeI+vcAxBJmut7Ejin+6VLex3Cph2BH3meHpNhni4mvvCBhOUheMc RkHN1a2ls7kd3YEAFMk+ISVlCX6YwXv1/5Kp6ic9Hk6M2kQEzMIDzUUppInMbb+iMIh/gr gxTpLey4OIRl4F2MC445/Z4Xu0UXRf0WXpc6ak2ycRJCyz393n1+fh3ncHrgEg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=ngyro.com header.s=fm1 header.b=Ex9cYQmd; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm3 header.b=niUrkRTQ; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=none Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOpux-0003RV-PE; Wed, 26 Jul 2023 21:35:51 -0400 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 1qOpuv-0003RE-My for guix-devel@gnu.org; Wed, 26 Jul 2023 21:35:49 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOput-0007Hr-5v for guix-devel@gnu.org; Wed, 26 Jul 2023 21:35:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 372D3320090A; Wed, 26 Jul 2023 21:35:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 26 Jul 2023 21:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ngyro.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1690421742; x=1690508142; bh=p3 1h6tucFlanDdwHNuN1KeKMoJLRyrWsKl7n9/YrvLY=; b=Ex9cYQmdaJnzhJ1xvY ELb+eOEHxfkt5syOyi3YsczpZYPsUZuJ3MdbyOJPb4IhbiZ79izSRYUmbXiKtk9T q7qOYWbBzi1KAou0oUzGF8OsWrHuTWt9YdAjXf+O4MhecuctG3Zch3d2xiTLVoGA qHbyujwFDEmxovI6jqbJ7BK+uleHA+gwJc0ftOsWOUfLmzv8BcjQdG5aNvL6Hwpj zgWaVTsPH8RYGriKNmsO5vcGubPAmN4HwQNk3furZSP2YotOuKHkcZ/wewQgidff RkvBVWLe96C/ZBph9i/hVhsaT/ffEIuNGMca/PPsGKTR/7WDBOutbRl96zTT6jhf hV9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1690421742; x=1690508142; bh=p31h6tucFlanD dwHNuN1KeKMoJLRyrWsKl7n9/YrvLY=; b=niUrkRTQQbu3Xub4L/8skGSl5zukb yhAUBpDFEVLYBDFUyE2l4Odib1WjwM4yq4VMIVVQ2twblYe55xxfQo6BgkUdxbWg VGk0YEwCkFCeVYqP/ZNJ0YnXIFuOrP7Gi1u+/BX2xwyp6gf2BV7OO3fNa0FohNVX rOrNfCuwiCkSA5y3uft9lwhm4tGcCQn0nFq7Tg8vLg+sVAy1YBBDd+Jyje3ZbS/p BmVh4yWt+DjtQZrEzSx4vqcYUemnxpinjEnVRofVVb0198dEk27NK23qSHTraKmv zNztW3BF16CHyQAyO0AbNG/SRRzxxKoUMkG9zZW+RGCd/Rc02KdGuiH5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrieefgdegjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculddvfedmnecujfgurhephffvvefufhffjgfkfgggtgesmhdtreertder jeenucfhrhhomhepvfhimhhothhhhicuufgrmhhplhgvuceoshgrmhhplhgvthesnhhghi hrohdrtghomheqnecuggftrfgrthhtvghrnhepheeukeffvdegjefhheevfedtiedtvddv vdelheelgffhudffgeffgffffedtgfegnecuffhomhgrihhnpehgnhhurdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhplhgv thesnhhghihrohdrtghomh X-ME-Proxy: Feedback-ID: i4721425c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 26 Jul 2023 21:35:41 -0400 (EDT) From: Timothy Sample To: Fernando Oleo Blanco Cc: Ricardo Wurmus , Denis 'GNUtoo' Carikli , guix-devel@gnu.org Subject: Re: Adding GNAT/GCC-Ada to Guix References: <5e3b0f14-9acf-ae97-1b87-f539917ecd8c@irvise.xyz> <20230716163635.5cc42861@primary_laptop> <87ilajf09o.fsf@elephly.net> <2b47ef4f-49b4-e30e-7b12-c7bc7a2defb0@irvise.xyz> Date: Wed, 26 Jul 2023 19:35:39 -0600 In-Reply-To: <2b47ef4f-49b4-e30e-7b12-c7bc7a2defb0@irvise.xyz> (Fernando Oleo Blanco's message of "Thu, 20 Jul 2023 18:13:59 +0000") Message-ID: <87o7jyi1as.fsf@ngyro.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=64.147.123.19; envelope-from=samplet@ngyro.com; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx2.migadu.com X-Migadu-Spam-Score: 2.26 X-Spam-Score: 2.26 X-Migadu-Queue-Id: B29EC316E2 X-TUID: pTNbBBsiiKvy --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Fernando, Fernando Oleo Blanco writes: > I have talked with some people over at IRC and they recommended the use > of the smaller GCC-Ada/GNAT binaries from Debian (even from older > releases) and try to build an up-to-date Ada compiler toolchain with it. > > However, that would be a lot of work to get going and it may require a > lot of trial and error for it to fully work. [...] I did this five years ago! Attached is a package that constructs a working Ada compiler from Debian 8 (Jessie) binaries. There are also some packages that loosely follow the Guix commencement of GCC (as of five years ago), but include GNAT. Cf. https://logs.guix.gnu.org/guix/2018-09-04.log#165534 I just tested building =E2=80=98gnat-debian=E2=80=99 and =E2=80=98gnat-boot= 0=E2=80=99. They still work! The former is GCC 4 and the latter is (now) GCC 11. I also built a basic Ada program with =E2=80=98gnat-boot0=E2=80=99. The rest of it may or= may not work. The =E2=80=98gnat-5=E2=80=99 package is no longer appropriate, obvio= usly. :) I hope that helps. FWIW, I still think Debian is the best option here for a bootstrapping binary. Ada-Ed and old GNAT are the most likely option for proper bootstrapping. I found a yacc and lex grammar for Ada 95, too, but I can=E2=80=99t remember if it is freely licensed. It could be used to bridge the gap between Ada-Ed and old GNAT (maybe). -- Tim --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=ada.scm Content-Transfer-Encoding: quoted-printable ;;; Copyright =C2=A9 2018 Timothy Sample ;;; SPDX-License-Identifier: GPL-3.0-or-later (use-modules (gnu packages bootstrap) (gnu packages elf) (gnu packages guile) (gnu packages gcc) (gnu packages perl) (guix base16) (guix build-system gnu) (guix download) ((guix licenses) #:prefix license:) (guix packages) (guix utils) (ice-9 match)) ;;; Debian GNAT bootstrap binary (define %debian-mirror "http://archive.debian.org/debian") (define (debian-url source name version) (string-append %debian-mirror "/pool/main/" (substring source 0 1) "/" source "/" name "_" version "_amd64.deb")) (define %debian-gcc-packages '(("libasan1" "ea0c7defc2fbbb61f069a5d119a3e3e5c9740f7fafd5214bf3065aa8cb971097") ("libatomic1" "92d74070442f13a2e9403464862e1b0b1bb23992e5157e2ac83cc4ac9f17084a") ("libcilkrts5" "a0d57dd6273ef2366ba8b54669ac147226e24238e40c2c4a39a3e0e2a7eacb99") ("cpp-4.9" "f1b38be5b85df78265bba28dae8987b72904b7d36051703bc1f7e70c55136a91") ("gcc-4.9" "569a2ca8aed7eca54fbb9edae367064bbb0f7f773973e73c72e27fbfc703c3b0") ("libgomp1" "5e4425acbd597a4f091c69e787a9ea16f8bf4442c1dfd795d1ac8669912f2851") ("libitm1" "c005a4b836179ca9aa6ed28d9cb8785a3af6daa222cb55563fcc1edbca081eb4") ("libgcc-4.9-dev" "db89814eb484edf5d9c24a9def334ca1eac22afbfd3f8b23f12262e217ac80ff") ("libgcc1" "3101d5dc171fab3b4601bc3282bbc69f0fb9cfd1e1761389e1e6d2590e384623") ("libstdc++6" "a8f4ef6773b90bb39a8a8a0a5e3e20ca8501de6896204f665eb114d5b79f164f") ("liblsan0" "20caadf3fdd5905618f9933768bdbd79b9c16a26ece2774ad1b38d14329ecdf2") ("libquadmath0" "7e3779d41a42a88621f93c47a77874547b266b7c8166c80e254721e8347c3355") ("libtsan0" "5574f38d9b2f4987b90a70003ea7e60e0b5cab5c7a7c6ac9c2837eb1353e71bf") ("libubsan0" "49f00199613ff3d214c4137a2fe3b43bc3bbee79fa92ed9fb9cd0b0abaaf7c3e"))) (define %debian-gnat-packages '(("gnat-4.9" "0afb887980b819853f04e6c674f1a962836e3f691f14ad2b93af93c432db4bcb") ("libgnat-4.9" "9d6258a9dea4e78d4e6bd9996e00f673f1169df1aa00db713c716f22011b3638") ("libgnatprj4.9" "cadaf3f8d5f150589cbb286ecca07f1cd2f33b2f52675326398c9e1fb3b9aba5") ("libgnatvsn4.9" "227eaf2a40c24c9222e2f658d8b02e24e5f0d82f4c9003f994421c19c13f040d"))) (define %debian-gnat-closure `(("cloog" "libcloog-isl4" "0.18.2-1+b2" "8bb4ba985d65ededbfc24d76d3610af57a70787b635841407558d25a7f06ff49") ("gmp" "libgmp10" "6.0.0+dfsg-6" "155a31b0f716aa3dcd7ee68e9bd57e0b76a6b31f4e41fb2d953e986315437082") ("isl" "libisl10" "0.12.2-2" "5a091cf30221e183d319f4906a746043be7220061f3b742b2ad958ee79ac01f7") ("mpclib3" "libmpc3" "1.0.2-1" "0a252dcf89843ee8b402fd226c8fb552d69c82c7013a28e335ba36878468d959") ("mpfr4" "libmpfr4" "3.1.2-2" "1b6ef16024e7850c4f2d47dbe06cba1143ac36d5584db515f63d5fbd873e3eb2") ("zlib" "zlib1g" "1.2.8.dfsg-2+b1" "b75102f61ace79c14ea6f06fdd9509825ee2af694c6aa503253df4e6659d6772") ("gcc-defaults" "gcc" "4.9.2-2" "b7a60f9bc12d8ac0bbce99160390f28ee4a2d1d94753d123a7016d0443e46518") ("gcc-defaults" "cpp" "4.9.2-2" "e0d777817359da6dd7d003c164f12a55a8b889eb360ba2c945d5316ee7dbefd8") ,@(map (match-lambda ((name hash) `("gcc-4.9" ,name "4.9.2-10+deb8u1" ,hash))) %debian-gcc-packages) ,@(map (match-lambda ((name hash) `("gnat-4.9" ,name "4.9.2-1" ,hash))) %debian-gnat-packages))) (define gnat-debian (package (name "gnat-debian") (version "4.9.2-1") (source #f) (build-system gnu-build-system) (arguments `(#:tests? #f #:strip-binaries? #f #:modules ((ice-9 match) ,@%gnu-build-system-modules) #:phases (modify-phases %standard-phases ;; Instead of a single source archive, we have a bunch of ;; Debian package archives to unpack. (replace 'unpack (lambda* (#:key inputs #:allow-other-keys) (for-each (match-lambda ((name . value) (when (string-suffix? ".deb" name) (invoke "ar" "x" value) (invoke "tar" "xvf" "data.tar.xz")))) inputs) ;; Most of the libraries are in "/usr/lib" but a few are in ;; "/lib". They are easier to work with if consolidated. (copy-recursively "lib" "usr/lib") #t)) ;; There is a symlink to "libgcc_s.so" that uses an absolute ;; path. We need to make it relative. (add-after 'unpack 'fix-libgcc_s-link (lambda _ (with-directory-excursion "usr//lib/gcc/x86_64-linux-gnu/4.9" (delete-file "libgcc_s.so") (symlink "../../../x86_64-linux-gnu/libgcc_s.so.1" "libgcc_s.so")) #t)) ;; This follows the Rust bootstrap binary packages. We need to ;; patch the binaries so that they can find their shared ;; libraries and the dynamic linker. (add-after 'configure 'patch-elves (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (ld-so (string-append (assoc-ref inputs "libc") ,(glibc-dynamic-linker))) (rpath (string-append out "/lib/x86_64-linux-gnu:" (dirname ld-so))) (elves (find-files "." (lambda (file stat) (and (not (string-suffix? ".o" fil= e)) (elf-file? file)))))) (for-each (lambda (elf) (format #t "Setting RUNPATH for ~a~%" elf) (invoke "patchelf" "--set-rpath" rpath elf) (when (with-output-to-port (%make-void-port "w") (lambda () (zero? (system* "patchelf" "--print-interpreter" elf)))) (format #t "Setting interpreter for ~a~%" elf) (invoke "patchelf" "--set-interpreter" ld-so e= lf))) elves) #t))) (delete 'configure) (delete 'build) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (copy-recursively "usr" out) #t))) ;; Tthe easiest way to ensure that GNAT uses Guix's dynamic ;; linker is to wrap the "collect2" program and modify its ;; arguments. Normally, one would use LDFLAGS to set it, but ;; this doesn't propagate through the GNAT tools (e.g., ;; "gnatmake"). (add-after 'install 'wrap-collect (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (string-append (assoc-ref outputs "out"))) (collect2 (string-append out "/lib/gcc/" "x86_64-linux-gnu/4.9/" "collect2")) (ld-so (string-append (assoc-ref inputs "libc") ,(glibc-dynamic-linker))) (guile (string-append (assoc-ref inputs "guile") "/bin/guile"))) ;; Hide the real "collect2" program. (copy-file collect2 (string-append collect2 "-real")) ;; Write a small script to change the "-dynamic-linker" ;; argument before running the real "collect2". (with-output-to-file collect2 (lambda _ (display (string-append "#!" guile " --no-auto-compile\n!#\n")) (write `(begin (use-modules (ice-9 match)) (define (update-dynamic-linker args) (let loop ((args args) (acc '())) (match args (() (reverse acc)) (("-dynamic-linker" _ . rest) (loop rest (cons* ,ld-so "-dynamic-linker" ac= c))) ((arg . rest) (loop rest (cons arg acc)))))) (apply execl ,(string-append collect2 "-real") (update-dynamic-linker (command-line))))))) #t)))))) (inputs `(("guile" ,guile-2.2))) (native-inputs `(("patchelf" ,patchelf) ,@(map (match-lambda ((source name version hash) `(,(string-append name ".deb") ,(origin (method url-fetch) (uri (debian-url source name version)) (sha256 (base16-string->bytevector hash)))))) %debian-gnat-closure))) (synopsis "GNU Ada compiler") (description "GNAT is a full-featured Ada 2012 compiler.") (home-page "https://gcc.gnu.org/") (license license:gpl3+))) ;;; GNAT commencement (define-public gnat-boot0 (package (inherit gcc) (name "gnat-boot0") (arguments (substitute-keyword-arguments (package-arguments gcc) ((#:configure-flags flags) `(cons "--enable-languages=3Dc,c++,ada" (filter (lambda (flag) (not (string-prefix? "--enable-languages" flag))) ,flags))))) (native-inputs `(("gcc" ,gnat-debian) ,@(package-native-inputs gcc))))) (define gnat-final (package (inherit gnat-boot0) (name "gnat-final") (native-inputs `(("gcc" ,gnat-boot0) ,@(package-native-inputs gcc))))) ;;; GNAT packages ;; XXX: These packages conflict with GCC. Ideally, they would extend ;; GCC, but that may require modifying the GCC package, which is ;; something I would like to avoid (unless it could be merged ;; upstream). It may be possible to wrap `gcc' and use its `-B' flag ;; to find the Ada compiler. Another option could be to make a union ;; package. (define (make-gnat gcc) (package (inherit gcc) (name "gnat") (arguments (substitute-keyword-arguments (package-arguments gcc) ((#:configure-flags flags) `(cons "--enable-languages=3Dc,c++,ada" (filter (lambda (flag) (not (string-prefix? "--enable-languages" flag))) ,flags))))) (native-inputs (cons `("gcc" ,gnat-final) (package-native-inputs gcc))))) (define-public gnat-5 (make-gnat gcc-5)) (define-public gnat gnat-5) (define-public gnat-toolchain (package (inherit ((@@ (gnu packages commencement) make-gcc-toolchain) gnat)) (name "gnat-toolchain"))) --=-=-=--