rose-compiler / rose

Developed at Lawrence Livermore National Laboratory (LLNL), ROSE is an open source compiler infrastructure to build source-to-source program transformation and analysis tools for large-scale C (C89 and C98), C++ (C++98 and C++11), UPC, Fortran (77/95/2003), OpenMP, Java, Python and PHP applications.
http://rosecompiler.org
Other
582 stars 133 forks source link

Apt package doesn't have binary analysis enabled #182

Open mattfj10 opened 2 years ago

mattfj10 commented 2 years ago

Hi,

I'm currently running on Ubuntu 18.04 and am trying to use Rose to do some binary analysis. Below is my code:

#include <rose.h>
#include <Rose/BinaryAnalysis/Partitioner2/Engine.h>
#include <AsmUnparser.h>
int main(int argc, char * argv []) {
  ROSE_INITIALIZE;
  Rose::BinaryAnalysis::Partitioner2::Engine engine;
  SgAsmBlock *gblock = engine.frontend(argc, argv, purpose, description);
}

However, when I try to build it I get the following error:

test_code/binary_analysis.cpp: In function ‘int main(int, char**)’:
test_code/binary_analysis.cpp:6:0: error: ‘Rose::BinaryAnalysis’ has not been declared
   Rose::BinaryAnalysis::Partitioner2::Engine engine;

test_code/binary_analysis.cpp:7:0: error: ‘SgAsmBlock’ was not declared in this scope
   SgAsmBlock *gblock = engine.frontend(argc, argv, purpose, description);

test_code/binary_analysis.cpp:7:0: note: suggested alternative: ‘SgBasicBlock’
test_code/binary_analysis.cpp:7:0: error: ‘gblock’ was not declared in this scope
test_code/binary_analysis.cpp:7:0: note: suggested alternative: ‘clock’
test_code/binary_analysis.cpp:7:0: error: ‘engine’ was not declared in this scope
test_code/binary_analysis.cpp:7:0: note: suggested alternative: ‘getline’
test_code/binary_analysis.cpp:7:0: error: ‘purpose’ was not declared in this scope
test_code/binary_analysis.cpp:7:0: note: suggested alternative: ‘pclose’
test_code/binary_analysis.cpp:7:0: error: ‘description’ was not declared in this scope

I'm using the appropriate flags based on the documentation and I've been able to do source to source translation code in ROSE properly, but it seems to be unable to compile whenever I try to use code from the binary analysis part of ROSE. According to the installation instructions for Ubuntu the apt package should have binaries set for one of the enabled languages, so I'm not sure why it doesn't seem to think that none of the library has been declared.

matzke1 commented 2 years ago

You can ask many ROSE tools how ROSE was configured and whether binary analysis was enabled. I don't use the apt package, but here's what things look like on my machine where I compiled ROSE from source code:

$ rose-config --version-long ROSE 0.11.64.3 (configured Thu Jan 13 09:59:39 2022 -0500)   --- logic assertions:           enabled   --- full optimization:          disabled   --- boost library:              1.78.0 (/home/matzke/.spock/var/installed/wisconsin/d73f47d2/boost-nopy)   --- readline library:           unused   --- C/C++ analysis:             disabled   --- Fortran analysis:           disabled   --- binary analysis:            enabled   ---   object serialization:     enabled   ---   ARM AArch32 (A32/T32):    enabled   ---   ARM AArch64 (A64):        enabled   ---   MIPS (be and le):         enabled   ---   Motorola m68k (coldfire): enabled   ---   PowerPC (be and le):      enabled   ---   Intel x86 (i386):         enabled   ---   Intel x86-64 (amd64):     enabled   ---   concolic testing:         enabled   ---   capstone library:         4.0.2   ---   dlib library:             19.19.0   ---   gcrypt library:           1.8.5   ---   magic numbers library:    unused   ---   pqxx library:             6.4.6   ---   sqilte library:           3.31.1   ---   yaml library:             unknown version   ---   z3 library:               4.8.12.0 (/home/matzke/.spock/var/installed/wisconsin/01f8f5ec/z3/bin/z3)   --- Ada analysis:               disabled   --- C# analysis:                disabled   --- COBOL analysis:             disabled   --- CUDA analysis:              disabled   --- Java analysis:              disabled   --- Jovial analysis:            disabled   --- Matlab analysis:            disabled   --- OFP analysis:               disabled   --- OpenCL analysis:            disabled   --- PHP analysis:               disabled   --- Python analysis:            disabled

--Robb

mattfj10 commented 2 years ago
$ rose-config --version-long
ROSE (version: 0.11.46.0.0)
  --- using EDG C/C++ front-end version: edg-5.0
  --- using OFP Fortran parser version: unknown (OFP is disabled)
  --- using Boost version: 1.65.1 (/usr)
  --- using backend C compiler: gcc-7 version: 7.4
  --- using backend C compiler path (as specified at configure time): gcc-7
  --- using backend C++ compiler: g++-7 version: 7.4
  --- using backend C++ compiler path (as specified at configure time): g++-7
  --- using original build tree path: /root/mount/rose-build
  --- using instalation path: /usr/rose
  --- using GNU readline version: unknown (readline is disabled)
  --- using libmagic version: unknown (libmagic is disabled)
  --- using yaml-cpp version: unknown (yaml-cpp is disabled)
  --- using lib-yices version: unknown (libyices is disabled)
  --- binary analysis is disabled

It would seem binary analysis is in fact disabled. That's unfortunate as the documentation for installation via apt claims binary analysis is enabled for the package (which I assume also means all the option dependencies for it are installed to, which also does not seem to be the case). That's a shame because I was trying to avoid building from source because the dependencies for binary analysis seem like a pain to install and set up.

pinnown commented 2 years ago

The page for apt package installation should have said that binary support is enabled for Ubuntu 20.04 and has been corrected.

The default boost on Ubuntu 18.04 is incompatible with ROSE so a custom boost must be used and installation of ROSE must be done from source. See the instruction for building ROSE from source and there is a note about building binary support at the bottom.