2020-06-15 14:18:57 +00:00
|
|
|
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
|
|
|
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
|
|
|
#
|
|
|
|
# SYNOPSIS
|
|
|
|
#
|
|
|
|
# Freestanding Hermetically-Sealed Monolithic Repository
|
|
|
|
#
|
|
|
|
# REQUIREMENTS
|
|
|
|
#
|
|
|
|
# You can run your programs on any operating system, but you have
|
|
|
|
# to build them on Linux 2.6+ (or WSL) using GNU Make. A modern C
|
|
|
|
# compiler that's statically-linked comes included as a courtesy.
|
|
|
|
#
|
|
|
|
# EXAMPLES
|
|
|
|
#
|
|
|
|
# # build and run everything
|
|
|
|
# make -j8 -O
|
|
|
|
# make -j8 -O MODE=dbg
|
|
|
|
# make -j8 -O MODE=opt
|
|
|
|
# make -j8 -O MODE=rel
|
|
|
|
# make -j8 -O MODE=tiny
|
|
|
|
#
|
|
|
|
# # build individual target
|
|
|
|
# make -j8 -O o//examples/hello.com
|
|
|
|
# o//examples/hello.com
|
|
|
|
#
|
|
|
|
# # view source
|
|
|
|
# less examples/hello.c
|
|
|
|
#
|
|
|
|
# # view binary
|
|
|
|
# o//tool/viz/bing.com o//examples/hello.com |
|
|
|
|
# o//tool/viz/fold.com
|
|
|
|
#
|
|
|
|
# # view transitive closure of legalese
|
|
|
|
# o//tool/viz/bing.com -n o//examples/hello.com |
|
|
|
|
# o//tool/viz/fold.com
|
|
|
|
#
|
|
|
|
# # basic debugging
|
|
|
|
# make -j8 -O MODE=dbg o/dbg/examples/crashreport.com
|
2022-04-17 05:09:36 +00:00
|
|
|
# o/examples/crashreport.com
|
2020-06-15 14:18:57 +00:00
|
|
|
# less examples/crashreport.c
|
|
|
|
#
|
2021-03-03 22:30:25 +00:00
|
|
|
# # extremely tiny binaries
|
2020-06-15 14:18:57 +00:00
|
|
|
# make -j8 -O MODE=tiny \
|
2020-06-16 02:01:28 +00:00
|
|
|
# LDFLAGS+=-s \
|
|
|
|
# CPPFLAGS+=-DIM_FEELING_NAUGHTY \
|
|
|
|
# CPPFLAGS+=-DSUPPORT_VECTOR=0b00000001 \
|
2020-06-15 14:18:57 +00:00
|
|
|
# o/tiny/examples/hello4.elf
|
|
|
|
# ls -hal o/tiny/examples/hello4.elf
|
|
|
|
# o/tiny/examples/hello4.elf
|
|
|
|
#
|
|
|
|
# TROUBLESHOOTING
|
|
|
|
#
|
2021-02-07 14:11:44 +00:00
|
|
|
# make -j8 -O V=1 o//examples/hello.com
|
2020-06-15 14:18:57 +00:00
|
|
|
# make o//examples/life.elf -pn |& less
|
|
|
|
# etc.
|
|
|
|
#
|
|
|
|
# SEE ALSO
|
|
|
|
#
|
|
|
|
# build/config.mk
|
|
|
|
|
2022-07-21 16:16:38 +00:00
|
|
|
SHELL = build/bootstrap/cocmd.com
|
2022-11-04 08:04:43 +00:00
|
|
|
MAKEFLAGS += --no-builtin-rules
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
.FEATURES: output-sync
|
2023-06-18 08:23:54 +00:00
|
|
|
.PHONY: all o bins check test depend tags aarch64 clean
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-09-13 11:14:20 +00:00
|
|
|
ifneq ($(m),)
|
|
|
|
ifeq ($(MODE),)
|
|
|
|
MODE := $(m)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2023-10-15 03:57:15 +00:00
|
|
|
UNAME_M = $(shell uname -m)
|
|
|
|
UNAME_S = $(shell uname -s)
|
|
|
|
|
|
|
|
# apple still distributes a 17 year old version of gnu make
|
|
|
|
ifeq ($(MAKE_VERSION), 3.81)
|
|
|
|
$(error please use build/bootstrap/make.com)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# provide instructions to non-linux users on unbundling gcc
|
|
|
|
ifeq ($(TOOLCHAIN),) # if TOOLCHAIN isn't defined
|
|
|
|
ifeq ("$(wildcard o/third_party/gcc/bin/x86_64-linux-cosmo-*)","") # if our gcc isn't unbundled
|
|
|
|
ifneq ($(UNAME_M)-$(UNAME_S), x86_64-Linux) # if this is not amd64 linux
|
2023-11-05 23:51:28 +00:00
|
|
|
$(error you need to download https://justine.lol/cosmocc-0.0.18.zip and unzip it inside the cosmo directory)
|
2023-10-15 03:57:15 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# the default build modes is empty string
|
|
|
|
# on x86_64 hosts, MODE= is the same as MODE=x86_64
|
|
|
|
# on aarch64 hosts, MODE= is changed to MODE=aarch64
|
|
|
|
ifeq ($(MODE),)
|
|
|
|
ifeq ($(UNAME_M),arm64)
|
|
|
|
MODE := aarch64
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_M),aarch64)
|
|
|
|
MODE := aarch64
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# primary build rules
|
2020-06-15 14:18:57 +00:00
|
|
|
all: o
|
2022-03-21 10:46:16 +00:00
|
|
|
o: o/$(MODE)
|
|
|
|
o/$(MODE): \
|
|
|
|
o/$(MODE)/ape \
|
2020-12-19 19:21:04 +00:00
|
|
|
o/$(MODE)/dsp \
|
|
|
|
o/$(MODE)/net \
|
|
|
|
o/$(MODE)/libc \
|
|
|
|
o/$(MODE)/test \
|
|
|
|
o/$(MODE)/tool \
|
|
|
|
o/$(MODE)/examples \
|
2020-06-15 14:18:57 +00:00
|
|
|
o/$(MODE)/third_party
|
|
|
|
|
2023-10-15 03:57:15 +00:00
|
|
|
# check if we're using o//third_party/make/make.com
|
|
|
|
# we added sandboxing to guarantee cosmo's makefile is hermetic
|
|
|
|
# it also shaves away 200ms of startup latency with native $(uniq)
|
2023-07-24 00:07:38 +00:00
|
|
|
ifneq ($(LANDLOCKMAKE_VERSION),)
|
2023-10-15 03:57:15 +00:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
2023-07-24 00:07:38 +00:00
|
|
|
ifeq ($(wildcard /usr/bin/ape),)
|
2023-07-28 10:56:56 +00:00
|
|
|
$(warning please run ape/apeinstall.sh if you intend to use landlock make)
|
|
|
|
$(shell sleep .5)
|
2023-07-24 00:07:38 +00:00
|
|
|
endif
|
2023-10-15 03:57:15 +00:00
|
|
|
endif
|
2023-07-08 13:58:21 +00:00
|
|
|
ifeq ($(USE_SYSTEM_TOOLCHAIN),)
|
2022-08-11 04:24:31 +00:00
|
|
|
.STRICT = 1
|
2023-06-08 11:37:05 +00:00
|
|
|
endif
|
2023-07-24 00:07:38 +00:00
|
|
|
endif
|
2023-06-08 11:37:05 +00:00
|
|
|
|
2023-10-15 03:57:15 +00:00
|
|
|
.PLEDGE += stdio rpath wpath cpath fattr proc
|
|
|
|
.UNVEIL += \
|
2023-09-11 20:51:37 +00:00
|
|
|
libc/integral \
|
|
|
|
libc/stdbool.h \
|
|
|
|
libc/disclaimer.inc \
|
|
|
|
rwc:/dev/shm \
|
|
|
|
rx:build/bootstrap \
|
|
|
|
rx:o/third_party/gcc \
|
|
|
|
r:build/portcosmo.h \
|
|
|
|
/proc/stat \
|
|
|
|
rw:/dev/null \
|
|
|
|
rw:/dev/full \
|
|
|
|
w:o/stack.log \
|
|
|
|
/etc/hosts \
|
|
|
|
~/.runit.psk \
|
|
|
|
/proc/self/status \
|
|
|
|
rx:/usr/bin/qemu-aarch64 \
|
|
|
|
rx:o/third_party/qemu/qemu-aarch64 \
|
2022-09-05 15:26:03 +00:00
|
|
|
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
2022-08-11 04:24:31 +00:00
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
PKGS =
|
|
|
|
|
2021-02-03 14:22:51 +00:00
|
|
|
-include ~/.cosmo.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include build/functions.mk #─┐
|
2021-02-03 14:22:51 +00:00
|
|
|
include build/definitions.mk # ├──META
|
|
|
|
include build/config.mk # │ You can build
|
|
|
|
include build/rules.mk # │ You can topologically order
|
2023-06-18 07:55:09 +00:00
|
|
|
include build/online.mk #─┘
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/nexgen32e/nexgen32e.mk #─┐
|
2021-02-03 14:22:51 +00:00
|
|
|
include libc/sysv/sysv.mk # ├──SYSTEM SUPPORT
|
|
|
|
include libc/nt/nt.mk # │ You can do math
|
|
|
|
include libc/intrin/intrin.mk # │ You can use the stack
|
2023-07-06 16:07:42 +00:00
|
|
|
include third_party/compiler_rt/compiler_rt.mk # │ You can manipulate arrays
|
|
|
|
include libc/tinymath/tinymath.mk # │ You can issue raw system calls
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/str/str.mk # │
|
|
|
|
include third_party/xed/xed.mk # │
|
2023-03-06 07:52:17 +00:00
|
|
|
include third_party/puff/puff.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/elf/elf.mk # │
|
2021-02-03 14:22:51 +00:00
|
|
|
include ape/ape.mk # │
|
2022-09-07 01:41:08 +00:00
|
|
|
include libc/fmt/fmt.mk # │
|
2023-10-25 21:32:20 +00:00
|
|
|
include libc/vga/vga.mk # │
|
|
|
|
include libc/irq/irq.mk #─┘
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/calls/calls.mk #─┐
|
2023-10-25 21:32:20 +00:00
|
|
|
include libc/irq/irq.mk # ├──SYSTEMS RUNTIME
|
|
|
|
include third_party/nsync/nsync.mk # │ You can issue system calls
|
|
|
|
include libc/runtime/runtime.mk # │
|
2023-11-03 13:04:13 +00:00
|
|
|
include libc/dlopen/dlopen.mk # │
|
2023-10-25 21:32:20 +00:00
|
|
|
include third_party/double-conversion/dc.mk # │
|
2023-08-13 05:30:05 +00:00
|
|
|
include libc/crt/crt.mk # │
|
2021-02-03 14:22:51 +00:00
|
|
|
include third_party/dlmalloc/dlmalloc.mk #─┘
|
|
|
|
include libc/mem/mem.mk #─┐
|
2023-02-23 14:24:49 +00:00
|
|
|
include third_party/gdtoa/gdtoa.mk # ├──DYNAMIC RUNTIME
|
|
|
|
include third_party/nsync/mem/mem.mk # │ You can now use stdio
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
include libc/proc/proc.mk # │ You can now use threads
|
|
|
|
include libc/thread/thread.mk # │ You can now use processes
|
|
|
|
include tool/hello/hello.mk # │ You can finally call malloc()
|
2023-08-31 22:17:35 +00:00
|
|
|
include third_party/zlib/zlib.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/stdio/stdio.mk # │
|
2023-06-17 17:13:50 +00:00
|
|
|
include libc/time/time.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include net/net.mk # │
|
2023-04-27 12:42:10 +00:00
|
|
|
include third_party/vqsort/vqsort.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/log/log.mk # │
|
2023-06-18 11:02:01 +00:00
|
|
|
include third_party/getopt/getopt.mk # │
|
2021-09-07 00:36:47 +00:00
|
|
|
include third_party/bzip2/bzip2.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include dsp/core/core.mk # │
|
2023-07-08 13:58:21 +00:00
|
|
|
include third_party/musl/musl.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/x/x.mk # │
|
|
|
|
include third_party/stb/stb.mk # │
|
|
|
|
include dsp/scale/scale.mk # │
|
|
|
|
include dsp/mpeg/mpeg.mk # │
|
|
|
|
include dsp/dsp.mk # │
|
2022-05-12 19:16:25 +00:00
|
|
|
include third_party/zlib/gz/gz.mk # │
|
2023-04-27 09:56:41 +00:00
|
|
|
include third_party/intel/intel.mk # │
|
2023-04-29 03:25:53 +00:00
|
|
|
include third_party/aarch64/aarch64.mk # │
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/libc.mk #─┘
|
|
|
|
include libc/sock/sock.mk #─┐
|
2021-02-03 14:22:51 +00:00
|
|
|
include dsp/tty/tty.mk # ├──ONLINE RUNTIME
|
|
|
|
include libc/dns/dns.mk # │ You can communicate with the network
|
2021-06-24 19:31:26 +00:00
|
|
|
include net/http/http.mk # │
|
2021-07-08 04:44:27 +00:00
|
|
|
include third_party/mbedtls/mbedtls.mk # │
|
2023-07-08 09:40:17 +00:00
|
|
|
include third_party/libcxx/libcxx.mk # │
|
|
|
|
include third_party/ggml/ggml.mk # │
|
|
|
|
include third_party/radpajama/radpajama.mk # │
|
2021-07-08 04:44:27 +00:00
|
|
|
include net/https/https.mk # │
|
2021-06-24 19:31:26 +00:00
|
|
|
include third_party/regex/regex.mk #─┘
|
2022-06-09 13:33:31 +00:00
|
|
|
include third_party/tidy/tidy.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include third_party/third_party.mk
|
2022-10-08 04:29:40 +00:00
|
|
|
include third_party/nsync/testing/testing.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include libc/testlib/testlib.mk
|
|
|
|
include tool/viz/lib/vizlib.mk
|
2022-05-12 18:01:58 +00:00
|
|
|
include tool/args/args.mk
|
|
|
|
include test/tool/args/test.mk
|
2021-08-14 18:26:23 +00:00
|
|
|
include third_party/linenoise/linenoise.mk
|
2022-03-18 10:17:08 +00:00
|
|
|
include third_party/maxmind/maxmind.mk
|
2022-07-17 09:40:39 +00:00
|
|
|
include net/finger/finger.mk
|
2022-10-12 04:06:27 +00:00
|
|
|
include third_party/double-conversion/test/test.mk
|
2021-03-08 22:13:40 +00:00
|
|
|
include third_party/lua/lua.mk
|
2023-10-16 02:46:40 +00:00
|
|
|
include third_party/tree/tree.mk
|
2023-07-02 03:30:38 +00:00
|
|
|
include third_party/zstd/zstd.mk
|
2022-10-14 23:37:29 +00:00
|
|
|
include third_party/tr/tr.mk
|
2022-08-22 03:57:08 +00:00
|
|
|
include third_party/sed/sed.mk
|
2022-08-21 19:29:07 +00:00
|
|
|
include third_party/awk/awk.mk
|
2022-12-24 01:32:03 +00:00
|
|
|
include third_party/hiredis/hiredis.mk
|
2021-10-26 18:54:07 +00:00
|
|
|
include third_party/make/make.mk
|
2022-11-11 22:22:42 +00:00
|
|
|
include third_party/ctags/ctags.mk
|
2022-06-23 10:39:44 +00:00
|
|
|
include third_party/finger/finger.mk
|
2021-09-16 00:24:36 +00:00
|
|
|
include third_party/argon2/argon2.mk
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
include third_party/smallz4/smallz4.mk
|
2021-05-04 14:39:59 +00:00
|
|
|
include third_party/sqlite3/sqlite3.mk
|
2021-06-24 19:31:26 +00:00
|
|
|
include third_party/mbedtls/test/test.mk
|
2021-04-09 08:06:57 +00:00
|
|
|
include third_party/quickjs/quickjs.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include third_party/lz4cli/lz4cli.mk
|
2022-04-21 04:59:25 +00:00
|
|
|
include third_party/zip/zip.mk
|
2023-07-02 03:56:53 +00:00
|
|
|
include third_party/xxhash/xxhash.mk
|
2022-06-10 11:54:37 +00:00
|
|
|
include third_party/unzip/unzip.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include tool/build/lib/buildlib.mk
|
2020-12-19 19:21:04 +00:00
|
|
|
include third_party/chibicc/chibicc.mk
|
|
|
|
include third_party/chibicc/test/test.mk
|
2021-10-08 15:11:51 +00:00
|
|
|
include third_party/python/python.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include tool/build/build.mk
|
2022-12-22 00:12:02 +00:00
|
|
|
include tool/curl/curl.mk
|
2023-05-02 02:43:59 +00:00
|
|
|
include third_party/qemu/qemu.mk
|
2021-04-18 19:40:48 +00:00
|
|
|
include examples/examples.mk
|
2021-09-12 05:30:37 +00:00
|
|
|
include examples/pyapp/pyapp.mk
|
2022-06-11 16:27:14 +00:00
|
|
|
include examples/pylife/pylife.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include tool/decode/lib/decodelib.mk
|
|
|
|
include tool/decode/decode.mk
|
2022-03-17 21:12:41 +00:00
|
|
|
include tool/lambda/lib/lib.mk
|
|
|
|
include tool/lambda/lambda.mk
|
2022-04-08 03:30:22 +00:00
|
|
|
include tool/plinko/lib/lib.mk
|
|
|
|
include tool/plinko/plinko.mk
|
|
|
|
include test/tool/plinko/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include tool/net/net.mk
|
|
|
|
include tool/viz/viz.mk
|
|
|
|
include tool/tool.mk
|
2022-10-03 15:17:37 +00:00
|
|
|
include net/turfwar/turfwar.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/libc/tinymath/test.mk
|
|
|
|
include test/libc/intrin/test.mk
|
|
|
|
include test/libc/mem/test.mk
|
|
|
|
include test/libc/nexgen32e/test.mk
|
|
|
|
include test/libc/runtime/test.mk
|
2022-04-20 16:56:53 +00:00
|
|
|
include test/libc/thread/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/libc/sock/test.mk
|
|
|
|
include test/libc/str/test.mk
|
2021-09-28 05:58:51 +00:00
|
|
|
include test/libc/log/test.mk
|
2022-08-13 15:42:32 +00:00
|
|
|
include test/libc/str/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/libc/calls/test.mk
|
|
|
|
include test/libc/x/test.mk
|
|
|
|
include test/libc/xed/test.mk
|
|
|
|
include test/libc/fmt/test.mk
|
|
|
|
include test/libc/dns/test.mk
|
|
|
|
include test/libc/time/test.mk
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
include test/libc/proc/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/libc/stdio/test.mk
|
2020-11-25 16:19:00 +00:00
|
|
|
include test/libc/release/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/libc/test.mk
|
|
|
|
include test/net/http/test.mk
|
2021-07-19 21:55:20 +00:00
|
|
|
include test/net/https/test.mk
|
2022-07-17 09:40:39 +00:00
|
|
|
include test/net/finger/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/net/test.mk
|
|
|
|
include test/tool/build/lib/test.mk
|
|
|
|
include test/tool/build/test.mk
|
|
|
|
include test/tool/viz/lib/test.mk
|
|
|
|
include test/tool/viz/test.mk
|
2021-02-27 18:47:19 +00:00
|
|
|
include test/tool/net/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
include test/tool/test.mk
|
|
|
|
include test/dsp/core/test.mk
|
|
|
|
include test/dsp/scale/test.mk
|
|
|
|
include test/dsp/tty/test.mk
|
|
|
|
include test/dsp/test.mk
|
2020-06-18 23:14:47 +00:00
|
|
|
include examples/package/lib/build.mk
|
|
|
|
include examples/package/build.mk
|
2020-06-16 02:01:28 +00:00
|
|
|
#-φ-examples/package/new.sh
|
2020-06-16 13:38:43 +00:00
|
|
|
include test/test.mk
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-05-02 14:48:59 +00:00
|
|
|
OBJS = $(foreach x,$(PKGS),$($(x)_OBJS))
|
|
|
|
SRCS := $(foreach x,$(PKGS),$($(x)_SRCS))
|
|
|
|
HDRS := $(foreach x,$(PKGS),$($(x)_HDRS))
|
|
|
|
INCS = $(foreach x,$(PKGS),$($(x)_INCS))
|
|
|
|
BINS = $(foreach x,$(PKGS),$($(x)_BINS))
|
|
|
|
TESTS = $(foreach x,$(PKGS),$($(x)_TESTS))
|
|
|
|
CHECKS = $(foreach x,$(PKGS),$($(x)_CHECKS))
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
bins: $(BINS)
|
|
|
|
check: $(CHECKS)
|
2023-07-23 17:57:18 +00:00
|
|
|
test: $(TESTS)
|
2020-06-15 14:18:57 +00:00
|
|
|
depend: o/$(MODE)/depend
|
|
|
|
tags: TAGS HTAGS
|
|
|
|
|
|
|
|
o/$(MODE)/.x:
|
2022-05-25 18:31:08 +00:00
|
|
|
@$(COMPILE) -AMKDIR -tT$@ $(MKDIR) $(@D)
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2023-07-08 15:44:46 +00:00
|
|
|
o/$(MODE)/srcs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x)))) $(SRCS)
|
2021-10-14 00:27:13 +00:00
|
|
|
$(file >$@,$(SRCS))
|
2023-07-08 15:44:46 +00:00
|
|
|
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x)))) $(HDRS) $(INCS)
|
2021-10-14 00:27:13 +00:00
|
|
|
$(file >$@,$(HDRS) $(INCS))
|
2023-07-08 15:44:46 +00:00
|
|
|
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x)))) $(INCS) $(INCS)
|
2021-10-14 00:27:13 +00:00
|
|
|
$(file >$@,$(INCS))
|
2021-07-19 21:55:20 +00:00
|
|
|
o/$(MODE)/depend: o/$(MODE)/.x o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt o/$(MODE)/incs.txt $(SRCS) $(HDRS) $(INCS)
|
2023-11-10 12:14:27 +00:00
|
|
|
$(COMPILE) -AMKDEPS -L320 $(MKDEPS) -o $@ -s -r o/$(MODE)/ @o/$(MODE)/srcs.txt @o/$(MODE)/hdrs.txt @o/$(MODE)/incs.txt
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-10-14 00:27:13 +00:00
|
|
|
o/$(MODE)/srcs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
|
|
|
|
$(file >$@) $(foreach x,$(SRCS),$(file >>$@,$(x)))
|
|
|
|
o/$(MODE)/hdrs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
|
|
|
$(file >$@) $(foreach x,$(HDRS) $(INCS),$(file >>$@,$(x)))
|
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
TAGS: private .UNSANDBOXED = 1
|
2023-05-03 01:35:25 +00:00
|
|
|
TAGS: o/$(MODE)/srcs-old.txt $(SRCS) #o/$(MODE)/third_party/ctags/ctags.com
|
2022-05-25 18:31:08 +00:00
|
|
|
@$(RM) $@
|
2022-11-11 22:22:42 +00:00
|
|
|
@o/$(MODE)/third_party/ctags/ctags.com $(TAGSFLAGS) -L $< -o $@
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
HTAGS: private .UNSANDBOXED = 1
|
2023-07-08 15:44:46 +00:00
|
|
|
HTAGS: o/$(MODE)/hdrs-old.txt $(filter-out third_party/libcxx/%,$(HDRS)) #o/$(MODE)/third_party/ctags/ctags.com
|
2022-05-25 18:31:08 +00:00
|
|
|
@$(RM) $@
|
2022-11-11 22:22:42 +00:00
|
|
|
@build/htags o/$(MODE)/third_party/ctags/ctags.com -L $< -o $@
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
loc: private .UNSANDBOXED = 1
|
2020-06-21 07:10:11 +00:00
|
|
|
loc: o/$(MODE)/tool/build/summy.com
|
|
|
|
find -name \*.h -or -name \*.c -or -name \*.S | \
|
|
|
|
$(XARGS) wc -l | grep total | awk '{print $$1}' | $<
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
# PLEASE: MAINTAIN TOPOLOGICAL ORDER
|
|
|
|
# FROM HIGHEST LEVEL TO LOWEST LEVEL
|
|
|
|
COSMOPOLITAN_OBJECTS = \
|
2023-07-08 02:25:13 +00:00
|
|
|
TOOL_ARGS \
|
2022-09-13 08:46:29 +00:00
|
|
|
NET_HTTP \
|
|
|
|
LIBC_DNS \
|
|
|
|
LIBC_SOCK \
|
|
|
|
LIBC_NT_WS2_32 \
|
|
|
|
LIBC_NT_IPHLPAPI \
|
|
|
|
LIBC_X \
|
|
|
|
THIRD_PARTY_GETOPT \
|
|
|
|
LIBC_LOG \
|
|
|
|
LIBC_TIME \
|
|
|
|
THIRD_PARTY_MUSL \
|
2023-08-18 16:34:14 +00:00
|
|
|
THIRD_PARTY_ZLIB_GZ \
|
2022-09-13 08:46:29 +00:00
|
|
|
LIBC_STDIO \
|
|
|
|
THIRD_PARTY_GDTOA \
|
|
|
|
THIRD_PARTY_REGEX \
|
|
|
|
LIBC_THREAD \
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
LIBC_PROC \
|
2022-10-11 00:52:41 +00:00
|
|
|
THIRD_PARTY_NSYNC_MEM \
|
2022-09-13 08:46:29 +00:00
|
|
|
LIBC_MEM \
|
|
|
|
THIRD_PARTY_DLMALLOC \
|
2023-11-05 03:29:25 +00:00
|
|
|
LIBC_DLOPEN \
|
2022-09-13 08:46:29 +00:00
|
|
|
LIBC_RUNTIME \
|
|
|
|
THIRD_PARTY_NSYNC \
|
|
|
|
LIBC_ELF \
|
2023-10-25 21:32:20 +00:00
|
|
|
LIBC_IRQ \
|
2022-09-13 08:46:29 +00:00
|
|
|
LIBC_CALLS \
|
|
|
|
LIBC_SYSV_CALLS \
|
|
|
|
LIBC_VGA \
|
|
|
|
LIBC_NT_PSAPI \
|
|
|
|
LIBC_NT_POWRPROF \
|
|
|
|
LIBC_NT_PDH \
|
|
|
|
LIBC_NT_GDI32 \
|
|
|
|
LIBC_NT_COMDLG32 \
|
|
|
|
LIBC_NT_USER32 \
|
|
|
|
LIBC_NT_NTDLL \
|
|
|
|
LIBC_NT_ADVAPI32 \
|
2022-09-15 10:49:34 +00:00
|
|
|
LIBC_NT_SYNCHRONIZATION \
|
2022-09-13 08:46:29 +00:00
|
|
|
LIBC_FMT \
|
2023-08-18 16:34:14 +00:00
|
|
|
THIRD_PARTY_ZLIB \
|
2023-03-06 07:52:17 +00:00
|
|
|
THIRD_PARTY_PUFF \
|
2022-09-13 08:46:29 +00:00
|
|
|
THIRD_PARTY_COMPILER_RT \
|
|
|
|
LIBC_TINYMATH \
|
|
|
|
THIRD_PARTY_XED \
|
|
|
|
LIBC_STR \
|
|
|
|
LIBC_SYSV \
|
|
|
|
LIBC_INTRIN \
|
|
|
|
LIBC_NT_KERNEL32 \
|
|
|
|
LIBC_NEXGEN32E
|
2020-08-25 11:23:25 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
COSMOPOLITAN_HEADERS = \
|
|
|
|
APE \
|
|
|
|
LIBC \
|
|
|
|
LIBC_CALLS \
|
|
|
|
LIBC_DNS \
|
|
|
|
LIBC_ELF \
|
|
|
|
LIBC_FMT \
|
|
|
|
LIBC_INTRIN \
|
|
|
|
LIBC_LOG \
|
|
|
|
LIBC_MEM \
|
|
|
|
LIBC_NEXGEN32E \
|
|
|
|
LIBC_NT \
|
|
|
|
LIBC_RUNTIME \
|
|
|
|
LIBC_SOCK \
|
|
|
|
LIBC_STDIO \
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
LIBC_PROC \
|
2022-09-13 08:46:29 +00:00
|
|
|
THIRD_PARTY_NSYNC \
|
|
|
|
THIRD_PARTY_XED \
|
|
|
|
LIBC_STR \
|
|
|
|
LIBC_SYSV \
|
|
|
|
LIBC_THREAD \
|
|
|
|
LIBC_TIME \
|
|
|
|
LIBC_TINYMATH \
|
|
|
|
LIBC_X \
|
|
|
|
LIBC_VGA \
|
|
|
|
NET_HTTP \
|
2023-07-08 02:25:13 +00:00
|
|
|
TOOL_ARGS \
|
2022-09-13 08:46:29 +00:00
|
|
|
THIRD_PARTY_DLMALLOC \
|
|
|
|
THIRD_PARTY_GDTOA \
|
|
|
|
THIRD_PARTY_GETOPT \
|
|
|
|
THIRD_PARTY_MUSL \
|
2020-08-25 11:23:25 +00:00
|
|
|
THIRD_PARTY_REGEX
|
|
|
|
|
2023-01-05 20:20:52 +00:00
|
|
|
o/$(MODE)/cosmopolitan.a: \
|
2021-10-14 00:27:13 +00:00
|
|
|
$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_A_OBJS))
|
|
|
|
|
2022-07-21 16:16:38 +00:00
|
|
|
o/cosmopolitan.h: \
|
|
|
|
o/$(MODE)/tool/build/rollup.com \
|
|
|
|
libc/integral/normalize.inc \
|
|
|
|
$(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS)) \
|
|
|
|
$(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_INCS))
|
2022-08-09 13:28:41 +00:00
|
|
|
$(file >$(TMPDIR)/$(subst /,_,$@),libc/integral/normalize.inc $(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS)))
|
2023-08-14 03:31:27 +00:00
|
|
|
@$(ECHO) '#ifndef __STRICT_ANSI__' >$@
|
|
|
|
@$(ECHO) '#define _COSMO_SOURCE' >>$@
|
|
|
|
@$(ECHO) '#endif' >>$@
|
2023-06-10 01:11:53 +00:00
|
|
|
@$(COMPILE) -AROLLUP -T$@ o/$(MODE)/tool/build/rollup.com @$(TMPDIR)/$(subst /,_,$@) >>$@
|
2020-08-25 11:23:25 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
o/cosmopolitan.html: private .UNSANDBOXED = 1
|
2020-12-28 01:05:03 +00:00
|
|
|
o/cosmopolitan.html: \
|
|
|
|
o/$(MODE)/third_party/chibicc/chibicc.com.dbg \
|
2022-08-07 12:59:53 +00:00
|
|
|
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))) \
|
|
|
|
$(SRCS) \
|
|
|
|
$(HDRS)
|
2022-08-09 13:28:41 +00:00
|
|
|
$(file >$(TMPDIR)/$(subst /,_,$@),$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))))
|
2020-12-28 01:05:03 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/chibicc.com.dbg -J \
|
|
|
|
-fno-common -include libc/integral/normalize.inc -o $@ \
|
2023-07-30 18:05:05 +00:00
|
|
|
-DCOSMO @$(TMPDIR)/$(subst /,_,$@)
|
2020-12-26 10:09:07 +00:00
|
|
|
|
2021-02-04 01:48:59 +00:00
|
|
|
$(SRCS): \
|
|
|
|
libc/integral/normalize.inc \
|
|
|
|
libc/integral/c.inc \
|
|
|
|
libc/integral/cxx.inc \
|
|
|
|
libc/integral/cxxtypescompat.inc \
|
|
|
|
libc/integral/lp64arg.inc \
|
|
|
|
libc/integral/lp64.inc
|
|
|
|
|
2023-07-27 21:09:07 +00:00
|
|
|
ifeq ($(ARCH), x86_64)
|
2023-08-12 05:52:11 +00:00
|
|
|
TOOLCHAIN_ARTIFACTS = \
|
|
|
|
o/cosmopolitan.h \
|
2023-08-15 05:22:58 +00:00
|
|
|
o/$(MODE)/ape/ape.lds \
|
2023-08-12 05:52:11 +00:00
|
|
|
o/$(MODE)/libc/crt/crt.o \
|
|
|
|
o/$(MODE)/ape/ape.elf \
|
|
|
|
o/$(MODE)/ape/ape.o \
|
|
|
|
o/$(MODE)/ape/ape-copy-self.o \
|
|
|
|
o/$(MODE)/ape/ape-no-modify-self.o \
|
|
|
|
o/$(MODE)/cosmopolitan.a \
|
|
|
|
o/$(MODE)/third_party/libcxx/libcxx.a \
|
|
|
|
o/$(MODE)/tool/build/march-native.com \
|
|
|
|
o/$(MODE)/tool/build/ar.com \
|
2023-08-12 23:44:04 +00:00
|
|
|
o/$(MODE)/tool/build/mktemper.com \
|
2023-08-12 05:52:11 +00:00
|
|
|
o/$(MODE)/tool/build/fixupobj.com \
|
|
|
|
o/$(MODE)/tool/build/zipcopy.com \
|
|
|
|
o/$(MODE)/tool/build/apelink.com \
|
|
|
|
o/$(MODE)/tool/build/pecheck.com
|
2023-07-27 21:09:07 +00:00
|
|
|
else
|
2023-08-12 05:52:11 +00:00
|
|
|
TOOLCHAIN_ARTIFACTS = \
|
|
|
|
o/$(MODE)/ape/ape.elf \
|
|
|
|
o/$(MODE)/ape/aarch64.lds \
|
|
|
|
o/$(MODE)/libc/crt/crt.o \
|
|
|
|
o/$(MODE)/cosmopolitan.a \
|
|
|
|
o/$(MODE)/third_party/libcxx/libcxx.a \
|
|
|
|
o/$(MODE)/tool/build/march-native.com \
|
|
|
|
o/$(MODE)/tool/build/fixupobj.com \
|
|
|
|
o/$(MODE)/tool/build/zipcopy.com
|
2023-07-27 21:09:07 +00:00
|
|
|
endif
|
2022-10-10 11:12:06 +00:00
|
|
|
|
2023-08-12 05:52:11 +00:00
|
|
|
.PHONY: toolchain
|
|
|
|
toolchain: $(TOOLCHAIN_ARTIFACTS)
|
|
|
|
|
|
|
|
.PHONY: clean_toolchain
|
|
|
|
clean_toolchain:
|
|
|
|
$(RM) $(TOOLCHAIN_ARTIFACTS)
|
|
|
|
|
2023-06-04 17:57:11 +00:00
|
|
|
aarch64: private .INTERNET = true
|
2023-06-03 15:12:13 +00:00
|
|
|
aarch64: private .UNSANDBOXED = true
|
|
|
|
aarch64:
|
|
|
|
$(MAKE) m=aarch64
|
|
|
|
|
2023-06-18 08:23:54 +00:00
|
|
|
clean:
|
2023-07-08 13:58:21 +00:00
|
|
|
$(RM) -r o
|
2023-06-18 08:23:54 +00:00
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
# UNSPECIFIED PREREQUISITES TUTORIAL
|
|
|
|
#
|
|
|
|
# A build rule must exist for all files that make needs to consider in
|
|
|
|
# order to build the requested goal. That includes input source files,
|
|
|
|
# even if the rule is empty and does nothing. Otherwise, the .DEFAULT
|
|
|
|
# rule gets triggered.
|
|
|
|
#
|
|
|
|
# This is a normal and neecssary behavior when source files get deleted.
|
|
|
|
# The build reacts automatically to this happening, by simply deleting
|
|
|
|
# and regenerating the dependency graph; so we can safely use wildcard.
|
|
|
|
#
|
|
|
|
# This is abnormal if it needs to keep doing that repeatedly. That can
|
|
|
|
# only mean the build config is broken.
|
|
|
|
#
|
|
|
|
# Also note that a suboptimal in-between state may exist, where running
|
|
|
|
# `make -pn` reveals rules being generated with the .DEFAULT target, but
|
|
|
|
# never get executed since they're not members of the transitive closure
|
|
|
|
# of `make all`. In that case the build config could be improved.
|
|
|
|
%.mk:
|
2020-08-25 11:23:25 +00:00
|
|
|
~/.cosmo.mk:
|
2020-06-15 14:18:57 +00:00
|
|
|
$(SRCS):
|
|
|
|
$(HDRS):
|
2021-02-02 11:45:31 +00:00
|
|
|
$(INCS):
|
2020-06-15 14:18:57 +00:00
|
|
|
.DEFAULT:
|
2022-11-11 22:22:42 +00:00
|
|
|
@$(ECHO)
|
|
|
|
@$(ECHO) NOTE: deleting o/$(MODE)/depend because of an unspecified prerequisite: $@
|
|
|
|
@$(ECHO)
|
2022-05-25 18:31:08 +00:00
|
|
|
$(RM) o/$(MODE)/depend
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
-include o/$(MODE)/depend
|