Skip to content

Installation on CentOS From Source

Nathan Pinnow edited this page Nov 5, 2020 · 6 revisions

In this tutorial, we show how to build ROSE Compiler on CentOS 7.6. These instructions were tested using Docker (docker run -ti centos:7.6.1810). This tutorial is restricted to installing ROSE for C/C++ and binaries. This tutorial shows using the release branch of ROSE which undergoes extensive testing though is updated infrequently. If you want the latest version of rose you should use the develop branch which can be updated multiple times per day but undergoes more limited testing.

From source code

The following code section shows all the command required to install ROSE, we will go into more detail in the following sections. If you are not running as root in a docker image do not forget to add sudo to the yum lines in order to install dependencies. Finally, you only need the last line if you interested into one of the ROSE's tool maintained internally.

#Initial Setup ------------------------------------------------------------------
yum update -y --skip-broken
yum install -y \
        tar git wget  cpio man bzip2 bzip2-devel\
        make automake libtool \
        libtool-ltdl-devel \
        which patch  \
        flex bison ghostscript byacc \
	gcc gcc-c++

export PREFIX=/path/to/rose/home
export NUM_PROCESSORS=10 #Assume 16gb of RAM

#Build GCC ----------------------------------------------------------------------
cd $PREFIX
mkdir -p gcc/7.4.0/build
cd gcc/7.4.0
wget -nv ftp://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.gz
tar xf gcc-7.4.0.tar.gz
rm -f gcc-7.4.0.tar.gz
mv gcc-7.4.0 src
cd src

./contrib/download_prerequisites
cd ../build
../src/configure --prefix="${PREFIX}/gcc/7.4.0/install" --enable-languages=c,c++ --disable-multilib

time make -j${NUM_PROCESSORS}
time make install -j${NUM_PROCESSORS}

export PATH="${PREFIX}/gcc/7.4.0/install/bin:${PATH}"
export LD_LIBRARY_PATH="${PREFIX}/gcc/7.4.0/install/lib64:${LD_LIBRARY_PATH}"

#Build Boost --------------------------------------------------------------------
cd "${PREFIX}"
mkdir -p boost/1_67_0

cd boost/1_67_0
wget -nv https://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.bz2/download -O boost_1_67_0.tar.bz2
tar jxf boost_1_67_0.tar.bz2
rm -f boost_1_67_0.tar.bz2
mv boost_1_67_0 src
cd src

./bootstrap.sh --prefix="../install" --with-libraries=all 
./b2 --prefix="../install" -j${NUM_PROCESSORS} install 

export LD_LIBRARY_PATH="${PREFIX}/boost/1_67_0/install/lib:${LD_LIBRARY_PATH}"
export BOOST_ROOT="${PREFIX}/boost/1_67_0/install"

#Download ROSE ------------------------------------------------------------------
cd "${PREFIX}"
mkdir -p rose/build rose/install
git clone -b release https://github.com/rose-compiler/rose.git rose/src

cd rose/src
./build

#Configure ----------------------------------------------------------------------
cd ../build
../src/configure --prefix="${PREFIX}/rose/install" \
                 --enable-languages=c,c++,binaries \
                 --with-boost="${BOOST_ROOT}"

#Compile ------------------------------------------------------------------------
make core -j${NUM_PROCESSORS}
make install-core -j${NUM_PROCESSORS}
make check-core -j${NUM_PROCESSORS}

#Optional to install tools ------------------------------------------------------
make install-tools -j${NUM_PROCESSORS}

Initial Setup

yum update -y --skip-broken
yum install -y \
        tar git wget  cpio man bzip2 bzip2-devel\
        make automake libtool \
        libtool-ltdl-devel \
        which patch  \
        flex bison ghostscript byacc \
	gcc gcc-c++

If your system does not have the basic prerequisites for ROSE, C++ compiler and Boost, they can be set up with the commands above. Full dependency information can be found at Software Dependencies

export PREFIX=/path/to/rose/home
export NUM_PROCESSORS=10 #Assume 16gb of RAM

PREFIX is the location ROSE will be installed along with a compatible version of gcc and Boost. NUM_PROCESSORS is used in the make commands to set the level of parallelism. There should be at least 1.5GB of RAM for each processor.

Build GCC

The default gcc for CentOS is a legacy compiler for ROSE which we no longer support. If your system does not have a compatible version of gcc with C++ enabled, follow these instructions to build gcc from source.

cd $PREFIX
mkdir -p gcc/7.4.0/build
cd gcc/7.4.0
wget -nv ftp://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.gz
tar xf gcc-7.4.0.tar.gz
rm -f gcc-7.4.0.tar.gz
mv gcc-7.4.0 src
cd src

The above commands set up the directories then download and unpack the gcc tar file.

./contrib/download_prerequisites
cd ../build
../src/configure --prefix="${PREFIX}/gcc/7.4.0/install" --enable-languages=c,c++ --disable-multilib

make -j${NUM_PROCESSORS}
make install -j${NUM_PROCESSORS}

After gcc has been unpacked, ensure the prerequisites are available then move to the build tree and configure gcc. After configuration, make and install the new version of gcc.

export PATH="${PREFIX}/gcc/7.4.0/install/bin:${PATH}"
export LD_LIBRARY_PATH="${PREFIX}/gcc/7.4.0/install/lib64:${LD_LIBRARY_PATH}"

Once gcc has been installed add it to PATH and LD_LIBRAARY_PATH so Boost and ROSE can find it.

Build Boost

cd "${PREFIX}"
mkdir -p boost/1_67_0

cd boost/1_67_0
wget -nv https://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.bz2/download -O boost_1_67_0.tar.bz2
tar jxf boost_1_67_0.tar.bz2
rm -f boost_1_67_0.tar.bz2
mv boost_1_67_0 src
cd src

Compile a newer version of Boost with the updated version of gcc. First, download and extract an appropriate version of Boost.

./bootstrap.sh --prefix="./install" --with-libraries=all
./b2 --prefix="./install" -std=c++11 install

Run the above commands to install to the local directory.

export LD_LIBRARY_PATH="${PREFIX}/boost_1_67_0/install/lib:${LD_LIBRARY_PATH}"
export BOOST_ROOT="${PREFIX}/boost_1_67_0/install"

Set up appropriate environment variables for ROSE to find Boost.

Download ROSE

cd "${PREFIX}"
mkdir -p rose/build rose/install
git clone -b release https://github.com/rose-compiler/rose.git rose/src

ROSE is distributed on GitHub. Use the release branch for a more stable experience. Other versions of ROSE (include latest development) are available via tagged commits or the develop branch.

cd rose/src
./build

You then need to generate the configure files inside of the source tree by running the build script.

Configure

cd ../build
../src/configure --prefix="${PREFIX}/rose/install" \
                 --enable-languages=c,c++,binaries \
                 --with-boost="${BOOST_ROOT}"

This step generates the Makefile for the specific configuration of ROSE that we want to install. The arguments to the configure script are:

  • specify the installation directory: --prefix=${PREFIX}/install
  • enable only C/C++ and binary support: --enable-languages=c,c++
  • specify location of Boost: --with-boost="${BOOST_ROOT}"

You can optionally add debug symbols to ROSE by using the configure option --with-CXX_DEBUG="-g". This will increase the size and time of a ROSE install.

More information about configure options can be found by running ${PREFIx}/rose/src/configure --help.

Compile

make core -j${NUM_PROCESSORS}
make install-core -j${NUM_PROCESSORS}
make check-core -j${NUM_PROCESSORS}

Finally, ROSE is compiled by running make. The commands above install and check ROSE core. To install some of the ROSE supported tools run:

make install-tools -j${NUM_PROCESSORS}