pybind_extension linkage is problematic for projects with multiple pybind modules
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu từ rule pybind_extension và kiểm tra cách việc liên kết cc_binary đưa các dependency bắc cầu vào một cách tĩnh và áp dụng -Bsymbolic. So sánh hành vi đó với cc_shared_library, tập trung vào cách có thể kiểm soát dependency tĩnh so với dependency động. Công việc được xem là hoàn tất khi một module pybind có thể tránh các bản sao riêng của trạng thái C++ toàn cục của tiến trình mà vẫn giữ được việc liên kết extension cần thiết.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This has been a long standing issue that shows up in projects with non-trivial / isolated C modules. I'm just finally getting around to actually writing up this problem
Right now, pybind_extension creates a shared library is using cc_binary(). This statically links all the dependencies, transitively. To complicate matters, it uses -Bsymbolic -- what this does is change how the shared library looks up symbols, giving preference to symbols within the shared library (which, because of the static linking, includes all dependencies).
The net effect is the resulting shared library can't participate in process-global state. For example, lets say there's a foo-plugins library, normally provided as libfoo-plugins.so, with the intent that consumers can load the library and register plugins into a static map<...> PLUGINS that is global to the process. Now we create a mybind.so Python C module using pybind_extension, which depends on foo-plugins. Because of how it's linked in, mybind.so has its own private copy of the PLUGINS map. Later, when people start registering plugins and asking which are available, they'll get different answers depending on if they're within mybind.so or outside it.
Such globals aren't uncommon. Absl flags and module initializers are such an example, but are easily found in other C++ libraries.
The fix I suggest is to switch pybind_extension to using something like cc_shared_library, which provides some control over what is statically vs dynamically linked into the Python C module. cc_shared_library is annoying to use, but it can get the job done.
In any case, there needs to be a way to better control what is statically vs dynamically linked into the pybind_extension module.
- Ngôn ngữ chính
- Starlark
- Star
- 116
- Fork
- 67
- Merge trung bình
- 22 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pybind/pybind11_bazel
-
Output file gets a `.pyd.dll` extension on WindowsCó thể làm lại được @Mizux đã nhận 238 ngày trước và không có pull request nào đang mở. Đang mởbug OS: Windows
pybind/pybind11_bazel#132 · 4 bình luận · 1 người được giao ·
Tất cả issue của pybind/pybind11_bazel
Issue tương tự
-
Installing from source leaves out all subpackages (fastai.vision, fastai.text, ...)Có thể đã có người làm @lejrn đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
bug testing windows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
quarto-dev/q2#1347 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
owasp-modsecurity/ModSecurity-nginx#418 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update Tailscale dependency for Android cgo fallback fixCó thể đã có người làm @lozbrown đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
conda/conda-lock#983 ·
Maintainer thường phản hồi trong vòng 1 ngày