powerpc: FOO uses hard float, BAR uses soft float
Hi,
I'm looking for help to get rid of linker warnigns like these:
-> ./MAKEALL sequoia
Configuring for sequoia - Board: sequoia, Options: SEQUOIA
powerpc-linux-ld: Warning: 20010226-1.o uses hard float, libpostpowerpcfpu.o uses soft float
powerpc-linux-ld: Warning: acc1.o uses hard float, libpostpowerpcfpu.o uses soft float
powerpc-linux-ld: Warning: /opt/eldk-5.1/powerpc/sysroots/powerpc-linux/usr/lib/powerpc-linux/4.6.1/libgcc.a(darwin-ldouble.o) uses hard float, u-boot uses soft float
These warnings are cause by the fact that we always build U-Boot with "-msoft-float", but boards that have POST enabled may pull in the FPU test code, which naturally will have to be compiled with "-mhard-float" instead.
Is there any way to silence these warnings (ideally only for these specific set of files, where we know they are to be expected) ?
I tried playing tricks to get rid of them - the information about using the FPU is envoded in the ".gnu.attributes" section of the ELF file:
-> readelf -A /work/wd/tmp-ppc/post/lib_powerpc/fpu/acc1.o Attribute Section: gnu
File Attributes
Tag_GNU_Power_ABI_FP: Hard float
-> readelf -e /work/wd/tmp-ppc/post/lib_powerpc/fpu/acc1.o | grep gnu.attributes
[129] .gnu.attributes LOOS+ffffff5 00000000 004e5c 000010 00 0 0 1
We can remove this information using brute force, like
${CROSS_COMPILE}objcopy -R .gnu.attributeswhich indeed gets rid of most of the warnings - but it will still result in the
powerpc-linux-ld: Warning: /opt/eldk-5.1/powerpc/sysroots/powerpc-linux/usr/lib/powerpc-linux/4.6.1/libgcc.a(darwin-ldouble.o) uses hard float, u-boot uses soft float
warning.
Anybody any ideas?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Two wrongs don't make a right, but three rights make a left.
Quoted 10 lines · Wolfgang Denk
Hi,
I'm looking for help to get rid of linker warnigns like these:
-> ./MAKEALL sequoia
Configuring for sequoia - Board: sequoia, Options: SEQUOIA
powerpc-linux-ld: Warning: 20010226-1.o uses hard float, libpostpowerpcfpu.o uses soft float
powerpc-linux-ld: Warning: acc1.o uses hard float, libpostpowerpcfpu.o uses soft float
powerpc-linux-ld: Warning: /opt/eldk-5.1/powerpc/sysroots/powerpc-linux/usr/lib/powerpc-linux/4.6.1/libgcc.a(darwin-ldouble.o) uses hard float, u-boot uses soft float
Quoted 7 lines
These warnings are cause by the fact that we always build U-Boot with "-msoft-float", but boards that have POST enabled may pull in the FPU test code, which naturally will have to be compiled with "-mhard-float" instead.
Is there any way to silence these warnings (ideally only for these specific set of files, where we know they are to be expected) ?
I'm not familiar with PPC, but below I describe the situation for ARM; if it's similar, this should be useful...
soft and hard float are incompatible ABIs. You can't mix code that's compiled with different ABIs. That's what the linker is complaining about.
The solution may be to build U-Boot with -mfloat-abi=hard, but disallow FP usage through some other means (I /think/ there's a separate gcc flag for this).
Alternatively, the FPU test code could be built with -mfloat-abi=softfp. That allows FPU usage (especially true if it's via inline assembler etc.!), but has an ABI compatible with -mfloat-abi=soft.
I wrote up more background notes on this for our internal wiki:
Not all ARM CPUs have a floating-point co-processor (FPU), and hence not all ARM CPUs have the FPU's set of dedicated floating-point (FP) registers.
Historically, this has meant that:
* The calling convention does not pass FP values in the dedicated FP
registers (FPRs), but rather uses the main ARM CPU's regular register set.
* Compilers don't emit FP instructions into code, but rather emit
calls to utility functions to perform FP operations, such as add or multiply. The implementation of those utility functions may contain hand-coded assembler that uses the FPU, or call an FP emulation library; the choice is up to the system/OS builder based on their knowledge of the actual CPU's capabilities.
The above combination yields the FP ABI known as "soft"; gcc option -mfloat-abi=soft.
When it is known that code will run on CPU(s) with a real FPU, the compiler may be instructed to emit FP instructions directly into the code. This benefits performance since a function call is no longer needed for each FP operation. However, for backwards-compatibility, when passing FP values between functions, the calling convention is not changed, and hence the values need to be moved back and forth between CPU registers and FPRs. This yields the floating point ABI known as "softfp"; gcc option -mfloat-abi=softfp.
Code using either the "soft" or "softfp" "ABIs" is 100% compatible (given a CPU that actually has an FPU); the actual ABI is identical between these two cases, the difference simply being whether FP operations use FPU instructions directly or not.
Most recent CPUs do actually contain an FPU. In this case, it is inefficient to constantly move FP values back and forth between CPU register and FPRs. To address this, a new calling convention was created, which uses FPRs to pass FP values between functions. This yields the floating point ABI known as "hard"; gcc option -mfloat-abi=hard.
Code using the "hard" ABI is incompatible with code using either the "soft" or "softfp" ABIs. The entire system (C library, all shared libraries, all applications) must be rebuilt using the hard ABI for it to function correctly because FP values are passed in the FP hardware registers in the hard ABI.
The user-space <-> kernel-space divide provides a barrier between ABI requirements. The kernel specifies a completely different syscall-based ABI and this is not be affected by whether user-space uses the soft or hard ABI for function calls. This is largely moot as syscalls generally do not pass or return floating point numbers.
Signature · 1 line
nvpublic
Quoted 40 lines · Wolfgang Denk
Hi,
I'm looking for help to get rid of linker warnigns like these:
-> ./MAKEALL sequoia
Configuring for sequoia - Board: sequoia, Options: SEQUOIA
powerpc-linux-ld: Warning: 20010226-1.o uses hard float, libpostpowerpcfpu.o uses soft float
powerpc-linux-ld: Warning: acc1.o uses hard float, libpostpowerpcfpu.o uses soft float
powerpc-linux-ld: Warning: /opt/eldk-5.1/powerpc/sysroots/powerpc-linux/usr/lib/powerpc-linux/4.6.1/libgcc.a(darwin-ldouble.o) uses hard float, u-boot uses soft floatThese warnings are cause by the fact that we always build U-Boot with "-msoft-float", but boards that have POST enabled may pull in the FPU test code, which naturally will have to be compiled with "-mhard-float" instead.
Is there any way to silence these warnings (ideally only for these specific set of files, where we know they are to be expected) ?
I tried playing tricks to get rid of them - the information about using the FPU is envoded in the ".gnu.attributes" section of the ELF file:
-> readelf -A /work/wd/tmp-ppc/post/lib_powerpc/fpu/acc1.o Attribute Section: gnu
File Attributes
Tag_GNU_Power_ABI_FP: Hard float-> readelf -e /work/wd/tmp-ppc/post/lib_powerpc/fpu/acc1.o | grep gnu.attributes
[129] .gnu.attributes LOOS+ffffff5 00000000 004e5c 000010 00 0 0 1We can remove this information using brute force, like
${CROSS_COMPILE}objcopy -R .gnu.attributeswhich indeed gets rid of most of the warnings - but it will still result in the
Quoted 7 lines
powerpc-linux-ld: Warning: /opt/eldk-5.1/powerpc/sysroots/powerpc-linux/usr/lib/powerpc-linux/4.6.1/libgcc.a(darwin-ldouble.o) uses hard float, u-boot uses soft float
warning.
Anybody any ideas?
Look at commit, we dealt with this in the past
commit ce82ff05388b5ddafdf6082ef0776cce72c40b1c
Author: Yuri Tikhonov <[email protected]> Date: Sat Dec 20 14:54:21 2008 +0300
FPU POST: fix warnings when building with 2.18 binutils
Also:
commit e009cdeb63308f291c54b173484401aab4a3fe54
Author: Kumar Gala <[email protected]> Date: Tue Jan 25 03:00:08 2011 -0600
powerpc: Fix FPU post related link warnings
- k
Dear Kumar,
Quoted 9 lines · In message <[email protected]> you wrote:
Look at commit, we dealt with this in the past
commit
ce82ff05388b5ddafdf6082ef0776cce72c40b1cAuthor: Yuri Tikhonov <[email protected]> Date: Sat Dec 20 14:54:21 2008 +0300FPU POST: fix warnings when building with 2.18 binutils
Quoted 7 lines
Also:
commit
e009cdeb63308f291c54b173484401aab4a3fe54Author: Kumar Gala <[email protected]> Date: Tue Jan 25 03:00:08 2011 -0600powerpc: Fix FPU post related link warnings
Thanks for pointing out. I have to admit that I had completely forgotten about these.
Hm, unfortunately this appears to have stopped working.
The two objects that are flagged as "Tag_GNU_Power_ABI_FP: Hard float" are
post/lib_powerpc/fpu/acc1.o
and
post/lib_powerpc/fpu/20010226-1.o
Both corresponding source files have the GNU_FPOST_ATTR macro...
It appears with GCC 4.6.1 the explicit "-mhard-float" command line option takes precedence over the ``asm(".gnu_attribute 4, 2");'' in the source file :-(
Is there any way to manually edit the attribute in the object file, using ld or elfedit or ... ?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de God made machine language; all the rest is the work of man.
PATCH 1/1 PPC: fix "Warning: FOO uses hard float, BAR uses soft float".
It appears that with recent versions of GCC the explicit "-mhard-float" command line option takes precedence over the ``asm(".gnu_attribute 4, 2");'' in the source file, so this no longer helps to avoid the warnings we get when linking code that uses FP instructions with other code that was built using soft-float.
We can remove the ".gnu_attribute" (which appears to carry no other information, at least so far) from the object files, but we also have to make sure we don't pull in the __gcc_qsub() and __gcc_qmul() functions from the standard libgcc, as these would again "infect" our linking. We copy this code from:
gcc-4.2.2/gcc/config/rs6000/darwin-ldouble.c
This old version was chosen because it was still available under a
compatible license (GCC v2+). The file was stripped down to the
needed parts, and reformatted so it passes checkpatch with only one warning (do not add new typedefs).
---
This patch silences build warnings for the following boards:
aev BC3450 charon, cm5200 fo300 korat korat_perm lwmon5 MiniFAP PMC440 sacsng sequoia sequoia_nand sequoia_ramboot TB5200 TB5200_B TQM5200 TQM5200_B TQM5200_B_HIGHBOOT TQM5200S TQM5200S_HIGHBOOT TQM5200_STK100
post/lib_powerpc/fpu/Makefile | 17 ++++- post/lib_powerpc/fpu/darwin-ldouble.c | 141 +++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 post/lib_powerpc/fpu/darwin-ldouble.c
post/lib_powerpc/fpu/Makefile +15 -2
@@ -24,10 +24,23 @@ include $(TOPDIR)/config.mk LIB = libpost$(ARCH)fpu.o -COBJS-$(CONFIG_HAS_POST) += fpu.o 20001122-1.o 20010114-2.o 20010226-1.o 980619-1.o -COBJS-$(CONFIG_HAS_POST) += acc1.o compare-fp-1.o mul-subnormal-single-1.o +COBJS-$(CONFIG_HAS_POST) += 20001122-1.o +COBJS-$(CONFIG_HAS_POST) += 20010114-2.o +COBJS-$(CONFIG_HAS_POST) += 20010226-1.o +COBJS-$(CONFIG_HAS_POST) += 980619-1.o +COBJS-$(CONFIG_HAS_POST) += acc1.o +COBJS-$(CONFIG_HAS_POST) += compare-fp-1.o +COBJS-$(CONFIG_HAS_POST) += fpu.o +COBJS-$(CONFIG_HAS_POST) += mul-subnormal-single-1.o + +COBJS-$(CONFIG_HAS_POST) += darwin-ldouble.o include $(TOPDIR)/post/rules.mk CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//) CFLAGS += -mhard-float -fkeep-inline-functions + +$(obj)%.o: %.c + $(CC) $(ALL_CFLAGS) -o [email protected] $< -c + $(OBJCOPY) -R .gnu.attributes [email protected] $@ + rm -f [email protected]
post/lib_powerpc/fpu/darwin-ldouble.c new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
1.7.6.4
PATCH 1/1 PPC: fix "Warning: FOO uses hard float, BAR uses soft float".
Hi Wolfgang,
Quoted 17 lines · On Thursday 22 December 2011 15:29:41 Wolfgang Denk wrote:
It appears that with recent versions of GCC the explicit "-mhard-float" command line option takes precedence over the ``asm(".gnu_attribute 4, 2");'' in the source file, so this no longer helps to avoid the warnings we get when linking code that uses FP instructions with other code that was built using soft-float.
We can remove the ".gnu_attribute" (which appears to carry no other information, at least so far) from the object files, but we also have to make sure we don't pull in the
__gcc_qsub()and__gcc_qmul()functions from the standard libgcc, as these would again "infect" our linking. We copy this code from:gcc-4.2.2/gcc/config/rs6000/darwin-ldouble.cThis old version was chosen because it was still available under a
compatible license (GCC v2+). The file was stripped down to the
needed parts, and reformatted so it passes checkpatch with only one warning (do not add new typedefs).
Quoted 5 lines
Signed-off-by Wolfgang Denk <[email protected]>Cc Kumar Gala <[email protected]>Cc Stefan Roese <[email protected]>Cc Andy Fleming <[email protected]>Cc Kim Phillips <[email protected]>
Tested successfully on sequoia, so:
Best regards,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 1/1 PPC: fix "Warning: FOO uses hard float, BAR uses soft float".
In reply to Wolfgang DenkHi Wolfgang,
Quoted 17 lines · On Thu, 22 Dec 2011 15:29:41 +0100 Wolfgang Denk <[email protected]> wrote:
It appears that with recent versions of GCC the explicit "-mhard-float" command line option takes precedence over the ``asm(".gnu_attribute 4, 2");'' in the source file, so this no longer helps to avoid the warnings we get when linking code that uses FP instructions with other code that was built using soft-float.
We can remove the ".gnu_attribute" (which appears to carry no other information, at least so far) from the object files, but we also have to make sure we don't pull in the
__gcc_qsub()and__gcc_qmul()functions from the standard libgcc, as these would again "infect" our linking. We copy this code from:gcc-4.2.2/gcc/config/rs6000/darwin-ldouble.cThis old version was chosen because it was still available under a
compatible license (GCC v2+). The file was stripped down to the
needed parts, and reformatted so it passes checkpatch with only one warning (do not add new typedefs).
Quoted 5 lines
Signed-off-by Wolfgang Denk <[email protected]>Cc Kumar Gala <[email protected]>Cc Stefan Roese <[email protected]>Cc Andy Fleming <[email protected]>Cc Kim Phillips <[email protected]>
Tested on TQM5200.
Anatolij
Wolfgang Denk
AppliedPATCH 1/1 PPC: fix "Warning: FOO uses hard float, BAR uses soft float".
In reply to Wolfgang DenkDear Wolfgang Denk,
Quoted 29 lines · In message <[email protected]> you wrote:
It appears that with recent versions of GCC the explicit "-mhard-float" command line option takes precedence over the ``asm(".gnu_attribute 4, 2");'' in the source file, so this no longer helps to avoid the warnings we get when linking code that uses FP instructions with other code that was built using soft-float.
We can remove the ".gnu_attribute" (which appears to carry no other information, at least so far) from the object files, but we also have to make sure we don't pull in the
__gcc_qsub()and__gcc_qmul()functions from the standard libgcc, as these would again "infect" our linking. We copy this code from:gcc-4.2.2/gcc/config/rs6000/darwin-ldouble.cThis old version was chosen because it was still available under a
compatible license (GCC v2+). The file was stripped down to the
needed parts, and reformatted so it passes checkpatch with only one warning (do not add new typedefs).Signed-off-by Wolfgang Denk <[email protected]>Cc Kumar Gala <[email protected]>Cc Stefan Roese <[email protected]>Cc Andy Fleming <[email protected]>Cc Kim Phillips <[email protected]>---
This patch silences build warnings for the following boards:
aev BC3450 charon, cm5200 fo300 koratkorat_permlwmon5 MiniFAP PMC440 sacsng sequoiasequoia_nandsequoia_rambootTB5200TB5200_BTQM5200TQM5200_BTQM5200_B_HIGHBOOTTQM5200STQM5200S_HIGHBOOTTQM5200_STK100
Quoted 4 lines
post/lib_powerpc/fpu/Makefile | 17 ++++- post/lib_powerpc/fpu/darwin-ldouble.c | 141 +++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 post/lib_powerpc/fpu/darwin-ldouble.c
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de He who hesitates is not only lost, but miles from the next exit.