# ROSE Compiler Framework/boost
## Impact of Using Boost in ROSE

The current way of using of Boost in ROSE has a love&hate impact. Some developers use Boost to simplify their work, but the cost is
* one mandatory external dependency for all other (users and developers who don't use Boost at all) and
* portability/maintenance issues (much of the limited supported GCC versions is caused by Boost libraries).
This page tries to document the boost libraries used by ROSE. Hopefully we can figure out why we must have each of them and if some can be made optional (not required by users who are not interested in the features a library supports)
To be crystal clear, we appreciate the Open Source Boost Community providing free and wonderful libraries. The issue is how we can better use Boost in ROSE to obtain a good balance of productivity, portability, and maintainability.

## Action Items

Make some less used libraries optional
* thread
* iostream
* wave

## Current dependent libraries

http://www.boost.org/doc/libs/ lists 113 libraries as 1/24/2015. Fortunately, we don't require all of them!
Expected complete list -- Boost version: 1.45.0 -- Found the following Boost libraries:

### Code including boost
## iostreams

The boost::iostreams is currently used only in the binary analysis parts of ROSE, and only for its portable (Windows + Unix) implementation of memory mapping. But the default boost installation process may not install it due to some unmet dependence.
Code using iostreams
* util/sawyer/MappedBuffer.h:#include <boost/iostreams/device/mapped_file.hpp>

### Cannot find error

If you see errors about missing iostreams, you can
* Option 1: Configure ROSE without binary analysis support, rerun the configuration command you just used, but this time add the "--enable-binary-analysis=no" switch. this library should not bother you anymore.
* Option 2: install iostreams: need libbz2 and zlib to install or it will be be built.
** sudo apt-get install zlibc zlib1g zlib1g-dev libbz2-dev
** Still have iostreams installed without bz2 and zlib: when you compile boost and your system doesn't have all boost's prerequisites installed, you need to tell it that by adding -sNO_BZIP2=1 -sNO_ZLIB=1 to boost's configuration command line. I think "-sNO_COMPRESSION=1" works also.
More information
* http://www.boost.org/doc/libs/1_47_0/libs/iostreams/doc/index.html.

## filesystem

grep -r filesystem.hpp *
Example use src/util/support/FileHelper.h

### no member named generic_string

Related error messages
relevant code src/util/support/FileHelper.h

## thread

boost thread 1.45-1.47 cannot be installed with gcc 4.7 and after. Some patches are needed.

### code using boost thread

demo@ubuntu:~/rose-edg4x.git/src$ grep -r thread.hpp *

### xtime.hpp error TIME_UTC

from /home/demo/development/priv-rose-codethorn/src/frontend/SageIII/attachPreprocessingInfo.C:30:
/home/demo/development/install/gcc-4.4.7/boost-1.45.0/include/boost/thread/xtime.hpp:23: error: expected identifier before numeric constant
WORKAROUND: in file boost/thread/xtime.hpp WORKAROUND THAT DOES WORK FOR THREAD AND WAVE:
only undefine the C11 macro: (the following 3 lines are new, followed by the existing troublesome enum in the file)
PS: you will also find that people fixed it by renaming the variable. This leads to errors in some libs later. Therefore I used my above workaround.

### self disabled for gcc 4.7 and after

Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS
* I was lucky to even catch this message. It was buried in the earlier process of screen output and quickly disappeared. It would be more help to show this in the end when screen output is stopped!!
http://stackoverflow.com/questions/8297652/error-boost-disable-threads
GCC doesn't "disable" anything, Boost.Threads 1.47 failed to correctly detect thread support in the compiler, because the undocumented implementation detail that Boost relied on changed. This is also nothing to do with experimental vs release versions, the same applies to all versions of 4.7
To define 'threads' support,
GCC <= 4.6 defines _GLIBCXX__PTHREADS whereas GCC >= 4.7 defines _GLIBCXX_HAS_GTHREADS. So, in order to compile older Boosts using any GCC more recent than 4.6 you need the patch libstdcpp3.hpp.patch enclosed in that ticket. Another problem that could also prevent Boost on working with modern compiler is ticket 6940 (TIME_UTC has a special meanhing in C11, therefore Boost >= 1.50 use TIME_UTC_ instead)
patch for boost/config/stdlib/libstdcpp3.hpp