linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: Loongson: Fix build error when make modules_install
@ 2023-06-26  7:50 Huacai Chen
  2023-06-26 16:07 ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2023-06-26  7:50 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Huacai Chen
  Cc: linux-mips, Jiaxun Yang, Huacai Chen, stable, 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.

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

Fixes: 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of cc-ifversion")
Cc: stable@vger.kernel.org
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 arch/mips/Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index a7a4ee66a9d3..7fb76d12829e 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -186,11 +186,8 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -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,-march=loongson3a,-march=mips64r2)
 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] 5+ messages in thread

* Re: [PATCH] MIPS: Loongson: Fix build error when make modules_install
  2023-06-26  7:50 [PATCH] MIPS: Loongson: Fix build error when make modules_install Huacai Chen
@ 2023-06-26 16:07 ` Nathan Chancellor
  2023-06-27  3:11   ` Huacai Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2023-06-26 16:07 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Thomas Bogendoerfer, Huacai Chen, linux-mips, Jiaxun Yang,
	stable, Nick Desaulniers

On Mon, Jun 26, 2023 at 03:50: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.

The first sentence does not make much sense to me, specifically "in
$(KBUILD_CFLAGS) of 'CHECKFLAGS'". What configuration and build command
reproduces this? I do not see how '-mno-loongson-mmi' would fail to get
added to cflags-y after 0e96ea5c3eb5, which should have had no
functional change... I don't want to hang this change up since there is
real breakage but I want to make sure we fully understand why
0e96ea5c3eb5 broke things and why this patch resolves it.

> Fix this by partially reverting to the old logic, use 'call cc-option'
> to conditionally apply -march=loongson3a and -march=mips64r2.
> 
> Fixes: 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of cc-ifversion")
> Cc: stable@vger.kernel.org
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  arch/mips/Makefile | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> index a7a4ee66a9d3..7fb76d12829e 100644
> --- a/arch/mips/Makefile
> +++ b/arch/mips/Makefile
> @@ -186,11 +186,8 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -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,-march=loongson3a,-march=mips64r2)
>  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] 5+ messages in thread

* Re: [PATCH] MIPS: Loongson: Fix build error when make modules_install
  2023-06-26 16:07 ` Nathan Chancellor
@ 2023-06-27  3:11   ` Huacai Chen
  2023-06-27 21:28     ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2023-06-27  3:11 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Huacai Chen, Thomas Bogendoerfer, linux-mips, Jiaxun Yang,
	stable, Nick Desaulniers

Hi, Nathan,

On Tue, Jun 27, 2023 at 12:07 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Mon, Jun 26, 2023 at 03:50: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.
>
> The first sentence does not make much sense to me, specifically "in
> $(KBUILD_CFLAGS) of 'CHECKFLAGS'". What configuration and build command
> reproduces this? I do not see how '-mno-loongson-mmi' would fail to get
> added to cflags-y after 0e96ea5c3eb5, which should have had no
> functional change... I don't want to hang this change up since there is
> real breakage but I want to make sure we fully understand why
> 0e96ea5c3eb5 broke things and why this patch resolves it.
Please use loongson3_defconfig to build a loongson kernel with
toolchains from here [1]:
'make' will succeed, but there is a build error when 'make
modules_install'. And you should be careful because 'make
modules_install' doesn't stop when the error occurs.

[1] https://mirrors.edge.kernel.org/pub/tools/crosstool/

Huacai
>
> > Fix this by partially reverting to the old logic, use 'call cc-option'
> > to conditionally apply -march=loongson3a and -march=mips64r2.
> >
> > Fixes: 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of cc-ifversion")
> > Cc: stable@vger.kernel.org
> > Cc: Nathan Chancellor <nathan@kernel.org>
> > Cc: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >  arch/mips/Makefile | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> > index a7a4ee66a9d3..7fb76d12829e 100644
> > --- a/arch/mips/Makefile
> > +++ b/arch/mips/Makefile
> > @@ -186,11 +186,8 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -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,-march=loongson3a,-march=mips64r2)
> >  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] 5+ messages in thread

* Re: [PATCH] MIPS: Loongson: Fix build error when make modules_install
  2023-06-27  3:11   ` Huacai Chen
@ 2023-06-27 21:28     ` Nathan Chancellor
  2023-06-28  7:36       ` Huacai Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2023-06-27 21:28 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Huacai Chen, Thomas Bogendoerfer, linux-mips, Jiaxun Yang,
	stable, Nick Desaulniers

Hi Huacai,

+ Masahiro

On Tue, Jun 27, 2023 at 11:11:27AM +0800, Huacai Chen wrote:
> Hi, Nathan,
> 
> On Tue, Jun 27, 2023 at 12:07 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > On Mon, Jun 26, 2023 at 03:50: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.
> >
> > The first sentence does not make much sense to me, specifically "in
> > $(KBUILD_CFLAGS) of 'CHECKFLAGS'". What configuration and build command
> > reproduces this? I do not see how '-mno-loongson-mmi' would fail to get
> > added to cflags-y after 0e96ea5c3eb5, which should have had no
> > functional change... I don't want to hang this change up since there is
> > real breakage but I want to make sure we fully understand why
> > 0e96ea5c3eb5 broke things and why this patch resolves it.
> Please use loongson3_defconfig to build a loongson kernel with
> toolchains from here [1]:
> 'make' will succeed, but there is a build error when 'make
> modules_install'. And you should be careful because 'make
> modules_install' doesn't stop when the error occurs.

Excellent, thank you! I understand what is going on here and your patch
should work to resolve it (although I think the commit message should be
flushed out a little more with the following details) but I am curious
if Masahiro has any thoughts around this.

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

It would nice if '-mno-loongson-mmi' could be added unconditionally when
using GCC but I can see that the flag has only existed since 9.x, so we
do need to keep the cc-option call.

I am fine with your change as long as it includes some of the above
information (basically noting that while the original change should have
been equivalent, the requirement of '-mno-loongson-mmi' when using
certain Loongson '-march=' values with '-msoft-float' means that those
Loongson '-march=' values need to be called with cc-option as well),
even if clang will incur two more cc-option calls as a result (not the
end of the world).

Additionally, it seems like the same issue will occur when running
modules_install when CONFIG_CPU_LOONGSON2E or CONFIG_CPU_LOONGSON2F are
enabled, which I guess I also broke in commit 13ceb48bc19c ("MIPS:
Loongson2ef: Remove unnecessary {as,cc}-option calls") :/

Sorry again for the breakage and thanks for the fix!

Cheers,
Nathan

> > > Fix this by partially reverting to the old logic, use 'call cc-option'
> > > to conditionally apply -march=loongson3a and -march=mips64r2.
> > >
> > > Fixes: 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of cc-ifversion")
> > > Cc: stable@vger.kernel.org
> > > Cc: Nathan Chancellor <nathan@kernel.org>
> > > Cc: Nick Desaulniers <ndesaulniers@google.com>
> > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > > ---
> > >  arch/mips/Makefile | 5 +----
> > >  1 file changed, 1 insertion(+), 4 deletions(-)
> > >
> > > diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> > > index a7a4ee66a9d3..7fb76d12829e 100644
> > > --- a/arch/mips/Makefile
> > > +++ b/arch/mips/Makefile
> > > @@ -186,11 +186,8 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -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,-march=loongson3a,-march=mips64r2)
> > >  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] 5+ messages in thread

* Re: [PATCH] MIPS: Loongson: Fix build error when make modules_install
  2023-06-27 21:28     ` Nathan Chancellor
@ 2023-06-28  7:36       ` Huacai Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2023-06-28  7:36 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Huacai Chen, Thomas Bogendoerfer, linux-mips, Jiaxun Yang,
	stable, Nick Desaulniers

Hi, Nathan,

On Wed, Jun 28, 2023 at 5:28 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi Huacai,
>
> + Masahiro
>
> On Tue, Jun 27, 2023 at 11:11:27AM +0800, Huacai Chen wrote:
> > Hi, Nathan,
> >
> > On Tue, Jun 27, 2023 at 12:07 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > On Mon, Jun 26, 2023 at 03:50: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.
> > >
> > > The first sentence does not make much sense to me, specifically "in
> > > $(KBUILD_CFLAGS) of 'CHECKFLAGS'". What configuration and build command
> > > reproduces this? I do not see how '-mno-loongson-mmi' would fail to get
> > > added to cflags-y after 0e96ea5c3eb5, which should have had no
> > > functional change... I don't want to hang this change up since there is
> > > real breakage but I want to make sure we fully understand why
> > > 0e96ea5c3eb5 broke things and why this patch resolves it.
> > Please use loongson3_defconfig to build a loongson kernel with
> > toolchains from here [1]:
> > 'make' will succeed, but there is a build error when 'make
> > modules_install'. And you should be careful because 'make
> > modules_install' doesn't stop when the error occurs.
>
> Excellent, thank you! I understand what is going on here and your patch
> should work to resolve it (although I think the commit message should be
> flushed out a little more with the following details) but I am curious
> if Masahiro has any thoughts around this.
>
> As you note, the error message comes from the CHECKFLAGS invocation of
> $(CC) but it has no impact on the final result of modules_install, it is
> purely a cosmetic issue from what I can tell. The error occurs because
> cc-option is defined in scripts/Makefile.compiler, which is not included
> in Makefile when running modules_install, as install targets are not
> supposed to require the compiler; see commit 805b2e1d427a ("kbuild:
> include Makefile.compiler only when compiler is needed"). As a result,
> the call to check for '-mno-loongson-mmi' just never happens.
>
> It would nice if '-mno-loongson-mmi' could be added unconditionally when
> using GCC but I can see that the flag has only existed since 9.x, so we
> do need to keep the cc-option call.
>
> I am fine with your change as long as it includes some of the above
> information (basically noting that while the original change should have
> been equivalent, the requirement of '-mno-loongson-mmi' when using
> certain Loongson '-march=' values with '-msoft-float' means that those
> Loongson '-march=' values need to be called with cc-option as well),
> even if clang will incur two more cc-option calls as a result (not the
> end of the world).
>
> Additionally, it seems like the same issue will occur when running
> modules_install when CONFIG_CPU_LOONGSON2E or CONFIG_CPU_LOONGSON2F are
> enabled, which I guess I also broke in commit 13ceb48bc19c ("MIPS:
> Loongson2ef: Remove unnecessary {as,cc}-option calls") :/
>
> Sorry again for the breakage and thanks for the fix!
OK, I will update the commit message and fix for LOONGSON2EF together.

Huacai
>
> Cheers,
> Nathan
>
> > > > Fix this by partially reverting to the old logic, use 'call cc-option'
> > > > to conditionally apply -march=loongson3a and -march=mips64r2.
> > > >
> > > > Fixes: 0e96ea5c3eb5904e5dc2f ("MIPS: Loongson64: Clean up use of cc-ifversion")
> > > > Cc: stable@vger.kernel.org
> > > > Cc: Nathan Chancellor <nathan@kernel.org>
> > > > Cc: Nick Desaulniers <ndesaulniers@google.com>
> > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > > > ---
> > > >  arch/mips/Makefile | 5 +----
> > > >  1 file changed, 1 insertion(+), 4 deletions(-)
> > > >
> > > > diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> > > > index a7a4ee66a9d3..7fb76d12829e 100644
> > > > --- a/arch/mips/Makefile
> > > > +++ b/arch/mips/Makefile
> > > > @@ -186,11 +186,8 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -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,-march=loongson3a,-march=mips64r2)
> > > >  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] 5+ messages in thread

end of thread, other threads:[~2023-06-28  8:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26  7:50 [PATCH] MIPS: Loongson: Fix build error when make modules_install Huacai Chen
2023-06-26 16:07 ` Nathan Chancellor
2023-06-27  3:11   ` Huacai Chen
2023-06-27 21:28     ` Nathan Chancellor
2023-06-28  7:36       ` Huacai Chen

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).