2020-12-05 20:20:41 +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
|
|
|
|
#
|
|
|
|
# C Compiler Unit Tests
|
|
|
|
#
|
|
|
|
# OVERVIEW
|
|
|
|
#
|
|
|
|
# This makefile compiles and runs each test twice. The first with
|
|
|
|
# GCC-built chibicc, and a second time with chibicc-built chibicc
|
|
|
|
|
|
|
|
PKGS += THIRD_PARTY_CHIBICC_TEST
|
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_A = o/$(MODE)/third_party/chibicc/test/test.a
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_FILES := $(wildcard third_party/chibicc/test/*)
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_SRCS = $(filter %.c,$(THIRD_PARTY_CHIBICC_TEST_FILES))
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_SRCS_TEST = $(filter %_test.c,$(THIRD_PARTY_CHIBICC_TEST_SRCS))
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_HDRS = $(filter %.h,$(THIRD_PARTY_CHIBICC_TEST_FILES))
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_TESTS = $(THIRD_PARTY_CHIBICC_TEST_COMS:%=%.ok)
|
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_COMS = \
|
2022-08-06 10:51:50 +00:00
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_SRCS_TEST:%_test.c=o/$(MODE)/%_test.com)
|
2020-12-05 20:20:41 +00:00
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_OBJS = \
|
2022-08-06 10:51:50 +00:00
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_SRCS:%.c=o/$(MODE)/%.o)
|
2020-12-05 20:20:41 +00:00
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_BINS = \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_COMS) \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_COMS:%=%.dbg)
|
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_CHECKS = \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_COMS:%=%.runs) \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_HDRS:%=o/$(MODE)/%.ok)
|
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_DIRECTDEPS = \
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
LIBC_CALLS \
|
2020-12-05 20:20:41 +00:00
|
|
|
LIBC_FMT \
|
2021-01-16 20:05:41 +00:00
|
|
|
LIBC_INTRIN \
|
|
|
|
LIBC_MEM \
|
|
|
|
LIBC_NEXGEN32E \
|
|
|
|
LIBC_RUNTIME \
|
2020-12-05 20:20:41 +00:00
|
|
|
LIBC_STDIO \
|
2021-01-16 20:05:41 +00:00
|
|
|
LIBC_STR \
|
2020-12-05 20:20:41 +00:00
|
|
|
LIBC_STUBS \
|
2020-12-27 15:02:35 +00:00
|
|
|
LIBC_TINYMATH \
|
2021-01-16 20:05:41 +00:00
|
|
|
LIBC_UNICODE \
|
2020-12-09 12:00:48 +00:00
|
|
|
LIBC_X \
|
|
|
|
THIRD_PARTY_CHIBICC \
|
2020-12-05 20:20:41 +00:00
|
|
|
THIRD_PARTY_COMPILER_RT
|
|
|
|
|
|
|
|
THIRD_PARTY_CHIBICC_TEST_DEPS := \
|
|
|
|
$(call uniq,$(foreach x,$(THIRD_PARTY_CHIBICC_TEST_DIRECTDEPS),$($(x))))
|
|
|
|
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_A): \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_A).pkg \
|
2022-08-06 10:51:50 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/test/common.o
|
2020-12-05 20:20:41 +00:00
|
|
|
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_A).pkg: \
|
2022-08-06 10:51:50 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/test/common.o \
|
2020-12-05 20:20:41 +00:00
|
|
|
$(foreach x,$(THIRD_PARTY_CHIBICC_TEST_DIRECTDEPS),$($(x)_A).pkg)
|
|
|
|
|
|
|
|
o/$(MODE)/third_party/chibicc/test/%.com.dbg: \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_DEPS) \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_A) \
|
2022-08-06 10:51:50 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/test/%.o \
|
2020-12-05 20:20:41 +00:00
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_A).pkg \
|
|
|
|
$(CRT) \
|
2022-05-25 18:31:08 +00:00
|
|
|
$(APE_NO_MODIFY_SELF)
|
2020-12-05 20:20:41 +00:00
|
|
|
@$(APELINK)
|
|
|
|
|
2022-08-08 18:41:08 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/test/%.o: \
|
|
|
|
third_party/chibicc/test/%.c \
|
|
|
|
$(CHIBICC)
|
Unbloat build config
- 10.5% reduction of o//depend dependency graph
- 8.8% reduction in latency of make command
- Fix issue with temporary file cleanup
There's a new -w option in compile.com that turns off the recent
Landlock output path workaround for "good commands" which do not
unlink() the output file like GNU tooling does.
Our new GNU Make unveil sandboxing appears to have zero overhead
in the grand scheme of things. Full builds are pretty fast since
the only thing that's actually slowed us down is probably libcxx
make -j16 MODE=rel
RL: took 85,732,063µs wall time
RL: ballooned to 323,612kb in size
RL: needed 828,560,521µs cpu (11% kernel)
RL: caused 39,080,670 page faults (99% memcpy)
RL: 350,073 context switches (72% consensual)
RL: performed 0 reads and 11,494,960 write i/o operations
pledge() and unveil() no longer consider ENOSYS to be an error.
These functions have also been added to Python's cosmo module.
This change also removes some WIN32 APIs and System Five magnums
which we're not using and it's doubtful anyone else would be too
2022-08-10 08:32:17 +00:00
|
|
|
@$(COMPILE) -wAOBJECTIFY.c $(CHIBICC) $(CHIBICC_FLAGS) $(OUTPUT_OPTION) -c $<
|
2021-02-07 14:11:44 +00:00
|
|
|
|
2022-08-06 10:51:50 +00:00
|
|
|
o/$(MODE)/third_party/chibicc/test/int128_test.o: QUOTA = -M1024m
|
2021-08-15 00:16:33 +00:00
|
|
|
|
2020-12-05 20:20:41 +00:00
|
|
|
.PHONY: o/$(MODE)/third_party/chibicc/test
|
|
|
|
o/$(MODE)/third_party/chibicc/test: \
|
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_BINS) \
|
2020-12-09 12:00:48 +00:00
|
|
|
$(THIRD_PARTY_CHIBICC_TEST_CHECKS)
|