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

Bug#644662: Fails to build if GCC does not have libssp support



Source: eglibc
Version: 2.13-21
Severity: normal
Tags: upstream patch

The attached patch fixes detection of GCC -fstack-protector and libssp.

In order to properly detect whether or not GCC has -fstack-protect
support built in, you actually need to link something.  Otherwise
GCC will accept the option and fail during the link due to missing
libssp.

This occurs in particular when trying to bootstrap a cross-compiler for
a new Debian port; the stage2 cross-compiler does not have libssp
support causing "undefined reference to `__stack_chk_guard'" errors
when building EGLIBC.

The fix is simply to remove the "-c" from the "-fstack-protector" test,
so it verifies whether or not GCC can actually link objects built with
that option.

This fix should also be forwarded upstream.

Cheers,
Kyle Moffett

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (700, 'testing'), (700, 'stable'), (600, 'unstable'), (500, 'stable-updates'), (500, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.39-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
diff -ruN eglibc-2.13/debian/patches/any/local-fix-libssp-detection.patch eglibc-2.13.new/debian/patches/any/local-fix-libssp-detection.patch
--- eglibc-2.13/debian/patches/any/local-fix-libssp-detection.patch	1969-12-31 19:00:00.000000000 -0500
+++ eglibc-2.13.new/debian/patches/any/local-fix-libssp-detection.patch	2011-10-06 19:35:30.000000000 -0400
@@ -0,0 +1,32 @@
+Fix detection of GCC -fstack-protect and libssp support
+
+In order to properly detect whether or not GCC has -fstack-protect
+support built in, you actually need to link something.  Otherwise
+GCC will accept the option and fail during the link due to missing
+libssp.
+Index: eglibc-2.13/configure
+===================================================================
+--- eglibc-2.13.orig/configure	2011-10-06 19:31:36.000000000 -0400
++++ eglibc-2.13/configure	2011-10-06 19:33:13.000000000 -0400
+@@ -6942,7 +6942,7 @@
+   $as_echo_n "(cached) " >&6
+ else
+   if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -fstack-protector
+-			    -o /dev/null -c -x c /dev/null 1>&5'
++			    -o /dev/null -x c /dev/null 1>&5'
+   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+Index: eglibc-2.13/configure.in
+===================================================================
+--- eglibc-2.13.orig/configure.in	2011-10-06 19:31:36.000000000 -0400
++++ eglibc-2.13/configure.in	2011-10-06 19:33:06.000000000 -0400
+@@ -1792,7 +1792,7 @@
+ 
+ AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
+ if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -fstack-protector
+-			    -o /dev/null -c -x c /dev/null 1>&AS_MESSAGE_LOG_FD])
++			    -o /dev/null -x c /dev/null 1>&AS_MESSAGE_LOG_FD])
+ then
+   libc_cv_ssp=yes
+ else
diff -ruN eglibc-2.13/debian/patches/series eglibc-2.13.new/debian/patches/series
--- eglibc-2.13/debian/patches/series	2011-10-07 17:40:39.000000000 -0400
+++ eglibc-2.13.new/debian/patches/series	2011-10-06 19:32:45.000000000 -0400
@@ -289,3 +289,4 @@
 any/cvs-dlopen-tls.diff
 any/submitted-glob_h-ifdef.diff
 any/cvs-dl_close-scope-handling.diff
+any/local-fix-libssp-detection.patch

Reply to: