Gentoo Archives: gentoo-dev

From: Alexis Ballier <aballier@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [EAPI 7] Cross-compile improvements (BDEPEND, BROOT, sysroot)
Date: Wed, 02 Dec 2015 11:40:30
Message-Id: 20151202124008.65063a57@gentoo.org
In Reply to: [gentoo-dev] [EAPI 7] Cross-compile improvements (BDEPEND, BROOT, sysroot) by James Le Cuirot
1 Wow, what a lengthy email :)
2
3 On Tue, 1 Dec 2015 22:58:55 +0000
4 James Le Cuirot <chewi@g.o> wrote:
5 [...]
6 >
7 > I raised one further point with mgorny that he feels could potentially
8 > go into EAPI 7 but I think could remain an implementation detail. In
9 > cases #3 and #4 (basically when ROOT != / and
10 > PORTAGE_CONFIGROOT != /), the toolchain needs to know how to source
11 > headers and libraries from ROOT instead of /.
12
13 Use SYSROOT. ROOT has nothing to do with building. This should be
14 defined in PMS though.
15
16
17 > gcc and friends support a --sysroot argument. It used to be the case
18 > that this didn't work on a toolchain configured without a sysroot,
19 > possibly creating issues for #4, but I've tested and it now works
20 > regardless.
21
22 $ gcc --sysroot=/tmp/foo -I/usr/include foo.c
23 /usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
24 this linker was not configured to use sysroots
25 collect2: error: ld returned 1 exit status
26
27 Two problems here:
28 1. link fails
29 2. gcc doesn't warn for -I/usr/include with sysroot (iirc crossdev's
30 gcc do)
31
32 [...]
33 > CMake supports a CMAKE_SYSROOT argument that you set in the toolchain
34 > file. We currently don't set this but it could easily be added to
35 > cmake-utils.eclass as well as (or instead of?) the similar variables
36 > that we already do set.
37
38 iirc, CMAKE_SYSROOT is only for your case #4 and behaves more like
39 'build as if I had chrooted in CMAKE_SYSROOT' and thus doesn't help at
40 all for cross-compilation
41
42 > The vast majority of configure scripts (using libtool and not ancient)
43 > support a --with-sysroot argument that can easily be detected by
44 > grepping for lt_sysroot. The behaviour of econf is largely defined by
45 > PMS, hence why mgorny thinks this particular detail could go into
46 > EAPI 7, but it only says which arguments must be passed and doesn't
47 > say that the PM can't pass additional ones. I don't wish this force
48 > this stuff upon Paludis and pkgcore unnecessarily.
49
50
51 This could help your case #4. Or, e.g., stage building:
52 https://bugs.gentoo.org/show_bug.cgi?id=563034
53
54 toolchain's sysroot seems way more reliable though
55
56 [...]
57
58 Alexis.

Replies