Description
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
I attempted to cross compile this example application for (1) glibc sysroot and (2) musl libc sysroot.
I got a segfault in the first case, and loader issues in the second case. I did not realise tinygo was not looking at CC and picked up my Ubuntu installed GCC crosscompiler "arm-linux-gnueabihf-gcc" which was for ARMv7.
tinygo version 0.20.0 linux/amd64 (using go version go1.16.2 and LLVM version 11.0.0)
~/go-example$ export CC=/home/flotter/xxx/build/rpiv6/glibc/gcc/bin/armv6-rpi-linux-gnueabihf-gcc
OR
~/go-example$ export CC=/home/flotter/xxx/build/rpiv6/musl/gcc/bin/armv6-rpi-linux-musleabihf-gcc
~/go-example$ export CGO_ENABLED=1
~/go-example$ export GOOS=linux
~/go-example$ export GOARCH=arm
~/go-example$ export GOARM=6
~/go-example$ tinygo env
GOOS="linux"
GOARCH="arm"
GOROOT="/usr/lib/go-1.16"
GOPATH="/home/flotter/work"
GOCACHE="/home/flotter/.cache/tinygo"
CGO_ENABLED="1"
TINYGOROOT="/usr/local/lib/tinygo"
/go-example$ CGO_ENABLE=1 tinygo build -o test_cross test.go
error: failed to link /tmp/tinygo2943599410/main: exec: "arm-linux-gnueabihf-gcc": executable file not found in $PATH
(1) Question: It looks like tinygo does not look at CC. Is it possible to tell Tinygo which compiler to use?
(2) Question: It does not look like tinygo looks at GOARM. Can I use it to build for an ARM v6 (i.e. Raspberry Pi Zero/1) ?