Bug 13236

Summary: Can't compile linux 5.4.8 (with gcc 10 on host)
Product: buildroot Reporter: Cédric Chépied <cedric.chepied>
Component: OtherAssignee: unassigned
Status: RESOLVED INVALID    
Severity: normal CC: buildroot
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Cédric Chépied 2020-10-05 10:35:00 UTC
I'm trying to build an image for olimex olinuxino maxi board.

Linux 5.4.8 build fails with this error:

/usr/bin/ld : scripts/dtc/dtc-parser.tab.o:(.bss+0x20) : multiple definitions of « yylloc »;

It looks very similar to this problem which seems to be solved for dtc package:

https://git.busybox.net/buildroot/commit/?id=198db470a73c14191915f8374362bc2a8b08c2bf

I solved it by applying this modification in linux build directory:
https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=0e9225eb0dfec51def612b928d2f1836b092bc7e

I don't know if this is a Linux bug or if it is fixed and you just have to pick a new version.
Comment 1 Peter Korsgaard 2020-10-05 13:14:22 UTC
This is indeed a Linux kernel bug and not really something we can do about (unless this is one of out defconfigs?) as you can specify a custom Linux kernel version.

The issue has been fixed in the upstream 5.4.x kernel since commit 35b34d264cb3479 (5.4.29):

commit 35b34d264cb347909ec89d9fa895900035d5438c
Author: Dirk Mueller <dmueller@suse.com>
Date:   Tue Jan 14 18:53:41 2020 +0100

    scripts/dtc: Remove redundant YYLOC global declaration

    commit e33a814e772cdc36436c8c188d8c42d019fda639 upstream.

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

      (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here

    This is because both dtc-lexer as well as dtc-parser define the same
    global symbol yyloc. Before with -fcommon those were merged into one
    defintion. The proper solution would be to to mark this as "extern",
    however that leads to:

      dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]
       26 | extern YYLTYPE yylloc;
          |                ^~~~~~
    In file included from dtc-lexer.l:24:
    dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
      127 | extern YYLTYPE yylloc;
          |                ^~~~~~
    cc1: all warnings being treated as errors

    which means the declaration is completely redundant and can just be
    dropped.

    Signed-off-by: Dirk Mueller <dmueller@suse.com>
    Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
    [robh: cherry-pick from upstream]
    Cc: stable@vger.kernel.org
    Signed-off-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>