Use tinygo to compile arm binary from x64 Linux : undefined reference problems

253 Views Asked by At

I am trying to compile a program with tinygo from Linux, when I enter the following command :

GOARCH=arm tinygo build -o <OutputName> ./main.go

I got :

/usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /tmp/tinygo859602615/main.o: in function `syscall.Seek':
/usr/local/go/src/syscall/syscall_linux_arm.go:60: undefined reference to `syscall.seek'

The relevant codes indicated here above are :

// Underlying system call writes to newoffset via pointer.
// Implemented in assembly to avoid allocation.
func seek(fd int, offset int64, whence int) (newoffset int64, err Errno)

func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
    newoffset, errno := seek(fd, offset, whence)
    if errno != 0 {
        return 0, errno
    }
    return newoffset, nil
}

I have just use sudo apt-get install arm-linux-gnueabihf to install this package.

However, GOARCH=arm go build -o ./main.go works without any problem. Using CGO_ENABLED="0" flag doesn't change anything. I have searched on the Internet and found no similar issues. Thank you for any possible information.

Environment :

Linux 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
go version go1.16.3 linux/amd64
CGO_ENABLED="1"
GOROOT="/usr/local/go"
TINYGOROOT="/usr/local/lib/tinygo"
0

There are 0 best solutions below