From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sP1HAIh2I2JqIQAAgWs5BA (envelope-from ) for ; Sat, 05 Mar 2022 15:41:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id qNZqNId2I2LBCgAAG6o9tA (envelope-from ) for ; Sat, 05 Mar 2022 15:41:11 +0100 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 6396E40985 for ; Sat, 5 Mar 2022 15:41:11 +0100 (CET) Received: from localhost ([::1]:57000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQVao-0004sI-03 for larch@yhetil.org; Sat, 05 Mar 2022 09:41:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQVag-0004rw-Sb for guix-patches@gnu.org; Sat, 05 Mar 2022 09:41:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nQVag-0007Du-Jp for guix-patches@gnu.org; Sat, 05 Mar 2022 09:41:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nQVag-0005Ds-Ab for guix-patches@gnu.org; Sat, 05 Mar 2022 09:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54239] [PATCH v2 1/5] gnu: Add cross-llvm. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 05 Mar 2022 14:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54239 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Julien Lepiller Cc: 54239@debbugs.gnu.org X-Debbugs-Original-Cc: 54239@debbugs.gnu.org, guix-patches@gnu.org Received: via spool by 54239-submit@debbugs.gnu.org id=B54239.164649125920060 (code B ref 54239); Sat, 05 Mar 2022 14:41:02 +0000 Received: (at 54239) by debbugs.gnu.org; 5 Mar 2022 14:40:59 +0000 Received: from localhost ([127.0.0.1]:47511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nQVaZ-0005DJ-BF for submit@debbugs.gnu.org; Sat, 05 Mar 2022 09:40:59 -0500 Received: from mout.gmx.net ([212.227.17.21]:41823) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nQVaW-0005D6-Rb for 54239@debbugs.gnu.org; Sat, 05 Mar 2022 09:40:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1646491245; bh=VmP/JBM+/jGg5P4hZo2pw5KH6RW3QDO5KxkaouPr960=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:Date:In-reply-to; b=iGkWGm3Yry/oIhGdNwRMkVl81xHJwGVvcijyTFM5wSuzEuII+SiS902XGRhkUBpdp I3J3jd8eWIe6Io7sPKdskJLNUI4NB5AlJ0y//q5yzQPC++1RaOY7vvfMaKhEZboRFk 9b2p6m3SVik7GdxoPVUpPh8KoDY2pCnZgkkDI5zE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from labiere ([82.69.64.142]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MnJhU-1ns6cz01Ey-00jHd7; Sat, 05 Mar 2022 15:40:45 +0100 References: <20220303170252.3caec0a6@tachikoma.lepiller.eu> <499e5dba47ef40df93a8b33fbb8e41cc2354e7a1.1646387919.git.julien@lepiller.eu> User-agent: mu4e 1.6.10; emacs 27.2 From: Pierre Langlois Date: Sat, 05 Mar 2022 14:00:32 +0000 In-reply-to: <499e5dba47ef40df93a8b33fbb8e41cc2354e7a1.1646387919.git.julien@lepiller.eu> Message-ID: <87zgm4ihsp.fsf@gmx.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Provags-ID: V03:K1:DX8VOw0tY3VDGTgdEuW0thJjp33yKxjaRyQg8Uj+hSi73wtjKq9 Wy6FGaNORACpPICwhdL6xeWkZcxL+9lWsKiME94PRBAdyt7mZJHUuiWwNIhLcYdzArCmPFP IEzlC9ts9SbCuxDsBHC6lFXyCNNujCkpqQgEJ146Zo2U2P3+eImn1ndrHEIXoSM6ZcS41m4 qxaVuP6ShvjQcXR+th3NA== X-UI-Out-Filterresults: notjunk:1;V03:K0:Lq/HQuYhqTw=:D5usQUaCyejWn+fg6eAxkO BrOniLlp6NAVv+yhb9R8iGwU6yt4P3YQJg7dlaseLUZefvvXagt0yfeyTaOD61i/LFN2HpB4e 8nSUEC9+Pqy2TfftRFrJNLzpFS21zCmvTK2zqWTP6CXvYOYtN6txsRl0EAVyWVISh+8p1koyf 3nf2gjq4KIkc075unDzlgsZrszBdYaZX+kDmHzrT+2YizbkgABoL0A7mp8mqSluTWIEfWzXq5 miZd5kQuRUuQ2QeOlOvBaO045iOADje/ITVmp+QDG5A+865iKyHNGHHHr6gPd+i4VCXlFJ1Pp KxgHigK+Qm7zKwHwJv64SIo23ZmsySRszdjr/WkQfkvzQ1f9Enh9W6wKZXR9z+xT1PX0WXUZ1 WnjxmMNP28bRta6kIFyIF4M5jfxJO9+f89wzhk925d5y8B+9arkf4QOizXIQyL1DFnNvUhI35 23vRyLks6phq8MksTZ3/Oay7ie/tjuWNBCLqDCIMSmHNVVQECkI5xbtiNKeb1G+RPi8b/a3k8 3FuGnQEY3G3oXrQAVYZXefXYoUmCg0V6E92+/6ClE9CU/P5BUrbxcszNKjGhCb0OyY+dtYa0a DQbzLWMD6OZ5RejhLDQJyklXeSNIvyL4At4avCw0wgcHgCgQbYWPut3ARpH2wagyfCBc2Ip+z 8TsAd2UyFNnXaG+TJot2CdpzKj9h4ArfYORRZF3PlwcJlYXXZ5JRIJxM/FZwBkfKtlWaxkXZg YNVxJbYGuB51VJBG8/HrSBa2DC1VYSj+9+cBf2x6D5og0CFUnZJkyoTQrWgy6RGL1wblKbjBX FJO+lJ/auzAy/X64fdcwRlvBQU8JiOrY66/MqQ9B5O2ymBmqpLoiqdAd+li8DfDjLc5+tqSev VyDgWpq2uL36uIpbuUvRdfF7SK6SGRih9pNtzr9lzEc8ezrpyDScjcb+XiNvxKjsn6jyaE0fq 0bF5CsU/Jt2HXeE+yweXz8FVt2I4nh5ZR23aEkiH6ZCb2CucF8V6gCVMK6iY3iAjtHv9vSv3a 5588nqVrpxUwiMQQy0H3NFgQMgKgmVWYDkgVgaSxF7AMmsWTKcVue4zi82zeWYjbb8oQMJlPi n/O/Kr8w5bVhco= 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1646491271; 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:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=LLm5Qu0O04XJ2Z5P4CiJwOSymK9b4o5Hoa2HvE0atm4=; b=U2kQ1dfzUnLrwMkvMF8aSPuNFXgds2TfSew3OE4Eh8LY9sv/K8WD+xUIsMvc6HGB7QmHvZ hu7fSNr6FcqCqdQfvEqGBGAmlLRvhKfQ8dZmnlwD/nC0odCXHH5PJbPsf9X+9qRkt7urRG QiDiuBYWfPCIKOCAf86hLnCUGPB4SJzdDLk4iPGG5OdmoXcRzyQFQ7Xjx5xylH46eVxxs0 KnTmz2jJa6tQi8eMzshEAeibR9oSguE6gmCr0tzbppFLsCHmlpvqDy3TeikA/1UfkkWv2/ Sa5Srukc8AD6/y04EeU9R1sElRHEeHu+hNJRunMnPwaA0O8zbDCvl6pZmaKTsw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646491271; a=rsa-sha256; cv=none; b=plAzcoG5bSDvJgiwgugXyGJpPhvDs0gV8Jg2LDCrm0+/SgD8tjIZJidXlr3e78HZDjXiJZ xiqk6KMc+mJ0JMJuZY0HF3sycMAfryxnZ848xX2JwF0M4gUC7Pla1cdK0CmFXCz0/WqKP1 0qlvSlfYsx4WXFZE+wt752NcbmbIgZbC+TI1GJZrtvbqXN8GVYeU2rfGDwLHFyC86ftRYW XNGl4Snk3HLbY59uet15Tpzxkyce2yQXVh0Hgzu7TbogrGPpwN1wZ1GT11nHxVTzZx53u0 Wla2p6Ki4ikC9OeiUA0TRmD0B1J5WjCdNVzSBkniuEhUP5ZmHUV2hjmRWXao/w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=iGkWGm3Y; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 3.26 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=iGkWGm3Y; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6396E40985 X-Spam-Score: 3.26 X-Migadu-Scanner: scn0.migadu.com X-TUID: pc3BTDkle8qk --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Julien Lepiller writes: > * gnu/packages/llvm.scm (cross-llvm): New variable. > --- > gnu/packages/llvm.scm | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm > index eb949bed1b..d6e9846699 100644 > --- a/gnu/packages/llvm.scm > +++ b/gnu/packages/llvm.scm > @@ -18,7 +18,7 @@ > ;;; Copyright =C2=A9 2020 Jakub K=C4=85dzio=C5=82ka > ;;; Copyright =C2=A9 2021 Maxime Devos > ;;; Copyright =C2=A9 2020, 2021 Maxim Cournoyer > -;;; Copyright =C2=A9 2021 Julien Lepiller > +;;; Copyright =C2=A9 2021, 2022 Julien Lepiller > ;;; Copyright =C2=A9 2021 Lars-Dominik Braun > ;;; Copyright =C2=A9 2021 Guillaume Le Vaillant > ;;; Copyright =C2=A9 2021 Maxim Cournoyer > @@ -74,7 +74,8 @@ (define-module (gnu packages llvm) > #:use-module (srfi srfi-1) > #:use-module (ice-9 match) > #:export (make-lld-wrapper > - system->llvm-target)) > + system->llvm-target > + cross-llvm)) >=20=20 > (define* (system->llvm-target #:optional > (system (or (and=3D> (%current-target-syst= em) > @@ -99,6 +100,22 @@ (define* (system->llvm-target #:optional > ("i686" =3D> "X86") > ("i586" =3D> "X86")))) >=20=20 > +(define (cross-llvm llvm target) > + "Return a native LLVM package that targets a different system. The re= sulting > +libraries are running on the host but target a different system by defau= lt. > +This packge can be used to control clang's default target." > + (package > + (inherit llvm) > + (arguments > + (substitute-keyword-arguments (package-arguments llvm) > + ((#:configure-flags flags) > + #~(append > + (list > + (string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=3D" #$target) > + (string-append "-DLLVM_TARGET_ARCH=3D" > + #$(system->llvm-target (gnu-triplet->nix-sys= tem target)))) While playing with trying to use this series to build a WebAssembly cross-compiler, I /think/ we have a bug here, and also in master, when it comes to setting LLVM_TARGET_ARCH. It's a bit confusing though, the documentation is as follows: =2D-8<---------------cut here---------------start------------->8--- LLVM_TARGET_ARCH:STRING LLVM target to use for native code generation. This is required for JIT generation. It defaults to =E2=80=9Chost=E2=80=9D, meaning that it = shall pick the architecture of the machine where LLVM is being built. If you are cross-compiling, set it to the target architecture name. =2D-8<---------------cut here---------------end--------------->8--- It's not clear what naming scheme the variable needs, is it the internal LLVM target name or the triplet? I think it's architecture part of the triplet...ish? But instead we pass it the internal target name. It still works at the moment because whenever LLVM_TARGET_ARCH is used, the cmake code looks quite permissive and tries to do the right thing by turning the string lowercase and matching common names (hence the "...ish" = :-) ). https://github.com/llvm/llvm-project/blob/24f88f57de588817bd21e799e2ac1069c= 025674c/llvm/cmake/config-ix.cmake#L420 So if I try and add WebAssembly into the mix, the architecure name is wasm32, but the LLVM target is called WebAssembly, and the lowercase version of it doesn't work :-(=20 | nix-system | LLVM target | LLVM target lowercase | Does it match? | |------------+-------------+-----------------------+----------------| | aarch64 | AArch64 | aarch64 | Y | | armhf | ARM | arm | Y | | mips64el | Mips | mips | Y | | powerpc | PowerPC | powerpc | Y | | riscv | RISCV | riscv | Y | | x86_64 | X86 | x86 | Y | | i686 | X86 | x86 | Y | | i586 | X86 | x86 | Y | |------------+-------------+-----------------------+----------------| | wasm32 | WebAssembly | webassembly | N :-( | I /think/ we might want to use the nix-system instead of the LLVM target for LLVM_TARGET_ARCH: =2D-8<---------------cut here---------------start------------->8--- (string-append "-DLLVM_TARGET_ARCH=3D" #$(gnu-triplet->nix-system target))) =2D-8<---------------cut here---------------end--------------->8--- But I'm not sure, it might not work for mips64el for example, so we could need yet-another-mapping. Given it works as it is today with the current set of supported targets, we don't necessarily need to fix it now. I'll be happy to take a look later when eventually adding support for the wasm32-wasi toolchain in Guix. Thanks, Pierre --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmIjdmYYHHBpZXJyZS5s YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UCOwH/jFKIRa8Xi5gwAvaxu5HhC7c XXWlEvz2rhfikOzU7TvNHTGXNBKu6Zhy0a+k3uN9hyYIYSdSi2cr2ZSjUDNYtefc QekS48AyA17prUiK1kw9Hx+0ulV2uI2e6USl7aYPZ7NvZ4Necx6S1sGQze1oEdyj m2uJagH6EQbELDq9fqzmdP2lLWhtTMFHnVJdA8/gN8pIycwehELSOQJ4pVhuNStq cu97BefLhFUuNERTF0n2TxAgd1qwqBI2GwaT7dHBZNUhpVsoMQs6nQge2DakSx8V jinX424tCaHONpL0RBwZsvyhfh3FF42U+i7FUph+rKZrXVUhn37Qu7lhrvDJTh8= =/iOv -----END PGP SIGNATURE----- --=-=-=--