zylin / zpugcc

50 stars 31 forks source link

Fails to build with GCC 5.4 #10

Open page-tek opened 7 years ago

page-tek commented 7 years ago

I didn't make an note of the exact error but something like:

cfns.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p' cfns.gperf:26:14: error: but not here

After googling I found that GCC 5 has a problem building older versions of GCC. I found a fix at https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00375.html

I'll include the diff from that thread. I didn't run the diff but applied it by hand. The complilation completed after I made the changes.

Cheers

Alan

diff --git a/gcc/cp/cfns.gperf b/gcc/cp/cfns.gperf
index 68acd3d..953262f 100644
--- a/gcc/cp/cfns.gperf
+++ b/gcc/cp/cfns.gperf
@@ -22,6 +22,9 @@ __inline
 static unsigned int hash (const char *, unsigned int);
 #ifdef __GNUC__
 __inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
 #endif
 const char * libc_name_p (const char *, unsigned int);
 %}
diff --git a/gcc/cp/cfns.h b/gcc/cp/cfns.h
index 1c6665d..6d00c0e 100644
--- a/gcc/cp/cfns.h
+++ b/gcc/cp/cfns.h
@@ -53,6 +53,9 @@ __inline
 static unsigned int hash (const char *, unsigned int);
 #ifdef __GNUC__
 __inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
 #endif
 const char * libc_name_p (const char *, unsigned int);
 /* maximum key range = 391, duplicates = 0 */
alvieboy commented 7 years ago

Thanks for the report. Let me try to reproduce the issue and see if your fix works.

ZiCog commented 3 years ago

I just had exactly the problem with 'libc_name_p' here.

The solution for me was to apply the "-fgnu89-inline" option to gcc. Making the following export before doing the build worked here:

export CC="gcc -fgnu89-inline"
ZiCog commented 3 years ago

This is a patch to add the export describe above to the build.sh:

diff --git a/toolchain/build.sh b/toolchain/build.sh
index 332e4065..fab6bd70 100644
--- a/toolchain/build.sh
+++ b/toolchain/build.sh
@@ -10,6 +10,7 @@ make install
 cd ..

 export PATH=`pwd`/install/bin:$PATH
+export CC="gcc -fgnu89-inline"
 rm -rf gccbuild
 mkdir gccbuild
 cd gccbuild