[New-bugs-announce] [issue35037] PYLONG_BITS_IN_DIGIT differs between MinGW and MSVC

Stefan Behnel report at bugs.python.org
Sun Oct 21 04:22:52 EDT 2018


New submission from Stefan Behnel <stefan_ml at behnel.de>:

I see reports from Cython users on Windows-64 that extension modules that use "longintrepr.h" get miscompiled by MinGW. A failing setup looks as follows:

Stock 64 bit CPython on Windows, e.g.
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]

MinGW uses this compile time setup, i.e. 15 bit digits:
PyLong_BASE  0x8000
PyLong_MASK  7FFF
PyLong_SHIFT  15
sizeof(digit)  2
sizeof(sdigit)  2

Whereas CPython reports the following, indicating that it was in fact built with 30 bit digits:
sys.getsize(1, 2**14, 2**15, 2**29, 2**30, 2**63, 2**64)  (28, 28, 28, 28, 32, 36, 36)

I'm not sure if this also applies to Py2.7, but I don't think the PyLong implementations differ in this regard.

The compile time PyLong digit size is not remembered by the CPython installation and instead determined on the fly by the extension compiler. It seems that the MSVC build of the stock CPython packages differs from what MinGW decides here. This renders MinGW unusable for code that uses "longintrepr.h", which Cython does by default in order to accelerate its unpacking of PyLong values.

Is there a reason why CPython cannot store its compile time value for the PYLONG_BITS_IN_DIGIT setting somewhere?

----------
components: Extension Modules, Windows
messages: 328197
nosy: paul.moore, scoder, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: PYLONG_BITS_IN_DIGIT differs between MinGW and MSVC
type: compile error
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35037>
_______________________________________


More information about the New-bugs-announce mailing list