Browse Source

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.
pull/1039/head
Ayke van Laethem 5 years ago
committed by Ayke
parent
commit
dd0fb1dd9a
  1. 2
      builder/library.go
  2. 1
      targets/cortex-m.json
  3. 1
      targets/gameboy-advance.json

2
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")

1
targets/cortex-m.json

@ -13,6 +13,7 @@
"-mthumb",
"-Werror",
"-fshort-enums",
"-fomit-frame-pointer",
"-fno-exceptions", "-fno-unwind-tables",
"-ffunction-sections", "-fdata-sections"
],

1
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"

Loading…
Cancel
Save