Mailing List Archive

crossdev, alternate root, and build dependencies
(Originally posted on gentoo-user, but may be more appropriate here)

I am trying to understand and use crossdev to build Gentoo for my
Raspberry Pi, and I have a couple of questions. I was able to
successfully build a toolchain::

crossdev -S -t armv6j-hardfloat-linux-gnueabi

This correctly installed binutils, gcc, glibc, and linux-headers::

equery list cross-armv6j-hardfloat-linux-gnueabi/*
* Searching for * in cross-armv6j-hardfloat-linux-gnueabi ...
[I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/binutils-2.22-r1:0
[I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/gcc-4.5.4:4.5
[I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/glibc-2.15-r3:2.2
[I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/linux-headers-3.6:0

I then copied the configuration from
/usr/armv6j-hardfloat-linux-gnueabi/etc/portage to an alternate
location, so I could modify it without impacting the crossdev toolchain.
Next, I started to emerge some ebuilds into a staging directory using
the following commands::

export CBUILD=$(portageq envvar CHOST)
export PORTAGE_CONFIGROOT=/home/dustin/rpi-build/configroot
export ROOT=/home/dustin/rpi-build/buildroot/
export PORTAGE_TMPDIR=/home/dusitn/rpi-build/tmp
emerge --nodeps baselayout
emerge --onlydeps baselayout

The first pass completed successfully, but the second failed to build
psmisc::

checking for tgetent in -ltinfo... no
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... no
configure: error: Cannot find tinfo, ncurses or termcap libraries

config.log shows this::

configure:3970: checking for tgetent in -lncurses
configure:3995: armv6j-hardfloat-linux-gnueabi-gcc -o conftest -O4
-pipe -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
-fomit-frame-pointer conftest.c -lncurses >&5
/usr/libexec/gcc/armv6j-hardfloat-linux-gnueabi/ld: cannot find
-lncurses
collect2: ld returned 1 exit status
configure:3995: $? = 1

ncurses did get installed in the alternate root::

ls -1 ${ROOT}lib/libncurses*
/home/dustin/rpi-build/buildroot/lib/libncurses.so.5
/home/dustin/rpi-build/buildroot/lib/libncurses.so.5.9
/home/dustin/rpi-build/buildroot/lib/libncursesw.so.5
/home/dustin/rpi-build/buildroot/lib/libncursesw.so.5.9

Now, I've found that if I install ncurses in /usr/${CHOST} instead of
${ROOT}, psmisc will build successfully. I am thus confused on where
things are supposed to be built. The Cross Development Guide says not to
install pieces of the toolchain in /usr/${CHOST}, but some ebuilds, like
openrc, have explicit RDEPENDs on them, so emerge pulls them in. I'm not
sure how to resolve this seeming catch-22 where I can't install runtime
dependencies in /usr/${CHOST}, but I also can't install build
dependencies in in ${ROOT}.

I am hoping to have this process scriptable, so my current method of
just installing missing build dependencies in /usr/${CHOST} after
something fails won't work. Any pointers would be appreciated.

Thanks,

--
♫Dustin
Re: crossdev, alternate root, and build dependencies [ In reply to ]
"Dustin C. Hatch" <admiralnemo@gmail.com> wrote on 2012/12/13 00:43:51:
>
> (Originally posted on gentoo-user, but may be more appropriate here)
>
> I am trying to understand and use crossdev to build Gentoo for my
> Raspberry Pi, and I have a couple of questions. I was able to
> successfully build a toolchain::
>
> crossdev -S -t armv6j-hardfloat-linux-gnueabi
>
> This correctly installed binutils, gcc, glibc, and linux-headers::
>
> equery list cross-armv6j-hardfloat-linux-gnueabi/*
> * Searching for * in cross-armv6j-hardfloat-linux-gnueabi ...
> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/binutils-2.22-r1:0
> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/gcc-4.5.4:4.5
> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/glibc-2.15-r3:2.2
> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/linux-headers-3.6:0
>
> I then copied the configuration from
> /usr/armv6j-hardfloat-linux-gnueabi/etc/portage to an alternate
> location, so I could modify it without impacting the crossdev toolchain.

> Next, I started to emerge some ebuilds into a staging directory using
> the following commands::
>
> export CBUILD=$(portageq envvar CHOST)
> export PORTAGE_CONFIGROOT=/home/dustin/rpi-build/configroot
> export ROOT=/home/dustin/rpi-build/buildroot/
> export PORTAGE_TMPDIR=/home/dusitn/rpi-build/tmp
> emerge --nodeps baselayout
> emerge --onlydeps baselayout
>
> The first pass completed successfully, but the second failed to build
> psmisc::
>
> checking for tgetent in -ltinfo... no
> checking for tgetent in -lncurses... no
> checking for tgetent in -ltermcap... no
> configure: error: Cannot find tinfo, ncurses or termcap libraries
>
> config.log shows this::
>
> configure:3970: checking for tgetent in -lncurses
> configure:3995: armv6j-hardfloat-linux-gnueabi-gcc -o conftest -O4
> -pipe -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
> -fomit-frame-pointer conftest.c -lncurses >&5
> /usr/libexec/gcc/armv6j-hardfloat-linux-gnueabi/ld: cannot find
> -lncurses
> collect2: ld returned 1 exit status
> configure:3995: $? = 1
>
> ncurses did get installed in the alternate root::
>
> ls -1 ${ROOT}lib/libncurses*
> /home/dustin/rpi-build/buildroot/lib/libncurses.so.5
> /home/dustin/rpi-build/buildroot/lib/libncurses.so.5.9
> /home/dustin/rpi-build/buildroot/lib/libncursesw.so.5
> /home/dustin/rpi-build/buildroot/lib/libncursesw.so.5.9
>
> Now, I've found that if I install ncurses in /usr/${CHOST} instead of
> ${ROOT}, psmisc will build successfully. I am thus confused on where
> things are supposed to be built. The Cross Development Guide says not to

> install pieces of the toolchain in /usr/${CHOST}, but some ebuilds, like

> openrc, have explicit RDEPENDs on them, so emerge pulls them in. I'm not

> sure how to resolve this seeming catch-22 where I can't install runtime
> dependencies in /usr/${CHOST}, but I also can't install build
> dependencies in in ${ROOT}.
>
> I am hoping to have this process scriptable, so my current method of
> just installing missing build dependencies in /usr/${CHOST} after
> something fails won't work. Any pointers would be appreciated.

This is the way crossdev works, I too wish one could avoid doing an extra
build into /usr/${CHOST}
One thing to try is adding --sysroot=${ROOT}(or something near that) to
your CFLAGS/LDFLAGS
Please let me know how that work out as I will be going down a similar
route in the foreseeable future.

Jocke
Re: crossdev, alternate root, and build dependencies [ In reply to ]
Don't bother using an alternate sysroot for building.

I would suggest saving a lot of effort and just using the precompiled
libs / headers in a prebuilt stage3 tarball. This one is hot off the
presses:

http://distfiles.gentoo.org/releases/arm/autobuilds/20130103/armv6j-hardfloat-linux-gnueabi/stage3-armv6j_hardfp-20130103.tar.bz2

To avoid overwriting the crossdev bits with the stage3 tarball (not
that it makes a huge difference), do something like this:

$ sudo -s
# mkdir -p /tmp/ARMV6/usr/armv6j-hardfloat-linux-gnueabi
# tar xpvjf stage3-armv6j_hardfp-20130103.tar.bz2 -C
/tmp/ARMV6/usr/armv6j-hardfloat-linux-gnueabi
# for i in binutils gcc glibc linux-headers; do
> tar xpvjf $PKGDIR/cross-armv6j-hardfloat-linux-gnueabi/${i}.tbz2 -C /tmp/ARMV6;
# done
# rsync -avr /tmp/ARMV6/ /
# rm -Rf /tmp/ARMV6/

Voila!

Also, a good tip - always use FEATURES="buildpkg". It will save you a
lot of time.

On Thu, Dec 13, 2012 at 3:54 AM, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> "Dustin C. Hatch" <admiralnemo@gmail.com> wrote on 2012/12/13 00:43:51:
>>
>> (Originally posted on gentoo-user, but may be more appropriate here)
>>
>> I am trying to understand and use crossdev to build Gentoo for my
>> Raspberry Pi, and I have a couple of questions. I was able to
>> successfully build a toolchain::
>>
>> crossdev -S -t armv6j-hardfloat-linux-gnueabi
>>
>> This correctly installed binutils, gcc, glibc, and linux-headers::
>>
>> equery list cross-armv6j-hardfloat-linux-gnueabi/*
>> * Searching for * in cross-armv6j-hardfloat-linux-gnueabi ...
>> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/binutils-2.22-r1:0
>> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/gcc-4.5.4:4.5
>> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/glibc-2.15-r3:2.2
>> [I-O] [ ] cross-armv6j-hardfloat-linux-gnueabi/linux-headers-3.6:0
>>
>> I then copied the configuration from
>> /usr/armv6j-hardfloat-linux-gnueabi/etc/portage to an alternate
>> location, so I could modify it without impacting the crossdev toolchain.
>
>> Next, I started to emerge some ebuilds into a staging directory using
>> the following commands::
>>
>> export CBUILD=$(portageq envvar CHOST)
>> export PORTAGE_CONFIGROOT=/home/dustin/rpi-build/configroot
>> export ROOT=/home/dustin/rpi-build/buildroot/
>> export PORTAGE_TMPDIR=/home/dusitn/rpi-build/tmp
>> emerge --nodeps baselayout
>> emerge --onlydeps baselayout
>>
>> The first pass completed successfully, but the second failed to build
>> psmisc::
>>
>> checking for tgetent in -ltinfo... no
>> checking for tgetent in -lncurses... no
>> checking for tgetent in -ltermcap... no
>> configure: error: Cannot find tinfo, ncurses or termcap libraries
>>
>> config.log shows this::
>>
>> configure:3970: checking for tgetent in -lncurses
>> configure:3995: armv6j-hardfloat-linux-gnueabi-gcc -o conftest -O4
>> -pipe -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
>> -fomit-frame-pointer conftest.c -lncurses >&5
>> /usr/libexec/gcc/armv6j-hardfloat-linux-gnueabi/ld: cannot find
>> -lncurses
>> collect2: ld returned 1 exit status
>> configure:3995: $? = 1
>>
>> ncurses did get installed in the alternate root::
>>
>> ls -1 ${ROOT}lib/libncurses*
>> /home/dustin/rpi-build/buildroot/lib/libncurses.so.5
>> /home/dustin/rpi-build/buildroot/lib/libncurses.so.5.9
>> /home/dustin/rpi-build/buildroot/lib/libncursesw.so.5
>> /home/dustin/rpi-build/buildroot/lib/libncursesw.so.5.9
>>
>> Now, I've found that if I install ncurses in /usr/${CHOST} instead of
>> ${ROOT}, psmisc will build successfully. I am thus confused on where
>> things are supposed to be built. The Cross Development Guide says not to
>
>> install pieces of the toolchain in /usr/${CHOST}, but some ebuilds, like
>
>> openrc, have explicit RDEPENDs on them, so emerge pulls them in. I'm not
>
>> sure how to resolve this seeming catch-22 where I can't install runtime
>> dependencies in /usr/${CHOST}, but I also can't install build
>> dependencies in in ${ROOT}.
>>
>> I am hoping to have this process scriptable, so my current method of
>> just installing missing build dependencies in /usr/${CHOST} after
>> something fails won't work. Any pointers would be appreciated.
>
> This is the way crossdev works, I too wish one could avoid doing an extra
> build into /usr/${CHOST}
> One thing to try is adding --sysroot=${ROOT}(or something near that) to
> your CFLAGS/LDFLAGS
> Please let me know how that work out as I will be going down a similar
> route in the foreseeable future.
>
> Jocke
>
>