* Re: [PATCH] riscv: fix build with binutils 2.38
[not found] ` <20220331103913.2vlneq6clnheuty6@pengutronix.de>
@ 2022-03-31 10:51 ` Marc Kleine-Budde
2022-03-31 17:05 ` Aurelien Jarno
2022-03-31 18:16 ` Linus Torvalds
0 siblings, 2 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2022-03-31 10:51 UTC (permalink / raw)
To: Aurelien Jarno
Cc: linux-kernel, stable, Kito Cheng, Paul Walmsley, Palmer Dabbelt,
Albert Ou, open list:RISC-V ARCHITECTURE, linux-sparse, ukl,
Luc Van Oostenryck
[-- Attachment #1: Type: text/plain, Size: 3377 bytes --]
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)
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: fix build with binutils 2.38
2022-03-31 10:51 ` [PATCH] riscv: fix build with binutils 2.38 Marc Kleine-Budde
@ 2022-03-31 17:05 ` Aurelien Jarno
2022-03-31 18:16 ` Linus Torvalds
1 sibling, 0 replies; 7+ messages in thread
From: Aurelien Jarno @ 2022-03-31 17:05 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: linux-kernel, stable, Kito Cheng, Paul Walmsley, Palmer Dabbelt,
Albert Ou, open list:RISC-V ARCHITECTURE, linux-sparse, ukl,
Luc Van Oostenryck
[-- 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 --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: fix build with binutils 2.38
2022-03-31 10:51 ` [PATCH] riscv: fix build with binutils 2.38 Marc Kleine-Budde
2022-03-31 17:05 ` Aurelien Jarno
@ 2022-03-31 18:16 ` Linus Torvalds
2022-03-31 19:42 ` Palmer Dabbelt
2022-04-01 6:53 ` Marc Kleine-Budde
1 sibling, 2 replies; 7+ messages in thread
From: Linus Torvalds @ 2022-03-31 18:16 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Aurelien Jarno, Linux Kernel Mailing List, stable, Kito Cheng,
Paul Walmsley, Palmer Dabbelt, Albert Ou,
open list:RISC-V ARCHITECTURE, Sparse Mailing-list, ukl,
Luc Van Oostenryck
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
On Thu, Mar 31, 2022 at 3:51 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> Cc += linux-sparse, Uwe, Luc Van Oostenryck
>
> tl;dr:
>
> A recent change in the kernel regarding the riscv -march handling breaks
> current sparse.
Gaah. Normally sparse doesn't even look at the -march flag, but for
riscv it does, because it's meaningful for the predefined macros.
Maybe that 'die()' shouldn't be so fatal. And maybe add a few more
extensions (but ignore them) to the parsing.
Something ENTIRELY UNTESTED like the attached.
Linus
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 1074 bytes --]
target-riscv.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/target-riscv.c b/target-riscv.c
index 6d9113c1..201ac375 100644
--- a/target-riscv.c
+++ b/target-riscv.c
@@ -3,6 +3,7 @@
#include "target.h"
#include "machine.h"
#include <string.h>
+#include <stdio.h>
#define RISCV_32BIT (1 << 0)
#define RISCV_64BIT (1 << 1)
@@ -47,6 +48,12 @@ static void parse_march_riscv(const char *arg)
{ "n", 0 },
{ "h", 0 },
{ "s", 0 },
+ { "i", 0 },
+ { "e", 0 },
+ { "_", 0 },
+ { "Counters", 0 },
+ { "Zicsr", 0 },
+ { "Zifencei", 0 },
};
int i;
@@ -60,7 +67,10 @@ static void parse_march_riscv(const char *arg)
goto ext;
}
}
- die("invalid argument to '-march': '%s'\n", arg);
+
+unknown:
+ fprintf(stderr, "WARNING: invalid argument to '-march': '%s'\n", arg);
+ return;
ext:
for (i = 0; i < ARRAY_SIZE(extensions); i++) {
@@ -73,7 +83,7 @@ ext:
}
}
if (arg[0])
- die("invalid argument to '-march': '%s'\n", arg);
+ goto unknown;
}
static void init_riscv(const struct target *self)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: fix build with binutils 2.38
2022-03-31 18:16 ` Linus Torvalds
@ 2022-03-31 19:42 ` Palmer Dabbelt
2022-04-01 6:53 ` Marc Kleine-Budde
1 sibling, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-03-31 19:42 UTC (permalink / raw)
To: Linus Torvalds
Cc: mkl, aurelien, linux-kernel, stable, Kito Cheng, Paul Walmsley,
aou, linux-riscv, linux-sparse, ukl, luc.vanoostenryck
On Thu, 31 Mar 2022 11:16:53 PDT (-0700), Linus Torvalds wrote:
> On Thu, Mar 31, 2022 at 3:51 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>>
>> Cc += linux-sparse, Uwe, Luc Van Oostenryck
>>
>> tl;dr:
>>
>> A recent change in the kernel regarding the riscv -march handling breaks
>> current sparse.
Sorry about that, looks like I'm not running sparse as part of my
testing. I'll add it, but it might take a bit as I'm assuming there
will be a bunch of issues it points out.
> Gaah. Normally sparse doesn't even look at the -march flag, but for
> riscv it does, because it's meaningful for the predefined macros.
>
> Maybe that 'die()' shouldn't be so fatal. And maybe add a few more
> extensions (but ignore them) to the parsing.
>
> Something ENTIRELY UNTESTED like the attached.
Converting this to a warning seems reasonable to me, as then we're not
as coupled to the sparse version. The current crop of extensions don't
set anything exciting for Linux, but there are some on the horizon that
likely will -- hopefully having sparse in my test setup should be
sufficient to dig those up, though.
As far as the new extension go: "Counters" isn't an ISA extension, and
"e" defines "__riscv_32e". It'd also be slightly saner to match on
"_Zifencei", but that probably doesn't matter (GCC is sufficiently
strict here). Looks like there's also some oddities in the sparse ISA
string parsing, I'll go clean them up as I get it running locally.
We could also stop relying on the compiler's defines, which would avoid
this problem entirely, but IIRC that was discussed when decided to
modify sparse in the first place and we went this way (though I don't
remember why). That would keep everything inside the kernel.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: fix build with binutils 2.38
2022-03-31 18:16 ` Linus Torvalds
2022-03-31 19:42 ` Palmer Dabbelt
@ 2022-04-01 6:53 ` Marc Kleine-Budde
2022-04-01 17:14 ` Linus Torvalds
1 sibling, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2022-04-01 6:53 UTC (permalink / raw)
To: Linus Torvalds
Cc: Aurelien Jarno, Linux Kernel Mailing List, stable, Kito Cheng,
Paul Walmsley, Palmer Dabbelt, Albert Ou,
open list:RISC-V ARCHITECTURE, Sparse Mailing-list, ukl,
Luc Van Oostenryck
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
On 31.03.2022 11:16:53, Linus Torvalds wrote:
> On Thu, Mar 31, 2022 at 3:51 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> >
> > Cc += linux-sparse, Uwe, Luc Van Oostenryck
> >
> > tl;dr:
> >
> > A recent change in the kernel regarding the riscv -march handling breaks
> > current sparse.
>
> Gaah. Normally sparse doesn't even look at the -march flag, but for
> riscv it does, because it's meaningful for the predefined macros.
>
> Maybe that 'die()' shouldn't be so fatal. And maybe add a few more
> extensions (but ignore them) to the parsing.
>
> Something ENTIRELY UNTESTED like the attached.
Works-for-me:
| CHECK /srv/work/frogger/socketcan/linux/drivers/net/can/usb/etas_es58x/es58x_core.c
| WARNING: invalid argument to '-march': 'zicsr_zifencei'
Tested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: fix build with binutils 2.38
2022-04-01 6:53 ` Marc Kleine-Budde
@ 2022-04-01 17:14 ` Linus Torvalds
2022-04-01 17:55 ` Palmer Dabbelt
0 siblings, 1 reply; 7+ messages in thread
From: Linus Torvalds @ 2022-04-01 17:14 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Aurelien Jarno, Linux Kernel Mailing List, stable, Kito Cheng,
Paul Walmsley, Palmer Dabbelt, Albert Ou,
open list:RISC-V ARCHITECTURE, Sparse Mailing-list, ukl,
Luc Van Oostenryck
On Thu, Mar 31, 2022 at 11:53 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> | WARNING: invalid argument to '-march': 'zicsr_zifencei'
Gaah, it works but still warns because I cut-and-pasted those
zicsr/zifencei options from some random source that had them
capitalized and I didn't look closely enough at the reports.
Anyway, hopefully somebody can bother to fix up that. Possibly by
changing the strncmp to a strnicmp - but I don't know what the rules
for lower-case vs capitals are for the other options. I'm still busy
with the kernel merge window, so this gets archived on my side..
Linus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: fix build with binutils 2.38
2022-04-01 17:14 ` Linus Torvalds
@ 2022-04-01 17:55 ` Palmer Dabbelt
0 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-04-01 17:55 UTC (permalink / raw)
To: Linus Torvalds
Cc: mkl, aurelien, linux-kernel, stable, Kito Cheng, Paul Walmsley,
aou, linux-riscv, linux-sparse, ukl, luc.vanoostenryck
On Fri, 01 Apr 2022 10:14:03 PDT (-0700), Linus Torvalds wrote:
> On Thu, Mar 31, 2022 at 11:53 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>>
>> | WARNING: invalid argument to '-march': 'zicsr_zifencei'
>
> Gaah, it works but still warns because I cut-and-pasted those
> zicsr/zifencei options from some random source that had them
> capitalized and I didn't look closely enough at the reports.
>
> Anyway, hopefully somebody can bother to fix up that. Possibly by
> changing the strncmp to a strnicmp - but I don't know what the rules
> for lower-case vs capitals are for the other options. I'm still busy
> with the kernel merge window, so this gets archived on my side..
I'm gluing sparse to my build tests now, so I'll sort it out (that'll
also make sure a failure doesn't leak again). Might not be today, but
shouldn't take too long.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-01 17:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220126171442.1338740-1-aurelien@aurel32.net>
[not found] ` <20220331103247.y33wvkxk5vfbqohf@pengutronix.de>
[not found] ` <20220331103913.2vlneq6clnheuty6@pengutronix.de>
2022-03-31 10:51 ` [PATCH] riscv: fix build with binutils 2.38 Marc Kleine-Budde
2022-03-31 17:05 ` Aurelien Jarno
2022-03-31 18:16 ` Linus Torvalds
2022-03-31 19:42 ` Palmer Dabbelt
2022-04-01 6:53 ` Marc Kleine-Budde
2022-04-01 17:14 ` Linus Torvalds
2022-04-01 17:55 ` Palmer Dabbelt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox