问题描述
RK平台在编译uboot代码过程中,可能因为编译环境的问题,会报这样的错误,导致编译不过:
$ ./make.sh rk3399
make for rk3399_defconfig by -j8HOSTCC  scripts/basic/fixdepHOSTCC  scripts/kconfig/conf.oHOSTCC  scripts/kconfig/zconf.tab.oHOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
scripts/kconfig/conf  --silentoldconfig KconfigCHK     include/config.hCFG     u-boot.cfgGEN     include/autoconf.mk.depCFG     spl/u-boot.cfgCFG     tpl/u-boot.cfgGEN     include/autoconf.mkGEN     spl/include/autoconf.mkGEN     tpl/include/autoconf.mkCHK     include/config/uboot.releaseCHK     include/generated/timestamp_autogenerated.hUPD     include/generated/timestamp_autogenerated.hHOSTCC  scripts/dtc/dtc.oCHK     include/generated/version_autogenerated.hHOSTCC  scripts/dtc/flattree.oHOSTCC  scripts/dtc/fstree.oHOSTCC  scripts/dtc/data.oHOSTCC  scripts/dtc/livetree.oHOSTCC  scripts/dtc/treesource.oHOSTCC  scripts/dtc/srcpos.oHOSTCC  scripts/dtc/checks.oHOSTCC  scripts/dtc/util.oHOSTCC  scripts/dtc/dtc-lexer.lex.oHOSTCC  scripts/dtc/dtc-parser.tab.oCC      lib/asm-offsets.sCC      arch/arm/lib/asm-offsets.sCHK     include/generated/asm-offsets.hCHK     include/generated/generic-asm-offsets.hLDS     u-boot.ldsCHK     include/config.hCFG     u-boot.cfgHOSTLD  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[2]: *** [scripts/Makefile.host:108: scripts/dtc/dtc] Error 1
make[1]: *** [scripts/Makefile.build:425: scripts/dtc] Error 2
make: *** [Makefile:491: scripts] Error 2
解决方法
--- scripts/dtc/dtc-lexer.lex_bak.c     2024-06-05 06:33:14.891816319 +0000
+++ scripts/dtc/dtc-lexer.lex.c 2024-06-05 06:18:42.879649490 +0000
@@ -631,7 +631,7 @@#include "srcpos.h"#include "dtc-parser.tab.h"-YYLTYPE yylloc;
+extern YYLTYPE yylloc;extern bool treesource_error;/* CAUTION: this will stop working if we ever use yyless() or yyunput() */