新版本gcc(gcc10.x)编译Linux内核,错误:multiple definition of `yylloc‘
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
由于GCC的更新编译之前的Linux内核会出现各种各样的问题,本文就multiple definition of yylloc问题解决给出解决方案
本文环境如下:
OS: Ubuntu 21.04LTS
GCC: gcc 10.3.0
LD: ld 2.36.1
Linux Kernel: Linux 4.15
1、查看gcc和ld版本
imaginemiracle@:$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-gDeRY6/gcc-10-10.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-gDeRY6/gcc-10-10.3.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1)
imaginemiracle@:$ ld -v
GNU ld (GNU Binutils for Ubuntu) 2.36.1
2、编译Linux内核
使用gcc 10.0以上版本就会出现该错误,/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
imaginemiracle@:rvlinux-u_IM$ make Image
......
......
......
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config/kernel.release
UPD include/config/kernel.release
WRAP arch/riscv/include/generated/uapi/asm/setup.h
WRAP arch/riscv/include/generated/uapi/asm/unistd.h
......
......
......
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/dtc/dtc
/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
make[5]: *** [scripts/Makefile.host:99: scripts/dtc/dtc] Error 1
make[4]: *** [/media/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/rvlinux-u_IM/linux/scripts/Makefile.build:575: scripts/dtc] Error 2
make[4]: *** Waiting for unfinished jobs....
HOSTLD scripts/mod/modpost
make[3]: *** [/media/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/rvlinux-u_IM/linux/Makefile:556: scripts] Error 2
make[3]: Leaving directory '/media/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/rvlinux-u_IM/work/linux'
make[2]: *** [Makefile:146: sub-make] Error 2
make[2]: Leaving directory '/media/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/rvlinux-u_IM/linux'
make[1]: *** [Makefile:103: /home/imaginemiracle/Downloads/vmlinux] Error 2
make[1]: Leaving directory '/media/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/rvlinux-u_IM'
make: *** [Makefile:186: Image] Error 2
3、解决方案
进入内核的dtc
目录(scripts/dtc
),修改文件dtc-lexer.lex.c_shipped
,在YYLTYPE yylloc;
前增加extern
(注: 若是未经更改的文件,该修改项会在634行
)
//file: scripts/dtc/dtc-lexer.lex.c_shipped
629 #line 37 "dtc-lexer.l"
630 #include "dtc.h"
631 #include "srcpos.h"
632 #include "dtc-parser.tab.h"
633
634 extern YYLTYPE yylloc; /* +Alter by wxn */
635 extern bool treesource_error;
636
637 /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
638 #define YY_USER_ACTION \
639 { \
640 srcpos_update(&yylloc, yytext, yyleng); \
641 }
642
643 /*#define LEXDEBUG 1*/
4、重新编译内核
再次编译内核,该错误解决。
imaginemiracle@:rvlinux-u_IM$ make Image
......
......
......
CC drivers/usb/core/quirks.o
AR drivers/usb/storage/usb-storage.o
AR drivers/usb/storage/built-in.o
CC drivers/usb/core/devices.o
CC drivers/usb/core/port.o
CC drivers/usb/core/of.o
CC drivers/usb/core/hcd-pci.o
AR drivers/usb/core/usbcore.o
AR drivers/usb/core/built-in.o
AR drivers/usb/built-in.o
AR drivers/built-in.o
GEN .version
CHK include/generated/compile.h
SKIPPED include/generated/compile.h
AR built-in.o
LD vmlinux.o
MODPOST vmlinux.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SYSMAP System.map
......
......
......
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献18条内容
所有评论(0)