classification
Title: building extensions as builtins is broken in 3.7
Type: Stage:
Components: Build Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: doko, eric.snow, ncoghlan, ned.deily
Priority: release blocker Keywords: patch

Created on 2017-12-06 13:03 by doko, last changed 2018-01-09 02:19 by ned.deily.

Files
File name Uploaded Description Edit
ext-as-builtins.diff doko, 2017-12-06 14:53 proposed patch
Messages (3)
msg307735 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2017-12-06 13:03
building extensions statically in linking these into the python binary is currently broken on 3.7.

I'm attaching the change that worked for me in 3.7alpha2, but doesn't work anymore with alpha3. Currently investigating.  When building extensions as builtins, these should benefit from the knowledge about the core interpreter.

x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/home/packages/python/3.7/python3.7-3.7.0~a3=. -fstack-protector-strong -Wformat -Werror=format-security    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -IObjects -IInclude -IPython -I. -I../Include -Wdate-time -D_FORTIFY_SOURCE=2   -DPy_BUILD_CORE  -c ../Modules/_elementtree.c -o Modules/_elementtree.o
In file included from ../Include/pyatomic.h:10:0,
                 from ../Include/Python.h:53,
                 from ../Modules/_elementtree.c:16:
../Modules/_elementtree.c: In function 'element_dealloc':
../Include/pystate.h:314:34: error: '_PyRuntime' undeclared (first use in this function); did you mean 'PyRun_File'?
 #  define _PyThreadState_Current _PyRuntime.gilstate.tstate_current
                                  ^
../Include/pyatomic.h:533:5: note: in expansion of macro '_Py_atomic_load_explicit'
     _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
     ^~~~~~~~~~~~~~~~~~~~~~~~
../Include/pystate.h:316:31: note: in expansion of macro '_Py_atomic_load_relaxed'
              ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
                               ^~~~~~~~~~~~~~~~~~~~~~~
../Include/pystate.h:316:56: note: in expansion of macro '_PyThreadState_Current'
              ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
                                                        ^~~~~~~~~~~~~~~~~~~~~~
../Include/object.h:1069:34: note: in expansion of macro 'PyThreadState_GET'
         PyThreadState *_tstate = PyThreadState_GET(); \
                                  ^~~~~~~~~~~~~~~~~
../Modules/_elementtree.c:634:5: note: in expansion of macro 'Py_TRASHCAN_SAFE_BEGIN'
     Py_TRASHCAN_SAFE_BEGIN(self)
     ^~~~~~~~~~~~~~~~~~~~~~
../Include/pystate.h:314:34: note: each undeclared identifier is reported only once for each function it appears in
 #  define _PyThreadState_Current _PyRuntime.gilstate.tstate_current
                                  ^
../Include/pyatomic.h:533:5: note: in expansion of macro '_Py_atomic_load_explicit'
     _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
     ^~~~~~~~~~~~~~~~~~~~~~~~
../Include/pystate.h:316:31: note: in expansion of macro '_Py_atomic_load_relaxed'
              ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
                               ^~~~~~~~~~~~~~~~~~~~~~~
../Include/pystate.h:316:56: note: in expansion of macro '_PyThreadState_Current'
              ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
                                                        ^~~~~~~~~~~~~~~~~~~~~~
../Include/object.h:1069:34: note: in expansion of macro 'PyThreadState_GET'
         PyThreadState *_tstate = PyThreadState_GET(); \
                                  ^~~~~~~~~~~~~~~~~
../Modules/_elementtree.c:634:5: note: in expansion of macro 'Py_TRASHCAN_SAFE_BEGIN'
     Py_TRASHCAN_SAFE_BEGIN(self)
     ^~~~~~~~~~~~~~~~~~~~~~
../Include/pyatomic.h:56:5: error: '__atomic_load_ptr' undeclared (first use in this function); did you mean '__atomic_load_n'?
     atomic_load_explicit(&(ATOMIC_VAL)->_value, ORDER)
     ^
../Include/pyatomic.h:533:5: note: in expansion of macro '_Py_atomic_load_explicit'
     _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
     ^~~~~~~~~~~~~~~~~~~~~~~~
../Include/pystate.h:316:31: note: in expansion of macro '_Py_atomic_load_relaxed'
              ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
                               ^~~~~~~~~~~~~~~~~~~~~~~
msg307741 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2017-12-06 14:53
that patch lets the build succeed. two additional includes and a little bit of shuffling
msg309682 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-01-09 02:19
Can someone provide a pull request and a test for this prior to beta 1?
History
Date User Action Args
2018-01-09 02:19:51ned.deilysetmessages: + msg309682
2017-12-06 16:21:18ned.deilysetpriority: normal -> release blocker
nosy: + ned.deily
2017-12-06 14:53:01dokosetfiles: + ext-as-builtins.diff
keywords: + patch
messages: + msg307741
2017-12-06 13:07:28vstinnersetnosy: + ncoghlan, eric.snow
2017-12-06 13:03:40dokocreate