mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Introduce MODE=fastbuild
for 28% speedup
This commit is contained in:
parent
094ccbb4bd
commit
1729a8259c
14 changed files with 82 additions and 111 deletions
116
build/config.mk
116
build/config.mk
|
@ -4,20 +4,35 @@
|
|||
# Default Mode
|
||||
#
|
||||
# - `make`
|
||||
# - Optimized
|
||||
# - Backtraces
|
||||
# - Debuggable
|
||||
# - Syscall tracing
|
||||
# - Function tracing
|
||||
# - Reasonably small
|
||||
# - Reasonably optimized
|
||||
# - Reasonably debuggable
|
||||
#
|
||||
ifeq ($(MODE),)
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-DSYSDEBUG \
|
||||
-O2
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O2
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
|
||||
# Fast Build Mode
|
||||
#
|
||||
# - `make MODE=fastbuild`
|
||||
# - No debugging
|
||||
# - Syscall tracing
|
||||
# - Function tracing
|
||||
# - Some optimizations
|
||||
# - Limited Backtraces
|
||||
# - Compiles 28% faster
|
||||
#
|
||||
ifeq ($(MODE),fastbuild)
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
CONFIG_OFLAGS += -g0
|
||||
CONFIG_LDFLAGS += -S
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
|
||||
# Optimized Mode
|
||||
|
@ -31,19 +46,11 @@ endif
|
|||
# - 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
|
||||
#
|
||||
ifeq ($(MODE), opt)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DNDEBUG \
|
||||
-msse2avx \
|
||||
-Wa,-msse2avx
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-DSYSDEBUG \
|
||||
-O3 \
|
||||
-fmerge-all-constants
|
||||
TARGET_ARCH ?= \
|
||||
-march=native
|
||||
CONFIG_CPPFLAGS += -DNDEBUG -DSYSDEBUG -msse2avx -Wa,-msse2avx
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O3 -fmerge-all-constants
|
||||
TARGET_ARCH ?= -march=native
|
||||
endif
|
||||
|
||||
# Optimized Linux Mode
|
||||
|
@ -54,18 +61,12 @@ endif
|
|||
# - Turns off function tracing
|
||||
# - Turns off support for older cpu models
|
||||
# - Turns off support for other operating systems
|
||||
#
|
||||
ifeq ($(MODE), optlinux)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DNDEBUG \
|
||||
-msse2avx \
|
||||
-Wa,-msse2avx \
|
||||
-DSUPPORT_VECTOR=1
|
||||
CONFIG_CCFLAGS += \
|
||||
-O3 -fmerge-all-constants
|
||||
DEFAULT_COPTS += \
|
||||
-mred-zone
|
||||
TARGET_ARCH ?= \
|
||||
-march=native
|
||||
CONFIG_CPPFLAGS += -DNDEBUG -msse2avx -Wa,-msse2avx -DSUPPORT_VECTOR=1
|
||||
CONFIG_CCFLAGS += -O3 -fmerge-all-constants
|
||||
DEFAULT_COPTS += -mred-zone
|
||||
TARGET_ARCH ?= -march=native
|
||||
endif
|
||||
|
||||
# Release Mode
|
||||
|
@ -81,16 +82,12 @@ endif
|
|||
# - DCHECK_xx() statements removed
|
||||
# - No memory corruption detection
|
||||
# - CHECK_xx() won't leak strings into binary
|
||||
#
|
||||
ifeq ($(MODE), rel)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DNDEBUG
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
PYFLAGS += \
|
||||
-O1
|
||||
CONFIG_CPPFLAGS += -DNDEBUG
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2
|
||||
TARGET_ARCH ?= -msse3
|
||||
PYFLAGS += -O1
|
||||
endif
|
||||
|
||||
# Asan Mode
|
||||
|
@ -103,14 +100,11 @@ endif
|
|||
# - Backtraces
|
||||
# - Debuggability
|
||||
# - Larger binaries
|
||||
#
|
||||
ifeq ($(MODE), asan)
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
CONFIG_COPTS += \
|
||||
-fsanitize=address
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2
|
||||
CONFIG_COPTS += -fsanitize=address
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
|
||||
# Debug Mode
|
||||
|
@ -122,22 +116,13 @@ endif
|
|||
# - Stack canaries
|
||||
# - No optimization (TODO)
|
||||
# - Enormous binaries
|
||||
#
|
||||
ifeq ($(MODE), dbg)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DMODE_DBG
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-DSYSDEBUG \
|
||||
-O2 \
|
||||
-fno-inline
|
||||
CONFIG_COPTS += \
|
||||
-fsanitize=address \
|
||||
-fsanitize=undefined
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
OVERRIDE_CCFLAGS += \
|
||||
-fno-pie
|
||||
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
|
||||
endif
|
||||
|
||||
# Tiny Mode
|
||||
|
@ -151,6 +136,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
#
|
||||
ifeq ($(MODE), tiny)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -185,6 +171,7 @@ endif
|
|||
# - No portability
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
#
|
||||
ifeq ($(MODE), tinylinux)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -216,6 +203,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
#
|
||||
ifeq ($(MODE), tinylinuxbsd)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -246,6 +234,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
#
|
||||
ifeq ($(MODE), tinysysv)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -276,6 +265,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
#
|
||||
ifeq ($(MODE), tinynowin)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
.privileged
|
||||
|
||||
_spinlock_yield:
|
||||
jmp sched_yield
|
||||
.endfn _spinlock_yield,globl
|
|
@ -27,7 +27,10 @@
|
|||
* This function does not need to issue a system call. The PID is
|
||||
* tracked by a global variable which is updated at fork(). The only
|
||||
* exception is when the process is vfork()'d in which case a system
|
||||
* call shall be issued.
|
||||
* call shall be issued. This optimization helps make functions like
|
||||
* rand64() fork-safe, however it could lead to race conditions in
|
||||
* programs that mix fork() with threads. In that case, apps should
|
||||
* consider using `sys_getpid().ax` instead to force a system call.
|
||||
*
|
||||
* On Linux, and only Linux, the process id is guaranteed to be the same
|
||||
* as gettid() for the main thread.
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kClockNames
|
||||
.long 1f - kClockNames
|
||||
.long .L\@ - kClockNames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
.section .rodata
|
||||
.section .rodata,"a",@progbits
|
||||
.align 4
|
||||
.underrun
|
||||
kClockNames:
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
.endm
|
||||
|
||||
.section .rodata,"a",@progbits
|
||||
.align 4
|
||||
.underrun
|
||||
kDos2Errno:
|
||||
// .e kNtErrorInvalidFunction,ENOSYS # in consts.sh
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kErrnoDocs
|
||||
.long 1f - kErrnoDocs
|
||||
.long .L\@ - kErrnoDocs
|
||||
.rodata.str1.1
|
||||
1: .asciz "\s"
|
||||
.L\@: .asciz "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e
|
||||
.long \e - kErrnoNames
|
||||
.long 1f - kErrnoNames
|
||||
.long .L\@ - kErrnoNames
|
||||
.rodata.str1.1
|
||||
1: .string "\e"
|
||||
.L\@: .string "\e"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kIpOptnames
|
||||
.long 1f - kIpOptnames
|
||||
.long .L\@ - kIpOptnames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kOpenFlags
|
||||
.long 1f - kOpenFlags
|
||||
.long .L\@ - kOpenFlags
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kRlimitNames
|
||||
.long 1f - kRlimitNames
|
||||
.long .L\@ - kRlimitNames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kSignalNames
|
||||
.long 1f - kSignalNames
|
||||
.long .L\@ - kSignalNames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kSockOptnames
|
||||
.long 1f - kSockOptnames
|
||||
.long .L\@ - kSockOptnames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
.macro .e e s
|
||||
.long \e - kTcpOptnames
|
||||
.long 1f - kTcpOptnames
|
||||
.long .L\@ - kTcpOptnames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.L\@: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
|
|
|
@ -174,7 +174,8 @@ int pthread_barrier_init(pthread_barrier_t *, const pthread_barrierattr_t *,
|
|||
|
||||
#define pthread_spin_init(pSpin, multiprocess) ((pSpin)->lock = 0, 0)
|
||||
#define pthread_spin_destroy(pSpin) ((pSpin)->lock = -1, 0)
|
||||
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407
|
||||
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407 && \
|
||||
!defined(__STRICT_ANSI__)
|
||||
extern const errno_t EBUSY;
|
||||
#define pthread_spin_lock(pSpin) \
|
||||
({ \
|
||||
|
|
Loading…
Reference in a new issue