Blob Blame History Raw
From 99cad3f2957e1698a0c4ab1330354800dce2abdf Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Mon, 21 Dec 2020 04:28:59 -0500
Subject: [PATCH 4/7] Use clang to do linking.

This avoids having to guess what the linker name-with-build-triplet is,
as we can just pass the target to it in the same way as the compilation
stage.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 compileopts/target.go | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/compileopts/target.go b/compileopts/target.go
index 8b3c68f..f1aab68 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -237,8 +237,9 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
 		GOARCH:    goarch,
 		BuildTags: []string{goos, goarch},
 		Compiler:  "clang",
-		Linker:    "cc",
 		CFlags:    []string{"--target=" + triple},
+		Linker:    "clang",
+		LDFlags:   []string{"--target=" + triple},
 		GDB:       "gdb",
 		PortReset: "false",
 	}
@@ -255,18 +256,12 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
 		spec.GDB = "gdb-multiarch"
 		if goarch == "arm" && goos == "linux" {
 			spec.CFlags = append(spec.CFlags, "--sysroot=/usr/arm-linux-gnueabihf")
-			spec.Linker = "arm-linux-gnueabihf-gcc"
 			spec.Emulator = []string{"qemu-arm", "-L", "/usr/arm-linux-gnueabihf"}
 		}
 		if goarch == "arm64" && goos == "linux" {
 			spec.CFlags = append(spec.CFlags, "--sysroot=/usr/aarch64-linux-gnu")
-			spec.Linker = "aarch64-linux-gnu-gcc"
 			spec.Emulator = []string{"qemu-aarch64", "-L", "/usr/aarch64-linux-gnu"}
 		}
-		if goarch == "386" && runtime.GOARCH == "amd64" {
-			spec.CFlags = append(spec.CFlags, "-m32")
-			spec.LDFlags = append(spec.LDFlags, "-m32")
-		}
 	}
 	return &spec, nil
 }
-- 
2.29.2