From ebec9ce9c029ce56820b6b07051cd6ad76988e30 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/4] 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 a84896c9..cf654748 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -248,9 +248,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",
}
@@ -272,18 +273,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