python / python/cpython

Compiling static library with `-fPIC` throws error

Ouverte
#100,707 1 commentaire 5 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

build type-bug
Langage dominant
Python
Étoiles
77.2k
Forks
36k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Reproduisez le problème avec CFLAGS=-fPIC ./configure --enable-shared=no --enable-optimizations sur CPython 3.11, puis comparez-le avec la compilation réussie sans -fPIC ni --enable-optimizations. Commencez par les erreurs signalées dans Objects/typeobject.c et l'avertissement dans Objects/obmalloc.c ; le travail est terminé lorsque la compilation statique optimisée s'achève avec -fPIC.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp, python
Domaine
build-system, compilers
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.