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───────────────────────┘
|
|
|
|
|
|
|
|
# Default Mode
|
|
|
|
#
|
|
|
|
# - `make`
|
2022-09-09 15:59:59 +00:00
|
|
|
# - Optimized
|
2020-06-15 14:18:57 +00:00
|
|
|
# - Backtraces
|
2022-09-09 15:59:59 +00:00
|
|
|
# - Debuggable
|
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
|
|
|
# - Syscall tracing
|
2020-06-15 14:18:57 +00:00
|
|
|
# - Function tracing
|
|
|
|
# - Reasonably small
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2020-06-15 14:18:57 +00:00
|
|
|
ifeq ($(MODE),)
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O2
|
|
|
|
CONFIG_CPPFLAGS += -DSYSDEBUG
|
|
|
|
TARGET_ARCH ?= -msse3
|
|
|
|
endif
|
|
|
|
|
2023-05-01 21:36:25 +00:00
|
|
|
ifeq ($(MODE), aarch64)
|
2023-05-09 09:35:05 +00:00
|
|
|
CONFIG_CCFLAGS += -O2 $(BACKTRACES) #$(FTRACE)
|
2023-05-01 21:36:25 +00:00
|
|
|
CONFIG_CPPFLAGS += -DSYSDEBUG
|
|
|
|
endif
|
|
|
|
|
2022-09-09 15:59:59 +00:00
|
|
|
# Fast Build Mode
|
|
|
|
#
|
|
|
|
# - `make MODE=fastbuild`
|
|
|
|
# - No debugging
|
|
|
|
# - Syscall tracing
|
|
|
|
# - Function tracing
|
|
|
|
# - Some optimizations
|
|
|
|
# - Limited Backtraces
|
|
|
|
# - Compiles 28% faster
|
|
|
|
#
|
2023-05-09 09:35:05 +00:00
|
|
|
ifeq ($(MODE), fastbuild)
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O
|
2022-10-17 18:02:04 +00:00
|
|
|
CONFIG_CPPFLAGS += -DSYSDEBUG -DDWARFLESS
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_OFLAGS += -g0
|
|
|
|
CONFIG_LDFLAGS += -S
|
|
|
|
TARGET_ARCH ?= -msse3
|
2020-06-15 14:18:57 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Optimized Mode
|
|
|
|
#
|
|
|
|
# - `make MODE=opt`
|
|
|
|
# - Backtraces
|
|
|
|
# - More optimized
|
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
|
|
|
# - Syscall tracing
|
|
|
|
# - Function tracing
|
2020-06-15 14:18:57 +00:00
|
|
|
# - Reasonably small
|
|
|
|
# - No memory corruption detection
|
|
|
|
# - assert() / CHECK_xx() may leak code into binary for debuggability
|
|
|
|
# - GCC 8+ hoists check fails into .text.cold, thus minimizing impact
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2020-06-15 14:18:57 +00:00
|
|
|
ifeq ($(MODE), opt)
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_CPPFLAGS += -DNDEBUG -DSYSDEBUG -msse2avx -Wa,-msse2avx
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O3 -fmerge-all-constants
|
|
|
|
TARGET_ARCH ?= -march=native
|
2021-10-15 02:36:49 +00:00
|
|
|
endif
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-10-15 02:36:49 +00:00
|
|
|
# Optimized Linux Mode
|
|
|
|
#
|
|
|
|
# - `make MODE=optlinux`
|
|
|
|
# - Turns on red zone
|
|
|
|
# - Turns off backtraces
|
|
|
|
# - Turns off function tracing
|
|
|
|
# - Turns off support for older cpu models
|
|
|
|
# - Turns off support for other operating systems
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2021-10-15 02:36:49 +00:00
|
|
|
ifeq ($(MODE), optlinux)
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_CPPFLAGS += -DNDEBUG -msse2avx -Wa,-msse2avx -DSUPPORT_VECTOR=1
|
|
|
|
CONFIG_CCFLAGS += -O3 -fmerge-all-constants
|
|
|
|
DEFAULT_COPTS += -mred-zone
|
|
|
|
TARGET_ARCH ?= -march=native
|
2020-06-15 14:18:57 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Release Mode
|
|
|
|
#
|
2021-08-15 00:16:33 +00:00
|
|
|
# Follows traditional closed source release binary norms.
|
|
|
|
#
|
2020-06-15 14:18:57 +00:00
|
|
|
# - `make MODE=rel`
|
|
|
|
# - More optimized
|
|
|
|
# - Reasonably small
|
|
|
|
# - Numeric backtraces
|
|
|
|
# - Toilsome debuggability
|
|
|
|
# - assert() statements removed
|
|
|
|
# - DCHECK_xx() statements removed
|
|
|
|
# - No memory corruption detection
|
|
|
|
# - CHECK_xx() won't leak strings into binary
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2020-06-15 14:18:57 +00:00
|
|
|
ifeq ($(MODE), rel)
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_CPPFLAGS += -DNDEBUG
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) -O2
|
|
|
|
TARGET_ARCH ?= -msse3
|
|
|
|
PYFLAGS += -O1
|
2020-06-15 14:18:57 +00:00
|
|
|
endif
|
|
|
|
|
2021-08-15 00:16:33 +00:00
|
|
|
# Asan Mode
|
|
|
|
#
|
|
|
|
# Safer binaries good for backend production serving.
|
|
|
|
#
|
|
|
|
# - `make MODE=asan`
|
|
|
|
# - Memory safety
|
|
|
|
# - Production worthy
|
|
|
|
# - Backtraces
|
|
|
|
# - Debuggability
|
|
|
|
# - Larger binaries
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2021-08-15 00:16:33 +00:00
|
|
|
ifeq ($(MODE), asan)
|
2022-09-16 21:02:06 +00:00
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) -O2 -DSYSDEBUG
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_COPTS += -fsanitize=address
|
|
|
|
TARGET_ARCH ?= -msse3
|
2021-08-15 00:16:33 +00:00
|
|
|
endif
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
# Debug Mode
|
|
|
|
#
|
|
|
|
# - `make MODE=dbg`
|
|
|
|
# - Backtraces
|
2021-08-15 00:16:33 +00:00
|
|
|
# - Enables asan
|
|
|
|
# - Enables ubsan (TODO)
|
|
|
|
# - Stack canaries
|
|
|
|
# - No optimization (TODO)
|
|
|
|
# - Enormous binaries
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2020-06-15 14:18:57 +00:00
|
|
|
ifeq ($(MODE), dbg)
|
2022-09-09 15:59:59 +00:00
|
|
|
CONFIG_CPPFLAGS += -DMODE_DBG
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -DSYSDEBUG -O -fno-inline
|
|
|
|
CONFIG_COPTS += -fsanitize=address -fsanitize=undefined
|
|
|
|
TARGET_ARCH ?= -msse3
|
|
|
|
OVERRIDE_CCFLAGS += -fno-pie
|
2020-06-15 14:18:57 +00:00
|
|
|
endif
|
|
|
|
|
2023-05-13 05:42:57 +00:00
|
|
|
ifeq ($(MODE), aarch64-dbg)
|
|
|
|
CONFIG_CPPFLAGS += -DMODE_DBG
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -DSYSDEBUG -O -fno-inline
|
|
|
|
CONFIG_COPTS += -fsanitize=undefined
|
|
|
|
endif
|
|
|
|
|
2022-10-17 18:02:04 +00:00
|
|
|
# System Five Mode
|
|
|
|
#
|
|
|
|
# - `make MODE=sysv`
|
|
|
|
# - Optimized
|
|
|
|
# - Backtraces
|
|
|
|
# - Debuggable
|
|
|
|
# - Syscall tracing
|
|
|
|
# - Function tracing
|
|
|
|
# - No Windows bloat!
|
|
|
|
#
|
|
|
|
ifeq ($(MODE), sysv)
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O2
|
|
|
|
CONFIG_CPPFLAGS += -DSYSDEBUG -DSUPPORT_VECTOR=121
|
|
|
|
TARGET_ARCH ?= -msse3
|
|
|
|
endif
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
# Tiny Mode
|
|
|
|
#
|
|
|
|
# - `make MODE=tiny`
|
|
|
|
# - No checks
|
|
|
|
# - No asserts
|
|
|
|
# - No canaries
|
|
|
|
# - No paranoia
|
|
|
|
# - No avx hooks
|
|
|
|
# - No backtraces
|
|
|
|
# - No algorithmics
|
|
|
|
# - YOLO
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2020-06-15 14:18:57 +00:00
|
|
|
ifeq ($(MODE), tiny)
|
2021-10-08 15:11:51 +00:00
|
|
|
CONFIG_CPPFLAGS += \
|
|
|
|
-DTINY \
|
|
|
|
-DNDEBUG \
|
2020-06-15 14:18:57 +00:00
|
|
|
-DTRUSTWORTHY
|
2021-10-08 15:11:51 +00:00
|
|
|
CONFIG_CCFLAGS += \
|
|
|
|
-Os \
|
|
|
|
-fno-align-functions \
|
|
|
|
-fno-align-jumps \
|
|
|
|
-fno-align-labels \
|
|
|
|
-fno-align-loops \
|
|
|
|
-fschedule-insns2 \
|
2021-10-15 02:36:49 +00:00
|
|
|
-fomit-frame-pointer \
|
2021-10-08 15:11:51 +00:00
|
|
|
-momit-leaf-frame-pointer \
|
2022-10-17 18:02:04 +00:00
|
|
|
-foptimize-sibling-calls \
|
|
|
|
-DDWARFLESS
|
2022-09-15 04:29:50 +00:00
|
|
|
CONFIG_OFLAGS += \
|
|
|
|
-g0
|
|
|
|
CONFIG_LDFLAGS += \
|
|
|
|
-S
|
2021-10-08 15:11:51 +00:00
|
|
|
TARGET_ARCH ?= \
|
2021-02-08 12:04:42 +00:00
|
|
|
-msse3
|
2021-10-08 15:11:51 +00:00
|
|
|
PYFLAGS += \
|
|
|
|
-O2 \
|
2021-09-07 02:34:57 +00:00
|
|
|
-B
|
2021-02-08 12:04:42 +00:00
|
|
|
endif
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2023-05-09 09:35:05 +00:00
|
|
|
ifeq ($(MODE), aarch64-tiny)
|
2023-05-19 02:05:08 +00:00
|
|
|
# TODO(jart): -mcmodel=tiny
|
2023-05-09 09:35:05 +00:00
|
|
|
CONFIG_CPPFLAGS += \
|
|
|
|
-DTINY \
|
|
|
|
-DNDEBUG \
|
|
|
|
-DTRUSTWORTHY
|
|
|
|
CONFIG_CCFLAGS += \
|
|
|
|
-Os \
|
|
|
|
-fno-align-functions \
|
|
|
|
-fno-align-jumps \
|
|
|
|
-fno-align-labels \
|
|
|
|
-fno-align-loops \
|
|
|
|
-fschedule-insns2 \
|
2023-05-19 02:05:08 +00:00
|
|
|
-fno-omit-frame-pointer \
|
2023-05-09 09:35:05 +00:00
|
|
|
-momit-leaf-frame-pointer \
|
|
|
|
-foptimize-sibling-calls \
|
|
|
|
-DDWARFLESS
|
|
|
|
CONFIG_OFLAGS += \
|
|
|
|
-g0
|
|
|
|
CONFIG_LDFLAGS += \
|
|
|
|
-S
|
|
|
|
PYFLAGS += \
|
|
|
|
-O2 \
|
|
|
|
-B
|
|
|
|
endif
|
|
|
|
|
2021-02-08 12:04:42 +00:00
|
|
|
# Linux-Only Tiny Mode
|
|
|
|
#
|
2021-02-27 18:33:32 +00:00
|
|
|
# - `make MODE=tinylinux`
|
2021-02-08 12:04:42 +00:00
|
|
|
# - No checks
|
|
|
|
# - No asserts
|
|
|
|
# - No canaries
|
|
|
|
# - No paranoia
|
|
|
|
# - No avx hooks
|
|
|
|
# - No backtraces
|
|
|
|
# - No portability
|
|
|
|
# - No algorithmics
|
|
|
|
# - YOLO
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2021-02-08 12:04:42 +00:00
|
|
|
ifeq ($(MODE), tinylinux)
|
2021-10-15 02:36:49 +00:00
|
|
|
CONFIG_CPPFLAGS += \
|
|
|
|
-DTINY \
|
|
|
|
-DNDEBUG \
|
|
|
|
-DTRUSTWORTHY \
|
2022-10-17 18:02:04 +00:00
|
|
|
-DSUPPORT_VECTOR=1 \
|
|
|
|
-DDWARFLESS
|
2021-10-15 02:36:49 +00:00
|
|
|
DEFAULT_COPTS += \
|
|
|
|
-mred-zone
|
2022-09-15 04:29:50 +00:00
|
|
|
CONFIG_OFLAGS += \
|
|
|
|
-g0
|
|
|
|
CONFIG_LDFLAGS += \
|
|
|
|
-S
|
2021-10-15 02:36:49 +00:00
|
|
|
CONFIG_CCFLAGS += \
|
|
|
|
-Os \
|
|
|
|
-fno-align-functions \
|
|
|
|
-fno-align-jumps \
|
|
|
|
-fno-align-labels \
|
2020-06-15 14:18:57 +00:00
|
|
|
-fno-align-loops
|
2021-10-15 02:36:49 +00:00
|
|
|
TARGET_ARCH ?= \
|
2021-02-08 12:04:42 +00:00
|
|
|
-msse3
|
|
|
|
endif
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-02-08 12:04:42 +00:00
|
|
|
# Linux+BSD Tiny Mode
|
|
|
|
#
|
2021-02-27 18:33:32 +00:00
|
|
|
# - `make MODE=tinylinuxbsd`
|
2021-02-08 12:04:42 +00:00
|
|
|
# - No apple
|
|
|
|
# - No checks
|
|
|
|
# - No asserts
|
|
|
|
# - No canaries
|
|
|
|
# - No paranoia
|
|
|
|
# - No microsoft
|
|
|
|
# - No avx hooks
|
|
|
|
# - No backtraces
|
|
|
|
# - No algorithmics
|
|
|
|
# - YOLO
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2021-02-08 12:04:42 +00:00
|
|
|
ifeq ($(MODE), tinylinuxbsd)
|
|
|
|
CONFIG_CPPFLAGS += \
|
|
|
|
-DTINY \
|
|
|
|
-DNDEBUG \
|
|
|
|
-DTRUSTWORTHY \
|
2022-10-17 18:02:04 +00:00
|
|
|
-DSUPPORT_VECTOR=113 \
|
|
|
|
-DDWARFLESS
|
2021-10-15 02:36:49 +00:00
|
|
|
DEFAULT_COPTS += \
|
|
|
|
-mred-zone
|
2022-09-15 04:29:50 +00:00
|
|
|
CONFIG_OFLAGS += \
|
|
|
|
-g0
|
|
|
|
CONFIG_LDFLAGS += \
|
|
|
|
-S
|
2021-02-08 12:04:42 +00:00
|
|
|
CONFIG_CCFLAGS += \
|
|
|
|
-Os \
|
|
|
|
-fno-align-functions \
|
|
|
|
-fno-align-jumps \
|
|
|
|
-fno-align-labels \
|
|
|
|
-fno-align-loops
|
2020-06-15 14:18:57 +00:00
|
|
|
TARGET_ARCH ?= \
|
2020-12-05 20:20:41 +00:00
|
|
|
-msse3
|
2021-02-08 12:04:42 +00:00
|
|
|
endif
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-02-08 12:04:42 +00:00
|
|
|
# Unix Tiny Mode
|
|
|
|
#
|
2021-02-27 18:33:32 +00:00
|
|
|
# - `make MODE=tinysysv`
|
2021-02-08 12:04:42 +00:00
|
|
|
# - No checks
|
|
|
|
# - No asserts
|
|
|
|
# - No canaries
|
|
|
|
# - No paranoia
|
|
|
|
# - No microsoft
|
|
|
|
# - No avx hooks
|
|
|
|
# - No backtraces
|
|
|
|
# - No algorithmics
|
|
|
|
# - YOLO
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2021-02-08 12:04:42 +00:00
|
|
|
ifeq ($(MODE), tinysysv)
|
|
|
|
CONFIG_CPPFLAGS += \
|
|
|
|
-DTINY \
|
|
|
|
-DNDEBUG \
|
|
|
|
-DTRUSTWORTHY \
|
2022-10-17 18:02:04 +00:00
|
|
|
-DSUPPORT_VECTOR=121 \
|
|
|
|
-DDWARFLESS
|
2021-10-15 02:36:49 +00:00
|
|
|
DEFAULT_COPTS += \
|
|
|
|
-mred-zone
|
2021-02-08 12:04:42 +00:00
|
|
|
CONFIG_CCFLAGS += \
|
|
|
|
-Os \
|
|
|
|
-fno-align-functions \
|
|
|
|
-fno-align-jumps \
|
|
|
|
-fno-align-labels \
|
|
|
|
-fno-align-loops
|
2022-09-15 04:29:50 +00:00
|
|
|
CONFIG_OFLAGS += \
|
|
|
|
-g0
|
|
|
|
CONFIG_LDFLAGS += \
|
|
|
|
-S
|
2021-02-08 12:04:42 +00:00
|
|
|
TARGET_ARCH ?= \
|
|
|
|
-msse3
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Tiny Metallic Unix Mode
|
|
|
|
#
|
2021-02-27 18:33:32 +00:00
|
|
|
# - `make MODE=tinynowin`
|
2021-02-08 12:04:42 +00:00
|
|
|
# - No checks
|
|
|
|
# - No asserts
|
|
|
|
# - No canaries
|
|
|
|
# - No paranoia
|
|
|
|
# - No microsoft
|
|
|
|
# - No avx hooks
|
|
|
|
# - No backtraces
|
|
|
|
# - No algorithmics
|
|
|
|
# - YOLO
|
2022-09-09 15:59:59 +00:00
|
|
|
#
|
2021-02-08 12:04:42 +00:00
|
|
|
ifeq ($(MODE), tinynowin)
|
|
|
|
CONFIG_CPPFLAGS += \
|
|
|
|
-DTINY \
|
|
|
|
-DNDEBUG \
|
|
|
|
-DTRUSTWORTHY \
|
2022-10-17 18:02:04 +00:00
|
|
|
-DSUPPORT_VECTOR=251 \
|
|
|
|
-DDWARFLESS
|
2021-02-08 12:04:42 +00:00
|
|
|
CONFIG_CCFLAGS += \
|
|
|
|
-Os \
|
|
|
|
-fno-align-functions \
|
|
|
|
-fno-align-jumps \
|
|
|
|
-fno-align-labels \
|
|
|
|
-fno-align-loops
|
2022-09-15 04:29:50 +00:00
|
|
|
CONFIG_OFLAGS += \
|
|
|
|
-g0
|
|
|
|
CONFIG_LDFLAGS += \
|
|
|
|
-S
|
2021-02-08 12:04:42 +00:00
|
|
|
TARGET_ARCH ?= \
|
|
|
|
-msse3
|
2020-06-15 14:18:57 +00:00
|
|
|
endif
|
|
|
|
|
2022-09-13 11:14:20 +00:00
|
|
|
# GCC11 Mode
|
|
|
|
# https://justine.lol/compilers/x86_64-linux-musl__x86_64-linux-musl__g++-11.2.0.tar.xz
|
|
|
|
ifeq ($(MODE), gcc11)
|
|
|
|
.UNVEIL += rx:/opt/gcc11
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -DSYSDEBUG -O2
|
|
|
|
AS = /opt/gcc11/bin/x86_64-linux-musl-as
|
|
|
|
CC = /opt/gcc11/bin/x86_64-linux-musl-gcc
|
|
|
|
CXX = /opt/gcc11/bin/x86_64-linux-musl-g++
|
|
|
|
CXXFILT = /opt/gcc11/bin/x86_64-linux-musl-c++filt
|
|
|
|
LD = /opt/gcc11/bin/x86_64-linux-musl-ld.bfd
|
|
|
|
NM = /opt/gcc11/bin/x86_64-linux-musl-nm
|
|
|
|
GCC = /opt/gcc11/bin/x86_64-linux-musl-gcc
|
|
|
|
STRIP = /opt/gcc11/bin/x86_64-linux-musl-strip
|
|
|
|
OBJCOPY = /opt/gcc11/bin/x86_64-linux-musl-objcopy
|
|
|
|
OBJDUMP = /opt/gcc11/bin/x86_64-linux-musl-objdump
|
|
|
|
ADDR2LINE = /opt/gcc11/bin/x86_64-linux-musl-addr2line
|
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O2 -Wno-stringop-overread
|
|
|
|
CONFIG_CFLAGS += -Wno-old-style-definition
|
|
|
|
CONFIG_CPPFLAGS += -DNDEBUG -DSYSDEBUG
|
|
|
|
TARGET_ARCH ?= -msse3
|
|
|
|
endif
|
|
|
|
|
2021-02-08 17:19:00 +00:00
|
|
|
# LLVM Mode
|
|
|
|
ifeq ($(MODE), llvm)
|
|
|
|
TARGET_ARCH ?= -msse3
|
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
|
|
|
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -DSYSDEBUG -O2
|
2021-02-08 17:19:00 +00:00
|
|
|
AS = clang
|
|
|
|
CC = clang
|
|
|
|
CXX = clang++
|
|
|
|
CXXFILT = llvm-c++filt
|
|
|
|
LD = ld.lld
|
|
|
|
NM = llvm-nm
|
|
|
|
GCC = clang
|
|
|
|
STRIP = llvm-strip
|
|
|
|
OBJCOPY = llvm-objcopy
|
|
|
|
OBJDUMP = llvm-objdump
|
|
|
|
ADDR2LINE = llvm-addr2line
|
|
|
|
endif
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
# ANSI Mode
|
|
|
|
#
|
2020-06-21 07:10:11 +00:00
|
|
|
# These flags cause GCC to predefine __STRICT_ANSI__. Please be warned
|
|
|
|
# that Cosmopolitan headers are written to comply with that request if
|
|
|
|
# it's possible to do so. Consider the following example:
|
|
|
|
#
|
|
|
|
# make -j12 -O o//tool/viz/printvideo.i
|
|
|
|
# clang-format-10 -i o//tool/viz/printvideo.i
|
|
|
|
# less o//tool/viz/printvideo.i
|
|
|
|
#
|
|
|
|
# You'll notice functions like memcpy(), ioctl(), etc. get expanded into
|
|
|
|
# wild-eyed gnu-style performance hacks. You can turn it off as follows:
|
|
|
|
#
|
|
|
|
# make -j12 -O MODE=ansi o/ansi/tool/viz/printvideo.i
|
|
|
|
# clang-format-10 -i o/ansi/tool/viz/printvideo.i
|
|
|
|
# less o/ansi/tool/viz/printvideo.i
|
|
|
|
#
|
|
|
|
# Here it becomes clear that ANSI mode can help you decouple your source
|
|
|
|
# from Cosmopolitan, by turning it into plain ordinary textbook C code.
|
|
|
|
#
|
|
|
|
# Another potential use case is distributing code to folks using tools
|
|
|
|
# such as MSVC or XCode. You can run your binary objects through a tool
|
|
|
|
# like objconv to convert them to COFF or MachO. Then use ANSI mode to
|
|
|
|
# rollup one header file that'll enable linkage with minimal issues.
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
ifeq ($(MODE), ansi)
|
|
|
|
|
2020-06-21 07:10:11 +00:00
|
|
|
CONFIG_CFLAGS += -std=c11
|
2020-08-25 11:23:25 +00:00
|
|
|
#CONFIG_CPPFLAGS += -ansi
|
2020-06-21 07:10:11 +00:00
|
|
|
CONFIG_CXXFLAGS += -std=c++11
|
2020-12-09 12:00:48 +00:00
|
|
|
TARGET_ARCH ?= -msse3
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
endif
|