Skip to content

Installation on Ubuntu From Source

Nathan Pinnow edited this page Nov 4, 2022 · 13 revisions

In this tutorial, we show how to build ROSE Compiler on Ubuntu 18.04. These instructions were tested using Docker (docker run -it ubuntu:18.04). This tutorial is restricted to installing ROSE for C/C++. 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.

apt-get Installation

You can follow the Install Using apt-get instructions to install pre-built binaries for Ubuntu 18.04, without building from source files.

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 apt-get lines in order to install dependencies. Make sure to set the value for NUM_PROCESSORS and ROSE_HOME to values appropriate for your system. Finally, you only need the last line if you interested into one of the ROSE's tool maintained internally.

#Initial Setup ------------------------------------------------------------------
apt-get update -y
apt-get install -y git wget make automake libtool gcc g++ libboost-all-dev flex bison ghostscript iputils-ping
export ROSE_HOME=/path/to/ROSE/HOME
export NUM_PROCESSORS=10 #Assume 16gb of RAM

#Download ROSE ------------------------------------------------------------------
mkdir -p ${ROSE_HOME}
git clone -b weekly https://github.com/rose-compiler/rose.git ${ROSE_HOME}/src
cd ${ROSE_HOME}/src
./build

#Configure ----------------------------------------------------------------------
mkdir ${ROSE_HOME}/build
cd $ROSE_HOME/build
#binaries can be added to --enable-languages for Ubuntu 20.04.
#See note below for insturctions on building binaries on Ubuntu 18.04
${ROSE_HOME}/src/configure --prefix=${ROSE_HOME}/install \
                  --enable-languages=c,c++ \ 
                  --with-boost=/usr --with-boost-libdir=/usr/lib/x86_64-linux-gnu 

#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

apt-get update -y
apt-get install -y git wget make automake libtool gcc g++ libboost-all-dev flex bison ghostscript

If your system does not have the prerequisites for ROSE they can be set up with the commands above. Full dependency information can be found at Software Dependencies

export ROSE_HOME=/path/to/ROSE/HOME
export NUM_PROCESSORS=10 #Assume 16gb of RAM

ROSE_HOME is the location ROSE will be installed. 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.

Download ROSE

mkdir -p ${ROSE_HOME}
git clone -b release https://github.com/rose-compiler/rose.git ${ROSE_HOME}/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_HOME}/src
./build

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

Configure

mkdir ${ROSE_HOME}/build
cd ${ROSE_HOME}/build
#binaries can be added to --enable-languages for Ubuntu 20.04.
#See note below for insturctions on building binaries on Ubuntu 18.04
${ROSE_HOME}/src/configure --prefix=${ROSE_HOME}/install \
                  --enable-languages=c,c++ \
                  --with-boost=/usr --with-boost-libdir=/usr/lib/x86_64-linux-gnu 

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=${ROSE_HOME}/install
  • enable only C/C++ support: --enable-languages=c,c++
  • specify location of Boost: --with-boost=/usr
  • specify location of Boost lib: --with-boost-libdir=/usr/lib/x86_64-linux-gnu

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 ${ROSE_HOME}/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}

Notes for Fortran support

While it can’t pass all tests for now it can work. To the github installation instructions add the following to the initial setup

apt install gfortran openjdk-8-jdk default-jre
export LD_LIBRARY_PATH=/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/:$LD_LIBRARY_PATH

Then add fortran to enabled languages and the –with-java flag.

Notes for Binary Analysis

To enable binary analysis on Ubuntu 20.04 add binaries the the enable languages list. On Ubuntu 18.04 the default boost in not compatible with ROSE so a different boost must be used. See below for instructions on building boost and the modified ROSE configure.

#Build Boost --------------------------------------------------------------------
export PREFIX=/path/to/boost/install/location
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"

#Updated ROSE configure
${ROSE_HOME}/src/configure --prefix=${ROSE_HOME}/install \
                  --enable-languages=c,c++,binaries \ 
                  --with-boost=$BOOST_ROOT

Clone this wiki locally