https://gcc.gnu.org/g:ea5cea17f6747512bf46e7db0bd24fc30e00c8c6

commit ea5cea17f6747512bf46e7db0bd24fc30e00c8c6
Author: Olivier Hainque <[email protected]>
Date:   Mon Oct 27 20:30:36 2025 +0000

    [PATCH] Turn x86_64-m32 configurations into biarch defaulting to m32
    
    Experimental changes.

Diff:
---
 gcc/ada/gcc-interface/Make-lang.in | 25 +++++++++++++++++++------
 gcc/ada/gcc-interface/Makefile.in  |  7 +++++++
 gcc/config.gcc                     |  4 ++--
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/gcc-interface/Make-lang.in 
b/gcc/ada/gcc-interface/Make-lang.in
index e768ef60ddf7..c264caa4c94e 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -192,10 +192,20 @@ GNATLS_FOR_HOST   = $(subst gnatmake,gnatls,$(GNATMAKE))
 
 # There are too many Ada sources to check against here.  Let's
 # always force the recursive make.
+
+# A native x86_64 compiler defaulting to -m32 is not suitable to build
+# 64bit host tools.  Arrange to build the tools with the base compiler
+# in this case, as we do for cross configurations.
+
+m32_target=$(filter x86_64%m32, $(target))
+not_m32_target=$(if $(m32_target),,$(target))
+
 ifeq ($(build), $(host))
-  ifeq ($(host), $(target))
-    # This is a regular native. So use the compiler from our current build
-    # tree.
+  native_target=$(filter $(host), $(target))
+
+  ifneq ($(and $(native_target), $(not_m32_target)),)
+    # This is a regular native. Use the compiler from our
+    # current build tree.
     ADA_TOOLS_FLAGS_TO_PASS=\
         CC="../../xgcc -B../../" \
         CXX="$(CXX)" \
@@ -205,8 +215,8 @@ ifeq ($(build), $(host))
         GNATLINK="../../gnatlink" \
         GNATBIND="../../gnatbind"
   else
-    # This is a regular cross compiler. Use the native compiler to compile
-    # the tools.
+    # This is a regular cross compiler or a 64bit native defaulting to -m32.
+    # Use the base native compiler to compile the tools.
 
     # put the host RTS dir first in the PATH to hide the default runtime
     # files that are among the sources
@@ -792,8 +802,11 @@ gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) 
$(GNATBIND_OBJS) $(EXTRA_HOST_OBJS)
        +$(GCC_LINK) -o $@ $(CFLAGS) ada/b_gnatb.o $(GNATBIND_OBJS) 
$(EXTRA_HOST_OBJS) ggc-none.o libcommon-target.a $(LIBS) $(SYSLIBS) $(GNATLIB)
 
 # use target-gcc target-gnatmake target-gnatbind target-gnatlink
+
+native_gnattools1=$(if $(not_m32_target),gnattools1,gnattools1-re)
+
 gnattools: $(CONFIG_H) prefix.o force
-       $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1
+       $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) $(native_gnattools1)
        $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools2
 
 regnattools:
diff --git a/gcc/ada/gcc-interface/Makefile.in 
b/gcc/ada/gcc-interface/Makefile.in
index 964a4d1b4491..cdaad954f990 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -358,6 +358,13 @@ ifeq ($(strip $(filter-out x86_64 linux-gnux32%, 
$(target_cpu) $(target_os))),)
   endif
 endif
 
+# The x86_64-*m32 compilers are x86_64 compilers defaulting to -m32
+ifeq ($(strip $(filter-out x86_64 %m32, $(target_cpu) $(target_os))),)
+  ifneq ($(strip $(MULTISUBDIR)),/64)
+    target_cpu:=i686
+  endif
+endif
+
 # The SuSE PowerPC64/Linux compiler is actually a 32-bit PowerPC compiler
 ifeq ($(strip $(filter-out powerpc64 suse linux%, $(target_cpu) 
$(target_vendor) $(target_os))),)
   target_cpu:=powerpc
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 952499b494c1..9ae039393fa8 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -689,8 +689,7 @@ x86_64-*-*)
                        exit 1
               esac
               case ${with_multilib_list} in
-              default | m32)
-                       with_multilib_list=m32
+              default | *m32*)
                        ;;
               *)
                        echo "Invalid multilib list for m32 target"
@@ -714,6 +713,7 @@ x86_64-*-*)
                tm_file="i386/biarchx32.h ${tm_file}"
                ;;
        32 | m32)
+               tm_defines="${tm_defines} TARGET_BI_ARCH=1"
                ;;
        *)
                echo "Unknown ABI used in --with-abi=$with_abi"

Reply via email to