public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] config-ml.in: Fix multi-os-dir search
@ 2024-01-01 16:48 YunQiang Su
  2024-01-02 16:59 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: YunQiang Su @ 2024-01-01 16:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: doko, YunQiang Su

When building multilib libraries, CC/CXX etc are set with an option
-B*/lib/, instead of -B<something>/lib/<multi-os-directory>.
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
-- 
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] config-ml.in: Fix multi-os-dir search
  2024-01-01 16:48 [PATCH] config-ml.in: Fix multi-os-dir search YunQiang Su
@ 2024-01-02 16:59 ` Jeff Law
  2024-04-29  3:15   ` YunQiang Su
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2024-01-02 16:59 UTC (permalink / raw)
  To: YunQiang Su, gcc-patches; +Cc: doko



On 1/1/24 09:48, YunQiang Su wrote:
> When building multilib libraries, CC/CXX etc are set with an option
> -B*/lib/, instead of -B<something>/lib/<multi-os-directory>.
> 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.
I would prefer this to wait for gcc-15.   I'll go ahead and ACK it for 
gcc-15 though.

What would also be valuable would be to extract out the rest of the 
multiarch patches from the Debian patches and get those into into GCC 
proper.

Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] config-ml.in: Fix multi-os-dir search
  2024-01-02 16:59 ` Jeff Law
@ 2024-04-29  3:15   ` YunQiang Su
  0 siblings, 0 replies; 3+ messages in thread
From: YunQiang Su @ 2024-04-29  3:15 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches, doko

Jeff Law <jeffreyalaw@gmail.com> 于2024年1月3日周三 01:00写道:
>
>
>
> On 1/1/24 09:48, YunQiang Su wrote:
> > When building multilib libraries, CC/CXX etc are set with an option
> > -B*/lib/, instead of -B<something>/lib/<multi-os-directory>.
> > 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.
> I would prefer this to wait for gcc-15.   I'll go ahead and ACK it for
> gcc-15 though.
>

I noticed that the gcc-14 branch has been created, and the basever has also
been 15.0 now.
Is it time for this patch now?

> What would also be valuable would be to extract out the rest of the
> multiarch patches from the Debian patches and get those into into GCC
> proper.
>
> Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-29  3:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-01 16:48 [PATCH] config-ml.in: Fix multi-os-dir search YunQiang Su
2024-01-02 16:59 ` Jeff Law
2024-04-29  3:15   ` YunQiang Su

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).