Skip to content
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

boost: Link Python when boost_python is fetched #6447

Closed
wants to merge 1 commit into from

Conversation

Doekin
Copy link
Contributor

@Doekin Doekin commented Feb 25, 2025

This PR attempts to address issues #6398 and #6399 by:
1. Preferring shared libraries for Boost when they are available on the system
2. linking Python when boost_python is present

_add_info(linkinfo, result)
found = true
end)
if found or package:config("shared") then
Copy link
Member

Choose a reason for hiding this comment

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

when package:config("shared") == false, use static libs, but shared libs are found. result will be shared libs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your feedback. In #6399 , I encountered an issue where boost_test_exec_monitor and boost_exception were only available as static libraries, and were inadvertently mixed with shared libraries, causing a double free at runtime.

Typically, only shared libraries are installed, with static libraries sometimes included as well. Given that shared libraries take priority during linking, there's a risk of mistakenly linking shared libraries when the fetch result includes static ones.

Therefore, I guess preferring shared libraries might help avoid this issue.

Copy link
Member

Choose a reason for hiding this comment

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

I know, but if package:config("shared") == false, we should only fetch static libraries.

if you want to use shared libraries, you should use add_requires("boost", {configs = {shared = true}})

Copy link
Contributor Author

@Doekin Doekin Feb 26, 2025

Choose a reason for hiding this comment

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

Sorry for the confusion, here’s my thought:

Currently, when static libraries are fetched, shared libraries are actually used due to their presence.

To clarify this situation and avoid mixing shared libraries (which are available both as shared and static) with pure static libraries (only available as static), it might make sense to always prefer shared libraries when possible, considering that add_requires("openssl") or add_deps("python") are common ways to fetch system-installed libraries, where package:config("shared") is false, yet shared libraries are still being fetched.

Alternatively, perhaps we could use add_linkgroups("a", "b", {static = true}) to ensure that static libraries are exactly used when fetched?

Copy link
Member

Choose a reason for hiding this comment

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

If you want to ensure compatibility and stability, you should disable system libraries. add_requires("boost", {system = false})

Now many packages' system libraries cannot control whether to choose static libraries or dynamic libraries, and there are many uncertainties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll explore other approaches to address my issue

@waruqi waruqi requested a review from star-hengxing February 25, 2025 15:34
@Doekin Doekin changed the title boost: Prefer shared libraries if available; automatically link Python boost: Link Python when boost_python is fetched Feb 26, 2025
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.

2 participants