gcc: Add new configure options to allow static libraries to be selected
diff mbox series

Message ID 20200122153911.21270-1-andrew.burgess@embecosm.com
State New
Headers show
Series
  • gcc: Add new configure options to allow static libraries to be selected
Related show

Commit Message

Andrew Burgess Jan. 22, 2020, 3:39 p.m. UTC
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: Regnerate.

libstdc++-v3/ChangeLog:

	* configure: Regnerate.
---
 config/ChangeLog       |  6 ++++++
 config/lib-link.m4     | 22 ++++++++++++++++------
 libcpp/ChangeLog       |  4 ++++
 libcpp/configure       | 29 +++++++++++++++++++++++------
 libstdc++-v3/ChangeLog |  4 ++++
 libstdc++-v3/configure | 47 ++++++++++++++++++++++++++++++++---------------
 6 files changed, 85 insertions(+), 27 deletions(-)

Comments

Jeff Law Jan. 22, 2020, 8:52 p.m. UTC | #1
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 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: 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.

jeff
>
Andrew Burgess Jan. 27, 2020, 10:03 p.m. UTC | #2
* Jeff Law <law@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 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: 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
Iain Sandoe Jan. 28, 2020, 10:34 a.m. UTC | #3
Hi Andrew,

Andrew Burgess <andrew.burgess@embecosm.com> wrote:

> * Jeff Law <law@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 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.

This kinda surprises me, gcc/ also configures for iconv

>>> 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.

this (r10-6269,  
https://gcc.gnu.org/g:e7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e) causes or  
exposes a problem which breaks bootstrap on all Darwin platforms I tried.

Bootstrap fails stage1 self-check with:
cc1: internal compiler error: in on_diagnostic, at input.c:2182

* AFAICT, this is caused by self-test attempting to do something that  
libcpp was not configured to support.

* All viable Darwin platforms have libiconv installed (but Darwin’s /lib is  
/usr/lib; this might well apply to other BSD derivatives too).

  * Before the patch, libcpp and gcc configury finds this and they agree on the availability of ICONV (#define HAVE_ICONV 1).

  * After the patch libcpp no longer thinks iconv is available, but gcc continues to find it - and that, I think, leads to it attempting tests for which libcpp has not been configured.

  * I can work around this by adding —with-iconv-prefix=/usr to the configure line which forces both libcpp and gcc to find the library explicitly - but that’s only a short-term solution.

Can you clarify why there’s no need to match the configury changes in  
libcpp / gcc / libstdc++ ?

thanks
Iain
Jonathan Wakely Jan. 28, 2020, 3:29 p.m. UTC | #4
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.
Tobias Burnus Jan. 29, 2020, 11:12 a.m. UTC | #5
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 <law@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
Andrew Burgess Jan. 30, 2020, 1:47 p.m. UTC | #6
* Iain Sandoe <idsandoe@googlemail.com> [2020-01-28 10:34:52 +0000]:

> Hi Andrew,
> 
> Andrew Burgess <andrew.burgess@embecosm.com> wrote:
> 
> > * Jeff Law <law@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 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.
> 
> This kinda surprises me, gcc/ also configures for iconv
> 
> > > > 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.
> 
> this (r10-6269,
> https://gcc.gnu.org/g:e7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e) causes or
> exposes a problem which breaks bootstrap on all Darwin platforms I tried.
> 
> Bootstrap fails stage1 self-check with:
> cc1: internal compiler error: in on_diagnostic, at input.c:2182

First, massive apologies for breaking this.  I'm aware that Jeff bent
the rules to allow me to commit this patch, so I feel terrible for
breaking things as a result.

> 
> * AFAICT, this is caused by self-test attempting to do something that libcpp
> was not configured to support.
> 
> * All viable Darwin platforms have libiconv installed (but Darwin’s /lib is
> /usr/lib; this might well apply to other BSD derivatives too).
> 
>  * Before the patch, libcpp and gcc configury finds this and they agree on the availability of ICONV (#define HAVE_ICONV 1).
> 
>  * After the patch libcpp no longer thinks iconv is available, but gcc continues to find it - and that, I think, leads to it attempting tests for which libcpp has not been configured.
>

This must be a bug, right?  With no changes to the configure scripts
both components should continue to find libiconv after this patch.
Even with the failure to update gcc/configure correctly (see below)
libcpp should continue to find the exact same libraries as before.

I took another look through the patch and I did spot one issue, which
I'm hoping is the cause of this problem, in lib-link.m4 I mostly
managed to write using 'sh' syntax, but in one place I messed up and
slipped back to (maybe?) bash syntax?

So I wrote this:

  if x$lib_type = xauto || x$lib_type = xshared; then

When I think I should have written:

  if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then

In all of the other places that I changed I correctly used 'test'
syntax, and I think they shouldn't make any difference to the
conditions that I modified.

Would you be able to test the patch below and let me know if it
resolves the build issue you're seeing please?  The patch doesn't have
ChangeLogs or commit message yet, and this point I'd just like to see
if this fixes the problem you're seeing.

>  * I can work around this by adding —with-iconv-prefix=/usr to the configure line which forces both libcpp and gcc to find the library explicitly - but that’s only a short-term solution.
> 
> Can you clarify why there’s no need to match the configury changes in libcpp
> / gcc / libstdc++ ?

This is the same issue that Tobias pointed out, and was a result of me
incorrectly trying to regenerate the configure files.

I obviously approached this problem the wrong way - I manually ran
autoreconf in all the directories containing a configure file, but
this didn't appear to do the correct thing.  I have had success with
this approach in other autotools based projects, but clearly it
doesn't work correctly here.

As Tobias suggested, when I rebuilt with --enable-maintainer-mode (and
with --enable-languages=all) I do see more files regenerated.

The patch below includes regeneration of all the missing files, as
well as updates for the 'test' syntax issue above.

Let me know if this resolves the problems you're seeing and if it does
I'll prepare it for submission.

Thanks,
Andrew

---

diff --git a/config/lib-link.m4 b/config/lib-link.m4
index 662192e0a07..20e281fd323 100644
--- a/config/lib-link.m4
+++ b/config/lib-link.m4
@@ -492,7 +492,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
             dnl known to the linker and runtime loader. (All the system
             dnl directories known to the linker should also be known to the
             dnl runtime loader, otherwise the system is severely misconfigured.)
-            if x$lib_type = xauto || x$lib_type = xshared; then
+            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
               LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
               LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
             else
diff --git a/gcc/configure b/gcc/configure
index e2c8fc71772..4c2c5991c0e 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 test "x$lib_type" = "xauto" || test "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
diff --git a/intl/configure b/intl/configure
index 2f35993148e..870b29f7d3f 100755
--- a/intl/configure
+++ b/intl/configure
@@ -719,8 +719,10 @@ enable_nls
 with_gnu_ld
 enable_rpath
 with_libiconv_prefix
+with_libiconv_type
 with_included_gettext
 with_libintl_prefix
+with_libintl_type
 enable_maintainer_mode
 '
       ac_precious_vars='build_alias
@@ -1353,9 +1355,11 @@ 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-included-gettext use the GNU gettext library included here
   --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
   --without-libintl-prefix     don't search for libintl in includedir and libdir
+  --with-libintl-type=TYPE     type of library to search for (auto/static/shared)
 
 Some influential environment variables:
   CC          C compiler command
@@ -5195,6 +5199,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=
@@ -5232,13 +5246,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"
@@ -5262,13 +5276,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"
@@ -5496,8 +5510,13 @@ fi
               done
             fi
           else
-                                                            LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
-            LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
+                                                            if test "x$lib_type" = "xauto" || test "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
@@ -6026,6 +6045,16 @@ if test "${with_libintl_prefix+set}" = set; then :
 
 fi
 
+
+# Check whether --with-libintl-type was given.
+if test "${with_libintl_type+set}" = set; then :
+  withval=$with_libintl_type;  with_libintl_type=$withval
+else
+   with_libintl_type=auto
+fi
+
+  lib_type=`eval echo \$with_libintl_type`
+
       LIBINTL=
   LTLIBINTL=
   INCINTL=
@@ -6063,13 +6092,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"
@@ -6093,13 +6122,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"
@@ -6327,8 +6356,13 @@ fi
               done
             fi
           else
-                                                            LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"
-            LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
+              LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"
+              LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"
+            else
+              LIBINTL="${LIBINTL}${LIBINTL:+ }-l:lib$name.$libext"
+              LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l:lib$name.$libext"
+            fi
           fi
         fi
       fi
diff --git a/libcpp/configure b/libcpp/configure
index 7e53cade210..11da199083b 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7066,7 +7066,7 @@ fi
               done
             fi
           else
-                                                            if x$lib_type = xauto || x$lib_type = xshared; then
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
               LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
               LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
             else
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 5e2892121f4..a39c33b055d 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -29506,7 +29506,7 @@ fi
               done
             fi
           else
-                                                            if x$lib_type = xauto || x$lib_type = xshared; then
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
               LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
               LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
             else
Iain Sandoe Jan. 30, 2020, 3:21 p.m. UTC | #7
Hi Andrew,

Andrew Burgess <andrew.burgess@embecosm.com> wrote:

> * Iain Sandoe <idsandoe@googlemail.com> [2020-01-28 10:34:52 +0000]:

>> * Before the patch, libcpp and gcc configury finds this and they agree on the availability of ICONV (#define HAVE_ICONV 1).
>> 
>> * After the patch libcpp no longer thinks iconv is available, but gcc continues to find it - and that, I think, leads to it attempting tests for which libcpp has not been configured.
> 
> This must be a bug, right?  With no changes to the configure scripts
> both components should continue to find libiconv after this patch.
> Even with the failure to update gcc/configure correctly (see below)
> libcpp should continue to find the exact same libraries as before.

not exactly sure which component you think has the bug in this case…

>> Can you clarify why there’s no need to match the configury changes in libcpp
>> / gcc / libstdc++ ?
> 
> This is the same issue that Tobias pointed out, and was a result of me
> incorrectly trying to regenerate the configure files.

.. but it seems that the combination of the two things produced the configuration
mismatch ..

> Let me know if this resolves the problems you're seeing and if it does
> I'll prepare it for submission.

I did a smoke test on Darwin19 and the amended patch allowed bootstrap to
 complete. ICONV is seen in both libcpp and gcc (that’s not an exhaustive check
and the testsuite is still running).

I’ll add this to my overnight runs - “overnight” means results later tomorrow for the
slower targets - but it looks encouraging.

thanks,
Iain
> 
> 
> diff --git a/config/lib-link.m4 b/config/lib-link.m4
> index 662192e0a07..20e281fd323 100644
> --- a/config/lib-link.m4
> +++ b/config/lib-link.m4
> @@ -492,7 +492,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
>             dnl known to the linker and runtime loader. (All the system
>             dnl directories known to the linker should also be known to the
>             dnl runtime loader, otherwise the system is severely misconfigured.)
> -            if x$lib_type = xauto || x$lib_type = xshared; then
> +            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
>               LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
>               LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
>             else
> diff --git a/gcc/configure b/gcc/configure
> index e2c8fc71772..4c2c5991c0e 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 test "x$lib_type" = "xauto" || test "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
> diff --git a/intl/configure b/intl/configure
> index 2f35993148e..870b29f7d3f 100755
> --- a/intl/configure
> +++ b/intl/configure
> @@ -719,8 +719,10 @@ enable_nls
> with_gnu_ld
> enable_rpath
> with_libiconv_prefix
> +with_libiconv_type
> with_included_gettext
> with_libintl_prefix
> +with_libintl_type
> enable_maintainer_mode
> '
>       ac_precious_vars='build_alias
> @@ -1353,9 +1355,11 @@ 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-included-gettext use the GNU gettext library included here
>   --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
>   --without-libintl-prefix     don't search for libintl in includedir and libdir
> +  --with-libintl-type=TYPE     type of library to search for (auto/static/shared)
> 
> Some influential environment variables:
>   CC          C compiler command
> @@ -5195,6 +5199,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=
> @@ -5232,13 +5246,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"
> @@ -5262,13 +5276,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"
> @@ -5496,8 +5510,13 @@ fi
>               done
>             fi
>           else
> -                                                            LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
> -            LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
> +                                                            if test "x$lib_type" = "xauto" || test "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
> @@ -6026,6 +6045,16 @@ if test "${with_libintl_prefix+set}" = set; then :
> 
> fi
> 
> +
> +# Check whether --with-libintl-type was given.
> +if test "${with_libintl_type+set}" = set; then :
> +  withval=$with_libintl_type;  with_libintl_type=$withval
> +else
> +   with_libintl_type=auto
> +fi
> +
> +  lib_type=`eval echo \$with_libintl_type`
> +
>       LIBINTL=
>   LTLIBINTL=
>   INCINTL=
> @@ -6063,13 +6092,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"
> @@ -6093,13 +6122,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"
> @@ -6327,8 +6356,13 @@ fi
>               done
>             fi
>           else
> -                                                            LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"
> -            LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"
> +                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
> +              LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"
> +              LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"
> +            else
> +              LIBINTL="${LIBINTL}${LIBINTL:+ }-l:lib$name.$libext"
> +              LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l:lib$name.$libext"
> +            fi
>           fi
>         fi
>       fi
> diff --git a/libcpp/configure b/libcpp/configure
> index 7e53cade210..11da199083b 100755
> --- a/libcpp/configure
> +++ b/libcpp/configure
> @@ -7066,7 +7066,7 @@ fi
>               done
>             fi
>           else
> -                                                            if x$lib_type = xauto || x$lib_type = xshared; then
> +                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
>               LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
>               LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
>             else
> diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
> index 5e2892121f4..a39c33b055d 100755
> --- a/libstdc++-v3/configure
> +++ b/libstdc++-v3/configure
> @@ -29506,7 +29506,7 @@ fi
>               done
>             fi
>           else
> -                                                            if x$lib_type = xauto || x$lib_type = xshared; then
> +                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
>               LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
>               LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
>             else
Andrew Burgess Jan. 30, 2020, 4:54 p.m. UTC | #8
* Iain Sandoe <idsandoe@googlemail.com> [2020-01-30 15:21:08 +0000]:

> >> Can you clarify why there’s no need to match the configury changes in libcpp
> >> / gcc / libstdc++ ?
> > 
> > This is the same issue that Tobias pointed out, and was a result of me
> > incorrectly trying to regenerate the configure files.
> 
> .. but it seems that the combination of the two things produced the configuration
> mismatch ..
> 
> > Let me know if this resolves the problems you're seeing and if it does
> > I'll prepare it for submission.
> 
> I did a smoke test on Darwin19 and the amended patch allowed bootstrap to
>  complete. ICONV is seen in both libcpp and gcc (that’s not an exhaustive check
> and the testsuite is still running).
> 
> I’ll add this to my overnight runs - “overnight” means results later tomorrow for the
> slower targets - but it looks encouraging.

Thanks, for checking this so quickly.

I'll prepare this as a proper patch and post this again later tonight
for review, but if your results are good tomorrow then I'll go ahead
and push this.

Thanks,
Andrew
Andrew Burgess Jan. 31, 2020, 12:28 a.m. UTC | #9
Here's a cleaned up version of the previous patch I posted.  If Iain
reports this fixes the regressions he saw then I will push this.

All feedback welcome.

Thanks,
Andrew

---

From 876996580d64d31407357787fc5df7bd5699b2c0 Mon Sep 17 00:00:00 2001
From: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Thu, 30 Jan 2020 12:18:13 +0000
Subject: [PATCH] Fixes after recent configure changes relating to static
 libraries

This commit:

  commit e7c26e04b2dd6266d62d5a5825ff7eb44d1cf14e (tjteru/master)
  Date:   Wed Jan 22 14:54:26 2020 +0000

      gcc: Add new configure options to allow static libraries to be selected

contains a couple of issues.  First I failed to correctly regenerate
all of the configure files it should have done.  Second, there was a
mistake in lib-link.m4, one of the conditions didn't use pure sh
syntax, I wrote this:

  if x$lib_type = xauto || x$lib_type = xshared; then

When I should have written this:

  if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then

These issues were raised on the mailing list in these messages:

  https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01827.html
  https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01921.html

config/ChangeLog:

	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Update shell syntax.

gcc/ChangeLog:

	* configure: Regenerate.

intl/ChangeLog:

	* configure: Regenerate.

libcpp/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
---
 config/ChangeLog       |  4 ++++
 config/lib-link.m4     |  2 +-
 gcc/ChangeLog          |  4 ++++
 gcc/configure          | 29 +++++++++++++++++++------
 intl/ChangeLog         |  4 ++++
 intl/configure         | 58 +++++++++++++++++++++++++++++++++++++++-----------
 libcpp/ChangeLog       |  4 ++++
 libcpp/configure       |  2 +-
 libstdc++-v3/ChangeLog |  4 ++++
 libstdc++-v3/configure |  2 +-
 10 files changed, 92 insertions(+), 21 deletions(-)

diff --git a/config/lib-link.m4 b/config/lib-link.m4
index 662192e0a07..20e281fd323 100644
--- a/config/lib-link.m4
+++ b/config/lib-link.m4
@@ -492,7 +492,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
             dnl known to the linker and runtime loader. (All the system
             dnl directories known to the linker should also be known to the
             dnl runtime loader, otherwise the system is severely misconfigured.)
-            if x$lib_type = xauto || x$lib_type = xshared; then
+            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
               LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
               LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
             else
diff --git a/gcc/configure b/gcc/configure
index e2c8fc71772..4c2c5991c0e 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 test "x$lib_type" = "xauto" || test "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
diff --git a/intl/configure b/intl/configure
index 2f35993148e..870b29f7d3f 100755
--- a/intl/configure
+++ b/intl/configure
@@ -719,8 +719,10 @@ enable_nls
 with_gnu_ld
 enable_rpath
 with_libiconv_prefix
+with_libiconv_type
 with_included_gettext
 with_libintl_prefix
+with_libintl_type
 enable_maintainer_mode
 '
       ac_precious_vars='build_alias
@@ -1353,9 +1355,11 @@ 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-included-gettext use the GNU gettext library included here
   --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
   --without-libintl-prefix     don't search for libintl in includedir and libdir
+  --with-libintl-type=TYPE     type of library to search for (auto/static/shared)
 
 Some influential environment variables:
   CC          C compiler command
@@ -5195,6 +5199,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=
@@ -5232,13 +5246,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"
@@ -5262,13 +5276,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"
@@ -5496,8 +5510,13 @@ fi
               done
             fi
           else
-                                                            LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
-            LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
+                                                            if test "x$lib_type" = "xauto" || test "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
@@ -6026,6 +6045,16 @@ if test "${with_libintl_prefix+set}" = set; then :
 
 fi
 
+
+# Check whether --with-libintl-type was given.
+if test "${with_libintl_type+set}" = set; then :
+  withval=$with_libintl_type;  with_libintl_type=$withval
+else
+   with_libintl_type=auto
+fi
+
+  lib_type=`eval echo \$with_libintl_type`
+
       LIBINTL=
   LTLIBINTL=
   INCINTL=
@@ -6063,13 +6092,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"
@@ -6093,13 +6122,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"
@@ -6327,8 +6356,13 @@ fi
               done
             fi
           else
-                                                            LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"
-            LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
+              LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"
+              LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"
+            else
+              LIBINTL="${LIBINTL}${LIBINTL:+ }-l:lib$name.$libext"
+              LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l:lib$name.$libext"
+            fi
           fi
         fi
       fi
diff --git a/libcpp/configure b/libcpp/configure
index 7e53cade210..11da199083b 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7066,7 +7066,7 @@ fi
               done
             fi
           else
-                                                            if x$lib_type = xauto || x$lib_type = xshared; then
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
               LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
               LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
             else
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 5e2892121f4..a39c33b055d 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -29506,7 +29506,7 @@ fi
               done
             fi
           else
-                                                            if x$lib_type = xauto || x$lib_type = xshared; then
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
               LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
               LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
             else
Iain Sandoe Jan. 31, 2020, 8:18 p.m. UTC | #10
Hello Andrew,

Andrew Burgess <andrew.burgess@embecosm.com> wrote:

> Here's a cleaned up version of the previous patch I posted.  If Iain
> reports this fixes the regressions he saw then I will push this.

I applied this to r10-6364 and tested on a bunch of Darwin platforms.

AFAICT, the configuration now reports consistent values between
libcpp, gcc, intl, and libstdc++-v3.

Bootstrap succeeded with my “normal” defaults, and testing appears
nominal.

Notes:

* I have only tested on Darwin, I’m assuming you have tested on other
  platforms.

* there are now a number of interacting ICONV options, I made no
  attempt to test multiple permutations.

thanks for the fix,
cheers
Iain
Andrew Burgess Feb. 1, 2020, 12:38 a.m. UTC | #11
* Iain Sandoe <idsandoe@googlemail.com> [2020-01-31 20:18:58 +0000]:

> Hello Andrew,
> 
> Andrew Burgess <andrew.burgess@embecosm.com> wrote:
> 
> > Here's a cleaned up version of the previous patch I posted.  If Iain
> > reports this fixes the regressions he saw then I will push this.
> 
> I applied this to r10-6364 and tested on a bunch of Darwin platforms.
> 
> AFAICT, the configuration now reports consistent values between
> libcpp, gcc, intl, and libstdc++-v3.
> 
> Bootstrap succeeded with my “normal” defaults, and testing appears
> nominal.
> 
> Notes:
> 
> * I have only tested on Darwin, I’m assuming you have tested on other
>  platforms.
> 
> * there are now a number of interacting ICONV options, I made no
>  attempt to test multiple permutations.

Thanks, I've gone ahead and pushed this fix.  I tested this on my
local machine with no issues, and with your positive results I think I
should get this in sooner rather than later.

Once again, sorry for the breakage.

Thanks,
Andrew

Patch
diff mbox series

diff --git a/config/lib-link.m4 b/config/lib-link.m4
index eeb200d266d..662192e0a07 100644
--- a/config/lib-link.m4
+++ b/config/lib-link.m4
@@ -150,6 +150,11 @@  AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
       fi
     fi
 ])
+  AC_LIB_ARG_WITH([lib$1-type],
+[  --with-lib$1-type=TYPE     type of library to search for (auto/static/shared) ],
+  [ with_lib$1_type=$withval ], [ with_lib$1_type=auto ])
+  lib_type=`eval echo \$with_lib$1_type`
+
   dnl Search the library and its dependencies in $additional_libdir and
   dnl $LDFLAGS. Using breadth-first-seach.
   LIB[]NAME=
@@ -195,13 +200,13 @@  AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
           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"
@@ -217,13 +222,13 @@  AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
               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"
@@ -487,8 +492,13 @@  AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
             dnl known to the linker and runtime loader. (All the system
             dnl directories known to the linker should also be known to the
             dnl runtime loader, otherwise the system is severely misconfigured.)
-            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
-            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
+            if x$lib_type = xauto || x$lib_type = xshared; then
+              LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+              LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
+            else
+              LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l:lib$name.$libext"
+              LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l:lib$name.$libext"
+            fi
           fi
         fi
       fi
diff --git a/libcpp/configure b/libcpp/configure
index a7aa35c5be0..7e53cade210 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
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d2e516df6d0..a5b9c7ddd0c 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -931,6 +931,7 @@  enable_libstdcxx_time
 enable_tls
 enable_rpath
 with_libiconv_prefix
+with_libiconv_type
 with_system_libunwind
 enable_linux_futex
 enable_symvers
@@ -1664,6 +1665,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-system-libunwind use installed libunwind
   --with-default-libstdcxx-abi
                           set the std::string ABI to use by default
@@ -12053,7 +12055,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12056 "configure"
+#line 12058 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12159,7 +12161,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12162 "configure"
+#line 12164 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15851,7 +15853,7 @@  $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 15854 "configure"
+#line 15856 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -15886,7 +15888,7 @@  $as_echo "$glibcxx_cv_atomic_bool" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15889 "configure"
+#line 15891 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -15921,7 +15923,7 @@  $as_echo "$glibcxx_cv_atomic_short" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15924 "configure"
+#line 15926 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -15957,7 +15959,7 @@  $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15960 "configure"
+#line 15962 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16110,7 +16112,7 @@  $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16113 "configure"
+#line 16115 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16152,7 +16154,7 @@  ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16155 "configure"
+#line 16157 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -16186,7 +16188,7 @@  $as_echo "$enable_int128" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16189 "configure"
+#line 16191 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -29152,6 +29154,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=
@@ -29189,13 +29201,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"
@@ -29219,13 +29231,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"
@@ -29453,8 +29465,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