diff mbox series

[4/5] MIPS: Detect toolchain support of o32 ABI with 64 bit CPU

Message ID 20230407102721.14814-5-jiaxun.yang@flygoat.com (mailing list archive)
State Superseded
Headers show
Series MIPS: LLVM toolchain support for more CPUs | expand

Commit Message

Jiaxun Yang April 7, 2023, 10:27 a.m. UTC
LLVM is not happy with using o32 ABI on 64 bit CPU, thus build 32 bit
kernel is unsupported.

Detect this in Kconfig to prevent user select 32 bit kernel with
unsupported toolchain.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/Kconfig | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Nick Desaulniers April 7, 2023, 10:19 p.m. UTC | #1
On Fri, Apr 7, 2023 at 3:27 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>
> LLVM is not happy with using o32 ABI on 64 bit CPU, thus build 32 bit
> kernel is unsupported.
>
> Detect this in Kconfig to prevent user select 32 bit kernel with
> unsupported toolchain.
>
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

I suspect this may fix:
Link: https://github.com/ClangBuiltLinux/linux/issues/884

> ---
>  arch/mips/Kconfig | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index d896af492da6..5e399a5ac3b3 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -2016,6 +2016,7 @@ choice
>  config 32BIT
>         bool "32-bit kernel"
>         depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL
> +       depends on CC_HAS_O32_ABI

Does this disable 32b mips builds with clang?

>         select TRAD_SIGNALS
>         help
>           Select this option if you want to build a 32-bit kernel.
> @@ -3136,7 +3137,7 @@ config COMPAT
>
>  config MIPS32_O32
>         bool "Kernel support for o32 binaries"
> -       depends on 64BIT
> +       depends on 64BIT && CC_HAS_O32_ABI
>         select ARCH_WANT_OLD_COMPAT_IPC
>         select COMPAT
>         select MIPS32_COMPAT
> @@ -3184,6 +3185,10 @@ config CC_HAS_DADDI_WORKAROUNDS
>  config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
>         def_bool y if CC_IS_CLANG
>
> +config CC_HAS_O32_ABI
> +       def_bool y
> +       depends on !CPU_SUPPORTS_64BIT_KERNEL || $(cc-option,-march=mips3 -mabi=32)

Should this be
def_bool $(cc-option,-march=mips3 -mabi=32)
depends on !CPU_SUPPORTS_64BIT_KERNEL

?

> +
>  config AS_HAS_MSA
>         def_bool $(cc-option,-Wa$(comma)-mmsa)
>
> --
> 2.39.2 (Apple Git-143)
>
Nick Desaulniers April 7, 2023, 10:21 p.m. UTC | #2
On Fri, Apr 7, 2023 at 3:19 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Fri, Apr 7, 2023 at 3:27 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
> >
> > LLVM is not happy with using o32 ABI on 64 bit CPU, thus build 32 bit
> > kernel is unsupported.
> >
> > Detect this in Kconfig to prevent user select 32 bit kernel with
> > unsupported toolchain.
> >
> > Reported-by: Nathan Chancellor <nathan@kernel.org>
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
> I suspect this may fix:
> Link: https://github.com/ClangBuiltLinux/linux/issues/884

Oh, and there was
https://github.com/ClangBuiltLinux/linux/issues/884#issuecomment-1242729142
I wonder if that is preferable or a source of inspiration?
Jiaxun Yang April 7, 2023, 10:26 p.m. UTC | #3
> 2023年4月7日 23:19,Nick Desaulniers <ndesaulniers@google.com> 写道:
> 
> On Fri, Apr 7, 2023 at 3:27 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>> 
>> LLVM is not happy with using o32 ABI on 64 bit CPU, thus build 32 bit
>> kernel is unsupported.
>> 
>> Detect this in Kconfig to prevent user select 32 bit kernel with
>> unsupported toolchain.
>> 
>> Reported-by: Nathan Chancellor <nathan@kernel.org>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> 
> I suspect this may fix:
> Link: https://github.com/ClangBuiltLinux/linux/issues/884
> 
>> ---
>> arch/mips/Kconfig | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>> index d896af492da6..5e399a5ac3b3 100644
>> --- a/arch/mips/Kconfig
>> +++ b/arch/mips/Kconfig
>> @@ -2016,6 +2016,7 @@ choice
>> config 32BIT
>>        bool "32-bit kernel"
>>        depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL
>> +       depends on CC_HAS_O32_ABI
> 
> Does this disable 32b mips builds with clang?

It disable 32bit kernel build for 64bit CPU with clang.

i.e.: 32bit kernel for R4000, 32bit kernel for MIPS64R2 is disabled, but you can still build 32 bit
kernel for mips32r2.

> 
>>        select TRAD_SIGNALS
>>        help
>>          Select this option if you want to build a 32-bit kernel.
>> @@ -3136,7 +3137,7 @@ config COMPAT
>> 
>> config MIPS32_O32
>>        bool "Kernel support for o32 binaries"
>> -       depends on 64BIT
>> +       depends on 64BIT && CC_HAS_O32_ABI
>>        select ARCH_WANT_OLD_COMPAT_IPC
>>        select COMPAT
>>        select MIPS32_COMPAT
>> @@ -3184,6 +3185,10 @@ config CC_HAS_DADDI_WORKAROUNDS
>> config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
>>        def_bool y if CC_IS_CLANG
>> 
>> +config CC_HAS_O32_ABI
>> +       def_bool y
>> +       depends on !CPU_SUPPORTS_64BIT_KERNEL || $(cc-option,-march=mips3 -mabi=32)
> 
> Should this be
> def_bool $(cc-option,-march=mips3 -mabi=32)
> depends on !CPU_SUPPORTS_64BIT_KERNEL

Hmm, the logic is to enable CC_HAS_O32_ABI if CPU is 32bit only (!CPU_SUPPORTS_64BIT_KERNEL)
or toolchain supports 64bit CPU with o32 ABI combination.

Thanks
Jiaxun

> 
> ?
> 
>> +
>> config AS_HAS_MSA
>>        def_bool $(cc-option,-Wa$(comma)-mmsa)
>> 
>> --
>> 2.39.2 (Apple Git-143)
>> 
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers
diff mbox series

Patch

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index d896af492da6..5e399a5ac3b3 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2016,6 +2016,7 @@  choice
 config 32BIT
 	bool "32-bit kernel"
 	depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL
+	depends on CC_HAS_O32_ABI
 	select TRAD_SIGNALS
 	help
 	  Select this option if you want to build a 32-bit kernel.
@@ -3136,7 +3137,7 @@  config COMPAT
 
 config MIPS32_O32
 	bool "Kernel support for o32 binaries"
-	depends on 64BIT
+	depends on 64BIT && CC_HAS_O32_ABI
 	select ARCH_WANT_OLD_COMPAT_IPC
 	select COMPAT
 	select MIPS32_COMPAT
@@ -3184,6 +3185,10 @@  config CC_HAS_DADDI_WORKAROUNDS
 config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
 	def_bool y if CC_IS_CLANG
 
+config CC_HAS_O32_ABI
+	def_bool y
+	depends on !CPU_SUPPORTS_64BIT_KERNEL || $(cc-option,-march=mips3 -mabi=32)
+
 config AS_HAS_MSA
 	def_bool $(cc-option,-Wa$(comma)-mmsa)