From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iIgfAqMKIWIpTgAAgWs5BA (envelope-from ) for ; Thu, 03 Mar 2022 19:36:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0GREO6IKIWIIxAAA9RJhRA (envelope-from ) for ; Thu, 03 Mar 2022 19:36:18 +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 4B65DD8E0 for ; Thu, 3 Mar 2022 19:36:18 +0100 (CET) Received: from localhost ([::1]:38822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqJF-0007JP-BT for larch@yhetil.org; Thu, 03 Mar 2022 13:36:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqJ0-0007Gx-6R for guix-patches@gnu.org; Thu, 03 Mar 2022 13:36:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqIz-0007uv-SA for guix-patches@gnu.org; Thu, 03 Mar 2022 13:36:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nPqIz-0006ZG-Pc for guix-patches@gnu.org; Thu, 03 Mar 2022 13:36:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54239] [PATCH] gnu: Add cross-clang. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 03 Mar 2022 18:36:01 +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: Maxime Devos Cc: 54239@debbugs.gnu.org Received: via spool by 54239-submit@debbugs.gnu.org id=B54239.164633251025177 (code B ref 54239); Thu, 03 Mar 2022 18:36:01 +0000 Received: (at 54239) by debbugs.gnu.org; 3 Mar 2022 18:35:10 +0000 Received: from localhost ([127.0.0.1]:43749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nPqIA-0006Xy-Ad for submit@debbugs.gnu.org; Thu, 03 Mar 2022 13:35:10 -0500 Received: from lepiller.eu ([89.234.186.109]:57062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nPqI8-0006Xp-Jj for 54239@debbugs.gnu.org; Thu, 03 Mar 2022 13:35:09 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id e7eeefda; Thu, 3 Mar 2022 18:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:cc:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=dkim; bh=L45yZPkw/oya oby8/Ot2ZqHGrR+vdZ3EKd18A6CTmjs=; b=hkJvBSlozKiF7ZzW6yyLPU4BUX+W NOhXObftWKYgPxvCsisbrH+Of085pqJyQtH0c3h5LBianMDxN7ji8m+CEMxkig6s BHNngEbapy53iNdGyWaM3O0useazWAWX60HrjdQzPx9LIZezdB/PqBF8v0PNfkqn qyjqO/ey3oY2KDZJ/7SWhgKn0VWIGa+ZclevENNUmhq8nD8qj5BIG3dtHY6Gz4Pc fGWifWcHP+896bka5W8XlnwNo4ef7aivvBeNevsLbtyLAeqtuYd6yMWJRld1Vviu tPiP6Mljs/9pvo4JNpidRHo44oRArkDcZ1Jga68vfSKMWnNfgqZr8aHXyg== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 2d8b9e22 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Thu, 3 Mar 2022 18:35:05 +0000 (UTC) Date: Thu, 3 Mar 2022 19:35:03 +0100 From: Julien Lepiller Message-ID: <20220303193503.4c055cec@tachikoma.lepiller.eu> In-Reply-To: <70c3446488f9b76479f4f989c351403c461369d1.camel@telenet.be> References: <20220303170252.3caec0a6@tachikoma.lepiller.eu> <70c3446488f9b76479f4f989c351403c461369d1.camel@telenet.be> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=1646332578; 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: content-transfer-encoding:content-transfer-encoding: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=zSEEvGn4ZS2y7LoWTkn0KlfEHZV5RuwoYCMD+9wfCzg=; b=jdZauKvzYO6VhmPs/V3Fh54MJh5A7RztJiVh+YbV21VLHZJ3+4jP2wBM89CGZA8AZ0yZOU 0YjEBU03PimAbYpgmkz0wbk0OSYqFF3nnwudlBCta11ueWizODngcMuFrUP7+JRiacaQQQ RMag7DX7RqhQz94P2t9/9Zk4bKV44TKXngofySZubH6nkAba3o3AsCmmJHCVmUQ+J404pf Hc13J4zqt3ezSQ+ju9Z7N+4iPrEt7esjK8TzTTEHqJBcomZVtlQC+WmzLxl3h+nLaLyxni ciIKOdixQ8xcuDEOXMqbjJVd8ogO12DgKZPOzqFyiNJD07U4Kj2Qx4w/GNtEkw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646332578; a=rsa-sha256; cv=none; b=PgVWTJyTOTnDq00FVxhRBbM0Bu37PRc40v48j4uRhDmkeXB6m55LONs5Yy7p9hADiVmms3 0VBMyJl/6BzS/ZV7l+xZkAEPuDqI7Bdo5oayypLWTuNaVlvAnofCiTPlgdZvAxXzBOa6h5 Ro686mZG00YEjnyOm7puMvk5kyPhyH1J72Qmbo3OiJVUxE4+gpvGTqMEaLI1spJjP26rPV Fw8pi7+wA/TbPzJtowMqzV8irL+tIUz2dNcXmjlIFYwIe1IsF9c7XGII2Yj5qzWxQpOa2E 5bSPp6H5xZU7jhTuj5N3eUa6EaWch3JV6OTUIjSn8VSsNtu6VNgK8gs7DZHsuQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=hkJvBSlo; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (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: 5.54 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=hkJvBSlo; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (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: 4B65DD8E0 X-Spam-Score: 5.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: qR09xSvGkz8/ Le Thu, 03 Mar 2022 17:40:36 +0100, Maxime Devos a =C3=A9crit : > Julien Lepiller schreef op do 03-03-2022 om 17:02 [+0100]: > > Hi Guix! > >=20 > > This small patch series adds cross-clang, a cross-compiler version > > of clang. Clang doesn't really make a distinction between a native > > and a cross-build, it is already a cross-compiler, but this ensures > > that: > >=20 > > 1. it actually works > > 2. it targets (%current-target-architecture) by default =20 >=20 > Do you mean (%current-target-system)? yes, that's what I meant. >=20 > Also, WDYT of making 'cross-clang' a memoising procedure, such > that there's only one package object for a cross-clang of a fixed > target system (and version)? I don't know how to do that. Are there some examples around? >=20 > > (native-inputs > > - (list clang llvm)) > > + (list (if (%current-target-system) > > + (cross-clang (%current-target-system) #:clang > > clang-9) > > + clang-9))) =20 >=20 > Probably a few other packages built with clang need such a thing as > well. How about making doing the right thing a bit easier? > Suggestion: introduce a 'clang-for-target' procedure, automatically > returning the right clang: >=20 > (define (clang-for-target #:optional (clang clang)) > (if (%current-target-system) > (cross-clang [...]) > clang)) ; not cross-compiling >=20 > then packages just need to do >=20 > (native-inputs (list (clang-for-target) libfoo libbar ...)) Great idea, I implemented that procedure. >=20 > The rest of the series ensures that libcxx and libcxxabi can be > cross-compiled with it. >=20 > Customarily, cross-compilers are named $TARGET-foo. WDYT of > renaming the clang binary to '$TARGET-clang', such that a package > can have both a native clang and a cross-clang in native-inputs if > desired? Also, Autoconf looks for $TARGET-compiler, where compiler is > at least gcc, but possibly also clang >=20 > And perhaps the package name can be changed '$TARGET-clang' like done > for gcc? I can do that, but I don't think it'll be recognized by cmake. It's building right now, and I'll have a try. > > + ;; Support the same variables as clang, even in cross-compilation > > + ;; context. > > + ;; Clang does not make a difference between native and > > + ;; cross-compilation. =20 >=20 > Upstream clang doesn't, but this is in a 'cross-clang' procedure, > so I think it would make sense for Guix' cross-clang to ignore > LIBRARY_PATH and only use CROSS_LIBRARY_PATH. Mixing up > C_INCLUDE_PATH and CROSS_C_INCLUDE_PATH (& friends) is unlikely > to lead anything good, e.g. include/bits/setjmp.h is > architecture-dependent. >=20 OK, fixed. > > + (files '("lib" "lib64")))) =20 >=20 > I don't think Guix does a "lib" / "lib64" split, "lib" might > be sufficient. At least, there are a few comments like >=20 > ;; Force powerpc libdir to be /lib and not /lib64 >=20 > in Guix (though the gcc packages still includes "lib64" but > maybe that's only due to historical reasons). I saw that in GCC, so I just used the same specification, but just '("lib") is fine with me. Fixed. > How does this patch series interact with 'with-c-toolchain'? > Would "guix build hello --target=3Daarch64-linux-gnu > --with-c-toolchain=3D..." succesfully compile 'hello' with clang? It won't work, just like it doesn't work for gcc-toolchain. When you do (without my patches): guix build hello --with-c-toolchain=3Dhello=3Dclang-toolchain --target=3Di686-unknown-linux-gnu it builds, but that's because --with-c-toolchain replaces "gcc" (and friends), but the cross package uses "cross-gcc". guix build hello --with-c-toolchain=3Dhello=3Dgcc-toolchain@7 --target=3Di686-unknown-linux-gnu also builds, but uses the latest gcc instead of gcc-toolchain@7. Will send v2 shortly, after I've tested the rename works. > Greetings, > Maxime.