Skip to content

Commit 2b960bb

Browse files
committed
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
1 parent b7e1dc8 commit 2b960bb

File tree

18 files changed

+46
-33
lines changed

18 files changed

+46
-33
lines changed

build/config.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,27 @@ PYFLAGS += \
228228
-O2 \
229229
-B
230230
endif
231+
ifeq ($(MODE), x86_64-tiny)
232+
CONFIG_CPPFLAGS += \
233+
-DTINY \
234+
-DNDEBUG \
235+
-DTRUSTWORTHY
236+
CONFIG_CCFLAGS += \
237+
-Os \
238+
-fno-align-functions \
239+
-fno-align-jumps \
240+
-fno-align-labels \
241+
-fno-align-loops \
242+
-fschedule-insns2 \
243+
-momit-leaf-frame-pointer \
244+
-foptimize-sibling-calls \
245+
-DDWARFLESS
246+
TARGET_ARCH ?= \
247+
-msse3
248+
PYFLAGS += \
249+
-O2 \
250+
-B
251+
endif
231252
ifeq ($(MODE), aarch64-tiny)
232253
# TODO(jart): -mcmodel=tiny
233254
CONFIG_CPPFLAGS += \

libc/calls/fcntl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int fcntl(int fd, int cmd, ...) {
136136
rc = ebadf();
137137
}
138138

139-
#ifdef SYSDEBUG
139+
#if SYSDEBUG
140140
if (rc != -1 && cmd == F_GETFL) {
141141
STRACE("fcntl(%d, F_GETFL) → %s", fd, DescribeOpenFlags(rc));
142142
} else if (cmd == F_SETFL) {

libc/calls/prctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int prctl(int operation, ...) {
5353
rc = enosys();
5454
}
5555

56-
#ifdef SYSDEBUG
56+
#if SYSDEBUG
5757
if (operation == PR_CAPBSET_READ || operation == PR_CAPBSET_DROP) {
5858
STRACE("prctl(%s, %s) → %d% m", DescribePrctlOperation(operation),
5959
DescribeCapability(a), rc);

libc/calls/sys_ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int sys_ptrace(int op, ...) {
4646
data = va_arg(va, long *);
4747
va_end(va);
4848
rc = __sys_ptrace(op, pid, addr, data);
49-
#ifdef SYSDEBUG
49+
#if SYSDEBUG
5050
if (UNLIKELY(__strace > 0) && strace_enabled(0) > 0) {
5151
if (rc != -1 && IsPeek(op) && data) {
5252
STRACE("sys_ptrace(%s, %d, %p, [%p]) → %p% m", DescribePtrace(op), pid,

libc/intrin/strace.internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_
33

44
#ifndef SYSDEBUG
5-
#define SYSDEBUG 1
5+
#define SYSDEBUG 0
66
#endif
77

88
#define _NTTRACE 0 /* not configurable w/ flag yet */

libc/proc/fork-nt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
void WipeKeystrokes(void);
6262

6363
static textwindows wontreturn void AbortFork(const char *func) {
64-
#ifdef SYSDEBUG
64+
#if SYSDEBUG
6565
kprintf("fork() %s() failed with win32 error %d\n", func, GetLastError());
6666
#endif
6767
TerminateThisProcess(SIGSTKFLT);
@@ -104,7 +104,7 @@ static dontinline textwindows bool WriteAll(int64_t h, void *buf, size_t n) {
104104
#ifndef NDEBUG
105105
if (ok) ok = ForkIo2(h, &n, sizeof(n), WriteFile, "WriteFile", false);
106106
#endif
107-
#ifdef SYSDEBUG
107+
#if SYSDEBUG
108108
if (!ok) {
109109
kprintf("failed to write %zu bytes to forked child: %d\n", n,
110110
GetLastError());
@@ -194,7 +194,7 @@ textwindows void WinMainForked(void) {
194194
if (!varlen || varlen >= ARRAYLEN(fvar)) return;
195195
NTTRACE("WinMainForked()");
196196
SetEnvironmentVariable(u"_FORK", NULL);
197-
#ifdef SYSDEBUG
197+
#if SYSDEBUG
198198
int64_t oncrash = AddVectoredExceptionHandler(1, (void *)OnForkCrash);
199199
#endif
200200
ParseInt(fvar, &reader);
@@ -271,7 +271,7 @@ textwindows void WinMainForked(void) {
271271
fds->p[2].handle = GetStdHandle(kNtStdErrorHandle);
272272

273273
// restore the crash reporting stuff
274-
#ifdef SYSDEBUG
274+
#if SYSDEBUG
275275
RemoveVectoredExceptionHandler(oncrash);
276276
#endif
277277
if (_weaken(__sig_init)) {
@@ -314,7 +314,7 @@ textwindows int sys_fork_nt(uint32_t dwCreationFlags) {
314314
startinfo.hStdOutput = g_fds.p[1].handle;
315315
startinfo.hStdError = g_fds.p[2].handle;
316316
args = __argv;
317-
#ifdef SYSDEBUG
317+
#if SYSDEBUG
318318
// If --strace was passed to this program, then propagate it the
319319
// forked process since the flag was removed by __intercept_flag
320320
if (strace_enabled(0) > 0) {

libc/proc/vfork.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ vfork:
5555
#if !IsTiny()
5656
push %rbp
5757
mov %rsp,%rbp
58-
#ifdef SYSDEBUG
58+
#if SYSDEBUG
5959
ezlea .Llog,di
6060
call __stracef
6161
#endif
@@ -93,7 +93,7 @@ vfork:
9393
b fork // which doesn't support vfork()
9494
1:
9595

96-
#ifdef SYSDEBUG
96+
#if SYSDEBUG
9797
stp x29,x30,[sp,-16]!
9898
adrp x0,.Llog
9999
add x0,x0,:lo12:.Llog
@@ -130,7 +130,7 @@ vfork:
130130
#endif
131131
.endfn vfork,globl
132132

133-
#ifdef SYSDEBUG
133+
#if SYSDEBUG
134134
.rodata.str1.1
135135
.Llog: .ascii STRACE_PROLOGUE
136136
.asciz "vfork()\n"

libc/runtime/cosmo.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cosmo: push %rbp
4040
mov %rdx,%r14
4141
mov %rcx,%r15
4242

43-
#ifdef SYSDEBUG
43+
#if SYSDEBUG
4444
call __strace_init
4545
mov %eax,%r12d
4646
#endif /* SYSDEBUG */

libc/runtime/cosmo2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ wontreturn textstartup void cosmo(long *sp, struct Syslib *m1) {
163163

164164
_init();
165165
// initialize program
166-
#ifdef SYSDEBUG
166+
#if SYSDEBUG
167167
argc = __strace_init(argc, argv, envp, auxv);
168168
#endif
169169
for (init_f **fp = __init_array_end; fp-- > __init_array_start;) {

libc/runtime/memtrack.internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int __untrack_memory(struct MemoryIntervals *, int, int,
5757
void (*)(struct MemoryIntervals *, int, int));
5858
void __release_memory_nt(struct MemoryIntervals *, int, int);
5959
int __untrack_memories(void *, size_t);
60-
size_t __get_memtrack_size(struct MemoryIntervals *);
60+
size_t __get_memtrack_size(struct MemoryIntervals *) nosideeffect;
6161

6262
#ifdef __x86_64__
6363
/*

0 commit comments

Comments
 (0)