如何在Numpy库上运行Facebook?

发布于 2025-02-10 20:07:09 字数 890 浏览 0 评论 0原文

我想在Numpy库上运行以检测其弱点。当我运行以下命令时:

infer run -- gcc -c /numpy/numpy/numpy/core/src/multiarrayabstractdtypes.c

它会引发以下错误:

Capturing in make/cc mode...
abstractdtypes.c:5:10: fatal error: 'Python.h' file not found
#include <Python.h>
         ^~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
    /opt/infer-linux64-v1.0.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-9
    @/media/nimashiri/DATA/vsprojects/ICSE23/ml_repos_cloned/numpy/numpy/numpy/core/src/multiarray/infer-out/tmp/clang_command_.tmp.a9d22f.txt
  ++Contents of '/media/nimashiri/DATA/vsprojects/ICSE23/ml_repos_cloned/numpy/numpy/numpy/core/src/multiarray/infer-out/tmp/clang_command_.tmp.a9d22f.txt':
    "-cc1" "-load"...

如何在具有特殊编译器(例如Numpy或Tensorflow)的项目中针对各个源文件运行。这些编译器不明确使用Make或Cmake。

谢谢。

I want to run Infer on numpy library to detect its weaknesses. When I run the following command:

infer run -- gcc -c /numpy/numpy/numpy/core/src/multiarrayabstractdtypes.c

it throws the following error:

Capturing in make/cc mode...
abstractdtypes.c:5:10: fatal error: 'Python.h' file not found
#include <Python.h>
         ^~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
    /opt/infer-linux64-v1.0.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-9
    @/media/nimashiri/DATA/vsprojects/ICSE23/ml_repos_cloned/numpy/numpy/numpy/core/src/multiarray/infer-out/tmp/clang_command_.tmp.a9d22f.txt
  ++Contents of '/media/nimashiri/DATA/vsprojects/ICSE23/ml_repos_cloned/numpy/numpy/numpy/core/src/multiarray/infer-out/tmp/clang_command_.tmp.a9d22f.txt':
    "-cc1" "-load"...

How can I run infer against individual source files in project having special compilers, e.g. numpy or tensorflow. These compilers do not use make or cmake explicitly.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妖妓 2025-02-17 20:07:09

我想出了如何做到这一点。这些是要遵循的步骤:

  1. 编译和构建项目,例如,当您想从源构建时,对于Numpy,您必须运行python setup.py build_ext-inplace-inplace-place

  2. 编译项目时,在终端中,您可以看到编译日志。您必须在编译日志中搜索编译命令。例如,当从源中编译numpy时,您可以看到类似的内容:

-Inumpy/core/include -Inumpy/core/include/numpy -Ibuild/src.linux-x86_64-3.8/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c 
  1. 以前的命令是编译所需的标头文件的路径。请注意,以前的标头文件是numpy/andural/src/distributions/logfactorial.c。您必须使用某些解析器手动或自动找到相应的文件。

  2. 在此步骤中,您需要运行capture命令如下:

infer capture -- gcc Inumpy/core/include -Inumpy/core/include/numpy -Ibuild/src.linux-x86_64-3.8/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/random/src/distributions/logfactorial.c
  1. 上一个命令将捕获汇编命令,现在我们需要使用Analyaze命令分析可能的错误,如下:
infer analyze -- gcc Inumpy/core/include -Inumpy/core/include/numpy -Ibuild/src.linux-x86_64-3.8/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/random/src/distributions/logfactorial.c

I figured out how to do that. These are steps to follow:

  1. Compile and build the project, e.g. for numpy when you want to build from source, you have to run python setup.py build_ext --inplace.

  2. When you compile the project, in the terminal, you can see the compilation log. You have to search for compilation commands in the compilation log. For example, when compiling numpy from source, you can see something like this:

-Inumpy/core/include -Inumpy/core/include/numpy -Ibuild/src.linux-x86_64-3.8/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c 
  1. The previous commands are path to header files needed for compilation. Please note that the previous header files are for numpy/random/src/distributions/logfactorial.c. You have to find the corresponding files either manually or automatically using some parsers.

  2. In this step, you need to run capture command as follows:

infer capture -- gcc Inumpy/core/include -Inumpy/core/include/numpy -Ibuild/src.linux-x86_64-3.8/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/random/src/distributions/logfactorial.c
  1. The previous command will capture compilation commands, now we need to analyze the file for possible errors using analyze command as follows:
infer analyze -- gcc Inumpy/core/include -Inumpy/core/include/numpy -Ibuild/src.linux-x86_64-3.8/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/random/src/distributions/logfactorial.c
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文