Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 446204

Summary: sys-devel/crossdev: cross-emerge: support multiple parallel SYSROOTs for a single target
Product: Gentoo Linux Reporter: Ambroz Bizjak <ambrop7>
Component: [OLD] Core systemAssignee: Gentoo Crossdev team <crossdev>
Status: UNCONFIRMED ---    
Severity: enhancement CC: embedded, rafallalik, slyfox, steev, zerochaos
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: cross-emerge-ng
toolchain-wrapper
crossdev-20120721-cross-emerge-ng.patch
cross-emerge-ng
toolchain-wrapper
crossdev-20120913-cross-emerge-ng.patch
cross-emerge-ng
toolchain-wrapper

Description Ambroz Bizjak 2012-12-06 02:45:29 UTC
Currently, by the official cross-compiling documentation for Gentoo, cross-compiled packages end up in /usr/CHOST.

- There is already a libc (and linux-headers) present there, so it is impossible to build a libc the usual way. This libc is package-managed as part of the host, not the target. Effectively, it is impossible to update it from a binary package after the target is deployed.

- If somebody wants a clean start, "rm -rf /usr/CHOST" will also remove toolchain components and crossdev will have to be run again.

- It is not possible to keep more than one cross-root for the same platform.

All this can be solved if the target system is built into a folder separate from /usr/CHOST. However, to do that, gcc and g++ have to be called with "--sysroot <target_root>". This is required to make the compiler/linker look for header/library files within the target root, instead of /usr/CHOST.

Because of the significant number of packages that ignore CFLAGS or LDFLAGS, a compiler wrapper which takes care of --sysroot is very useful. So, my cross-emerge-ng tool does the following:

1. Sets CBUILD, ROOT and PORTAGE_CONFIGROOT (to be used by emerge and ebuilds).
2. Sets CROSS_CHOST. This tells the compiler wrappers which cross-compilers they're supposed to call. (if the wrapper just read CHOST, it would break a package changes CHOST, which is not unexpected)
3. Sets CC and CXX to the compiler wrappers (chost-gcc and chost-g++).

Compared to the existing "cross-emerge" tool (which cannot wrap compilers), "cross-emerge-ng" does not do anything else than mentioned above (and which I have found unnecessary).

Note that cross-emerge-ng originated as part of the cross-compile overlay+instructions which I maintain ( http://code.google.com/p/ambro-cross-overlay/ ). It is very useful at this point; it is possible to cross-compile a complete @system and many other packages.

Reproducible: Always
Comment 1 Ambroz Bizjak 2012-12-06 02:47:21 UTC
Created attachment 331622 [details]
cross-emerge-ng

The cross-emerge-ng tool itself, goes into wrappers/ in crossdev source.
Comment 2 Ambroz Bizjak 2012-12-06 02:47:48 UTC
Created attachment 331624 [details]
toolchain-wrapper

The toolchain wrapper, goes into wrappers/ as well.
Comment 3 Ambroz Bizjak 2012-12-06 02:48:21 UTC
Created attachment 331626 [details, diff]
crossdev-20120721-cross-emerge-ng.patch

Makefile patch to install the new tools.
Comment 4 Rick Farina (Zero_Chaos) gentoo-dev 2012-12-06 05:04:15 UTC
Steev and I don't get enough email
Comment 5 SpanKY gentoo-dev 2012-12-06 06:02:38 UTC
relying on the env to not change won't help you.  cmake and other packages will clear the environment automatically thus nuking CROSS_CHOST.
Comment 6 Ambroz Bizjak 2012-12-06 12:47:41 UTC
(In reply to comment #5)
> relying on the env to not change won't help you.  cmake and other packages
> will clear the environment automatically thus nuking CROSS_CHOST.

I haven't seen a single package do this. It works for cmake packages all right.
Comment 7 SpanKY gentoo-dev 2012-12-06 18:11:42 UTC
(In reply to comment #6)

sorry, i meant scons, not cmake.  the point still stands -- relying on the environment is not going to work.
Comment 8 Ambroz Bizjak 2012-12-06 22:11:29 UTC
Created attachment 331686 [details]
cross-emerge-ng

This updated cross-emerge-ng automatically generates wrappers into SYSROOT/etc/crossdev-target with hardcoded CHOST and SYSROOT.

Note that I wish that cross-emerge-ng exists a separate tool intended to be used only with standalone SYSROOT (!=/usr/CHOST), instead of adding features  to cross-emerge. For example, cross-emerge currently calls emerge with --root-deps=rdeps, which will ignore all build-time dependencies. I should say again that cross-emerge-ng, together with the fixes in my overlay, can successfully build the entire @system and many other packages.
Comment 9 Ambroz Bizjak 2012-12-06 22:11:51 UTC
Created attachment 331688 [details]
toolchain-wrapper
Comment 10 Ambroz Bizjak 2012-12-06 22:14:06 UTC
Created attachment 331690 [details, diff]
crossdev-20120913-cross-emerge-ng.patch
Comment 11 Ambroz Bizjak 2012-12-06 22:14:57 UTC
Created attachment 331692 [details]
cross-emerge-ng

Sorry, posted the wrong file previously.
Comment 12 Ambroz Bizjak 2012-12-06 22:15:24 UTC
Created attachment 331694 [details]
toolchain-wrapper

Sorry, posted the wrong file previously.
Comment 13 SpanKY gentoo-dev 2013-04-18 15:58:17 UTC
*** Bug 466128 has been marked as a duplicate of this bug. ***