python / python/cpython

Compiling static library with `-fPIC` throws error

Offen
#100,707 1 Kommentar 5 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

build type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem mit CFLAGS=-fPIC ./configure --enable-shared=no --enable-optimizations auf CPython 3.11 und vergleiche es anschließend mit dem erfolgreichen Build ohne -fPIC oder --enable-optimizations. Beginne mit den gemeldeten Fehlern in Objects/typeobject.c und der Warnung in Objects/obmalloc.c; die Aufgabe ist abgeschlossen, wenn der optimierte statische Build mit -fPIC erfolgreich abgeschlossen wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, python
Bereich
build-system, compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.