gpt4 book ai didi

c++ - 使用 Frama-Clang 插件时出错

转载 作者:行者123 更新时间:2023-11-30 05:10:32 32 4
gpt4 key购买 nike

鉴于插件 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 的 repos 与 PPA 中的 clang 3.9 发生冲突。我最终得到了要构建的插件,现在我被困在这里了。

EDIT2:我能够编辑 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)的计算机上成功安装。

我已经升级了我的电脑,希望现在能取得更大的成功。

关于c++ - 使用 Frama-Clang 插件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45647503/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com