[PATCH] MIPS: gas: alter 64 or 32 for r6 triples if march is implicit

Jiaxun Yang jiaxun.yang@flygoat.com
Sat May 6 08:42:48 GMT 2023



> 2023年5月6日 09:37,YunQiang Su <yunqiang.su@cipunited.com> 写道:
> 
> When configure with triples mipsisa[32,64]r6[el,], the march value
> is pinned to a fix value if not given explicitly. for example
>   mipsisa32r6-linux-gnu -n32 xx.s
> will complains that:
>   -march=mips32r6 is not compatible with the selected ABI
> 
> Since we are using these triples as a regular linux distributions,
> let's alter march according to ABI.

Hi,

Hmm, why people wants to build n32 binary on mips32r6 CPU?
For multiline folks they should use mipsisa64r6 base triple which will accept
all 3 ABIs.

Thanks
Jiaxun


> ---
> gas/config/tc-mips.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
> 
> diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
> index 8a970ceada2..d99736df26a 100644
> --- a/gas/config/tc-mips.c
> +++ b/gas/config/tc-mips.c
> @@ -20247,6 +20247,24 @@ mips_parse_cpu (const char *option, const char *cpu_string)
>     : ISA_MIPS1);
>     }
> 
> +  /* mipsisa32r6-linux-gnu refuses -n32/-64 swtiches:
> + -march=mips32r6 is not compatible with the selected ABI
> +     Let's workaround it when -march options are not given explicitly.
> +     We treat it some like -march=from-abi */
> +  if ((strcasecmp (cpu_string, "mips32r6") == 0 || strcasecmp (cpu_string, "mips64r6") == 0)
> + && strcasecmp (option, "default CPU") == 0)
> +    {
> +      if (ABI_NEEDS_32BIT_REGS (mips_abi))
> + return mips_cpu_info_from_isa (ISA_MIPS32R6);
> +
> +      if (ABI_NEEDS_64BIT_REGS (mips_abi))
> + return mips_cpu_info_from_isa (ISA_MIPS64R6);
> +
> +      if (file_mips_opts.gp >= 0)
> + return mips_cpu_info_from_isa (file_mips_opts.gp == 32
> +       ? ISA_MIPS32R6 : ISA_MIPS64R6);
> +    }
> +
>   /* 'default' has traditionally been a no-op.  Probably not very useful.  */
>   if (strcasecmp (cpu_string, "default") == 0)
>     return 0;
> -- 
> 2.30.2
> 



More information about the Binutils mailing list