Open c-shankar opened 4 years ago
The possible reason is wrong version of GCC. Please try gcc-9 or older. Previously, I used gcc-10, and got this issue. Then installed gcc-9, and everything were successfully build.
git am https://github.com/Tomoms/android_kernel_oppo_msm8974/commit/11647f99b4de6bc460e106e876f72fc7af3e54a6.patch
The possible reason is wrong version of GCC. Please try gcc-9 or older. Previously, I used gcc-10, and got this issue. Then installed gcc-9, and everything were successfully build.
maybee, my gcc version is : gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)
dtc-lexer-lex.c
I met this issue when I build android7 in ubuntu22. But why am I not found dtc-lexer-lex.c
in aosp path
This issue occurs during kernel compilation. I resolved it by adding extern to yylloc. You can find the file in (root directory of kernel folder)/scripts/dtc/dtc-lexer-lex.c Also if dtc-lexer.lex.c_shipped file exists in the path make sure to extern yylloc here as well.
that's same happen with me when update gcc-9 to gcc-11 and i fixed it when i receive my last version gcc-9 and that's work whit me i used this command ==> sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
If you are facing the following error,
usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of 'yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status
edit the file ./linux-rtk/scripts/dtc/dtc-lexer-lex.c Find the line 'YYLTYPE yylloc' and change it to 'extern YYLTYPE yylloc'
reference : https://lkml.org/lkml/2020/4/1/1206
In some RK SDK, this symbol is placed in the file dtc-lexer.l
I was able to resolve the issue by applying the below patch (the file name was different in my case)
$ git diff
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index 2d30f41778b..d0eb405cb81 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -637,7 +637,7 @@ char *yytext;
#include "srcpos.h"
#include "dtc-parser.tab.h"
-YYLTYPE yylloc;
+extern YYLTYPE yylloc;
/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
#define YY_USER_ACTION \
was stuck on this for too long - ignored the _shipped
files at first. For context: those are being used in kernels prior to 4.17, see https://github.com/torvalds/linux/commit/e039139be8c2 and https://lkml.org/lkml/2020/3/31/658
you need the patch in kernels < 5.6
不要找了国内的伙伴,使用gcc-9 完美解决 我是乐于助人的ATRI mua~
This issue occurs during kernel compilation. I resolved it by adding extern to yylloc. You can find the file in (root directory of kernel folder)/scripts/dtc/dtc-lexer-lex.c Also if dtc-lexer.lex.c_shipped file exists in the path make sure to extern yylloc here as well.
补充一下,不用重装gcc,找到这个文件,查找"YYLTYPE yylloc;"这一行,替换成"extern YYLTYPE yylloc;"即可。
Kernel build successful after modifying dtc-lexer-lex.c in < kernel src directory>/scripts/dtc/ YYLYTYPE yylloc ==> extern YYLTYPE yylloc
( jfyi - I encountered this issue while building a custom linux arm kernel for qemu.
Hello, I'm facing the same problem even if i have made changes to the scripts/dtc/dtc-lexer.lex.c, by replacing YYLTYPE yylloc with extern YYLTYPE yylloc, This is what i'm getting : /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status make[1]: [scripts/Makefile.host:101: scripts/dtc/dtc] Error 1 make: [Makefile:1244: scripts_dtc] Error 2
您可能没有清理旧的obj文件,请先删除“dtc-lexer.lex.o”然后构建,或者先全部清理(一般为make clean之类的命令)再重新构建。 Perhaps you didnot clean old obj file, please delete “dtc-lexer.lex.o” and build again, or clean all(some sort of command like "make clean") and rebuild again.
If you are facing the following error,
usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of 'yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status
edit the file ./linux-rtk/scripts/dtc/dtc-lexer-lex.c Find the line 'YYLTYPE yylloc' and change it to 'extern YYLTYPE yylloc'
reference : https://lkml.org/lkml/2020/4/1/1206
This worked for me. I was trying to compile an android 4 kernel and kept getting this error.
不要找了国内的伙伴,使用gcc-9 完美解决 我是乐于助人的ATRI mua~
gcc9.5表示没解决
If you are facing the following error,
edit the file ./linux-rtk/scripts/dtc/dtc-lexer-lex.c Find the line 'YYLTYPE yylloc' and change it to 'extern YYLTYPE yylloc'
reference : https://lkml.org/lkml/2020/4/1/1206