https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93602

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I confirmed that --without-libiconv-prefix doesn't work. With GNU libiconv
installed as /usr/local/lib/libiconv.so.2 it breaks the compiler:

/gccobj/./gcc/xgcc -B/gccobj/./gcc/ -dumpspecs > tmp-specs
/gccobj/./gcc/xgcc: error while loading shared libraries: libiconv.so.2: cannot
open shared object file: No such file or directory


(In reply to Jonathan Wakely from comment #16)
> I think we need to use LTLIBICONV when linking libstdc++.

But that adds the libiconv libdir to libstdc++.so.6's RPATH, which can result
in user applications picking up unwanted version of other libraries.

Simply adding -liconv isn't a solution either, because that might create a
runtime dependency on a libiconv.so that isn't in the ldconfig search paths,
and so won't be found at run-time. That just moves the problem from link-time
to run-time.

I tried configuring libiconv with --enable-static (which is disabled by
default) and configuring GCC with --with-libiconv-type=static which cause
LTLIBICONV=/usr/local/lib/libiconv.a to be defined by libstdc++'s configure.
But that still fails, because libstdc++-v3/src/Makefile doesn't use LTLIBICONV,
so we still don't link libstdc++.so to it. 

A better solution is to add the libiconv sources to the GCC source tree, so
that it is built in-tree. If the libiconv sources are in a dir called
"libiconv" at the top level of the GCC source tree then a static libiconv.a
will be built as part of the GCC build. But we still don't link libstdc++.so to
it without using LTLIBICONV.

So although I'm reluctant to add LTLIBICONV to the libstdc++ build, because of
the rpath effects, I think we need to do it. Users who don't want those rpath
effects can link to an out-of-tree libiconv.a or build and use an in-tree
libiconv.a

Of course the best approach is just to not install libiconv on glibc systems at
all, because it's unnecessary.

Reply via email to