gcc: error: unrecognized command line option

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.

Leave a Comment