Skip to content

Cannot set ldflags in buildpack #2719

Open
@andrin55

Description

@andrin55

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"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions