Compilation for mips-mti-elf fails

Marian Buschsieweke <[email protected]>
Newsgroups gmane.comp.lib.newlib
Organization Otto-von-Guericke-Universität Magdeburg
Message-ID <[email protected]>
Hi,

compiling for newlib with GCC 11.2.0 for mips-mti-elf with multilib
now fails with "Error: unrecognized opcode `cfc1 $3,$31'" while compiling
newlib/libm/machine/mips/fenv.c

More precisely, newlib/libc/machine/mips/machine/fenv-fp.h included by fenv.c
contains multiple calls of the function line macro __cfc1() which is defined in
newlib/libc/machine/mips/sys/fenv.h as

	#define __cfc1(__fcsr)  __asm __volatile("cfc1 %0, $31" : "=r" (__fcsr))

Apparently, this is not compatible with mips16. Adding -mno-mips16 to the
invocation of the compiler fixes the comiplation. (The same was already done for
cma101.c and cygmon.c in libgloss.)

Attached is a potential fix.

Kind regards,
Marian
fix-mips-mti-elf.patch (text/x-patch, 1.4 KB)
The code accessing the floating point control/status register, namely

	#define	__cfc1(__fcsr)	__asm __volatile("cfc1 %0, $31" : "=r" (__fcsr)

does not compile with mips16. This changed the makefile to pass -mno-mips16 to avoid the following
compiler error:

	mips-mti-elf fails with "Error: unrecognized opcode `cfc1 $3,$31'"
--- newlib-4.1.0/newlib/libm/machine/mips/Makefile.in.orig	2021-11-12 11:49:11.691337941 +0100
+++ newlib-4.1.0/newlib/libm/machine/mips/Makefile.in	2021-11-12 11:48:21.181600000 +0100
@@ -349,7 +349,7 @@ lib_a-feupdateenv.obj: feupdateenv.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feupdateenv.obj `if test -f 'feupdateenv.c'; then $(CYGPATH_W) 'feupdateenv.c'; else $(CYGPATH_W) '$(srcdir)/feupdateenv.c'; fi`
 
 lib_a-fenv.o: fenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv.o `test -f 'fenv.c' || echo '$(srcdir)/'`fenv.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -mno-mips16 -c -o lib_a-fenv.o `test -f 'fenv.c' || echo '$(srcdir)/'`fenv.c
 
 lib_a-fenv.obj: fenv.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv.obj `if test -f 'fenv.c'; then $(CYGPATH_W) 'fenv.c'; else $(CYGPATH_W) '$(srcdir)/fenv.c'; fi`
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEARYIAB0WIQRiSCnVJmOHVlHGqtbLjjI4znFalAUCYZ/6TQAKCRDLjjI4znFa
lBciAP9ykyoqBW4AXiXchc7uO15LcasVGo1vPpxYHTwhY730WAD9GA2YiNvzlUzf
KKFuMkX6PEGP6iopRFo1ZK8W3MLl/gU=
=45xS
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.