# ROSE Compiler Framework/Installation

ROSE is released as an open source software package. Users are expected to compile and install the software.

## Don't like installing ROSE?

There are quite some steps for users to install ROSE from scratch. We provide a virtual machine image which contains an installed copy of ROSE. You can download and try it out before making serious investment of your time.
More information about this is at ROSE_Compiler_Framework/Virtual_Machine_Image.

## Platform Requirement

ROSE is portable to Linux and Mac OS X on IA-32 and x86-64 platforms. In particular, ROSE developers often use the following development environments:
* Red Hat Enterprise Linux 7 or its open source equivalent Centos 7
* Ubuntu 18.04
Minimum disk space
* 30 GB

## Software Requirement

Here is a list for prerequisite software packages for installing ROSE
* GCC: the range of supported GCC versions is checked by support-rose.m4 during configuration.
** gcc
** g++
* boost library: Again the range of supported Boost versions is checked by support-rose.m4 during configuration
* GNU autoconf and automake
* libtool:
* bison (byacc),
* flex
* glibc-devel
* git
* ZGRViewer, a GraphViz/DOT Viewer: essential to view dot graphs of ROSE AST
** install Graphviz first - Graph Visualization Software
Optional packages for additional features or advanced users
* gfortran (optional for Fortran support)
* Sun Java JDK or OpenJDK: needed only if you are interested in Fortran and Java support in ROSE.
* libxml2-devel
* sqlite
* texlive-full, need for building LaTeX docs

## Instructions for Ubuntu 18.04

Full process from the beginning to the end. It takes about 1 hour to finish if using an Amazon t2.2xlarge (AWS 8 vCPUs+32 GB Mem.) instance with -j8.

## ./build

In general, it is better to rebuild the configure file in the top level source directory of ROSE. Just type:

## configure

The next step is to run configure in a separated build tree. ROSE will complain if you try to build it within its source directory.
There are many configuration options. You can see the full list of options by typing ../sourcetree/configure --help . But only --prefix and --with-boost are required as the minimum options.
By default, all supported languages are enabled as much as possible, this may slow down your compilation process. You can specify the desired language sets by using:
For example, you can use "--enable-languages=c++,fortran" if you are only interested in C++ and fortran languages support
Additional useful configure options
* Specify where a gcc's OpenMP runtime library libgomp.a is located. Only GCC 4.4 (and after)'s gomp lib should be used to have OpenMP 3.0 support
** --with-gomp_omp_runtime_library=/usr/apps/gcc/4.4.1/lib/
By default, ROSE is configured with GCC's -O2 and -g options by default so the translators shipped with ROSE should already have some debugging information available. But some variables may be optimized away. To preserve the max debugging information, you may have to reconfigure/recompile rose to turn off GCC optimizations.
* --with-C_OPTIMIZE=-O0 --with-CXX_OPTIMIZE=-O0 // in the configuration option list
* --without-CXX_OPTIMIZE --without-C_OPTIMIZE // alternative method
* --with-C_OPTIMIZE=no --with-CXX_OPTIMIZE=no // third way
To enable more comprehensive testing when typing make check
* --with-ROSE_LONG_MAKE_CHECK_RULE=yes
If you are interested in the OpenMP lowering translation in ROSE and let it automatically link with GCC's libgomp.a, you should add one more option
* --with-gomp_omp_runtime_library=/usr/lib/gcc/x86_64-redhat-linux/4.4.5/
Other useful options
* --enable-boost-version-check=false // disable boost version check

### EDG version

Note: C++11 input files to ROSE are NOT supported using EDG 4.9 configuration with GNU compilers 4.9 and greater (configure ROSE using EDG 4.12)

### cmake

see more at ROSE Compiler Framework/cmake
EDG 4.x-based ROSE also supports cmake build system.
Here is the CMake command to configure ROSE:
Needs
* boost
* jdk: export JAVA_HOME=/home/demo/opt/jdk1.8.0_25/
* libxml2
$ CC=gcc CXX=g++ cmake ../rose/ -DBOOST_ROOT="$BOOST_HOME" -Denable-cuda:BOOL=off -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:PATH="$(pwd)/../install"
Afterwards, simply run "make" and then "ctest".

## make

In ROSE's build tree, type
will build the core ROSE, including librose.so, tutorials, projects, tests, and so on. -j4 means to use four processes to perform the build. You can have bigger numbers if your machine supports more concurrent processes. Still, the entire process will take hours to finish.
For most users, building librose.so should be enough for most of their work. In this case, just type

### turn off silent build

By default, the Automake build system will use silent build to reduce screen output. Details about compilation/linking command lines and options are hidden. In case you want to see the full command lines, you can pass an option to make, like "make V=1".
More background information about this subject is available at https://autotools.io/automake/silent.html.

## make check

Optionally, you can type make check to make sure the compiled rose pass all its shipped tests. This takes hours again to go through all make check rules within projects, tutorial, and tests directories.
To save time, you can just run partial tests under a selected directory, like the buildrose/tests

## make install

After "make", it is recommended to run "make install" so rose's library (librose.so), headers (rose.h) and some prebuilt rose-based tools can be installed under the specified installation path using --prefix.
To install everything, type the following command line under your ROSE build tree:
A simplified installation target is install-core, which only installs essential binaries and prebuilt tools

## set environment variables

After the installation, you should set up some standard environment variables so you can use rose. For bash, the following is an example:

## try out a rose translator

There are quite some pre-built rose translators installed under $ROSE_INS/bin.
You can try identityTranslator, which just parses input code, generates AST, and unparses it back to original code:
It should generate an output file named rose_helloWorld.c, which should just look like your input code.

### some example options

identityTranslator --help

## Trouble shooting

We list common issues associated with ROSE's installation.

### EDG binary

If you do not have the EDG frontend source code, ROSE's build system will automatically attempt to download an appropriate EDG binary using wget during the build process (i.e. make -C src/frontend/CxxFrontend). This is an example download URL that is generated by ROSE's build system:
The generalized format for the tarball file is as follows:
The binary compatibility signature can be manually generated executing the ROSE/scripts/edg-generate-sig script. For example:
The EDG binaries are platform-specific and have historically been a cause of issues, i.e. Autoconf detecting wrong host/build/platform types. One possible remedy to these problems is to use the Autoconf Build and Host Options:
1. Check what build system Autoconf thinks you have:
2. Use the appropriate Autoconf options during configuration of ROSE:
See Using the Target Type.
A real user's solution: