All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] go-runtime: fix building without SECURITY_LDFLAGS
@ 2022-01-12 15:28 Dmitry Baryshkov
  2022-01-12 16:15 ` Alexander Kanavin
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Baryshkov @ 2022-01-12 15:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

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>
---
 meta/recipes-devtools/go/go-runtime.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index a08d44dd3a8c..ccb86d4fe9a6 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -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}"
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] go-runtime: fix building without SECURITY_LDFLAGS
  2022-01-12 15:28 [PATCH] go-runtime: fix building without SECURITY_LDFLAGS Dmitry Baryshkov
@ 2022-01-12 16:15 ` Alexander Kanavin
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Kanavin @ 2022-01-12 16:15 UTC (permalink / raw)
  To: Dmitry Baryshkov; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1893 bytes --]

Thanks, this needs to be done in go-target.inc too.

Alex

On Wed, 12 Jan 2022 at 16:28, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
wrote:

> 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>
> ---
>  meta/recipes-devtools/go/go-runtime.inc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/go/go-runtime.inc
> b/meta/recipes-devtools/go/go-runtime.inc
> index a08d44dd3a8c..ccb86d4fe9a6 100644
> --- a/meta/recipes-devtools/go/go-runtime.inc
> +++ b/meta/recipes-devtools/go/go-runtime.inc
> @@ -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}"
> --
> 2.30.2
>
>

[-- Attachment #2: Type: text/html, Size: 2595 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-12 16:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 15:28 [PATCH] go-runtime: fix building without SECURITY_LDFLAGS Dmitry Baryshkov
2022-01-12 16:15 ` Alexander Kanavin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.