使用 Frama-Clang 插件时出错

Errors when using the Frama-Clang plugin

本文关键字:出错 插件 Frama-Clang 使用      更新时间:2023-10-16

鉴于插件 https://frama-c.com/frama-clang.html 被认为是在开发的"早期阶段",也许我现在不走运。但是想知道是否有其他人遇到过这样的问题:

navarre@navarre-t400:~/code/c$ frama-c max.cpp
[kernel] Parsing FRAMAC_SHARE/libc/__fc_builtin_for_normalization.i (no preprocessing)
[kernel] Parsing max.cpp (external front-end)
: CommandLine Error: Option 'asm-macro-max-nesting-depth' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
[kernel] user error: Failed to parse C++ file. See Clang messages for more information
[kernel] user error: stopping on file "max.cpp" that has errors.
[kernel] Frama-C aborted: invalid user input.

作为记录,max.cpp的内容如下:

int s(int i) {
return i;
}

任何帮助将不胜感激。甚至只是将我指向错误输出表明我看到的神秘"Clang 消息"!

编辑:我可能应该补充一点,我在 Ubuntu 上,并且有相当长的时间让构建工作,显然是由于 Ubuntu 的存储库与 PPA 中的 clang 3.9 冲突。我最终得到了插件来构建,现在我被困在这里。

编辑2:我能够编辑frama_Clang_register.ml的源代码以查看正在运行的命令。是这个:

framaCIRGen  -target i386-unknown-linux-gnu -D__FC_MACHDEP_X86_32 -std=c++11 -nostdinc -I /home/navarre/.opam/system/share/frama-c/frama-clang/libc++ -I /home/navarre/.opam/system/share/frama-c/libc -I /home/navarre/.opam/system/share/frama-c --stop-annot-error

所以现在的问题变成了"'framaCIRGen'有什么问题。首先,我注意到即使我只是运行framaCIRGen而不是其他任何东西,我也会收到令人反感的错误。有趣。

然后我注意到有问题的东西是(asm-macro-max-nesting-depth(不存在于framaCIRGen的源文件中,而是在编译的二进制文件中!

它也不在 cpp 的输出中,所以它一定是通过链接库进入的吗?

navarre@navarre-t400:~/Downloads/frama-clang-0.0.3$ cpp -std=c++11 ./FramaCIRGen.cpp -I/usr/lib/llvm-4.0/include   -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -fPIC -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS | grep asm-macro-max-nesting-depth | wc
0       0       0

编辑:

以下是 ./configure 的输出:

checking for frama-c-gui... no
checking for Makefile.config.in... yes
frama_clang... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for camlp4o... yes
checking for clang... no
checking for clang-3.8... no
checking for clang-3.9... no
checking for clang-4.0... clang-4.0
checking for clang++... no
checking for clang++-3.8... no
checking for clang++-3.9... no
checking for clang++-4.0... clang++-4.0
checking for llvm-config... no
checking for llvm-config-3.8... no
checking for llvm-config-3.9... no
checking for llvm-config-4.0... llvm-config-4.0
checking LLVM version... 4.0.1: Good
configure: frama_clang: yes
configure: creating ./config.status
config.status: creating ./Makefile.config

这是make的输出(环境变量VERBOSEMAKE=yes(。

Generating   .Makefile.plugin.generated
Generating   intermediate AST
Generating   top/Frama_Clang.mli
Ocamldep     ./.depend
Ocamlc       intermediate_format.cmi
Ocamlc       intermediate_format_parser.cmi
Ocamlc       intermediate_format_parser.cmo
Ocamlc       frama_Clang_option.cmi
Ocamlc       frama_Clang_option.cmo
Ocamlc       fclang_datatype.cmi
Ocamlc       fclang_datatype.cmo
Ocamlc       cxx_utils.cmi
Ocamlc       cxx_utils.cmo
Ocamlc       mangling.cmi
Ocamlc       mangling.cmo
Ocamlc       convert_env.cmi
Ocamlc       convert_env.cmo
Ocamlc       convert_acsl.cmi
Ocamlc       convert_acsl.cmo
Ocamlc       generate_spec.cmi
Ocamlc       generate_spec.cmo
Ocamlc       class.cmi
Ocamlc       class.cmo
Ocamlc       convert.cmi
Ocamlc       convert.cmo
Ocamlc       convert_link.cmi
Ocamlc       convert_link.cmo
Ocamlc       frama_Clang_register.cmi
Ocamlc       frama_Clang_register.cmo
Ocamlc       Frama_Clang.cmi
Generating   top/Frama_Clang.cmi
Packing      top/Frama_Clang.cmo
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     intermediate_format_parser.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     frama_Clang_option.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     fclang_datatype.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     cxx_utils.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     mangling.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     convert_env.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     convert_acsl.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     generate_spec.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     class.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     convert.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     convert_link.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Ocamlopt     frama_Clang_register.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Packing      top/Frama_Clang.cmx
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
Packing      top/Frama_Clang.cmxs
findlib: [WARNING] Interface Frama_Clang.cmi occurs in several directories: /home/navarre/.opam/system/lib/frama-c/plugins, .
make[1]: Entering directory `/home/navarre/Downloads/frama-clang-0.0.3'
Compiling    Clang_utils.cpp
Compiling    intermediate_format.c
Compiling    ACSLComment.cpp
Compiling    ACSLLogicType.cpp
Compiling    ACSLTermOrPredicate.cpp
Compiling    ACSLLoopAnnotation.cpp
Compiling    ACSLStatementAnnotation.cpp
Compiling    ACSLGlobalAnnotation.cpp
Compiling    ACSLCodeAnnotation.cpp
Compiling    ACSLFunctionContract.cpp
Compiling    ACSLComponent.cpp
Compiling    ACSLLexer.cpp
Compiling    ACSLParser.cpp
Compiling    ACSLToken.cpp
Compiling    DescentParse.cpp
Compiling    RTTITable.cpp
Compiling    VisitTable.cpp
Compiling    ClangVisitor.cpp
Compiling    FramaCIRGen.cpp
Linking      bin/framaCIRGen
make[1]: Leaving directory `/home/navarre/Downloads/frama-clang-0.0.3'

这是评论中建议的调试标志:

navarre@navarre-t400:~/code/c$ frama-c max.cpp -fclang-msg-key clang
[kernel] Parsing FRAMAC_SHARE/libc/__fc_builtin_for_normalization.i (no preprocessing)
[kernel] Parsing max.cpp (external front-end)
[fclang:clang] Clang command is framaCIRGen  -target i386-unknown-linux-gnu -D__FC_MACHDEP_X86_32 -std=c++11 -nostdinc -I /home/navarre/.opam/system/share/frama-c/frama-clang/libc++ -I /home/navarre/.opam/system/share/frama-c/libc -I /home/navarre/.opam/system/share/frama-c --stop-annot-error -v  max.cpp -o /tmp/clang_ast8f7187ast
: CommandLine Error: Option 'asm-macro-max-nesting-depth' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
framaCIRGen  -target i386-unknown-linux-gnu -D__FC_MACHDEP_X86_32 -std=c++11 -nostdinc -I /home/navarre/.opam/system/share/frama-c/frama-clang/libc++ -I /home/navarre/.opam/system/share/frama-c/libc -I /home/navarre/.opam/system/share/frama-c --stop-annot-error -v  max.cpp -o /tmp/clang_ast8f7187ast[kernel] user error: Failed to parse C++ file. See Clang messages for more information
[kernel] user error: stopping on file "max.cpp" that has errors.
[kernel] Frama-C aborted: invalid user input.
[extlib] Debug: not removing file /tmp/clang_ast8f7187ast

似乎问题在于我使用的 Ubuntu 软件包的年龄。我能够在另一台运行 16.04 的计算机上成功安装(我的有 14.04(。

我已经升级了我的电脑,现在期待更多的成功。