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

Go buildpack is not compatible with multi arch builder paketobuildpacks/builder-jammy-buildpackless-tiny:0.0.125 #884

Open
anthonydahanne opened this issue Apr 16, 2024 · 1 comment

Comments

@anthonydahanne
Copy link
Member

anthonydahanne commented Apr 16, 2024

Expected Behavior

Should work on MacOS Silicon

Current Behavior

Works fine on Ubuntu amd64

Possible Solution

review the arguments passed during go build

Steps to Reproduce

On MacOS Silicon based:

Build with single arch builder: works fine

cd paketo-buildpacks/samples/samples/go/mod
pack build mod-sample --buildpack paketo-buildpacks/go -B paketobuildpacks/builder-jammy-buildpackless-tiny:latest

latest: Pulling from paketobuildpacks/builder-jammy-buildpackless-tiny
Digest: sha256:ee3e15c022b075b75a375b3d51c2e4dd67cc27c13a97b81a702c825a64c1b57a
Status: Image is up to date for paketobuildpacks/builder-jammy-buildpackless-tiny:latest
latest: Pulling from paketobuildpacks/run-jammy-tiny
Digest: sha256:8c9943cbd8bf7a548f02e6acf8ce227df44eb9ebb9598fc90b79aabe4501774d
Status: Downloaded newer image for paketobuildpacks/run-jammy-tiny:latest
docker.io/paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046: Pulling from paketobuildpacks/go
Digest: sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
Status: Image is up to date for paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
docker.io/paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046: Pulling from paketobuildpacks/go
Digest: sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
Status: Image is up to date for paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
0.19.3: Pulling from buildpacksio/lifecycle
Digest: sha256:3184c0c4028b6ca18e851388f3dd54c10fcaea5e6f1e43cf660d0647be69d6cf
Status: Image is up to date for buildpacksio/lifecycle:0.19.3
===> ANALYZING
===> DETECTING
[detector] 4 of 9 buildpacks participating
[detector] paketo-buildpacks/ca-certificates 3.6.8
[detector] paketo-buildpacks/go-dist         2.5.0
[detector] paketo-buildpacks/go-mod-vendor   1.0.29
[detector] paketo-buildpacks/go-build        2.2.1
===> RESTORING
[restorer] Skipping buildpack layer analysis
===> BUILDING
[builder] 
[builder] Paketo Buildpack for CA Certificates 3.6.8
[builder]   https://github.com/paketo-buildpacks/ca-certificates
[builder]   Launch Helper: Contributing to layer
[builder]     Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[builder] Paketo Buildpack for Go Distribution 2.5.0
[builder]   Resolving Go version
[builder]     Candidate version sources (in priority order):
[builder]       go.mod    -> ">= 1.15"
[builder]       <unknown> -> ""
[builder] 
[builder]     Selected Go version (using go.mod): 1.22.0
[builder] 
[builder]   Executing build process
[builder]     Installing Go 1.22.0
[builder]       Completed in 13.876s
[builder] 
[builder]   Generating SBOM for /layers/paketo-buildpacks_go-dist/go
[builder]       Completed in 2ms
[builder] 
[builder] Paketo Buildpack for Go Mod Vendor 1.0.29
[builder]   Executing build process
[builder]     Running 'go mod vendor'
[builder]       go: downloading github.com/gorilla/mux v1.8.0
[builder]       Completed in 525ms
[builder] 
[builder]   Generating SBOM for /workspace/go.mod
[builder]       Completed in 44ms
[builder] 
[builder] Paketo Buildpack for Go Build 2.2.1
[builder]   Executing build process
[builder]     Running 'go build -o /layers/paketo-buildpacks_go-build/targets/bin -buildmode pie -trimpath .'
[builder]       Completed in 55.235s
[builder] 
[builder]   Generating SBOM for /layers/paketo-buildpacks_go-build/targets/bin
[builder]       Completed in 46ms
[builder] 
[builder]   Assigning launch processes:
[builder]     mod (default): /layers/paketo-buildpacks_go-build/targets/bin/mod
[builder] 
===> EXPORTING
[exporter] Reusing layer 'paketo-buildpacks/ca-certificates:helper'
[exporter] Reusing layer 'paketo-buildpacks/go-build:targets'
[exporter] Adding layer 'buildpacksio/lifecycle:launch.sbom'
[exporter] Reusing 1/1 app layer(s)
[exporter] Adding layer 'buildpacksio/lifecycle:launcher'
[exporter] Reusing layer 'buildpacksio/lifecycle:config'
[exporter] Reusing layer 'buildpacksio/lifecycle:process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting default process type 'mod'
[exporter] Saving mod-sample...
[exporter] *** Images (29cd65538584):
[exporter]       mod-sample
[exporter] Adding cache layer 'paketo-buildpacks/go-dist:go'
[exporter] Adding cache layer 'paketo-buildpacks/go-mod-vendor:mod-cache'
[exporter] Adding cache layer 'paketo-buildpacks/go-build:gocache'
[exporter] Adding cache layer 'buildpacksio/lifecycle:cache.sbom'
Successfully built image mod-sample

Build with multi arch builder: fails

cd paketo-buildpacks/samples/samples/go/mod
pack build mod-sample --buildpack paketo-buildpacks/go -B paketobuildpacks/builder-jammy-buildpackless-tiny:0.0.125


0.0.125: Pulling from paketobuildpacks/builder-jammy-buildpackless-tiny
Digest: sha256:977227ade60b80da02d5c5cdc3abcca13eaef7e94940f00d82a2748fc69c61e8
Status: Image is up to date for paketobuildpacks/builder-jammy-buildpackless-tiny:0.0.125
latest: Pulling from paketobuildpacks/run-jammy-tiny
Digest: sha256:8c9943cbd8bf7a548f02e6acf8ce227df44eb9ebb9598fc90b79aabe4501774d
Status: Downloaded newer image for paketobuildpacks/run-jammy-tiny:latest
docker.io/paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046: Pulling from paketobuildpacks/go
Digest: sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
Status: Image is up to date for paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
docker.io/paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046: Pulling from paketobuildpacks/go
Digest: sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
Status: Image is up to date for paketobuildpacks/go@sha256:36f17d4008d44d0c0fb368fff6022d32cfd6fc9a6989c3f98fc3d1dc73470046
0.19.1: Pulling from buildpacksio/lifecycle
Digest: sha256:0b6eb9408cd2d54873b49b24d755924bf1909a2c3dfdefbd7feb5b3702edda58
Status: Image is up to date for buildpacksio/lifecycle:0.19.1
===> ANALYZING
===> DETECTING
[detector] 4 of 9 buildpacks participating
[detector] paketo-buildpacks/ca-certificates 3.6.8
[detector] paketo-buildpacks/go-dist         2.5.0
[detector] paketo-buildpacks/go-mod-vendor   1.0.29
[detector] paketo-buildpacks/go-build        2.2.1
===> RESTORING
[restorer] Skipping buildpack layer analysis
===> BUILDING
[builder] 
[builder] Paketo Buildpack for CA Certificates 3.6.8
[builder]   https://github.com/paketo-buildpacks/ca-certificates
[builder]   Launch Helper: Contributing to layer
[builder]     Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[builder] Paketo Buildpack for Go Distribution 2.5.0
[builder]   Resolving Go version
[builder]     Candidate version sources (in priority order):
[builder]       go.mod    -> ">= 1.15"
[builder]       <unknown> -> ""
[builder] 
[builder]     Selected Go version (using go.mod): 1.22.0
[builder] 
[builder]   Executing build process
[builder]     Installing Go 1.22.0
[builder]       Completed in 13.731s
[builder] 
[builder]   Generating SBOM for /layers/paketo-buildpacks_go-dist/go
[builder]       Completed in 2ms
[builder] 
[builder] Paketo Buildpack for Go Mod Vendor 1.0.29
[builder]   Executing build process
[builder]     Running 'go mod vendor'
[builder]       go: downloading github.com/gorilla/mux v1.8.0
[builder]       Completed in 601ms
[builder] 
[builder]   Generating SBOM for /workspace/go.mod
[builder]       Completed in 43ms
[builder] 
[builder] Paketo Buildpack for Go Build 2.2.1
[builder]   Executing build process
[builder]     Running 'go build -o /layers/paketo-buildpacks_go-build/targets/bin -buildmode pie -trimpath .'
[builder]       # runtime/cgo
[builder]       gcc: error: unrecognized command-line option '-m64'
[builder]       Failed after 30.439s
[builder] failed to execute 'go build': exit status 1
[builder] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

Motivations

Multi arch builders and buildpacks are gaining traction; we don't necessarily want Go buildpack arm64 compatibility right now, but at least, it should not fail on MacOS Silicon with a multi arch builder

@anthonydahanne
Copy link
Member Author

Actually, on a Mac Silicon, you can use the existing Go buildpack that is amd64 only, to build an arm64 image:

--env CGO_ENABLED=0 --env GOARCH=arm64

and you're good to go! thanks for the help @dmikusa

That should be a proper workaround waiting for a pure arm64 experience with go-dist support for arm64

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

1 participant