|
|
Message-ID: <20261113141319.82021-1-graeme.harker@gmail.com>
Date: Fri, 13 Nov 2026 14:13:19 +0000
From: Graeme Harker <graeme.harker@...il.com>
To: musl@...ts.openwall.com
Cc: Graeme Harker <graeme.harker@...il.com>
Subject: [PATCH] m68k: fix soft-float build of setjmp and longjmp
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.
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.
The __mcffpu__ case is left alone: it would need fmovem.d, and a
-mcpu=5475 build of master fails in many other files anyway.
src/setjmp/m68k/{longjmp.s => longjmp.S} | 2 ++
src/setjmp/m68k/{setjmp.s => setjmp.S} | 2 ++
2 files changed, 4 insertions(+)
rename src/setjmp/m68k/{longjmp.s => longjmp.S} (90%)
rename src/setjmp/m68k/{setjmp.s => setjmp.S} (92%)
diff --git a/src/setjmp/m68k/longjmp.s b/src/setjmp/m68k/longjmp.S
similarity index 90%
rename from src/setjmp/m68k/longjmp.s
rename to src/setjmp/m68k/longjmp.S
index cdb05fb5..f26ab7ba 100644
--- a/src/setjmp/m68k/longjmp.s
+++ b/src/setjmp/m68k/longjmp.S
@@ -9,6 +9,8 @@ longjmp:
bne 1f
move.l #1,%d0
1: movem.l (%a0),%d2-%d7/%a2-%a7
+#if __HAVE_68881__
fmovem.x 52(%a0),%fp2-%fp7
+#endif
move.l 48(%a0),(%sp)
rts
diff --git a/src/setjmp/m68k/setjmp.s b/src/setjmp/m68k/setjmp.S
similarity index 92%
rename from src/setjmp/m68k/setjmp.s
rename to src/setjmp/m68k/setjmp.S
index 15e549b0..f6ec6024 100644
--- a/src/setjmp/m68k/setjmp.s
+++ b/src/setjmp/m68k/setjmp.S
@@ -13,6 +13,8 @@ setjmp:
movea.l 4(%sp),%a0
movem.l %d2-%d7/%a2-%a7,(%a0)
move.l (%sp),48(%a0)
+#if __HAVE_68881__
fmovem.x %fp2-%fp7,52(%a0)
+#endif
clr.l %d0
rts
base-commit: 7813e9119eb5fe681b6750b8a033a0490bca0941
--
2.53.0
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.