gccamazon-ec2makefileec2-amigcc4.8

Make exits with "Error 2" when trying to install gcc-4.8.1


I'm trying to install gcc-4.8.1 on an AWS ec2 "Other Linux" distribution. I downloaded gcc-4.6.2.tar.gz and then followed these instructions under the 'Configuration' heading from http://gcc.gnu.org/wiki/InstallingGCC (modified for 4.8.1 instead of 4.6.2):

tar xzf gcc-4.8.1.tar.gz
cd gcc-4.8.1
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.1/configure --prefix=$HOME/gcc-4.8.1 
make
make install

When I run 'make', the program runs for some time but eventually exits with this error:

build/genattrtab /home/ec2-user/gcc-4.8.1_install/objdir/../gcc-4.8.1/gcc/config/i386/i386.md insn-conditions.md \
                -Atmp-attrtab.c -Dtmp-dfatab.c -Ltmp-latencytab.c
make[3]: *** [s-attrtab] Killed
make[3]: Leaving directory `/home/ec2-user/gcc-4.8.1_install/objdir/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/ec2-user/gcc-4.8.1_install/objdir'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/ec2-user/gcc-4.8.1_install/objdir'
make: *** [all] Error 2

Can anyone shed any insight into why this might be happening? I don't understand the error message at all. I'm building it with gcc4.6.1 and /home/ec2-user/gcc-4.8.1_install is the directory I ran the commands from within.


Solution

  • I was doing a few things wrong. First, I didn't have the latest binutils installed.

    This particular error, however, was the OOM killer at work. The peak RAM used during installation is greater than that of EC2 micro instance. Use a larger instance or use swap:

    SWAP=/tmp/swap
    dd if=/dev/zero of=$SWAP bs=1M count=500
    mkswap $SWAP
    sudo swapon $SWAP
    

    This will swap in 500 MB, which was ample for my installation.