linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] MIPS: Loongson: Fix build error when make modules_install
@ 2023-06-28 11:08 Huacai Chen
  2023-06-28 15:22 ` Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Huacai Chen @ 2023-06-28 11:08 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Huacai Chen, linux-mips, Jiaxun Yang, Huacai Chen, stable,
	Feiyang Chen, Nathan Chancellor, Nick Desaulniers

After commit 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of
cc-ifversion") we get a build error when make modules_install:

cc1: error: '-mloongson-mmi' must be used with '-mhard-float'

The reason is when make modules_install, 'call cc-option' doesn't work
in $(KBUILD_CFLAGS) of 'CHECKFLAGS'. Then there is no -mno-loongson-mmi
applied and -march=loongson3a enable MMI instructions.

To be detail, the error message comes from the CHECKFLAGS invocation of
$(CC) but it has no impact on the final result of make modules_install,
it is purely a cosmetic issue. The error occurs because cc-option is
defined in scripts/Makefile.compiler, which is not included in Makefile
when running 'make modules_install', as install targets are not supposed
to require the compiler; see commit 805b2e1d427aab4b ("kbuild: include
Makefile.compiler only when compiler is needed"). As a result, the call
to check for '-mno-loongson-mmi' just never happens.

Fix this by partially reverting to the old logic, use 'call cc-option'
to conditionally apply -march=loongson3a and -march=mips64r2.

By the way, Loongson-2E/2F is also broken in commit 13ceb48bc19c563e05f4
("MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls") so fix it
together.

Fixes: 13ceb48bc19c563e05f4 ("MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls")
Fixes: 0e96ea5c3eb5904e5dc2 ("MIPS: Loongson64: Clean up use of cc-ifversion")
Cc: stable@vger.kernel.org
Cc: Feiyang Chen <chenfeiyang@loongson.cn>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
V2: Update commit message and fix for LOONGSON2EF together.

 arch/mips/Makefile | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index a7a4ee66a9d3..35a1b9b34734 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -181,16 +181,12 @@ endif
 cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
 cflags-$(CONFIG_CPU_BMIPS)	+= -march=mips32 -Wa,-mips32 -Wa,--trap
 
-cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap
-cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON2E) += $(call cc-option,-march=loongson2e) -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON2F) += $(call cc-option,-march=loongson2f) -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-march=loongson3a,-march=mips64r2) -Wa,--trap
 # Some -march= flags enable MMI instructions, and GCC complains about that
 # support being enabled alongside -msoft-float. Thus explicitly disable MMI.
 cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi)
-ifdef CONFIG_CPU_LOONGSON64
-cflags-$(CONFIG_CPU_LOONGSON64)	+= -Wa,--trap
-cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a
-cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2
-endif
 cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi)
 
 cflags-$(CONFIG_CPU_R4000_WORKAROUNDS)	+= $(call cc-option,-mfix-r4000,)
-- 
2.39.3


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

* Re: [PATCH V2] MIPS: Loongson: Fix build error when make modules_install
  2023-06-28 11:08 [PATCH V2] MIPS: Loongson: Fix build error when make modules_install Huacai Chen
@ 2023-06-28 15:22 ` Nathan Chancellor
  2023-07-03 14:09 ` Thomas Bogendoerfer
  2023-07-18 14:43 ` Maciej W. Rozycki
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-06-28 15:22 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Thomas Bogendoerfer, Huacai Chen, linux-mips, Jiaxun Yang, stable,
	Feiyang Chen, Nick Desaulniers

On Wed, Jun 28, 2023 at 07:08:47PM +0800, Huacai Chen wrote:
> After commit 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of
> cc-ifversion") we get a build error when make modules_install:
> 
> cc1: error: '-mloongson-mmi' must be used with '-mhard-float'
> 
> The reason is when make modules_install, 'call cc-option' doesn't work
> in $(KBUILD_CFLAGS) of 'CHECKFLAGS'. Then there is no -mno-loongson-mmi
> applied and -march=loongson3a enable MMI instructions.
> 
> To be detail, the error message comes from the CHECKFLAGS invocation of
> $(CC) but it has no impact on the final result of make modules_install,
> it is purely a cosmetic issue. The error occurs because cc-option is
> defined in scripts/Makefile.compiler, which is not included in Makefile
> when running 'make modules_install', as install targets are not supposed
> to require the compiler; see commit 805b2e1d427aab4b ("kbuild: include
> Makefile.compiler only when compiler is needed"). As a result, the call
> to check for '-mno-loongson-mmi' just never happens.
> 
> Fix this by partially reverting to the old logic, use 'call cc-option'
> to conditionally apply -march=loongson3a and -march=mips64r2.
> 
> By the way, Loongson-2E/2F is also broken in commit 13ceb48bc19c563e05f4
> ("MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls") so fix it
> together.
> 
> Fixes: 13ceb48bc19c563e05f4 ("MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls")
> Fixes: 0e96ea5c3eb5904e5dc2 ("MIPS: Loongson64: Clean up use of cc-ifversion")
> Cc: stable@vger.kernel.org
> Cc: Feiyang Chen <chenfeiyang@loongson.cn>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> V2: Update commit message and fix for LOONGSON2EF together.
> 
>  arch/mips/Makefile | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> index a7a4ee66a9d3..35a1b9b34734 100644
> --- a/arch/mips/Makefile
> +++ b/arch/mips/Makefile
> @@ -181,16 +181,12 @@ endif
>  cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
>  cflags-$(CONFIG_CPU_BMIPS)	+= -march=mips32 -Wa,-mips32 -Wa,--trap
>  
> -cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap
> -cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap
> +cflags-$(CONFIG_CPU_LOONGSON2E) += $(call cc-option,-march=loongson2e) -Wa,--trap
> +cflags-$(CONFIG_CPU_LOONGSON2F) += $(call cc-option,-march=loongson2f) -Wa,--trap
> +cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-march=loongson3a,-march=mips64r2) -Wa,--trap
>  # Some -march= flags enable MMI instructions, and GCC complains about that
>  # support being enabled alongside -msoft-float. Thus explicitly disable MMI.
>  cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi)
> -ifdef CONFIG_CPU_LOONGSON64
> -cflags-$(CONFIG_CPU_LOONGSON64)	+= -Wa,--trap
> -cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a
> -cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2
> -endif
>  cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi)
>  
>  cflags-$(CONFIG_CPU_R4000_WORKAROUNDS)	+= $(call cc-option,-mfix-r4000,)
> -- 
> 2.39.3
> 

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

* Re: [PATCH V2] MIPS: Loongson: Fix build error when make modules_install
  2023-06-28 11:08 [PATCH V2] MIPS: Loongson: Fix build error when make modules_install Huacai Chen
  2023-06-28 15:22 ` Nathan Chancellor
@ 2023-07-03 14:09 ` Thomas Bogendoerfer
  2023-07-18 14:43 ` Maciej W. Rozycki
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2023-07-03 14:09 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Huacai Chen, linux-mips, Jiaxun Yang, stable, Feiyang Chen,
	Nathan Chancellor, Nick Desaulniers

On Wed, Jun 28, 2023 at 07:08:47PM +0800, Huacai Chen wrote:
> After commit 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of
> cc-ifversion") we get a build error when make modules_install:
> 
> cc1: error: '-mloongson-mmi' must be used with '-mhard-float'
> 
> The reason is when make modules_install, 'call cc-option' doesn't work
> in $(KBUILD_CFLAGS) of 'CHECKFLAGS'. Then there is no -mno-loongson-mmi
> applied and -march=loongson3a enable MMI instructions.
> 
> To be detail, the error message comes from the CHECKFLAGS invocation of
> $(CC) but it has no impact on the final result of make modules_install,
> it is purely a cosmetic issue. The error occurs because cc-option is
> defined in scripts/Makefile.compiler, which is not included in Makefile
> when running 'make modules_install', as install targets are not supposed
> to require the compiler; see commit 805b2e1d427aab4b ("kbuild: include
> Makefile.compiler only when compiler is needed"). As a result, the call
> to check for '-mno-loongson-mmi' just never happens.
> 
> Fix this by partially reverting to the old logic, use 'call cc-option'
> to conditionally apply -march=loongson3a and -march=mips64r2.
> 
> By the way, Loongson-2E/2F is also broken in commit 13ceb48bc19c563e05f4
> ("MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls") so fix it
> together.
> 
> Fixes: 13ceb48bc19c563e05f4 ("MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls")
> Fixes: 0e96ea5c3eb5904e5dc2 ("MIPS: Loongson64: Clean up use of cc-ifversion")
> Cc: stable@vger.kernel.org
> Cc: Feiyang Chen <chenfeiyang@loongson.cn>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
> V2: Update commit message and fix for LOONGSON2EF together.
> 
>  arch/mips/Makefile | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

* Re: [PATCH V2] MIPS: Loongson: Fix build error when make modules_install
  2023-06-28 11:08 [PATCH V2] MIPS: Loongson: Fix build error when make modules_install Huacai Chen
  2023-06-28 15:22 ` Nathan Chancellor
  2023-07-03 14:09 ` Thomas Bogendoerfer
@ 2023-07-18 14:43 ` Maciej W. Rozycki
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2023-07-18 14:43 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Thomas Bogendoerfer, Huacai Chen, linux-mips, Jiaxun Yang, stable,
	Feiyang Chen, Nathan Chancellor, Nick Desaulniers

On Wed, 28 Jun 2023, Huacai Chen wrote:

> After commit 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of
> cc-ifversion") we get a build error when make modules_install:
> 
> cc1: error: '-mloongson-mmi' must be used with '-mhard-float'
> 
> The reason is when make modules_install, 'call cc-option' doesn't work
> in $(KBUILD_CFLAGS) of 'CHECKFLAGS'. Then there is no -mno-loongson-mmi
> applied and -march=loongson3a enable MMI instructions.

 That's the wrong fix, you've just papered over the actual problem in a 
needlessly complex way.

 The right fix is not to define CHECKFLAGS unless `need-compiler' -- we 
don't need CHECKFLAGS when we aren't going to use the compiler, in which 
case Makefile.compiler is not sourced, as discussed here: 
<https://lore.kernel.org/r/20230204145641.66417-1-alobakin@mailbox.org/> 
and here: 
<https://lore.kernel.org/r/alpine.DEB.2.21.2302071942200.11790@angie.orcam.me.uk/>.  
I guess nobody bothers reading such discussions though, hence the most 
obvious fixes are ignored.

 I've posted proper fixes now: 
<https://lore.kernel.org/r/alpine.DEB.2.21.2307180025120.62448@angie.orcam.me.uk/>.

  Maciej

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

end of thread, other threads:[~2023-07-18 14:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28 11:08 [PATCH V2] MIPS: Loongson: Fix build error when make modules_install Huacai Chen
2023-06-28 15:22 ` Nathan Chancellor
2023-07-03 14:09 ` Thomas Bogendoerfer
2023-07-18 14:43 ` Maciej W. Rozycki

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 NNTP newsgroup(s).