Skip to content

MAINT: Add Mingw distutils support for Python compiled using MSVCR 14.#6875

Closed
tharen wants to merge 2 commits into
numpy:masterfrom
tharen:mingw64_f2py_vc14
Closed

MAINT: Add Mingw distutils support for Python compiled using MSVCR 14.#6875
tharen wants to merge 2 commits into
numpy:masterfrom
tharen:mingw64_f2py_vc14

Conversation

@tharen

@tharen tharen commented Dec 23, 2015

Copy link
Copy Markdown
Attempting to compile extensions with Mingw, cygwin, etc. for Python
distributions compiled using Visual Studio 2015 would result in errors
related to the MSVC version names.  This commit adds support to the Numpy
distutils modules for the new naming convention.

This is related to https://bugs.python.org/issue25251 and requires the
attached patch for distutils/cygwinccompiler.py.

    Attempting to compile extensions with Mingw, cygwin, etc. for Python
    distributions compiled using Visual Studio 2015 would result in errors
    related to the MSVC version names.  This commit adds support to the Numpy
    distutils modules for the new naming convention.

    This is related to https://bugs.python.org/issue25251 and requires the
    attached patch for distutils/cygwinccompiler.py.
@njsmith

njsmith commented Dec 23, 2015

Copy link
Copy Markdown
Member

Does this actually work? I can't see how this can possibly work -- vcruntime140.dll does not contain the C runtime.

@tharen

tharen commented Dec 23, 2015

Copy link
Copy Markdown
Author

Interesting... It does for me, but then the library I compiled with it was
pure fortran. I simply followed along with the patch included in the Python
bug report, https://bugs.python.org/issue25251. However, upon further
investigation I now understand that with VS 2015 the CRT has been split
into version dependent and independent libraries, e.g. vcruntime140 and
ucrtbase. mingw32ccompiler.py is defining a macro using the compiler
version number. I don't know if this is necessary or a holdover. A simple
check were I replace ucrtbase for vcruntime140 and hard code the version to
999 suggests that it may not be needed. But linking both DLLs seems
safest. I've made a couple changes and include both libraries. Although
now this is inconsistent with the change proposed in the referenced bug
report.

I'm a bit outside my wheelhouse. This all seems a bit fragile and
problematic to me anyhow, compiler version dependencies, etc. I may
simply be getting lucky here since I gather the UCRT is not supported
by Mingw yet.

Here are a couple links that I found informative.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a5194720-b019-4e60-bd2f-e1ed03e1a951/about-vs2015-crt-what-is-ucrtbasedll-and-where-is-its-symbol?forum=vcgeneral
http://stevedower.id.au/blog/building-for-python-3-5/

On Tue, Dec 22, 2015 at 5:35 PM, Nathaniel J. Smith <
notifications@github.com> wrote:

Does this actually work? I can't see how this can possibly work --
vcruntime140.dll does not contain the C runtime.


Reply to this email directly or view it on GitHub
#6875 (comment).

@njsmith

njsmith commented Dec 24, 2015

Copy link
Copy Markdown
Member

Unfortunately, linking to ucrtbase.dll directly is definitely wrong -- there are special new rules you have to follow to correctly link to the new CRT. Quoting the stevedower.id.au link that you posted:

It’s very important to clarify here that the compatibility guarantees only hold when linked through ucrt.lib. The public exports of ucrtbase.dll may change at any time, but linking through ucrt.lib uses API Sets to provide cross-version compatibility. Using the exports of ucrtbase.dll directly is not supported.

We're actually right now discussing how to get this right with the UCRT designers at MS, so it will happen (see also https://mingwpy.github.io), but I'm going to close this PR for now until the mingw-w64 side of things has been sorted out. Thanks for your efforts, and sorry that this is such a mess... we're working on it :-)

@njsmith njsmith closed this Dec 24, 2015
@tharen

tharen commented Dec 24, 2015

Copy link
Copy Markdown
Author

OK. I caught that bit about linking ucrtbase after the fact. Nothing is
ever as simple as it seems. Thanks for the feedback!
On Dec 23, 2015 11:04 PM, "Nathaniel J. Smith" notifications@github.com
wrote:

Closed #6875 #6875.


Reply to this email directly or view it on GitHub
#6875 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants