Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gshimansky opened this issue Dec 18, 2019 · 3 comments
Open

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

gshimansky opened this issue Dec 18, 2019 · 3 comments

Comments

@gshimansky
Copy link
Contributor

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
@timarmstrong
Copy link
Contributor

@gshimansky I think the proposed change makes sense. Would you be able to submit a pull request? If not we can pull it in ourselves, but that way you'd get credit for it.

It looks like that's originally from this LLVM commit so is Apache 2.0 licensed.

@gshimansky
Copy link
Contributor Author

Ok give me some time, I'll submit a PR tomorrow.

@timarmstrong
Copy link
Contributor

Thanks @gshimansky, I appreciate it.

gshimansky added a commit to gshimansky/native-toolchain that referenced this issue Dec 18, 2019
xyu pushed a commit to Automattic/cloudera-native-toolchain that referenced this issue Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants