2

I'm using Arch linux and I need GCC 4.7.0 for a class.

I only have GCC 6.2.1 installed on my system currently.

I followed all the install instructions correctly but I still yield this error after running the initial make.

$ make
.
.
In file included from /home/flounder/src/gcc-4.7.0/gcc-4.7.0/gcc/cp/except.c:987:0:
cfns.gperf: At top level:
cfns.gperf:101:1: error: ‘gnu_inline’ attribute present on ‘libc_name_p’
cfns.gperf:26:14: error: but not here
.
.
make[3]: *** [Makefile:1055: cp/except.o] Error 1
make[3]: Leaving directory '/home/flounder/src/gcc_compile/gcc'
make[2]: *** [Makefile:4101: all-stage1-gcc] Error 2
make[2]: Leaving directory '/home/flounder/src/gcc_compile'
make[1]: *** [Makefile:19342: stage1-bubble] Error 2
make[1]: Leaving directory '/home/flounder/src/gcc_compile'
make: *** [Makefile:898: all] Error 2

I've read that this can happen when trying to build old versions of GCC with modern versions because:

GCC adds new errors as versions go on, so the source code of older versions of GCC isn't always considered valid under newer versions of GCC

I read that here, here, and here.

So what can I do to remedy the issue?

Two possible solutions I think could work:

  1. Cross compile GCC 4.7.0 for my computer using the school Linux computers (which also have GCC 4.7.0 but they're 32-bit and I have a 64-bit OS)
  2. First compile GCC 5.4.x on my computer using GCC 6.2.1 then use GCC 5.4.x to compile GCC 4.7.0

The first option seems more bulletproof. Would they both work? Is one better than the other?

Edit:

As @Kenneth B. Jensen mentioned below, I attempted to run the configuration with the --disable-werror flag set and attempted to run the initial make with the -k flag set but I still ran into trouble. The following is the error output:

$ make -k
.
.
.
if [ xinfo = xinfo ]; then \
    makeinfo --split-size=5000000 --split-size=5000000 --split-size=5000000 --no-split -I . -I /home/flounder/src/gcc-4.7.0/gcc/doc \
            -I /home/flounder/src/gcc-4.7.0/gcc/doc/include -o doc/cppinternals.info /home/flounder/src/gcc-4.7.0/gcc/doc/cppinternals.texi; \
fi
echo timestamp > gcc.pod
perl /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl /home/flounder/src/gcc-4.7.0/gcc/doc/invoke.texi > gcc.pod
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\@strong{ <-- HERE (.*)}$/ at /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl line 319.
echo timestamp > doc/gcc.1
(pod2man --center="GNU" --release="gcc-4.7.0" --date=2012-03-22 --section=1 gcc.pod > doc/gcc.1.T$$ && \
    mv -f doc/gcc.1.T$$ doc/gcc.1) || \
    (rm -f doc/gcc.1.T$$ && exit 1)
echo timestamp > gpl.pod
perl /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl /home/flounder/src/gcc-4.7.0/gcc/doc/include/gpl_v3.texi > gpl.pod
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\@strong{ <-- HERE (.*)}$/ at /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl line 319.
echo timestamp > doc/gpl.7
(pod2man --center="GNU" --release="gcc-4.7.0" --date=2012-03-22 --section=7 gpl.pod > doc/gpl.7.T$$ && \
    mv -f doc/gpl.7.T$$ doc/gpl.7) || \
    (rm -f doc/gpl.7.T$$ && exit 1)
cp doc/gcc.1 doc/g++.1
make[3]: Target 'all' not remade because of errors.
rm gcc.pod
make[3]: Leaving directory '/home/flounder/src/gcc_compile/gcc'
make[2]: *** [Makefile:4101: all-stage1-gcc] Error 2
make[2]: Target 'all-stage1' not remade because of errors.
make[2]: Leaving directory '/home/flounder/src/gcc_compile'
make[1]: *** [Makefile:19342: stage1-bubble] Error 2
make[1]: Target 'stage3-bubble' not remade because of errors.
make[1]: Leaving directory '/home/flounder/src/gcc_compile'
make: *** [Makefile:898: all] Error 2
  • Is there any particular need for GCC 4.7.0? GCC 6.2.1 should be backwards compatible with older versions, especially if the class only involves compiling relatively simple programs. – Kenneth B. Jensen Jan 8 '17 at 6:23
  • I would prefer to use GCC 4.7.0 if possible. The class uses an automated grading system for the programs and compiles our programs using GCC 4.7.0 with the -Werror flag set (among others). I'm not sure if there are any scenario's where GCC 4.7.0 would throw a warning and GCC 6.2.1 would not but that would definitely be one example of why I'd like to use GCC 4.7.0 instead. Also, the class is an operating systems class, so there will be a large amount of threaded and concurrent programming. – Maxwell Morgan Jan 8 '17 at 6:28
  • Be sure to make clean before attempting a rebuild (configure or make), too – Kenneth B. Jensen Jan 8 '17 at 7:17
  • Yes, I ran the make distclean as suggested in the installation documentation but still came about the errors posted above in the edit – Maxwell Morgan Jan 8 '17 at 7:18
  • I still haven't been able to compile 4.7.0 successfully from 6.2.1, though compiling 5.4.0 has been successful in the build process at time of writing, which may be possible to reverse through the versions to build 4.7.0. – Kenneth B. Jensen Jan 8 '17 at 9:31
3

You'll probably end up spending an awful lot of time getting GCC 4.7 built on your current system, and in the end you still won't be sure of the result: your school's computers' version of GCC may include distribution patches or even local changes which your version won't have.

I would suggest instead that you run the distribution your school is using in a VM. Your school is using RHEL, and you can too: you can get a no-cost developer subscription from Red Hat Developers; once you've got your subscription, you can download ISOs of any still-supported version of RHEL, so you should be able to install the same version as used on the school computers.

In any case since this is for grading purposes you should always check your code on the school computers before submitting it!

2

I agree that using a newer gcc is often not a good option. I had to write a new program for an embedded ARM v4 system running Pengutronix stuck at a 2.6 kernel and an old glibc. Therefore I had to compile the old toolchain on my system.

Often newer GCC versions find errors in the source code, that have been present there for quite some time. Instead of turning the error checking off, I advise to fix the source code instead.

According to the error log the function declaration and the function header do not match for

const char * libc_name_p (const char *, unsigned int);

in file cfns.h included in except.c

Edit cfns.h and change the function declaration

#ifdef __GNUC__
__inline
#endif
const char * libc_name_p (const char *, unsigned int);

to

#ifdef __GNUC__
__inline
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const char * libc_name_p (const char *, unsigned int);

Then compilation should work.

1

Looking at the configure options for GCC, it may successfully make upon issuing ./configure --disable-werror, then building GCC with make -k.

From the man page (make (1)):

 -k, --keep-going
            Continue  as much as possible after an error.  While the 
            target that failed, and those that depend on it, cannot be 
            remade, the other dependencies of these target can be 
            processed all the same.

After doing both of these to compile GCC 4.7.0 under GCC 6.2.1 on x86_64, it seems to compile without issue, however, at time of writing, the compilation has not finished.

  • Thank you for the suggestion! But unfortunately, I still ran into some trouble down the line during the initial make -k. I'll add the error output to the question. – Maxwell Morgan Jan 8 '17 at 7:08
  • Yes, I ran the make distclean as suggested in the installation documentation but still came about the errors posted above – Maxwell Morgan Jan 8 '17 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.