From 70d30dd656957f518b8169a125f6b17f53da8237 Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Sun, 5 May 2024 23:12:37 +0800 Subject: [PATCH] config-ml.in: Fix multi-os-dir search When building multilib libraries, CC/CXX etc are set with an option -B*/lib/, instead of -B/lib/. This will make some trouble in some case, for example building cross toolchain based on Debian's cross packages: If we have libc6-dev-i386-amd64-cross packages installed on a non-x86 machine. This package will have the files in /usr/x86_4-linux-gnu/lib32. The fellow configure will fail when build libgcc for i386, with complains the libc is not i386 ones: ../configure --enable-multilib --enable-multilib \ --target=x86_64-linux-gnu Let's insert a "-B*/lib/`CC ${flags} --print-multi-os-directory`" before "-B*/lib/". This patch is based on the patch used by Debian now. ChangeLog * config-ml.in: Insert an -B option with multi-os-dir into compiler commands used to build libraries. --- config-ml.in | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/config-ml.in b/config-ml.in index 68854a4f16c..645cac822fd 100644 --- a/config-ml.in +++ b/config-ml.in @@ -514,7 +514,12 @@ multi-do: else \ if [ -d ../$${dir}/$${lib} ]; then \ flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \ - if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \ + libsuffix_=`$${compiler} $${flags} --print-multi-os-directory`; \ + if (cd ../$${dir}/$${lib}; $(MAKE) $(subst \ + -B$(build_tooldir)/lib/, \ + -B$(build_tooldir)/lib/$${libsuffix_}/ \ + -B$(build_tooldir)/lib/, \ + $(FLAGS_TO_PASS)) \ CFLAGS="$(CFLAGS) $${flags}" \ CCASFLAGS="$(CCASFLAGS) $${flags}" \ FCFLAGS="$(FCFLAGS) $${flags}" \ @@ -768,6 +773,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then # Create a regular expression that matches any string as long # as ML_POPDIR. popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'` + multi_osdir=`${CC-gcc} ${flags} --print-multi-os-directory 2>/dev/null` CC_= for arg in ${CC}; do case $arg in @@ -775,6 +781,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\1/p"`' ' ;; "${ML_POPDIR}"/*) CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + CC_="${CC_}${arg}${multi_osdir} ${arg} " ;; *) CC_="${CC_}${arg} " ;; esac @@ -787,6 +795,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + CXX_="${CXX_}${arg}${multi_osdir} ${arg} " ;; *) CXX_="${CXX_}${arg} " ;; esac @@ -799,6 +809,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + F77_="${F77_}${arg}${multi_osdir} ${arg} " ;; *) F77_="${F77_}${arg} " ;; esac @@ -811,6 +823,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + GFORTRAN_="${GFORTRAN_}${arg}${multi_osdir} ${arg} " ;; *) GFORTRAN_="${GFORTRAN_}${arg} " ;; esac @@ -823,6 +837,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + GOC_="${GOC_}${arg}${multi_osdir} ${arg} " ;; *) GOC_="${GOC_}${arg} " ;; esac @@ -835,6 +851,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + GDC_="${GDC_}${arg}${multi_osdir} ${arg} " ;; *) GDC_="${GDC_}${arg} " ;; esac