From fc3c536ec2fab9f8caad29bee206ec87997c6b30 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 21 Feb 2024 13:20:21 -0800 Subject: [PATCH] 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. --- tool/cosmocc/bin/cosmocc | 8 ++++---- tool/cosmocc/bin/cosmocross | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tool/cosmocc/bin/cosmocc b/tool/cosmocc/bin/cosmocc index af8f38f67..d63e159bf 100755 --- a/tool/cosmocc/bin/cosmocc +++ b/tool/cosmocc/bin/cosmocc @@ -79,6 +79,7 @@ OPT= ARGS= FLAGS= OUTPUT= +MDFLAG=0 MCOSMO=0 INTENT=ld NEED_JOIN= @@ -88,9 +89,8 @@ APELINKFLAGS= FLAGS_X86_64= FLAGS_AARCH64= INPUT_FILE_COUNT=0 -MDFLAG=0 -NEED_DEPENDENCY_OUTPUT= DEPENDENCY_OUTPUT= +NEED_DEPENDENCY_OUTPUT= for x; do if [ x"$x" != x"${x#* }" ]; then fatal_error "arguments containing spaces unsupported: $x" @@ -267,8 +267,8 @@ LDFLAGS_AARCH64="$LDFLAGS -L$BIN/../aarch64-linux-cosmo/lib -Wl,-T,$BIN/../aarch LDLIBS_AARCH64="-lcosmo" if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ]; then - CFLAGS_X86_64="${CFLAGS_X86_64} -fpatchable-function-entry=18,16" - CFLAGS_AARCH64="${CFLAGS_AARCH64} -fpatchable-function-entry=7,6" + CFLAGS_X86_64="${CFLAGS_X86_64} -fpatchable-function-entry=18,16 -fno-inline-functions-called-once" + CFLAGS_AARCH64="${CFLAGS_AARCH64} -fpatchable-function-entry=7,6 -fno-inline-functions-called-once" fi if [ x"$PROG" != x"${PROG%++}" ]; then diff --git a/tool/cosmocc/bin/cosmocross b/tool/cosmocc/bin/cosmocross index ba6d3e54a..94490d941 100755 --- a/tool/cosmocc/bin/cosmocross +++ b/tool/cosmocc/bin/cosmocross @@ -193,9 +193,9 @@ fi if [ x"$OPT" != x"-Os" ] && # $OPT != -Os [ x"${MODE%tiny}" = x"${MODE}" ]; then # $MODE not in (tiny, aarch64-tiny) if [ x"$ARCH" = x"x86_64" ]; then - CFLAGS="$CFLAGS -fpatchable-function-entry=18,16" + CFLAGS="$CFLAGS -fpatchable-function-entry=18,16 -fno-inline-functions-called-once" elif [ x"$ARCH" = x"aarch64" ]; then - CFLAGS="$CFLAGS -fpatchable-function-entry=7,6" + CFLAGS="$CFLAGS -fpatchable-function-entry=7,6 -fno-inline-functions-called-once" fi fi