pybind_extension linkage is problematic for projects with multiple pybind modules
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 領域
- build-system
調査の方向性
pybind_extension ルールから始め、cc_binary のリンクが推移的依存関係を静的に含め、-Bsymbolic を適用する仕組みを調査します。その動作を cc_shared_library と比較し、静的依存関係と動的依存関係をどのように制御できるかに注目します。pybind モジュールがプロセス全体で共有される C++ 状態のプライベートなコピーを避けつつ、必要な拡張機能のリンクを維持できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Starlark
- スター
- 116
- フォーク
- 67
- 平均マージ
- 22分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pybind/pybind11_bazel のほかの issue
-
Output file gets a `.pyd.dll` extension on Windows再び着手できるかも @Mizux が 239 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug OS: Windows
pybind/pybind11_bazel#132 · コメント 4 件 · 担当者 1 名 ·
pybind/pybind11_bazel の issue をすべて見る
似ている issue
-
Installing from source leaves out all subpackages (fastai.vision, fastai.text, ...)対応中かも @lejrn が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
bug testing windows
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
quarto-dev/q2#1347 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
owasp-modsecurity/ModSecurity-nginx#418 ·
メンテナーはふだん 1 日以内に返信
-
Update Tailscale dependency for Android cgo fallback fix対応中かも @lozbrown が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
conda/conda-lock#983 ·
メンテナーはふだん 1 日以内に返信