Reputation: 1641
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.
Upvotes: 16
Views: 13866
Reputation: 1641
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.
Upvotes: 21