服务器升级系统后编译出现的错误总结

2022-11-05 16:49:06 浏览数 (1)

背景

部门用来开发的服务器之前的系统是ubuntu16.04的,已经好多年了,因为数据量庞大,更新系统怕有风险,一直没有升级。老系统局限性太多了,现在好多项目需要安装的软件版本太低,像openwrt、fenix一些工程编译所需要的最低系统环境都满足不了,所以最近终于把系统升到了ubuntu22.04,估计又可以用好几年了。

带来的问题

这个服务器主要用来编译linux内核、uboot等,升级系统后之前提交编译正常的项目都多多少少出现了点小错误,这里总结记录下,不定时更新。

1.YYLTYPE yylloc错误
代码语言:javascript复制
/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
解决方法:

在编译源码根目录下的scripts/dtc/dtc-parser.tab.c文件中,找到YYLTYPE yylloc定义的地方,前面加上extern外部变量声明。

bug fix:

代码语言:javascript复制
/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;
/* Location data for the lookahead symbol.  */
extern YYLTYPE yylloc
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
  = { 1, 1, 1, 1 }
# endif
;
/* Number of syntax errors so far.  */
int yynerrs;
2.New address错误
解决方法:

找到scripts/selinux/genheaders/genheaders.c和scripts/selinux/mdp/mdp.c两个C文件,注释掉<sys/socket.h>头文件的引用;找到security/selinux/include/classmap.h头文件,添加<linux/socket.h>头文件的引用。

bug fix:

代码语言:javascript复制
diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c
index fa48fabcb..032b47a13 100644
--- a/scripts/selinux/genheaders/genheaders.c
    b/scripts/selinux/genheaders/genheaders.c
@@ -9,7  9,7 @@
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
-#include <sys/socket.h>
 //#include <sys/socket.h>

 struct security_class_mapping {
        const char *name;
diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c
index ffe8179f5..c1db0c488 100644
--- a/scripts/selinux/mdp/mdp.c
    b/scripts/selinux/mdp/mdp.c
@@ -32,7  32,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <sys/socket.h>
 //#include <sys/socket.h>

 static void usage(char *name)
 {
diff --git a/security/selinux/include/classmap.h b/security/selinux/include/classmap.h
index cc35695d9..45ef6a0c1 100644
--- a/security/selinux/include/classmap.h
    b/security/selinux/include/classmap.h
@@ -1,5  1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/capability.h>
 #include <linux/socket.h>

 #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", 
     "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map"

版权属于:咖啡走糖

本文链接:https://cloud.tencent.com/developer/article/2152400

若无注明,本文皆咖啡走糖原创,转载时必须注明出处及本声明!

0 人点赞