aboutsummaryrefslogtreecommitdiffhomepage
path: root/compileopts/target.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2020-09-23 19:14:21 +0200
committerRon Evans <[email protected]>2020-10-02 08:54:43 +0200
commit7123941df061f8e4d4a8aa27662b02fb04101ae9 (patch)
tree3c2cb65ebb7a2e38b77f44668a45671f8bffec3d /compileopts/target.go
parent05d2f2c412c351d1262094bf5f75d55eb9b2fbde (diff)
downloadtinygo-7123941df061f8e4d4a8aa27662b02fb04101ae9.tar.gz
tinygo-7123941df061f8e4d4a8aa27662b02fb04101ae9.zip
main: add support for debugging qemu-user targets
This commit allows debugging like the following: GOARCH=arm tinygo gdb ./testdata/alias.go This can be very useful to debug issues on a different instruction set architecture but still on a host system. I tested the following 7 configurations to make sure it works and I didn't break anything: GOOS=amd64 GOOS=386 GOOS=arm GOOS=arm64 tinygo gdb -target=hifive1-qemu tinygo gdb -target=cortex-m-qemu tinygo gdb -target=microbit
Diffstat (limited to 'compileopts/target.go')
-rw-r--r--compileopts/target.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/compileopts/target.go b/compileopts/target.go
index 89e40252a..f95c48559 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -231,16 +231,15 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
// No target spec available. Use the default one, useful on most systems
// with a regular OS.
spec := TargetSpec{
- Triple: triple,
- GOOS: goos,
- GOARCH: goarch,
- BuildTags: []string{goos, goarch},
- Compiler: "clang",
- Linker: "cc",
- CFlags: []string{"--target=" + triple},
- GDB: "gdb",
- PortReset: "false",
- FlashMethod: "native",
+ Triple: triple,
+ GOOS: goos,
+ GOARCH: goarch,
+ BuildTags: []string{goos, goarch},
+ Compiler: "clang",
+ Linker: "cc",
+ CFlags: []string{"--target=" + triple},
+ GDB: "gdb",
+ PortReset: "false",
}
if goos == "darwin" {
spec.LDFlags = append(spec.LDFlags, "-Wl,-dead_strip")
@@ -249,16 +248,15 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
}
if goarch != runtime.GOARCH {
// Some educated guesses as to how to invoke helper programs.
+ 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.GDB = "arm-linux-gnueabihf-gdb"
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.GDB = "aarch64-linux-gnu-gdb"
spec.Emulator = []string{"qemu-aarch64", "-L", "/usr/aarch64-linux-gnu"}
}
if goarch == "386" && runtime.GOARCH == "amd64" {