Blob Blame History Raw
From 4f3e80094626a2b67075efdb6b899f2ab806725c Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Mon, 3 Jan 2022 18:40:21 -0500
Subject: [PATCH 4/5] arm: Explicitly disable unwind tables

Some clang builds (e.g., Fedora's) enable unwind tables by default. As
tinygo does not need nor support them, that leads to undefined symbols
when linking.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 builder/library.go    | 2 +-
 compileopts/target.go | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/builder/library.go b/builder/library.go
index 73079785..012e4053 100644
--- a/builder/library.go
+++ b/builder/library.go
@@ -120,7 +120,7 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ
 		}
 	}
 	if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
-		args = append(args, "-fshort-enums", "-fomit-frame-pointer", "-mfloat-abi=soft")
+		args = append(args, "-fshort-enums", "-fomit-frame-pointer", "-mfloat-abi=soft", "-fno-unwind-tables")
 	}
 	if strings.HasPrefix(target, "riscv32-") {
 		args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128")
diff --git a/compileopts/target.go b/compileopts/target.go
index 2e5f5487..829b481e 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -256,6 +256,7 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
 		spec.Features = "+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
 	case "arm":
 		spec.CPU = "generic"
+		spec.CFlags = append(spec.CFlags, "-fno-unwind-tables")
 		switch strings.Split(triple, "-")[0] {
 		case "armv5":
 			spec.Features = "+armv5t,+strict-align,-thumb-mode"
-- 
2.31.1