ROSE Compiler Framework/Installation

From Wikibooks, open books for an open world
Jump to: navigation, search

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

Platform Requirement[edit]

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 5.6 or its open source equivalent Centos 5.6
  • Ubuntu 10.04.4 LTS. Higher versions of Ubuntu are NOT supported due to the GCC versions supported by ROSE.
  • Mac OS X 10.5 and 10.6

Software Requirement[edit]

Here is a list for prerequisite software packages for installing ROSE

  • GCC 4.0.x to 4.4.x , the range of supported GCC versions is checked by support-rose.m4 during configuration
    • gcc
    • g++
    • gfortran (optional for Fortran support)
  • boost library: version 1.36 to 1.47. Again the range of supported Boost versions is checked by support-rose.m4 during configuration
  • Sun Java JDK
  • GNU autoconf >=2.6 and automake >= 1.9.5, GNU m4 >=1.4.5
  • libtool: >=1.5.6, defined in rose/build
  • 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

  • libxml2-devel
  • sqlite
  • texlive-full, need for building LaTeX docs

LLNL internal environment[edit]

For LLNL internal developers, we already have all software installed. They can be accessed by source

  • Redhat 5: /nfs/casc/overture/ROSE/opt/rhel5/x86_64/rose_environment.sh
  • Redhat 6: /nfs/casc/overture/ROSE/opt/rhel6/x86_64/rose_environment.sh


Some typical software paths are:

__GIT_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/git"
__BOOST_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/boost"
__GCC_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/gcc"
__GHC_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/ghc"
__JAVA_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/java/jdk"
__PYTHON_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/python"
__LIBTOOL_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/libtool"
__AUTOCONF_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/autoconf"
__AUTOMAKE_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/automake"
__LLVM_CLANG_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/llvm/clang"
__CMAKE_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/cmake"
__CCACHE_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/ccache"
__GHOSTSCRIPT_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/ghostscript"
__GRAPHVIZ_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/graphviz"
__XERCES_HOME="/nfs/casc/overture/ROSE/opt/rhel5/x86_64/xerces"

Default versions are

#-------------------------------------------------------------------------------
# Set Defaults
#-------------------------------------------------------------------------------
BOOST_VERSION_DEFAULT=1_45_0
GCC_VERSION_DEFAULT=4.4.5
GHC_VERSION_DEFAULT=6.10.4
GIT_VERSION_DEFAULT=latest
JAVA_VERSION_DEFAULT=latest
PYTHON_VERSION_DEFAULT=2.7.5
LIBTOOL_VERSION_DEFAULT=2.4
AUTOCONF_VERSION_DEFAULT=2.69
AUTOMAKE_VERSION_DEFAULT=1.14
LLVM_CLANG_VERSION_DEFAULT=3.0
CMAKE_VERSION_DEFAULT=latest
CCACHE_VERSION_DEFAULT=latest
GHOSTSCRIPT_VERSION_DEFAULT=latest
GRAPHVIZ_VERSION_DEFAULT=latest
XERCES_VERSION_DEFAULT=latest

Installing boost[edit]

The installation of Boost may need some special attention.

Download a supported boost version from http://sourceforge.net/projects/boost/files/boost/

For version 1.36 to 1.38

./configure --prefix=/home/usera/opt/boost-1.35.0
 make
 make install

Ignore the warning like : Unicode/ICU support for Boost.Regex?... not found.

For version 1.39 and 1.47: create the boost installation directory first

In boost source tree

  • ./bootstrap.sh --prefix=your_boost_install_path
  • ./bjam -j4 install --prefix=your_boost_install_path --libdir=your_boost_install_path/lib


Remember to export LD_LIBRARY_PATH for the installed boost library, for example

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/leo/opt/boost_1.45.0_inst/lib
export PATH LD_LIBRARY_PATH

Installing Java JDK[edit]

Download Java SE JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html

For example, you can download jdk-7u5-linux-i586.tar.gz for your Linux 32-bit system.

After untar it to your installation path, remember to set environment variables for Java JDK

# jdk path should be search first before other paths
PATH=/home/leo/opt/jdk1.7.0_05/bin:$PATH

# lib path for libjvm.so
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/leo/opt/jdk1.7.0_05/jre/lib/i386/server

# Don't forget to export both variables!!
export PATH LD_LIBRARY_PATH

./build[edit]

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

 rose_sourcetree>./build

configure[edit]

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.

 mkdir buildrose
 cd buildrose
 ../rose_sourcetree/configure --prefix=/home/user/opt/rose_tux284 --with-boost=/home/user/opt/boost-1.36.0/

ROSE's configure turns on debugging option by default. The generated object files should already have debugging information.

Additional useful configure options

  • Specify where a gcc's OpenMP runtime library libgomp.a is located. Only GCC 4.4's gomp lib should be used to have OpenMP 3.0 support
    • --with-gomp_omp_runtime_library=/usr/apps/gcc/4.4.1/lib/

EDG 4.x Branch[edit]

We are upgrading ROSE to use a later version of EDG frontend version 4.7.


Special configuration options are needed to turn on this new frontend, as follows:


/home/liao6/rose/freshmaster/sourcetree/configure --prefix=/home/liao6/rose/freshmaster/install --with-boost=/nfs/casc/overture/ROSE/opt/rhel6/x86_64/boost/1_45_0/gcc/4.4.5 --with-ROSE_LONG_MAKE_CHECK_RULE=yes --with-C_OPTIMIZE=-O0 --with-CXX_OPTIMIZE=-O0 --with-gomp_omp_runtime_library=/usr/apps/gcc/4.4.1/lib64/

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

make[edit]

In ROSE's build tree, type

 cd buildrose
 make -j4

will build the entire 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

 make -C src/ -j4

turn off silent build[edit]

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://www.flameeyes.eu/autotools-mythbuster/automake/silent.html.

make check[edit]

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 -C tests/ check -j4

make install[edit]

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.

A simplfied installation target is install-core, which only installs essential binaries

 make install-core

set environment variables[edit]

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

ROSE_INS=/home/userx/opt/rose_installation_tree
PATH=$PATH:$ROSE_INS/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROSE_INS/lib
# Don't forget to export variables !!!
export PATH LD_LIBRARY_PATH

try out a rose translator[edit]

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:

  identityTranslator -c helloWorld.c

It should generate an output file named rose_helloWorld.c, which should just look like your input code.

Trouble shooting[edit]

We list common issues associated with ROSE's installation.

EDG binary[edit]

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).

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:

$ ./config/config.guess 
x86_64-unknown-linux-gnu

2. Use the appropriate Autoconf options during configuration of ROSE:

$ $ROSE/configure [--build|--host|--target|...]

See Using the Target Type.

A real user's solution:

Hi Justin,

Checking the config.guess file in source tree, I search the apple darwin for detail information in  --build option, 
then  I found that  UNAME-PROCESSOR and UNAME_RELEASE are needed in --build

First, I type uname  -m (for finding UNAME_PROCESSOR in config.guess)
 result :  x86_64 
Second, I type uname -r (for finding UNAME_RELEASE)
 result : 10.8.0 (darwin kernel version)

Third, I type command to configure again, but I added  --build option, then autoconf can directly find the detail platform type
 
/Users/ma23/ROSE/configure --with-CXX_DEBUG=-ggdb3 --with-CXX_WARNINGS=-Wall --with-boost=/Users/ma23/Desktop/ROSE/boost/BOOST_INSTALL 
--with-gfortran=/Users/ma23/Desktop/macports/bin/gfortran-mp-4.4 --with-alternate_backend_fortran_compiler=gfortran-mp-4.4 
GFORTRAN_PATH=/Users/ma23/Desktop/macports/bin/gfortran-mp-4.4 --build=x86_64-apple-darwin10 

At last, make :)

Thanks:)
Regards,
Hongyi Ma