Get --ftrace working on aarch64

This change implements a new approach to function call logging, that's
based on the GCC flag: -fpatchable-function-entry. Read the commentary
in build/config.mk to learn how it works.
This commit is contained in:
Justine Tunney 2023-06-05 23:35:31 -07:00
parent 5b908bc756
commit eb40cb371d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
934 changed files with 2259 additions and 1268 deletions

View file

@ -43,7 +43,7 @@ $(THIRD_PARTY_ARGON2_A).pkg: \
# we can't use ubsan because:
# it's just too slow to be practical (like 6s vs. 13s)
$(THIRD_PARTY_ARGON2_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections \
-fno-sanitize=undefined

View file

@ -63,7 +63,7 @@ o/$(MODE)/third_party/bzip2/bzip2recover.com.dbg: \
@$(APELINK)
$(THIRD_PARTY_BZIP2_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -103,7 +103,7 @@ o/$(MODE)/third_party/chibicc/as.com.dbg: \
@$(APELINK)
o/$(MODE)/third_party/chibicc/chibicc.o: private \
OVERRIDE_CPPFLAGS += $(THIRD_PARTY_CHIBICC_DEFINES)
CPPFLAGS += $(THIRD_PARTY_CHIBICC_DEFINES )
THIRD_PARTY_CHIBICC_LIBS = $(foreach x,$(THIRD_PARTY_CHIBICC_ARTIFACTS),$($(x)))
THIRD_PARTY_CHIBICC_SRCS = $(foreach x,$(THIRD_PARTY_CHIBICC_ARTIFACTS),$($(x)_SRCS))

View file

@ -46,7 +46,7 @@ ifneq ($(MODE),tinylinux)
# README file recommends -O3
# It does double performance in default mode
o/$(MODE)/third_party/dlmalloc/dlmalloc.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3
endif
endif
@ -54,14 +54,14 @@ endif
# we can't use address sanitizer because:
# address sanitizer depends on dlmalloc
o/$(MODE)/third_party/dlmalloc/dlmalloc.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffreestanding \
-fno-sanitize=address
# we must segregate codegen because:
# file contains multiple independently linkable apis
o/$(MODE)/third_party/dlmalloc/dlmalloc.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -48,7 +48,7 @@ $(THIRD_PARTY_DOUBLECONVERSION_A).pkg: \
$(foreach x,$(THIRD_PARTY_DOUBLECONVERSION_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_DOUBLECONVERSION_A_OBJS): private \
OVERRIDE_CXXFLAGS += \
CXXFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -39,7 +39,7 @@ $(THIRD_PARTY_GDTOA_A).pkg: \
$(foreach x,$(THIRD_PARTY_GDTOA_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_GDTOA_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -81,14 +81,14 @@ $(THIRD_PARTY_GGML_A).pkg: \
$(foreach x,$(THIRD_PARTY_GGML_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_GGML_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3 \
-ffunction-sections \
-fdata-sections
ifeq ($(ARCH), x86_64)
$(THIRD_PARTY_GGML_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-msse3 \
-mavx \
-mavx2 \
@ -97,13 +97,13 @@ $(THIRD_PARTY_GGML_A_OBJS): private \
endif
o/opt/third_party/ggml/ggml.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-x-no-pg
ifeq ($(ARCH), x86_64)
o/rel/third_party/ggml/ggml.o \
o/opt/third_party/ggml/ggml.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fschedule-insns2 \
-mred-zone
endif

View file

@ -209,7 +209,7 @@ $(THIRD_PARTY_LIBCXX_A).pkg: \
$(foreach x,$(THIRD_PARTY_LIBCXX_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_LIBCXX_A_OBJS): private \
OVERRIDE_CXXFLAGS += \
CXXFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -44,7 +44,7 @@ $(THIRD_PARTY_LINENOISE_A).pkg: \
$(foreach x,$(THIRD_PARTY_LINENOISE_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_LINENOISE_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fno-jump-tables \
-ffunction-sections \
-fdata-sections

View file

@ -148,15 +148,15 @@ $(THIRD_PARTY_LUA_A).pkg: \
o/$(MODE)/third_party/lua/lmathlib.o \
o//third_party/lua/lgc.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O2
o/$(MODE)/third_party/lua/lvm.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fno-gcse
$(THIRD_PARTY_LUA_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -162,15 +162,15 @@ o/$(MODE)/third_party/make/make.com: \
o/$(MODE)/third_party/make/strcache.o \
o/$(MODE)/third_party/make/expand.o \
o/$(MODE)/third_party/make/read.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O2
o/$(MODE)/third_party/make/hash.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3
$(THIRD_PARTY_MAKE_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-DNO_ARCHIVES \
-DHAVE_CONFIG_H \
-DSTACK_FRAME_UNLIMITED \

View file

@ -42,7 +42,7 @@ $(THIRD_PARTY_MAXMIND_A).pkg: \
$(foreach x,$(THIRD_PARTY_MAXMIND_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_MAXMIND_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fdata-sections \
-ffunction-sections

View file

@ -48,27 +48,27 @@ $(THIRD_PARTY_MBEDTLS_A).pkg: \
$(foreach x,$(THIRD_PARTY_MBEDTLS_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_MBEDTLS_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fdata-sections \
-ffunction-sections
o/$(MODE)/third_party/mbedtls/everest.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3
o/$(MODE)/third_party/mbedtls/bigmul4.o \
o/$(MODE)/third_party/mbedtls/bigmul6.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O2
ifeq ($(ARCH), x86_64)
o/$(MODE)/third_party/mbedtls/shiftright-avx.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3 -mavx
endif
o/$(MODE)/third_party/mbedtls/zeroize.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3 \
-x-no-pg \
-fomit-frame-pointer \

View file

@ -135,7 +135,7 @@ o/$(MODE)/third_party/mbedtls/test/%.com.runs: o/$(MODE)/third_party/mbedtls/tes
@$(COMPILE) -ACHECK -wtT$@ $(VM) $< $(TESTARGS)
o/$(MODE)/third_party/mbedtls/test/lib.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fdata-sections \
-ffunction-sections

View file

@ -91,7 +91,7 @@ void log_analyzer( void *ctx, int level,
/* Invalid minor version used when not specifying a min/max version or expecting a test to fail */
#define TEST_SSL_MINOR_VERSION_NONE -1
s
typedef struct handshake_test_options
{
const char *cipher;

View file

@ -40,7 +40,7 @@ $(THIRD_PARTY_NSYNC_MEM_A).pkg: \
$(foreach x,$(THIRD_PARTY_NSYNC_MEM_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_NSYNC_MEM_A_OBJS): private \
OVERRIDE_CCFLAGS += \
CCFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -50,7 +50,7 @@ $(THIRD_PARTY_NSYNC_A).pkg: \
$(foreach x,$(THIRD_PARTY_NSYNC_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_NSYNC_A_OBJS): private \
OVERRIDE_CCFLAGS += \
CCFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -342,7 +342,7 @@ static PyMethodDef cosmo_methods[] = {
{"getcpucore", cosmo_getcpucore, METH_NOARGS, getcpucore_doc},
{"getcpunode", cosmo_getcpunode, METH_NOARGS, getcpunode_doc},
#endif /* __x86_64__ */
#ifdef __PG__
#ifdef FTRACE
{"ftrace", cosmo_ftrace, METH_NOARGS, ftrace_doc},
#endif
{0},

View file

@ -3375,7 +3375,7 @@ o/$(MODE)/third_party/python/Modules/posixmodule.o: \
$(THIRD_PARTY_PYTHON_STAGE1_A_OBJS) \
$(THIRD_PARTY_PYTHON_STAGE2_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fwrapv \
-ffunction-sections \
-fdata-sections
@ -3384,7 +3384,7 @@ o/$(MODE)/third_party/python/Python/ceval.o \
o/$(MODE)/third_party/python/Objects/object.o \
o/$(MODE)/third_party/python/Python/graminit.o \
o/$(MODE)/third_party/python/Objects/abstract.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fno-function-sections \
-fno-data-sections
@ -3402,7 +3402,7 @@ o/$(MODE)/third_party/python/Objects/memoryobject.o \
o/$(MODE)/third_party/python/Objects/unicodeobject.o \
o/$(MODE)/third_party/python/Python/ast.o \
o/$(MODE)/third_party/python/Python/compile.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fpie
o//third_party/python/Modules/_decimal/libmpdec/basearith.o \
@ -3431,38 +3431,38 @@ o//third_party/python/Objects/obmalloc.o \
o//third_party/python/Objects/funcobject.o \
o//third_party/python/Objects/pyhash.o \
o//third_party/python/Python/ceval.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O2
$(THIRD_PARTY_PYTHON_STAGE1_A_OBJS) \
$(THIRD_PARTY_PYTHON_STAGE2_A_OBJS): private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DPy_BUILD_CORE \
-DMULTIARCH='"x86_64-cosmo"'
ifneq ($(MODE),dbg)
$(THIRD_PARTY_PYTHON_STAGE1_A_OBJS) \
$(THIRD_PARTY_PYTHON_STAGE2_A_OBJS): private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DNDEBUG
endif
o/$(MODE)/third_party/python/Python/sysmodule.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-DABIFLAGS='"m"'
# NOTE: Care must be taken that the compiler doesn't try to "optimize"
# the indirect jumps by sharing them between all opcodes. Such
# optimizations can be disabled on gcc by using -fno-gcse.
o/$(MODE)/third_party/python/Python/ceval.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fno-gcse
# Issue #23654: Turn off ICC's tail call optimization for the
# stack_overflow generator. ICC turns the recursive tail
# call into a loop. [Let's do GCC too, just to be safe.]
o/$(MODE)/third_party/python/Modules/faulthandler.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fno-optimize-sibling-calls
o/$(MODE)/third_party/python/Lib/mimetypes.o: private PYFLAGS += -Y.python/mime.types

View file

@ -194,18 +194,18 @@ o/$(MODE)/third_party/quickjs/unicode_gen.com.dbg: \
@$(APELINK)
$(THIRD_PARTY_QUICKJS_OBJS): private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DCONFIG_BIGNUM \
-DCONFIG_VERSION=\"2021-03-27\"
o/tiny/third_party/quickjs/call.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O2
# TODO(jart): Replace alloca() calls with malloc().
o/$(MODE)/third_party/quickjs/libregexp.o \
o/$(MODE)/third_party/quickjs/quickjs.o: private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DSTACK_FRAME_UNLIMITED
o/$(MODE)/third_party/quickjs/call.o: private QUOTA = -M1024m -C32 -L180

View file

@ -51,7 +51,7 @@ $(THIRD_PARTY_REGEX_OBJS): third_party/regex/regex.mk
o/$(MODE)/third_party/regex/regcomp.o \
o/$(MODE)/third_party/regex/regexec.o \
o/$(MODE)/third_party/regex/tre-mem.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
$(OLD_CODE)
.PHONY: o/$(MODE)/third_party/regex

View file

@ -138,12 +138,12 @@ THIRD_PARTY_SQLITE3_CPPFLAGS_DEBUG = -DSQLITE_DEBUG
endif
$(THIRD_PARTY_SQLITE3_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
$(THIRD_PARTY_SQLITE3_FLAGS) \
$(THIRD_PARTY_SQLITE3_CPPFLAGS_DEBUG) \
$(THIRD_PARTY_SQLITE3_SHELL_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
$(THIRD_PARTY_SQLITE3_FLAGS) \
$(THIRD_PARTY_SQLITE3_CPPFLAGS_DEBUG) \
-DHAVE_READLINE=0 \
@ -170,16 +170,16 @@ o//third_party/sqlite3/parse.o \
o//third_party/sqlite3/select.o \
o//third_party/sqlite3/pragma.o \
o//third_party/sqlite3/vdbe.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-Os
o/$(MODE)/third_party/sqlite3/shell.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-DSTACK_FRAME_UNLIMITED
$(THIRD_PARTY_SQLITE3_A_OBJS) \
$(THIRD_PARTY_SQLITE3_SHELL_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fdata-sections \
-ffunction-sections
@ -187,7 +187,7 @@ $(THIRD_PARTY_SQLITE3_SHELL_OBJS): private \
o/$(MODE)/third_party/sqlite3/expr.o \
o/$(MODE)/third_party/sqlite3/printf.o \
o/$(MODE)/third_party/sqlite3/parse.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-fpie
o/$(MODE)/third_party/sqlite3/shell.o: private QUOTA = -M512m -C16 -L180

View file

@ -56,16 +56,16 @@ $(THIRD_PARTY_STB_A).pkg: \
$(foreach x,$(THIRD_PARTY_STB_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_STB_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections
o/$(MODE)/third_party/stb/stb_vorbis.o: private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DSTACK_FRAME_UNLIMITED
o/$(MODE)/third_party/stb/stb_truetype.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-Os
THIRD_PARTY_STB_LIBS = $(foreach x,$(THIRD_PARTY_STB_ARTIFACTS),$($(x)))

View file

@ -51,7 +51,7 @@ o/$(MODE)/third_party/unzip/unzip.com.dbg: \
@$(APELINK)
$(THIRD_PARTY_UNZIP_A_OBJS): private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DUSE_BZIP2 \
-DUNICODE_SUPPORT \
-DHAVE_UNLINK \
@ -60,7 +60,7 @@ $(THIRD_PARTY_UNZIP_A_OBJS): private \
-DNO_LCHMOD
$(THIRD_PARTY_UNZIP_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
$(OLD_CODE)
THIRD_PARTY_UNZIP_COMS = o/$(MODE)/third_party/unzip/unzip.com

View file

@ -34,7 +34,7 @@ THIRD_PARTY_XED_A_DEPS := \
ifneq ($(ARCH), aarch64)
o/$(MODE)/third_party/xed/x86ild.greg.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-mstringop-strategy=unrolled_loop
endif
@ -48,7 +48,7 @@ $(THIRD_PARTY_XED_A).pkg: \
$(foreach x,$(THIRD_PARTY_XED_A_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/third_party/xed/x86ild.greg.o: private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-O3
HIRD_PARTY_XED_LIBS = $(foreach x,$(THIRD_PARTY_XED_ARTIFACTS),$($(x)))

View file

@ -151,7 +151,7 @@ o/$(MODE)/third_party/zip/zipfile_.o \
o/$(MODE)/third_party/zip/zipnote.o \
o/$(MODE)/third_party/zip/zipsplit.o \
o/$(MODE)/third_party/zip/zipup.o: private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DUNIX \
-DMMAP \
-DUNICODE_SUPPORT \

View file

@ -41,7 +41,7 @@ $(THIRD_PARTY_ZLIB_GZ_A).pkg: \
$(foreach x,$(THIRD_PARTY_ZLIB_GZ_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_ZLIB_GZ_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections

View file

@ -45,7 +45,7 @@ o/$(MODE)/third_party/zlib/crc32_simd.o: private \
-msse4.2 \
-mpclmul
$(THIRD_PARTY_ZLIB_A_OBJS): private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DADLER32_SIMD_SSSE3 \
-DCRC32_SIMD_SSE42_PCLMUL \
-DDEFLATE_SLIDE_HASH_SSE2 \
@ -59,7 +59,7 @@ o/$(MODE)/third_party/zlib/crc32_simd.o: private \
TARGET_ARCH += \
-march=armv8-a+aes+crc
$(THIRD_PARTY_ZLIB_A_OBJS): private \
OVERRIDE_CPPFLAGS += \
CPPFLAGS += \
-DADLER32_SIMD_NEON \
-DCRC32_ARMV8_CRC32 \
-DDEFLATE_SLIDE_HASH_NEON \
@ -68,7 +68,7 @@ $(THIRD_PARTY_ZLIB_A_OBJS): private \
endif
$(THIRD_PARTY_ZLIB_A_OBJS): private \
OVERRIDE_CFLAGS += \
CFLAGS += \
-ffunction-sections \
-fdata-sections