报错信息
在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几乎一样的难度了。