背景

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

带来的问题

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

1.YYLTYPE yylloc错误

/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:

/* 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:

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"

3.dtc编译错误

在编译uboot时遇到如下错误:

/usr/include/libfdt_env.h:27:30: error: conflicting types for ‘fdt64_t’
   27 | typedef uint64_t FDT_BITWISE fdt64_t;
      |                              ^~~~~~~
In file included from <command-line>:
././include/libfdt_env.h:19:16: note: previous declaration of ‘fdt64_t’ was here
   19 | typedef __be64 fdt64_t;
      |                ^~~~~~~
In file included from ././include/libfdt_env.h:12,
                 from <command-line>:
/usr/include/libfdt_env.h:47:24: error: expected ‘)’ before ‘x’
   47 | static inline uint32_t fdt32_to_cpu(fdt32_t x)
      |                        ^~~~~~~~~~~~
././include/compiler.h:71:9: error: expected ‘)’ before ‘&’ token
   71 |  ((((x) & 0xff000000) >> 24) | \
      |         ^
././include/compiler.h:71:23: error: expected ‘)’ before ‘>>’ token
   71 |  ((((x) & 0xff000000) >> 24) | \
      |                       ^~
././include/compiler.h:71:30: error: expected ‘)’ before ‘|’ token
   71 |  ((((x) & 0xff000000) >> 24) | \
      |                              ^
/usr/include/libfdt_env.h:51:23: error: expected ‘)’ before ‘x’
   51 | static inline fdt32_t cpu_to_fdt32(uint32_t x)
      |                       ^~~~~~~~~~~~
././include/compiler.h:71:9: error: expected ‘)’ before ‘&’ token
解决方法:

删除libfdt-dev软件包

sudo apt-get purge -y --auto-remove libfdt-dev
如果觉得我的文章对你有用,请随意赞赏