cosmopolitan/third_party/python/Python
Justine Tunney 5e8c928f1a
Introduce dlopen() support
Every program built using Cosmopolitan is statically-linked. However
there are some cases, e.g. GUIs and video drivers, where linking the
host platform libraries is desirable. So what we do in such cases is
launch a stub executable using the host platform's libc, and longjmp
back into this executable. The stub executable passes back to us the
platform-specific dlopen() implementation, which we shall then wrap.

Here's the list of platforms that are supported so far:

- x86-64 Linux w/ Glibc
- x86-64 Linux w/ Musl Libc
- x86-64 FreeBSD
- x86-64 Windows
- aarch64 Linux w/ Glibc
- aarch64 MacOS

What this means is your Cosmo programs can call foreign functions on
your host operating system. However, it's important to note that any
foreign library you link won't have the ability to call functions in
your Cosmopolitan program. For example it's now technically possible
that Lua can load a module, however that almost certainly won't work
since the Lua module won't have access to Cosmo's Lua API.

Kudos to @jacereda for figuring out how to do this.
2023-11-03 06:37:18 -07:00
..
clinic Python 3.7 METH_FASTCALL backport (#406) 2022-05-13 05:05:12 -07:00
_warnings.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
asdl.c Make whitespace changes 2021-08-13 03:20:45 -07:00
ast.c Fix bugs in cosmocc toolchain 2023-06-08 23:44:03 -07:00
atexit.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
bltinmodule.c Move importlib functions to within C (#408) 2022-05-26 23:20:59 -07:00
ceval.c Fix warnings 2023-09-01 20:50:18 -07:00
ceval_gil.inc quick addition of cosmo pthreads to python.com 2023-02-23 06:55:17 -08:00
codecs.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
compile.c Python 3.7 METH_FASTCALL backport (#406) 2022-05-13 05:05:12 -07:00
condvar.h Undiamond Python headers 2021-08-12 14:07:40 -07:00
cosmomodule.c Remove IMAGE_BASE_VIRTUAL 2023-09-12 01:21:36 -07:00
dtoa.c Unbloat the build 2022-08-11 00:15:29 -07:00
dynamic_annotations.c Make whitespace changes 2021-08-13 03:20:45 -07:00
dynload_dl.c Make numerous improvements 2021-09-28 01:52:34 -07:00
dynload_shlib.c Introduce dlopen() support 2023-11-03 06:37:18 -07:00
dynload_stub.c Make whitespace changes 2021-08-13 03:20:45 -07:00
dynload_win.c Make numerous improvements 2021-09-28 01:52:34 -07:00
errors.c Fix breakages in Linux-only build modes 2023-07-09 19:51:44 -07:00
fatality.c Fix warnings 2023-09-01 20:50:18 -07:00
fdisinteractive.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
fileutils.c Support non-blocking i/o across platforms 2023-07-23 02:56:47 -07:00
finalize.c quick addition of cosmo pthreads to python.com 2023-02-23 06:55:17 -08:00
flags.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
flushstdfiles.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
formatter_unicode.c Fold LIBC_UNICODE into LIBC_STR 2022-08-13 08:42:32 -07:00
frozen.c Revert "Make MODE=tiny not depend on default build" 2021-10-26 17:14:38 -07:00
frozenmain.c Fold LIBC_UNICODE into LIBC_STR 2022-08-13 08:42:32 -07:00
frozenmodules.c Improve Libc by making Python work even better 2021-08-18 22:16:23 -07:00
future.c Make numerous improvements 2021-09-28 01:52:34 -07:00
getargs.c Revert whitespace fixes to third_party (#501) 2022-07-21 21:46:07 -07:00
getcompiler.c Make numerous improvements 2021-09-28 01:52:34 -07:00
getcopyright.c Fix bugs in cosmocc toolchain 2023-06-08 23:44:03 -07:00
getopt.c Make numerous improvements 2021-09-28 01:52:34 -07:00
getplatform.c Make numerous improvements 2021-09-28 01:52:34 -07:00
getsig.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
getversion.c Make whitespace changes 2021-08-13 03:20:45 -07:00
graminit.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
import.c Fix warnings 2023-09-01 20:50:18 -07:00
importdl.c Make whitespace changes 2021-08-13 03:20:45 -07:00
importdl.h Undiamond Python headers 2021-08-12 14:07:40 -07:00
initfsencoding.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
initialized.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
initimport.c Fix warnings 2023-09-01 20:50:18 -07:00
initmain.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
initsigs.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
initsite.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
initstdio.c Reduce build graph by another eight percent 2022-08-13 13:11:56 -07:00
inittab.c Improve Libc by making Python work even better 2021-08-18 22:16:23 -07:00
makeopcodetargets.py Perform build and magnum tuning 2021-08-10 10:26:13 -07:00
marshal.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
modsupport.c Python 3.7 METH_FASTCALL backport (#406) 2022-05-13 05:05:12 -07:00
mysnprintf.c Make numerous improvements 2021-09-28 01:52:34 -07:00
mystrtoul.c Make fixes, improvements, and chibicc python bindings 2021-10-08 08:41:57 -07:00
opcode_targets.inc Python 3.7 METH_FASTCALL backport (#406) 2022-05-13 05:05:12 -07:00
peephole.c Make numerous improvements 2021-09-28 01:52:34 -07:00
progname.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
pyarena.c Make whitespace changes 2021-08-13 03:20:45 -07:00
pyfpe.c Make whitespace changes 2021-08-13 03:20:45 -07:00
pyhash.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
pylifecycle.c Fix warnings 2023-09-01 20:50:18 -07:00
pymath.c Port a lot more code to AARCH64 2023-05-14 09:37:26 -07:00
pystate.c Introduce dlopen() support 2023-11-03 06:37:18 -07:00
pystrcmp.c Make whitespace changes 2021-08-13 03:20:45 -07:00
pystrhex.c Make whitespace changes 2021-08-13 03:20:45 -07:00
pystrtod.c Fold LIBC_UNICODE into LIBC_STR 2022-08-13 08:42:32 -07:00
Python-ast.c Implement tree-shaking for Python sources 2021-09-05 01:20:03 -07:00
pythonhome.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
pythonrun.c Fold LIBC_UNICODE into LIBC_STR 2022-08-13 08:42:32 -07:00
pytime.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
random.c Fix warnings 2023-09-01 20:50:18 -07:00
recursive.c Make fixes, improvements, and chibicc python bindings 2021-10-08 08:41:57 -07:00
restoresigs.c Begin incorporating Python unit tests into build 2021-09-12 21:04:44 -07:00
sigcheck.c Make whitespace changes 2021-08-13 03:20:45 -07:00
structmember.c Make whitespace changes 2021-08-13 03:20:45 -07:00
symtable.c Make whitespace changes 2021-08-13 03:20:45 -07:00
sysmodule.c Make improvements 2023-09-18 21:04:47 -07:00
thread.c Fix Python stack overflow checking in MODE=dbg 2023-02-23 08:13:33 -08:00
thread_pthread.inc Fix Python stack overflow checking in MODE=dbg 2023-02-23 08:13:33 -08:00
traceback.c Make whitespace changes 2021-08-13 03:20:45 -07:00
wordcode_helpers.inc Make whitespace changes 2021-08-13 03:20:45 -07:00
xedmodule.c Unbreak the x86-64 build 2023-06-16 20:05:24 -07:00
xtermmodule.c Unbreak the x86-64 build 2023-06-16 20:05:24 -07:00