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

Unbuildable: github.com/klauspost/pgzip #152

Open
simulance opened this issue Aug 14, 2023 · 2 comments
Open

Unbuildable: github.com/klauspost/pgzip #152

simulance opened this issue Aug 14, 2023 · 2 comments

Comments

@simulance
Copy link

simulance commented Aug 14, 2023

Attempt 1: on darwin_arm64

$ plz build ///third_party/go/github.com_klauspost_pgzip//:pgzip
Build stopped after 8.29s. 1 target failed:
    ///third_party/go/github.com_klauspost_pgzip//:pgzip
Error building target ///third_party/go/github.com_klauspost_pgzip//:pgzip: exit status 1
pkg/darwin_amd64/github.com/klauspost/pgzip/gunzip.go, line 26, column 2: could not import github.com/klauspost/compress/flate (open : no such file or directory)
$ 

Attempt 2: on darwin_arm64 cross-compiling to linux_amd64

$ plz build ///third_party/go/github.com_klauspost_pgzip//:pgzip -a linux_amd64
Build stopped after 40ms. 1 target failed:
    ///third_party/go/github.com_klauspost_pgzip_linux_amd64//:pgzip
Subrepo third_party/go/github.com_klauspost_pgzip_linux_amd64 is not defined (referenced by command-line targets)
$ 

Attempt 3: on linux_amd64

$ plz build ///third_party/go/github.com_klauspost_pgzip//:pgzip
Build stopped after 23.32s. 1 target failed:
    ///third_party/go/github.com_klauspost_pgzip//:pgzip
Error building target ///third_party/go/github.com_klauspost_pgzip//:pgzip: exit status 1
pkg/linux_amd64/github.com/klauspost/pgzip/gunzip.go, line 26, column 2: could not import github.com/klauspost/compress/flate (open : no such file or directory)
$ 

The standard go command builds it fine but there appears to be no way of building it using Please 17.3.0.

Repro script
plz init

mkdir plugins
cat > plugins/BUILD << EOF
plugin_repo(
    name = "go",
    revision="v1.8.1",
)
EOF

cat >> .plzconfig << EOF
[Plugin "go"]
Target = //plugins:go
GoTool = //third_party/go:toolchain|go
EOF

mkdir -p third_party/go
cat > third_party/go/BUILD << EOF
subinclude('///go//build_defs:go')
go_toolchain(name='toolchain', version='1.20.7')
go_repo(module="github.com/klauspost/compress", version="v1.16.7")
go_repo(module="github.com/klauspost/pgzip", version="v1.2.6")
EOF

plz build ///third_party/go/github.com_klauspost_pgzip//:pgzip
plz build ///third_party/go/github.com_klauspost_pgzip//:pgzip -a linux_amd64
@peterebden
Copy link
Contributor

This appears to be because github.com/klauspost/pgzip doesn't have a go.mod file so we don't attach dependencies properly.

I suppose it needs to try to figure out that it should be doing that from the source, which I think might be tricky to fully generalise (the module location isn't extant in the import path). Alternatively maybe we allow a deps argument on go_repo to let the user hint this where necessary.

@peterebden
Copy link
Contributor

Ah ok we already have that, it's requirements. The following works:

go_repo(
    module = "github.com/klauspost/compress",
    version = "v1.16.7",
)

go_repo(
    module="github.com/klauspost/pgzip",
    version="v1.2.6",
    requirements = ["github.com/klauspost/compress"],
)
$ plz build ///third_party/go/github.com_klauspost_pgzip//:pgzip
Build finished; total time 11.95s, incrementality 62.5%. Outputs:
///third_party/go/github.com_klauspost_pgzip//:pgzip:
  plz-out/gen/third_party/go/github.com_klauspost_pgzip/pgzip.a

I don't think that fixes the cross-compile issue which seems more generic... We've talked a few times about revisiting how architectures work in the face of things like go_repo that extensively use subrepos.

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

No branches or pull requests

2 participants