classification
Title: _struct module compilation error under Cygwin 1.7.17 on Python 3.4
Type: compile error Stage: resolved
Components: Build Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: dellair.jie, masamoto, python-dev, serhiy.storchaka, zach.ware
Priority: normal Keywords: patch

Created on 2014-04-01 14:52 by dellair.jie, last changed 2017-03-31 16:36 by dstufft. This issue is now closed.

Files
File name Uploaded Description Edit
_struct.c.txt dellair.jie, 2014-04-01 14:52
Build.log dellair.jie, 2014-04-01 14:53
3.4-struct.patch masamoto, 2014-04-02 12:17 patch of compiling Modules/_struct.c on Cygwin
PyType_Ready-unpackiter_type.patch masamoto, 2016-10-02 11:08 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (17)
msg215321 - (view) Author: dellair jie (dellair.jie) Date: 2014-04-01 14:52
Dear all,

I am compiling Python 3.4 on Cygwin 1.7.17.

The following has been done in order to reach the point where _struct module failed.
> A clean Python 3.4
> Applied patches:
  cygwin_si_band.patch in Issue21085
  0001-CYGWIN-issue13756-Python-make-fail-on-cygwin.patch in issue13756
  0019-MINGW-export-_PyNode_SizeOf-as-PyAPI-for-parser-modu.patch in issue186373
> configure + make

The issue happened during make:
building '_struct' extension
gcc -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./Include -I. -IInclude -I/cygdrive/c/temp/Python-3.4.0/Include -I/cygdrive/c/temp/Python-3.4.0 -c /cygdrive/c/temp/Python-3.4.0/Modules/_struct.c -o build/temp.cygwin-1.7.17-i686-3.4/cygdrive/c/temp/Python-3.4.0/Modules/_struct.o
/cygdrive/c/temp/Python-3.4.0/Modules/_struct.c:1630:5: error: initializer element is not constant
/cygdrive/c/temp/Python-3.4.0/Modules/_struct.c:1630:5: error: (near initialization for ‘unpackiter_type.ob_base.ob_base.ob_type’)

Please feel free to find the build.log and the output of _struct.c.txt (gcc with -dD -E -DPy_BUILD_core) for more information.

Thanks in advance,
Br,
Dellair
msg215322 - (view) Author: dellair jie (dellair.jie) Date: 2014-04-01 14:53
The full build log
msg215349 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-04-02 01:23
This looks like a duplicate of Issue6672.
msg215359 - (view) Author: dellair jie (dellair.jie) Date: 2014-04-02 06:51
Neil,

It doesn't look like a duplicate of Issue6672.
The one in Issue6672 was for Mingw, all the patches simply added __MINGW32__ to __CYGWIN__ build structure.
While my issue is, the build failed with _struct.c on Cygwin. So the module is recognized, just didn't pass the compilation.

Br,
Dellair
msg215379 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2014-04-02 12:17
I wrote a patch file.
In other extention module source codes, global variable PyTypeObject has initialized to using "PyVarObject_HEAD_INIT(NULL, 0)".
And so, as with other modules, I tried to edit and compiling _struct.c in Cygwin 1.7.28.
The module compiling was passing, And struct module passed a test "python3.4 -m test test_struct".
msg215385 - (view) Author: dellair jie (dellair.jie) Date: 2014-04-02 14:11
Yamamoto,

Thanks, the patch you offered did make the _struct error disappeared. I will do a bit more testing.

Dellair
msg217517 - (view) Author: dellair jie (dellair.jie) Date: 2014-04-29 13:17
Hello masamoto,

The patch you provided works quite well.
The build passed and Python calls are successfully.
Please let me know what else you need me to test in order to have the patch accepted or else feel free to close it with Resolution Fixed.

Thanks,
Dellair
msg217562 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2014-04-29 23:58
I have solved about compiling _struct module too.
I have no authority of this issues, So please close of issues.
msg217577 - (view) Author: dellair jie (dellair.jie) Date: 2014-04-30 07:15
Fixed with the patch.
msg277852 - (view) Author: Roundup Robot (python-dev) Date: 2016-10-02 05:34
New changeset 3bde312ae936 by Zachary Ware in branch 'default':
Issue #21124: Fix building _struct on Cygwin.
https://hg.python.org/cpython/rev/3bde312ae936
msg277853 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-10-02 05:38
For future reference, having a patch attached to the issue does not mean the issue is fixed, and it should not be closed.
msg277874 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-02 09:51
PyType_Ready() should be called for unpackiter_type.

See also issue26906.
msg277887 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2016-10-02 11:08
I wrote a patch to add the unpackiter_type initialization into PyInit__struct function. I has confirmed solve #28337 on ubuntu x86 16.04.
msg277891 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-10-02 13:49
Do we not have a unit test for that?
msg277959 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2016-10-03 15:29
unpack_iterator type has not been registered into _struct module. And all users get only unpack_iterator object from function returning iterator. The object iterating doesn't need reference to type. Therefore, I think issue finish by PyType_Ready fix because this segfault doesn't have big impact.

However, I think if possible, it is preferable that extension module having un-initialize type objects gets a compile error at build time. And impossible case for compile error is better that wrong extension module always fails import.
msg278012 - (view) Author: Roundup Robot (python-dev) Date: 2016-10-04 06:25
New changeset c4eb211fb38b by Zachary Ware in branch 'default':
Closes #21124, #28337: Call PyType_Ready on unpackiter_type.
https://hg.python.org/cpython/rev/c4eb211fb38b
msg278013 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-10-04 06:26
Thanks for the patch again :).

The last idea you mentioned sounds somewhat interesting, please open a new issue for it if you'd like to pursue it.
History
Date User Action Args
2017-03-31 16:36:22dstufftsetpull_requests: + pull_request958
2016-10-04 06:26:33zach.waresetmessages: + msg278013
2016-10-04 06:25:05python-devsetstatus: open -> closed
resolution: fixed
messages: + msg278012

stage: resolved
2016-10-03 15:29:43masamotosetmessages: + msg277959
2016-10-02 13:49:21zach.waresetmessages: + msg277891
2016-10-02 11:08:58masamotosetfiles: + PyType_Ready-unpackiter_type.patch
nosy: + masamoto
messages: + msg277887

2016-10-02 09:51:26serhiy.storchakasetstatus: closed -> open

nosy: + serhiy.storchaka
messages: + msg277874

resolution: fixed -> (no value)
stage: resolved -> (no value)
2016-10-02 05:38:25zach.waresetversions: + Python 3.7, - Python 3.4
nosy: + zach.ware

messages: + msg277853

type: compile error
stage: resolved
2016-10-02 05:34:12python-devsetnosy: + python-dev
messages: + msg277852
2014-04-30 07:15:17dellair.jiesetstatus: open -> closed
resolution: fixed
messages: + msg217577
2014-04-29 23:59:23masamotosetnosy: - masamoto
2014-04-29 23:58:39masamotosetnosy: dellair.jie, masamoto
messages: + msg217562
2014-04-29 13:17:28dellair.jiesetmessages: + msg217517
2014-04-03 19:11:39ned.deilysetnosy: - ned.deily

superseder: Add Mingw recognition to pyport.h to allow building extensions ->
resolution: duplicate -> (no value)
stage: resolved -> (no value)
2014-04-02 14:11:43dellair.jiesetmessages: + msg215385
2014-04-02 12:17:12masamotosetfiles: + 3.4-struct.patch

nosy: + masamoto
messages: + msg215379

keywords: + patch
2014-04-02 06:51:24dellair.jiesetstatus: pending -> open

messages: + msg215359
2014-04-02 01:23:30ned.deilysetstatus: open -> pending

superseder: Add Mingw recognition to pyport.h to allow building extensions
components: + Build
title: Compilation error on _struct module on Python 3.4 -> _struct module compilation error under Cygwin 1.7.17 on Python 3.4
nosy: + ned.deily

messages: + msg215349
resolution: duplicate
stage: resolved
2014-04-01 14:53:31dellair.jiesetfiles: + Build.log

messages: + msg215322
2014-04-01 14:52:31dellair.jiecreate