Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not import machine (no package for import machine)compiler #43079

Closed
alperenkilic opened this issue Dec 8, 2020 · 5 comments
Closed

could not import machine (no package for import machine)compiler #43079

alperenkilic opened this issue Dec 8, 2020 · 5 comments

Comments

@alperenkilic
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.15.6 darwin/amd64

Does this issue reproduce with the latest release?

➜ ~ git:(master) ✗ tinygo version
tinygo version 0.16.0 darwin/amd64 (using go version go1.15.6 and LLVM version 10.0.1)
Ekran Resmi 2020-12-08 22 38 29

What operating system and processor architecture are you using (go env)?

GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/alperen/Library/Caches/go-build" GOENV="/Users/alperen/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/alperen/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/alperen/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_r/kff8ys5x4y7ct7djw7tblv4h0000gn/T/go-build298683877=/tmp/go-build -gno-record-gcc-switches -fno-common" Output
$ go env

What did you do?

gorobot.go:4:2: cannot find package "machine" in any of:
/usr/local/go/src/machine (from $GOROOT)
/Users/alperen/go/src/machine (from $GOPATH)

https://play.golang.org/p/-yEb1jgtiwN

What did you expect to see?

What did you see instead?

@AlexRouSg
Copy link
Contributor

@bcmills
Copy link
Contributor

bcmills commented Dec 8, 2020

The error message here is correct: machine is not a package in the Go standard library.

From what I understand, the machine package may be associated with the TinyGo project. It's a bit disappointing that they've coopted a standard-library path (see #32819) instead of using a domain-prefixed import path like those used for other third-party packages, but that's an issue to raise with the TinyGo maintainers, not something we should address in the mainline go command.

(CC @aykevl)

@bcmills bcmills closed this as completed Dec 8, 2020
@aykevl
Copy link

aykevl commented Dec 21, 2020

@bcmills thanks for CCing me! Yes, this definitely is a TinyGo issue which doesn't belong in the Go project itself.

It's a bit disappointing that they've coopted a standard-library path (see #32819) instead of using a domain-prefixed import path like those used for other third-party packages,

It seemed like a good idea at the time but now not so much. However, changing the import path is going to be difficult so it has to be done only when the benefits are significant. That said, for TinyGo the machine package is just as important as the runtime package: the runtime package depends on it.

Yesterday I looked into using tinygo.org/x/machine instead so that the Go toolchain can deal with it, but then I ran into the fact that I can't redirect it to the actual location (github.com/tinygo-org/tinygo/src/machine). I could use tinygo.org/x/tinygo/src/machine instead but that seems ugly to me, especially for a package that is often needed. This issue of vanity import paths of a subdirectory has been raised before (#34055, #33562) but so far without solution.

I know this is somewhat off topic for this issue but any ideas here would be appreciated.

@bcmills
Copy link
Contributor

bcmills commented Dec 22, 2020

@aykevl, the Go standard library currently vendors in a few external libraries (such as golang.org/x/sys/cpu) for internal use. Would it make sense to similarly move the TinyGo libraries out to a separate repo and vendor them back in?

(Unfortunately, at the moment the Go vendoring approach does not allow user code to import the same vendored packages, so today that approach would result in some code duplication that might be too costly in an embedded context; see #30241 for more detail and some alternatives under consideration.)

@aykevl
Copy link

aykevl commented Feb 17, 2021

@bcmills technically yes but I would really like to keep all the code in a single repository. Otherwise adding support for a new chip (which happens much more often than adding a new architecture) would require changing multiple repositories. Therefore I'm hoping #34055 will get accepted which would provide a way to transition away from these paths.

@golang golang locked and limited conversation to collaborators Feb 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants