cosmopolitan/libc/isystem
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
..
arpa Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
linux Make improvements 2023-10-08 08:59:53 -07:00
net Get us closer to building busybox 2023-06-18 04:13:45 -07:00
netinet get rsync to build (#886) 2023-08-16 21:41:36 -07:00
sys Changes made for cosmocc builds (#908) 2023-10-09 14:39:02 -07:00
algorithm Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
alloca.h Remove some dead code 2023-07-03 02:48:29 -07:00
ammintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
any Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ar.h Remove some dead code 2023-07-03 02:48:29 -07:00
arm_acle.h Fix some more issues 2023-09-21 11:41:42 -07:00
arm_bf16.h Fix some more issues 2023-09-21 11:41:42 -07:00
arm_fp16.h Fix some more issues 2023-09-21 11:41:42 -07:00
arm_neon.h Fix some more issues 2023-09-21 11:41:42 -07:00
array Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
assert.h Further improve fatcosmocc 2023-08-13 01:51:39 -07:00
atomic Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
bit Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
bitset Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
byteswap.h Clean up more code 2023-06-18 01:00:05 -07:00
cassert Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ccomplex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cctype Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cerrno Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cfenv Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cfloat Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
charconv Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
chrono Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cinttypes Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ciso646 Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
climits Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
clocale Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
clzerointrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
cmath Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
codecvt Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
compare Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
complex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
complex.h Clean up more code 2023-06-18 01:00:05 -07:00
condition_variable Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cosmo.h Introduce posix_spawn_file_actions_addchdir_np() 2023-10-11 21:45:32 -07:00
cpio.h Clean up more code 2023-06-18 01:00:05 -07:00
cpuid.h Clean up more code 2023-06-18 01:00:05 -07:00
crypt.h Clean up more code 2023-06-18 01:00:05 -07:00
csetjmp Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
csignal Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdarg Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdbool Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstddef Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdint Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdio Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdlib Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstring Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ctgmath Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ctime Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ctype.h Clean up more code 2023-06-18 01:00:05 -07:00
cwchar Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cwctype Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
deque Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
dirent.h Clean up more code 2023-06-18 01:00:05 -07:00
dlfcn.h Introduce dlopen() support 2023-11-03 06:37:18 -07:00
elf.h Clean up more code 2023-06-18 01:00:05 -07:00
emmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
endian.h Clean up more code 2023-06-18 01:00:05 -07:00
err.h Clean up more code 2023-06-18 01:00:05 -07:00
errno.h Clean up more code 2023-06-18 01:00:05 -07:00
exception Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
execution Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
fcntl.h Clean up more code 2023-06-18 01:00:05 -07:00
features.h Clean up more code 2023-06-18 01:00:05 -07:00
fenv.h Clean up more code 2023-06-18 01:00:05 -07:00
filesystem Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
float.h Clean up more code 2023-06-18 01:00:05 -07:00
fnmatch.h Clean up more code 2023-06-18 01:00:05 -07:00
forward_list Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
fstream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ftw.h Make fixes and improvements 2023-07-09 05:21:11 -07:00
functional Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
getopt.h Fix getopt again 2023-08-15 20:06:19 -07:00
glob.h Clean up more code 2023-06-18 01:00:05 -07:00
grp.h Clean up more code 2023-06-18 01:00:05 -07:00
iconv.h Clean up more code 2023-06-18 01:00:05 -07:00
ifaddrs.h Introduce getifaddrs() 2023-11-02 08:33:03 -07:00
immintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
initializer_list Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
inttypes.h Clean up more code 2023-06-18 01:00:05 -07:00
iomanip Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ios Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iosfwd Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iostream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iso646.h Clean up more code 2023-06-18 01:00:05 -07:00
istream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iterator Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
langinfo.h Clean up more code 2023-06-18 01:00:05 -07:00
libgen.h Implement more toolchain fixes 2023-06-18 05:39:31 -07:00
limits Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
limits.h Clean up more code 2023-06-18 01:00:05 -07:00
list Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
locale Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
locale.h Clean up more code 2023-06-18 01:00:05 -07:00
malloc.h Clean up more code 2023-06-18 01:00:05 -07:00
map Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
math.h Clean up more code 2023-06-18 01:00:05 -07:00
memory Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
memory.h Clean up more code 2023-06-18 01:00:05 -07:00
mm3dnow.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
mm_malloc.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
mmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
mntent.h Make some foss compatibility improvements 2022-10-14 13:59:34 -07:00
monetary.h Greatly expand system() shell code features 2022-10-11 21:30:31 -07:00
mutex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
mwaitxintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
netdb.h Get us closer to building busybox 2023-06-18 04:13:45 -07:00
new Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
nl_types.h Fold LIBC_UNICODE into LIBC_STR 2022-08-13 08:42:32 -07:00
nmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
nsync.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_atomic.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_counter.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_cv.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_debug.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_mu.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_mu_wait.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_note.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_once.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_time.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_waiter.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
numeric Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
optional Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ostream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
paths.h Initial import 2020-06-15 07:18:57 -07:00
pmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
poll.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
popcntintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
pthread.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
pwd.h Fix isystem headers including wrong files (#108) 2021-03-06 21:06:29 -08:00
queue Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
random Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ratio Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
regex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
regex.h Initial import 2020-06-15 07:18:57 -07:00
sched.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
scoped_allocator Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
search.h Add tsearch from Musl Libc (#912) 2023-10-15 16:50:54 -07:00
semaphore.h Add posix semaphores support 2022-10-14 09:21:02 -07:00
set Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
setjmp.h Clean up more code 2023-06-18 01:00:05 -07:00
sgxintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
shared_mutex Introduce libcxx <shared_mutex> 2023-10-31 21:57:28 -07:00
signal.h Simplify cosmocc builds (#863) 2023-07-23 11:11:08 -07:00
smmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
span Make some fixes for libcxx 2023-07-07 19:35:58 -07:00
spawn.h Make improvements 2023-09-18 21:04:47 -07:00
sstream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
stack Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
stdalign.h Clean up more code 2023-06-18 01:00:05 -07:00
stdarg.h Make the Windows Console work better 2023-09-07 18:27:22 -07:00
stdatomic.h Clean up more code 2023-06-18 01:00:05 -07:00
stdbool.h Make fatcosmocc good enough to build ncurses 6.4 2023-08-12 22:30:05 -07:00
stdc-predef.h Initial import 2020-06-15 07:18:57 -07:00
stdckdint.h Clean up more code 2023-06-18 01:00:05 -07:00
stddef.h Clean up more code 2023-06-18 01:00:05 -07:00
stdexcept Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
stdint.h Clean up more code 2023-06-18 01:00:05 -07:00
stdio.h Make improvements 2023-09-06 12:34:59 -07:00
stdio_ext.h Clean up more code 2023-06-18 01:00:05 -07:00
stdlib.h Make improvements 2023-09-06 12:34:59 -07:00
stdnoreturn.h Clean up more code 2023-06-18 01:00:05 -07:00
streambuf Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
string Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
string.h Clean up more code 2023-06-18 01:00:05 -07:00
string_view Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
strings.h Clean up more code 2023-06-18 01:00:05 -07:00
strstream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
sysexits.h Clean up more code 2023-06-18 01:00:05 -07:00
syslog.h Clean up more code 2023-06-18 01:00:05 -07:00
system_error Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
termios.h Clean up more code 2023-06-18 01:00:05 -07:00
tgmath.h Clean up more code 2023-06-18 01:00:05 -07:00
thread Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
time.h Clean up more code 2023-06-18 01:00:05 -07:00
tmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
tuple Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
type_traits Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
typeindex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
typeinfo Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
uchar.h Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ucontext.h Changes made for cosmocc builds (#908) 2023-10-09 14:39:02 -07:00
uio.h Improve isystem includes and magic numbers 2021-08-14 23:36:36 -07:00
unistd.h Changes made for cosmocc builds (#908) 2023-10-09 14:39:02 -07:00
unordered_map Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
unordered_set Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
utility Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
utime.h Clean up more code 2023-06-18 01:00:05 -07:00
utmp.h Clean up more code 2023-06-18 01:00:05 -07:00
utmpx.h Clean up more code 2023-06-18 01:00:05 -07:00
valarray Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
variant Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
vector Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
version Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
wait.h Clean up more code 2023-06-18 01:00:05 -07:00
wchar.h Add Cosmopolitan to uname() 2023-09-21 23:51:55 -07:00
wctype.h Clean up more code 2023-06-18 01:00:05 -07:00
winternl.h Restore strict header checking 2022-08-13 16:02:01 -07:00
wmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
x86intrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
xmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00