From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 048DA3857343; Thu, 21 Apr 2022 10:13:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 048DA3857343 Received: by mail-lf1-x12b.google.com with SMTP id bq30so7823658lfb.3; Thu, 21 Apr 2022 03:13:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sHgWKMKkp4HaXcBbHMt3dkiPqMYMidTcgf/s5YpGV4w=; b=Y855sfk1jOEfMcKM4laUsYspG+LYHQWi9Mc6QjqT5v9Da/NF9x1qFBEzCy/eIFlK6t pd9BOS76Ypfso1MqS2C6GfjAOhoWHmMnyi4voNDAMVodTHvHmwzG5DkIIuDWRbKPg2pR WbeDUNd30L5lANUq+vpj1ky0S5ysHhiGHjkHlbr9MA8R91tfFcKinE6CXe9ImweeiyIY Rdb/B2waRIjZwDG5U5NIqomcz1Hvxw+rwwoAkATY7b9mL9mV732uqwxWyAS5Rs9Zwfs9 aN7Rr2VdT4/Fz6K86fxmH0lOYi8IzXQFWVSIZjf3x2DMESCUe2eRETHy6f9GOapj4Dul 1/mg== X-Gm-Message-State: AOAM533g+NHakMtLOU/3WAJn+eXh9kFwjGS9BNDit06KJzD0mYobOY9o vMh18vIBaHYpqbWN4ATtnx1oTGK0HOvAk8BFxQ== X-Google-Smtp-Source: ABdhPJydSw7vKQO+1IAUnjgV94AMMAtGJna96iSfeZ5f2ZfBWzHj0IYNUUQMyN8NqoLQyIRVfZDs6Moc3VbHB/GOIr8= X-Received: by 2002:a05:6512:239e:b0:471:9b79:70bf with SMTP id c30-20020a056512239e00b004719b7970bfmr11808776lfv.297.1650536034176; Thu, 21 Apr 2022 03:13:54 -0700 (PDT) MIME-Version: 1.0 References: <20220413142359.577396-1-jwakely@redhat.com> In-Reply-To: From: Yubin Ruan Date: Thu, 21 Apr 2022 18:13:43 +0800 Message-ID: Subject: Re: [PATCH] libstdc++: Use LTLIBICONV when linking libstdc++.so [PR93602] To: Jonathan Wakely Cc: "libstdc++" , gcc Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 10:13:58 -0000 Hi, Will this be in GCC12? -- Yubin On Wed, Apr 20, 2022 at 8:58 PM Jonathan Wakely via Libstdc++ wrote: > > Pushed to trunk now. > > On Wed, 13 Apr 2022 at 15:24, Jonathan Wakely via Libstdc++ > wrote: > > > > Tested x86_64-linux, without libiconv installed, with libiconv installe= d, > > with libiconv installed but using an in-tree libiconv, with libiconv.a > > installed and using --with-libiconv-type=3Dstatic, 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 b= e > > 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. Bu= t > > that seems unnecessarily hostile; not all users will dislike the rpath > > solution. The proposed patch makes it Just Work=E2=84=A2 for users who = (for > > whatever reason) have installed libiconv, while also allowing them to d= o > > 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. Bu= t > > 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=3Dstatic 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 @@ > > > > linux > > > > + > > + > > + The 'gnu' locale model makes use of iconv > > + for character set conversions. The relevant functions are pro= vided > > + by Glibc and so are always available, however they can also b= e > > + provided by the separate GNU libiconv library. If GNU libicon= v is > > + found when GCC is built (e.g., because its headers are instal= led > > + in /usr/local/include) > > + then the libstdc++.so.6 library will hav= e a > > + run-time dependency on libiconv.so.2. > > + If you do not want that run-time dependency then you should d= o > > + one of the following: > > + > > + > > + > > + > > + Uninstall the libiconv headers before building GCC. > > + Glibc already provides iconv so you = should > > + not need libiconv anyway. > > + > > + > > + > > + > > + > > + Download the libiconv sources and extract them into = the > > + top level of the GCC source tree, e.g., > > + > > + > > +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 > > + > > + > > + This will build libiconv as part of building GCC and link= to > > + it statically, so there is no libiconv.so.2 > > + dependency. > > + > > + > > + > > + > > + Configure GCC with confi= gure > > + option to get the static library. > > + > > + > > + > > + > > + > > > > > > If GCC 3.1.0 or later on is being used on GNU/Linux, an attem= pt > > diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.a= m > > index 18f57632c3d..9c3f4aca655 100644 > > --- a/libstdc++-v3/src/Makefile.am > > +++ b/libstdc++-v3/src/Makefile.am > > @@ -278,7 +278,9 @@ CXXLINK =3D \ > > $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ > > --mode=3Dlink $(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 > > >