Add a variable to allow adding extra parameters to -ldflags in the GO_LDFLAGS variable, the main usecase is setting the application version similar to https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/go.bbclass?id=be665a79831c3dab7623e75d112bb35d72e39a82#n44 Current implementation: GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'"' Suggestion: GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"' Then in the recipe something like GO_EXTRA_LDFLAGS="-X main.Version=v1.0.0" or GO_EXTRA_LDFLAGS="-X main.Version=${PV}" can be used Current workaround: append the flag to GO_LINKMODE
Can't you use GO_LDFLAGS:append = "xxx" for this?
Ahmen, does Richard's suggestion work for you? If so please close this enhancement.
Unfortunately it doesn't work. The goal is to add parameters inside the '-ldflags' quote, I tried using your suggestion using: GO_LDFLAGS:append = ' -ldflags="-X main.Version=v1.0.0"' Which would result in GO_LDFLAGS = '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'" -ldflags="-X main.Version=v1.0.0"' But that overrode the previous '-ldflags' content, breaking qa You can try this by adding GO_LDFLAGS:append = ' -ldflags="-X main.Version=v1.0.0"' to the end of poky/meta/recipes-extended/go-examples/go-helloworld_0.1.bb and building "bitbake go-helloworld", it will result in qa failures (do_package_qa) That is why I am suggesting to add a variable *inside* the '-ldflags' quote, i.e. to result in: GO_LDFLAGS = '-ldflags="${GO_RPATH} ${GO_LINKMODE} -X main.Version=v1.0.0 -extldflags '${GO_EXTLDFLAGS}'"' with one occurence of '-ldflags' Maybe someone with better go linker understanding can share a better solution.
Ahmed, can you send the patch to the list?
Sent: https://lists.openembedded.org/g/openembedded-core/message/157449
Hey Randy, do I need to assign the bug to someone for integration?
Hi Ahmen, Thanks for sending the patch to the list. It can take a while for changes to make it through our QA process and when we are doing a release for 3.4 which was going on last week, it can take even longer. You patch is merged now though: https://git.openembedded.org/openembedded-core/commit/?id=eaa7a61dab9a1d7bb039f16abdd9aacb44faa595 so I've marked this issue as resolved/fixed. Thanks!