This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix target/11096: i686-linux to sh-linux cross compiler failsto compile C++ files


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11096 is the same as
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3774,
but for SH instead of arm.
Compiling a 'hello, world' c++ program spews errors of the sort

$ sh4-linux/gcc-3.3-glibc-2.2.5/bin/sh4-linux-g++ hello2.cc -o sh4-linux-hello2
In file included from /home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/sh4-linux/bits/c++io.h:35,
                 from /home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/bits/fpos.h:44,
                 from /home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/iosfwd:49,
                 from /home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/ios:44,
                 from /home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/ostream:45,
                 from /home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/iostream:45,
                 from hello2.cc:1:
/home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/cstdio:168: error: `
   vfscanf' not declared
/home3/dank/crosstool-0.3/result/sh4-linux/gcc-3.3-glibc-2.2.5/include/c++/3.3/cstdio:169: error: `
   vscanf' not declared
...

unless -D_ISOC9X_SOURCE is passed to the compiler.
The fix for arm appears to have been
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/linux-elf.h.diff?r1=1.31&r2=1.32
which predefines _GNU_SOURCE, with the comment
/* The GNU C++ standard library currently requires _GNU_SOURCE *

Looks like other architectures might need this, too.  I'm attaching a patch
for sh4.  No idea if it's the best fix, but it seems logical,
and it seems to resolve the problem for me.
- Dan


--- gcc-3.3/gcc/config/sh/linux.h.old Wed Jun 4 17:37:40 2003 +++ gcc-3.3/gcc/config/sh/linux.h Wed Jun 4 17:38:16 2003 @@ -52,6 +52,10 @@ %{!rpath:-rpath /lib}} \ %{static:-static}"

+/* The GNU C++ standard library requires that these macros be defined.  */
+#undef CPLUSPLUS_CPP_SPEC
+#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
+
 #undef LIB_SPEC
 #define LIB_SPEC \
   "%{shared: -lc} \

--
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]