mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Exclude strace from MODE=tiny builds
This change gets o/tinylinux/examples/hello2.com back down to 8kb in size which had been unintentionally bloated to 40kb in recent months See #965
This commit is contained in:
parent
b7e1dc81c2
commit
2b960bb249
18 changed files with 46 additions and 33 deletions
|
@ -228,6 +228,27 @@ PYFLAGS += \
|
|||
-O2 \
|
||||
-B
|
||||
endif
|
||||
ifeq ($(MODE), x86_64-tiny)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops \
|
||||
-fschedule-insns2 \
|
||||
-momit-leaf-frame-pointer \
|
||||
-foptimize-sibling-calls \
|
||||
-DDWARFLESS
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
PYFLAGS += \
|
||||
-O2 \
|
||||
-B
|
||||
endif
|
||||
ifeq ($(MODE), aarch64-tiny)
|
||||
# TODO(jart): -mcmodel=tiny
|
||||
CONFIG_CPPFLAGS += \
|
||||
|
|
|
@ -136,7 +136,7 @@ int fcntl(int fd, int cmd, ...) {
|
|||
rc = ebadf();
|
||||
}
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
if (rc != -1 && cmd == F_GETFL) {
|
||||
STRACE("fcntl(%d, F_GETFL) → %s", fd, DescribeOpenFlags(rc));
|
||||
} else if (cmd == F_SETFL) {
|
||||
|
|
|
@ -53,7 +53,7 @@ int prctl(int operation, ...) {
|
|||
rc = enosys();
|
||||
}
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
if (operation == PR_CAPBSET_READ || operation == PR_CAPBSET_DROP) {
|
||||
STRACE("prctl(%s, %s) → %d% m", DescribePrctlOperation(operation),
|
||||
DescribeCapability(a), rc);
|
||||
|
|
|
@ -46,7 +46,7 @@ int sys_ptrace(int op, ...) {
|
|||
data = va_arg(va, long *);
|
||||
va_end(va);
|
||||
rc = __sys_ptrace(op, pid, addr, data);
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
if (UNLIKELY(__strace > 0) && strace_enabled(0) > 0) {
|
||||
if (rc != -1 && IsPeek(op) && data) {
|
||||
STRACE("sys_ptrace(%s, %d, %p, [%p]) → %p% m", DescribePtrace(op), pid,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_
|
||||
|
||||
#ifndef SYSDEBUG
|
||||
#define SYSDEBUG 1
|
||||
#define SYSDEBUG 0
|
||||
#endif
|
||||
|
||||
#define _NTTRACE 0 /* not configurable w/ flag yet */
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
void WipeKeystrokes(void);
|
||||
|
||||
static textwindows wontreturn void AbortFork(const char *func) {
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
kprintf("fork() %s() failed with win32 error %d\n", func, GetLastError());
|
||||
#endif
|
||||
TerminateThisProcess(SIGSTKFLT);
|
||||
|
@ -104,7 +104,7 @@ static dontinline textwindows bool WriteAll(int64_t h, void *buf, size_t n) {
|
|||
#ifndef NDEBUG
|
||||
if (ok) ok = ForkIo2(h, &n, sizeof(n), WriteFile, "WriteFile", false);
|
||||
#endif
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
if (!ok) {
|
||||
kprintf("failed to write %zu bytes to forked child: %d\n", n,
|
||||
GetLastError());
|
||||
|
@ -194,7 +194,7 @@ textwindows void WinMainForked(void) {
|
|||
if (!varlen || varlen >= ARRAYLEN(fvar)) return;
|
||||
NTTRACE("WinMainForked()");
|
||||
SetEnvironmentVariable(u"_FORK", NULL);
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
int64_t oncrash = AddVectoredExceptionHandler(1, (void *)OnForkCrash);
|
||||
#endif
|
||||
ParseInt(fvar, &reader);
|
||||
|
@ -271,7 +271,7 @@ textwindows void WinMainForked(void) {
|
|||
fds->p[2].handle = GetStdHandle(kNtStdErrorHandle);
|
||||
|
||||
// restore the crash reporting stuff
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
RemoveVectoredExceptionHandler(oncrash);
|
||||
#endif
|
||||
if (_weaken(__sig_init)) {
|
||||
|
@ -314,7 +314,7 @@ textwindows int sys_fork_nt(uint32_t dwCreationFlags) {
|
|||
startinfo.hStdOutput = g_fds.p[1].handle;
|
||||
startinfo.hStdError = g_fds.p[2].handle;
|
||||
args = __argv;
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
// If --strace was passed to this program, then propagate it the
|
||||
// forked process since the flag was removed by __intercept_flag
|
||||
if (strace_enabled(0) > 0) {
|
||||
|
|
|
@ -55,7 +55,7 @@ vfork:
|
|||
#if !IsTiny()
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
ezlea .Llog,di
|
||||
call __stracef
|
||||
#endif
|
||||
|
@ -93,7 +93,7 @@ vfork:
|
|||
b fork // which doesn't support vfork()
|
||||
1:
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
stp x29,x30,[sp,-16]!
|
||||
adrp x0,.Llog
|
||||
add x0,x0,:lo12:.Llog
|
||||
|
@ -130,7 +130,7 @@ vfork:
|
|||
#endif
|
||||
.endfn vfork,globl
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
.rodata.str1.1
|
||||
.Llog: .ascii STRACE_PROLOGUE
|
||||
.asciz "vfork()\n"
|
||||
|
|
|
@ -40,7 +40,7 @@ cosmo: push %rbp
|
|||
mov %rdx,%r14
|
||||
mov %rcx,%r15
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
call __strace_init
|
||||
mov %eax,%r12d
|
||||
#endif /* SYSDEBUG */
|
||||
|
|
|
@ -163,7 +163,7 @@ wontreturn textstartup void cosmo(long *sp, struct Syslib *m1) {
|
|||
|
||||
_init();
|
||||
// initialize program
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
argc = __strace_init(argc, argv, envp, auxv);
|
||||
#endif
|
||||
for (init_f **fp = __init_array_end; fp-- > __init_array_start;) {
|
||||
|
|
|
@ -57,7 +57,7 @@ int __untrack_memory(struct MemoryIntervals *, int, int,
|
|||
void (*)(struct MemoryIntervals *, int, int));
|
||||
void __release_memory_nt(struct MemoryIntervals *, int, int);
|
||||
int __untrack_memories(void *, size_t);
|
||||
size_t __get_memtrack_size(struct MemoryIntervals *);
|
||||
size_t __get_memtrack_size(struct MemoryIntervals *) nosideeffect;
|
||||
|
||||
#ifdef __x86_64__
|
||||
/*
|
||||
|
|
|
@ -466,7 +466,7 @@ inline void *__mmap_unlocked(void *addr, size_t size, int prot, int flags,
|
|||
*/
|
||||
void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
|
||||
void *res;
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
size_t toto = 0;
|
||||
#if _KERNTRACE || _NTTRACE
|
||||
if (IsWindows()) {
|
||||
|
@ -487,9 +487,11 @@ void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
|
|||
toto = __strace > 0 ? __get_memtrack_size(&_mmi) : 0;
|
||||
#endif
|
||||
__mmi_unlock();
|
||||
#if SYSDEBUG
|
||||
STRACE("mmap(%p, %'zu, %s, %s, %d, %'ld) → %p% m (%'zu bytes total)", addr,
|
||||
size, DescribeProtFlags(prot), DescribeMapFlags(flags), fd, off, res,
|
||||
toto);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,9 +153,7 @@ int munmap(void *p, size_t n) {
|
|||
int rc;
|
||||
__mmi_lock();
|
||||
rc = __munmap_unlocked(p, n);
|
||||
#if SYSDEBUG
|
||||
size_t toto = __strace > 0 ? __get_memtrack_size(&_mmi) : 0;
|
||||
#endif
|
||||
__mmi_unlock();
|
||||
STRACE("munmap(%.12p, %'zu) → %d% m (%'zu bytes total)", p, n, rc, toto);
|
||||
return rc;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/serialize.h"
|
||||
#include "libc/intrin/nomultics.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/limits.h"
|
||||
|
@ -41,6 +40,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/runtime/winargs.internal.h"
|
||||
#include "libc/serialize.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
@ -271,7 +271,7 @@ abi int64_t WinMain(int64_t hInstance, int64_t hPrevInstance,
|
|||
__umask = 077;
|
||||
__pid = __imp_GetCurrentProcessId();
|
||||
cmdline = MyCommandLine();
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
// sloppy flag-only check for early initialization
|
||||
if (StrStr(cmdline, u"--strace")) ++__strace;
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@ int getsockopt(int fd, int level, int optname, void *out_opt_optval,
|
|||
rc = enotsock();
|
||||
}
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
if (out_opt_optval && out_optlen && rc != -1) {
|
||||
STRACE("getsockopt(%d, %s, %s, [%#.*hhs], [%d]) → %d% lm", fd,
|
||||
DescribeSockLevel(level), DescribeSockOptname(level, optname),
|
||||
|
|
|
@ -67,14 +67,12 @@ int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
size_t n;
|
||||
} ss;
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
fd_set old_readfds;
|
||||
fd_set *old_readfds_ptr = 0;
|
||||
fd_set old_writefds;
|
||||
fd_set *old_writefds_ptr = 0;
|
||||
fd_set old_exceptfds;
|
||||
fd_set *old_exceptfds_ptr = 0;
|
||||
#endif
|
||||
|
||||
BEGIN_CANCELATION_POINT;
|
||||
if (nfds < 0) {
|
||||
|
@ -87,7 +85,6 @@ int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
(sigmask && !__asan_is_valid(sigmask, sizeof(*sigmask))))) {
|
||||
rc = efault();
|
||||
} else {
|
||||
#ifdef SYSDEBUG
|
||||
if (readfds) {
|
||||
old_readfds = *readfds;
|
||||
old_readfds_ptr = &old_readfds;
|
||||
|
@ -100,7 +97,6 @@ int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
old_exceptfds = *exceptfds;
|
||||
old_exceptfds_ptr = &old_exceptfds;
|
||||
}
|
||||
#endif
|
||||
if (IsLinux()) {
|
||||
if (timeout) {
|
||||
ts = *timeout;
|
||||
|
|
|
@ -48,7 +48,6 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
struct timeval *timeout) {
|
||||
|
||||
int rc;
|
||||
#ifdef SYSDEBUG
|
||||
fd_set old_readfds;
|
||||
fd_set *old_readfds_ptr = 0;
|
||||
fd_set old_writefds;
|
||||
|
@ -57,7 +56,6 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
fd_set *old_exceptfds_ptr = 0;
|
||||
struct timeval old_timeout;
|
||||
struct timeval *old_timeout_ptr = 0;
|
||||
#endif
|
||||
|
||||
POLLTRACE("select(%d, %p, %p, %p, %s) → ...", nfds, readfds, writefds,
|
||||
exceptfds, DescribeTimeval(0, timeout));
|
||||
|
@ -72,7 +70,6 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
(timeout && !__asan_is_valid(timeout, sizeof(*timeout))))) {
|
||||
rc = efault();
|
||||
} else {
|
||||
#ifdef SYSDEBUG
|
||||
if (readfds) {
|
||||
old_readfds = *readfds;
|
||||
old_readfds_ptr = &old_readfds;
|
||||
|
@ -89,7 +86,6 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
old_timeout = *timeout;
|
||||
old_timeout_ptr = &old_timeout;
|
||||
}
|
||||
#endif
|
||||
if (!IsWindows()) {
|
||||
#ifdef __aarch64__
|
||||
struct timespec ts, *tsp;
|
||||
|
|
|
@ -86,7 +86,7 @@ int setsockopt(int fd, int level, int optname, const void *optval,
|
|||
rc = enotsock();
|
||||
}
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
if (!(rc == -1 && errno == EFAULT)) {
|
||||
STRACE("setsockopt(%d, %s, %s, %#.*hhs, %'u) → %d% lm", fd,
|
||||
DescribeSockLevel(level), DescribeSockOptname(level, optname),
|
||||
|
|
|
@ -379,12 +379,12 @@ _init_systemfive_magnums:
|
|||
jnz 3b
|
||||
xchg %rbx,%rax
|
||||
stosq
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
inc %r8d
|
||||
#endif
|
||||
jmp 2b
|
||||
5: nop
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
push %rdi
|
||||
push %rsi
|
||||
push %r8
|
||||
|
@ -449,7 +449,7 @@ _init_systemfive_done:
|
|||
nop
|
||||
.init.end 300,_init_systemfive,globl,hidden
|
||||
|
||||
#ifdef SYSDEBUG
|
||||
#if SYSDEBUG
|
||||
.rodata.str1.1
|
||||
.Llog: .ascii STRACE_PROLOGUE
|
||||
.ascii "bell system five system call support"
|
||||
|
|
Loading…
Reference in a new issue