This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Detect obsolete glibcs or kernel headers in libgomp configury (PR libgomp/26175, libgomp/26477)


Hi!

With this patch we detect prehistoric glibcs or kernel headers in libgomp
configury and use --disable-linux-futex by default.
If SYS_gettid/SYS_futex isn't defined in <asm/unistd.h>, then libgomp
wouldn't compile at all, so by default we use --disable-linux-futex
in that case and for explicit --enable-linux-futex issue an error.
Otherwise, it checks for compiling against NPTL (then we can pretty
safely assume it will be run against NPTL too), or, for native builds only,
if NPTL is used at runtime.
Ok for trunk?

2006-06-05  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/26175
	PR libgomp/26477
	* configure.ac: If neither --enable-linux-futex nor
	--disable-linux-futex is passed, determine the default by checking
	for compiling and/or running against NPTL.  With --enable-linux-futex,
	check if SYS_gettid and SYS_futex are defined.
	* configure: Rebuilt.

--- libgomp/configure.ac.jj	2006-04-26 10:37:59.000000000 +0200
+++ libgomp/configure.ac	2006-06-05 17:00:16.000000000 +0200
@@ -16,9 +16,9 @@ LIBGOMP_ENABLE(version-specific-runtime-
 AC_MSG_RESULT($enable_version_specific_runtime_libs)
 
 AC_MSG_CHECKING([for --enable-linux-futex])
-LIBGOMP_ENABLE(linux-futex, yes,
+LIBGOMP_ENABLE(linux-futex, default,
   [Use the Linux futex system call],
-  permit yes|no)
+  permit yes|no|default)
 AC_MSG_RESULT($enable_linux_futex)
 
 # -------
@@ -171,6 +171,46 @@ case "$host" in
     AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
 	Define if the POSIX Semaphores do not work on your system.)
     ;;
+  *-linux*)
+    case "$enable_linux_futex" in
+      default)
+	# If headers don't have gettid/futex syscalls definition, then
+	# default to no, otherwise there will be compile time failures.
+	# Otherwise, if we detect we are compiled/linked against NPTL,
+	# default to yes, or if not cross-compiling and we are compiled/linked
+	# against LinuxThreads, but run against NPTL, default to yes as well.
+	# Otherwise default to no.
+	enable_linux_futex=no
+	AC_LINK_IFELSE(
+	 [AC_LANG_PROGRAM(
+	  [#include <sys/syscall.h>
+	   int lk;],
+	  [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],
+	  [AC_LINK_IFELSE(
+	   [AC_LANG_PROGRAM(
+	    [#ifndef _GNU_SOURCE
+	     #define _GNU_SOURCE 1
+	     #endif
+	     #include <pthread.h>
+	     pthread_t th; void *status;],
+	    [pthread_tryjoin_np (th, &status);])],[enable_linux_futex=yes],
+	    [if test x$cross_compiling = xno; then
+	       if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
+		  | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then
+		 enable_linux_futex=yes
+	       fi
+	     fi])])
+	;;
+      yes)
+	AC_LINK_IFELSE(
+	 [AC_LANG_PROGRAM(
+	  [#include <sys/syscall.h>
+	   int lk;],
+	  [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],[],
+	  [AC_MSG_ERROR([SYS_gettid and SYS_futex required for --enable-linux-futex])])
+	;;
+    esac
+    ;;
 esac
 
 # At least for glibc, clock_gettime is in librt.  But don't pull that
--- libgomp/configure.jj	2006-04-26 10:37:59.000000000 +0200
+++ libgomp/configure	2006-06-05 17:00:21.000000000 +0200
@@ -855,7 +855,7 @@ Optional Features:
                           Specify that runtime libraries should be installed
                           in a compiler-specific directory [default=no]
   _g_switchUse the Linux futex system call
-                          permit yes|no [default=yes]
+                          permit yes|no|default [default=default]
   --enable-multilib       build many library versions (default)
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
@@ -1376,7 +1376,7 @@ echo "$as_me: error: Argument to enable/
       esac
 
 else
-  enable_linux_futex=yes
+  enable_linux_futex=default
 fi;
 
 echo "$as_me:$LINENO: result: $enable_linux_futex" >&5
@@ -8509,6 +8509,170 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
     ;;
+  *-linux*)
+    case "$enable_linux_futex" in
+      default)
+	# If headers don't have gettid/futex syscalls definition, then
+	# default to no, otherwise there will be compile time failures.
+	# Otherwise, if we detect we are compiled/linked against NPTL,
+	# default to yes, or if not cross-compiling and we are compiled/linked
+	# against LinuxThreads, but run against NPTL, default to yes as well.
+	# Otherwise default to no.
+	enable_linux_futex=no
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/syscall.h>
+	   int lk;
+int
+main ()
+{
+syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifndef _GNU_SOURCE
+	     #define _GNU_SOURCE 1
+	     #endif
+	     #include <pthread.h>
+	     pthread_t th; void *status;
+int
+main ()
+{
+pthread_tryjoin_np (th, &status);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  enable_linux_futex=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+if test x$cross_compiling = xno; then
+	       if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
+		  | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then
+		 enable_linux_futex=yes
+	       fi
+	     fi
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+	;;
+      yes)
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/syscall.h>
+	   int lk;
+int
+main ()
+{
+syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: SYS_gettid and SYS_futex required for --enable-linux-futex" >&5
+echo "$as_me: error: SYS_gettid and SYS_futex required for --enable-linux-futex" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+	;;
+    esac
+    ;;
 esac
 
 # At least for glibc, clock_gettime is in librt.  But don't pull that

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]