forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 10
增强 MACA 查找诊断输出 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ghangz
wants to merge
5
commits into
MetaX-MACA:dev
Choose a base branch
from
ghangz:mengz/improve-find-maca-diagnostics
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
增强 MACA 查找诊断输出 #21
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e219c2e
Improve MACA CMake discovery diagnostics
ghangz 05362ee
test: make FindMACA stale-state check standalone
ghangz db238b5
cmake: clear invalid MACA candidate paths
ghangz 2667f57
fix: refresh FindMACA cache entries
ghangz f587013
Normalize MACA diagnostic messages
ghangz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| if(NOT TVM_SOURCE_DIR) | ||
| get_filename_component(TVM_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) | ||
| endif() | ||
|
|
||
| include("${TVM_SOURCE_DIR}/cmake/utils/FindMACA.cmake") | ||
|
|
||
| set(MACA_FOUND TRUE) | ||
| set(MACA_INCLUDE_DIRS "/stale/include") | ||
| set(MACA_MACAMCC_LIBRARY "/stale/libmcruntime.so") | ||
|
|
||
| find_maca("${CMAKE_CURRENT_LIST_DIR}/does-not-exist") | ||
|
|
||
| if(MACA_FOUND) | ||
| message(FATAL_ERROR "find_maca must clear stale MACA_FOUND when no SDK is found") | ||
| endif() | ||
|
|
||
| if(MACA_INCLUDE_DIRS OR MACA_MACAMCC_LIBRARY) | ||
| message(FATAL_ERROR "find_maca must clear stale MACA include and library values") | ||
| endif() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题分析:
在 CMake 中,
find_library会将查找结果缓存到 CMake Cache 中(例如MACA_MACAMCC_LIBRARY)。当用户在同一个构建目录中切换 MACA SDK 路径(例如从/opt/maca切换到另一个自定义路径)时,由于 Cache 中已存在旧的路径,find_library将不会重新执行搜索,而是直接复用缓存中的旧库路径。这会导致 include 目录与库文件版本不匹配,引发难以排查的编译或运行期错误。解决方案:
在调用
find_library之前,先使用unset(... CACHE)清理对应的缓存变量。由于我们指定了PATHS和NO_DEFAULT_PATH,重新搜索的开销极小,但能极大提高构建的可靠性。