Skip to content

Commit

Permalink
Added patch for missing sys/ustat.h header file
Browse files Browse the repository at this point in the history
Fix for cloudera#57
  • Loading branch information
gshimansky authored and xyu committed Sep 15, 2021
1 parent c718816 commit facc6b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/gcc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions source/gcc/gcc-4.9.2-patches/945-ustat.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit facc6b2

Please sign in to comment.