From 66814faec0f8e589b48af8c22a70d94d96bf0957 Mon Sep 17 00:00:00 2001
From: Ronan Le Martret <ronan.lemartret@iot.bzh>
Date: Wed, 30 Sep 2020 09:04:59 +0000
Subject: [RCAR] Fix gcc 10 build failed on u-boot and kernel.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* cherry pick upstream patch to fix u-boot and linux kernel on gcc
  10 build issue.

Bug-AGL: [SPEC-3617]

Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
Change-Id: I0c85938287861a8efc328b5c08bbf364027f6473
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/25416
Tested-by: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
ci-image-build: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
ci-image-boot-test: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Reviewed-by: Stéphane Desneux <stephane.desneux@iot.bzh>
---
 ...Remove-redundant-YYLOC-global-declaration.patch | 27 ++++++++++++
 .../recipes-bsp/u-boot/u-boot_%.bbappend           |  5 +++
 ...-Remove-redundant-YYLOC-global-declaratio.patch | 51 ++++++++++++++++++++++
 .../recipes-kernel/linux/linux-renesas_%.bbappend  |  6 +++
 4 files changed, 89 insertions(+)
 create mode 100644 meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/files/0001-Remove-redundant-YYLOC-global-declaration.patch
 create mode 100644 meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/u-boot_%.bbappend
 create mode 100644 meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/files/0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch

diff --git a/meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/files/0001-Remove-redundant-YYLOC-global-declaration.patch b/meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/files/0001-Remove-redundant-YYLOC-global-declaration.patch
new file mode 100644
index 000000000..2a184e57e
--- /dev/null
+++ b/meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/files/0001-Remove-redundant-YYLOC-global-declaration.patch
@@ -0,0 +1,27 @@
+From 018921ee79d3f30893614b3b2b63b588d8544f73 Mon Sep 17 00:00:00 2001
+From: Peter Robinson <pbrobinson@gmail.com>
+Date: Thu, 30 Jan 2020 09:37:15 +0000
+Subject: [PATCH] Remove redundant YYLOC global declaration
+
+Same as the upstream fix for building dtc with gcc 10.
+
+Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
+---
+ scripts/dtc/dtc-lexer.l | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
+index fd825ebba6..24af549977 100644
+--- a/scripts/dtc/dtc-lexer.l
++++ b/scripts/dtc/dtc-lexer.l
+@@ -38,7 +38,6 @@ LINECOMMENT	"//".*\n
+ #include "srcpos.h"
+ #include "dtc-parser.tab.h"
+ 
+-YYLTYPE yylloc;
+ extern bool treesource_error;
+ 
+ /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
+-- 
+2.26.2
+
diff --git a/meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/u-boot_%.bbappend b/meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/u-boot_%.bbappend
new file mode 100644
index 000000000..fefc3c9a3
--- /dev/null
+++ b/meta-agl-bsp/meta-rcar-gen3/recipes-bsp/u-boot/u-boot_%.bbappend
@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI +=" \
+            file://0001-Remove-redundant-YYLOC-global-declaration.patch \
+          "
diff --git a/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/files/0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch b/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/files/0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch
new file mode 100644
index 000000000..a17837dc3
--- /dev/null
+++ b/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/files/0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch
@@ -0,0 +1,51 @@
+From e33a814e772cdc36436c8c188d8c42d019fda639 Mon Sep 17 00:00:00 2001
+From: Dirk Mueller <dmueller@suse.com>
+Date: Tue, 14 Jan 2020 18:53:41 +0100
+Subject: [PATCH] scripts/dtc: Remove redundant YYLOC global declaration
+
+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>
+---
+ scripts/dtc/dtc-lexer.l | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
+index 5c6c3fd557d7..b3b7270300de 100644
+--- a/scripts/dtc/dtc-lexer.l
++++ b/scripts/dtc/dtc-lexer.l
+@@ -23,7 +23,6 @@ LINECOMMENT	"//".*\n
+ #include "srcpos.h"
+ #include "dtc-parser.tab.h"
+ 
+-YYLTYPE yylloc;
+ extern bool treesource_error;
+ 
+ /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
+-- 
+2.26.2
+
diff --git a/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/linux-renesas_%.bbappend b/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/linux-renesas_%.bbappend
index 12054df86..ca315b28e 100644
--- a/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/linux-renesas_%.bbappend
+++ b/meta-agl-bsp/meta-rcar-gen3/recipes-kernel/linux/linux-renesas_%.bbappend
@@ -10,6 +10,12 @@ SRC_URI_append = " \
     file://0004-ADSP-enable-and-add-sound-hardware-abstraction.patch \
 "
 
+# Gcc 10 build fix
+SRC_URI_append = " \
+    file://0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch \
+"
+
+
 # For Xen
 SRC_URI_append = " \
     ${@bb.utils.contains('AGL_XEN_WANTED','1','file://xen-be.cfg','',d)} \
-- 
cgit