Skip to content

sys/ustat.h not found for gcc-4.9.2 build #57

@gshimansky

Description

@gshimansky

There is a problem with building libsanitizer in gcc-4.9.2 on Ubuntu 19.10. There is no sys/ustat.h file in the system. Suggested patch looks like this. Idea is taken from this link https://github.com/vmware/photon/blob/master/SPECS/gcc/libsanitizer-avoidustat.h-glibc-2.28.patch

diff --git a/source/gcc/build.sh b/source/gcc/build.sh
index c87e0bd..632f4e6 100755
--- a/source/gcc/build.sh
+++ b/source/gcc/build.sh
@@ -76,7 +76,7 @@ if [ ! -f $SOURCE_DIR/check/$PACKAGE_STRING ]; then
     # We apply the patches manually here (instead of bumping the patch level) because
     # some components (boost) fail to compile with a modified gcc version.
     PATCH_DIR=${THIS_DIR}/gcc-${PACKAGE_VERSION}-patches
-    apply_patches 4 $PATCH_DIR
+    apply_patches 5 $PATCH_DIR
   fi

   download_gcc_prerequisites
diff --git a/source/gcc/gcc-4.9.2-patches/945-ustat.patch b/source/gcc/gcc-4.9.2-patches/945-ustat.patch
new file mode 100644
index 0000000..5aeb09f
--- /dev/null
+++ b/source/gcc/gcc-4.9.2-patches/945-ustat.patch
@@ -0,0 +1,31 @@
+--- gcc-4.9.2.orig/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc    2019-12-17 17:56:37.654678258 -0600
++++ gcc-4.9.2/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc 2019-12-17 17:58:23.089867685 -0600
+@@ -81,7 +81,6 @@
+ #include <sys/statvfs.h>
+ #include <sys/timex.h>
+ #include <sys/user.h>
+-#include <sys/ustat.h>
+ #include <linux/cyclades.h>
+ #include <linux/if_eql.h>
+ #include <linux/if_plip.h>
+@@ -163,7 +162,19 @@ namespace __sanitizer {
+   unsigned struct_old_utsname_sz = sizeof(struct old_utsname);
+   unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname);
+   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+-  unsigned struct_ustat_sz = sizeof(struct ustat);
++// Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
++// has been removed from glibc 2.28.
++#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
++  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
++  || defined(__x86_64__)
++#define SIZEOF_STRUCT_USTAT 32
++#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
++  || defined(__powerpc__) || defined(__s390__)
++#define SIZEOF_STRUCT_USTAT 20
++#else
++#error Unknown size of struct ustat
++#endif
++  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
+ #endif // SANITIZER_LINUX
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions