Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 01-27-2011, 03:59 PM   #1
Registered: Nov 2009
Posts: 35

Rep: Reputation: 0
cross compiling for arm with buildroot

this is my first attempt at cross compiling. I'm trying to build some boot and kernel images for my WD Mybook world edition, which uses an arm processor on my x86_64 host box. Ultimately i'd like to install slackarm. Lilo doesn't work on arm so you have to compile your own kernel and have the bootloader statically linked to kernel inorder to boot the OS. So i'm using my slackware install to cross compile the boot loaders (u-boot) and kernel image (uImage).

I've successfully compiled the buildroot environment which has generated the arm-linux-* binaries, eg, gcc 3.4.2 for arm.
arm-linux-gcc-3.4.2 -> arm-linux-uclibc-gcc-3.4.2*
these are in a build folder (shortened in text below), which i add to my PATH
# add buildroot tools to PATH
nick@slackbox:/path/to/buildroot/build_arm_nofpu/staging_dir/bin$ PATH=$PWD:$PATH
nick@slackbox:/path/to/buildroot/build_arm_nofpu/staging_dir/bin$ echo $PATH
I then move to the directory where i want to build the stage1 boot loader, which is supplied in the GPL code from WD.

# move to stage1 dir
cd /path/to/build/stage1
# build using buildroot binaries
make CROSS_CoMPILE=arm-linux-
however the build fails with a segfault, which looks to be caused by the incorrect libraries and compiler being used:

......lots of lines..........
COLLECT_GCC_OPTIONS='-c' '-v' '-g' '-I' '.' '-I' '../include' '-o' 'update_header.o' '-mtune=generic'
gcc crc32.o -lc -v update_header.o -o update_header
Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/specs
Target: x86_64-slackware-linux
Configured with: ../gcc-4.4.4/configure --prefix=/usr --libdir=/usr/lib64 --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,java,objc --enable-threads=posix --enable-checking=release --with-system-zlib --with-python-dir=/lib64/python2.6/site-packages --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --disable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 4.4.4 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'update_header' '-mtune=generic'
 /usr/libexec/gcc/x86_64-slackware-linux/4.4.4/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ -o update_header /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/crtbegin.o -L/usr/lib64/gcc/x86_64-slackware-linux/4.4.4 -L/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../x86_64-slackware-linux/lib -L/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../.. crc32.o -lc update_header.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/crtend.o /usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../lib64/crtn.o
make[1]: Leaving directory `/home/public/MyBook/build/stage1/tools'
arm-linux-objcopy -O binary -R .note -R .comment -S stage1.elf stage1.bin
./tools/update_header stage1.bin
size in header:-509546482, size of file: 6436
make: *** [stage1.bin] Segmentation fault
make: *** Deleting file `stage1.bin'
It seems to be using my x86_64 libs and gcc 4.4.4 which is the host compiler not the target.
I've tried setting ARCH=arm but got the same results.

Do i need to export some additional variables or unset some to prevent the host files being used instead of the targets?

Has anyone succesfully used the buildroot environment or offer and help?

Old 01-28-2011, 02:36 AM   #2
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,855

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
COMPILER_PATH and LIBRARY_PATH show that your slackware x86_64 compiler and libs are being used.

I use a wrapper script for my alternate and cross-compilers which sets both PATH and LD_LIBRARY_PATH, like this:

# change the paths below and name the script as something like: GCC336
# copy or save it somwhere in your normal PATH
# Then, to run make(for example) just run: 'GCC336 make'

export PATH=/opt/gcc-3.3.6/lib/gcc-lib/i486-slackware-linux/3.3.6:$PATH
export LD_LIBRARY_PATH=/opt/gcc-3.3.6/lib
exec "$@"
1 members found this post helpful.
Old 01-29-2011, 03:51 AM   #3
Registered: Nov 2009
Posts: 35

Original Poster
Rep: Reputation: 0
Thumbs up [solved]

Thanks gnashley, that was what i was missing.

After a bit of fiddling get the correct paths everything compiled ok.

I tested that the script was actually using the correct gcc version by a simple 'which gcc' after the script. I call my script

user@host:~$ which gcc

user@host:/home/public/MyBook/build/stage1$ ./ which gcc
Old 01-29-2011, 11:42 AM   #4
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,855

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
Exactly! I use a similar script for each of my alternate version or cross-compilers. Some people prefer to use pre- or appended names for the toolchain components, but I find it less troublesome to always use a uniuqe prefix for each toolchain and then use such a wrapper. Doing things the other way means you have to set CC and other such variables each time -and even then some Makefiles simply call 'gcc' so they may not find the right one. Changing the PATH makes things a bit easier.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cross compiling apache-2.0.54 for arm jkeertir Linux - Newbie 3 09-11-2014 01:35 PM
cross compiling sqlite3 for arm 7 processor maheshpawar49 Linux - Software 5 11-23-2010 11:45 PM
Cross compiling for ARM Hachaso Programming 1 06-26-2009 06:07 AM
ARM Cross Compiling Issues AuzJ Linux - Newbie 4 04-16-2009 03:47 AM
Cross compiling utftpd for arm SachinTCS Linux - Desktop 1 04-13-2007 02:11 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration