mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 14:22:28 +00:00
Decentralize Python native module linkage
We can now link even smaller Python binaries. For example, the hello.com program in the Python build directory is a compiled linked executable of hello.py which just prints hello world. Using decentralized sections, we can make that binary 1.9mb in size (noting that python.com is 6.3 megs!) This works for nontrivial programs too. For example, say we want an APE binary that's equivalent to python.com -m http.server. Our makefile now builds such a binary using the new launcher and it's only 3.2mb in size since Python sources get turned into ELF objects, which tell our linker that we need things like native hashing algorithm code.
This commit is contained in:
parent
dfa0359b50
commit
559b024e1d
129 changed files with 2798 additions and 13514 deletions
9
third_party/python/Modules/zipimport.c
vendored
9
third_party/python/Modules/zipimport.c
vendored
|
@ -40,6 +40,10 @@ PYTHON_PROVIDE("zipimport.ZipImportError");
|
|||
PYTHON_PROVIDE("zipimport._zip_directory_cache");
|
||||
PYTHON_PROVIDE("zipimport.zipimporter");
|
||||
|
||||
PYTHON_YOINK("encodings.ascii");
|
||||
PYTHON_YOINK("encodings.cp437");
|
||||
PYTHON_YOINK("encodings.utf_8");
|
||||
|
||||
#define IS_SOURCE 0x0
|
||||
#define IS_BYTECODE 0x1
|
||||
#define IS_PACKAGE 0x2
|
||||
|
@ -1598,3 +1602,8 @@ PyInit_zipimport(void)
|
|||
return NULL;
|
||||
return mod;
|
||||
}
|
||||
|
||||
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_zipimport = {
|
||||
"zipimport",
|
||||
PyInit_zipimport,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue