[uClibc] uClibc strtod() does not work well when I enabled soft-float.

Hiroshi Ito ito at mlb.co.jp
Sun Nov 7 14:09:10 UTC 2004


Hello,

I wrote:
> when I set SOFT_FLOAT to true in toolchains Makefile,
> Any string passed to strtod will be nan, until I use double
> constant value.
> 
> for example.
> # cat a.c
> #include <stdio.h>
> #include <stdlib.h>
>  
> int main( int argc, char *argv[] )
> {
>         double a;
>         printf( "%f\n", strtod( "1.0", NULL ) );
>         printf( "%f\n", strtod( "1.0", NULL ) );
>         a=1.0;
>         printf( "%f\n", strtod( "1.0", NULL ) );
>         printf( "%f\n", strtod( "1.0", NULL ) );
> }
> 
> compile as
> gcc-3.3.x/toolchain_mipsel_nofpu/bin/mipsel-linux-gcc \
> -static -o a a.c
> # ./a
> nan
> nan
> 1.000000
> 1.000000
> # 

Sorry, It was my fault about building toolchain.

Anyway, I compiled it with -msoft-float, It works.
gcc-3.3.x/toolchain_mipsel_nofpu/bin/mipsel-linux-gcc \
 -msoft-float -static -o a a.c
# ./a
1.000000
1.000000
1.000000
1.000000
#

Now the question.
When I build the uClibc with -msoft-float, all application have to
use -msoft-float ? Is it normal thing?

Is this mailing list is right place to send a patch of toolchain ?

when I build toolchain with SOFT_FLOAT:=true
It stops like follows,
----
# Replace specs file with one that defaults to soft float mode.
if [ ! -f /home/ito/t/toolchain/gcc-3.3.x/toolchain_mipsel_nofpu/usr/lib/gcc-lib/mipsel-linux-uclibc/3.3.4/specs ] ; then \
        echo staging dir specs file is missing ; \
        /bin/false ; \
fi;
staging dir specs file is missing
----

Patch is attached.
-------------- next part --------------
Index: gcc-uclibc-3.3.mk
===================================================================
RCS file: /var/cvs/toolchain/gcc-3.3.x/make/gcc-uclibc-3.3.mk,v
retrieving revision 1.9
diff -u -b -B -w -p -r1.9 gcc-uclibc-3.3.mk
--- gcc-uclibc-3.3.mk	6 Aug 2004 17:00:28 -0000	1.9
+++ gcc-uclibc-3.3.mk	7 Nov 2004 13:53:32 -0000
@@ -168,11 +168,11 @@ endif
 	);
 ifeq ($(SOFT_FLOAT),true)
 	# Replace specs file with one that defaults to soft float mode.
-	if [ ! -f $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ] ; then \
+	if [ ! -f  `$(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc -v 2>&1 | sed -n '1s:[^/]*\(/.*\):\1:p'` ] ; then \
 		echo staging dir specs file is missing ; \
 		/bin/false ; \
 	fi;
-	cp $(SOURCE_DIR)/specs-$(ARCH)-soft-float $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+	cp $(SOURCE_DIR)/specs-$(ARCH)-soft-float `$(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc -v 2>&1 | sed -n '1s:[^/]*\(/.*\):\1:p'`
 endif
 	touch $(GCC_BUILD_DIR2)/.installed
 
@@ -227,13 +227,13 @@ $(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_D
 	$(MAKE) $(JLEVEL) DESTDIR=$(TARGET_DIR) -C $(GCC_BUILD_DIR3) install
 ifeq ($(SOFT_FLOAT),true)
 	# Replace specs file with one that defaults to soft float mode.
-	if [ ! -f $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ] ; then \
+	if [ ! -f `$(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc -v 2>&1 | sed -n '1s:[^/]*\(/.*\):\1:p'` ] ; then \
 		echo target dir specs file is missing ; \
 		/bin/false ; \
 	fi;
-	cp $(SOURCE_DIR)/specs-$(ARCH)-soft-float $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+	cp $(SOURCE_DIR)/specs-$(ARCH)-soft-float  `$(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc -v 2>&1 | sed -n '1s:[^/]*\(/.*\):\1:p'`
 	# Make sure gcc does not think we are cross compiling
-	$(SED) "s/^1/0/;" $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+	$(SED) "s/^1/0/;" `$(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc -v 2>&1 | sed -n '1s:[^/]*\(/.*\):\1:p'`
 else
 	# Remove broken specs file (cross compile flag is set).
 	rm -f $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs


More information about the uClibc mailing list