On 22/01/20 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 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),

Typically they would only need to remove the .so symlink used when
linking, not the actual libiconv.so.NNN library that other things
depend on. If they put the symlink back again, it's only a problem
for other builds that might want the symlink, not for any
already-linked software using the shared library. Still not ideal
though.

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.

A much simpler solution is:

mkdir -p /tmp/iconv/lib
ln -s $real_iconv_prefix/include /tmp/iconv/
ln -s $real_iconv_prefix/lib64/libiconv.a /tmp/iconv/lib64

And then configure with --with-libiconv-prefix=/tmp/iconv

i.e. there's no need to build or install anything, just use symlinks
to create a new path that doesn't have the shared library.

It's still a bit more effort than with your new configure option, but
it's pretty trivial.

Reply via email to