This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Link CRT Statically
Type: Stage:
Components: Distutils, Windows Versions: Python 2.4, Python 2.6, Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: tarek Nosy List: amaury.forgeotdarc, hankdane, loewis, tarek
Priority: normal Keywords:

Created on 2009-09-16 04:19 by hankdane, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg92663 - (view) Author: Henri Hein (hankdane) Date: 2009-09-16 04:19
Suggestion:  Link the CRT statically into Python26.dll/PythonNN.dll 
and compiled .PYD files, at least when using the Microsoft compiler.  

There has been a number of bugs related to the msvcrt.dll, 
msvcr90.dll, etc.  Many of these would go away if the CRT was 
statically linked into PythonNN.dll.  

The advantages of dynamically linking the CRT are not clear.  The 
binaries are decreased a bit in size, but this is countered by having 
to redistribute the CRT DLL.  

Switching to static linking is a little more work than just flipping a 
switch, as you have to compensate for some of the initialization work 
the DLL does, but it is both doable and worth doing.
msg92665 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-09-16 07:46
This can't possibly work. Extension modules that also link with the CRT 
will thus end with a separate copy of the CRT global state, causing 
crashes.
msg92739 - (view) Author: Henri Hein (hankdane) Date: 2009-09-17 02:55
If you do not *want* to change it, that is your prerogative, but it 
*can* definitely work.
msg92746 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-09-17 08:50
It will seem to work for simple scripts, but many extension modules
won't behave properly because:
- some API functions (PyFile_AsFile, many PyRun_*functions,
PyMarshal_*+FromFile) pass FILE* structures, which differ between
instances of the CRT.
- file descriptors, environment variables, locale settings, the errno
variable, are not shared.
- when a thread exits, it would have to free thread-local storage for
each CRT.

Python uses Ansi C, and has to use the same system as the extension
modules it wants to support. Linking statically with the CRT may be a
solution in specific cases, but not for the general python distribution.
msg92769 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-09-17 15:03
> If you do not *want* to change it, that is your prerogative, but it 
> *can* definitely work.

I don't believe it can work; Amaury has already given a number of
reasons. If you still believe otherwise, and want to see something
change, please try coming up with a patch.
msg92805 - (view) Author: Henri Hein (hankdane) Date: 2009-09-18 06:02
Right, I was thinking about rebuilding Python26.dll.  If we do go down 
that path, I will report the results.

Thanks for the feedback.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51168
2009-09-18 06:02:52hankdanesetmessages: + msg92805
2009-09-17 15:03:09loewissetmessages: + msg92769
2009-09-17 08:50:48amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg92746
2009-09-17 02:55:02hankdanesetmessages: + msg92739
2009-09-16 13:44:29georg.brandlsetstatus: open -> closed
resolution: rejected
2009-09-16 07:46:20loewissetnosy: + loewis
messages: + msg92665
2009-09-16 04:19:12hankdanecreate