ROSE 编译器框架/cmake
基于 EDG 4.x 的 ROSE 也支持 cmake 构建系统。
以下是配置 ROSE 的 CMake 命令
需要
- 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"
之后,只需运行 "make" 然后 "ctest"。
一个真实的例子
- mkdir cmakebuild; cd cmakebuild
- CC=gcc CXX=g++ cmake ../rose-edg4x.git/ -DBOOST_ROOT=/home/demo/opt/boost_1.45.0_inst -Denable-cuda:BOOL=off -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:PATH="$(pwd)/../rose-install"
很难阅读屏幕输出以找到问题所在。
- 有些是作为环境检测的一部分发生的内部错误消息
- 真正的错误消息被埋在中间。在第一个错误发生后,该过程继续并打印出大量其他信息。
- 在检查 /home/demo/cmakebuild/CMakeFiles/CMakeError.log 时,其内容被预期编译失败的错误消息污染(无法编译的 cpp 文件)。
这会让用户难以找到阻止配置过程的真正错误。
一个例子
Generating /home/demo/cmakebuild/include-staging/gcc_HEADERS/rose_edg_required_macros_and_functions.h processing header file directory /usr/lib/gcc/x86_64-linux-gnu/4.8/include to be mapped to /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs1 /usr/lib/gcc/x86_64-linux-gnu/4.8/include needs 0 change(s) /usr/lib/gcc/x86_64-linux-gnu/4.8/include does not need any changes processing header file directory /usr/local/include to be mapped to /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs2 /usr/local/include needs 0 change(s) /usr/local/include does not need any changes processing header file directory /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed to be mapped to /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs3 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed needs 0 change(s) /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed does not need any changes processing header file directory /usr/include/x86_64-linux-gnu to be mapped to /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs4 /usr/include/x86_64-linux-gnu needs 1 change(s) /usr/include/x86_64-linux-gnu needs to be copied and modified Done copying Processing c++config header file (removing use of visibility attribute) at /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs4/./c++/4.8/bits/c++config.h Verified "/usr/include/sys/cdefs.h" exists ... (referenced by ROSE specific "sys/cdefs.h" header file) system_headers_directory = /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs should be used instead of target_parent_dir = Copying /home/demo/rose-edg4x.git/config/rose_specific_cdefs.h to /home/demo/cmakebuild/include-staging/gcc_HEADERS/hdrs/sys to fix __gconv_info incomplete definition problem ... StatusRunning tests ... -- checking for module 'libxml-2.0' -- found libxml-2.0, version 2.9.1 -- xmllint program not found. Install it if you want validate generated doc file. -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so -- META_EXE_LOC = /home/demo/cmakebuild/bin/CxxGrammarMetaProgram -- Smaller Generated Files Disabled -- >>>>>>>>>>>>>>>>>>>>>> smallerGeneratedFiles : OFF Commented out use of OpenAnalysis in Windows. -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") -- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.2.50") -- Found Perl: /usr/bin/perl (found version "5.18.2") StatusFinished ... -- Configuring incomplete, errors occurred! See also "/home/demo/cmakebuild/CMakeFiles/CMakeOutput.log". See also "/home/demo/cmakebuild/CMakeFiles/CMakeError.log".
检查 CMakeFiles/CMakeError.log 获取详细信息。屏幕输出有时没有帮助。
更多信息请参见ROSE 编译器框架/boost
可能由于缺少依赖项而未默认安装
解决方案
- boost iostreams: 安装 libbz2
- boost_thread 复制虚拟文件以解决此问题
预期完整的列表 - Boost 版本:1.45.0 - 找到以下 Boost 库
-- date_time -- filesystem -- iostreams -- program_options -- regex -- system -- wave -- thread
https://boost.ac.cn/doc/libs/ 列出了 113 个库,截至 2015 年 1 月 24 日
文件系统
412795ae (Stanislav Negara 2011-07-15 15:13:34 -0700 16) #include <boost/filesystem.hpp> 412795ae (Stanislav Negara 2011-07-15 15:13:34 -0700 17) 412795ae (Stanislav Negara 2011-07-15 15:13:34 -0700 18) #include <string>
CMake 错误,位于 cmake/DownloadEDG.cmake:32 (消息)
ROSE only supports GCC versions 4.0 to 4.4.
<gcc -dumpversion> reported 4.8
调用堆栈(最近的调用优先)
CMakeLists.txt:352 (include)
这没有帮助!!
CC="gcc-4.4" CXX="g++-4.4" cmake ../rose-edg4x.git/ -DBOOST_ROOT=/home/demo/opt/boost_1.45.0_inst -Denable-cuda:BOOL=off -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:PATH="$(pwd)/../rose-install"
cmake/DownloadEDG.cmake
set(min_supported "4.4") set(max_supported "4.8")
--- a/cmake/DownloadEDG.cmake +++ b/cmake/DownloadEDG.cmake @@ -20,8 +20,8 @@ endif() # Detect compiler by asking GCC what version it is set(compiler "") -set(min_supported "4.0") -set(max_supported "4.4") +set(min_supported "4.4") +set(max_supported "4.8") execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_version) # strip patch version; we only care about major & minor @@ -33,16 +33,16 @@ if(GCC_version VERSION_GREATER max_supported OR "ROSE only supports GCC versions ${min_supported} to ${max_supported}.\n" "<gcc -dumpversion> reported ${GCC_version}") endif() -if(GCC_version VERSION_EQUAL 4.4) +if(GCC_version VERSION_EQUAL 4.8) + set(compiler "GNU-4.8") +elseif(GCC_version VERSION_EQUAL 4.7) + set(compiler "GNU-4.7") +elseif(GCC_version VERSION_EQUAL 4.6) + set(compiler "GNU-4.6") +elseif(GCC_version VERSION_EQUAL 4.5) + set(compiler "GNU-4.5") +elseif(GCC_version VERSION_EQUAL 4.4) set(compiler "GNU-4.4") -elseif(GCC_version VERSION_EQUAL 4.3) - set(compiler "GNU-4.3") -elseif(GCC_version VERSION_EQUAL 4.2) - set(compiler "GNU-4.2") -elseif(GCC_version VERSION_EQUAL 4.1) - set(compiler "GNU-4.1") -elseif(GCC_version VERSION_EQUAL 4.0) - set(compiler "GNU-4.0") endif() if(compiler STREQUAL "") message(FATAL_ERROR
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: JAVA_JVM_LIBRARY (ADVANCED) linked by target "ROSE_DLL" in directory /home/demo/rose-edg4x.git/src linked by target "roseFortran" in directory /home/demo/rose-edg4x.git/src/frontend/OpenFortranParser_SAGE_Connection
解决方案 export JAVA_HOME=/home/demo/opt/jdk1.8.0_25/
sudo apt-get install zlib1g-dev
LIBXML2_INCLUDE_DIR (高级)
sudo apt-get install libxml2-dev
mysql.h //
/home/demo/cmakebuild/CMakeFiles/CMakeTmp/src.cxx:1:19: fatal error: mysql.h: No such file or directory #include <mysql.h> ^ compilation terminated. make[1]: *** [CMakeFiles/cmTryCompileExec47651848.dir/src.cxx.o] Error 1 make[1]: Leaving directory `/home/demo/cmakebuild/CMakeFiles/CMakeTmp' make: *** [cmTryCompileExec47651848/fast] Error 2
mysql_config --include -I/usr/include/mysql demo@ubuntu:~/opt/boost_1.45.0_inst/lib$ ls /usr/include/mysql decimal.h my_attribute.h my_global.h mysqld_ername.h my_sys.h
错误:找不到 "/usr/include/sys/cdefs.h" 系统头文件 ...(由 ROSE 特定的 "sys/cdefs.h" 头文件引用)
config/create_system_headers
# DQ (6/27/2006): We really should verify that "/usr/include/sys/cdefs.h" exists since we reference it explicitly # in the ROSE specific generated "sys/cdefs.h" header file. if [ -f /usr/include/sys/cdefs.h ] then echo "Verified \"/usr/include/sys/cdefs.h\" exists ... (referenced by ROSE specific \"sys/cdefs.h\" header file)" else echo "ERROR: Could not find \"/usr/include/sys/cdefs.h\" system header file ... (referenced by ROSE specific \"sys/cdefs.h\" header file)" exit 5 fi
demo@ubuntu:~/cmakebuild$ locate cdefs.h ...
/usr/include/x86_64-linux-gnu/sys/cdefs.h
解决方法
- sudo ln -s /usr/include/x86_64-linux-gnu/sys /usr/include/sys
sudo apt-get install zlib1g-dev
这些错误是用户应该关注的错误吗?还是只是用于检测事物的内部探测?
出现在 /home/demo/cmakebuild/CMakeFiles/CMakeError.log 中,并让用户感到困惑。
Performing C++ SOURCE FILE Test SIZEOF_WCHAR_T_IS_2 failed with the following output: Change Dir: /home/demo/cmakebuild/CMakeFiles/CMakeTmp Run Build Command:/usr/bin/make "cmTryCompileExec3342910900/fast" /usr/bin/make -f CMakeFiles/cmTryCompileExec3342910900.dir/build.make CMakeFiles/cmTryCompileExec3342910900.dir/build make[IPX8 under IEC standard 60529.]: Entering directory `/home/demo/cmakebuild/CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /home/demo/cmakebuild/CMakeFiles/CMakeTmp/CMakeFiles 1 Building CXX object CMakeFiles/cmTryCompileExec3342910900.dir/src.cxx.o /usr/bin/g++ -fexceptions -DHAVE_CONFIG_H -fPIC -DSIZEOF_WCHAR_T_IS_2 -o CMakeFiles/cmTryCompileExec3342910900.dir/src.cxx.o -c /home/demo/cmakebuild/CMakeFiles/CMakeTmp/src.cxx /home/demo/cmakebuild/CMakeFiles/CMakeTmp/src.cxx:2:41: error: size of array ‘i’ is negative int i[ ( sizeof(wchar_t)==2 ? 1 : -1 ) ]; ^ make[1]: Leaving directory `/home/demo/cmakebuild/CMakeFiles/CMakeTmp' make[1]: *** [CMakeFiles/cmTryCompileExec3342910900.dir/src.cxx.o] Error 1 make: *** [cmTryCompileExec3342910900/fast] Error 2 Source file was: int i[ ( sizeof(wchar_t)==2 ? 1 : -1 ) ]; int main(){return 0;}
- //Ivan Cabral°
2603:8080:b005:e996:4f0:bbc8:a101:cb49