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

fix darwin-arm64 generated go-bindata #44

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

lalyos
Copy link
Contributor

@lalyos lalyos commented Sep 17, 2023

Right now master is broken for macs with arm64:

$ GOOS=darwin GOARCH=amd64 GO111MODULE=off go build .
# ok

$ GOOS=darwin GOARCH=arm64 GO111MODULE=off go build .
./basher.go:58:9: undefined: RestoreAsset

Its a combination of 2 issues:

  • outdated go-bindata used to generate arm64 for darwin
  • Makefile copy-paste error

Outdated go-bindata

RestoreAsset is clearly missing from bash_darwin_arm64.go. I tried to reproduce the same file, but couldn't get even close to it.
after running make bash all other os/arch combination was almost identical (except from timestamp):

git diff --numstat
1       1       bash_darwin_amd64.go
146     14      bash_darwin_arm64.go
1       1       bash_linux_amd64.go
1       1       bash_linux_arm.go
1       1       bash_linux_arm64.go

but bash_darwin_arm64.go was somehow really different. I started to chase down how it could happened. Because go-basher was created before go modules, go-bindata was installed by good old go get:

make deps -n
go get -u github.com/a-urth/go-bindata/...

But this way go-bindata version was never pinned to an exact version (git commit) just something happend to be on the environment where make bash was run.

First of all there are different go-bindata package is used in the roo and in the example dir:

go get -u github.com/a-urth/go-bindata/...

go get github.com/jteeuwen/go-bindata/...

Which one is the correct? Unfortunately both of them are archived, but there is a
https://github.com/go-bindata/go-bindata fork which is still alive and even made go mod compatible.

I stared to git bisect to find the exact version was used and found:

$ go-bindata -tags=darwin,amd64 -o=bash_darwin_arm64.go -prefix=.bash/osx-amd64 -pkg=basher .bash/osx-amd64; git diff --numstat bash_darwin_arm64.go

146     14      bash_darwin_arm64.go

$ go-bindata-2014-11-20-bbd0c6e -tags=darwin,amd64 -o=bash_darwin_arm64.go -prefix=.bash/osx-amd64 -pkg=basher .bash/osx-amd64; git diff --numstat bash_darwin_arm64.go

# no diff means exact same

Actually it was tagged as v3.0.7, but if you call go-bindata -version its annoyingly always say v3.1.0 as they forgot to update go-bindata/version.go (wtf)

So I used github.com/go-bindata/go-bindata which does has a v3.1.3 tag, but it doesn't follows go's recommendation:

The recommended strategy is to develop v2+ modules in a directory named after the major version suffix.

So right now make deps could use: go install github.com/go-bindata/go-bindata/v3/...@v3.1.3

Makefile copy paste error:

If you check the 2 last line in Makefile's bash target

go-basher/Makefile

Lines 39 to 40 in 43d5d65

go-bindata -tags=darwin,amd64 -o=bash_darwin_arm64.go -prefix=$(BASH_DIR)/osx-amd64 -pkg=basher $(BASH_DIR)/osx-amd64
go-bindata -tags=darwin,amd64 -o=bash_darwin_amd64.go -prefix=$(BASH_DIR)/osx-amd64 -pkg=basher $(BASH_DIR)/osx-amd64

Line 39. supposed to generate the arm64 version, but: tags, prefix and input dir doesn't matches.

@progrium progrium merged commit 5f673cf into progrium:master Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants