Skip to content

Commit fc3c536

Browse files
committed
Make --ftrace work better with cosmocc
This change causes cosmocc to use -fno-inline-functions-called-once by default, unless -Os or -finline-functions-called-once is defined. This is important since I believe it generally makes code go faster, and it most importantly makes --ftrace output much more understandable, since the trace will be more likely to reflect the actual shape of the code. We've always used this flag in the mono repo when ftracing is enabled, but it slipped my mind to incorporate this into the cosmocc toolchain.
1 parent 77ddf4c commit fc3c536

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tool/cosmocc/bin/cosmocc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ OPT=
7979
ARGS=
8080
FLAGS=
8181
OUTPUT=
82+
MDFLAG=0
8283
MCOSMO=0
8384
INTENT=ld
8485
NEED_JOIN=
@@ -88,9 +89,8 @@ APELINKFLAGS=
8889
FLAGS_X86_64=
8990
FLAGS_AARCH64=
9091
INPUT_FILE_COUNT=0
91-
MDFLAG=0
92-
NEED_DEPENDENCY_OUTPUT=
9392
DEPENDENCY_OUTPUT=
93+
NEED_DEPENDENCY_OUTPUT=
9494
for x; do
9595
if [ x"$x" != x"${x#* }" ]; then
9696
fatal_error "arguments containing spaces unsupported: $x"
@@ -267,8 +267,8 @@ LDFLAGS_AARCH64="$LDFLAGS -L$BIN/../aarch64-linux-cosmo/lib -Wl,-T,$BIN/../aarch
267267
LDLIBS_AARCH64="-lcosmo"
268268

269269
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ]; then
270-
CFLAGS_X86_64="${CFLAGS_X86_64} -fpatchable-function-entry=18,16"
271-
CFLAGS_AARCH64="${CFLAGS_AARCH64} -fpatchable-function-entry=7,6"
270+
CFLAGS_X86_64="${CFLAGS_X86_64} -fpatchable-function-entry=18,16 -fno-inline-functions-called-once"
271+
CFLAGS_AARCH64="${CFLAGS_AARCH64} -fpatchable-function-entry=7,6 -fno-inline-functions-called-once"
272272
fi
273273

274274
if [ x"$PROG" != x"${PROG%++}" ]; then

tool/cosmocc/bin/cosmocross

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ fi
193193
if [ x"$OPT" != x"-Os" ] && # $OPT != -Os
194194
[ x"${MODE%tiny}" = x"${MODE}" ]; then # $MODE not in (tiny, aarch64-tiny)
195195
if [ x"$ARCH" = x"x86_64" ]; then
196-
CFLAGS="$CFLAGS -fpatchable-function-entry=18,16"
196+
CFLAGS="$CFLAGS -fpatchable-function-entry=18,16 -fno-inline-functions-called-once"
197197
elif [ x"$ARCH" = x"aarch64" ]; then
198-
CFLAGS="$CFLAGS -fpatchable-function-entry=7,6"
198+
CFLAGS="$CFLAGS -fpatchable-function-entry=7,6 -fno-inline-functions-called-once"
199199
fi
200200
fi
201201

0 commit comments

Comments
 (0)