aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-01-22 14:54:26 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-01-27 22:02:35 +0000
commite7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e (patch)
tree62d830b9fba6b4823faf161909504f0bbde3bdb5 /libcpp
parent15d552394e1cb94598eef278ff3d9e9876097b33 (diff)
downloadgcc-e7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e.zip
gcc-e7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e.tar.gz
gcc-e7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e.tar.bz2
gcc: Add new configure options to allow static libraries to be selected
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 libiconv. 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: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate.
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog4
-rwxr-xr-xlibcpp/configure29
2 files changed, 27 insertions, 6 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index e84c0da..ea9d602 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,7 @@
+2020-01-27 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * configure: Regenerate.
+
2020-01-24 Nathan Sidwell <nathan@acm.org>
* expr.c (parse_has_include): Remove bogus controlling macro code.
diff --git a/libcpp/configure b/libcpp/configure
index a7aa35c..7e53cad 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -730,6 +730,7 @@ enable_werror_always
with_gnu_ld
enable_rpath
with_libiconv_prefix
+with_libiconv_type
enable_maintainer_mode
enable_checking
enable_canonical_system_headers
@@ -1383,6 +1384,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)
Some influential environment variables:
CC C compiler command
@@ -6753,6 +6755,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=
@@ -6790,13 +6802,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"
@@ -6820,13 +6832,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"
@@ -7054,8 +7066,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