Re: Compilation for mips-mti-elf fails

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <YgC/R7lQphpu5fMb@vapier>
On 29 Nov 2021 18:27, Jeff Johnston wrote:
> 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.

this change doesn't make sense to me.  it moves fenv.o out of lib_a_OBJECTS
(which is used to create lib.a in this subdir) and into a new LIBADD_OBJS.
but LIBADD_OBJS isn't used anywhere that i can see.  did you mean to write
lib_a_LIBADD instead ?

Joel is reporting problems w/RTEMS due to this change.

--- a/newlib/libm/machine/mips/Makefile.am
+++ b/newlib/libm/machine/mips/Makefile.am
@@ -15,7 +15,7 @@ noinst_DATA =
 
 include $(srcdir)/../../../Makefile.shared
 
-LIBADD_OBJS = \
+lib_a_LIBADD = \
 	lib_a-fenv.$(OBJEXT)
 
 # fenv.c cannot be compiled as mips16 since it uses the cfc1 instruction
--- a/newlib/libm/machine/mips/Makefile.in
+++ b/newlib/libm/machine/mips/Makefile.in
@@ -115,7 +115,7 @@ am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
 am__v_AR_0 = @echo "  AR      " $@;
 am__v_AR_1 = 
 lib_a_AR = $(AR) $(ARFLAGS)
-lib_a_LIBADD =
+lib_a_DEPENDENCIES = lib_a-fenv.$(OBJEXT)
 am__objects_1 = lib_a-feclearexcept.$(OBJEXT) lib_a-fegetenv.$(OBJEXT) \
 	lib_a-fegetexceptflag.$(OBJEXT) lib_a-fegetround.$(OBJEXT) \
 	lib_a-feholdexcept.$(OBJEXT) lib_a-feraiseexcept.$(OBJEXT) \
@@ -329,7 +329,7 @@ noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
 lib_a_CFLAGS = $(AM_CFLAGS)
 noinst_DATA = 
-LIBADD_OBJS = \
+lib_a_LIBADD = \
 	lib_a-fenv.$(OBJEXT)
 
 all: all-am
-mike

> On Thu, Nov 25, 2021 at 4:04 PM Marian Buschsieweke <
> [email protected]> 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
> >

> From f3df3e145d1b2a54a248db3a2a68271664dde86c Mon Sep 17 00:00:00 2001
> From: Jeff Johnston <[email protected]>
> Date: Mon, 29 Nov 2021 17:33:52 -0500
> Subject: [PATCH] Modifying patch from: [email protected]
> 
> 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
>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmIAv0cACgkQQWM7n+g3
9YHJAw/7BWxBE2ajyW5VlbIZLQMJEJg6O3loGuIBYJx4doxP2EvSRBjTazky59KS
Yx0FzV1mVfHvUvC2NGdgfWd45YLxkzCgdE4Aq5TOIOb0avtkGENqcmifpqFaezGW
q7iW9/s1CcRBiewRNn4A7zYkXA9rfd7UxTNJpg2GAwZTgwygf+V2bzisGeKy+C4Q
zs2sj8k3xoJKLvMDO30YCN3IVlrh7XqcRLzgX4lTvvWbaqqYSQ6papA63yd7FMj9
zRsA/rzY1k8uIMu0KdcAMesLp7LSl7vSjNJmMotBV+vcugyWlZKorNbIX8Wc/3ww
LDsyGc/4jRWfclanEkhrwGnFyPrnOnD55vFd3r24Mbi2PK7OOug650GbRLi+mfg/
ESujEHB37+yc6DXEOPtIiWIL+073SuMUJ2DgZMJgafkQd8sXJkPnsxHnoa3LKk7N
xgiDVlR4nRlRTpnGjKAvq/c6XyVMyr+/twXbZNR/1KQZZjIxMTsjtPX9mRL/ORk6
24UL051Vn5BCl00yrhUlfj+Xm6HyhsvvHVXoqXgBZSFGX090x1CgrEUQtzUW+gQK
vWcfZMABfSC8SHhJ41bgWp2hmDhEjnYcceTknCdv8LzV9rn4VIWoIqW6sgalEXM8
99f133HQyQBVm51f13RzA3stNIJbEhJEMgxKMNxxbddXcPB0WBk=
=4roa
-----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.