public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [PATCH] Correct DLL Installation Path for x86_64-w64-mingw32 Multilib [PR115094]
@ 2024-05-14 20:26 trcrsired
  2024-05-15  7:46 ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: trcrsired @ 2024-05-14 20:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: trcrsired

From: trcrsired <uwgghhbcad@gmail.com>

When building native GCC for the x86_64-w64-mingw32 host, the compiler copies its library DLLs to the `bin` directory. However, in the case of a multilib configuration, both 32-bit and 64-bit libraries end up in the same `bin` directory, leading to conflicts where 64-bit DLLs are overridden by their 32-bit counterparts.

This patch addresses the issue by adjusting the installation path for the libraries. Specifically, it installs the libraries to separate directories: `lib` for 64-bit and `lib32` for 32-bit. This behavior aligns with how libraries are installed when creating an x86_64-w64-mingw32 cross-compiler without copying them to the `bin` directory if it is a multilib build.
---
 gcc/configure           | 26 ++++++++++++++++++++++++++
 libatomic/configure     | 13 +++++++++++++
 libbacktrace/configure  | 13 +++++++++++++
 libcc1/configure        | 26 ++++++++++++++++++++++++++
 libffi/configure        | 26 ++++++++++++++++++++++++++
 libgfortran/configure   | 26 ++++++++++++++++++++++++++
 libgm2/configure        | 26 ++++++++++++++++++++++++++
 libgo/config/libtool.m4 | 13 +++++++++++++
 libgo/configure         | 13 +++++++++++++
 libgomp/configure       | 26 ++++++++++++++++++++++++++
 libgrust/configure      | 26 ++++++++++++++++++++++++++
 libitm/configure        | 26 ++++++++++++++++++++++++++
 libobjc/configure       | 13 +++++++++++++
 libphobos/configure     | 13 +++++++++++++
 libquadmath/configure   | 13 +++++++++++++
 libsanitizer/configure  | 26 ++++++++++++++++++++++++++
 libssp/configure        | 13 +++++++++++++
 libstdc++-v3/configure  | 26 ++++++++++++++++++++++++++
 libtool.m4              | 13 +++++++++++++
 libvtv/configure        | 26 ++++++++++++++++++++++++++
 lto-plugin/configure    | 13 +++++++++++++
 zlib/configure          | 13 +++++++++++++
 22 files changed, 429 insertions(+)

diff --git a/gcc/configure b/gcc/configure
index aaf5899cc03..beab6df1878 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -20472,6 +20472,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -20481,6 +20493,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -24200,6 +24213,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -24209,6 +24234,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libatomic/configure b/libatomic/configure
index 32cb3ecac26..cb17a863719 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -10518,6 +10518,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10527,6 +10539,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libbacktrace/configure b/libbacktrace/configure
index ab94a85f45c..644d523c3cb 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -10696,6 +10696,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10705,6 +10717,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libcc1/configure b/libcc1/configure
index ea689a353c8..8233251c6e9 100755
--- a/libcc1/configure
+++ b/libcc1/configure
@@ -9952,6 +9952,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -9961,6 +9973,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -14086,6 +14099,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -14095,6 +14120,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libffi/configure b/libffi/configure
index f82a45b13bc..d5c3717803c 100755
--- a/libffi/configure
+++ b/libffi/configure
@@ -10750,6 +10750,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10759,6 +10771,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -14478,6 +14491,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -14487,6 +14512,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libgfortran/configure b/libgfortran/configure
index 774dd52fc95..b092ee0a75d 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -11896,6 +11896,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11905,6 +11917,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -15742,6 +15755,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -15751,6 +15776,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libgm2/configure b/libgm2/configure
index 13861f0ff93..0b1471187ff 100755
--- a/libgm2/configure
+++ b/libgm2/configure
@@ -13588,6 +13588,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -13597,6 +13609,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -17340,6 +17353,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -17349,6 +17374,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libgo/config/libtool.m4 b/libgo/config/libtool.m4
index 4ca90ee71bc..25436f1187c 100644
--- a/libgo/config/libtool.m4
+++ b/libgo/config/libtool.m4
@@ -2219,6 +2219,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -2228,6 +2240,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libgo/configure b/libgo/configure
index c0d0a1560f5..d39bb637c5f 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -10633,6 +10633,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10642,6 +10654,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libgomp/configure b/libgomp/configure
index ad245b47dff..22f879046a5 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -10531,6 +10531,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10540,6 +10552,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -14247,6 +14260,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -14256,6 +14281,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libgrust/configure b/libgrust/configure
index dcdc3142fa2..7abc1a8b13a 100755
--- a/libgrust/configure
+++ b/libgrust/configure
@@ -11699,6 +11699,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11708,6 +11720,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -15451,6 +15464,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -15460,6 +15485,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libitm/configure b/libitm/configure
index 9ba7fb03a57..31db9015c18 100755
--- a/libitm/configure
+++ b/libitm/configure
@@ -11193,6 +11193,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11202,6 +11214,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -14921,6 +14934,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -14930,6 +14955,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libobjc/configure b/libobjc/configure
index 68172549137..32160f9a547 100755
--- a/libobjc/configure
+++ b/libobjc/configure
@@ -9920,6 +9920,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -9929,6 +9941,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libphobos/configure b/libphobos/configure
index 9b6a41879d3..0d9a877455d 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -10929,6 +10929,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10938,6 +10950,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libquadmath/configure b/libquadmath/configure
index 49d70809218..2882c1f30c2 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -9966,6 +9966,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -9975,6 +9987,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libsanitizer/configure b/libsanitizer/configure
index 6bfd28916d2..56b217d123a 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -11537,6 +11537,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11546,6 +11558,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -15265,6 +15278,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -15274,6 +15299,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libssp/configure b/libssp/configure
index 0052e03650d..e8560a861f7 100755
--- a/libssp/configure
+++ b/libssp/configure
@@ -10208,6 +10208,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -10217,6 +10229,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 21abaeb0778..df7f77751ea 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -11324,6 +11324,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11333,6 +11345,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -15076,6 +15089,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -15085,6 +15110,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libtool.m4 b/libtool.m4
index add2d4a1e23..0e1006f18db 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -2293,6 +2293,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -2302,6 +2314,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/libvtv/configure b/libvtv/configure
index a7889161c50..64d904757c9 100755
--- a/libvtv/configure
+++ b/libvtv/configure
@@ -11431,6 +11431,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11440,6 +11452,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
@@ -15159,6 +15172,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -15168,6 +15193,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/lto-plugin/configure b/lto-plugin/configure
index 28f5dd79cd7..56d4915673b 100755
--- a/lto-plugin/configure
+++ b/lto-plugin/configure
@@ -11303,6 +11303,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -11312,6 +11324,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
diff --git a/zlib/configure b/zlib/configure
index 92c462d04c6..ba3ad8101d6 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -9898,6 +9898,18 @@ cygwin* | mingw* | pw32* | cegcc*)
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
+    # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
+    if test ${multilib} = yes; then
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      $install_prog $dir/$dlname $destdir/$dlname~
+      chmod a+x $destdir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
+      fi'
+    else
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
@@ -9907,6 +9919,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
+    fi
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $RM \$dlpath'
-- 
2.34.1


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

end of thread, other threads:[~2024-05-15 11:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 20:26 [PATCH] [PATCH] Correct DLL Installation Path for x86_64-w64-mingw32 Multilib [PR115094] trcrsired
2024-05-15  7:46 ` Richard Biener
2024-05-15  9:02   ` unlvsur unlvsur
2024-05-15  9:28     ` Richard Biener
2024-05-15  9:39       ` unlvsur unlvsur
2024-05-15 11:16         ` Richard Biener

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