public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* arm-elf snafu?  can't mix default-soft-float, explicit -msoft-float
@ 2003-07-22 17:11 Doug Evans
  2003-07-23 18:35 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Evans @ 2003-07-22 17:11 UTC (permalink / raw)
  To: gcc-bugs, binutils

I found this while testing gcc with arm-elf-sid.


Running /samantha/gnu-pure/gcc/gcc/testsuite/gcc.c-torture/execute/execute.exp ...
Executing on host: /samantha/gnu-pure/b-arm-gcc/gcc/xgcc -B/samantha/gnu-pure/b-arm-gcc/gcc/  -c    -msoft-float -o /samantha/gnu-pure/b-arm-gcc/gcc/testsuite/gcc-testglue.o /samantha/gnu-pure/gcc/gcc/../dejagnu/testglue.c    (timeout = 300)
Executing on host: /samantha/gnu-pure/b-arm-gcc/gcc/xgcc -B/samantha/gnu-pure/b-arm-gcc/gcc/ /samantha/gnu-pure/gcc/gcc/testsuite/gcc.c-torture/execute/20000112-1.c gcc_tg.o  -w  -O0       -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -lm   -msoft-float -o /samantha/gnu-pure/b-arm-gcc/gcc/testsuite/20000112-1.x0    (timeout = 300)
/samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/bin/ld: ERROR: /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/lib/libc.a(atexit.o) uses hardware FP, whereas /samantha/gnu-pure/b-arm-gcc/gcc/testsuite/20000112-1.x0 uses software FP
File format not recognized: failed to merge target specific data of file /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/lib/libc.a(atexit.o)
/samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/bin/ld: ERROR: /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/lib/libc.a(exit.o) uses hardware FP, whereas /samantha/gnu-pure/b-arm-gcc/gcc/testsuite/20000112-1.x0 uses software FP
File format not recognized: failed to merge target specific data of file /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/lib/libc.a(exit.o)
/samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/bin/ld: ERROR: /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/lib/libc.a(impure.o) uses hardware FP, whereas /samantha/gnu-pure/b-arm-gcc/gcc/testsuite/20000112-1.x0 uses software FP
File format not recognized: failed to merge target specific data of file /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/lib/libc.a(impure.o)
[...]


CVS source as of July 13.
target=arm-elf

NOTE: arm-elf defaults to -msoft-float.
In gcc/config/arm/elf.h:
#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME)

Simple testcase:

bash$ rm foo1.c foo2.c ; touch foo1.c foo2.c
bash$ arm-elf-gcc -c foo1.c
bash$ arm-elf-objdump -p foo1.o
foo1.o:     file format elf32-littlearm
private flags = 0: [APCS-32] [FPA float format]
bash$ arm-elf-gcc -c foo2.c -msoft-float
foo1.o:     file format elf32-littlearm
private flags = 200: [APCS-32] [FPA float format] [software FP]
bash$ arm-elf-gcc -nostdlib foo1.o foo2.o
[links successfully]
bash$ arm-elf-gcc -nostdlib foo2.o foo1.o
/samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/bin/ld: ERROR: foo1.o uses hardware FP, whereas a.out uses software FP
File format not recognized: failed to merge target specific data of file foo1.o

This line in gcc/config/arm/elf.h

#ifndef SUBTARGET_ASM_FLOAT_SPEC
#define SUBTARGET_ASM_FLOAT_SPEC "\
%{mapcs-float:-mfloat} %{msoft-float:-mfpu=softfpa}"
#endif

is causing an explicit -msoft-float to pass -mfpu=softfpa to gas which in turn
causes EF_ARM_SOFT_FLOAT to be added to the elf e_flags field.

That doesn't happen when -msoft-float is elided.
[Ergo gas and/or ld had better default to that ...
OTOH, propagating assumptions of default values throughout the tools
is a pain.  Better to restrict it to gcc.]

Specifying the order as foo1.o foo2.o works whereas foo2.o foo1.o doesn't
because in the former way there's no file after foo2.o for
elf32_arm_merge_private_bfd_data to complain about.

      if ((in_flags & EF_ARM_SOFT_FLOAT) != (out_flags & EF_ARM_SOFT_FLOAT))
	{
	  /* We can allow interworking between code that is VFP format
	     layout, and uses either soft float or integer regs for
	     passing floating point arguments and results.  We already
	     know that the APCS_FLOAT flags match; similarly for VFP
	     flags.  */
	  if ((in_flags & EF_ARM_APCS_FLOAT) != 0
	      || (in_flags & EF_ARM_VFP_FLOAT) == 0)
	    {
	      if (in_flags & EF_ARM_SOFT_FLOAT)
		_bfd_error_handler (_("\
ERROR: %s uses software FP, whereas %s uses hardware FP"),
				    bfd_archive_filename (ibfd),
				    bfd_get_filename (obfd));
	      else
		_bfd_error_handler (_("\
ERROR: %s uses hardware FP, whereas %s uses software FP"),
				    bfd_archive_filename (ibfd),
				    bfd_get_filename (obfd));

	      flags_compatible = FALSE;
	    }
	}

Seems to me the first bug is that include/elf/arm.h:EF_ARM_* is over-specified
thus allowing this implicit-default vs explicit-default mismatch to occur.
[Obviously this is something that presumably can't be fixed though.
Am I misreading the intention here?]

/* Processor specific flags for the ELF header e_flags field.  */
#define EF_ARM_RELEXEC     0x01
#define EF_ARM_HASENTRY    0x02
#define EF_ARM_INTERWORK   0x04
#define EF_ARM_APCS_26     0x08
#define EF_ARM_APCS_FLOAT  0x10
#define EF_ARM_PIC         0x20
#define EF_ARM_ALIGN8	   0x40		/* 8-bit structure alignment is in use.  */
#define EF_ARM_NEW_ABI     0x80
#define EF_ARM_OLD_ABI     0x100
#define EF_ARM_SOFT_FLOAT  0x200
#define EF_ARM_VFP_FLOAT   0x400
#define EF_ARM_MAVERICK_FLOAT 0x800

My preference for fixing this is to have gcc pass -mfpu=softfpa
in the default case.  Due to the way gcc is designed that can
get a bit hairy though.  Thus the second choice is to have gas
have defaults that match gcc (then elf files have an unambiguous
meaning of e_flags == 0).
Failing that I guess elf32_arm_merge_private_bfd_data is going to
have to become default aware.

Suggestions?

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

* Re: arm-elf snafu?  can't mix default-soft-float, explicit -msoft-float
  2003-07-22 17:11 arm-elf snafu? can't mix default-soft-float, explicit -msoft-float Doug Evans
@ 2003-07-23 18:35 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2003-07-23 18:35 UTC (permalink / raw)
  To: Doug Evans; +Cc: gcc-bugs, binutils

Hi Doug,

> Simple testcase:
>
> bash$ rm foo1.c foo2.c ; touch foo1.c foo2.c
> bash$ arm-elf-gcc -c foo1.c
> bash$ arm-elf-objdump -p foo1.o
> foo1.o:     file format elf32-littlearm
> private flags = 0: [APCS-32] [FPA float format]
> bash$ arm-elf-gcc -c foo2.c -msoft-float
> foo1.o:     file format elf32-littlearm
> private flags = 200: [APCS-32] [FPA float format] [software FP]
> bash$ arm-elf-gcc -nostdlib foo1.o foo2.o
> [links successfully]
> bash$ arm-elf-gcc -nostdlib foo2.o foo1.o
> /samantha/gnu-pure/rel/lib/gcc-lib/arm-elf/3.4/../../../../arm-elf/bin/ld: ERROR: foo1.o uses hardware FP, whereas a.out uses software FP

> This line in gcc/config/arm/elf.h
> 
> #ifndef SUBTARGET_ASM_FLOAT_SPEC
> #define SUBTARGET_ASM_FLOAT_SPEC "\
> %{mapcs-float:-mfloat} %{msoft-float:-mfpu=softfpa}"
> #endif


I think that this is the problem.  If you apply the patch below for
example, then arm-elf targets will always pass -mfpu=softfpa to GAS,
unless -mhard-float is specfied, whereas the arm-linux toolchain will
always pass an explicit -mfpu=fpa unless -msoft-float is specified.

What do you think ?

Cheers
        Nick

gcc/ChangeLog                
2003-07-23  Nick Clifton  <nickc@redhat.com>

	* config/arm/elf.h (SUBTARGET_ASM_FLOAT_SPEC): Pass
	-mfpu=softfpa to GAS by default.
	* config/arm/linux-elf.h (SUBTARGET_ASM_FLOAT_SPEC): Define.
        Pass -mfpu=fpa to GAS by default.

Index: gcc/config/arm/elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/elf.h,v
retrieving revision 1.44
diff -c -3 -p -r1.44 elf.h
*** gcc/config/arm/elf.h	19 Jun 2003 21:47:06 -0000	1.44
--- gcc/config/arm/elf.h	23 Jul 2003 18:32:24 -0000
***************
*** 46,52 ****
  
  #ifndef SUBTARGET_ASM_FLOAT_SPEC
  #define SUBTARGET_ASM_FLOAT_SPEC "\
! %{mapcs-float:-mfloat} %{msoft-float:-mfpu=softfpa}"
  #endif
  
  #ifndef ASM_SPEC
--- 46,52 ----
  
  #ifndef SUBTARGET_ASM_FLOAT_SPEC
  #define SUBTARGET_ASM_FLOAT_SPEC "\
! %{mapcs-float:-mfloat} %{!mhard-float:-mfpu=softfpa} %{mhard-float:-mfpu=fpa}"
  #endif
  
  #ifndef ASM_SPEC
  
Index: gcc/config/arm/linux-elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/linux-elf.h,v
retrieving revision 1.40
diff -c -3 -p -r1.40 linux-elf.h
*** gcc/config/arm/linux-elf.h	14 Jun 2003 17:11:57 -0000	1.40
--- gcc/config/arm/linux-elf.h	23 Jul 2003 18:32:24 -0000
***************
*** 40,45 ****
--- 40,49 ----
  #define MULTILIB_DEFAULTS \
  	{ "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
  
+ #undef  SUBTARGET_ASM_FLOAT_SPEC
+ #define SUBTARGET_ASM_FLOAT_SPEC "\
+   %{mapcs-float:-mfloat} %{!msoft-float:-mfpu=fpa} %{msoft-float:-mfpu=softfpa}"
+ 
  #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
  
  /* The GNU C++ standard library requires that these macros be defined.  */
        

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

end of thread, other threads:[~2003-07-23 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-22 17:11 arm-elf snafu? can't mix default-soft-float, explicit -msoft-float Doug Evans
2003-07-23 18:35 ` Nick Clifton

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