Merged
[feat] 补充valgrind #14047
丛吉钰Add on 11 days ago
[feat] 补充valgrind #14047
Merged
丛吉钰Add on 11 days ago
Total: 1 files changed+12-1
Mbuild.sh+12-1
@@ -27,7 +27,7 @@ SUPPORTED_SHORT_OPTS="hj:vO:uf:-:"
27# 所有支持的长选项27# 所有支持的长选项
28SUPPORTED_LONG_OPTS=(28SUPPORTED_LONG_OPTS=(
29 "help" "ops=" "soc=" "vendor_name=" "build-type=" "cov" "noexec" "noaicpu" "opkernel" "opkernel_aicpu" "opkernel_aicpu_test" "static"29 "help" "ops=" "soc=" "vendor_name=" "build-type=" "cov" "noexec" "noaicpu" "opkernel" "opkernel_aicpu" "opkernel_aicpu_test" "static"
30- "jit" "pkg" "asan" "make_clean_all" "make_clean" "no_force"30+ "jit" "pkg" "asan" "valgrind" "make_clean_all" "make_clean" "no_force"
31 "ophost" "opgraph" "opapi" "run_example" "example_name=" "genop=" "genop_aicpu=" "experimental" "cann_3rd_lib_path=" "oom" "onnxplugin" "tfplugin" "dump_cce"31 "ophost" "opgraph" "opapi" "run_example" "example_name=" "genop=" "genop_aicpu=" "experimental" "cann_3rd_lib_path=" "oom" "onnxplugin" "tfplugin" "dump_cce"
32 "simulator" "bisheng_flags=" "kernel_template_input=" "module_extension=" "noaclnn" "mssanitizer" "rule_launch=" "ccache=" "torch_extension" "pkg-type="32 "simulator" "bisheng_flags=" "kernel_template_input=" "module_extension=" "noaclnn" "mssanitizer" "rule_launch=" "ccache=" "torch_extension" "pkg-type="
33 "ut_mode=" "ut_timeout="33 "ut_mode=" "ut_timeout="
@@ -393,6 +393,7 @@ usage() {
393 echo " --make_clean make clean"393 echo " --make_clean make clean"
394 echo " --make_clean_all make clean and delete related file"394 echo " --make_clean_all make clean and delete related file"
395 echo " --asan enable asan on the host side"395 echo " --asan enable asan on the host side"
396+ echo " --valgrind run ut with valgrind. This option will disable asan and direct execution (same as --noexec, ut is only run under valgrind)"
396 echo " --ccache=<VALUE> Enable or disable ccache compilation acceleration"397 echo " --ccache=<VALUE> Enable or disable ccache compilation acceleration"
397 echo " VALUE options: on/off/true/false/disable, Default: on"398 echo " VALUE options: on/off/true/false/disable, Default: on"
398 echo " Example: --ccache=off to disable ccache"399 echo " Example: --ccache=off to disable ccache"
@@ -498,6 +499,12 @@ check_param() {
498 exit 1499 exit 1
499 fi500 fi
500 501 
502+ if [[ "$ENABLE_VALGRIND" == "TRUE" && "$ENABLE_ASAN" == "TRUE" ]]; then
503+ # 按文档约定:--valgrind 生效时自动关闭 ASAN(与 --asan 传参顺序无关),不中断构建
504+ echo "[INFO] --valgrind is enabled, disabling ASAN"
505+ ENABLE_ASAN=FALSE
506+ fi
507+ 
501 if [[ "$PACKAGE_TYPE" != "run" && "$PACKAGE_TYPE" != "all" ]]; then508 if [[ "$PACKAGE_TYPE" != "run" && "$PACKAGE_TYPE" != "all" ]]; then
502 if [[ "$ENABLE_STATIC" == "TRUE" ]]; then509 if [[ "$ENABLE_STATIC" == "TRUE" ]]; then
503 echo "[ERROR] --pkg-type=${PACKAGE_TYPE} cannot be used with --static"510 echo "[ERROR] --pkg-type=${PACKAGE_TYPE} cannot be used with --static"
@@ -925,6 +932,10 @@ checkopts() {
925 ENABLE_TORCH_EXTENSION_ONLY=TRUE932 ENABLE_TORCH_EXTENSION_ONLY=TRUE
926 ;;933 ;;
927 asan) ENABLE_ASAN=TRUE ;;934 asan) ENABLE_ASAN=TRUE ;;
935+ valgrind)
936+ ENABLE_VALGRIND=TRUE
937+ ENABLE_UT_EXEC=FALSE
938+ ;;
atomgit-bot
atomgit-botatomgit-bot11 days ago

🟡 Medium Priority

变更行:build.sh:934-937 的 valgrind) 分支设置 ENABLE_VALGRIND=TRUE 与 ENABLE_UT_EXEC=FALSE。

证据链:ENABLE_UT_EXEC 在 build.sh 中只有三处使用——初始化 ENABLE_UT_EXEC=TRUE(build.sh:718)、noexec) ENABLE_UT_EXEC=FALSE(build.sh:905)、以及 -DENABLE_UT_EXEC=${ENABLE_UT_EXEC} 透传给 cmake(build.sh:1087);帮助文本 build.sh:392 明确 --noexec Only compile ut, do not execute the compiled executable file。也就是说 ENABLE_UT_EXEC=FALSE 正是 --noexec 的语义(只编译不执行)。而本 diff 在 build.sh:396 声明 valgrind「run ut with valgrind … will disable … noexec」,即 valgrind 应当覆盖/取消 noexec 状态。

失效模式:bash build.sh -u --valgrind 实际会把 -DENABLE_UT_EXEC=FALSE 传给 cmake,与直接加 --noexec 的结果一致。若 cmake 侧的执行开关仍以 ENABLE_UT_EXEC 为准(cmake 文件不在本次可检视范围内,故置信度下调),UT 可执行文件只编译不执行,用户既拿不到 valgrind 内存检测报告,也没有任何报错提示;且「避免与 --noexec 冲突」这一点在 build.sh 内完全没有实现——传 --noexec --valgrind 时同样落到 ENABLE_UT_EXEC=FALSE,没有校验也没有覆盖。

修复方向:确认 cmake 侧 valgrind 执行路径是否依赖 ENABLE_UT_EXEC;若依赖,删除该行(保持 TRUE)或改为在 ENABLE_VALGRIND==TRUE 时强制 ENABLE_UT_EXEC=TRUE,并在 check_param 中对 --valgrind 与 --noexec 的组合给出明确处理(覆盖或报错)。

建议:核对 cmake 侧 valgrind 执行路径后,避免用 ENABLE_UT_EXEC=FALSE 表达 valgrind(这与 --noexec 等价);如需强制覆盖 noexec,应在 check_param 中显式把 ENABLE_UT_EXEC 置回 TRUE 或对 --noexec + --valgrind 组合报错。

likedislike
Incorrect?
928 run_example) ENABLE_RUN_EXAMPLE=TRUE939 run_example) ENABLE_RUN_EXAMPLE=TRUE
929 set_example_opt "$@"940 set_example_opt "$@"
930 ;;941 ;;