---
title: BC文件生成
description: "BC文件 用于内存一致性检查和向量化检查。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevps/development/affinityanalyzer/KunpengDevKitCli_0043.html
sourcePath: /source/zh/kunpengdevps/development/affinityanalyzer/KunpengDevKitCli_0043.html
indexId: a86d2769654b5f591b27ef1ae12222322d0c8d62316f81d753cb97b8494b67d079
---
# BC文件生成

BC文件 用于内存一致性检查和向量化检查。

#### 命令功能

通过编译源码文件生成对应的BC文件。

用于生成BC文件的源码文件需要确保可以在本地使用提供的编译命令编译通过。


#### 命令格式

```
devkit advisor bc-gen [-h | --help] {-c COMMAND | --command COMMAND} [-o OUTPUT_PATH | --output OUTPUT_PATH] [-l {0,1,2,3} | --log-level {0,1,2,3}] [--set-timeout TIMEOUT] [-t THREADS | --thread THREADS]
```


#### 参数说明


**表1 参数说明**

| 参数 | 参数选项 | 参数说明 |
| --- | --- | --- |
| \-h/\-\-help | \- | 可选参数，获取帮助信息。 |
| \-c/\-\-command | \- | 必选参数，源码构建命令。在服务器中正常执行的构建命令，若存在多个构建命令需使用英文分号分隔并用英文单引号或双引号包裹；命令中如有空格，也需要用英文单引号或双引号包裹。 例如："mkdir build;cd build;cmake ..;make"。 说明： 命令行工具源码构建命令不支持设置变量和export环境变量。 例如： "CFLAGS='\-O0 \-g';make"或"export CFLAGS='\-O0 \-g';make" |
| \-o/\-\-output | \- | 可选参数，生成BC文件的存放路径，需要有写权限。报告默认存放在当前路径下，名称默认为“模块名称\_时间戳”。 |
| \-l/\-\-log\-level | 0/1/2/3 | 可选参数，设置日志级别，默认为1。 0：日志级别为DEBUG。 1：日志级别为INFO。 2：日志级别为WARNING。 3：日志级别为ERROR。 |
| \-\-set\-timeout | \- | 可选参数，任务超时时间，单位为分钟，若执行时间超过超时时间则退出执行。默认无超时时间，任务将持续执行直到结束。 |
| \-t/\-\-thread | \- | 可选参数，编译BC文件的线程数，默认线程数为当前环境CPU总数的一半。 |


#### 使用示例

执行以下命令，生成BC文件。

此处以扫描“/home/test”下源码文件，编译命令为cmake .、make，BC文件保存在“/home/test/bc_files”下为例，请根据实际情况进行修改。

```
cd /home/test && cmake .
devkit advisor bc-gen -c make -o /home/test/bc_files
```

返回信息如下，并输出报告。

```
Executing bc gen task, please wait...
Current progress: ###### [20%]
Start to get the compile database
Current progress: ################ [50%]
Start to generate the BC files
Current progress: ################################# [100%]
Configuration:
Generate BC files path: /home/test/bc_files
Compile command: make
Threads: The threads are not set, using the half number of cores.
Task Timeout Interval: The timeout period is not set.
Log level: info
Summary:
Scanned all source files, there are 5 linked BC files and 5 object BC files generated.
For the detail information, please check:
Output path of linked BC files: /home/test/bc_files/bc-gen_20250408112730_d397/bin
Output path of object BC files: /home/test/bc_files/bc-gen_20250408112730_d397/object
There are 3 linked BC files fail to be generated.
For the causes of the failure to generate all the BC files and their intermediates, please check:
Log path: /
install_path
/advisor/logs/affinity/affinity.log
```

- 若BC文件生成失败，请到“/current_path/bc_warning.json”、“/install_path/advisor/logs/affinity/affinity.log”路径下查看报错信息，获取失败原因。部分报错修改请参见《毕昇编译器 用户指南》中的  兼容性说明(https://www.hikunpeng.com/document/detail/zh/kunpengdevps/compilation/ug-bisheng/kunpengbisheng_06_0027.html)
。
- current_path指当前所在路径，install_path指工具安装目录。
