"arm-angstrom-linux-gnueabi-ld: -Wl,-O1: unknown option" when trying to build Linux Kernel from Source Code

I am trying to do external kernel development, i.e. I cloned the kernel sources and try to build them using a toolchain generated with openembedded.

To generate the toolchain I did:

cd ~/oe-core/
. export
bitbake -k angstrom-lxde-image -c populate_sdk
cd ../deploy/sdk/
./angstrom-glibc-x86_64-armv7at2hf-neon-v2016.12-toolchain.sh -S -d ${HOME}/oe-core/sdk

To build the kernel I did in another terminal session:

cd ~/oe-core/colibri-t30-kernel-sources/
. ~/oe-core/sdk/environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi
make colibri_t30_defconfig
make -j3 uImage 2>&1 | tee build.log

This results in:

Makefile:657: "WARNING: Appending $KCFLAGS (--sysroot=/home/lars.moellendorf/oe-core/sdk/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi) from environment to kernel $CFLAGS"
  CHK     include/linux/version.h
  HOSTCC  scripts/basic/fixdep
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/genksyms/genksyms.o
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/genksyms/lex.lex.o
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/bin2c
  HOSTCC  scripts/recordmcount
  HOSTCC  scripts/genksyms/parse.tab.o
  HOSTLD  scripts/genksyms/genksyms
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/arm/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      init/main.o
  HOSTCC  usr/gen_init_cpio
  CC      arch/arm/vfp/vfpmodule.o
  GEN     usr/initramfs_data.cpio
  AS      usr/initramfs_data.o
  LD      usr/built-in.o
arm-angstrom-linux-gnueabi-ld: -Wl,-O1: unknown option
arm-angstrom-linux-gnueabi-ld: use the --help option for usage information
make[1]: *** [scripts/Makefile.build:373: usr/built-in.o] Error 1
make: *** [Makefile:945: usr] Error 2
make: *** Waiting for unfinished jobs....
  AS      arch/arm/vfp/entry.o
  AS      arch/arm/vfp/vfphw.o
  CC      arch/arm/vfp/vfpsingle.o
  CC      init/do_mounts.o
arm-angstrom-linux-gnueabi-ld: -Wl,-O1: unknown option
arm-angstrom-linux-gnueabi-ld: use the --help option for usage information
make[1]: *** [scripts/Makefile.build:305: init/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  CC      arch/arm/vfp/vfpdouble.o
make: *** [Makefile:945: init] Error 2
  LD      arch/arm/vfp/vfp.o
arm-angstrom-linux-gnueabi-ld: -Wl,-O1: unknown option
arm-angstrom-linux-gnueabi-ld: use the --help option for usage information
make[1]: *** [scripts/Makefile.build:427: arch/arm/vfp/vfp.o] Error 1
make: *** [Makefile:945: arch/arm/vfp] Error 2

Here some more information:

echo $ARCH
arm
echo $CC
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/home/lars.moellendorf/oe-core/sdk/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
echo $LD
arm-angstrom-linux-gnueabi-ld --sysroot=/home/lars.moellendorf/oe-core/sdk/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi

What might be the problem here?

Hello

This is how OE builds the kernel.

It looks like unsetting the various flags is needed for the 3.1.10 kernel the T30 needs while the 4.1 kernel for the i.MX based modules did compile without any change to the environment.

unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE

Max

Thank you, so building the kernel works like this:

cd ~/oe-core/colibri-t30-kernel-sources/
export ARCH=arm
export PATH=${HOME}/oe-core/sdk/sysroots/x86_64-angstromsdk-linux/usr/bin/:${HOME}/oe-core/sdk/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/:$PATH
export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
make colibri_t30_defconfig
make -j3 uImage 2>&1 | tee build.log