Skip to content

Fix linux aggressively drop symbols#71

Merged
chengcli merged 2 commits intomainfrom
cli/fix_linux_drop
Feb 5, 2026
Merged

Fix linux aggressively drop symbols#71
chengcli merged 2 commits intomainfrom
cli/fix_linux_drop

Conversation

@chengcli
Copy link
Owner

@chengcli chengcli commented Feb 5, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 5, 2026 15:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses symbol dropping issues on Linux systems by adjusting library linking behavior and ordering.

Changes:

  • Reordered library linking in setup.py to place CUDA libraries last, ensuring proper dependency resolution
  • Replaced conditional CUDAExtension/CppExtension logic with a single CppExtension since the Python binding code is pure C++
  • Added --no-as-needed linker flag to test executables on Linux to prevent aggressive symbol dropping

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
setup.py Modified library ordering to prioritize non-CUDA kintera libraries before CUDA libraries, and switched from conditional CUDA/non-CUDA extension types to always using CppExtension
cmake/macros/macro_setup_test.cmake Added --no-as-needed linker flag for Linux (non-macOS Unix systems) to prevent linker from dropping libraries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +28
if (UNIX AND NOT APPLE)
target_link_options(${namel}.${buildl} PRIVATE -Wl,--no-as-needed)
endif()
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The --no-as-needed linker flag is being added to setup_test to prevent Linux from aggressively dropping symbols. However, macro_setup_problem.cmake has a similar structure and links the same libraries (kintera::kintera and optionally kintera::kintera_cu) but does not have this flag. For consistency and to prevent similar symbol dropping issues in problem executables, consider adding the same linker flag to setup_problem as well.

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +78
ext_module = cpp_extension.CppExtension(
name='kintera.kintera',
sources=glob.glob('python/csrc/*.cpp'),
include_dirs=include_dirs,
library_dirs=lib_dirs,
libraries=libraries,
extra_compile_args=['-Wno-attributes'],
extra_link_args=extra_link_args,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The --no-as-needed linker flag is being added to test executables in CMake to prevent Linux from aggressively dropping symbols. However, the Python extension in setup.py also links to the same kintera libraries and may suffer from the same symbol dropping issue on Linux. Consider adding -Wl,--no-as-needed to extra_link_args for non-Darwin platforms (lines 64-69) to ensure consistent behavior and prevent potential symbol resolution issues in the Python extension.

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +28
# 1) non-cuda libs first (consumers)
kintera_non_cuda = [l for l in library_names if l.startswith("kintera") and "cuda" not in l]
# 2) cuda libs last (providers)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The comment on line 26 describes kintera non-CUDA libraries as "consumers," but this is potentially misleading. In typical linking scenarios, consumers depend on providers, not the other way around. If kintera_cuda libraries are "providers" (line 28), then kintera non-CUDA libraries would be consumers of those CUDA providers. However, placing providers (kintera_cuda) last in the link order is correct for ensuring that dependencies are resolved properly. Consider clarifying these comments to explain that this ordering ensures proper symbol resolution where libraries that depend on CUDA functionality come before the CUDA provider libraries.

Suggested change
# 1) non-cuda libs first (consumers)
kintera_non_cuda = [l for l in library_names if l.startswith("kintera") and "cuda" not in l]
# 2) cuda libs last (providers)
# 1) non-CUDA kintera libs first (they may depend on CUDA symbols)
kintera_non_cuda = [l for l in library_names if l.startswith("kintera") and "cuda" not in l]
# 2) CUDA kintera libs last (they provide the CUDA symbols for earlier deps)

Copilot uses AI. Check for mistakes.
@chengcli chengcli merged commit 4d0f413 into main Feb 5, 2026
3 checks passed
@chengcli chengcli deleted the cli/fix_linux_drop branch February 5, 2026 19:20
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

🎉 Released v1.2.10!

What's Changed

Full Changelog: v1.2.9...v1.2.10

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