]> code.ossystems Code Review - openembedded-core.git/commitdiff
go: fix building without SECURITY_LDFLAGS
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Thu, 13 Jan 2022 19:22:49 +0000 (22:22 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 14 Jan 2022 09:25:27 +0000 (09:25 +0000)
Commit 9985b17a30bb ("go: correctly set debug-prefix-map and build
directory") has changed CGO_LDFLAGS to the manually crafted version of
LDFLAGS to strip out DEBUG_PREFIX_MAP contents.

However this manually crafted version includes ${SECURITY_LDFLAGS}.

If security_flags.inc is not included, the variable is not defined, thus
CGO_LDFLAGS will include the '${SECURITY_LDFLAGS}' literally. When
building the recipe, the build would break with the follwing message:

aarch64-linaro-linux-gcc: error: ${SECURITY_LDFLAGS}: No such file or directory

So, instead of manually specifying variable contents, perform the
expected action: filter offending arguments out of LDFLAGS.

Cc: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/go/go-runtime.inc
meta/recipes-devtools/go/go-target.inc

index a08d44dd3a8cd58ba74a14488d55de063bc7829c..ccb86d4fe9a69bd9a70d41d4733f1fe84073b9fe 100644 (file)
@@ -10,7 +10,8 @@ DEBUG_PREFIX_MAP = "\
 export CGO_CFLAGS = "${CFLAGS}"
 export CGO_CPPFLAGS = "${CPPFLAGS}"
 export CGO_CXXFLAGS = "${CXXFLAGS}"
-export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
+# Filter out -fdebug-prefix-map options as they clash with the GO's build system
+export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
 export GOCACHE = "${B}/.cache"
 
 GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
index 51f1b79cc320db9d28f1c3196803eef0f19c97b4..b0d487ae1c21831c29e10be97108df7f9a50a6d8 100644 (file)
@@ -9,7 +9,8 @@ DEBUG_PREFIX_MAP = "\
 export CGO_CFLAGS = "${CFLAGS}"
 export CGO_CPPFLAGS = "${CPPFLAGS}"
 export CGO_CXXFLAGS = "${CXXFLAGS}"
-export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
+# Filter out -fdebug-prefix-map options as they clash with the GO's build system
+export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
 
 export GOCACHE = "${B}/.cache"
 GO_LDFLAGS = ""