On Thu, Oct 30, 2025 at 2:42 AM Alexandre Oliva <[email protected]> wrote:
>
> On Oct 27, 2025, Richard Biener <[email protected]> wrote:
>
> > So on x86-64-linux this is a cross configuration?
>
> It's one of those cross-natives corner cases.
>
> > Or is this able to bootstrap itself but then resulting in a 32bit host
> > compiler?
>
> Yeah, it can bootstrap.  (It needs an additional tweak to fix multilibs
> in libgnat.)

If bootstrap is used, it is the same as i686-linux with
--with-multilib-list=m32,m64.

> But the interesting use case for this is the non-bootstrap case.

If it is the case, why not use x86-64-linux --with-abi=m32?

> A variant of this change that enables multilibs, and that could be more
> interesting to bootstrap, can also bootstrap starting with an
> x86_64-linux-gnu compiler with -m64 added to BOOT_CFLAGS, along with an
> -L flag to find the 64-bit libstdc++, but you hit post-bootstrap
> incompatibilities building e.g. fixincludes (and gnattools?) between the
> 64-bit libiberty (and other bootstrapped libraries), and the 32-bit
> outputs from the bootstrapped compiler used to build the post-bootstrap
> host tools.
>
> Non-bootstrapped builds don't hit this incompatibility, because the
> initial 64-bit compiler, rather than the just-built one, is used to
> build these host tools.
>
> Here's an incremental change, also by Olivier Hainque, that enables
> biarch -m32-defaulting x86_64-linux-gnum32.
>
>
> [PATCH] Turn x86_64-m32 configurations into biarch defaulting to m32
>
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 8d96ef00005ad..7c85d04184b88 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_file="i386/biarch32.h ${tm_file}"
>                 ;;
>         *)
>                 echo "Unknown ABI used in --with-abi=$with_abi"
> diff --git a/gcc/config/i386/biarch32.h b/gcc/config/i386/biarch32.h
> new file mode 100644
> index 0000000000000..116cd68acc838
> --- /dev/null
> +++ b/gcc/config/i386/biarch32.h
> @@ -0,0 +1,29 @@
> +/* Make configure files to produce biarch compiler defaulting to 64bit mode.
> +   This file must be included very first, while the OS specific file later
> +   to overwrite otherwise wrong defaults.
> +   Copyright (C) 2001-2025 Free Software Foundation, Inc.
> +   Contributed by Bo Thorsen <[email protected]>.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 3, or (at your option)
> +any later version.
> +
> +GCC is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +GNU General Public License for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#define TARGET_64BIT_DEFAULT 0
> +#define TARGET_BI_ARCH 3
> diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
> index dadcf7664c632..443041789555b 100644
> --- a/gcc/config/i386/i386-options.cc
> +++ b/gcc/config/i386/i386-options.cc
> @@ -2018,22 +2018,35 @@ ix86_option_override_internal (bool main_args_p,
>  #ifdef TARGET_BI_ARCH
>    else
>      {
> -#if TARGET_BI_ARCH == 1
> -      /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
> -        is on and OPTION_MASK_ABI_X32 is off.  We turn off
> -        OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
> -        -mx32.  */
> -      if (TARGET_X32_P (opts->x_ix86_isa_flags))
> -       opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
> -#else
> -      /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
> -        on and OPTION_MASK_ABI_64 is off.  We turn off
> -        OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
> -        -m64 or OPTION_MASK_CODE16 is turned on by -m16.  */
> -      if (TARGET_LP64_P (opts->x_ix86_isa_flags)
> -         || TARGET_16BIT_P (opts->x_ix86_isa_flags))
> -       opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
> -#endif
> +      switch (TARGET_BI_ARCH)
> +       {
> +       case 1:
> +           /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
> +              is on and OPTION_MASK_ABI_X32 is off.  We turn off
> +              OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
> +              -mx32.  */
> +           if (TARGET_X32_P (opts->x_ix86_isa_flags))
> +             opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
> +           break;
> +
> +       case 2:
> +         /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
> +            on and OPTION_MASK_ABI_64 is off.  We turn off
> +            OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
> +            -m64 or OPTION_MASK_CODE16 is turned on by -m16.  */
> +         if (TARGET_LP64_P (opts->x_ix86_isa_flags)
> +             || TARGET_16BIT_P (opts->x_ix86_isa_flags))
> +           opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
> +
> +       case 3:
> +         /* When TARGET_BI_ARCH == 3, by default, OPTION_MASK_ABI_X32 and
> +            OPTION_MASK_ABI_64 are both off.  */
> +         break;
> +
> +       default:
> +         gcc_unreachable();
> +       }
> +
>        if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
>           && TARGET_IAMCU_P (opts->x_target_flags))
>         sorry ("Intel MCU psABI isn%'t supported in %s mode",
>
>
> --
> Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
> Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity.
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive!



-- 
H.J.

Reply via email to