Cannot set ldflags in buildpack
When using the default buildpack image (ghcr.io/knative/builder-jammy-tiny) the BP_GO_BUILD_LDFLAGS environment variable has no effect.
It is picked up by the buildpack:
Provided Environment Variables
BP_GO_BUILD_LDFLAGS=-X function/build.ProgramVersion=blafromflags
But not used for building:
Executing: go build -o /workspace/bin/faas /workspace/faas
Processing layers
I would expect it to work like it is documented here: https://paketo.io/docs/howto/go/#set--ldflags-for-go-build
When using upstream variant (docker.io/paketobuildpacks/builder-jammy-base) the flags are correctly set:
Paketo Buildpack for Go Build 2.2.25
Executing build process
Running 'go build -o /layers/paketo-buildpacks_go-build/targets/bin "-ldflags=-X function/build.ProgramVersion=blafromflags" -buildmode pie -trimpath .'
go: no main packages to build
It was set like this in the func.yaml
build:
buildEnvs:
- name: BP_GO_BUILD_LDFLAGS
value: "-X function/build.ProgramVersion=blafromflags"
Is this for local or on-cluster build?
This is with a local build with Podman v5.2.2 on RHEL 9.5
Hey @matejvasek, are you still working on this? If not, I’d like to take it up.
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.
Can we re-open this?