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

Notices

Reply
 
Search this Thread
Old 01-27-2011, 03:59 PM   #1
brooko
Member
 
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.
Code:
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
Code:
# add buildroot tools to PATH
nick@slackbox:/path/to/buildroot/build_arm_nofpu/staging_dir/bin$ 
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
/path/to/buildroot/build_arm_nofpu/staging_dir/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib64/java/bin:/usr/lib64/kde4/libexec:/usr/lib64/qt/bin:/usr/share/texmf/bin:.
I then move to the directory where i want to build the stage1 boot loader, which is supplied in the GPL code from WD.

Code:
# 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:

Code:
.............................
......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)
COMPILER_PATH=/usr/libexec/gcc/x86_64-slackware-linux/4.4.4/:/usr/libexec/gcc/x86_64-slackware-linux/4.4.4/:/usr/libexec/gcc/x86_64-slackware-linux/:/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/:/usr/lib64/gcc/x86_64-slackware-linux/:/usr/libexec/gcc/x86_64-slackware-linux/4.4.4/:/usr/libexec/gcc/x86_64-slackware-linux/:/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../x86_64-slackware-linux/bin/
LIBRARY_PATH=/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/:/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../x86_64-slackware-linux/lib/:/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../:/lib/:/usr/lib/
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/ld-linux-x86-64.so.2 -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'
nick@slackbox:......./build/stage1$
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?

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

Rep: Reputation: 462Reputation: 462Reputation: 462Reputation: 462Reputation: 462
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:

Code:
#!/bin/sh
# 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'

PATH=/opt/gcc-3.3.6/bin:$PATH
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
brooko
Member
 
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 buildarm.sh

Code:
#before
user@host:~$ which gcc
/usr/bin/gcc
user@host:~$

#after
user@host:/home/public/MyBook/build/stage1$ ./buildarm.sh which gcc
/home/public/MyBook/build/buildroot/build_arm_nofpu/staging_dir/arm-linux-uclibc/bin/gcc
 
Old 01-29-2011, 11:42 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,750

Rep: Reputation: 462Reputation: 462Reputation: 462Reputation: 462Reputation: 462
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.
 
  


Reply


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 2 04-28-2011 03:20 AM
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


All times are GMT -5. The time now is 02:41 AM.

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