diff mbox

Fix for PR57316 (avoid building sanitizer on old kernels)

Message ID 52E10C18.2050504@samsung.com
State New
Headers show

Commit Message

Yury Gribov Jan. 23, 2014, 12:33 p.m. UTC
Hi,

Attached patch disables libsanitizer on older Linux distribs which lack 
necessary syscalls (see 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57316 for more details).

Bootstrapped/regtested on x64.

Ok to commit?

--
Best regards,
Yury Gribov

Comments

Jakub Jelinek Jan. 23, 2014, 12:59 p.m. UTC | #1
On Thu, Jan 23, 2014 at 04:33:28PM +0400, Yury Gribov wrote:
> Attached patch disables libsanitizer on older Linux distribs which
> lack necessary syscalls (see
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57316 for more details).
> 
> Bootstrapped/regtested on x64.
> 
> Ok to commit?

Ok, thanks, but:

> 2014-01-22  ygribov  <ygribov@samsung.com>

Put your real name here instead.

> 	sanitizer/PR57316

	PR sanitizer/57316

> 	* configure.ac: Check for missing syscalls.
> 	* Makefile.am: Likewise.
> 	* configure: Regenerate.
> 	* Makefile.in: Regenerate.

	Jakub
Yury Gribov Jan. 23, 2014, 2:33 p.m. UTC | #2
Jakub wrote:
 >> Ok to commit?
 >
 > Ok, thanks, but:

Done, r206966.

 > Put your real name here instead.
 >	PR sanitizer/57316

Oh my, fixed.

-Y
diff mbox

Patch

2014-01-22  ygribov  <ygribov@samsung.com>

	sanitizer/PR57316
	* configure.ac: Check for missing syscalls.
	* Makefile.am: Likewise.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
index a17f7b6..b0dc582 100644
--- a/libsanitizer/Makefile.am
+++ b/libsanitizer/Makefile.am
@@ -1,5 +1,6 @@ 
 ACLOCAL_AMFLAGS = -I .. -I ../config
 
+if SANITIZER_SUPPORTED
 SUBDIRS = sanitizer_common
 if !USING_MAC_INTERPOSE
 SUBDIRS += interception
@@ -11,6 +12,7 @@  SUBDIRS += lsan asan ubsan
 if TSAN_SUPPORTED
 SUBDIRS += tsan
 endif
+endif
 
 ## May be used by toolexeclibdir.
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
index 5a33e0e..60cbe2e 100644
--- a/libsanitizer/Makefile.in
+++ b/libsanitizer/Makefile.in
@@ -35,9 +35,9 @@  POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception
-@LIBBACKTRACE_SUPPORTED_TRUE@am__append_2 = libbacktrace
-@TSAN_SUPPORTED_TRUE@am__append_3 = tsan
+@SANITIZER_SUPPORTED_TRUE@@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception
+@LIBBACKTRACE_SUPPORTED_TRUE@@SANITIZER_SUPPORTED_TRUE@am__append_2 = libbacktrace
+@SANITIZER_SUPPORTED_TRUE@@TSAN_SUPPORTED_TRUE@am__append_3 = tsan
 subdir = .
 DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(top_srcdir)/configure $(am__configure_deps) \
@@ -250,8 +250,9 @@  top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I .. -I ../config
-SUBDIRS = sanitizer_common $(am__append_1) $(am__append_2) lsan asan \
-	ubsan $(am__append_3)
+@SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_1) \
+@SANITIZER_SUPPORTED_TRUE@	$(am__append_2) lsan asan ubsan \
+@SANITIZER_SUPPORTED_TRUE@	$(am__append_3)
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
diff --git a/libsanitizer/configure b/libsanitizer/configure
index c207359..5e4840f 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -612,6 +612,8 @@  ALLOC_FILE
 VIEW_FILE
 BACKTRACE_SUPPORTED
 FORMAT_FILE
+SANITIZER_SUPPORTED_FALSE
+SANITIZER_SUPPORTED_TRUE
 USING_MAC_INTERPOSE_FALSE
 USING_MAC_INTERPOSE_TRUE
 link_liblsan
@@ -12017,7 +12019,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12020 "configure"
+#line 12022 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12123,7 +12125,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12126 "configure"
+#line 12128 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15586,6 +15588,47 @@  fi
 
 backtrace_supported=yes
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for necessary platform features" >&5
+$as_echo_n "checking for necessary platform features... " >&6; }
+case "$target" in
+  *-*-linux*)
+    # Some old Linux distributions miss required syscalls.
+    sanitizer_supported=no
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/syscall.h>
+int
+main ()
+{
+
+      syscall (__NR_gettid);
+      syscall (__NR_futex);
+      syscall (__NR_exit_group);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  sanitizer_supported=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    ;;
+  *)
+    sanitizer_supported=yes
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sanitizer_supported" >&5
+$as_echo "$sanitizer_supported" >&6; }
+ if test "$sanitizer_supported" = yes; then
+  SANITIZER_SUPPORTED_TRUE=
+  SANITIZER_SUPPORTED_FALSE='#'
+else
+  SANITIZER_SUPPORTED_TRUE='#'
+  SANITIZER_SUPPORTED_FALSE=
+fi
+
+
 # Test for __sync support.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking __sync extensions" >&5
 $as_echo_n "checking __sync extensions... " >&6; }
@@ -16456,6 +16499,10 @@  if test -z "${USING_MAC_INTERPOSE_TRUE}" && test -z "${USING_MAC_INTERPOSE_FALSE
   as_fn_error "conditional \"USING_MAC_INTERPOSE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${SANITIZER_SUPPORTED_TRUE}" && test -z "${SANITIZER_SUPPORTED_FALSE}"; then
+  as_fn_error "conditional \"SANITIZER_SUPPORTED\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${LIBBACKTRACE_SUPPORTED_TRUE}" && test -z "${LIBBACKTRACE_SUPPORTED_FALSE}"; then
   as_fn_error "conditional \"LIBBACKTRACE_SUPPORTED\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
index c4641d4..e672131 100644
--- a/libsanitizer/configure.ac
+++ b/libsanitizer/configure.ac
@@ -132,6 +132,24 @@  AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
 
 backtrace_supported=yes
 
+AC_MSG_CHECKING([for necessary platform features])
+case "$target" in
+  *-*-linux*)
+    # Some old Linux distributions miss required syscalls.
+    sanitizer_supported=no
+    AC_TRY_COMPILE([#include <sys/syscall.h>],[
+      syscall (__NR_gettid);
+      syscall (__NR_futex);
+      syscall (__NR_exit_group);
+    ], [sanitizer_supported=yes])
+    ;;
+  *)
+    sanitizer_supported=yes
+    ;;
+esac
+AC_MSG_RESULT($sanitizer_supported)
+AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes)
+
 # Test for __sync support.
 AC_CACHE_CHECK([__sync extensions],
 [libsanitizer_cv_sys_sync],