Skip to content

Commit

Permalink
arm: use -fomit-frame-pointer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aykevl committed Apr 7, 2020
1 parent 639ec1e commit dd0fb1d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builder/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions targets/cortex-m.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"-mthumb",
"-Werror",
"-fshort-enums",
"-fomit-frame-pointer",
"-fno-exceptions", "-fno-unwind-tables",
"-ffunction-sections", "-fdata-sections"
],
Expand Down
1 change: 1 addition & 0 deletions targets/gameboy-advance.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"-Oz",
"-Werror",
"-fshort-enums",
"-fomit-frame-pointer",
"-Qunused-arguments",
"-fno-exceptions", "-fno-unwind-tables",
"-ffunction-sections", "-fdata-sections"
Expand Down

0 comments on commit dd0fb1d

Please sign in to comment.