public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@redhat.com>
To: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Cc: Newlib <newlib@sourceware.org>
Subject: Re: Compilation for mips-mti-elf fails
Date: Mon, 29 Nov 2021 18:27:00 -0500	[thread overview]
Message-ID: <CAOox84ttb5szmu+J+zOySvXJwmkkq0=-DarD+qve2FGUaBCzjw@mail.gmail.com> (raw)
In-Reply-To: <20211125220413.35e7869f@faultier2go.lan>

[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]

Hi Marian,

Thanks for the patch.  That directory has a Makefile.am file so it must be
modified and the Makefile.in generated.
I have included a modified version of your patch.  If you have no
objections, I'll check it in.

Regards,

-- Jeff J.


On Thu, Nov 25, 2021 at 4:04 PM Marian Buschsieweke <
marian.buschsieweke@ovgu.de> wrote:

> 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
>

[-- Attachment #2: 0001-Modifying-patch-from-marian.buschsieweke-ovgu.de.patch --]
[-- Type: text/x-patch, Size: 5011 bytes --]

From f3df3e145d1b2a54a248db3a2a68271664dde86c Mon Sep 17 00:00:00 2001
From: Jeff Johnston <jjohnstn@redhat.com>
Date: Mon, 29 Nov 2021 17:33:52 -0500
Subject: [PATCH] Modifying patch from: marian.buschsieweke@ovgu.de

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/libm/machine/mips/Makefile.am | 12 ++++++++++--
 newlib/libm/machine/mips/Makefile.in | 21 ++++++++++++---------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/newlib/libm/machine/mips/Makefile.am b/newlib/libm/machine/mips/Makefile.am
index bb142a6..cef4957 100644
--- a/newlib/libm/machine/mips/Makefile.am
+++ b/newlib/libm/machine/mips/Makefile.am
@@ -6,8 +6,7 @@ INCLUDES = -I $(newlib_basedir)/../newlib/libm/common $(NEWLIB_CFLAGS) \
 LIB_SOURCES = \
 	feclearexcept.c fegetenv.c fegetexceptflag.c \
 	fegetround.c feholdexcept.c feraiseexcept.c fesetenv.c \
-	fesetexceptflag.c fesetround.c fetestexcept.c feupdateenv.c \
-	fenv.c
+	fesetexceptflag.c fesetround.c fetestexcept.c feupdateenv.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
@@ -17,5 +16,14 @@ noinst_DATA =
 
 include $(srcdir)/../../../Makefile.shared
 
+LIBADD_OBJS = \
+	lib_a-fenv.$(OBJEXT)
+
+lib_a-fenv.o: fenv.c
+	$(COMPILE) -mno-mips16 -c -o $@ `test -f 'fenv.c' || echo '$(srcdir)/'`fenv.c
+
+lib_a-fenv.obj: fenv.c
+	$(COMPILE) -mno-mips16 -c -o $@ `if test -f 'fenv.c'; then $(CYGPATH_W) 'fenv.c'; else $(CYGPATH_W) '$(srcdir)/fenv.c'; fi`
+
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff --git a/newlib/libm/machine/mips/Makefile.in b/newlib/libm/machine/mips/Makefile.in
index 2a42145..cfab717 100644
--- a/newlib/libm/machine/mips/Makefile.in
+++ b/newlib/libm/machine/mips/Makefile.in
@@ -75,7 +75,7 @@ am__objects_1 = lib_a-feclearexcept.$(OBJEXT) lib_a-fegetenv.$(OBJEXT) \
 	lib_a-feholdexcept.$(OBJEXT) lib_a-feraiseexcept.$(OBJEXT) \
 	lib_a-fesetenv.$(OBJEXT) lib_a-fesetexceptflag.$(OBJEXT) \
 	lib_a-fesetround.$(OBJEXT) lib_a-fetestexcept.$(OBJEXT) \
-	lib_a-feupdateenv.$(OBJEXT) lib_a-fenv.$(OBJEXT)
+	lib_a-feupdateenv.$(OBJEXT)
 am_lib_a_OBJECTS = $(am__objects_1)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -189,6 +189,7 @@ prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
+shared_machine_dir = @shared_machine_dir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sys_dir = @sys_dir@
@@ -203,8 +204,7 @@ INCLUDES = -I $(newlib_basedir)/../newlib/libm/common $(NEWLIB_CFLAGS) \
 LIB_SOURCES = \
 	feclearexcept.c fegetenv.c fegetexceptflag.c \
 	fegetround.c feholdexcept.c feraiseexcept.c fesetenv.c \
-	fesetexceptflag.c fesetround.c fetestexcept.c feupdateenv.c \
-	fenv.c
+	fesetexceptflag.c fesetround.c fetestexcept.c feupdateenv.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
@@ -221,6 +221,9 @@ DOCBOOK_CHEW = ${top_srcdir}/../doc/makedocbook.py
 DOCBOOK_OUT_FILES = $(CHEWOUT_FILES:.def=.xml)
 DOCBOOK_CHAPTERS = $(CHAPTERS:.tex=.xml)
 CLEANFILES = $(CHEWOUT_FILES) $(DOCBOOK_OUT_FILES)
+LIBADD_OBJS = \
+	lib_a-fenv.$(OBJEXT)
+
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 all: all-am
@@ -348,12 +351,6 @@ lib_a-feupdateenv.o: feupdateenv.c
 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
-
-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`
-
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -554,6 +551,12 @@ docbook: $(DOCBOOK_OUT_FILES)
 	  ${top_srcdir}/../doc/chapter-texi2docbook.py <$(srcdir)/$${chapter%.xml}.tex >../$$chapter ; \
 	done
 
+lib_a-fenv.o: fenv.c
+	$(COMPILE) -mno-mips16 -c -o $@ `test -f 'fenv.c' || echo '$(srcdir)/'`fenv.c
+
+lib_a-fenv.obj: fenv.c
+	$(COMPILE) -mno-mips16 -c -o $@ `if test -f 'fenv.c'; then $(CYGPATH_W) 'fenv.c'; else $(CYGPATH_W) '$(srcdir)/fenv.c'; fi`
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
-- 
1.8.3.1


  reply	other threads:[~2021-11-29 23:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 21:04 Marian Buschsieweke
2021-11-29 23:27 ` Jeff Johnston [this message]
2022-02-07  6:42   ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOox84ttb5szmu+J+zOySvXJwmkkq0=-DarD+qve2FGUaBCzjw@mail.gmail.com' \
    --to=jjohnstn@redhat.com \
    --cc=marian.buschsieweke@ovgu.de \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).