This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Fix .ctors/.dtors header configure test for bootstrapping


This next patch in the series improving support for building glibc as
part of bootstrapping cross tools deals with the configure test for
.ctors/.dtors header and trailer.  This uses AC_TRY_LINK and does need
to be a link test (it examines properties of the linked binary) so it
is changed to use the same approach as the libc_cv_initfini_array
test: a source file that defines _start, __start (which one is used
may depend on the architecture) and all other functions needed is
compiled and linked with -static -nostartfiles -nostdlib using
AC_TRY_COMMAND.

Tested x86_64 (native).

2012-03-07  Joseph Myers  <joseph@codesourcery.com>

	* configure.in (libc_cv_ctors_header): Avoid use of AC_TRY_LINK.
	* configure: Regenerated.

diff --git a/configure.in b/configure.in
index 7ebeba4..5ce753d 100644
--- a/configure.in
+++ b/configure.in
@@ -1374,11 +1374,16 @@ fi
 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" {
@@ -1393,10 +1398,10 @@ __attribute__ ((destructor))  void dtor (void) { puts("dtor"); }
 	  exit ((ctors_ok && dtors_ok) ? 0 : 1)
 	}
       '], [libc_cv_ctors_header=no])
-    ], [dnl
-      AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
-    ])
-])
+  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

-- 
Joseph S. Myers
joseph@codesourcery.com


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