内核编译出错:unrecognized command line option '-mgeneral-regs-only'

:~/proj/firefly-rk3399/kernel$ echo $CROSS_COMPILE
/home/teddy/proj/firefly-rk3288-lollipop/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
:~/proj/firefly-rk3399/kernel$ echo $ARCH
arm

:~/proj/firefly-rk3399/kernel$ make -j8 ARCH=arm64 rk3399-firefly.img
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CC scripts/mod/empty.o
CC scripts/mod/devicetable-offsets.s
CHK include/generated/utsrelease.h
cc1: error: unrecognized command line option ‘-mgeneral-regs-only’
make[2]: *** [scripts/mod/devicetable-offsets.s] Error 1
make[2]: *** Waiting for unfinished jobs…
cc1: error: unrecognized command line option ‘-mgeneral-regs-only’
make[2]: *** [scripts/mod/empty.o] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
make: *** Waiting for unfinished jobs…
CHK include/generated/timeconst.h
CC kernel/bounds.s
cc1: error: unrecognized command line option ‘-mgeneral-regs-only’
make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2


make -j8 ARCH=arm64 rk3399-firefly.img
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CC scripts/mod/empty.o
CC scripts/mod/devicetable-offsets.s
CHK include/generated/utsrelease.h
arm-eabi-gcc: error: unrecognized command line option ‘-mgeneral-regs-only’
make[2]: *** [scripts/mod/devicetable-offsets.s] Error 1
make[2]: *** Waiting for unfinished jobs…
arm-eabi-gcc: error: unrecognized command line option ‘-mgeneral-regs-only’
make[2]: *** [scripts/mod/empty.o] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
make: *** Waiting for unfinished jobs…
CHK include/generated/timeconst.h
CC kernel/bounds.s
arm-eabi-gcc: error: unrecognized command line option ‘-mgeneral-regs-only’
make[1]: *** [kernel/bounds.s] Error

自带的prebuild里的交叉编译不行,必须要自己装

export ARCH=arm64e

sudo apt-get install gcc-aarch64-linux-gnu
sudo apt-get install gcc-arm-linux-gnueabi

export CROSS_COMPILE=/usr/bin/aarch64-linux-gnu-

export CROSS32CC=arm-linux-gnueabi-gcc

https://devtalk.nvidia.com/default/topic/906942/failed-to-compile-kernel-module-gcc-cannot-recognize-aarch64-option-mgeneral-regs-only-/

总之就是编译器的毛病,之前也遇到这个问题,换了 Linaro 4.9.x 就好了。

tedyyan 发表于 2017-3-29 15:05
自带的prebuild里的交叉编译不行,必须要自己装

export ARCH=arm64e

在3399PRO LINUX 1.4的内核里面编译NPU的固件,遇到这个问题,感谢楼主,完美解决。