[3/6] go: correctly set debug-prefix-map and build directory

Message ID 20220101112959.1866747-3-alex@linutronix.de
State Accepted, archived
Commit 9985b17a30bb9b9f1bc82a44662687db5cead66e
Headers show
Series [1/6] go: log build id computations | expand

Commit Message

Alexander Kanavin Jan. 1, 2022, 11:29 a.m. UTC
Go has its own system for creating temporary build
sub-directories with randomized names, and setting
up debug-prefix-map on the fly to prevent those
directories leaking into target binaries. OE's own
settings were clashing with it, so this change
carefully avoids the two stepping on each other.

Additionally, the top level build directory cannot
be named 'go-something'.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes/go.bbclass                 |  2 +-
 meta/recipes-devtools/go/go-common.inc  |  2 +-
 meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
 meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
 4 files changed, 18 insertions(+), 3 deletions(-)

Comments

Dmitry Baryshkov Jan. 10, 2022, 4:34 a.m. UTC | #1
сб, 1 янв. 2022 г. в 14:30, Alexander Kanavin <alex.kanavin@gmail.com>:
>
> Go has its own system for creating temporary build
> sub-directories with randomized names, and setting
> up debug-prefix-map on the fly to prevent those
> directories leaking into target binaries. OE's own
> settings were clashing with it, so this change
> carefully avoids the two stepping on each other.
>
> Additionally, the top level build directory cannot
> be named 'go-something'.
>
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>

This patch breaks the build here, with the following error messages
(full log attached):

| HASH[build go/importer]
| HASH[build go/importer]: "go1.17.5"
| HASH[build go/importer]: "compile\n"
| HASH[build go/importer]: "goos linux goarch arm64\n"
| HASH[build go/importer]: "import \"go/importer\"\n"
| HASH[build go/importer]: "omitdebug false standard true local false
prefix \"\"\n"
| HASH[build go/importer]: "modinfo \"\"\n"
| HASH[build go/importer]: "compile compile version go1.17.5 [] []\n"
| HASH[build go/importer]: "=\n"
| HASH /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/src/go/importer/importer.go:
030536f1a71bcd0c3615684f4b94373b4136a282de9e6cd9d283e454704be386
| HASH[build go/importer]: "file importer.go AwU28acbzQw2FWhPS5Q3\n"
| HASH[build go/importer]: "import go/build XGXQDTt1BQjYRjE7nFi7\n"
| HASH[build go/importer]: "import go/internal/gccgoimporter
MqGIqtLxk8pkuc9XENIo\n"
| HASH[build go/importer]: "import go/internal/gcimporter
U16uHUOXrDggYRgVMENf\n"
| HASH[build go/importer]: "import go/internal/srcimporter
vtV3UGYK55GaAj4JI8MN\n"
| HASH[build go/importer]: "import go/token 36MC7EMX8CqyCcPmrSmS\n"
| HASH[build go/importer]: "import go/types EyjwGzDrQ1CtOXxe_UYb\n"
| HASH[build go/importer]: "import io A3HnNVYVSU1F06BuLR5o\n"
| HASH[build go/importer]: "import runtime TtpuHdFJwA5GfsHmM2LT\n"
| HASH[build go/importer]:
b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
| HASH subkey b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
"srcfiles" = e6f8fcd87c2dd28b3381ad27b9938048b5b3bde6a19db4a4837e184ef9cef82a
| HASH subkey b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
"stdout" = 3cb42089ec7038a91addcc400ee71ea90feee998a35e992b699729f04ae85c1a
| go tool dist: FAILED:
/home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/pkg/tool/native_native/go_bootstrap
install -gcflags=all= -ldflags=all= std: exit status 2
| WARNING: /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939:175
exit 2 from './make.bash --target-only --no-banner std'
| WARNING: Backtrace (BB generated script):
| #1: do_compile,
/home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
line 175
| #2: main, /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
line 185


> ---
>  meta/classes/go.bbclass                 |  2 +-
>  meta/recipes-devtools/go/go-common.inc  |  2 +-
>  meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
>  meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
>  4 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
> index 5c1fdd7d5f..9c4c92bffd 100644
> --- a/meta/classes/go.bbclass
> +++ b/meta/classes/go.bbclass
> @@ -67,7 +67,7 @@ GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
>
>  B = "${WORKDIR}/build"
>  export GOPATH = "${B}"
> -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
> +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>  GOTMPDIR[vardepvalue] = ""
>
>  python go_do_unpack() {
> diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc
> index 5bbf35b787..83f8db7b39 100644
> --- a/meta/recipes-devtools/go/go-common.inc
> +++ b/meta/recipes-devtools/go/go-common.inc
> @@ -23,7 +23,7 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
>  SSTATE_SCAN_CMD = "true"
>
>  export GOROOT_OVERRIDE = "1"
> -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
> +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>  GOTMPDIR[vardepvalue] = ""
>  export CGO_ENABLED = "1"
>
> diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
> index 617e6b5414..a08d44dd3a 100644
> --- a/meta/recipes-devtools/go/go-runtime.inc
> +++ b/meta/recipes-devtools/go/go-runtime.inc
> @@ -2,10 +2,15 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
>  PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
>
> +DEBUG_PREFIX_MAP = "\
> +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
> +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
> +"
> +
>  export CGO_CFLAGS = "${CFLAGS}"
>  export CGO_CPPFLAGS = "${CPPFLAGS}"
>  export CGO_CXXFLAGS = "${CXXFLAGS}"
> -export CGO_LDFLAGS = "${LDFLAGS}"
> +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>  export GOCACHE = "${B}/.cache"
>
>  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
> diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc
> index 47b4411d54..51f1b79cc3 100644
> --- a/meta/recipes-devtools/go/go-target.inc
> +++ b/meta/recipes-devtools/go/go-target.inc
> @@ -1,6 +1,16 @@
>  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
>
> +DEBUG_PREFIX_MAP = "\
> +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
> +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
> +"
> +
> +export CGO_CFLAGS = "${CFLAGS}"
> +export CGO_CPPFLAGS = "${CPPFLAGS}"
> +export CGO_CXXFLAGS = "${CXXFLAGS}"
> +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
> +
>  export GOCACHE = "${B}/.cache"
>  GO_LDFLAGS = ""
>  GO_LDFLAGS:class-nativesdk = "-linkmode external"
> --
> 2.20.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#160096): https://lists.openembedded.org/g/openembedded-core/message/160096
> Mute This Topic: https://lists.openembedded.org/mt/88071320/3618183
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [dbaryshkov@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexander Kanavin Jan. 10, 2022, 8:08 a.m. UTC | #2
aarch64-linaro-linux-gcc: error: ${SECURITY_LDFLAGS}: No such file or
directory

You need to find out why the variable isn't expanded. 'bitbake -e
go-runtime' may help.

Alex

On Mon, 10 Jan 2022 at 05:34, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:

> сб, 1 янв. 2022 г. в 14:30, Alexander Kanavin <alex.kanavin@gmail.com>:
> >
> > Go has its own system for creating temporary build
> > sub-directories with randomized names, and setting
> > up debug-prefix-map on the fly to prevent those
> > directories leaking into target binaries. OE's own
> > settings were clashing with it, so this change
> > carefully avoids the two stepping on each other.
> >
> > Additionally, the top level build directory cannot
> > be named 'go-something'.
> >
> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
>
> This patch breaks the build here, with the following error messages
> (full log attached):
>
> | HASH[build go/importer]
> | HASH[build go/importer]: "go1.17.5"
> | HASH[build go/importer]: "compile\n"
> | HASH[build go/importer]: "goos linux goarch arm64\n"
> | HASH[build go/importer]: "import \"go/importer\"\n"
> | HASH[build go/importer]: "omitdebug false standard true local false
> prefix \"\"\n"
> | HASH[build go/importer]: "modinfo \"\"\n"
> | HASH[build go/importer]: "compile compile version go1.17.5 [] []\n"
> | HASH[build go/importer]: "=\n"
> | HASH
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/src/go/importer/importer.go:
> 030536f1a71bcd0c3615684f4b94373b4136a282de9e6cd9d283e454704be386
> | HASH[build go/importer]: "file importer.go AwU28acbzQw2FWhPS5Q3\n"
> | HASH[build go/importer]: "import go/build XGXQDTt1BQjYRjE7nFi7\n"
> | HASH[build go/importer]: "import go/internal/gccgoimporter
> MqGIqtLxk8pkuc9XENIo\n"
> | HASH[build go/importer]: "import go/internal/gcimporter
> U16uHUOXrDggYRgVMENf\n"
> | HASH[build go/importer]: "import go/internal/srcimporter
> vtV3UGYK55GaAj4JI8MN\n"
> | HASH[build go/importer]: "import go/token 36MC7EMX8CqyCcPmrSmS\n"
> | HASH[build go/importer]: "import go/types EyjwGzDrQ1CtOXxe_UYb\n"
> | HASH[build go/importer]: "import io A3HnNVYVSU1F06BuLR5o\n"
> | HASH[build go/importer]: "import runtime TtpuHdFJwA5GfsHmM2LT\n"
> | HASH[build go/importer]:
> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
> | HASH subkey
> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
> "srcfiles" =
> e6f8fcd87c2dd28b3381ad27b9938048b5b3bde6a19db4a4837e184ef9cef82a
> | HASH subkey
> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
> "stdout" = 3cb42089ec7038a91addcc400ee71ea90feee998a35e992b699729f04ae85c1a
> | go tool dist: FAILED:
>
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/pkg/tool/native_native/go_bootstrap
> install -gcflags=all= -ldflags=all= std: exit status 2
> | WARNING:
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939:175
> exit 2 from './make.bash --target-only --no-banner std'
> | WARNING: Backtrace (BB generated script):
> | #1: do_compile,
>
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
> line 175
> | #2: main,
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
> line 185
>
>
> > ---
> >  meta/classes/go.bbclass                 |  2 +-
> >  meta/recipes-devtools/go/go-common.inc  |  2 +-
> >  meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
> >  meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
> >  4 files changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
> > index 5c1fdd7d5f..9c4c92bffd 100644
> > --- a/meta/classes/go.bbclass
> > +++ b/meta/classes/go.bbclass
> > @@ -67,7 +67,7 @@ GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
> >
> >  B = "${WORKDIR}/build"
> >  export GOPATH = "${B}"
> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
> >  GOTMPDIR[vardepvalue] = ""
> >
> >  python go_do_unpack() {
> > diff --git a/meta/recipes-devtools/go/go-common.inc
> b/meta/recipes-devtools/go/go-common.inc
> > index 5bbf35b787..83f8db7b39 100644
> > --- a/meta/recipes-devtools/go/go-common.inc
> > +++ b/meta/recipes-devtools/go/go-common.inc
> > @@ -23,7 +23,7 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
> >  SSTATE_SCAN_CMD = "true"
> >
> >  export GOROOT_OVERRIDE = "1"
> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
> >  GOTMPDIR[vardepvalue] = ""
> >  export CGO_ENABLED = "1"
> >
> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
> b/meta/recipes-devtools/go/go-runtime.inc
> > index 617e6b5414..a08d44dd3a 100644
> > --- a/meta/recipes-devtools/go/go-runtime.inc
> > +++ b/meta/recipes-devtools/go/go-runtime.inc
> > @@ -2,10 +2,15 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
> >  PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
> >
> > +DEBUG_PREFIX_MAP = "\
> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
> > +"
> > +
> >  export CGO_CFLAGS = "${CFLAGS}"
> >  export CGO_CPPFLAGS = "${CPPFLAGS}"
> >  export CGO_CXXFLAGS = "${CXXFLAGS}"
> > -export CGO_LDFLAGS = "${LDFLAGS}"
> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED}
> ${SECURITY_LDFLAGS}"
> >  export GOCACHE = "${B}/.cache"
> >
> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
> > diff --git a/meta/recipes-devtools/go/go-target.inc
> b/meta/recipes-devtools/go/go-target.inc
> > index 47b4411d54..51f1b79cc3 100644
> > --- a/meta/recipes-devtools/go/go-target.inc
> > +++ b/meta/recipes-devtools/go/go-target.inc
> > @@ -1,6 +1,16 @@
> >  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk
> go-native"
> >
> > +DEBUG_PREFIX_MAP = "\
> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
> > +"
> > +
> > +export CGO_CFLAGS = "${CFLAGS}"
> > +export CGO_CPPFLAGS = "${CPPFLAGS}"
> > +export CGO_CXXFLAGS = "${CXXFLAGS}"
> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED}
> ${SECURITY_LDFLAGS}"
> > +
> >  export GOCACHE = "${B}/.cache"
> >  GO_LDFLAGS = ""
> >  GO_LDFLAGS:class-nativesdk = "-linkmode external"
> > --
> > 2.20.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#160096):
> https://lists.openembedded.org/g/openembedded-core/message/160096
> > Mute This Topic: https://lists.openembedded.org/mt/88071320/3618183
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> dbaryshkov@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> With best wishes
> Dmitry
>
Dmitry Baryshkov Jan. 12, 2022, 2:47 p.m. UTC | #3
пн, 10 янв. 2022 г. в 11:08, Alexander Kanavin <alex.kanavin@gmail.com>:
>
> aarch64-linaro-linux-gcc: error: ${SECURITY_LDFLAGS}: No such file or directory
>
> You need to find out why the variable isn't expanded. 'bitbake -e go-runtime' may help.

The distro I was using here (rpb if that matters) does not use
security_flags.inc, so SECURITY_LDFLAGS are not defined.
Please remove such dependency. We can not expect that every distro
would include security_flags.inc

>
> Alex
>
> On Mon, 10 Jan 2022 at 05:34, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
>>
>> сб, 1 янв. 2022 г. в 14:30, Alexander Kanavin <alex.kanavin@gmail.com>:
>> >
>> > Go has its own system for creating temporary build
>> > sub-directories with randomized names, and setting
>> > up debug-prefix-map on the fly to prevent those
>> > directories leaking into target binaries. OE's own
>> > settings were clashing with it, so this change
>> > carefully avoids the two stepping on each other.
>> >
>> > Additionally, the top level build directory cannot
>> > be named 'go-something'.
>> >
>> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
>>
>> This patch breaks the build here, with the following error messages
>> (full log attached):
>>
>> | HASH[build go/importer]
>> | HASH[build go/importer]: "go1.17.5"
>> | HASH[build go/importer]: "compile\n"
>> | HASH[build go/importer]: "goos linux goarch arm64\n"
>> | HASH[build go/importer]: "import \"go/importer\"\n"
>> | HASH[build go/importer]: "omitdebug false standard true local false
>> prefix \"\"\n"
>> | HASH[build go/importer]: "modinfo \"\"\n"
>> | HASH[build go/importer]: "compile compile version go1.17.5 [] []\n"
>> | HASH[build go/importer]: "=\n"
>> | HASH /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/src/go/importer/importer.go:
>> 030536f1a71bcd0c3615684f4b94373b4136a282de9e6cd9d283e454704be386
>> | HASH[build go/importer]: "file importer.go AwU28acbzQw2FWhPS5Q3\n"
>> | HASH[build go/importer]: "import go/build XGXQDTt1BQjYRjE7nFi7\n"
>> | HASH[build go/importer]: "import go/internal/gccgoimporter
>> MqGIqtLxk8pkuc9XENIo\n"
>> | HASH[build go/importer]: "import go/internal/gcimporter
>> U16uHUOXrDggYRgVMENf\n"
>> | HASH[build go/importer]: "import go/internal/srcimporter
>> vtV3UGYK55GaAj4JI8MN\n"
>> | HASH[build go/importer]: "import go/token 36MC7EMX8CqyCcPmrSmS\n"
>> | HASH[build go/importer]: "import go/types EyjwGzDrQ1CtOXxe_UYb\n"
>> | HASH[build go/importer]: "import io A3HnNVYVSU1F06BuLR5o\n"
>> | HASH[build go/importer]: "import runtime TtpuHdFJwA5GfsHmM2LT\n"
>> | HASH[build go/importer]:
>> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> | HASH subkey b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> "srcfiles" = e6f8fcd87c2dd28b3381ad27b9938048b5b3bde6a19db4a4837e184ef9cef82a
>> | HASH subkey b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> "stdout" = 3cb42089ec7038a91addcc400ee71ea90feee998a35e992b699729f04ae85c1a
>> | go tool dist: FAILED:
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/pkg/tool/native_native/go_bootstrap
>> install -gcflags=all= -ldflags=all= std: exit status 2
>> | WARNING: /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939:175
>> exit 2 from './make.bash --target-only --no-banner std'
>> | WARNING: Backtrace (BB generated script):
>> | #1: do_compile,
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
>> line 175
>> | #2: main, /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
>> line 185
>>
>>
>> > ---
>> >  meta/classes/go.bbclass                 |  2 +-
>> >  meta/recipes-devtools/go/go-common.inc  |  2 +-
>> >  meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
>> >  meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
>> >  4 files changed, 18 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
>> > index 5c1fdd7d5f..9c4c92bffd 100644
>> > --- a/meta/classes/go.bbclass
>> > +++ b/meta/classes/go.bbclass
>> > @@ -67,7 +67,7 @@ GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
>> >
>> >  B = "${WORKDIR}/build"
>> >  export GOPATH = "${B}"
>> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
>> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>> >  GOTMPDIR[vardepvalue] = ""
>> >
>> >  python go_do_unpack() {
>> > diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc
>> > index 5bbf35b787..83f8db7b39 100644
>> > --- a/meta/recipes-devtools/go/go-common.inc
>> > +++ b/meta/recipes-devtools/go/go-common.inc
>> > @@ -23,7 +23,7 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
>> >  SSTATE_SCAN_CMD = "true"
>> >
>> >  export GOROOT_OVERRIDE = "1"
>> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
>> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>> >  GOTMPDIR[vardepvalue] = ""
>> >  export CGO_ENABLED = "1"
>> >
>> > diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
>> > index 617e6b5414..a08d44dd3a 100644
>> > --- a/meta/recipes-devtools/go/go-runtime.inc
>> > +++ b/meta/recipes-devtools/go/go-runtime.inc
>> > @@ -2,10 +2,15 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
>> >  PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
>> >
>> > +DEBUG_PREFIX_MAP = "\
>> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
>> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
>> > +"
>> > +
>> >  export CGO_CFLAGS = "${CFLAGS}"
>> >  export CGO_CPPFLAGS = "${CPPFLAGS}"
>> >  export CGO_CXXFLAGS = "${CXXFLAGS}"
>> > -export CGO_LDFLAGS = "${LDFLAGS}"
>> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>> >  export GOCACHE = "${B}/.cache"
>> >
>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
>> > diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc
>> > index 47b4411d54..51f1b79cc3 100644
>> > --- a/meta/recipes-devtools/go/go-target.inc
>> > +++ b/meta/recipes-devtools/go/go-target.inc
>> > @@ -1,6 +1,16 @@
>> >  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
>> >
>> > +DEBUG_PREFIX_MAP = "\
>> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
>> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
>> > +"
>> > +
>> > +export CGO_CFLAGS = "${CFLAGS}"
>> > +export CGO_CPPFLAGS = "${CPPFLAGS}"
>> > +export CGO_CXXFLAGS = "${CXXFLAGS}"
>> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>> > +
>> >  export GOCACHE = "${B}/.cache"
>> >  GO_LDFLAGS = ""
>> >  GO_LDFLAGS:class-nativesdk = "-linkmode external"
>> > --
>> > 2.20.1
>> >
>> >
>> > -=-=-=-=-=-=-=-=-=-=-=-
>> > Links: You receive all messages sent to this group.
>> > View/Reply Online (#160096): https://lists.openembedded.org/g/openembedded-core/message/160096
>> > Mute This Topic: https://lists.openembedded.org/mt/88071320/3618183
>> > Group Owner: openembedded-core+owner@lists.openembedded.org
>> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [dbaryshkov@gmail.com]
>> > -=-=-=-=-=-=-=-=-=-=-=-
>> >
>>
>>
>> --
>> With best wishes
>> Dmitry
Dmitry Baryshkov Jan. 12, 2022, 2:55 p.m. UTC | #4
пн, 10 янв. 2022 г. в 11:08, Alexander Kanavin <alex.kanavin@gmail.com>:
>
> aarch64-linaro-linux-gcc: error: ${SECURITY_LDFLAGS}: No such file or directory
>
> You need to find out why the variable isn't expanded. 'bitbake -e go-runtime' may help.

For the reference:

# $CGO_LDFLAGS [2 operations]
#   exported /home/lumag/Projects/RPB/build-rpb/conf/../../layers/openembedded-core/meta/recipes-devtools/go/go-runtime.inc:13
#     [export] "1"
#   set /home/lumag/Projects/RPB/build-rpb/conf/../../layers/openembedded-core/meta/recipes-devtools/go/go-runtime.inc:13
#     "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
# pre-expansion value:
#   "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
export CGO_LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
\${SECURITY_LDFLAGS}"

Quoting bitbake manual:

If the variable expansion syntax is used on a variable that does not
exist, the string is kept as is. For example, given the following
assignment, BAR expands to the literal string "${FOO}" as long as FOO
does not exist.

     BAR = "${FOO}"



>
> Alex
>
> On Mon, 10 Jan 2022 at 05:34, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:
>>
>> сб, 1 янв. 2022 г. в 14:30, Alexander Kanavin <alex.kanavin@gmail.com>:
>> >
>> > Go has its own system for creating temporary build
>> > sub-directories with randomized names, and setting
>> > up debug-prefix-map on the fly to prevent those
>> > directories leaking into target binaries. OE's own
>> > settings were clashing with it, so this change
>> > carefully avoids the two stepping on each other.
>> >
>> > Additionally, the top level build directory cannot
>> > be named 'go-something'.
>> >
>> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
>>
>> This patch breaks the build here, with the following error messages
>> (full log attached):
>>
>> | HASH[build go/importer]
>> | HASH[build go/importer]: "go1.17.5"
>> | HASH[build go/importer]: "compile\n"
>> | HASH[build go/importer]: "goos linux goarch arm64\n"
>> | HASH[build go/importer]: "import \"go/importer\"\n"
>> | HASH[build go/importer]: "omitdebug false standard true local false
>> prefix \"\"\n"
>> | HASH[build go/importer]: "modinfo \"\"\n"
>> | HASH[build go/importer]: "compile compile version go1.17.5 [] []\n"
>> | HASH[build go/importer]: "=\n"
>> | HASH /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/src/go/importer/importer.go:
>> 030536f1a71bcd0c3615684f4b94373b4136a282de9e6cd9d283e454704be386
>> | HASH[build go/importer]: "file importer.go AwU28acbzQw2FWhPS5Q3\n"
>> | HASH[build go/importer]: "import go/build XGXQDTt1BQjYRjE7nFi7\n"
>> | HASH[build go/importer]: "import go/internal/gccgoimporter
>> MqGIqtLxk8pkuc9XENIo\n"
>> | HASH[build go/importer]: "import go/internal/gcimporter
>> U16uHUOXrDggYRgVMENf\n"
>> | HASH[build go/importer]: "import go/internal/srcimporter
>> vtV3UGYK55GaAj4JI8MN\n"
>> | HASH[build go/importer]: "import go/token 36MC7EMX8CqyCcPmrSmS\n"
>> | HASH[build go/importer]: "import go/types EyjwGzDrQ1CtOXxe_UYb\n"
>> | HASH[build go/importer]: "import io A3HnNVYVSU1F06BuLR5o\n"
>> | HASH[build go/importer]: "import runtime TtpuHdFJwA5GfsHmM2LT\n"
>> | HASH[build go/importer]:
>> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> | HASH subkey b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> "srcfiles" = e6f8fcd87c2dd28b3381ad27b9938048b5b3bde6a19db4a4837e184ef9cef82a
>> | HASH subkey b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> "stdout" = 3cb42089ec7038a91addcc400ee71ea90feee998a35e992b699729f04ae85c1a
>> | go tool dist: FAILED:
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/pkg/tool/native_native/go_bootstrap
>> install -gcflags=all= -ldflags=all= std: exit status 2
>> | WARNING: /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939:175
>> exit 2 from './make.bash --target-only --no-banner std'
>> | WARNING: Backtrace (BB generated script):
>> | #1: do_compile,
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
>> line 175
>> | #2: main, /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
>> line 185
>>
>>
>> > ---
>> >  meta/classes/go.bbclass                 |  2 +-
>> >  meta/recipes-devtools/go/go-common.inc  |  2 +-
>> >  meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
>> >  meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
>> >  4 files changed, 18 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
>> > index 5c1fdd7d5f..9c4c92bffd 100644
>> > --- a/meta/classes/go.bbclass
>> > +++ b/meta/classes/go.bbclass
>> > @@ -67,7 +67,7 @@ GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
>> >
>> >  B = "${WORKDIR}/build"
>> >  export GOPATH = "${B}"
>> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
>> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>> >  GOTMPDIR[vardepvalue] = ""
>> >
>> >  python go_do_unpack() {
>> > diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc
>> > index 5bbf35b787..83f8db7b39 100644
>> > --- a/meta/recipes-devtools/go/go-common.inc
>> > +++ b/meta/recipes-devtools/go/go-common.inc
>> > @@ -23,7 +23,7 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
>> >  SSTATE_SCAN_CMD = "true"
>> >
>> >  export GOROOT_OVERRIDE = "1"
>> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
>> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>> >  GOTMPDIR[vardepvalue] = ""
>> >  export CGO_ENABLED = "1"
>> >
>> > diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
>> > index 617e6b5414..a08d44dd3a 100644
>> > --- a/meta/recipes-devtools/go/go-runtime.inc
>> > +++ b/meta/recipes-devtools/go/go-runtime.inc
>> > @@ -2,10 +2,15 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
>> >  PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
>> >
>> > +DEBUG_PREFIX_MAP = "\
>> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
>> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
>> > +"
>> > +
>> >  export CGO_CFLAGS = "${CFLAGS}"
>> >  export CGO_CPPFLAGS = "${CPPFLAGS}"
>> >  export CGO_CXXFLAGS = "${CXXFLAGS}"
>> > -export CGO_LDFLAGS = "${LDFLAGS}"
>> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>> >  export GOCACHE = "${B}/.cache"
>> >
>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
>> > diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc
>> > index 47b4411d54..51f1b79cc3 100644
>> > --- a/meta/recipes-devtools/go/go-target.inc
>> > +++ b/meta/recipes-devtools/go/go-target.inc
>> > @@ -1,6 +1,16 @@
>> >  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
>> >
>> > +DEBUG_PREFIX_MAP = "\
>> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
>> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
>> > +"
>> > +
>> > +export CGO_CFLAGS = "${CFLAGS}"
>> > +export CGO_CPPFLAGS = "${CPPFLAGS}"
>> > +export CGO_CXXFLAGS = "${CXXFLAGS}"
>> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>> > +
>> >  export GOCACHE = "${B}/.cache"
>> >  GO_LDFLAGS = ""
>> >  GO_LDFLAGS:class-nativesdk = "-linkmode external"
>> > --
>> > 2.20.1
>> >
>> >
>> > -=-=-=-=-=-=-=-=-=-=-=-
>> > Links: You receive all messages sent to this group.
>> > View/Reply Online (#160096): https://lists.openembedded.org/g/openembedded-core/message/160096
>> > Mute This Topic: https://lists.openembedded.org/mt/88071320/3618183
>> > Group Owner: openembedded-core+owner@lists.openembedded.org
>> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [dbaryshkov@gmail.com]
>> > -=-=-=-=-=-=-=-=-=-=-=-
>> >
>>
>>
>> --
>> With best wishes
>> Dmitry
Alexander Kanavin Jan. 12, 2022, 3 p.m. UTC | #5
I'm not immediately sure how to solve this though. We do want to keep those
flags when they're defined.

Ideas? Perhaps they could be defined empty in some place which is present
in all distributions?

Alex

On Wed, 12 Jan 2022 at 15:56, Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:

> пн, 10 янв. 2022 г. в 11:08, Alexander Kanavin <alex.kanavin@gmail.com>:
> >
> > aarch64-linaro-linux-gcc: error: ${SECURITY_LDFLAGS}: No such file or
> directory
> >
> > You need to find out why the variable isn't expanded. 'bitbake -e
> go-runtime' may help.
>
> For the reference:
>
> # $CGO_LDFLAGS [2 operations]
> #   exported
> /home/lumag/Projects/RPB/build-rpb/conf/../../layers/openembedded-core/meta/recipes-devtools/go/go-runtime.inc:13
> #     [export] "1"
> #   set
> /home/lumag/Projects/RPB/build-rpb/conf/../../layers/openembedded-core/meta/recipes-devtools/go/go-runtime.inc:13
> #     "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
> # pre-expansion value:
> #   "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
> export CGO_LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
> \${SECURITY_LDFLAGS}"
>
> Quoting bitbake manual:
>
> If the variable expansion syntax is used on a variable that does not
> exist, the string is kept as is. For example, given the following
> assignment, BAR expands to the literal string "${FOO}" as long as FOO
> does not exist.
>
>      BAR = "${FOO}"
>
>
>
> >
> > Alex
> >
> > On Mon, 10 Jan 2022 at 05:34, Dmitry Baryshkov <dbaryshkov@gmail.com>
> wrote:
> >>
> >> сб, 1 янв. 2022 г. в 14:30, Alexander Kanavin <alex.kanavin@gmail.com>:
> >> >
> >> > Go has its own system for creating temporary build
> >> > sub-directories with randomized names, and setting
> >> > up debug-prefix-map on the fly to prevent those
> >> > directories leaking into target binaries. OE's own
> >> > settings were clashing with it, so this change
> >> > carefully avoids the two stepping on each other.
> >> >
> >> > Additionally, the top level build directory cannot
> >> > be named 'go-something'.
> >> >
> >> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> >>
> >> This patch breaks the build here, with the following error messages
> >> (full log attached):
> >>
> >> | HASH[build go/importer]
> >> | HASH[build go/importer]: "go1.17.5"
> >> | HASH[build go/importer]: "compile\n"
> >> | HASH[build go/importer]: "goos linux goarch arm64\n"
> >> | HASH[build go/importer]: "import \"go/importer\"\n"
> >> | HASH[build go/importer]: "omitdebug false standard true local false
> >> prefix \"\"\n"
> >> | HASH[build go/importer]: "modinfo \"\"\n"
> >> | HASH[build go/importer]: "compile compile version go1.17.5 [] []\n"
> >> | HASH[build go/importer]: "=\n"
> >> | HASH
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/src/go/importer/importer.go:
> >> 030536f1a71bcd0c3615684f4b94373b4136a282de9e6cd9d283e454704be386
> >> | HASH[build go/importer]: "file importer.go AwU28acbzQw2FWhPS5Q3\n"
> >> | HASH[build go/importer]: "import go/build XGXQDTt1BQjYRjE7nFi7\n"
> >> | HASH[build go/importer]: "import go/internal/gccgoimporter
> >> MqGIqtLxk8pkuc9XENIo\n"
> >> | HASH[build go/importer]: "import go/internal/gcimporter
> >> U16uHUOXrDggYRgVMENf\n"
> >> | HASH[build go/importer]: "import go/internal/srcimporter
> >> vtV3UGYK55GaAj4JI8MN\n"
> >> | HASH[build go/importer]: "import go/token 36MC7EMX8CqyCcPmrSmS\n"
> >> | HASH[build go/importer]: "import go/types EyjwGzDrQ1CtOXxe_UYb\n"
> >> | HASH[build go/importer]: "import io A3HnNVYVSU1F06BuLR5o\n"
> >> | HASH[build go/importer]: "import runtime TtpuHdFJwA5GfsHmM2LT\n"
> >> | HASH[build go/importer]:
> >> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
> >> | HASH subkey
> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
> >> "srcfiles" =
> e6f8fcd87c2dd28b3381ad27b9938048b5b3bde6a19db4a4837e184ef9cef82a
> >> | HASH subkey
> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
> >> "stdout" =
> 3cb42089ec7038a91addcc400ee71ea90feee998a35e992b699729f04ae85c1a
> >> | go tool dist: FAILED:
> >>
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/pkg/tool/native_native/go_bootstrap
> >> install -gcflags=all= -ldflags=all= std: exit status 2
> >> | WARNING:
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939:175
> >> exit 2 from './make.bash --target-only --no-banner std'
> >> | WARNING: Backtrace (BB generated script):
> >> | #1: do_compile,
> >>
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
> >> line 175
> >> | #2: main,
> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
> >> line 185
> >>
> >>
> >> > ---
> >> >  meta/classes/go.bbclass                 |  2 +-
> >> >  meta/recipes-devtools/go/go-common.inc  |  2 +-
> >> >  meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
> >> >  meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
> >> >  4 files changed, 18 insertions(+), 3 deletions(-)
> >> >
> >> > diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
> >> > index 5c1fdd7d5f..9c4c92bffd 100644
> >> > --- a/meta/classes/go.bbclass
> >> > +++ b/meta/classes/go.bbclass
> >> > @@ -67,7 +67,7 @@ GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
> >> >
> >> >  B = "${WORKDIR}/build"
> >> >  export GOPATH = "${B}"
> >> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
> >> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
> >> >  GOTMPDIR[vardepvalue] = ""
> >> >
> >> >  python go_do_unpack() {
> >> > diff --git a/meta/recipes-devtools/go/go-common.inc
> b/meta/recipes-devtools/go/go-common.inc
> >> > index 5bbf35b787..83f8db7b39 100644
> >> > --- a/meta/recipes-devtools/go/go-common.inc
> >> > +++ b/meta/recipes-devtools/go/go-common.inc
> >> > @@ -23,7 +23,7 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
> >> >  SSTATE_SCAN_CMD = "true"
> >> >
> >> >  export GOROOT_OVERRIDE = "1"
> >> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
> >> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
> >> >  GOTMPDIR[vardepvalue] = ""
> >> >  export CGO_ENABLED = "1"
> >> >
> >> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
> b/meta/recipes-devtools/go/go-runtime.inc
> >> > index 617e6b5414..a08d44dd3a 100644
> >> > --- a/meta/recipes-devtools/go/go-runtime.inc
> >> > +++ b/meta/recipes-devtools/go/go-runtime.inc
> >> > @@ -2,10 +2,15 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
> >> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
> >> >  PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
> >> >
> >> > +DEBUG_PREFIX_MAP = "\
> >> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
> >> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
> >> > +"
> >> > +
> >> >  export CGO_CFLAGS = "${CFLAGS}"
> >> >  export CGO_CPPFLAGS = "${CPPFLAGS}"
> >> >  export CGO_CXXFLAGS = "${CXXFLAGS}"
> >> > -export CGO_LDFLAGS = "${LDFLAGS}"
> >> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED}
> ${SECURITY_LDFLAGS}"
> >> >  export GOCACHE = "${B}/.cache"
> >> >
> >> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
> >> > diff --git a/meta/recipes-devtools/go/go-target.inc
> b/meta/recipes-devtools/go/go-target.inc
> >> > index 47b4411d54..51f1b79cc3 100644
> >> > --- a/meta/recipes-devtools/go/go-target.inc
> >> > +++ b/meta/recipes-devtools/go/go-target.inc
> >> > @@ -1,6 +1,16 @@
> >> >  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
> >> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk
> go-native"
> >> >
> >> > +DEBUG_PREFIX_MAP = "\
> >> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
> >> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
> >> > +"
> >> > +
> >> > +export CGO_CFLAGS = "${CFLAGS}"
> >> > +export CGO_CPPFLAGS = "${CPPFLAGS}"
> >> > +export CGO_CXXFLAGS = "${CXXFLAGS}"
> >> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED}
> ${SECURITY_LDFLAGS}"
> >> > +
> >> >  export GOCACHE = "${B}/.cache"
> >> >  GO_LDFLAGS = ""
> >> >  GO_LDFLAGS:class-nativesdk = "-linkmode external"
> >> > --
> >> > 2.20.1
> >> >
> >> >
> >> > -=-=-=-=-=-=-=-=-=-=-=-
> >> > Links: You receive all messages sent to this group.
> >> > View/Reply Online (#160096):
> https://lists.openembedded.org/g/openembedded-core/message/160096
> >> > Mute This Topic: https://lists.openembedded.org/mt/88071320/3618183
> >> > Group Owner: openembedded-core+owner@lists.openembedded.org
> >> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
> [dbaryshkov@gmail.com]
> >> > -=-=-=-=-=-=-=-=-=-=-=-
> >> >
> >>
> >>
> >> --
> >> With best wishes
> >> Dmitry
>
>
>
> --
> With best wishes
> Dmitry
>
Alexander Kanavin Jan. 12, 2022, 3:07 p.m. UTC | #6
One experiment that can be tried is unsetting DEBUG_PREFIX_MAP in the go
recipe though, but it may make things non-reproducible again.

On Wed, 12 Jan 2022 at 16:01, Alexander Kanavin via lists.openembedded.org
<alex.kanavin=gmail.com@lists.openembedded.org> wrote:

> I'm not immediately sure how to solve this though. We do want to keep
> those flags when they're defined.
>
> Ideas? Perhaps they could be defined empty in some place which is present
> in all distributions?
>
> Alex
>
> On Wed, 12 Jan 2022 at 15:56, Dmitry Baryshkov <dbaryshkov@gmail.com>
> wrote:
>
>> пн, 10 янв. 2022 г. в 11:08, Alexander Kanavin <alex.kanavin@gmail.com>:
>> >
>> > aarch64-linaro-linux-gcc: error: ${SECURITY_LDFLAGS}: No such file or
>> directory
>> >
>> > You need to find out why the variable isn't expanded. 'bitbake -e
>> go-runtime' may help.
>>
>> For the reference:
>>
>> # $CGO_LDFLAGS [2 operations]
>> #   exported
>> /home/lumag/Projects/RPB/build-rpb/conf/../../layers/openembedded-core/meta/recipes-devtools/go/go-runtime.inc:13
>> #     [export] "1"
>> #   set
>> /home/lumag/Projects/RPB/build-rpb/conf/../../layers/openembedded-core/meta/recipes-devtools/go/go-runtime.inc:13
>> #     "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>> # pre-expansion value:
>> #   "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
>> export CGO_LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
>> \${SECURITY_LDFLAGS}"
>>
>> Quoting bitbake manual:
>>
>> If the variable expansion syntax is used on a variable that does not
>> exist, the string is kept as is. For example, given the following
>> assignment, BAR expands to the literal string "${FOO}" as long as FOO
>> does not exist.
>>
>>      BAR = "${FOO}"
>>
>>
>>
>> >
>> > Alex
>> >
>> > On Mon, 10 Jan 2022 at 05:34, Dmitry Baryshkov <dbaryshkov@gmail.com>
>> wrote:
>> >>
>> >> сб, 1 янв. 2022 г. в 14:30, Alexander Kanavin <alex.kanavin@gmail.com
>> >:
>> >> >
>> >> > Go has its own system for creating temporary build
>> >> > sub-directories with randomized names, and setting
>> >> > up debug-prefix-map on the fly to prevent those
>> >> > directories leaking into target binaries. OE's own
>> >> > settings were clashing with it, so this change
>> >> > carefully avoids the two stepping on each other.
>> >> >
>> >> > Additionally, the top level build directory cannot
>> >> > be named 'go-something'.
>> >> >
>> >> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
>> >>
>> >> This patch breaks the build here, with the following error messages
>> >> (full log attached):
>> >>
>> >> | HASH[build go/importer]
>> >> | HASH[build go/importer]: "go1.17.5"
>> >> | HASH[build go/importer]: "compile\n"
>> >> | HASH[build go/importer]: "goos linux goarch arm64\n"
>> >> | HASH[build go/importer]: "import \"go/importer\"\n"
>> >> | HASH[build go/importer]: "omitdebug false standard true local false
>> >> prefix \"\"\n"
>> >> | HASH[build go/importer]: "modinfo \"\"\n"
>> >> | HASH[build go/importer]: "compile compile version go1.17.5 [] []\n"
>> >> | HASH[build go/importer]: "=\n"
>> >> | HASH
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/src/go/importer/importer.go:
>> >> 030536f1a71bcd0c3615684f4b94373b4136a282de9e6cd9d283e454704be386
>> >> | HASH[build go/importer]: "file importer.go AwU28acbzQw2FWhPS5Q3\n"
>> >> | HASH[build go/importer]: "import go/build XGXQDTt1BQjYRjE7nFi7\n"
>> >> | HASH[build go/importer]: "import go/internal/gccgoimporter
>> >> MqGIqtLxk8pkuc9XENIo\n"
>> >> | HASH[build go/importer]: "import go/internal/gcimporter
>> >> U16uHUOXrDggYRgVMENf\n"
>> >> | HASH[build go/importer]: "import go/internal/srcimporter
>> >> vtV3UGYK55GaAj4JI8MN\n"
>> >> | HASH[build go/importer]: "import go/token 36MC7EMX8CqyCcPmrSmS\n"
>> >> | HASH[build go/importer]: "import go/types EyjwGzDrQ1CtOXxe_UYb\n"
>> >> | HASH[build go/importer]: "import io A3HnNVYVSU1F06BuLR5o\n"
>> >> | HASH[build go/importer]: "import runtime TtpuHdFJwA5GfsHmM2LT\n"
>> >> | HASH[build go/importer]:
>> >> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> >> | HASH subkey
>> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> >> "srcfiles" =
>> e6f8fcd87c2dd28b3381ad27b9938048b5b3bde6a19db4a4837e184ef9cef82a
>> >> | HASH subkey
>> b98eef9d67666fef158497b06bd4a9793d63af81f5e9e5008e51e0fa35b86a7d
>> >> "stdout" =
>> 3cb42089ec7038a91addcc400ee71ea90feee998a35e992b699729f04ae85c1a
>> >> | go tool dist: FAILED:
>> >>
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/go/pkg/tool/native_native/go_bootstrap
>> >> install -gcflags=all= -ldflags=all= std: exit status 2
>> >> | WARNING:
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939:175
>> >> exit 2 from './make.bash --target-only --no-banner std'
>> >> | WARNING: Backtrace (BB generated script):
>> >> | #1: do_compile,
>> >>
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
>> >> line 175
>> >> | #2: main,
>> /home/lumag/Projects/RPB/build-rpb/tmp-rpb-glibc/work/armv8a-linaro-linux/go-runtime/1.17.5-r0/temp/run.do_compile.2219939,
>> >> line 185
>> >>
>> >>
>> >> > ---
>> >> >  meta/classes/go.bbclass                 |  2 +-
>> >> >  meta/recipes-devtools/go/go-common.inc  |  2 +-
>> >> >  meta/recipes-devtools/go/go-runtime.inc |  7 ++++++-
>> >> >  meta/recipes-devtools/go/go-target.inc  | 10 ++++++++++
>> >> >  4 files changed, 18 insertions(+), 3 deletions(-)
>> >> >
>> >> > diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
>> >> > index 5c1fdd7d5f..9c4c92bffd 100644
>> >> > --- a/meta/classes/go.bbclass
>> >> > +++ b/meta/classes/go.bbclass
>> >> > @@ -67,7 +67,7 @@ GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
>> >> >
>> >> >  B = "${WORKDIR}/build"
>> >> >  export GOPATH = "${B}"
>> >> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
>> >> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>> >> >  GOTMPDIR[vardepvalue] = ""
>> >> >
>> >> >  python go_do_unpack() {
>> >> > diff --git a/meta/recipes-devtools/go/go-common.inc
>> b/meta/recipes-devtools/go/go-common.inc
>> >> > index 5bbf35b787..83f8db7b39 100644
>> >> > --- a/meta/recipes-devtools/go/go-common.inc
>> >> > +++ b/meta/recipes-devtools/go/go-common.inc
>> >> > @@ -23,7 +23,7 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
>> >> >  SSTATE_SCAN_CMD = "true"
>> >> >
>> >> >  export GOROOT_OVERRIDE = "1"
>> >> > -export GOTMPDIR ?= "${WORKDIR}/go-tmp"
>> >> > +export GOTMPDIR ?= "${WORKDIR}/build-tmp"
>> >> >  GOTMPDIR[vardepvalue] = ""
>> >> >  export CGO_ENABLED = "1"
>> >> >
>> >> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
>> b/meta/recipes-devtools/go/go-runtime.inc
>> >> > index 617e6b5414..a08d44dd3a 100644
>> >> > --- a/meta/recipes-devtools/go/go-runtime.inc
>> >> > +++ b/meta/recipes-devtools/go/go-runtime.inc
>> >> > @@ -2,10 +2,15 @@ DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>> >> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
>> >> >  PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
>> >> >
>> >> > +DEBUG_PREFIX_MAP = "\
>> >> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
>> >> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
>> >> > +"
>> >> > +
>> >> >  export CGO_CFLAGS = "${CFLAGS}"
>> >> >  export CGO_CPPFLAGS = "${CPPFLAGS}"
>> >> >  export CGO_CXXFLAGS = "${CXXFLAGS}"
>> >> > -export CGO_LDFLAGS = "${LDFLAGS}"
>> >> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED}
>> ${SECURITY_LDFLAGS}"
>> >> >  export GOCACHE = "${B}/.cache"
>> >> >
>> >> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
>> >> > diff --git a/meta/recipes-devtools/go/go-target.inc
>> b/meta/recipes-devtools/go/go-target.inc
>> >> > index 47b4411d54..51f1b79cc3 100644
>> >> > --- a/meta/recipes-devtools/go/go-target.inc
>> >> > +++ b/meta/recipes-devtools/go/go-target.inc
>> >> > @@ -1,6 +1,16 @@
>> >> >  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
>> >> >  DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk
>> go-native"
>> >> >
>> >> > +DEBUG_PREFIX_MAP = "\
>> >> > +                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
>> >> > +                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
>> >> > +"
>> >> > +
>> >> > +export CGO_CFLAGS = "${CFLAGS}"
>> >> > +export CGO_CPPFLAGS = "${CPPFLAGS}"
>> >> > +export CGO_CXXFLAGS = "${CXXFLAGS}"
>> >> > +export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED}
>> ${SECURITY_LDFLAGS}"
>> >> > +
>> >> >  export GOCACHE = "${B}/.cache"
>> >> >  GO_LDFLAGS = ""
>> >> >  GO_LDFLAGS:class-nativesdk = "-linkmode external"
>> >> > --
>> >> > 2.20.1
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >> With best wishes
>> >> Dmitry
>>
>>
>>
>> --
>> With best wishes
>> Dmitry
>>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#160486):
> https://lists.openembedded.org/g/openembedded-core/message/160486
> Mute This Topic: https://lists.openembedded.org/mt/88071320/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Otavio Salvador Jan. 12, 2022, 3:07 p.m. UTC | #7
Em qua., 12 de jan. de 2022 às 12:01, Alexander Kanavin
<alex.kanavin@gmail.com> escreveu:
> I'm not immediately sure how to solve this though. We do want to keep those flags when they're defined.
>
> Ideas? Perhaps they could be defined empty in some place which is present in all distributions?

I believe it does make sense; it ought to have a default.
https://github.com/openembedded/openembedded-core/blob/master/meta/conf/distro/include/default-distrovars.inc
sounds like the right place.

Patch

diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index 5c1fdd7d5f..9c4c92bffd 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -67,7 +67,7 @@  GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"
 
 B = "${WORKDIR}/build"
 export GOPATH = "${B}"
-export GOTMPDIR ?= "${WORKDIR}/go-tmp"
+export GOTMPDIR ?= "${WORKDIR}/build-tmp"
 GOTMPDIR[vardepvalue] = ""
 
 python go_do_unpack() {
diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc
index 5bbf35b787..83f8db7b39 100644
--- a/meta/recipes-devtools/go/go-common.inc
+++ b/meta/recipes-devtools/go/go-common.inc
@@ -23,7 +23,7 @@  INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
 SSTATE_SCAN_CMD = "true"
 
 export GOROOT_OVERRIDE = "1"
-export GOTMPDIR ?= "${WORKDIR}/go-tmp"
+export GOTMPDIR ?= "${WORKDIR}/build-tmp"
 GOTMPDIR[vardepvalue] = ""
 export CGO_ENABLED = "1"
 
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index 617e6b5414..a08d44dd3a 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -2,10 +2,15 @@  DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
 DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
 PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
 
+DEBUG_PREFIX_MAP = "\
+                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
+                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
+"
+
 export CGO_CFLAGS = "${CFLAGS}"
 export CGO_CPPFLAGS = "${CPPFLAGS}"
 export CGO_CXXFLAGS = "${CXXFLAGS}"
-export CGO_LDFLAGS = "${LDFLAGS}"
+export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
 export GOCACHE = "${B}/.cache"
 
 GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc
index 47b4411d54..51f1b79cc3 100644
--- a/meta/recipes-devtools/go/go-target.inc
+++ b/meta/recipes-devtools/go/go-target.inc
@@ -1,6 +1,16 @@ 
 DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
 DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
 
+DEBUG_PREFIX_MAP = "\
+                     -fdebug-prefix-map=${STAGING_DIR_HOST}= \
+                     -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
+"
+
+export CGO_CFLAGS = "${CFLAGS}"
+export CGO_CPPFLAGS = "${CPPFLAGS}"
+export CGO_CXXFLAGS = "${CXXFLAGS}"
+export CGO_LDFLAGS = "-Wl,-O1 ${TARGET_LINK_HASH_STYLE} ${ASNEEDED} ${SECURITY_LDFLAGS}"
+
 export GOCACHE = "${B}/.cache"
 GO_LDFLAGS = ""
 GO_LDFLAGS:class-nativesdk = "-linkmode external"