Blob Blame History Raw
From bc8ebbf8b8f7b4e83f34a7fd90fbf64a8108f539 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 3/3] 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 ba5f7382..411d99d9 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -247,9 +247,10 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
 		GOARCH:           goarch,
 		BuildTags:        []string{goos, goarch},
 		Scheduler:        "tasks",
-		Linker:           "cc",
 		DefaultStackSize: 1024 * 64, // 64kB
 		CFlags:           []string{"--target=" + triple},
+		Linker:           "clang",
+		LDFlags:          []string{"--target=" + triple},
 		GDB:              []string{"gdb"},
 		PortReset:        "false",
 	}
@@ -268,18 +269,12 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
 		spec.GDB = []string{"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.31.1