---
title: BC文件生成
description: "BC文件用于内存一致性检查和向量化检查。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/devkit_24_t50/cliuserguide/KunpengDevKitCli_0043.html
sourcePath: /source/zh/kunpengdevkithistory/devkit_24_t50/cliuserguide/KunpengDevKitCli_0043.html
indexId: 3395b4b3395a6740a75c222272989d5da3863f7a74a026c51412195ec4b1605085
---
# 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 | command | 必选参数，源码的构建命令。 例如：make all。 说明： 命令行工具源码构建命令不支持设置变量和export环境变量。 例如："CFLAGS='\-O0 \-g';make"或"export CFLAGS='\-O0 \-g';make"。 |
| \-o/\-\-output | output\_path | 生成BC文件的存放路径，需要有写权限。报告默认存放在当前路径下，名称默认为“模块名称\_时间戳”。 |
| \-\-set\-timeout | time | 任务超时时间，单位为分钟，若执行时间超过超时时间则退出执行。默认无超时时间，任务将持续执行直到结束。 |
| \-l/\-\-log\-level | 0/1/2/3 | 设置日志级别，默认为1。 0：日志级别为DEBUG。 1：日志级别为INFO。 2：日志级别为WARNING。 3：日志级别为ERROR。 |
| \-t/\-\-threads | thread\_num | 编译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 static memory consistency check 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 is 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 87 bc files generated.
For the detail information, please check:
Output path of linked bc files: /home/test/bc_files/bc-gen_20250407014611_6128/bin
Output path of object bc files: /home/test/bc_files/bc-gen_20250407014611_6128/object
For the causes of the failure to generate the bc files of some files, please check:
Log path: /
install_path
/advisor/logs/affinity/affinity.log
Warning and error messages when generate the bc files: /
current_path
/bc_warning.json
```

- 若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指工具安装目录。
