-
Notifications
You must be signed in to change notification settings - Fork 1
fix: macos dynamic link libpaddle #2
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
base: paddle
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,12 +8,50 @@ find_package(pybind11 REQUIRED) | |||||||||
| #find_package(Torch REQUIRED) | ||||||||||
| set(TORCH_CXX_FLAGS "") | ||||||||||
|
|
||||||||||
| function(resolve_paddle_library out_var) | ||||||||||
| foreach(candidate IN LISTS ARGN) | ||||||||||
| if(EXISTS "${candidate}") | ||||||||||
| set(${out_var} "${candidate}" PARENT_SCOPE) | ||||||||||
| return() | ||||||||||
| endif() | ||||||||||
| endforeach() | ||||||||||
| message(FATAL_ERROR "Unable to locate Paddle library for ${out_var}. Tried: ${ARGN}") | ||||||||||
| endfunction() | ||||||||||
|
|
||||||||||
| if(APPLE) | ||||||||||
| # Paddle on macOS ships libpaddle as .so, while runtime deps are .dylib. | ||||||||||
| set(PADDLE_LIBPADDLE_CANDIDATES "${PADDLE_PATH}/base/libpaddle.so") | ||||||||||
| set(PADDLE_LIBCOMMON_CANDIDATES "${PADDLE_PATH}/libs/libcommon.dylib") | ||||||||||
| set(PADDLE_LIBPHI_CORE_CANDIDATES "${PADDLE_PATH}/libs/libphi_core.dylib") | ||||||||||
| elseif(WIN32) | ||||||||||
| set(PADDLE_LIBPADDLE_CANDIDATES | ||||||||||
| "${PADDLE_PATH}/base/libpaddle.dll" | ||||||||||
| "${PADDLE_PATH}/base/libpaddle.lib" | ||||||||||
|
Comment on lines
+28
to
+29
|
||||||||||
| "${PADDLE_PATH}/base/libpaddle.dll" | |
| "${PADDLE_PATH}/base/libpaddle.lib" | |
| "${PADDLE_PATH}/base/libpaddle.lib" | |
| "${PADDLE_PATH}/base/libpaddle.dll" |
Copilot
AI
Feb 24, 2026
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.
On Windows, the library candidates should list .lib files before .dll files. Import libraries (.lib) are typically used for linking, while dynamic libraries (.dll) are loaded at runtime. If both files exist, the current order will select the .dll first, which may not work correctly with CMake's target_link_libraries. Consider reordering to check for .lib files first.
Copilot
AI
Feb 24, 2026
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.
On Windows, the library candidates should list .lib files before .dll files. Import libraries (.lib) are typically used for linking, while dynamic libraries (.dll) are loaded at runtime. If both files exist, the current order will select the .dll first, which may not work correctly with CMake's target_link_libraries. Consider reordering to check for .lib files first.
Copilot
AI
Feb 24, 2026
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.
The code should validate that PADDLE_PATH is defined and non-empty before using it to construct library paths. If PADDLE_PATH is not set, the error message from resolve_paddle_library will be confusing (e.g., "Unable to locate Paddle library for PADDLE_LIBPADDLE. Tried: /base/libpaddle.so"). Consider adding a check like if(NOT DEFINED PADDLE_PATH OR PADDLE_PATH STREQUAL "") with a clear error message before this platform-specific code block.
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.
I don't think this addresses the macOS runtime failure described in the PR.
-undefined,dynamic_lookup only relaxes symbol resolution at link time; it does not add any runtime search path for FFmpeg dylibs. The failure we usually hit on macOS is Library not loaded: @rpath/libavutil*.dylib during import torchcodec / torch.ops.load_library(...).
Upstream torchcodec fixed that class of bug in meta-pytorch#1152 (see issue meta-pytorch#570) by adding an INSTALL_RPATH for Homebrew FFmpeg. This patch does not add any INSTALL_RPATH, @loader_path, or install-name adjustment, so users will still need to set DYLD_LIBRARY_PATH manually.
Can we port the actual runtime search-path fix here, and add at least one macOS validation for import torchcodec?
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.
The error message could be more user-friendly. Currently it says "Unable to locate Paddle library for PADDLE_LIBPADDLE" which uses the variable name. Consider changing the message to be more descriptive, for example: "Unable to locate Paddle library '${out_var}'. Searched in: ${ARGN}" or maintain a mapping from variable names to descriptive names like "libpaddle", "libcommon", etc.