summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Hossam <Ahmed.Hossam@opensynergy.com>2021-10-26 20:56:42 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-08 23:41:00 +0000
commit2f3ee2aff27881ba1d658218e959491e148b8859 (patch)
tree981fe69945e840967e94dd57628240785d56d762
parent1eb9a963ffd0d08823ee994f0b40c1c8db8ddfb0 (diff)
downloadpoky-2f3ee2aff27881ba1d658218e959491e148b8859.tar.gz
go.bbclass: Allow adding parameters to go ldflags
Currently, there is no clean way to pass extra parameters to the go tool link, which is passed by the go build ldflags flag, the append needs to happen inside the quotes of the ldflags parameter See [YOCTO #14554]. Add a variable to allow adding extra parameters to -ldflags in the GO_LDFLAGS variable, one of the main usecases is setting the application version. For example, adding to the recipe something like GO_EXTRA_LDFLAGS="-X main.Version=v1.0.0" or GO_EXTRA_LDFLAGS="-X main.Version=${PV}" (From OE-Core rev: 4c0c5edbb561f2bd21bba979ed7553fb3b717116) Signed-off-by: Ahmed Hossam <Ahmed.Hossam@opensynergy.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> (cherry picked from commit eaa7a61dab9a1d7bb039f16abdd9aacb44faa595) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/go.bbclass3
1 files changed, 2 insertions, 1 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index 0dd0c5f1d2..aa54b4a08c 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -41,7 +41,8 @@ GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS
41GO_LINKMODE ?= "" 41GO_LINKMODE ?= ""
42GO_LINKMODE:class-nativesdk = "--linkmode=external" 42GO_LINKMODE:class-nativesdk = "--linkmode=external"
43GO_LINKMODE:class-native = "--linkmode=external" 43GO_LINKMODE:class-native = "--linkmode=external"
44GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'"' 44GO_EXTRA_LDFLAGS ?= ""
45GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"'
45export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath" 46export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath"
46export GOPATH_OMIT_IN_ACTIONID ?= "1" 47export GOPATH_OMIT_IN_ACTIONID ?= "1"
47export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c" 48export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c"