* Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
@ 2024-12-29 12:48 Thomas Petazzoni
2024-12-29 14:23 ` Geert Uytterhoeven
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2024-12-29 12:48 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-m68k
Hello,
While trying to build the multi_defconfig, from Linux 6.12.5, for a
68040 system, the build fails with:
{standard input}: Assembler messages:
{standard input}:104: Error: operands mismatch -- statement `movec %d2,%caar' ignored
make[5]: *** [scripts/Makefile.build:229: arch/m68k/kernel/sys_m68k.o] Error 1
It seems like the 68020/68030 code:
if (CPU_IS_020_OR_030) {
if (scope == FLUSH_SCOPE_LINE && len < 256) {
unsigned long cacr;
__asm__ ("movec %%cacr, %0" : "=r" (cacr));
if (cache & FLUSH_CACHE_INSN)
cacr |= 4;
if (cache & FLUSH_CACHE_DATA)
cacr |= 0x400;
len >>= 2;
while (len--) {
__asm__ __volatile__ ("movec %1, %%caar\n\t"
"movec %0, %%cacr"
: /* no outputs */
: "r" (cacr), "r" (addr));
addr += 4;
}
} else {
/* Flush the whole cache, even if page granularity requested. */
unsigned long cacr;
__asm__ ("movec %%cacr, %0" : "=r" (cacr));
if (cache & FLUSH_CACHE_INSN)
cacr |= 8;
if (cache & FLUSH_CACHE_DATA)
cacr |= 0x800;
__asm__ __volatile__ ("movec %0, %%cacr" : : "r" (cacr));
}
ret = 0;
goto out_unlock;
gets compiled in, and binutils isn't happy about it.
The issue can trivially be reproduced by building the following
Buildroot configuration:
BR2_m68k=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
Quick recipe:
$ git clone https://gitlab.com/buildroot.org/buildroot.git
$ cd buildroot/
$ cat >.config <<EOF
BR2_m68k=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
EOF
$ make olddefconfig
$ make
Is this expected?
Best regards,
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
2024-12-29 12:48 Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k Thomas Petazzoni
@ 2024-12-29 14:23 ` Geert Uytterhoeven
2024-12-30 8:30 ` Finn Thain
0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2024-12-29 14:23 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: linux-m68k
Hi Thomas,
On Sun, Dec 29, 2024 at 1:48 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
> While trying to build the multi_defconfig, from Linux 6.12.5, for a
> 68040 system, the build fails with:
>
> {standard input}: Assembler messages:
> {standard input}:104: Error: operands mismatch -- statement `movec %d2,%caar' ignored
> make[5]: *** [scripts/Makefile.build:229: arch/m68k/kernel/sys_m68k.o] Error 1
That's not the only error:
{standard input}: Assembler messages:
{standard input}:17: Error: invalid instruction for this architecture;
needs M68K mmu (68020 [68k, 68ec020], 68030 [68ec030], 68040
[68ec040], 68060 [68ec060]) -- statement `pflusha' ignored
make[5]: *** [scripts/Makefile.build:229: arch/m68k/mm/kmap.o] Error 1
There are more like the above, but at least these tell you what's the
underlying problem: the cross-compiler does not seem to support real
m68k CPUs. Interestingly, it was built with --with-cpu=68040...
Also:
cat > /tmp/a.s <<EOF
movec %d2,%caar
EOF
output/host/bin/m68k-buildroot-linux-gnu-as /tmp/a.s
does build.
output/host/bin/m68k-buildroot-linux-gnu-gcc -c /tmp/a.s
does not.
With plain m68k-linux-gnu-{as,gcc} (Ubuntu 13.3.0-6ubuntu2~24.04,
which is also 13.3.0, just like the buildroot toolchain), both work.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
2024-12-29 14:23 ` Geert Uytterhoeven
@ 2024-12-30 8:30 ` Finn Thain
2024-12-30 8:53 ` Geert Uytterhoeven
0 siblings, 1 reply; 7+ messages in thread
From: Finn Thain @ 2024-12-30 8:30 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: Geert Uytterhoeven, linux-m68k
On Sun, 29 Dec 2024, Geert Uytterhoeven wrote:
> output/host/bin/m68k-buildroot-linux-gnu-as /tmp/a.s
>
> does build.
>
> output/host/bin/m68k-buildroot-linux-gnu-gcc -c /tmp/a.s
>
> does not.
>
You may want to try,
$ output/host/bin/m68k-buildroot-linux-gnu-gcc -v -c /tmp/a.s
As that will print the full assembler command line, among other things.
E.g.
...
/usr/libexec/gcc/m68k-unknown-linux-musl/as -v -mcpu=68020 --pcrel -o a.o a.s
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
2024-12-30 8:30 ` Finn Thain
@ 2024-12-30 8:53 ` Geert Uytterhoeven
2024-12-30 9:35 ` Thomas Petazzoni
2024-12-30 11:22 ` Andreas Schwab
0 siblings, 2 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2024-12-30 8:53 UTC (permalink / raw)
To: Finn Thain; +Cc: Thomas Petazzoni, linux-m68k
Hi Finn,
On Mon, Dec 30, 2024 at 9:30 AM Finn Thain <fthain@linux-m68k.org> wrote:
> You may want to try,
>
> $ output/host/bin/m68k-buildroot-linux-gnu-gcc -v -c /tmp/a.s
>
> As that will print the full assembler command line, among other things.
> E.g.
>
> ...
> /usr/libexec/gcc/m68k-unknown-linux-musl/as -v -mcpu=68020 --pcrel -o a.o a.s
Thanks, so it fails when -mcpu=68040 is passed to the assembler.
Oh, I misread "caar" as "cacr". The latter exists on MC68040, the
former does not. However, that doesn't explain the failures for pflusha,
which is supported on 68040.
After disabling CONFIG_680[236]0 in the kernel config, I can build
it fine using the buildroot toolchain.
Conclusion: make sure your toolchain supports (a superset of) the
CPUs supported by your kernel config.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
2024-12-30 8:53 ` Geert Uytterhoeven
@ 2024-12-30 9:35 ` Thomas Petazzoni
2024-12-30 9:57 ` Geert Uytterhoeven
2024-12-30 11:22 ` Andreas Schwab
1 sibling, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2024-12-30 9:35 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Finn Thain, linux-m68k
Hello Geert,
On Mon, 30 Dec 2024 09:53:29 +0100
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > /usr/libexec/gcc/m68k-unknown-linux-musl/as -v -mcpu=68020 --pcrel -o a.o a.s
>
> Thanks, so it fails when -mcpu=68040 is passed to the assembler.
>
> Oh, I misread "caar" as "cacr". The latter exists on MC68040, the
> former does not. However, that doesn't explain the failures for pflusha,
> which is supported on 68040.
>
> After disabling CONFIG_680[236]0 in the kernel config, I can build
> it fine using the buildroot toolchain.
>
> Conclusion: make sure your toolchain supports (a superset of) the
> CPUs supported by your kernel config.
Thanks for the investigation. How should the toolchain be configured to
s upport multiple m68k CPUs? My understanding was that when you
configure gcc with --with-cpu=<something>, it means gcc will by default
emit code for <something>, but it can always be overridden when running
gcc using -mcpu=<somethingelse>.
How can one build this kernel/sys_m68k.c file if it uses instructions
that are mutually incompatible on different m68k cores?
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
2024-12-30 9:35 ` Thomas Petazzoni
@ 2024-12-30 9:57 ` Geert Uytterhoeven
0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2024-12-30 9:57 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: Finn Thain, linux-m68k
Hi Thomas,
On Mon, Dec 30, 2024 at 10:35 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
> On Mon, 30 Dec 2024 09:53:29 +0100
> Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> > > /usr/libexec/gcc/m68k-unknown-linux-musl/as -v -mcpu=68020 --pcrel -o a.o a.s
> >
> > Thanks, so it fails when -mcpu=68040 is passed to the assembler.
> >
> > Oh, I misread "caar" as "cacr". The latter exists on MC68040, the
> > former does not. However, that doesn't explain the failures for pflusha,
> > which is supported on 68040.
> >
> > After disabling CONFIG_680[236]0 in the kernel config, I can build
> > it fine using the buildroot toolchain.
> >
> > Conclusion: make sure your toolchain supports (a superset of) the
> > CPUs supported by your kernel config.
>
> Thanks for the investigation. How should the toolchain be configured to
> s upport multiple m68k CPUs? My understanding was that when you
> configure gcc with --with-cpu=<something>, it means gcc will by default
> emit code for <something>, but it can always be overridden when running
> gcc using -mcpu=<somethingelse>.
Sorry, it's been ages since I built my own cross-compiler.
IIRC, I always used the default, which gives a compiler targeting all
(non-Coldfire) variants.
The GCC documentation seems to be ambiguous
(https://gcc.gnu.org/install/configure.html):
Example 1: to configure a compiler for SH4A only, but supporting
both endians, with little endian being the default:
--with-cpu=sh4a --with-endian=little,big --with-multilib-list=
vs.
--with-cpu=cpu
--with-cpu-32=cpu
--with-cpu-64=cpu
Specify which cpu variant the compiler should generate code
for by default
> How can one build this kernel/sys_m68k.c file if it uses instructions
> that are mutually incompatible on different m68k cores?
Each of the CPU-specific sections depends on CPU_IS_*(), which
expand to compile-time and/or run-time checks for the CPU type,
depending on which CONFIG_680*0 kernel config options are set.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k
2024-12-30 8:53 ` Geert Uytterhoeven
2024-12-30 9:35 ` Thomas Petazzoni
@ 2024-12-30 11:22 ` Andreas Schwab
1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2024-12-30 11:22 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Finn Thain, Thomas Petazzoni, linux-m68k
On Dez 30 2024, Geert Uytterhoeven wrote:
> Conclusion: make sure your toolchain supports (a superset of) the
> CPUs supported by your kernel config.
Conclusion: always use .chip directives.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-12-30 11:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-29 12:48 Build issue "Error: operands mismatch -- statement `movec %d2,%caar' ignored" on m68k Thomas Petazzoni
2024-12-29 14:23 ` Geert Uytterhoeven
2024-12-30 8:30 ` Finn Thain
2024-12-30 8:53 ` Geert Uytterhoeven
2024-12-30 9:35 ` Thomas Petazzoni
2024-12-30 9:57 ` Geert Uytterhoeven
2024-12-30 11:22 ` Andreas Schwab
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).