From dd0fb1dd9ad159dc1ff79d3f685a5e368ede3301 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 5 Apr 2020 18:23:19 +0200 Subject: [PATCH] arm: use -fomit-frame-pointer The frame pointer was already omitted in the object files that TinyGo emits, but wasn't yet omitted in the C files it compiles. Omitting the frame pointer is good for code size (and perhaps performance). The frame pointer was originally used for printing stack traces in a debugger. However, advances in DWARF debug info have made it largely unnecessary (debug info contains enough information now to recover the frame pointer even without an explicit frame pointer register). In fact, GDB has been able to produce backtraces in TinyGo compiled code for a while now while it didn't include a frame pointer. --- builder/library.go | 2 +- targets/cortex-m.json | 1 + targets/gameboy-advance.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builder/library.go b/builder/library.go index a0d522a3..d85e4d36 100644 --- a/builder/library.go +++ b/builder/library.go @@ -69,7 +69,7 @@ func (l *Library) Load(target string) (path string, err error) { // Precalculate the flags to the compiler invocation. args := append(l.cflags(), "-c", "-Oz", "-g", "-ffunction-sections", "-fdata-sections", "-Wno-macro-redefined", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir) if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") { - args = append(args, "-fshort-enums") + args = append(args, "-fshort-enums", "-fomit-frame-pointer") } if strings.HasPrefix(target, "riscv32-") { args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128") diff --git a/targets/cortex-m.json b/targets/cortex-m.json index 979c09d1..11370d28 100644 --- a/targets/cortex-m.json +++ b/targets/cortex-m.json @@ -13,6 +13,7 @@ "-mthumb", "-Werror", "-fshort-enums", + "-fomit-frame-pointer", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections" ], diff --git a/targets/gameboy-advance.json b/targets/gameboy-advance.json index f7ac76eb..8051acf3 100644 --- a/targets/gameboy-advance.json +++ b/targets/gameboy-advance.json @@ -15,6 +15,7 @@ "-Oz", "-Werror", "-fshort-enums", + "-fomit-frame-pointer", "-Qunused-arguments", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections"