public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Arsen Arsenović" <arsen@aarsen.me>
To: gcc-patches@gcc.gnu.org
Cc: "Kévin Le Gouguec" <legouguec@adacore.com>,
	"Arsen Arsenović" <arsen@aarsen.me>
Subject: [PATCH 3/3] *: support in-tree libiconv again
Date: Sat, 13 Apr 2024 23:58:04 +0200	[thread overview]
Message-ID: <20240414001113.1698685-4-arsen@aarsen.me> (raw)
In-Reply-To: <20240414001113.1698685-1-arsen@aarsen.me>

ChangeLog:

	* Makefile.def: Inform gettext of our freshly-built libiconv.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (LIBICONV_SIBLING): If an in-tree host libiconv
	is being built, set this variable to the path to libiconv.a
	(LTLIBICONV_SIBLING): If an in-tree host libiconv is being
	built, set this variable to the path to libiconv.la.
	(LIBICONV_EXTRA_CPPFLAGS): If an in-tree host libiconv is being,
	set this variable to the appropriate CPPFLAGS for using the new
	libiconv.
	(LIBICONV_CVS): If an in-tree host libiconv is being, set this
	variable to the cache variables that iconv.m4 uses that need to
	be specicified in order to use the related variables.

config/ChangeLog:

	* iconv.m4: Restore modifications from GCC commit
	d485982286692075d175dbbcf17d00431106ce96 and co.

gcc/ChangeLog:

	* configure: Regenerate.

libcpp/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
---
 Makefile.def           |   7 +-
 Makefile.in            |  60 +++++------
 config/iconv.m4        |  50 +++++++--
 configure              |  25 +++++
 configure.ac           |  21 ++++
 gcc/configure          | 240 +++++++++++++++++++++++++++++++----------
 libcpp/configure       | 206 ++++++++++++++++++++++++++++-------
 libstdc++-v3/configure | 121 ++++++++++++++++-----
 8 files changed, 572 insertions(+), 158 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index d25edb6ed76d..c37f78f2e1da 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -78,11 +78,16 @@ host_modules= { module= gettext; bootstrap=true; no_install=true;
                 module_srcdir= "gettext/gettext-runtime";
 		// Don't override configure-discovered build arguments
 		all_args_override="";
+		// The toolchain build system overrides LDFLAGS that configure
+		// discovers, so specifying these flags as part of the
+		// configure arguments will not work.  Instead, we need to
+		// export them at configure time as well as make time.
+		extra_exports='LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS;';
 		// We always build gettext with pic, because some packages (e.g. gdbserver)
 		// need it in some configuratons, which is determined via nontrivial tests.
 		// Always enabling pic seems to make sense for something tied to
 		// user-facing output.
-		extra_configure_flags='--disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf';
+		extra_configure_flags='--disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@';
 		missing= pdf;
 		missing= html;
 		missing= info;
diff --git a/Makefile.in b/Makefile.in
index f71f515b7aa1..d65b4b2994a7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19856,7 +19856,7 @@ configure-gettext:
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	test ! -f $(HOST_SUBDIR)/gettext/Makefile || exit 0; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
-	$(HOST_EXPORTS)  \
+	$(HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring in $(HOST_SUBDIR)/gettext; \
 	cd "$(HOST_SUBDIR)/gettext" || exit 1; \
 	case $(srcdir) in \
@@ -19869,7 +19869,7 @@ configure-gettext:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf \
+	  --target=${target_alias} --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@ \
 	  || exit 1
 @endif gettext
 
@@ -19889,7 +19889,7 @@ configure-stage1-gettext:
 	$(HOST_EXPORTS) \
 	CFLAGS="$(STAGE1_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE1_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage 1 in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -19905,7 +19905,7 @@ configure-stage1-gettext:
 	  --target=${target_alias} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stage2-gettext maybe-configure-stage2-gettext
@@ -19923,7 +19923,7 @@ configure-stage2-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE2_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE2_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGE2_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGE2_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage 2 in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -19939,7 +19939,7 @@ configure-stage2-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stage3-gettext maybe-configure-stage3-gettext
@@ -19957,7 +19957,7 @@ configure-stage3-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE3_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE3_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGE3_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGE3_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage 3 in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -19973,7 +19973,7 @@ configure-stage3-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stage4-gettext maybe-configure-stage4-gettext
@@ -19991,7 +19991,7 @@ configure-stage4-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE4_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE4_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGE4_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGE4_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage 4 in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -20007,7 +20007,7 @@ configure-stage4-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stageprofile-gettext maybe-configure-stageprofile-gettext
@@ -20025,7 +20025,7 @@ configure-stageprofile-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEprofile_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEprofile_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEprofile_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGEprofile_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage profile in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -20041,7 +20041,7 @@ configure-stageprofile-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stagetrain-gettext maybe-configure-stagetrain-gettext
@@ -20059,7 +20059,7 @@ configure-stagetrain-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEtrain_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEtrain_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEtrain_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGEtrain_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage train in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -20075,7 +20075,7 @@ configure-stagetrain-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stagefeedback-gettext maybe-configure-stagefeedback-gettext
@@ -20093,7 +20093,7 @@ configure-stagefeedback-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEfeedback_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEfeedback_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEfeedback_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGEfeedback_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage feedback in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -20109,7 +20109,7 @@ configure-stagefeedback-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stageautoprofile-gettext maybe-configure-stageautoprofile-gettext
@@ -20127,7 +20127,7 @@ configure-stageautoprofile-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEautoprofile_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEautoprofile_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEautoprofile_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGEautoprofile_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage autoprofile in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -20143,7 +20143,7 @@ configure-stageautoprofile-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 .PHONY: configure-stageautofeedback-gettext maybe-configure-stageautofeedback-gettext
@@ -20161,7 +20161,7 @@ configure-stageautofeedback-gettext:
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEautofeedback_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEautofeedback_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEautofeedback_CFLAGS)"; export LIBCFLAGS;  \
+	LIBCFLAGS="$(STAGEautofeedback_CFLAGS)"; export LIBCFLAGS; LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	echo Configuring stage autofeedback in $(HOST_SUBDIR)/gettext; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gettext; \
 	cd $(HOST_SUBDIR)/gettext || exit 1; \
@@ -20177,7 +20177,7 @@ configure-stageautofeedback-gettext:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf
+	  --disable-shared --disable-threads --disable-java --disable-csharp --with-pic --disable-libasprintf CPPFLAGS="@LIBICONV_EXTRA_CPPFLAGS@ $$CPPFLAGS" @LIBICONV_CVS@
 @endif gettext-bootstrap
 
 
@@ -20195,7 +20195,7 @@ maybe-all-gettext: all-gettext
 all-gettext: configure-gettext
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS)  \
+	$(HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	(cd $(HOST_SUBDIR)/gettext && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS)  $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gettext))
@@ -20216,7 +20216,7 @@ all-stage1-gettext: configure-stage1-gettext
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE1_TFLAGS)"; \
-	$(HOST_EXPORTS)  \
+	$(HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20261,7 +20261,7 @@ all-stage2-gettext: configure-stage2-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE2_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20304,7 +20304,7 @@ all-stage3-gettext: configure-stage3-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE3_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20347,7 +20347,7 @@ all-stage4-gettext: configure-stage4-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE4_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20390,7 +20390,7 @@ all-stageprofile-gettext: configure-stageprofile-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEprofile_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20433,7 +20433,7 @@ all-stagetrain-gettext: configure-stagetrain-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEtrain_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20476,7 +20476,7 @@ all-stagefeedback-gettext: configure-stagefeedback-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20519,7 +20519,7 @@ all-stageautoprofile-gettext: configure-stageautoprofile-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEautoprofile_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	$$s/gcc/config/i386/$(AUTO_PROFILE) \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
@@ -20562,7 +20562,7 @@ all-stageautofeedback-gettext: configure-stageautofeedback-gettext
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEautofeedback_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS)  \
+	$(POSTSTAGE1_HOST_EXPORTS) LDFLAGS="@LTLIBICONV_SIBLING@ $$LDFLAGS"; export LDFLAGS; \
 	cd $(HOST_SUBDIR)/gettext && \
 	 \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
diff --git a/config/iconv.m4 b/config/iconv.m4
index ff5d52611397..cb07797ff218 100644
--- a/config/iconv.m4
+++ b/config/iconv.m4
@@ -6,6 +6,7 @@ dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Bruno Haible.
+dnl with modifications to support building with in-tree libiconv
 
 AC_PREREQ([2.64])
 
@@ -34,16 +35,15 @@ AC_DEFUN([AM_ICONV_LINK],
   dnl accordingly.
   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
 
-  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
-  dnl because if the user has installed libiconv and not disabled its use
-  dnl via --without-libiconv-prefix, he wants to use it. The first
-  dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
-  am_save_CPPFLAGS="$CPPFLAGS"
-  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
-
   AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
+    dnl Add $INCICONV to CPPFLAGS before performing the following checks,
+    dnl because if the user has installed libiconv and not disabled its use
+    dnl via --without-libiconv-prefix, he wants to use it. The first
+    dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
+    am_save_CPPFLAGS="$CPPFLAGS"
+    AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
     AC_LINK_IFELSE(
       [AC_LANG_PROGRAM(
          [[
@@ -54,8 +54,39 @@ AC_DEFUN([AM_ICONV_LINK],
            iconv(cd,NULL,NULL,NULL,NULL);
            iconv_close(cd);]])],
       [am_cv_func_iconv=yes])
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+          [iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);],
+          INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/"$_libs"/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          # The setup above only works if expanded at make time, so we need to
+          # suppress various configure-time tests.
+          am_cv_func_iconv_works=yes
+          am_cv_func_iconv=yes)
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       AC_LINK_IFELSE(
         [AC_LANG_PROGRAM(
@@ -68,6 +99,7 @@ AC_DEFUN([AM_ICONV_LINK],
              iconv_close(cd);]])],
         [am_cv_lib_iconv=yes]
         [am_cv_func_iconv=yes])
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
   ])
@@ -219,12 +251,10 @@ AC_DEFUN([AM_ICONV_LINK],
       [Define if you have the iconv() function and it works.])
   fi
   if test "$am_cv_lib_iconv" = yes; then
+    AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
     AC_MSG_CHECKING([how to link with libiconv])
     AC_MSG_RESULT([$LIBICONV])
   else
-    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
-    dnl either.
-    CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
diff --git a/configure b/configure
index 02b435c1163b..39771554ee27 100755
--- a/configure
+++ b/configure
@@ -679,6 +679,10 @@ RPATH_ENVVAR
 target_configargs
 host_configargs
 build_configargs
+LIBICONV_CVS
+LTLIBICONV_SIBLING
+LIBICONV_SIBLING
+LIBICONV_EXTRA_CPPFLAGS
 BUILD_CONFIG
 LDFLAGS_FOR_TARGET
 CXXFLAGS_FOR_TARGET
@@ -9978,6 +9982,27 @@ case " ${configdirs} " in
     ;;
 esac
 
+# Check whether we should inject an in-tree libiconv into our subconfigures.
+LIBICONV_EXTRA_CPPFLAGS=
+LIBICONV_SIBLING=
+LTLIBICONV_SIBLING=
+LIBICONV_CVS=
+case " ${configdirs} " in
+  *\ libiconv\ *)
+  # For out-of-tree dependencies that might use libiconv (e.g. gettext).
+  # https://lists.gnu.org/archive/html/bug-gettext/2023-11/msg00056.html
+  LIBICONV_EXTRA_CPPFLAGS="-I`${PWDCMD-pwd}`/\$(HOST_SUBDIR)/libiconv/include"
+  LIBICONV_SIBLING="`${PWDCMD-pwd}`/\$(HOST_SUBDIR)/libiconv/lib/.libs/libiconv.a"
+  LTLIBICONV_SIBLING="`${PWDCMD-pwd}`/\$(HOST_SUBDIR)/libiconv/lib/.libs/libiconv.la"
+  # Cache vars used for tricking iconv.m4.
+  LIBICONV_CVS="am_cv_func_iconv=yes am_cv_lib_iconv=no am_cv_func_iconv_works=yes"
+  ;;
+esac
+
+
+
+
+
 # Strip out unwanted targets.
 
 # While at that, we remove Makefiles if we were started for recursive
diff --git a/configure.ac b/configure.ac
index 1a19c07a27b8..991aa8eb441c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3097,6 +3097,27 @@ case " ${configdirs} " in
     ;;
 esac
 
+# Check whether we should inject an in-tree libiconv into our subconfigures.
+LIBICONV_EXTRA_CPPFLAGS=
+LIBICONV_SIBLING=
+LTLIBICONV_SIBLING=
+LIBICONV_CVS=
+case " ${configdirs} " in
+  *\ libiconv\ *)
+  # For out-of-tree dependencies that might use libiconv (e.g. gettext).
+  # https://lists.gnu.org/archive/html/bug-gettext/2023-11/msg00056.html
+  LIBICONV_EXTRA_CPPFLAGS="-I`${PWDCMD-pwd}`/\$(HOST_SUBDIR)/libiconv/include"
+  LIBICONV_SIBLING="`${PWDCMD-pwd}`/\$(HOST_SUBDIR)/libiconv/lib/.libs/libiconv.a"
+  LTLIBICONV_SIBLING="`${PWDCMD-pwd}`/\$(HOST_SUBDIR)/libiconv/lib/.libs/libiconv.la"
+  # Cache vars used for tricking iconv.m4.
+  LIBICONV_CVS="am_cv_func_iconv=yes am_cv_lib_iconv=no am_cv_func_iconv_works=yes"
+  ;;
+esac
+AC_SUBST([LIBICONV_EXTRA_CPPFLAGS])
+AC_SUBST([LIBICONV_SIBLING])
+AC_SUBST([LTLIBICONV_SIBLING])
+AC_SUBST([LIBICONV_CVS])
+
 # Strip out unwanted targets.
 
 # While at that, we remove Makefiles if we were started for recursive
diff --git a/gcc/configure b/gcc/configure
index 266ab8f84b2a..40fadb13737e 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -11792,31 +11792,6 @@ fi
 
 
 
-          am_save_CPPFLAGS="$CPPFLAGS"
-
-  for element in $INCICONV; do
-    haveit=
-    for x in $CPPFLAGS; do
-
-  acl_save_prefix="$prefix"
-  prefix="$acl_final_prefix"
-  acl_save_exec_prefix="$exec_prefix"
-  exec_prefix="$acl_final_exec_prefix"
-  eval x=\"$x\"
-  exec_prefix="$acl_save_exec_prefix"
-  prefix="$acl_save_prefix"
-
-      if test "X$x" = "X$element"; then
-        haveit=yes
-        break
-      fi
-    done
-    if test -z "$haveit"; then
-      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
-    fi
-  done
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
 $as_echo_n "checking for iconv... " >&6; }
 if ${am_cv_func_iconv+:} false; then :
@@ -11825,6 +11800,30 @@ else
 
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
+                    am_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -11846,8 +11845,52 @@ if ac_fn_cxx_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/"$_libs"/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          # The setup above only works if expanded at make time, so we need to
+          # suppress various configure-time tests.
+          am_cv_func_iconv_works=yes
+          am_cv_func_iconv=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -11871,6 +11914,7 @@ if ac_fn_cxx_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
 
@@ -12047,12 +12091,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h
 
   fi
   if test "$am_cv_lib_iconv" = yes; then
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
 $as_echo_n "checking how to link with libiconv... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
 $as_echo "$LIBICONV" >&6; }
   else
-            CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
@@ -14013,31 +14079,6 @@ $as_echo "$ac_res" >&6; }
 
 
 
-          am_save_CPPFLAGS="$CPPFLAGS"
-
-  for element in $INCICONV; do
-    haveit=
-    for x in $CPPFLAGS; do
-
-  acl_save_prefix="$prefix"
-  prefix="$acl_final_prefix"
-  acl_save_exec_prefix="$exec_prefix"
-  exec_prefix="$acl_final_exec_prefix"
-  eval x=\"$x\"
-  exec_prefix="$acl_save_exec_prefix"
-  prefix="$acl_save_prefix"
-
-      if test "X$x" = "X$element"; then
-        haveit=yes
-        break
-      fi
-    done
-    if test -z "$haveit"; then
-      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
-    fi
-  done
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
 $as_echo_n "checking for iconv... " >&6; }
 if ${am_cv_func_iconv+:} false; then :
@@ -14046,6 +14087,30 @@ else
 
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
+                    am_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -14067,8 +14132,52 @@ if ac_fn_cxx_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/"$_libs"/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          # The setup above only works if expanded at make time, so we need to
+          # suppress various configure-time tests.
+          am_cv_func_iconv_works=yes
+          am_cv_func_iconv=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -14092,6 +14201,7 @@ if ac_fn_cxx_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
 
@@ -14268,12 +14378,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h
 
   fi
   if test "$am_cv_lib_iconv" = yes; then
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
 $as_echo_n "checking how to link with libiconv... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
 $as_echo "$LIBICONV" >&6; }
   else
-            CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
@@ -21569,7 +21701,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21572 "configure"
+#line 21704 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21675,7 +21807,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21678 "configure"
+#line 21810 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libcpp/configure b/libcpp/configure
index 8a38c0546e3e..e704853b768a 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7654,31 +7654,6 @@ $as_echo "$ac_res" >&6; }
 
 
 
-          am_save_CPPFLAGS="$CPPFLAGS"
-
-  for element in $INCICONV; do
-    haveit=
-    for x in $CPPFLAGS; do
-
-  acl_save_prefix="$prefix"
-  prefix="$acl_final_prefix"
-  acl_save_exec_prefix="$exec_prefix"
-  exec_prefix="$acl_final_exec_prefix"
-  eval x=\"$x\"
-  exec_prefix="$acl_save_exec_prefix"
-  prefix="$acl_save_prefix"
-
-      if test "X$x" = "X$element"; then
-        haveit=yes
-        break
-      fi
-    done
-    if test -z "$haveit"; then
-      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
-    fi
-  done
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
 $as_echo_n "checking for iconv... " >&6; }
 if ${am_cv_func_iconv+:} false; then :
@@ -7687,6 +7662,30 @@ else
 
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
+                    am_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -7708,8 +7707,52 @@ if ac_fn_c_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/"$_libs"/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          # The setup above only works if expanded at make time, so we need to
+          # suppress various configure-time tests.
+          am_cv_func_iconv_works=yes
+          am_cv_func_iconv=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -7733,6 +7776,7 @@ if ac_fn_c_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
 
@@ -7909,12 +7953,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h
 
   fi
   if test "$am_cv_lib_iconv" = yes; then
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
 $as_echo_n "checking how to link with libiconv... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
 $as_echo "$LIBICONV" >&6; }
   else
-            CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
@@ -8694,7 +8760,15 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 
 
-          am_save_CPPFLAGS="$CPPFLAGS"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
+$as_echo_n "checking for iconv... " >&6; }
+if ${am_cv_func_iconv+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    am_cv_func_iconv="no, consider installing GNU libiconv"
+    am_cv_lib_iconv=no
+                    am_save_CPPFLAGS="$CPPFLAGS"
 
   for element in $INCICONV; do
     haveit=
@@ -8718,15 +8792,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
     fi
   done
 
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
-$as_echo_n "checking for iconv... " >&6; }
-if ${am_cv_func_iconv+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    am_cv_func_iconv="no, consider installing GNU libiconv"
-    am_cv_lib_iconv=no
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -8748,8 +8813,52 @@ if ac_fn_cxx_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/"$_libs"/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          # The setup above only works if expanded at make time, so we need to
+          # suppress various configure-time tests.
+          am_cv_func_iconv_works=yes
+          am_cv_func_iconv=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -8773,6 +8882,7 @@ if ac_fn_cxx_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
 
@@ -8949,12 +9059,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h
 
   fi
   if test "$am_cv_lib_iconv" = yes; then
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
 $as_echo_n "checking how to link with libiconv... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
 $as_echo "$LIBICONV" >&6; }
   else
-            CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 21abaeb07788..0d72b95c0ab2 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -26968,31 +26968,6 @@ fi
 
 
 
-          am_save_CPPFLAGS="$CPPFLAGS"
-
-  for element in $INCICONV; do
-    haveit=
-    for x in $CPPFLAGS; do
-
-  acl_save_prefix="$prefix"
-  prefix="$acl_final_prefix"
-  acl_save_exec_prefix="$exec_prefix"
-  exec_prefix="$acl_final_exec_prefix"
-  eval x=\"$x\"
-  exec_prefix="$acl_save_exec_prefix"
-  prefix="$acl_save_prefix"
-
-      if test "X$x" = "X$element"; then
-        haveit=yes
-        break
-      fi
-    done
-    if test -z "$haveit"; then
-      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
-    fi
-  done
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
 $as_echo_n "checking for iconv... " >&6; }
 if ${am_cv_func_iconv+:} false; then :
@@ -27001,6 +26976,30 @@ else
 
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
+                    am_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     if test x$gcc_no_link = xyes; then
   as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
 fi
@@ -27025,8 +27024,55 @@ if ac_fn_c_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/"$_libs"/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          # The setup above only works if expanded at make time, so we need to
+          # suppress various configure-time tests.
+          am_cv_func_iconv_works=yes
+          am_cv_func_iconv=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       if test x$gcc_no_link = xyes; then
   as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
@@ -27053,6 +27099,7 @@ if ac_fn_c_try_link "$LINENO"; then :
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
 
@@ -27229,12 +27276,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h
 
   fi
   if test "$am_cv_lib_iconv" = yes; then
+
+  for element in $INCICONV; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
 $as_echo_n "checking how to link with libiconv... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
 $as_echo "$LIBICONV" >&6; }
   else
-            CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
-- 
2.44.0


  parent reply	other threads:[~2024-04-14  0:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-13 21:58 [PATCH 0/3] Recover in-tree libiconv build support Arsen Arsenović
2024-04-13 21:58 ` [PATCH 1/3] toplevel: don't override gettext-runtime/configure-discovered build args Arsen Arsenović
2024-04-13 21:58 ` [PATCH 2/3] gitignore: ignore /libiconv* Arsen Arsenović
2024-04-13 21:58 ` Arsen Arsenović [this message]
2024-04-18 16:41 ` [PATCH 0/3] Recover in-tree libiconv build support Kévin Le Gouguec
2024-05-04 18:48 ` Ping: " Arsen Arsenović
2024-06-15 12:50   ` Ping^2: " Arsen Arsenović
2024-07-08  0:30     ` Ping^3: " Arsen Arsenović

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=20240414001113.1698685-4-arsen@aarsen.me \
    --to=arsen@aarsen.me \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=legouguec@adacore.com \
    /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).