Closed typeless closed 2 years ago
It appears a package you are using depends on os
from the Go standard library, which obviously isn't available for baremetal TinyGo.
Can you share the output of command tinygo list -json
from the same directory you are trying to build from?
Also, if you are trying to build native ELF executables for Ubuntu, see: https://tinygo.org/docs/guides/linux/
Otherwise, you need to specify a build target for tinygo, such as tinygo build -o=out.tiny -target=arduino .
I tried with GOARCH=arm
as mentioned in the guides, but it gave the same build error too.
This is a proprietary project, which contains some information that I am afraid unsuitable to share.
$ tinygo list -json
{
"Dir": "/home/mural/src/castlestech.com/lbox/cmd/uld",
"ImportPath": "castlestech.com/lbox/cmd/uld",
"Name": "main",
"Target": "/home/mural/bin/uld",
"Root": "/home/mural/src/castlestech.com/lbox",
"Module": {
"Path": "castlestech.com/lbox",
"Main": true,
"Dir": "/home/mural/src/castlestech.com/lbox",
"GoMod": "/home/mural/src/castlestech.com/lbox/go.mod",
"GoVersion": "1.13"
},
"Match": [
"."
],
"Stale": true,
"StaleReason": "stale dependency: reflect",
"GoFiles": [
"main.go"
],
"Imports": [
"castlestech.com/lbox/cmd/uld/internal/captype",
"castlestech.com/lbox/cmd/uld/internal/decap",
"castlestech.com/lbox/cmd/uld/internal/download",
"castlestech.com/lbox/cmd/uld/internal/upload",
"flag",
"fmt",
"io",
"log",
"os"
],
"Deps": [
"bufio",
"bytes",
"castlestech.com/lbox/cap/v3",
"castlestech.com/lbox/cap/v4",
"castlestech.com/lbox/cmd/uld/internal/captype",
"castlestech.com/lbox/cmd/uld/internal/decap",
"castlestech.com/lbox/cmd/uld/internal/download",
"castlestech.com/lbox/cmd/uld/internal/upload",
"castlestech.com/lbox/dle",
"castlestech.com/lbox/multitty",
"castlestech.com/lbox/crypto/cipher",
"castlestech.com/lbox/crypto/rsa",
"context",
"crypto",
"crypto/aes",
"crypto/cipher",
"crypto/des",
"crypto/dsa",
"crypto/ecdsa",
"crypto/ed25519",
"crypto/ed25519/internal/edwards25519",
"crypto/ed25519/internal/edwards25519/field",
"crypto/elliptic",
"crypto/elliptic/internal/fiat",
"crypto/internal/randutil",
"crypto/internal/subtle",
"crypto/md5",
"crypto/rand",
"crypto/rsa",
"crypto/sha1",
"crypto/sha256",
"crypto/sha512",
"crypto/subtle",
"crypto/x509",
"crypto/x509/pkix",
"device",
"encoding/asn1",
"encoding/base64",
"encoding/binary",
"encoding/hex",
"encoding/pem",
"errors",
"flag",
"fmt",
"github.com/pkg/term",
"github.com/pkg/term/termios",
"hash",
"internal/bytealg",
"internal/cpu",
"internal/fmtsort",
"internal/itoa",
"internal/oserror",
"internal/race",
"internal/reflectlite",
"internal/task",
"internal/unsafeheader",
"io",
"io/fs",
"io/ioutil",
"log",
"math",
"math/big",
"math/bits",
"math/rand",
"net",
"net/url",
"os",
"os/signal",
"path",
"path/filepath",
"reflect",
"runtime",
"runtime/interrupt",
"sort",
"strconv",
"strings",
"sync",
"sync/atomic",
"syscall",
"time",
"unicode",
"unicode/utf16",
"unicode/utf8",
"unsafe",
"vendor/golang.org/x/crypto/cryptobyte",
"vendor/golang.org/x/crypto/cryptobyte/asn1"
],
"TestGoFiles": [
"download_test.go"
],
"TestImports": [
"bufio",
"context",
"fmt",
"io",
"os",
"os/exec",
"regexp",
"testing",
"time"
]
}
Here is a fix: https://github.com/tinygo-org/tinygo/pull/2114
There are other missing APIs.
internal/decap/decap.go:201:16: Rename not declared by package os
internal/decap/decap.go:231:16: Chdir not declared by package os
internal/decap/decap.go:265:12: NewFile not declared by package os
Should I create a new issue?
You can do that, or create a PR to add these to the os
package :)
Released with 0.20.0 so now closing. Thank you!
I am trying to use tinygo to build a binary for an embedded Linux device. I got the following errors:
TinyGo version:
My build OS: