编译老GCC时出现ustat与glibc版本兼容错误

报错信息

在make时报错信息如下:

../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:157:10: fatal error: sys/ustat.h: No such file or directory                                                                           
 #include <sys/ustat.h>                                                                                                                                                                                            
          ^~~~~~~~~~~~~                                                                                                                                                                                            
compilation terminated.                                                                                                                                                                                            
make[4]: *** [Makefile:523: sanitizer_platform_limits_posix.lo] Error 1  

错误原因

这是因为glibc在2.28版本后抛弃了使用ustat(),该函数只用来解决兼容问题,所有的新程序都得用statfs新函数,为解决该问题,处理方式如下:

解决方案

在文件../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc 中修改如下内容

在158行注释掉如下内容

  156 #include <sys/user.h>
  157 //#include <sys/ustat.h>
  158 #include <linux/cyclades.h>

在250行左右改成如下内容:

  250 #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
  251   || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
  252   || defined(__x86_64__)
  253 #define SIZEOF_STRUCT_USTAT 32
  254 #elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
  255   || defined(__powerpc__) || defined(__s390__)
  256 #define SIZEOF_STRUCT_USTAT 20
  257 #error Unknown size of struct ustat
  258 #endif
  259   unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;

最终解决方案

但是该问题出现的本质是用新的glibc编译旧的gcc,应该先找到旧的glibc然后使用旧的glibc来编译旧的gcc。

并非最终解决方案,一个系统里出现两套glibc时,现有的二进制文件比如ls, module等都无法使用而需要重新编译,和使用chroot或者docker几乎一样的难度了。
文章链接:https://sunwaybits.tech/fix-glibc-ustat-gcc-compatibility-error/
文章标题:编译老GCC时出现ustat与glibc版本兼容错误
文章作者:MyronH
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇