gcc: error: unrecognized command line option
Solution 1
A more deterministic way of pointing to the exact toolchain you want to use is to provide its full prefix when setting CROSS_COMPILE
. This will avoid possible path-related errors, and the information on which exact toolchain was used for building will be embedded in your build script.
Full example - installing official Arm gcc toolchain and retrieving/building u-boot 20.04 for xilinx_zynq_virt (use your own u-boot and defconfig):
# gcc 9.2.0
mkdir -p /opt/arm/9
wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi.tar.xz?revision=64186c5d-b471-4c97-a8f5-b1b300d6594a&la=en&hash=5E9204DA5AF0B055B5B0F50C53E185FAA10FF625'
tar Jxf gcc-arm-9.2-2019.12-x86_64-arm-none-eabi.tar.xz -C /opt/arm/9
# u-boot
wget https://github.com/u-boot/u-boot/archive/v2020.04.tar.gz
tar zxf v2020.04.tar.gz
cd u-boot-2020.04
make CROSS_COMPILE=/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi- ARCH=arm mrproper xilinx_zynq_virt_defconfig all
ll -gG u-boot*
-rwxrwxr-x 1 5778348 Jun 19 08:08 u-boot*
-rwxrwxr-x 1 599172 Jun 19 08:08 u-boot.bin*
-rw-rw-r-- 1 14907 Jun 19 08:08 u-boot.cfg
-rw-rw-r-- 1 9181 Jun 19 08:09 u-boot.cfg.configs
-rwxrwxr-x 1 665132 Jun 19 08:09 u-boot.elf*
-rw-rw-r-- 1 70 Jun 19 08:09 u-boot-elf.lds
-rw-rw-r-- 1 599612 Jun 19 08:09 u-boot-elf.o
-rw-rw-r-- 1 599236 Jun 19 08:09 u-boot.img
-rw-rw-r-- 1 1626 Jun 19 08:08 u-boot.lds
-rw-rw-r-- 1 696711 Jun 19 08:08 u-boot.map
-rwxrwxr-x 1 599172 Jun 19 08:08 u-boot-nodtb.bin*
-rwxrwxr-x 1 1797626 Jun 19 08:08 u-boot.srec*
-rw-rw-r-- 1 184969 Jun 19 08:08 u-boot.sym
I hope this help.
Solution 2
Your PATH is pointing to some 2011 GCC cross compiler. You need at least GCC 6 which was released in 2016. Please, install a current release of GCC.
On Debian or Ubuntu the C compiler for the host system and the cross compiler are separate packages. You can install the cross-compiler for 32bit and 64bit ARM with:
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install gcc-aarch64-linux-gnu
As the compilers are installed in /usr/bin it is sufficient to set the CROSS_COMPILER variable like
export CROSS_COMPILE=arm-linux-gnueabihf-
or
export CROSS_COMPILE=aarch64-linux-gnu-
EBBulut
Updated on June 04, 2022Comments
-
EBBulut 7 months
I'm trying create an u-boot image file. But have i have some error.
gcc version: 7.3.0 make PATH=/opt/CodeSourcery/Sourcery_G++_Lite/arm-2011.03-41-arm-none-linux-gnueabi:$PATH export CROSS_COMPILE=arm-linux-gnueabihf-(or arm-none-linux-gnueabi) make ARCH=arm xilinx_zynq_defconfig make -j ARCH=arm UIMAGE_LOADADDR=0x8000 uImage
ERROR:
gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’ gcc: note: valid arguments to ‘-mabi=’ are: ms sysv gcc: error: unrecognized command line option ‘-mlittle-endian’; did you mean ‘-fconvert=little-endian’? gcc: error: unrecognized command line option ‘-mfpu=vfp’; did you mean ‘-mcpu=’? CC scripts/mod/devicetable-offsets.s
How can i fix? any idea?
-
kaylum over 2 yearsI'm not a uboot expert but it looks like you are not correctly cross compiling but instead end up using the native toolchain. Probably haven't set
CROSS_COMPILE
env var. -
EBBulut over 2 yearsI'm setting with this; export CROSS_COMPILE=arm-linux-gnueabihf- Edit my command now.
-
kaylum over 2 years
make PATH=...
Is that really what you ran? -
EBBulut over 2 yearsYes. i did try
export PATH=..
still same result.
-
-
EBBulut over 2 yearsThanks. i did install gcc-8,2 but i need change gcc path, i guess. Do u know how can i change gcc path ?
-
Xypron over 2 yearsThe host GCC and the GCC cross compiler are separate packages. For Ubuntu I have added a description above.
-
EBBulut over 2 yearsThank u @Frant. its so helped.