From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: riscv cross toolchain - C_INCLUDE_PATH Date: Mon, 02 Jan 2017 22:24:27 +0100 Message-ID: <87o9zp9mus.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOA5p-0005l8-Tz for guix-devel@gnu.org; Mon, 02 Jan 2017 16:24:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOA5m-0001bD-Pc for guix-devel@gnu.org; Mon, 02 Jan 2017 16:24:33 -0500 In-Reply-To: (David Craven's message of "Fri, 30 Dec 2016 19:52:52 +0100") 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+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: David Craven Cc: guix-devel Hi! David Craven skribis: > I'm trying to build a riscv cross toolchain. Why do I have to reset > C_INCLUDE_PATH to get glibc to build? It seems to me that all the > cross packages shouldn't be in the C_INCLUDE_PATH. Some insight would > be greatly appreciated. > > export C_INCLUDE_PATH=3D"/gnu/store/sjg2km4jy29wbwpisaab8z0jl5h9v9mn-risc= v-glibc-2.24.90-1.e84d3a5-checkout/include:/gnu/store/7nqgj7nz2ypl7dwmjkx0h= swbjf0w1a63-gcc-cross-sans-libc-riscv64-unknown-linux-gnu-6.1.0-1.287c5cb/i= nclude:/gnu/store/pd7w87bjcq2n4dr481gk14d4y1p2iiaz-binutils-cross-riscv64-u= nknown-linux-gnu-2.27-1.8c5f683/include:/gnu/store/zpkwh5b3b3hrlpckdpb0givg= qg5rf8gn-gettext-minimal-0.19.8.1/include:/gnu/store/d5nscny560slzpljixqzim= 6b8ms7hhv2-bzip2-1.0.6/include:/gnu/store/4yg6q1kp856m68arkpqc85hqgbffhpxf-= xz-5.2.2/include:/gnu/store/06icf5h4z83mw5g17a58fy26z14dsj9z-file-5.28/incl= ude:/gnu/store/k03y1lfaj1xw0d7j2lxdil8ii5c67fdy-gawk-4.1.4/include:/gnu/sto= re/c5ihjcdxsm9086323bn2j67v7z34lc1a-make-4.2.1/include:/gnu/store/4xxd00drj= 8gjcr84xdfna44qak2vhwmf-binutils-2.27/include:/gnu/store/y1g6991kxvdk4vxhsq= 07r5saww30v8dq-gcc-4.9.4/include:/gnu/store/iwgi9001dmmihrjg4rqhd6pa6788prj= w-glibc-2.24/include:/gnu/store/p1qnhavlg6d9mgv6569c8pici37v2dak-linux-libr= e-headers-cross-riscv64-unknown-linux-gnu-4.4.18/include:/gnu/store/jc898ps= n5yc9s328nn8fya3sc2daf037-linux-libre-headers-4.4.18/include" > > (define-public (riscv-cross-glibc target) > (let ((glibc (cross-libc target > (riscv-cross-gcc target) > (riscv-cross-binutils target) > (riscv-cross-kernel-headers target))) > (commit "e84d3a58c42e29cc162efa0446bb0a1e3554dde4") > (revision "1")) > (package > (inherit glibc) > (version (string-append "2.24.90-" revision "." > (string-take commit 7))) > (source (origin > (method git-fetch) > (uri (git-reference > (url "https://github.com/riscv/riscv-glibc") > (commit commit))) > (file-name (string-append "riscv-glibc-" version "-checko= ut")) > (sha256 > (base32 > "0pbg4f7y7l5kwvb6z8c7s6cp8nrypkvz6cgcc2m03k671p1zwgpi")= ))) > (arguments > (substitute-keyword-arguments (package-arguments glibc) > ((#:configure-flags configure-flags) > `(cons "--disable-werror" ,configure-flags)) > ((#:phases phases) > `(modify-phases ,phases > (add-before 'build 'reset-c-include-path > (lambda* (#:key inputs #:allow-other-keys) > (setenv "C_INCLUDE_PATH" > (string-append (assoc-ref inputs "kernel-headers= ") > "/include"))))))))))) =E2=80=98cross-libc=E2=80=99 in cross-base.scm does that dance too, but tha= t=E2=80=99s because it=E2=80=99s a =E2=80=9Cspecial case.=E2=80=9D In GNU terminology, there=E2=80=99s the =E2=80=9Cbuild=E2=80=9D, =E2=80=9Ch= ost=E2=80=9D, and =E2=80=9Ctarget=E2=80=9D. However, Guix only knows of =E2=80=9Csystem=E2=80=9D and =E2=80=9Ctarget=E2=80=9D (a= nd input/native-input, and search-paths/native-search-paths). So to build the cross-toolchain we need this special hack, which is admittedly ugly. (guix build-systems) has a comment on this, in the definition of . The initial thought was that we don=E2=80=99t need to expose build/host/tar= get at the package level, and that native/target is enough. Suggestions are welcome though! Thanks, Ludo=E2=80=99.