16

I need an older version of GCC for installing CUDA toolkit, as CUDA toolkit does not support GCC newer than 5.3.1, and the Fedora machine I am trying to install it on comes with GCC 6. I don't have much control over the machine, so I have had to resort to building GCC myself. The steps I have followed are:

$ cd gcc-5.3.0
$ contrib/download_prerequisites
$ cd ../build
$ ../gcc-5.3.0/configure --prefix=$HOME/local/gcc-5.3.0 --program-suffix=5.3 --enable-shared --enable-multiarch --enable-threads=posix --enable-languages=c,c++,fortran --enable-checking=release --with-tune=generic
$ make

This results in successful configure, but make fails with error:

cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute

There are a whole bunch of other C++11 warnings as well. After some google searches, I figured that this had to do with building GCC 5 or older with GCC 6. I thought it might help if I could force the compiler to follow C++98 instead. So, I tried:

$ export CXXFLAGS="-std=gnu++98"
$ ../gcc-5.3.0/configure ...
$ make

Didn't work. I still keep getting the same C++11 warnings, with build failing with the exact same error. Then, I tried:

$ ../gcc-5.3.0/configure CXXFLAGS="-std=gnu++98" ...
$ make

Again, same error. I peeked at the Makefile this time, and it sure had CXXFLAGS set to -std=gnu++98 here and there. Also, I have tried to build GCC 4.9.3 as well to see if this is a problem tied to a specific release, but I got the same error again.

I am not sure how to proceed further. Any help is much appreciated. Thanks.

MD XF
8,1899 gold badges45 silver badges74 bronze badges
asked Dec 18, 2016 at 1:16
3
  • 3
    According to the documentation gcc.gnu.org/onlinedocs/gcc/Inline.html, gnu_inline is a gcc extension to pre-c99 C code. Since you have the source code, you can locate the file that causes the error and try to change the offending declaration to inline so that it follows the C99/11 and C++ syntax, or to __INLINE or __inline__. My guess is, your C++ code includes some headers written for pre-C99 c code. More info here: gcc.gnu.org/ml/gcc-patches/2015-08/msg00375.html Commented Dec 18, 2016 at 1:52
  • Interesting suggestion. I tried the changes as mentioned in the referenced link, it got me much further than the earlier error, but eventually it failed with error gcc-5.3.0/gcc/cp/except.c:1043: undefined reference to `libc_name_p(char const*, unsigned int)' collect2: error: ld returned 1 exit status. Commented Dec 18, 2016 at 2:14
  • try those solutions one by one? google.com/… Commented Dec 18, 2016 at 2:18

1 Answer 1

22

In case someone else had this problem, apparently it's fixed by this patch. If you make the suggested changes (which would be too verbose to mention here, but are simple enough to be done manually) to the GCC source files, then configure and make successfully work without the need to pass -std options. I successfully built GCC 5.3.0 using GCC 6.2.1 with these changes to the source files.

answered Dec 18, 2016 at 23:17
Sign up to request clarification or add additional context in comments.

4 Comments

Got following error In file included from ../.././gcc/cp/except.c:1023:0: ../.././gcc/cp/cfns.h:31:9: error: "cfns" is not a valid filename #line 3 cfns.gperf". Is it possible to build older gcc(5.3.1) using higher verssion(7)
I tried using this for gcc-4.8.5 and now hitting this error: ./md-unwind-support.h:141:18: error: field ‘uc’ has incomplete type struct ucontext uc;
Its curious why they release a version of GCC that doesn't compile?
Fo the ucontext compile failure i found this: unix.stackexchange.com/questions/566650/…

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.