Follow @Openwall on Twitter for new release announcements and other news
[<prev] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20261113184046.GP5716@brightrain.aerifal.cx>
Date: Fri, 13 Nov 2026 13:40:47 -0500
From: Rich Felker <dalias@...c.org>
To: Graeme Harker <graeme.harker@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] m68k: fix soft-float build of setjmp and longjmp

On Fri, Nov 13, 2026 at 02:13:19PM +0000, Graeme Harker wrote:
> configure selects the m68k-sf subarch when the compiler does not
> define __HAVE_68881__, but setjmp and longjmp save and restore fp2-fp7
> with fmovem.x unconditionally. gas rejects the instruction for a
> target with no fpu (for example -m68030 -msoft-float), so the subarch
> could not be built, and with an assembler that did accept it the
> functions would trap on a cpu that has no fpu.

This seems like it probably should be fixed, especially since we
nominally support the -sf subarch.

> preprocess the two files and keep the fpu instructions only when
> __HAVE_68881__ is defined, the condition the m68k fenv and sqrtl code
> already use. the jmp_buf layout is not changed, and the code
> assembled for hard-float targets is the same as before.
> ---
> Tested with gcc 15.2.0 and binutils from Ubuntu's m68k-linux-gnu
> cross toolchain:
> 
> - CC="m68k-linux-gnu-gcc -m68030 -msoft-float" ./configure
>   --target=m68k-linux-gnu --disable-shared: master stops at these two
>   files; with the patch it builds, and libc.a has no fpu instruction.
> - Default (68020 with 68881) build: setjmp.o and longjmp.o disassemble
>   identically before and after.
> - Run time: 1.2.6 with this change (the two files are the same in
>   1.2.6 and master) has been in use on a 68030 board with no fpu,
>   under Linux 7.3-rc1, with a static busybox whose ash uses
>   setjmp/longjmp.

Is there an ABI document that covers the softfloat ABI? In particular,
when archs have softfloat ABIs it's important to check whether, when
running them on a cpu that does have hard float, the floating point
registers are all call-clobbered, or whether some are "call-saved if
present" like on arm. In the latter case, setjmp/longjmp need to check
hwcaps rather than just using compile-time checks, and this requires
workarounds for encoding unsupported insns.

Hopefully it's the former.

> The __mcffpu__ case is left alone: it would need fmovem.d, and a
> -mcpu=5475 build of master fails in many other files anyway.

Hm, I don't recall being aware of that, but it seems plausible. I
can't find any past discussions about making it work.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.