Compiling static library with `-fPIC` throws error
未關閉
還沒有人認領這個 Issue。
build
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
I'm compiling python as a static library to embed in my c++ shared library, and -fPIC is necessary to get it working!
compilation command: CFLAGS=-fPIC ./configure --enable-shared=no --enable-optimizations
the following error happens:
Objects/typeobject.c: In function ‘inherit_special’:
Objects/typeobject.c:5777:1: error: the control flow of function ‘inherit_special’ does not match its profile data (counter ‘arcs’) [-Werror=coverage-mismatch]
5777 | inherit_special(PyTypeObject *type, PyTypeObject *base)
| ^~~~~~~~~~~~~~~
Objects/typeobject.c:5777:1: error: the control flow of function ‘inherit_special’ does not match its profile data (counter ‘time_profiler’) [-Werror=coverage-mismatch]
Objects/typeobject.c: In function ‘object_set_class’:
Objects/typeobject.c:4774:1: error: the control flow of function ‘object_set_class’ does not match its profile data (counter ‘arcs’) [-Werror=coverage-mismatch]
4774 | object_set_class(PyObject *self, PyObject *value, void *closure)
| ^~~~~~~~~~~~~~~~
Objects/typeobject.c:4774:1: error: the control flow of function ‘object_set_class’ does not match its profile data (counter ‘time_profiler’) [-Werror=coverage-mismatch]
Objects/obmalloc.c:1449:1: warning: ‘always_inline’ function might not be inlinable [-Wattributes]
1449 | arena_map_get(block *p, int create)
| ^~~~~~~~~~~~~
if I remove the -fPIC it compiles fine!
edit: Just tried removing --enable-optimizations and it worked, but I think it should work with optimizations?
Your environment
- CPython versions tested on: branch 3.11
- Operating system and architecture: Manjaro Linux x64
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
在 CPython 3.11 上使用 CFLAGS=-fPIC ./configure --enable-shared=no --enable-optimizations 重現該問題,然後將其與不使用 -fPIC 或 --enable-optimizations 時成功的建置進行比較。從 Objects/typeobject.c 中回報的失敗和 Objects/obmalloc.c 中的警告開始;當帶有 -fPIC 的最佳化靜態建置完成時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cpp, python
- 領域
- build-system, compilers
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100