Skip to content

明确 mxsml 动态库搜索顺序#14

Open
ghangz wants to merge 3 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mxsml-library-search-report
Open

明确 mxsml 动态库搜索顺序#14
ghangz wants to merge 3 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mxsml-library-search-report

Conversation

@ghangz

@ghangz ghangz commented Jun 25, 2026

Copy link
Copy Markdown

这个改动补充了动态库搜索顺序的说明,明确系统默认加载路径和显式候选路径之间的关系,降低后续排查库覆盖问题时的理解成本,也让调用方更容易判断为什么实际加载到的是某个版本。

变更已通过现有库加载单元测试回归验证,本地测试结果正常。

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the library path lookup by extracting the candidate library paths into a public function CandidateLibraryPaths(), allowing applications to query the search order. It also adds unit tests and updates the README. A review comment suggests adding documentation to CandidateLibraryPaths() to clarify that system default paths are tried before these candidate paths.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/lib/search_paths.go

const mxsmlLibName = "libmxsml.so"

func CandidateLibraryPaths() []string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Load() 函数的实现中,程序会首先尝试通过 dlopen("libmxsml.so") 从系统默认的动态库搜索路径(如 LD_LIBRARY_PATH/usr/lib 等)加载动态库。如果加载失败,才会依次尝试 CandidateLibraryPaths() 返回的候选路径。

为了避免使用者误以为仅会搜索 CandidateLibraryPaths() 返回的路径,建议在 CandidateLibraryPaths() 函数上添加文档注释,明确说明这一搜索顺序和逻辑。这对于诊断容器或宿主机 SDK 布局问题非常重要。

// CandidateLibraryPaths 返回用于定位 libmxsml.so 的候选绝对路径列表。
// 需要注意的是,Load() 在尝试这些候选路径之前,会首先尝试从系统默认路径(如 LD_LIBRARY_PATH)
// 直接加载 "libmxsml.so"。
func CandidateLibraryPaths() []string {

@ghangz ghangz changed the title 输出 mxsml 动态库搜索顺序 ?? mxsml ??????? Jun 26, 2026
@ghangz ghangz changed the title ?? mxsml ??????? 明确 mxsml 动态库搜索顺序 Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant