public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Compilation for mips-mti-elf fails
@ 2021-11-25 21:04 Marian Buschsieweke
  2021-11-29 23:27 ` Jeff Johnston
  0 siblings, 1 reply; 3+ messages in thread
From: Marian Buschsieweke @ 2021-11-25 21:04 UTC (permalink / raw)
  To: newlib


[-- Attachment #1.1: Type: text/plain, Size: 716 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: fix-mips-mti-elf.patch --]
[-- Type: text/x-patch, Size: 1439 bytes --]

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`

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-07  6:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 21:04 Compilation for mips-mti-elf fails Marian Buschsieweke
2021-11-29 23:27 ` Jeff Johnston
2022-02-07  6:42   ` Mike Frysinger

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 read-only IMAP folder(s) and NNTP newsgroup(s).