public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Yubin Ruan <ablacktshirt@gmail.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
	gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: Use LTLIBICONV when linking libstdc++.so [PR93602]
Date: Thu, 21 Apr 2022 11:15:37 +0100	[thread overview]
Message-ID: <CACb0b4=c5Q7dfgTvH_krUroOrdRG+dPZ_XUrMpiPRyf+hMYd+w@mail.gmail.com> (raw)
In-Reply-To: <CAJYFCiOTVBW_S8MbL+Ne6PG4cdz=Pi7rMANGxzHCXoMt2UUfBw@mail.gmail.com>

On Thu, 21 Apr 2022 at 11:14, Yubin Ruan wrote:
>
> Hi,
>
> Will this be in GCC12?

Unless the patch gets reverted, yes. GCC 12 hasn't branched from trunk
yet, so everything on trunk will be in GCC 12.

>
> --
> Yubin
>
> On Wed, Apr 20, 2022 at 8:58 PM Jonathan Wakely via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > Pushed to trunk now.
> >
> > On Wed, 13 Apr 2022 at 15:24, Jonathan Wakely via Libstdc++
> > <libstdc++@gcc.gnu.org> wrote:
> > >
> > > Tested x86_64-linux, without libiconv installed, with libiconv installed,
> > > with libiconv installed but using an in-tree libiconv, with libiconv.a
> > > installed and using --with-libiconv-type=static, and with libiconv.so
> > > installed and using --without-libiconv-prefix (which still fails).
> > >
> > > I'm not entirely happy about the fact that libtool's LTLIBICONV adds an
> > > rpath to libstdc++.so, but that can be avoided (as documented by this
> > > patch) and I don't really see a better solution. Another option would be
> > > to use -l:libiconv.a if configure defines LTLIBICONV to non-empty and
> > > the linker supports it, which would *force* the use of a static lib. But
> > > that seems unnecessarily hostile; not all users will dislike the rpath
> > > solution. The proposed patch makes it Just Work™ for users who (for
> > > whatever reason) have installed libiconv, while also allowing them to do
> > > something more sensible if they care enough to do so.
> > >
> > > Thoughts?
> > >
> > > -- >8 --
> > >
> > > This fixes missing libiconv symbols when libstdc++ is built on a system
> > > that has libiconv installed. If the libiconv headers are found then
> > > libstdc++ depends on libiconv_open etc instead of libc's iconv_open. But
> > > without this fix libstdc++ is not linked to the libiconv library that
> > > provides the definitions of those symbols.
> > >
> > > As discussed in PR 93602 this changed means that libstdc++.so.6 might
> > > have an rpath pointing to the location of the libiconv.so library. If
> > > that is not desired, then GCC must be configured to link to a static
> > > libiconv.a instead, using either --with-libiconv-type=static or an
> > > in-tree build of libiconv.
> > >
> > > libstdc++-v3/ChangeLog:
> > >
> > >         PR libstdc++/93602
> > >         * doc/xml/manual/prerequisites.xml: Document libiconv
> > >         workarounds.
> > >         * doc/html/manual/setup.html: Regenerate.
> > >         * src/Makefile.am (CXXLINK): Add $(LTLIBICONV).
> > >         * src/Makefile.in: Regenerate.
> > > ---
> > > diff --git a/libstdc++-v3/doc/xml/manual/prerequisites.xml b/libstdc++-v3/doc/xml/manual/prerequisites.xml
> > > index 22e90a7e79d..8799487c821 100644
> > > --- a/libstdc++-v3/doc/xml/manual/prerequisites.xml
> > > +++ b/libstdc++-v3/doc/xml/manual/prerequisites.xml
> > > @@ -48,6 +48,56 @@
> > >        <varlistentry>
> > >         <term>linux</term>
> > >
> > > +       <listitem>
> > > +       <para>
> > > +         The 'gnu' locale model makes use of <function>iconv</function>
> > > +         for character set conversions. The relevant functions are provided
> > > +         by Glibc and so are always available, however they can also be
> > > +         provided by the separate GNU libiconv library. If GNU libiconv is
> > > +         found when GCC is built (e.g., because its headers are installed
> > > +         in <filename class="directory">/usr/local/include</filename>)
> > > +         then the <filename>libstdc++.so.6</filename> library will have a
> > > +         run-time dependency on <filename>libiconv.so.2</filename>.
> > > +         If you do not want that run-time dependency then you should do
> > > +         one of the following:
> > > +       </para>
> > > +       <itemizedlist>
> > > +         <listitem>
> > > +           <para>
> > > +             Uninstall the libiconv headers before building GCC.
> > > +             Glibc already provides <function>iconv</function> so you should
> > > +             not need libiconv anyway.
> > > +           </para>
> > > +         </listitem>
> > > +         <listitem>
> > > +           <para>
> > > +           <link linkend="https://www.gnu.org/software/libiconv/#downloading">
> > > +           Download</link> the libiconv sources and extract them into the
> > > +           top level of the GCC source tree, e.g.,
> > > +           </para>
> > > +<programlisting>
> > > +wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
> > > +tar xf libiconv-1.16.tar.gz
> > > +ln -s libiconv-1.16 libiconv
> > > +</programlisting>
> > > +           <para>
> > > +             This will build libiconv as part of building GCC and link to
> > > +             it statically, so there is no <filename>libiconv.so.2</filename>
> > > +             dependency.
> > > +           </para>
> > > +         </listitem>
> > > +         <listitem>
> > > +           <para>
> > > +             Configure GCC with <option>--with-libiconv-type=static</option>.
> > > +             This requires the static <filename>libiconv.a</filename> library,
> > > +             which is not installed by default. You might need to reinstall
> > > +             libiconv using the <option>--enable-static</option> configure
> > > +             option to get the static library.
> > > +           </para>
> > > +         </listitem>
> > > +       </itemizedlist>
> > > +       </listitem>
> > > +
> > >         <listitem>
> > >         <para>
> > >           If GCC 3.1.0 or later on is being used on GNU/Linux, an attempt
> > > diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
> > > index 18f57632c3d..9c3f4aca655 100644
> > > --- a/libstdc++-v3/src/Makefile.am
> > > +++ b/libstdc++-v3/src/Makefile.am
> > > @@ -278,7 +278,9 @@ CXXLINK = \
> > >         $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
> > >         --mode=link $(CXX) \
> > >         $(VTV_CXXLINKFLAGS) \
> > > -       $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
> > > +       $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
> > > +       $(LTLDFLAGS) $(LTLIBICONV) \
> > > +       -o $@
> > >
> > >  # Symbol versioning for shared libraries.
> > >  if ENABLE_SYMVERS
> > >
> >
>


      reply	other threads:[~2022-04-21 10:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13 14:23 Jonathan Wakely
2022-04-20 12:56 ` Jonathan Wakely
2022-04-21 10:13   ` Yubin Ruan
2022-04-21 10:15     ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACb0b4=c5Q7dfgTvH_krUroOrdRG+dPZ_XUrMpiPRyf+hMYd+w@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=ablacktshirt@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).