Hi Andrew,
I think when committing this patch, you missed to regenerate gcc/configure.
At least with --enable-maintainer-mode, I see the attached changes – and
I think they come from your patch. (Line numbers might be off as I
edited out my changes.) — The other changes are due to
https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01920.html
Can you check? – I haven't checked whether any other sub-configures have
to be regenerated, maybe some other lib*/configure need to be updated as
well.
Cheers,
Tobias
On 1/27/20 11:03 PM, Andrew Burgess wrote:
* Jeff Law <l...@redhat.com> [2020-01-22 13:52:27 -0700]:
On Wed, 2020-01-22 at 15:39 +0000, Andrew Burgess wrote:
The motivation behind this change is to make it easier for a user to
link against static libraries on a target where dynamic libraries are
the default library type (for example GNU/Linux).
Further, my motivation is really for linking libraries into GDB,
however, the binutils-gdb/config/ directory is a copy of gcc/config/
so changes for GDB need to be approved by the GCC project first.
After making this change in the gcc/config/ directory I've run
autoreconf on all of the configure scripts in the GCC tree and a
couple have been updated, so I'll use one of these to describe what my
change does.
Consider libcpp, this library links against lib
Can you check? – I haven't checked whether any other sub-configures
have to be regenerated, maybe some other lib*/configure need to be
updated as well.
iconv. Currently if
the user builds on a system with both static and dynamic libiconv
installed then autotools will pick up the dynamic libiconv by
default. This is almost certainly the right thing to do.
However, if the user wants to link against static libiconv then things
are a little harder, they could remove the dynamic libiconv from their
system, but this is probably a bad idea (other things might depend on
that library), or the user can build their own version of libiconv,
install it into a unique prefix, and then configure gcc using the
--with-libiconv-prefix=DIR flag. This works fine, but is somewhat
annoying, the static library available, I just can't get autotools to
use it.
My change then adds a new flag --with-libiconv-type=TYPE, where type
is either auto, static, or shared. The default auto, ensures we keep
the existing behaviour unchanged.
If the user configures with --with-libiconv-type=static then the
configure script will ignore any dynamic libiconv it finds, and will
only look for a static libiconv, if no static libiconv is found then
the configure will continue as though there is no libiconv at all
available.
Similarly a user can specify --with-libiconv-type=shared and force the
use of shared libiconv, any static libiconv will be ignored.
As I've implemented this change within the AC_LIB_LINKFLAGS_BODY macro
then only libraries configured using the AC_LIB_LINKFLAGS or
AC_LIB_HAVE_LINKFLAGS macros will gain the new configure flag.
If this is accepted into GCC then there will be follow on patches for
binutils and GDB to regenerate some configure scripts in those
projects.
For GCC only two configure scripts needed updated after this commit,
libcpp and libstdc++-v3, both of which link against libiconv.
config/ChangeLog:
* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Add new
--with-libXXX-type=... option. Use this to guide the selection of
either a shared library or a static library.
libcpp/ChangeLog:
* configure: Regnerate.
libstdc++-v3/ChangeLog:
* configure: Regnerate.
s/Regnerate/Regenerate/
This isn't strictly a regression bugfix. But given the nature of these
files I think we probably need to be a bit more lax and allow safe
changes so that downstream uses can move forward independent of the gcc
development and release schedule.
So, OK.
Thanks for the flexibility. Now pushed.
Thanks,
Andrew
diff --git a/gcc/config.in b/gcc/config.in
index ec5c46abdb5..05dc9499f22 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2185,6 +2191,12 @@
#endif
+/* Define if your target C Library properly handles PT_GNU_STACK */
+#ifndef USED_FOR_TARGET
+#undef TARGET_LIBC_GNUSTACK
+#endif
+
+
/* Define if your target C Library provides the AT_HWCAP value in the TCB */
#ifndef USED_FOR_TARGET
#undef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB
diff --git a/gcc/configure b/gcc/configure
index 490fe6ac8e8..facbbacd06a 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -974,6 +974,7 @@ with_zstd_include
with_zstd_lib
enable_rpath
with_libiconv_prefix
+with_libiconv_type
enable_sjlj_exceptions
with_gcc_major_version_only
enable_secureplt
@@ -1811,6 +1812,7 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and libdir
+ --with-libiconv-type=TYPE type of library to search for (auto/static/shared)
--with-gcc-major-version-only
use only GCC major number in filesystem paths
--with-pic try to use only PIC/non-PIC objects [default=use
@@ -10730,6 +10732,16 @@ if test "${with_libiconv_prefix+set}" = set; then :
fi
+
+# Check whether --with-libiconv-type was given.
+if test "${with_libiconv_type+set}" = set; then :
+ withval=$with_libiconv_type; with_libiconv_type=$withval
+else
+ with_libiconv_type=auto
+fi
+
+ lib_type=`eval echo \$with_libiconv_type`
+
LIBICONV=
LTLIBICONV=
INCICONV=
@@ -10767,13 +10779,13 @@ fi
found_so=
found_a=
if test $use_additional = yes; then
- if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+ if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext" && test x$lib_type != xstatic; then
found_dir="$additional_libdir"
found_so="$additional_libdir/lib$name.$shlibext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
- else
+ elif test x$lib_type != xshared; then
if test -f "$additional_libdir/lib$name.$libext"; then
found_dir="$additional_libdir"
found_a="$additional_libdir/lib$name.$libext"
@@ -10797,13 +10809,13 @@ fi
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
- if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+ if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext" && test x$lib_type != xstatic; then
found_dir="$dir"
found_so="$dir/lib$name.$shlibext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
- else
+ elif test x$lib_type != xshared; then
if test -f "$dir/lib$name.$libext"; then
found_dir="$dir"
found_a="$dir/lib$name.$libext"
@@ -11031,8 +11043,13 @@ fi
done
fi
else
- LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
- LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
+ if x$lib_type = xauto || x$lib_type = xshared; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l:lib$name.$libext"
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l:lib$name.$libext"
+ fi
fi
fi
fi
@@ -18957,7 +18974,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 18960 "configure"
+#line 18977 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19063,7 +19080,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19066 "configure"
+#line 19083 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -29800,6 +29850,23 @@ $as_echo "#define TARGET_LIBC_PROVIDES_HWCAP_IN_TCB 1" >>confdefs.h
fi
+# Check if the target LIBC handles PT_GNU_STACK.
+gcc_cv_libc_gnustack=unknown
+case "$target" in
+ mips*-*-linux*)
+
+if test $glibc_version_major -gt 2 \
+ || ( test $glibc_version_major -eq 2 && test $glibc_version_minor -ge 31 ); then :
+ gcc_cv_libc_gnustack=yes
+fi
+ ;;
+esac
+if test x$gcc_cv_libc_gnustack = xyes; then
+
+$as_echo "#define TARGET_LIBC_GNUSTACK 1" >>confdefs.h
+
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dl_iterate_phdr in target C library" >&5
$as_echo_n "checking dl_iterate_phdr in target C library... " >&6; }
gcc_cv_target_dl_iterate_phdr=unknown