Skip to content

Commit dd0fb1d

Browse files
committed
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.
1 parent 639ec1e commit dd0fb1d

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

builder/library.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (l *Library) Load(target string) (path string, err error) {
6969
// Precalculate the flags to the compiler invocation.
7070
args := append(l.cflags(), "-c", "-Oz", "-g", "-ffunction-sections", "-fdata-sections", "-Wno-macro-redefined", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir)
7171
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
72-
args = append(args, "-fshort-enums")
72+
args = append(args, "-fshort-enums", "-fomit-frame-pointer")
7373
}
7474
if strings.HasPrefix(target, "riscv32-") {
7575
args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128")

targets/cortex-m.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"-mthumb",
1414
"-Werror",
1515
"-fshort-enums",
16+
"-fomit-frame-pointer",
1617
"-fno-exceptions", "-fno-unwind-tables",
1718
"-ffunction-sections", "-fdata-sections"
1819
],

targets/gameboy-advance.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"-Oz",
1616
"-Werror",
1717
"-fshort-enums",
18+
"-fomit-frame-pointer",
1819
"-Qunused-arguments",
1920
"-fno-exceptions", "-fno-unwind-tables",
2021
"-ffunction-sections", "-fdata-sections"

0 commit comments

Comments
 (0)