[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#565369: eglibc: Please add __set_fpscr prototype



Source: eglibc
Version: 2.10.2-5
Severity: important
Tags: patch
User: debian-sh4@superh.org
Usertags: sh4
X-Debbugs-CC: debian-superh@lists.debian.org

Hi,

When we compile a  program that used _FPU_SETCW in sh4 in C++, we
become the error.
Because .....
1.Current eglibc does not have prototype of __set_fpscr.
2. _FPU_SETCW is macro, and __set_fpscr function in libgcc.a is called.
    When user use _FPU_SETCW in C++, user has build error. Because
"extern "C"" is not set to  __set_fpscr.

This is sh4 specific.

test program:
-----
$ cat f.c
#include <fpu_control.h>
int main(void)
{
        _FPU_SETCW(0);
        return 0;
}
-----

build log: (failed)
-----
$ g++ -o f f.c -Wl,-t
/usr/bin/ld: mode shlelf_linux
/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../crt1.o
/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../crti.o
/usr/lib/gcc/sh4-linux-gnu/4.4.2/crtbegin.o
/tmp/ccZX5ufD.o
-lstdc++ (/usr/lib/gcc/sh4-linux-gnu/4.4.2/libstdc++.so)
-lm (/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../libm.so)
libgcc_s.so.1 (/usr/lib/gcc/sh4-linux-gnu/4.4.2/libgcc_s.so.1)
/lib/libc.so.6
(/usr/lib/libc_nonshared.a)elf-init.oS
/lib/ld-linux.so.2
libgcc_s.so.1 (/usr/lib/gcc/sh4-linux-gnu/4.4.2/libgcc_s.so.1)
/usr/lib/gcc/sh4-linux-gnu/4.4.2/crtend.o
/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../crtn.o
/tmp/ccZX5ufD.o: In function `main':
f.c:(.text+0x24): undefined reference to `__set_fpscr(unsigned long)'
/usr/bin/ld: link errors found, deleting executable `f'
collect2: ld returned 1 exit status
-----

build log: (success. After applied the patch which I attached.)
-----
$ g++ -o f f.c -Wl,-t
/usr/bin/ld: mode shlelf_linux
/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../crt1.o
/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../crti.o
/usr/lib/gcc/sh4-linux-gnu/4.4.2/crtbegin.o
/tmp/ccu0OHaQ.o
-lstdc++ (/usr/lib/gcc/sh4-linux-gnu/4.4.2/libstdc++.so)
-lm (/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../libm.so)
libgcc_s.so.1 (/usr/lib/gcc/sh4-linux-gnu/4.4.2/libgcc_s.so.1)
(/usr/lib/gcc/sh4-linux-gnu/4.4.2/libgcc.a)_set_fpscr.o
/lib/libc.so.6
(/usr/lib/libc_nonshared.a)elf-init.oS
/lib/ld-linux.so.2
libgcc_s.so.1 (/usr/lib/gcc/sh4-linux-gnu/4.4.2/libgcc_s.so.1)
/usr/lib/gcc/sh4-linux-gnu/4.4.2/crtend.o
/usr/lib/gcc/sh4-linux-gnu/4.4.2/../../../crtn.o
-----

I made a patch to solve this problem. Could you apply this patch?
I apply "extern "C"" to only __set_fpscr with patch. Should I apply
the whole file in this?

Best regards,
 Nobuhiro

-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6
--- a/sysdeps/sh/sh4/fpu/fpu_control.h	2006-08-17 10:18:26.000000000 +0900
+++ b/sysdeps/sh/sh4/fpu/fpu_control.h	2010-01-15 15:31:04.000000000 +0900
@@ -45,6 +45,14 @@
 #define _FPU_GETCW(cw) __asm__ ("sts fpscr,%0" : "=r" (cw))
 
 #if defined __GNUC__
+/* Allow the use in C++ code.  */
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void __set_fpscr(unsigned long);
+#ifdef __cplusplus
+}
+#endif  /* C++ */
 #define _FPU_SETCW(cw) __set_fpscr ((cw))
 #else
 #define _FPU_SETCW(cw) __asm__ ("lds %0,fpscr" : : "r" (cw))

Reply to: