All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Kito Cheng <kito.cheng@gmail.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	"open list:RISC-V ARCHITECTURE" <linux-riscv@lists.infradead.org>,
	linux-sparse@vger.kernel.org, ukl@pengutronix.de,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: Re: [PATCH] riscv: fix build with binutils 2.38
Date: Thu, 31 Mar 2022 19:05:59 +0200	[thread overview]
Message-ID: <YkXfdyDISV6S6+kY@aurel32.net> (raw)
In-Reply-To: <20220331105112.7t3qgtilhortkiq4@pengutronix.de>


[-- Attachment #1.1: Type: text/plain, Size: 3764 bytes --]

Hi,

On 2022-03-31 12:51, Marc Kleine-Budde wrote:
> Cc += linux-sparse, Uwe, Luc Van Oostenryck
> 
> tl;dr:
> 
> A recent change in the kernel regarding the riscv -march handling breaks
> current sparse.
> 
> On 31.03.2022 12:39:14, Marc Kleine-Budde wrote:
> > On 31.03.2022 12:32:47, Marc Kleine-Budde wrote:
> > > On 26.01.2022 18:14:42, Aurelien Jarno wrote:
> > > > From version 2.38, binutils default to ISA spec version 20191213. This
> > > > means that the csr read/write (csrr*/csrw*) instructions and fence.i
> > > > instruction has separated from the `I` extension, become two standalone
> > > > extensions: Zicsr and Zifencei. As the kernel uses those instruction,
> > > > this causes the following build failure:
> > > > 
> > > >   CC      arch/riscv/kernel/vdso/vgettimeofday.o
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messages:
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > > 
> > > > The fix is to specify those extensions explicitely in -march. However as
> > > > older binutils version do not support this, we first need to detect
> > > > that.
> > > > 
> > > > Cc: stable@vger.kernel.org # 4.15+
> > > > Cc: Kito Cheng <kito.cheng@gmail.com>
> > > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> > > > ---
> > > >  arch/riscv/Makefile | 6 ++++++
> > > >  1 file changed, 6 insertions(+)
> > > > 
> > > > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > > > index 8a107ed18b0d..7d81102cffd4 100644
> > > > --- a/arch/riscv/Makefile
> > > > +++ b/arch/riscv/Makefile
> > > > @@ -50,6 +50,12 @@ riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
> > > >  riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64ima
> > > >  riscv-march-$(CONFIG_FPU)		:= $(riscv-march-y)fd
> > > >  riscv-march-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-y)c
> > > > +
> > > > +# Newer binutils versions default to ISA spec version 20191213 which moves some
> > > > +# instructions from the I extension to the Zicsr and Zifencei extensions.
> > > > +toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
> > > > +riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
> > > > +
> > > >  KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
> > > >  KBUILD_AFLAGS += -march=$(riscv-march-y)
> > > 
> > > I'm on current linus/master, this change breaks on current Debian
> > > testing with:
> > > 
> > > | make: Leaving directory 'linux'
> > > |   SYNC    include/config/auto.conf.cmd
> > > |   GEN     Makefile
> > > |   GEN     Makefile
> > > |   CC      scripts/mod/empty.o
> > > |   CHECK   linux/scripts/mod/empty.c
> >       ^^^^^
> > It's actually "sparse" that breaks
> >       
> > > | invalid argument to '-march': '_zicsr_zifencei'
> > 
> > | $ sparse --version
> > | 0.6.4 (Debian: 0.6.4-2)

I confirm the issue. To make things clear, it's not a Makefile issue,
sparse get passed the correct -march=rv64ima_zicsr_zifencei value, and
only display the part it can't parse.

On the medium/long term, sparse should get fixed to support those
extensions. On the short term, we need to find a way to get different
flags for sparse than for as/gcc.

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Aurelien Jarno <aurelien@aurel32.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Kito Cheng <kito.cheng@gmail.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	"open list:RISC-V ARCHITECTURE" <linux-riscv@lists.infradead.org>,
	linux-sparse@vger.kernel.org, ukl@pengutronix.de,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: Re: [PATCH] riscv: fix build with binutils 2.38
Date: Thu, 31 Mar 2022 19:05:59 +0200	[thread overview]
Message-ID: <YkXfdyDISV6S6+kY@aurel32.net> (raw)
In-Reply-To: <20220331105112.7t3qgtilhortkiq4@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 3764 bytes --]

Hi,

On 2022-03-31 12:51, Marc Kleine-Budde wrote:
> Cc += linux-sparse, Uwe, Luc Van Oostenryck
> 
> tl;dr:
> 
> A recent change in the kernel regarding the riscv -march handling breaks
> current sparse.
> 
> On 31.03.2022 12:39:14, Marc Kleine-Budde wrote:
> > On 31.03.2022 12:32:47, Marc Kleine-Budde wrote:
> > > On 26.01.2022 18:14:42, Aurelien Jarno wrote:
> > > > From version 2.38, binutils default to ISA spec version 20191213. This
> > > > means that the csr read/write (csrr*/csrw*) instructions and fence.i
> > > > instruction has separated from the `I` extension, become two standalone
> > > > extensions: Zicsr and Zifencei. As the kernel uses those instruction,
> > > > this causes the following build failure:
> > > > 
> > > >   CC      arch/riscv/kernel/vdso/vgettimeofday.o
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messages:
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > >   <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
> > > > 
> > > > The fix is to specify those extensions explicitely in -march. However as
> > > > older binutils version do not support this, we first need to detect
> > > > that.
> > > > 
> > > > Cc: stable@vger.kernel.org # 4.15+
> > > > Cc: Kito Cheng <kito.cheng@gmail.com>
> > > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> > > > ---
> > > >  arch/riscv/Makefile | 6 ++++++
> > > >  1 file changed, 6 insertions(+)
> > > > 
> > > > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > > > index 8a107ed18b0d..7d81102cffd4 100644
> > > > --- a/arch/riscv/Makefile
> > > > +++ b/arch/riscv/Makefile
> > > > @@ -50,6 +50,12 @@ riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
> > > >  riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64ima
> > > >  riscv-march-$(CONFIG_FPU)		:= $(riscv-march-y)fd
> > > >  riscv-march-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-y)c
> > > > +
> > > > +# Newer binutils versions default to ISA spec version 20191213 which moves some
> > > > +# instructions from the I extension to the Zicsr and Zifencei extensions.
> > > > +toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
> > > > +riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
> > > > +
> > > >  KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
> > > >  KBUILD_AFLAGS += -march=$(riscv-march-y)
> > > 
> > > I'm on current linus/master, this change breaks on current Debian
> > > testing with:
> > > 
> > > | make: Leaving directory 'linux'
> > > |   SYNC    include/config/auto.conf.cmd
> > > |   GEN     Makefile
> > > |   GEN     Makefile
> > > |   CC      scripts/mod/empty.o
> > > |   CHECK   linux/scripts/mod/empty.c
> >       ^^^^^
> > It's actually "sparse" that breaks
> >       
> > > | invalid argument to '-march': '_zicsr_zifencei'
> > 
> > | $ sparse --version
> > | 0.6.4 (Debian: 0.6.4-2)

I confirm the issue. To make things clear, it's not a Makefile issue,
sparse get passed the correct -march=rv64ima_zicsr_zifencei value, and
only display the part it can't parse.

On the medium/long term, sparse should get fixed to support those
extensions. On the short term, we need to find a way to get different
flags for sparse than for as/gcc.

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-03-31 17:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 17:14 [PATCH] riscv: fix build with binutils 2.38 Aurelien Jarno
2022-01-26 17:14 ` Aurelien Jarno
2022-01-28 10:05 ` Alexandre Ghiti
2022-01-28 10:05   ` Alexandre Ghiti
2022-02-10 17:40 ` Palmer Dabbelt
2022-02-10 17:40   ` Palmer Dabbelt
2022-02-10 17:56   ` Greg KH
2022-02-10 17:56     ` Greg KH
2022-03-31 10:32 ` Marc Kleine-Budde
2022-03-31 10:32   ` Marc Kleine-Budde
2022-03-31 10:39   ` Marc Kleine-Budde
2022-03-31 10:39     ` Marc Kleine-Budde
2022-03-31 10:51     ` Marc Kleine-Budde
2022-03-31 10:51       ` Marc Kleine-Budde
2022-03-31 17:05       ` Aurelien Jarno [this message]
2022-03-31 17:05         ` Aurelien Jarno
2022-03-31 18:16       ` Linus Torvalds
2022-03-31 18:16         ` Linus Torvalds
2022-03-31 19:42         ` Palmer Dabbelt
2022-03-31 19:42           ` Palmer Dabbelt
2022-04-01  6:53         ` Marc Kleine-Budde
2022-04-01  6:53           ` Marc Kleine-Budde
2022-04-01 17:14           ` Linus Torvalds
2022-04-01 17:14             ` Linus Torvalds
2022-04-01 17:55             ` Palmer Dabbelt
2022-04-01 17:55               ` Palmer Dabbelt
  -- strict thread matches above, loose matches on Subject: below --
2022-02-14  5:28 Khem Raj
2022-02-17  9:34 ` Leo Liang
2022-02-14  5:31 Khem Raj
2022-02-14  5:33 Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YkXfdyDISV6S6+kY@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=aou@eecs.berkeley.edu \
    --cc=kito.cheng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=mkl@pengutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=stable@vger.kernel.org \
    --cc=ukl@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.