已合并
【PR】【fix】修复 binary_enumerate_functions 样例重复执行构建失败 #4771
陈天銮创建于 27 天前
【PR】【fix】修复 binary_enumerate_functions 样例重复执行构建失败 #4771
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 陈天銮 的贡献)27 天前 添加了label:enhancement
27 天前 关联了issue:binary_enumerate_functions 重复执行时因复用构建产物失败
atomgit-bot
27 天前 评论:
27 天前 评论:
变更摘要
本 PR 修复 example/2_advanced_features/kernel/2_binary_enumerate_functions 样例在不清空 build 目录的情况下重复执行 run.sh 导致的构建失败问题,并同步精简脚本结构。核心改动是在构建前新增 rm -rf "${BUILD_DIR}" "${OUTPUT_DIR}",保证每次运行都从干净目录构建;同时引入统一的 die() 错误处理函数、重构 CANN 环境解析逻辑,并新增 ascendc.cmake 存在性检查与环境变量信息输出。本次仅修改 run.sh 一个文件。
主要改动
- 核心修复:每次构建前清理旧产物: 在
cmake构建前新增rm -rf "${BUILD_DIR}" "${OUTPUT_DIR}",使重复执行run.sh时始终从干净目录构建,修复样例无法稳定重复运行的问题。 - 新增统一的
die()错误处理函数: 定义die() { echo "[ERROR] $*" >&2; exit 1; },统一[ERROR]前缀并输出到 stderr,替换了原先 4 处手写的echo + exit 1(包括内核二进制与宿主可执行文件缺失检查)。 - 重构 CANN 环境解析逻辑: 将原先 if/elif/else 三分支嵌套改为"仅在
ASCEND_INSTALL_PATH/ASCEND_HOME_PATH均缺失时才自动探测resolve_cann_env.sh",并通过统一export归一化ASCEND_INSTALL_PATH/ASCEND_HOME_PATH,消除了重复代码;自动探测失败时改用die报错。 - 新增
ascendc.cmake存在性校验: 构建前检查${ASCENDC_CMAKE_DIR:-}/ascendc.cmake是否存在,缺失时通过die提示需先安装或 source CANN Toolkit。 - 新增环境信息输出并格式化
LD_LIBRARY_PATH: 增加[INFO]日志打印ASCEND_HOME_PATH、SOC_VERSION、ASCENDC_CMAKE_DIR,并将LD_LIBRARY_PATH的export改写为多行拼接形式。


不准确?
atomgit-bot
27 天前 评论:
27 天前 评论:
27 天前 添加了label:cann-cla/yes
CANN-robot
27 天前 评论:
27 天前 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| example | ✅ 卢煜坤, dragon_q (2/2) | ✅ 卢煜坤, dragon_q (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
weixin_51634168, thanks for your pull request. All authors of the commits have signed the CLA. 👍


CANN-robot
27 天前 评论:
27 天前 评论:
27 天前 将SongAnyin,zhaozhixuan,wda1991,wangtao43,zhangpengpeng8,vaceciliachen,yanmingxiang,weiying_101,turing_yhy,Henry_ascend,Reyn52166,dragon_q,Turing_JasonWen,phy-zhao,WangHuiH,Axiaolei,ykl999,sunnana_004434229,YzQnWyx,houyanbao,wangluyao17,zhou-wuxiao,tingwood,liubin1986设为评审人
27 天前 将SongAnyin,zhaozhixuan,wda1991,wangtao43,zhangpengpeng8,vaceciliachen,yanmingxiang,weiying_101,turing_yhy,Henry_ascend,Reyn52166,dragon_q,Turing_JasonWen,phy-zhao,WangHuiH,Axiaolei,ykl999,sunnana_004434229,YzQnWyx,houyanbao,wangluyao17,zhou-wuxiao,tingwood,liubin1986设为评审人
27 天前 将SongAnyin,zhaozhixuan,wda1991,wangtao43,zhangpengpeng8,vaceciliachen,yanmingxiang,weiying_101,turing_yhy,Henry_ascend,Reyn52166,dragon_q,Turing_JasonWen,phy-zhao,WangHuiH,Axiaolei,ykl999,sunnana_004434229,YzQnWyx,houyanbao,wangluyao17,zhou-wuxiao,liubin1986设为审查人
27 天前 将SongAnyin,zhaozhixuan,wda1991,wangtao43,zhangpengpeng8,vaceciliachen,yanmingxiang,weiying_101,turing_yhy,Henry_ascend,Reyn52166,dragon_q,Turing_JasonWen,phy-zhao,WangHuiH,Axiaolei,ykl999,sunnana_004434229,YzQnWyx,houyanbao,wangluyao17,zhou-wuxiao,liubin1986设为审查人
27 天前 修改了pull request 的描述
27 天前 修改了pull request 的描述
陈天銮
27 天前 评论:
27 天前 评论:
compile


27 天前 预合并成功(commit_id: 15028ab31988b7f5690c5fcbd70d418829ce7c85)
CANN-robot
27 天前 评论:
27 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


27 天前 添加了label:ci-pipeline-running
此处折叠了8条事件消息 查看更多
27 天前 删除了label:ci-pipeline-passed
CANN-robot
27 天前 评论:
27 天前 评论:
ykl999
27 天前 评论:
27 天前 评论:
/approve
/lgtm


27 天前 添加了label:approved
27 天前 添加了label:lgtm
陈天銮
27 天前 评论:
27 天前 评论:
compile


27 天前 预合并成功(commit_id: 634a5297fc5370f3fd40e6b75a6256c115279f27)
CANN-robot
27 天前 评论:
27 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


27 天前 添加了label:ci-pipeline-running
27 天前 删除了label:ci-pipeline-running
27 天前 添加了label:ci-pipeline-passed
27 天前 合入了pull request
【PR】【fix】修复 binary_enumerate_functions 样例重复执行构建失败并精简 run.sh
关联 Issue
https://gitcode.com/cann/runtime/issues/938
问题背景
example/2_advanced_features/kernel/2_binary_enumerate_functions在干净构建目录下首次执行成功,但不清理build目录再次执行run.sh时构建失败,样例无法稳定重复运行。修改内容
仅修改
example/2_advanced_features/kernel/2_binary_enumerate_functions/run.sh:构建前增加
rm -rf "${BUILD_DIR}" "${OUTPUT_DIR}",每次运行从干净目录构建。