1 |
Hi list, |
2 |
|
3 |
On Thu, Apr 07, 2016 at 08:43:17PM +0200, Michael Weiser wrote: |
4 |
|
5 |
> As was to be expected, I'm now faced with the fact that all packages I |
6 |
> compile *for* the target and install into ROOT=EPREFIX/usr/CTARGET get |
7 |
> compiled for a Prefix in EPREFIX on the target and thus install into |
8 |
> ROOT/EPREFIX. |
9 |
|
10 |
> Is there a way to build a package in Prefix with ROOT set and EPREFIX |
11 |
> unset? |
12 |
|
13 |
As feedback on this I can report that I now have a prefix on my MacBook |
14 |
Air running OS X 10.11 that is not only able to build and install cross |
15 |
toolchains for arm*-{soft,hard}float-linux-gnueabi, avr and |
16 |
powerpc-unknown-linux-gnu but also cross-compile and merge packages for |
17 |
those targets into $EPREFIX/usr/$CTARGET ready for deployment to an |
18 |
actual system (as of yet untested for real though)! |
19 |
|
20 |
On the embarassing side it turns out that all that was missing was |
21 |
basically a turned on brain on my part: After configuring |
22 |
$EPREFIX/usr/$CTARGET/etc/profile/make.conf and colleagues for the |
23 |
target system and switching to the emerge-$CTARGET wrapper provided by |
24 |
crossdev, it almost worked. Bug |
25 |
https://bugs.gentoo.org/show_bug.cgi?id=586438 gave the final hint of |
26 |
providing --prefix=/ to emerge-$CTARGET to disable all prefix logic for |
27 |
the cross compile target. |
28 |
|
29 |
When actually doing the cross-compiling, about 50% of packages need |
30 |
tweaking to cope with the fact they're configured on a non-Linux system |
31 |
for a Linux system. Most annoyingly, glibc, linux-kernel, linux-headers |
32 |
and in consequence iptables are hit by file name collisions due to |
33 |
filesystem case-insensitivity (e.g. |
34 |
/usr/include/linux/netfilter/xt_DSCP.h vs. xt_dscp.h - whoever thought |
35 |
having those file names and have them include each other (!) was a good |
36 |
idea). |
37 |
|
38 |
Bugs pertaining to cross-compile support in prefix (on OS X): |
39 |
|
40 |
https://bugs.gentoo.org/show_bug.cgi?id=586726: sys-devel/crossdev: prefixify |
41 |
https://bugs.gentoo.org/show_bug.cgi?id=583202: sys-devel/binutils-config: Extend ldwrapper to work with cross-toolchains |
42 |
https://bugs.gentoo.org/show_bug.cgi?id=583210: cross-*/binutils: QA notice invalid self-reference install_name/reference to |
43 |
https://bugs.gentoo.org/show_bug.cgi?id=583216: sys-libs/glibc: Fix cross-compilation in prefix |
44 |
https://bugs.gentoo.org/show_bug.cgi?id=583432: toolchain.eclass: Adjust for cross-compilation in prefixo |
45 |
|
46 |
for reference: |
47 |
https://bugs.gentoo.org/show_bug.cgi?id=583198: cross-arm*/gcc: nesting level exceeded when compiling cross compiler for arm with clang |
48 |
https://bugs.gentoo.org/show_bug.cgi?id=586438: sys-apps/portage: Only enable prefix QA checks when prefix USE flag is active |
49 |
|
50 |
What's still needed is some config in /etc/portage to glue this all |
51 |
together. What I now have looks like this: |
52 |
|
53 |
- inject bracket depth workaround for clang to compile gcc for arm via env snippet |
54 |
- replace kernel and elibc use flags of build system (Darwin) with those for the |
55 |
target (Linux) ones |
56 |
- do not set CC=clang and CXX=clang++ in make.conf but have a bashrc for |
57 |
portage that conditionally sets them based on the target we're compiling |
58 |
for. Also tweak {C,CXX,LD}FLAGS based on the same logic. This is only |
59 |
needed for bootstrapping the cross toolchain because this is done with |
60 |
the build host portage config. Actual emering of packages for the target |
61 |
then uses the separate make.conf in $EPREFIX/usr/$CTARGET. |
62 |
|
63 |
All this should only be needed on OS X (or in a Linux prefix using |
64 |
clang). A prefix on Linux should generally be much more forgiving |
65 |
because build and target systems are much more similar. |
66 |
|
67 |
env/clang-fbracket-workaround: |
68 |
CFLAGS_armv5teb_softfloat_linux_gnueabi="-fbracket-depth=1024" |
69 |
CFLAGS_armv5tejl_softfloat_linux_gnueabi="-fbracket-depth=1024" |
70 |
CFLAGS_armv7ve_hardfloat_linux_gnueabi="-fbracket-depth=1024" |
71 |
CFLAGS_armv7veb_hardfloat_linux_gnueabi="-fbracket-depth=1024" |
72 |
|
73 |
package.env/system |
74 |
cross-armv5teb-softfloat-linux-gnueabi/gcc clang-fbracket-workaround |
75 |
cross-armv5tejl-softfloat-linux-gnueabi/gcc clang-fbracket-workaround |
76 |
cross-armv7ve-hardfloat-linux-gnueabi/gcc clang-fbracket-workaround |
77 |
cross-armv7veb-hardfloat-linux-gnueabi/gcc clang-fbracket-workaround |
78 |
|
79 |
profile/package.use.force/system |
80 |
cross-avr/gcc -kernel_Darwin -elibc_Darwin kernel_linux elibc_glibc |
81 |
cross-armv5tejl-softfloat-linux-gnueabi/gcc -kernel_Darwin -elibc_Darwin kernel_linux elibc_glibc |
82 |
cross-armv5b-softfloat-linux-gnueabi/gcc -kernel_Darwin -elibc_Darwin kernel_linux elibc_glibc |
83 |
cross-armv7ve-hardfloat-linux-gnueabi/gcc -kernel_Darwin -elibc_Darwin kernel_linux elibc_glibc |
84 |
cross-armv7veb-hardfloat-linux-gnueabi/gcc -kernel_Darwin -elibc_Darwin kernel_linux elibc_glibc |
85 |
cross-powerpc-unknown-linux-gnu/gcc -kernel_Darwin -elibc_Darwin kernel_linux elibc_glibc |
86 |
|
87 |
profile/package.use.mask/system |
88 |
cross-avr/gcc -kernel_linux -elibc_glibc kernel_Darwin elibc_Darwin |
89 |
cross-armv5tejl-softfloat-linux-gnueabi/gcc -kernel_linux -elibc_glibc kernel_Darwin elibc_Darwin |
90 |
cross-armv5teb-softfloat-linux-gnueabi/gcc -kernel_linux -elibc_glibc kernel_Darwin elibc_Darwin |
91 |
cross-armv7ve-hardfloat-linux-gnueabi/gcc -kernel_linux -elibc_glibc kernel_Darwin elibc_Darwin |
92 |
cross-armv7veb-hardfloat-linux-gnueabi/gcc -kernel_linux -elibc_glibc kernel_Darwin elibc_Darwin |
93 |
cross-powerpc-unknown-linux-gnu/gcc -kernel_linux -elibc_glibc kernel_Darwin elibc_Darwin |
94 |
|
95 |
You get the idea. bashrc attached. |
96 |
|
97 |
Thanks to everyone who's connected to creating these awesome pieces of |
98 |
software I can grab and glue together into something even more awesome |
99 |
like this. I'm a very happy cross-compiling prefix-camper now. ;) |
100 |
-- |
101 |
bye, Michael |
102 |
Don't panic! |