已合并
【PR】【fix】修复 binary_enumerate_functions 样例重复执行构建失败 #4771
陈天銮创建于 27 天前
【PR】【fix】修复 binary_enumerate_functions 样例重复执行构建失败 #4771
已合并
陈天銮创建于 27 天前
陈天銮
陈天銮
27 天前

【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:

  1. 修复重复执行失败
    构建前增加 rm -rf "${BUILD_DIR}" "${OUTPUT_DIR}",每次运行从干净目录构建。
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 陈天銮 的贡献)
陈天銮陈天銮
27 天前 添加了label:enhancement
陈天銮陈天銮
27 天前 创建了 pull request,commit 23c467de
陈天銮陈天銮
27 天前 关联了issue:binary_enumerate_functions 重复执行时因复用构建产物失败
atomgit-bot
atomgit-bot
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 改写为多行拼接形式。
likedislike
不准确?
atomgit-bot
atomgit-bot
27 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
27 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
CANN-robot
CANN-robot成员
27 天前 评论:

CLA Signature Pass

weixin_51634168, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
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设为评审人
CANN-robotCANN-robot成员
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 天前 评论:

compile

likedislike
陈天銮陈天銮
27 天前 预合并成功(commit_id: 15028ab31988b7f5690c5fcbd70d418829ce7c85)
CANN-robot
CANN-robot成员
27 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
27 天前 添加了label:ci-pipeline-running
此处折叠了8条事件消息 查看更多
CANN-robotCANN-robot成员
27 天前 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
27 天前 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
ykl999
ykl999成员
27 天前 评论:

/approve
/lgtm

likedislike
CANN-robotCANN-robot成员
27 天前 添加了label:approved
强龙成员
27 天前 评论:

/approve
/lgtm

likedislike
CANN-robotCANN-robot成员
27 天前 添加了label:lgtm
陈天銮
陈天銮
27 天前 评论:

compile

likedislike
陈天銮陈天銮
27 天前 预合并成功(commit_id: 634a5297fc5370f3fd40e6b75a6256c115279f27)
CANN-robot
CANN-robot成员
27 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
27 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
27 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
27 天前 添加了label:ci-pipeline-passed
CANN-robotCANN-robot成员
27 天前 合入了pull request