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 sw=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
|
2024-03-03 00:57:56 +00:00
|
|
|
# make -j8 -O o//examples/hello
|
|
|
|
# o//examples/hello
|
2020-06-15 14:18:57 +00:00
|
|
|
#
|
|
|
|
# # view source
|
|
|
|
# less examples/hello.c
|
|
|
|
#
|
|
|
|
# # view binary
|
2024-03-03 00:57:56 +00:00
|
|
|
# o//tool/viz/bing o//examples/hello |
|
|
|
|
# o//tool/viz/fold
|
2020-06-15 14:18:57 +00:00
|
|
|
#
|
|
|
|
# # view transitive closure of legalese
|
2024-03-03 00:57:56 +00:00
|
|
|
# o//tool/viz/bing -n o//examples/hello |
|
|
|
|
# o//tool/viz/fold
|
2020-06-15 14:18:57 +00:00
|
|
|
#
|
|
|
|
# # basic debugging
|
2024-03-03 00:57:56 +00:00
|
|
|
# make -j8 -O MODE=dbg o/dbg/examples/crashreport
|
|
|
|
# o/examples/crashreport
|
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
|
|
|
|
#
|
2024-03-03 00:57:56 +00:00
|
|
|
# make -j8 -O V=1 o//examples/hello
|
2020-06-15 14:18:57 +00:00
|
|
|
# make o//examples/life.elf -pn |& less
|
|
|
|
# etc.
|
|
|
|
#
|
|
|
|
# SEE ALSO
|
|
|
|
#
|
|
|
|
# build/config.mk
|
|
|
|
|
2024-03-03 00:57:56 +00:00
|
|
|
SHELL = build/bootstrap/cocmd
|
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
|
|
|
|
|
2024-01-05 15:58:07 +00:00
|
|
|
COMMA := ,
|
|
|
|
PWD := $(shell pwd)
|
|
|
|
|
2023-11-13 13:29:25 +00:00
|
|
|
# detect wsl2 running cosmopolitan binaries on the host by checking whether:
|
2024-03-03 00:57:56 +00:00
|
|
|
# - user ran build/bootstrap/make, in which case make's working directory is in wsl
|
|
|
|
# - user ran make, in which case cocmd's working directory is in wsl
|
2024-01-05 15:58:07 +00:00
|
|
|
ifneq ($(findstring //wsl.localhost/,$(CURDIR) $(PWD)),)
|
2023-11-13 13:29:25 +00:00
|
|
|
$(warning wsl2 interop is enabled)
|
|
|
|
$(error you need to run sudo sh -c 'echo -1 > /proc/sys/fs/binfmt_misc/WSLInterop')
|
|
|
|
endif
|
|
|
|
|
2023-11-13 13:53:10 +00:00
|
|
|
UNAME_M := $(shell uname -m)
|
|
|
|
UNAME_S := $(shell uname -s)
|
2023-10-15 03:57:15 +00:00
|
|
|
|
|
|
|
# apple still distributes a 17 year old version of gnu make
|
|
|
|
ifeq ($(MAKE_VERSION), 3.81)
|
2024-03-03 00:57:56 +00:00
|
|
|
$(error please use build/bootstrap/make)
|
2023-10-15 03:57:15 +00:00
|
|
|
endif
|
|
|
|
|
2024-01-05 15:58:07 +00:00
|
|
|
LC_ALL = C
|
|
|
|
SOURCE_DATE_EPOCH = 0
|
|
|
|
|
|
|
|
ARFLAGS = rcsD
|
|
|
|
ZFLAGS ?=
|
|
|
|
XARGS ?= xargs -P4 -rs8000
|
|
|
|
DOT ?= dot
|
|
|
|
CLANG = clang
|
|
|
|
TMPDIR = o/tmp
|
2024-07-20 18:21:26 +00:00
|
|
|
AR = $(BOOTSTRAP)/ar.ape
|
|
|
|
CP = $(BOOTSTRAP)/cp.ape
|
|
|
|
RM = $(BOOTSTRAP)/rm.ape -f
|
|
|
|
GZIP = $(BOOTSTRAP)/gzip.ape
|
|
|
|
ECHO = $(BOOTSTRAP)/echo.ape
|
|
|
|
CHMOD = $(BOOTSTRAP)/chmod.ape
|
|
|
|
TOUCH = $(BOOTSTRAP)/touch.ape
|
|
|
|
PKG = $(BOOTSTRAP)/package.ape
|
|
|
|
MKDEPS = $(BOOTSTRAP)/mkdeps
|
|
|
|
ZIPOBJ = $(BOOTSTRAP)/zipobj
|
|
|
|
ZIPCOPY = $(BOOTSTRAP)/zipcopy
|
|
|
|
PECHECK = $(BOOTSTRAP)/pecheck
|
|
|
|
FIXUPOBJ = $(BOOTSTRAP)/fixupobj
|
|
|
|
OBJBINCOPY = $(BOOTSTRAP)/objbincopy
|
2024-07-28 06:22:11 +00:00
|
|
|
MKDIR = $(BOOTSTRAP)/mkdir.ape -p
|
|
|
|
COMPILE = $(BOOTSTRAP)/compile.ape -V9 -M2048m -P8192 $(QUOTA)
|
2024-01-05 15:58:07 +00:00
|
|
|
|
2024-01-06 19:42:39 +00:00
|
|
|
# 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
|
|
|
|
|
2024-01-05 15:58:07 +00:00
|
|
|
ifneq ($(findstring aarch64,$(MODE)),)
|
|
|
|
ARCH = aarch64
|
2024-08-16 18:05:37 +00:00
|
|
|
HOSTS ?= pi pi5 studio freebsdarm
|
2024-01-05 15:58:07 +00:00
|
|
|
else
|
|
|
|
ARCH = x86_64
|
Release Cosmopolitan v3.3
This change upgrades to GCC 12.3 and GNU binutils 2.42. The GNU linker
appears to have changed things so that only a single de-duplicated str
table is present in the binary, and it gets placed wherever the linker
wants, regardless of what the linker script says. To cope with that we
need to stop using .ident to embed licenses. As such, this change does
significant work to revamp how third party licenses are defined in the
codebase, using `.section .notice,"aR",@progbits`.
This new GCC 12.3 toolchain has support for GNU indirect functions. It
lets us support __target_clones__ for the first time. This is used for
optimizing the performance of libc string functions such as strlen and
friends so far on x86, by ensuring AVX systems favor a second codepath
that uses VEX encoding. It shaves some latency off certain operations.
It's a useful feature to have for scientific computing for the reasons
explained by the test/libcxx/openmp_test.cc example which compiles for
fifteen different microarchitectures. Thanks to the upgrades, it's now
also possible to use newer instruction sets, such as AVX512FP16, VNNI.
Cosmo now uses the %gs register on x86 by default for TLS. Doing it is
helpful for any program that links `cosmo_dlopen()`. Such programs had
to recompile their binaries at startup to change the TLS instructions.
That's not great, since it means every page in the executable needs to
be faulted. The work of rewriting TLS-related x86 opcodes, is moved to
fixupobj.com instead. This is great news for MacOS x86 users, since we
previously needed to morph the binary every time for that platform but
now that's no longer necessary. The only platforms where we need fixup
of TLS x86 opcodes at runtime are now Windows, OpenBSD, and NetBSD. On
Windows we morph TLS to point deeper into the TIB, based on a TlsAlloc
assignment, and on OpenBSD/NetBSD we morph %gs back into %fs since the
kernels do not allow us to specify a value for the %gs register.
OpenBSD users are now required to use APE Loader to run Cosmo binaries
and assimilation is no longer possible. OpenBSD kernel needs to change
to allow programs to specify a value for the %gs register, or it needs
to stop marking executable pages loaded by the kernel as mimmutable().
This release fixes __constructor__, .ctor, .init_array, and lastly the
.preinit_array so they behave the exact same way as glibc.
We no longer use hex constants to define math.h symbols like M_PI.
2024-02-20 19:12:09 +00:00
|
|
|
HOSTS ?= freebsd rhel7 xnu openbsd netbsd win10
|
2023-10-15 03:57:15 +00:00
|
|
|
endif
|
2024-01-05 15:58:07 +00:00
|
|
|
|
|
|
|
ZIPOBJ_FLAGS += -a$(ARCH)
|
|
|
|
|
|
|
|
export ADDR2LINE
|
|
|
|
export LC_ALL
|
|
|
|
export MKDIR
|
|
|
|
export MODE
|
|
|
|
export SOURCE_DATE_EPOCH
|
|
|
|
export TMPDIR
|
|
|
|
|
2024-08-20 15:46:21 +00:00
|
|
|
COSMOCC = .cosmocc/3.7.1
|
2024-07-20 18:21:26 +00:00
|
|
|
BOOTSTRAP = $(COSMOCC)/bin
|
2024-01-05 15:58:07 +00:00
|
|
|
TOOLCHAIN = $(COSMOCC)/bin/$(ARCH)-linux-cosmo-
|
2024-08-20 15:46:21 +00:00
|
|
|
DOWNLOAD := $(shell build/download-cosmocc.sh $(COSMOCC) 3.7.1 13b65b0e659b493bd82f3d0a319d0265d66f849839e484aa2a54191024711e85)
|
2024-07-28 06:22:11 +00:00
|
|
|
|
|
|
|
IGNORE := $(shell $(MKDIR) $(TMPDIR))
|
2024-01-05 15:58:07 +00:00
|
|
|
|
|
|
|
AS = $(TOOLCHAIN)as
|
|
|
|
CC = $(TOOLCHAIN)gcc
|
|
|
|
CXX = $(TOOLCHAIN)g++
|
|
|
|
CXXFILT = $(TOOLCHAIN)c++filt
|
|
|
|
LD = $(TOOLCHAIN)ld.bfd
|
|
|
|
NM = $(TOOLCHAIN)nm
|
|
|
|
GCC = $(TOOLCHAIN)gcc
|
|
|
|
STRIP = $(TOOLCHAIN)strip
|
|
|
|
OBJCOPY = $(TOOLCHAIN)objcopy
|
|
|
|
OBJDUMP = $(TOOLCHAIN)objdump
|
|
|
|
ifneq ($(wildcard $(PWD)/$(TOOLCHAIN)addr2line),)
|
|
|
|
ADDR2LINE = $(PWD)/$(TOOLCHAIN)addr2line
|
|
|
|
else
|
|
|
|
ADDR2LINE = $(TOOLCHAIN)addr2line
|
2023-10-15 03:57:15 +00:00
|
|
|
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 \
|
2024-06-03 16:09:33 +00:00
|
|
|
o/$(MODE)/ctl \
|
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-11-29 04:04:15 +00:00
|
|
|
# TODO(jart): Make Emacs `C-c C-c` shortcut not need this.
|
|
|
|
.PHONY: o/$(MODE)/ o/$(MODE)/.
|
|
|
|
o/$(MODE)/: o/$(MODE)
|
2023-11-28 22:24:28 +00:00
|
|
|
o/$(MODE)/.: o/$(MODE)
|
|
|
|
|
2024-03-03 00:57:56 +00:00
|
|
|
# check if we're using o//third_party/make/make
|
2023-10-15 03:57:15 +00:00
|
|
|
# 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
|
2024-01-05 15:58:07 +00:00
|
|
|
ifneq ($(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 \
|
2024-02-25 22:57:28 +00:00
|
|
|
rwc:/dev/shm \
|
2024-02-01 11:39:46 +00:00
|
|
|
rx:.cosmocc \
|
2023-09-11 20:51:37 +00:00
|
|
|
rx:build/bootstrap \
|
|
|
|
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 #─┘
|
2023-11-28 19:21:08 +00:00
|
|
|
include libc/nexgen32e/BUILD.mk #─┐
|
|
|
|
include libc/sysv/BUILD.mk # ├──SYSTEM SUPPORT
|
|
|
|
include libc/nt/BUILD.mk # │ You can do math
|
|
|
|
include libc/intrin/BUILD.mk # │ You can use the stack
|
|
|
|
include third_party/compiler_rt/BUILD.mk # │ You can manipulate arrays
|
|
|
|
include libc/tinymath/BUILD.mk # │ You can issue raw system calls
|
|
|
|
include libc/str/BUILD.mk # │
|
|
|
|
include third_party/xed/BUILD.mk # │
|
|
|
|
include third_party/puff/BUILD.mk # │
|
|
|
|
include libc/elf/BUILD.mk # │
|
|
|
|
include ape/BUILD.mk # │
|
|
|
|
include libc/fmt/BUILD.mk # │
|
|
|
|
include libc/vga/BUILD.mk # │
|
|
|
|
include libc/irq/BUILD.mk #─┘
|
|
|
|
include libc/calls/BUILD.mk #─┐
|
|
|
|
include libc/irq/BUILD.mk # ├──SYSTEMS RUNTIME
|
|
|
|
include third_party/nsync/BUILD.mk # │ You can issue system calls
|
|
|
|
include libc/runtime/BUILD.mk # │
|
|
|
|
include libc/crt/BUILD.mk # │
|
|
|
|
include third_party/dlmalloc/BUILD.mk #─┘
|
|
|
|
include libc/mem/BUILD.mk #─┐
|
|
|
|
include third_party/gdtoa/BUILD.mk # ├──DYNAMIC RUNTIME
|
|
|
|
include third_party/nsync/mem/BUILD.mk # │ You can now use stdio
|
|
|
|
include libc/proc/BUILD.mk # │ You can now use threads
|
|
|
|
include libc/dlopen/BUILD.mk # │ You can now use processes
|
|
|
|
include libc/thread/BUILD.mk # │ You can finally call malloc()
|
|
|
|
include third_party/zlib/BUILD.mk # │
|
|
|
|
include libc/stdio/BUILD.mk # │
|
2023-12-29 06:58:17 +00:00
|
|
|
include tool/hello/BUILD.mk # │
|
2024-05-05 06:05:36 +00:00
|
|
|
include third_party/tz/BUILD.mk # │
|
2023-11-28 19:21:08 +00:00
|
|
|
include net/BUILD.mk # │
|
|
|
|
include third_party/vqsort/BUILD.mk # │
|
|
|
|
include libc/log/BUILD.mk # │
|
|
|
|
include third_party/getopt/BUILD.mk # │
|
|
|
|
include third_party/bzip2/BUILD.mk # │
|
|
|
|
include dsp/core/BUILD.mk # │
|
|
|
|
include third_party/zlib/gz/BUILD.mk # │
|
|
|
|
include third_party/intel/BUILD.mk # │
|
|
|
|
include third_party/aarch64/BUILD.mk # │
|
|
|
|
include libc/BUILD.mk #─┘
|
|
|
|
include libc/sock/BUILD.mk #─┐
|
2023-12-29 06:58:17 +00:00
|
|
|
include net/http/BUILD.mk # ├──ONLINE RUNTIME
|
|
|
|
include third_party/musl/BUILD.mk # │ You can communicate with the network
|
2023-12-09 04:03:03 +00:00
|
|
|
include libc/x/BUILD.mk # │
|
|
|
|
include dsp/scale/BUILD.mk # │
|
|
|
|
include dsp/mpeg/BUILD.mk # │
|
|
|
|
include dsp/tty/BUILD.mk # │
|
|
|
|
include dsp/BUILD.mk # │
|
|
|
|
include third_party/stb/BUILD.mk # │
|
2023-11-28 19:21:08 +00:00
|
|
|
include third_party/mbedtls/BUILD.mk # │
|
2023-12-10 15:28:01 +00:00
|
|
|
include third_party/ncurses/BUILD.mk # │
|
2023-12-11 13:59:20 +00:00
|
|
|
include third_party/readline/BUILD.mk # │
|
2024-01-08 16:45:10 +00:00
|
|
|
include third_party/libunwind/BUILD.mk # |
|
|
|
|
include third_party/libcxxabi/BUILD.mk # |
|
2024-07-01 12:40:38 +00:00
|
|
|
include third_party/double-conversion/BUILD.mk # │
|
2024-06-29 22:45:09 +00:00
|
|
|
include ctl/BUILD.mk # │
|
2023-11-28 19:21:08 +00:00
|
|
|
include third_party/libcxx/BUILD.mk # │
|
2024-01-29 05:57:40 +00:00
|
|
|
include third_party/openmp/BUILD.mk # │
|
2023-12-10 13:59:18 +00:00
|
|
|
include third_party/pcre/BUILD.mk # │
|
2023-12-10 16:01:37 +00:00
|
|
|
include third_party/less/BUILD.mk # │
|
2023-11-28 19:21:08 +00:00
|
|
|
include net/https/BUILD.mk # │
|
2024-07-23 10:16:17 +00:00
|
|
|
include third_party/regex/BUILD.mk #─┘
|
2023-11-28 19:21:08 +00:00
|
|
|
include third_party/tidy/BUILD.mk
|
|
|
|
include third_party/BUILD.mk
|
|
|
|
include third_party/nsync/testing/BUILD.mk
|
|
|
|
include libc/testlib/BUILD.mk
|
|
|
|
include tool/viz/lib/BUILD.mk
|
|
|
|
include tool/args/BUILD.mk
|
2024-02-25 22:57:28 +00:00
|
|
|
include test/math/BUILD.mk
|
2023-11-28 19:21:08 +00:00
|
|
|
include test/posix/BUILD.mk
|
2024-06-03 16:09:33 +00:00
|
|
|
include test/ctl/BUILD.mk
|
2024-01-09 17:51:59 +00:00
|
|
|
include test/libcxx/BUILD.mk
|
2023-11-28 19:21:08 +00:00
|
|
|
include test/tool/args/BUILD.mk
|
|
|
|
include third_party/linenoise/BUILD.mk
|
|
|
|
include third_party/maxmind/BUILD.mk
|
|
|
|
include net/finger/BUILD.mk
|
|
|
|
include third_party/double-conversion/test/BUILD.mk
|
|
|
|
include third_party/lua/BUILD.mk
|
|
|
|
include third_party/tree/BUILD.mk
|
|
|
|
include third_party/zstd/BUILD.mk
|
|
|
|
include third_party/tr/BUILD.mk
|
|
|
|
include third_party/sed/BUILD.mk
|
|
|
|
include third_party/awk/BUILD.mk
|
|
|
|
include third_party/hiredis/BUILD.mk
|
|
|
|
include third_party/make/BUILD.mk
|
|
|
|
include third_party/ctags/BUILD.mk
|
|
|
|
include third_party/finger/BUILD.mk
|
|
|
|
include third_party/argon2/BUILD.mk
|
|
|
|
include third_party/smallz4/BUILD.mk
|
|
|
|
include third_party/sqlite3/BUILD.mk
|
|
|
|
include third_party/mbedtls/test/BUILD.mk
|
|
|
|
include third_party/lz4cli/BUILD.mk
|
|
|
|
include third_party/zip/BUILD.mk
|
|
|
|
include third_party/xxhash/BUILD.mk
|
|
|
|
include third_party/unzip/BUILD.mk
|
|
|
|
include tool/build/lib/BUILD.mk
|
|
|
|
include third_party/chibicc/BUILD.mk
|
|
|
|
include third_party/chibicc/test/BUILD.mk
|
|
|
|
include third_party/python/BUILD.mk
|
|
|
|
include tool/build/BUILD.mk
|
|
|
|
include tool/curl/BUILD.mk
|
|
|
|
include third_party/qemu/BUILD.mk
|
2024-01-08 18:50:06 +00:00
|
|
|
include third_party/libcxxabi/test/BUILD.mk
|
2023-11-28 19:21:08 +00:00
|
|
|
include examples/BUILD.mk
|
|
|
|
include examples/pyapp/BUILD.mk
|
|
|
|
include examples/pylife/BUILD.mk
|
|
|
|
include tool/decode/lib/BUILD.mk
|
|
|
|
include tool/decode/BUILD.mk
|
|
|
|
include tool/lambda/lib/BUILD.mk
|
|
|
|
include tool/lambda/BUILD.mk
|
|
|
|
include tool/plinko/lib/BUILD.mk
|
|
|
|
include tool/plinko/BUILD.mk
|
|
|
|
include test/tool/plinko/BUILD.mk
|
|
|
|
include tool/net/BUILD.mk
|
|
|
|
include tool/viz/BUILD.mk
|
|
|
|
include tool/BUILD.mk
|
|
|
|
include net/turfwar/BUILD.mk
|
|
|
|
include test/libc/tinymath/BUILD.mk
|
|
|
|
include test/libc/intrin/BUILD.mk
|
|
|
|
include test/libc/mem/BUILD.mk
|
|
|
|
include test/libc/nexgen32e/BUILD.mk
|
|
|
|
include test/libc/runtime/BUILD.mk
|
|
|
|
include test/libc/thread/BUILD.mk
|
|
|
|
include test/libc/sock/BUILD.mk
|
|
|
|
include test/libc/str/BUILD.mk
|
|
|
|
include test/libc/log/BUILD.mk
|
|
|
|
include test/libc/str/BUILD.mk
|
|
|
|
include test/libc/calls/BUILD.mk
|
|
|
|
include test/libc/x/BUILD.mk
|
|
|
|
include test/libc/xed/BUILD.mk
|
|
|
|
include test/libc/fmt/BUILD.mk
|
|
|
|
include test/libc/time/BUILD.mk
|
|
|
|
include test/libc/proc/BUILD.mk
|
|
|
|
include test/libc/stdio/BUILD.mk
|
|
|
|
include test/libc/BUILD.mk
|
|
|
|
include test/net/http/BUILD.mk
|
|
|
|
include test/net/https/BUILD.mk
|
|
|
|
include test/net/finger/BUILD.mk
|
|
|
|
include test/net/BUILD.mk
|
|
|
|
include test/tool/build/lib/BUILD.mk
|
|
|
|
include test/tool/build/BUILD.mk
|
|
|
|
include test/tool/viz/lib/BUILD.mk
|
|
|
|
include test/tool/viz/BUILD.mk
|
|
|
|
include test/tool/net/BUILD.mk
|
|
|
|
include test/tool/BUILD.mk
|
|
|
|
include test/dsp/core/BUILD.mk
|
|
|
|
include test/dsp/scale/BUILD.mk
|
|
|
|
include test/dsp/tty/BUILD.mk
|
|
|
|
include test/dsp/BUILD.mk
|
|
|
|
include examples/package/lib/BUILD.mk
|
|
|
|
include examples/package/BUILD.mk
|
2020-06-16 02:01:28 +00:00
|
|
|
#-φ-examples/package/new.sh
|
2023-11-28 19:21:08 +00:00
|
|
|
include test/BUILD.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
|
2024-03-03 00:57:56 +00:00
|
|
|
TAGS: o/$(MODE)/srcs-old.txt $(SRCS) #o/$(MODE)/third_party/ctags/ctags
|
2022-05-25 18:31:08 +00:00
|
|
|
@$(RM) $@
|
2024-03-03 00:57:56 +00:00
|
|
|
@o/$(MODE)/third_party/ctags/ctags $(TAGSFLAGS) -L $< -o $@
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
HTAGS: private .UNSANDBOXED = 1
|
2024-03-03 00:57:56 +00:00
|
|
|
HTAGS: o/$(MODE)/hdrs-old.txt $(filter-out third_party/libcxx/%,$(HDRS)) #o/$(MODE)/third_party/ctags/ctags
|
2022-05-25 18:31:08 +00:00
|
|
|
@$(RM) $@
|
2024-03-03 00:57:56 +00:00
|
|
|
@build/htags o/$(MODE)/third_party/ctags/ctags -L $< -o $@
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-09-13 08:46:29 +00:00
|
|
|
loc: private .UNSANDBOXED = 1
|
2024-03-03 00:57:56 +00:00
|
|
|
loc: o/$(MODE)/tool/build/summy
|
2020-06-21 07:10:11 +00:00
|
|
|
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 = \
|
2024-07-20 23:43:48 +00:00
|
|
|
CTL \
|
|
|
|
THIRD_PARTY_DOUBLECONVERSION \
|
|
|
|
THIRD_PARTY_OPENMP \
|
2023-07-08 02:25:13 +00:00
|
|
|
TOOL_ARGS \
|
2022-09-13 08:46:29 +00:00
|
|
|
NET_HTTP \
|
|
|
|
LIBC_SOCK \
|
|
|
|
LIBC_NT_WS2_32 \
|
|
|
|
LIBC_NT_IPHLPAPI \
|
|
|
|
LIBC_X \
|
|
|
|
THIRD_PARTY_GETOPT \
|
|
|
|
LIBC_LOG \
|
2024-05-05 06:05:36 +00:00
|
|
|
THIRD_PARTY_TZ \
|
2022-09-13 08:46:29 +00:00
|
|
|
THIRD_PARTY_MUSL \
|
2023-08-18 16:34:14 +00:00
|
|
|
THIRD_PARTY_ZLIB_GZ \
|
2024-01-08 16:45:10 +00:00
|
|
|
THIRD_PARTY_LIBCXXABI \
|
2024-01-08 16:31:13 +00:00
|
|
|
THIRD_PARTY_LIBUNWIND \
|
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 \
|
2024-02-01 11:39:46 +00:00
|
|
|
LIBC_NT_BCRYPTPRIMITIVES \
|
2022-09-13 08:46:29 +00:00
|
|
|
LIBC_NT_KERNEL32 \
|
|
|
|
LIBC_NEXGEN32E
|
2020-08-25 11:23:25 +00:00
|
|
|
|
2023-11-12 06:32:12 +00:00
|
|
|
COSMOPOLITAN_H_PKGS = \
|
2022-09-13 08:46:29 +00:00
|
|
|
APE \
|
|
|
|
LIBC \
|
|
|
|
LIBC_CALLS \
|
|
|
|
LIBC_ELF \
|
|
|
|
LIBC_FMT \
|
2023-11-12 06:32:12 +00:00
|
|
|
LIBC_DLOPEN \
|
2022-09-13 08:46:29 +00:00
|
|
|
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_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 \
|
2023-11-15 18:48:31 +00:00
|
|
|
THIRD_PARTY_ZLIB \
|
2024-01-08 22:23:43 +00:00
|
|
|
THIRD_PARTY_ZLIB_GZ \
|
2020-08-25 11:23:25 +00:00
|
|
|
THIRD_PARTY_REGEX
|
|
|
|
|
2023-11-12 06:32:12 +00:00
|
|
|
COSMOCC_PKGS = \
|
|
|
|
$(COSMOPOLITAN_H_PKGS) \
|
2024-06-03 16:09:33 +00:00
|
|
|
CTL \
|
2023-11-11 22:04:26 +00:00
|
|
|
THIRD_PARTY_AARCH64 \
|
|
|
|
THIRD_PARTY_LIBCXX \
|
2024-01-08 22:23:43 +00:00
|
|
|
THIRD_PARTY_LIBCXXABI \
|
2024-01-29 23:45:10 +00:00
|
|
|
THIRD_PARTY_LIBUNWIND \
|
2024-01-29 05:57:40 +00:00
|
|
|
THIRD_PARTY_OPENMP \
|
2023-11-11 22:04:26 +00:00
|
|
|
THIRD_PARTY_INTEL
|
|
|
|
|
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))
|
|
|
|
|
2023-11-12 06:32:12 +00:00
|
|
|
COSMOCC_HDRS = \
|
|
|
|
$(wildcard libc/integral/*) \
|
|
|
|
$(foreach x,$(COSMOCC_PKGS),$($(x)_HDRS)) \
|
|
|
|
$(foreach x,$(COSMOCC_PKGS),$($(x)_INCS))
|
|
|
|
|
2024-07-31 08:02:24 +00:00
|
|
|
o/cosmocc.h.txt: Makefile libc $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x)))) $(HDRS) $(INCS)
|
2023-11-12 06:32:12 +00:00
|
|
|
$(file >$@, $(call uniq,$(COSMOCC_HDRS)))
|
|
|
|
|
|
|
|
COSMOPOLITAN_H_ROOT_HDRS = \
|
|
|
|
libc/integral/normalize.inc \
|
|
|
|
$(foreach x,$(COSMOPOLITAN_H_PKGS),$($(x)_HDRS))
|
2023-11-11 22:04:26 +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: \
|
2024-03-03 00:57:56 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/chibicc.dbg \
|
2022-08-07 12:59:53 +00:00
|
|
|
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))) \
|
2024-02-20 21:40:46 +00:00
|
|
|
$(filter-out %.cpp,$(filter-out %.cc,$(SRCS))) \
|
2022-08-07 12:59:53 +00:00
|
|
|
$(HDRS)
|
2024-02-20 21:40:46 +00:00
|
|
|
$(file >$(TMPDIR)/$(subst /,_,$@),$(filter-out %.cpp,$(filter-out %.cc,$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))))))
|
2024-03-03 00:57:56 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/chibicc.dbg -J \
|
2020-12-28 01:05:03 +00:00
|
|
|
-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 = \
|
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 \
|
2024-03-03 00:57:56 +00:00
|
|
|
o/$(MODE)/tool/build/march-native \
|
|
|
|
o/$(MODE)/tool/build/ar \
|
|
|
|
o/$(MODE)/tool/build/mktemper \
|
|
|
|
o/$(MODE)/tool/build/fixupobj \
|
|
|
|
o/$(MODE)/tool/build/zipcopy \
|
|
|
|
o/$(MODE)/tool/build/apelink \
|
|
|
|
o/$(MODE)/tool/build/pecheck
|
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 \
|
2024-03-03 00:57:56 +00:00
|
|
|
o/$(MODE)/tool/build/march-native \
|
|
|
|
o/$(MODE)/tool/build/fixupobj \
|
|
|
|
o/$(MODE)/tool/build/zipcopy
|
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
|