tags:

views:

213

answers:

3

I am trying to cross-compile linux for an ARM architecture.

The host is an X86 machine running ubuntu-jaunty. I downloaded a cross-compile toolchain for ARM from http://ftp.arm.linux.org.uk/pub/armlinux/toolchain/. I downloaded the 2.95.3 version of the toolchain.

The problem I am having is that GCC is passing in some default flags by itself that is causing GCC to then output error:

/usr/local/arm/2.95.3/bin/arm-linux-gcc -specs=/home/feroze/wnr834m/marvell_WNR834M/gcc_specs -D__KERNEL__ -I/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -DLED_DUAL_COLOR -DFOR_ROUTER -I/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk/arch/arm/mach-mv88fxx81/Soc/gpp/ -Uarm -fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -march=armv5 -mtune=arm9tdmi -mshort-load-bytes -msoft-float -Uarm -march=strongarm -DKBUILD_BASENAME=main -c -o init/main.o init/main.c cc1: bad value (strongarm) for -march= switch make[1]: *** [init/main.o] Error 1 make[1]: Leaving directory `/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk'

I checked the whole makefile, and could not find any place where LINUX_ARM_ARCH_5 and -march=armv5 are being defined. I am defining -march=strongarm in the makefile, but then it gets appended by theh ARMv5 defines.

So, I created a defs file from gcc, modified it to only have options for ARMv4, and then used it by specifying the -specs= option. However, that still doesnt solve the problem.

Can somemone help? How do I resolve this?

Thanks!

feroze

+1  A: 

Be sure to check your environment variables, as they can persuade make to do unexpected things.

If the Makefile includes another file, it could be modifying CFLAGS before CC is called. Can you print the contents of CFLAGS just before the CC call?

jheddings
There is nothing in the Environment variables that are causing this. I already checked that.
feroze
+1  A: 

This won't strictly help you eliminate the issue, but you can do gcc -dM -E <empty_file.c> or gcc -dM -E -x c /dev/null to print out a listing of all the predefined #defines for gcc. Combine -dM with another flag like your -march and you might be able to track down what's causing your #define issue.

Mark Rushakoff
+1  A: 

The -march flag is set in arch/ARM/Makefile, and depends on the machine you selected in your config file. If you don't want the armv5 flag, be sure to select the correct architecture in the config file.

You should assume the kernel appended CFLAGS are right (provided your config is ok) and if your toolchain does not support one of them, then you have no choice but to cross compile a toolchain by yourself, using the original crosstol script that should work with 2.95.3

Edit : original answer
What are you trying to build ? a 2.95.3 toolchain is fairly ancient. You should try a more recent toolchain. You can find a precompiled one here Pick the EABI one to start.

This is not a direct answer to your problem, but if you are building the linux kernel, you should not need to mess with the Makefiles. You will get more help if you can get a more "standard" toolchain.

shodanex
The reason I am using the 2.95.3 toolchain is because I am building the linux kernel firmware for a fairly old router - Netgear WNR834M.I tried building that kernel source with a newer toolchain but I got a lot of compile errors.
feroze
Forgot to mention that the linux kernel version in the sources for that router is 2.4 (I think).
feroze
I couldnt get it to compile with the CodeSourcery EABI toolchain. Also, the 2.95.3 version of the toolchain does not support the armv5 processor on the device. So, even though the compile succeeds with 2.95.3, the linker fails because it cannot find some symbols.I will try with the original crosstool script that you suggest. Even netgear OSS support is asking me to go there to build one.
feroze