明确 mxsml 动态库搜索顺序#14
Conversation
There was a problem hiding this comment.
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.
|
|
||
| const mxsmlLibName = "libmxsml.so" | ||
|
|
||
| func CandidateLibraryPaths() []string { |
There was a problem hiding this comment.
在 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 {?? API ?? 2 ??????
这个改动补充了动态库搜索顺序的说明,明确系统默认加载路径和显式候选路径之间的关系,降低后续排查库覆盖问题时的理解成本,也让调用方更容易判断为什么实际加载到的是某个版本。
变更已通过现有库加载单元测试回归验证,本地测试结果正常。