unrecognized option '-mcpu=r4600'

Roman Duka rduka@mail.ru
Fri Jan 30 23:48:00 GMT 2004

Xu, Jiang wrote:
> Though I am new to cross compiling, if you try to build binutils-
> and run "as --help", you saw "-mCPU", NOT "-mcpu".  However, as in the
> message I sent last time, I think this paticular version does not support
> "-mcpu".  I think this is the reason why "-mcpu" is recognized by cc1, not
> as.
> John

./as --version
GNU assembler 20030722
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
This assembler was configured for a target of `mips-unknown-linux-gnu'.

fragment after running ./as --help

-march=CPU/-mtune=CPU   generate code/schedule for CPU, where CPU is one of:
                         mips1, mips2, mips3, mips4, mips5, mips32,
                         mips32r2, mips64, r3000, r2000, r3900, r6000,
                         r4000, r4010, vr4100, vr4111, vr4120, vr4130,
                         vr4181, vr4300, r4400, r4600, orion, r4650,
                         r8000, r10000, r12000, vr5000, vr5400, vr5500,
                         rm5200, rm5230, rm5231, rm5261, rm5721, rm7000,
                         rm9000, 4kc, 4km, 4kp, 5kc, 20kc, sb1, from-abi
-mCPU                   equivalent to -march=CPU -mtune=CPU. Deprecated.
-no-mCPU                don't generate code specific to CPU.
                         For -mCPU and -no-mCPU, CPU must be one of:
                         3900, 4010, 4100, 4650

so from here you can see that the flag "-mCPU" really means using -m and 
substituing CPU by the mips cpu type. NOTE: it says deprecated, so don't 
use this flag, it may not be supported anymore. Here "-march=" and 
"-mtune=" flags are used for selecting different mips cpus, there is no 
"-mcpu=" flag, so doing something like "as -mcpu=r6000" will fail, 
instead "as -march=r6000" would be the correct way. I think GNU 
assemblers and compilers are trying to deprecate "-mcpu=" flag in favour 
of "-march=" and "-mtune=" So the problem is the gcc and binutils tools 
which accept all these architecture flags, have to work with Linux 
kernel makefile etc. Downgrading gcc/binutils, or upgrading compiling 
kernel to 2.6.x could help. Please follow the step below, i think they 
will help you to compile Linux kernel with binutils-

First we need to set our PATH environment variable to a directory which 
contains our cross gcc and binutils Adjust it to your own path names

roman@athlon1000:~/kernel/linux-2.4.22> export 

Prepare Linux kernel for cross compiling. NOTE: "CROSS_COMPILE" is set 
to the architecture prefix that your cross binaries have, i.e. setting 
it to "mips-unknown-linux-gnu-" will cause Makefile to append "gcc" to 
the end of it, to obtain the name of cross compiler, so the final name 
of your c compiler will be "mips-unknown-linux-gnu-gcc"

roman@athlon1000:~/kernel/linux-2.4.22> make mrproper
roman@athlon1000:~/kernel/linux-2.4.22> make ARCH=mips 
CROSS_COMPILE=mips-unknown-linux-gnu- menuconfig
roman@athlon1000:~/kernel/linux-2.4.22> make ARCH=mips 
CROSS_COMPILE=mips-unknown-linux-gnu- clean dep

Next we need to get rid of "-mcpu" flags in Make files, because they 
seem to conflict with the binutils. The command below will look inside 
all file in the Linux kernel tree and print out the names of files which 
contain "-mcpu" search pattern, the line number and the line which 
contains the pattern

roman@athlon1000:~/kernel/linux-2.4.22> find ./ -exec grep -Hn -e 
'\-mcpu' {} 2> /dev/null \;
./arch/arm/Makefile:31:apcs-$(CONFIG_CPU_26)            :=-mapcs-26 
-mcpu=arm3 -Os
./arch/ppc/Makefile:33:CFLAGS := $(CFLAGS) -mcpu=860
./arch/mips/Makefile:60:GCCFLAGS        += -mcpu=r3000 -mips1
./arch/mips/Makefile:63:GCCFLAGS        += -mcpu=r3000 -mips1
./arch/mips/Makefile:66:GCCFLAGS        += -mcpu=r6000 -mips2 -Wa,--trap
./arch/mips/Makefile:69:GCCFLAGS        += -mcpu=r4300 -mips2 -Wa,--trap
./arch/mips/Makefile:72:GCCFLAGS        += -mcpu=r4600 -mips2 -Wa,--trap
./arch/mips/Makefile:75:GCCFLAGS        += -mcpu=r4600 -mips2 -Wa,--trap
./arch/mips/Makefile:78:GCCFLAGS        += -mcpu=r4600 -mips2 -Wa,--trap
./arch/mips/Makefile:81:GCCFLAGS        += -mcpu=r4600 -mips2 -Wa,--trap
./arch/mips/Makefile:84:GCCFLAGS        += -mcpu=r4600 -mips2 -Wa,--trap
./arch/mips/Makefile:87:GCCFLAGS        += -mcpu=r5000 -mips2 -Wa,--trap
./arch/mips/Makefile:90:GCCFLAGS        += -mcpu=r5000 -mips2 -Wa,--trap
./arch/mips/Makefile:94:GCCFLAGS        += -mcpu=r5000 -mips2 -Wa,--trap
./arch/mips/Makefile:97:GCCFLAGS        += $(call check_gcc, 
-march=rm7000, -mcpu=r5000) \
./arch/mips/Makefile:101:GCCFLAGS       += $(call check_gcc, -mcpu=sb1, 
-mcpu=r5000) \

Now we need to adjust on of those Makefiles, depending on which 
architecture we're compiling kernel for, we're trying to compile it for 
"mips" so looking at the output above we see that "arch/mips/Makefile" 
is the one we need to adjust. If we were compiling for sparc, the file 
would be "arch/sparc/Makefile" etc.

Run the command below, which will replace all occurances of "-mcpu" with 
"-mtune". NOTE: if you try to replace "-mcpu" by "-march" you'll get an 
error message during kernel compilation, because if you look at the 
search results above, you'll see that the mips Makefile, includes 
"-mips2", "-mips1" etc. flags, and in this case it is equivalent to 
"-march" flag.

mv arch/mips/Makefile arch/mips/Makefile.orig && sed 's/-mcpu/-mtune/g' 
< arch/mips/Makefile.orig > arch/mips/Makefile

After this just run the following command to compile your kernel (NOTE: 
set CROSS_COMPILE to whaterver architecuture prefix you have)

make ARCH=mips CROSS_COMPILE=mips-unknown-linux-gnu-

Hopefully this should compile the kernel OK, if you get errors etc, just 
post them to this list and we'll see what else could be done


Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com

More information about the crossgcc mailing list