Skip to content

Instantly share code, notes, and snippets.

@lnrsoft
Last active May 29, 2021 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lnrsoft/721b84e348192d755a23de5b0fb0c884 to your computer and use it in GitHub Desktop.
Save lnrsoft/721b84e348192d755a23de5b0fb0c884 to your computer and use it in GitHub Desktop.
How to build GCC 7.3.1 Compiler on OSX
# Building Prerequisites
# This basic list includes those packages that are required before we build our GNU GCC compiler from its source code.
# 1. GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on.
# 2. MPICH is a high performance and widely portable implementation of the Message Passing Interface (MPI) standard.
# 3. MPFR is a portable library written in C for arbitrary precision arithmetic on floating-point numbers. It is based on the GNU MP library. It aims to provide a class of floating-point numbers with precise semantics.
# 4. MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result.
# I use many more libraries during my work, POCO, Boost, OPenCV etc.
# I only added 3 other tool isl, doxygen and GDB to this list, they are not must but I strongly recommend them.
#
# -isl is a library for manipulating sets and relations of integer points bounded by linear constraints.
# -Doxygen is the de facto standard tool for generating documentation from annotated C++ sources
# -GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.
# -GCC 7.3.1 The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran.
# Roland Ihasz - March 2018
cd
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2
tar -xf gmp-6.1.2.tar.bz2
cd gmp-6.1.2
./configure --prefix=/usr/local/gcc-7.3.0 --enable-cxx
make -j 4
make check
sudo make install
cd
wget http://www.mpfr.org/mpfr-current/mpfr-4.0.1.tar.bz2
tar -xf mpfr-4.0.1.tar.bz2
cd mpfr-4.0.1
./configure --prefix=/usr/local/gcc-7.3.0 --with-gmp=/usr/local/gcc-7.3.0
make -j 4
sudo make install
cd
wget https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
tar -xf mpc-1.1.0.tar.gz
cd mpc-1.1.0
./configure --prefix=/usr/local/gcc-7.3.0 --with-gmp=/usr/local/gcc-7.3.0 --with-mpfr=/usr/local/gcc-7.3.0
make -j 4
sudo make install
cd
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
tar -xf isl-0.18.tar.bz2
cd isl-0.18
./configure
make -j 4
sudo make install
wget http://www.mpich.org/static/downloads/3.2.1/mpich-3.2.1.tar.gz
tar -xf mpich-3.2.1.tar.gz
cd mpich-3.2.1
./configure
make -j 4
sudo make install
cd
wget ftp://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.14.src.tar.gz
tar -xf doxygen-1.8.14.src.tar.gz
cd doxygen-1.8.14
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make -j 4
sudo make install
cd
wget http://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.gz
tar -xf gdb-8.1.tar.gz
cd gdb-8.1
./configure
make -j 4
sudo make install
cd
wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-7.3.0/gcc-7.3.0.tar.xz
tar -xf gcc-7.3.0.tar.xz
cd gcc-7.3.0
mkdir build
cd build
../configure --prefix=/usr/local/gcc-7.3.0 --enable-checking=release --with-gmp=/usr/local/gcc-7.3.0 --with-mpfr=/usr/local/gcc-7.3.0 --with-mpc=/usr/local/gcc-7.3.0 --enable-languages=c,c++,fortran --with-isl=/usr/local/gcc-7.3.0 --program-suffix=-7.3.0
make -j 4
sudo make install
export PATH=/usr/local/gcc-7.3.1/bin:$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment