-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution for "'multiple definition of yylloc' error #4
Comments
The possible reason is wrong version of GCC. Please try gcc-9 or older. |
|
maybee, my gcc version is : gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2) |
I met this issue when I build android7 in ubuntu22. But why am I not found |
that's same happen with me when update gcc-9 to gcc-11 |
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 you need the patch in kernels < 5.6 |
不要找了国内的伙伴,使用gcc-9 完美解决 |
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 <[email protected]> Signed-off-by: David Gibson <[email protected]> [robh: cherry-pick from upstream] Cc: [email protected] Signed-off-by: Rob Herring <[email protected]> [nc: Also apply to dtc-lexer.lex.c_shipped due to a lack of e039139be8c2, where dtc-lexer.l started being used] Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Change-Id: I7f299451e99aab09375883546e47505ec0937c26
补充一下,不用重装gcc,找到这个文件,查找"YYLTYPE yylloc;"这一行,替换成"extern YYLTYPE yylloc;"即可。 |
Kernel build successful after modifying dtc-lexer-lex.c in < kernel src directory>/scripts/dtc/ ( jfyi - I encountered this issue while building a custom linux arm kernel for qemu.
|
Hello,
|
您可能没有清理旧的obj文件,请先删除“dtc-lexer.lex.o”然后构建,或者先全部清理(一般为make clean之类的命令)再重新构建。 |
As suggested in: BPI-SINOVOIP/BPI-M4-bsp#4#issuecomment-1140414552 Change-Id: I05cb1f34ddb73592d8822f4fbdf05579ad8a46bc
fix for 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 see BPI-SINOVOIP/BPI-M4-bsp#4 (comment) edit the file ./linux-rtk/scripts/dtc/dtc-lexer-lex.c_shipped Find the line 'YYLTYPE yylloc' and change it to 'extern YYLTYPE yylloc'
This worked for me. I was trying to compile an android 4 kernel and kept getting this error. |
As suggested in: BPI-SINOVOIP/BPI-M4-bsp#4#issuecomment-1140414552 More info: lwys-trash-oct23/android_kernel_samsung_msm8916@9db5f0e Signed-off-by: Liu Wenyuan <[email protected]>
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
The text was updated successfully, but these errors were encountered: