Skip to content

WIP:huawei-alice: fix kernel dtc build against gcc10, don't set CC to GCC6 as Makefile ignores it

A two ago I successfully built the kernel, but yesterday I got an error:

  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/util.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x50): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[3]: *** [scripts/Makefile.host:127: scripts/dtc/dtc] Error 1
make[2]: *** [/home/pmos/build/src/android_kernel_huawei_alice-0f650cf363b7911523ec5f11aebcdfa5abc55007/scripts/Makefile.build:468: scripts/dtc] Error 2
make[2]: *** Waiting for unfinished jobs....
  HOSTLD  scripts/mod/modpost
make[1]: *** [/home/pmos/build/src/android_kernel_huawei_alice-0f650cf363b7911523ec5f11aebcdfa5abc55007/Makefile:576: scripts] Error 2
make: *** [Makefile:136: sub-make] Error 2
>>> ERROR: linux-huawei-alice: build failed

After a quick search I came up with this: https://lkml.org/lkml/2020/4/1/1206:

gcc 10 will default to -fno-common, which causes this error at link time:

Well, the APKBUILD uses the GCC6 snippet from the wiki, but the log shows that GCC10 is being used. That's because the Makefile simply ignores our variables and sets CC itself.

HOSTCC       = gcc
CC              = $(SOURCEANALYZER) $(CCACHE) $(CROSS_COMPILE)gcc
CPP             = $(CC) -E

Obviously the GCC6 snippet in the APKBUILD is useless in combination with that Makefile. My last successful build was around August 10, and at that time gcc in the alpine repo was still GCC10.

I created a patch similar to this one to make the kernel build against GCC10.

I removed the GCC6 snippet, changed gcc6 to gcc in the makedepends, and bumped the pkgrel.

The kernel works fine on my device.

Edited by Edwin Mackenzie-Owen

Merge request reports