Skip to content

Instantly share code, notes, and snippets.

@mottosso
Forked from jeetsukumaran/build-gcc.sh
Last active July 24, 2018 03:21
Show Gist options
  • Save mottosso/73acaa883cd0442176e646b084117e1e to your computer and use it in GitHub Desktop.
Save mottosso/73acaa883cd0442176e646b084117e1e to your computer and use it in GitHub Desktop.
Build and Install GCC from Scratch

Usage

The Docker image contains the OS and dependencies to produce a standalone copy of GCC, written to the current working directory.

Quick Install

$ curl -sL https://gist.githubusercontent.com/mottosso/73acaa883cd0442176e646b084117e1e/raw/shell.sh | bash -
$ gcc --version
# gcc (GCC) 4.8.3
# Copyright (C) 2013 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.  There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Manual Install

$ git clone https://gist.github.com/73acaa883cd0442176e646b084117e1e.git build-gcc
$ cd build-gcc
$ docker build -t mottosso/scientific:6.6 .
$ docker run -ti --rm -v $(pwd):/home/root mottosso/scientific:6.6 bash build.sh
$ export PATH=$(pwd)/gcc-4.8.3/bin
$ gcc --version
# gcc (GCC) 4.8.3
# Copyright (C) 2013 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.  There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# GCC build script for Scientific Linux 6.6
GCC_VERSION="4.8.3"
WORKDIR="/tmp"
INSTALLDIR="$(pwd)/gcc-${GCC_VERSION}"
# Get the source code
cd $WORKDIR && \
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 && \
tar -xf gcc-${GCC_VERSION}.tar.bz2|| exit 1
# Download prerequisites
cd $WORKDIR/gcc-${GCC_VERSION} && \
./contrib/download_prerequisites || exit 1
# Build
# Flags derived from Rez
# https://github.com/nerdvegas/rez/blob/42c7c391483742062a828c7c6583c867b45c5d3e/repository/gcc/4.8.2/build.sh#L62
mkdir -p $WORKDIR/build && \
cd $WORKDIR/build && \
../gcc-${GCC_VERSION}/configure \
--prefix=${INSTALLDIR} \
--enable-languages=c,c++,fortran,objc \
--with-pic \
--disable-shared \
--enable-static \
--enable-threads=posix \
--enable-__cxa_atexit \
--enable-clocale=gnu \
--with-libelf=/usr/include \
--disable-multilib \
--disable-bootstrap \
--disable-install-libiberty \
--with-system-zlib && \
make || exit 1
echo "Installing.."
mkdir -p $INSTALLDIR && \
make install || exit 1
echo "Finished successfully"
FROM ringo/scientific:6.6
MAINTAINER marcus@abstractfactory.io
# Prerequisities
RUN yum install -y \
wget \
zlib-devel && \
yum groupinstall -y \
"Development Tools" \
"Development Libraries"
WORKDIR /home/root
gcc=$(pwd)/gcc-4.8.3
export PATH=$gcc/bin:$PATH
export LD_LIBRARY_PATH=$gcc/lib64
# Install via curl
#
# Usage:
# $ curl -sL https://gist.githubusercontent.com/mottosso/73acaa883cd0442176e646b084117e1e/raw/shell.sh | bash -
#
git clone https://gist.github.com/73acaa883cd0442176e646b084117e1e.git build-gcc && \
cd build-gcc && \
docker build -t mottosso/scientific:6.6 . && \
docker run -ti --rm -v $(pwd):/home/root mottosso/scientific:6.6 bash build.sh && \
export PATH=$(pwd)/gcc-4.8.3/bin:$PATH || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment