[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] Fix .ctors/.dtors configure test



The .ctors/.dtors configure test that came in with a recent merge from FSF 
glibc was another instance of a configure test that assumes by using 
AC_TRY_LINK that you have a previous libc installation available for 
configure tests to link with.  I've applied this patch to fix it similarly 
to other tests to use nostartfiles -nostdlib and avoid that dependency.

Index: configure.in
===================================================================
--- configure.in	(revision 14702)
+++ configure.in	(working copy)
@@ -1524,11 +1524,16 @@
   AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer,
 		 libc_cv_ctors_header, [dnl
     libc_cv_ctors_header=yes
-    AC_TRY_LINK([], [
+    cat > conftest.c <<EOF
+int _start (void) { return 0; }
+int __start (void) { return 0; }
+int puts (const char *s) { return 0; }
 __attribute__ ((constructor)) void ctor (void) { puts("ctor"); }
 __attribute__ ((destructor))  void dtor (void) { puts("dtor"); }
-],
-		[dnl
+EOF
+    if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -o conftest
+		       conftest.c -static -nostartfiles -nostdlib 1>&AS_MESSAGE_LOG_FD])
+    then
       AS_IF([$READELF -WS conftest$ac_exeext | $AWK '
         { gsub(/\@<:@ */, "@<:@") }
 	$2 == ".ctors" || $2 == ".dtors" {
@@ -1543,10 +1548,10 @@
 	  exit ((ctors_ok && dtors_ok) ? 0 : 1)
 	}
       '], [libc_cv_ctors_header=no])
-    ], [dnl
+    else
       AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
-    ])
-  ])
+    fi
+  rm -f conftest*])
   if test $libc_cv_ctors_header = no; then
     AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
   fi
Index: configure
===================================================================
--- configure	(revision 14702)
+++ configure	(working copy)
@@ -6520,46 +6520,22 @@
   $as_echo_n "(cached) " >&6
 else
       libc_cv_ctors_header=yes
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
+    cat > conftest.c <<EOF
+int _start (void) { return 0; }
+int __start (void) { return 0; }
+int puts (const char *s) { return 0; }
 __attribute__ ((constructor)) void ctor (void) { puts("ctor"); }
 __attribute__ ((destructor))  void dtor (void) { puts("dtor"); }
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
+EOF
+    if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -o conftest
+		       conftest.c -static -nostartfiles -nostdlib 1>&5'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-        if $READELF -WS conftest$ac_exeext | $AWK '
+  (exit $ac_status); }; }
+    then
+      if $READELF -WS conftest$ac_exeext | $AWK '
         { gsub(/\[ */, "[") }
 	$2 == ".ctors" || $2 == ".dtors" {
 	  size = strtonum("0x" $6)
@@ -6576,22 +6552,13 @@
   libc_cv_ctors_header=no
 fi
 
-
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	      { { $as_echo "$as_me:$LINENO: error: missing __attribute__ ((constructor)) support??" >&5
+    else
+      { { $as_echo "$as_me:$LINENO: error: missing __attribute__ ((constructor)) support??" >&5
 $as_echo "$as_me: error: missing __attribute__ ((constructor)) support??" >&2;}
    { (exit 1); exit 1; }; }
-
+    fi
+  rm -f conftest*
 fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-
-fi
 { $as_echo "$as_me:$LINENO: result: $libc_cv_ctors_header" >&5
 $as_echo "$libc_cv_ctors_header" >&6; }
   if test $libc_cv_ctors_header = no; then
Index: ChangeLog.eglibc
===================================================================
--- ChangeLog.eglibc	(revision 14702)
+++ ChangeLog.eglibc	(working copy)
@@ -1,3 +1,9 @@
+2011-07-25  Joseph Myers  <joseph@xxxxxxxxxxxxxxxx>
+
+	* configure.in (whether to use .ctors/.dtors header and trailer):
+	Avoid use of AC_TRY_LINK.
+	* configure: Regenerate.
+
 2011-07-22  Denis Zaitceff  <zaitceff@xxxxxxxxx>
 
 	* elf/dl-support.c, elf/rtld.c: Include <gnu/option-groups.h>.

-- 
Joseph S. Myers
joseph@xxxxxxxxxxxxxxxx