BPI-SINOVOIP / BPI-M4-bsp

Supports Banana Pi BPI-M4 (RTD1395) (Kernel 4.9.119)
16 stars 14 forks source link

Solution for "'multiple definition of yylloc' error #4

Open c-shankar opened 4 years ago

c-shankar commented 4 years ago

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

rhakh commented 2 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.

paralin commented 2 years ago

git am https://github.com/Tomoms/android_kernel_oppo_msm8974/commit/11647f99b4de6bc460e106e876f72fc7af3e54a6.patch

Aheadboy commented 2 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.

maybee, my gcc version is : gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)

Aheadboy commented 2 years ago

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

Pranav-flo commented 2 years ago

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.

image image

hamzajrifi commented 2 years ago

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

ShawnYang23 commented 1 year ago

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

MadhbhavikaR commented 1 year ago

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 \
wbob commented 1 year ago

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

mcstarkteam commented 1 year ago

不要找了国内的伙伴,使用gcc-9 完美解决 我是乐于助人的ATRI mua~

H3d9 commented 1 year ago

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.

image image

补充一下,不用重装gcc,找到这个文件,查找"YYLTYPE yylloc;"这一行,替换成"extern YYLTYPE yylloc;"即可。

rhmcruiser commented 1 year ago

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.

FASKA2003 commented 1 year ago

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

H3d9 commented 12 months ago

您可能没有清理旧的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.

G-lacier commented 8 months ago

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.

Yuyaowen commented 1 month ago

不要找了国内的伙伴,使用gcc-9 完美解决 我是乐于助人的ATRI mua~

gcc9.5表示没解决