From 704fffcfb11d1b41e276bbb52624c393ff7e4428 Mon Sep 17 00:00:00 2001
From: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Date: Wed, 31 Jul 2019 17:11:08 +0100
Subject: GCC: libstdc++ has a link to libiconv

After adding the libiconv library to the template, the C++ library uses
three of its functions (`libiconv', `libiconv_open' and
`libiconv_close'). However, it doesn't explicity link with it inside its
shared library!

I tried by exporting `LIBS=-liconv' before the GCC configure script but it
crashed as soon as it went on to the second GCC building stage (because
this environment variable was no longer present there). I also tried adding
the C++ configure option of `--enable-cstdio' to the GCC configure options
(so it doesn't use iconv according to the manual), but it made no change.

With this commit, as a brute-force solution, `patchelf --add-needed' is run
on the installed `libstdc++.so', so `libiconv.so' is explicitly included
inside the `libstdc++' shared library.

This bug was found by Roberto Baena Galle while trying to load Matplotlib
(which needed the C++ library).

This fixes bug #56702.
---
 .file-metadata                   | Bin 6468 -> 6123 bytes
 reproduce/software/make/basic.mk |   1 +
 2 files changed, 1 insertion(+)

diff --git a/.file-metadata b/.file-metadata
index 2dfb5d6..28f008f 100644
Binary files a/.file-metadata and b/.file-metadata differ
diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk
index 98aea0d..fc28683 100644
--- a/reproduce/software/make/basic.mk
+++ b/reproduce/software/make/basic.mk
@@ -1180,6 +1180,7 @@ $(ibidir)/gcc: $(gcc-tarball) \
 	  && cd ../.. \
 	  && rm -rf gcc-$(gcc-version) \
 	  && if [ "x$(on_mac_os)" != xyes ]; then \
+	       patchelf --add-needed $(ildir)/libiconv.so $(ildir)/libstdc++.so; \
 	       for f in $$(find $(idir)/libexec/gcc) $(ildir)/libstdc++*; do \
 	         if ldd $$f &> /dev/null; then \
 	           patchelf --set-rpath $(ildir) $$f; \
-- 
cgit v1.2.1