runc-opencontainers is the only recipe currently failing like this for me with gold, so instead of switching system linker I would prefer to force bfd only here.

But there is also one more issue which is probably introduced by gcc-11 (I had older version of your patches with 11.0.1 in my branches, so waiting for build to confirm if it's reproducible with 11.1.0 as well):

NOTE: > Executing update_font_cache intercept ...
NOTE: Exit code 132. Output:
+ '[' True = False -a qemuwrapper-cross '!=' nativesdk-qemuwrapper-cross ']'
+ qemu-i386 -r 3.2.0 -E LD_LIBRARY_PATH=/jenkins/mjansa/build/ose/honister/BUILD/work/qemux86-webos-linux/webos-image-ros-world/1.0-r3/rootfs/usr/lib:/jenkins/mjansa/build/ose/honister/BUILD/work/qemux86-webos-linux/webos-image-ros-world/1.0-r3/rootfs/lib -L /jenkins/mjansa/build/ose/honister/BUILD/work/qemux86-webos-linux/webos-image-ros-world/1.0-r3/rootfs -E FC_DEBUG=16 /jenkins/mjansa/build/ose/honister/BUILD/work/qemux86-webos-linux/webos-image-ros-world/1.0-r3/rootfs/usr/libexec/fc-cache --sysroot=/jenkins/mjansa/build/ose/honister/BUILD/work/qemux86-webos-linux/webos-image-ros-world/1.0-r3/rootfs --system-only -v
qemu: uncaught target signal 4 (Illegal instruction) - core dumped



On Mon, May 3, 2021 at 5:25 PM Khem Raj <raj.khem@gmail.com> wrote:


On 5/3/21 6:40 AM, Martin Jansa wrote:
> * just a work around for internal error in binutils-2.36 gold:
>    http://errors.yoctoproject.org/Errors/Details/580099/
>    CGO_ENABLED=1 x86_64-oe-linux-go build -trimpath  -tags "seccomp seccomp                       netgo osusergo" -ldflags "-w -extldflags -static -X main.gitCommit="fce58ab2d5c488bc573d02712db476a6daa9a60c-dirty" -X main.version=1.0.0-rc93+dev " -o runc .
>    TOPDIR/tmp-glibc/work/core2-64-oe-linux/runc-opencontainers/1.0.0-rc93+gitAUTOINC+fce58ab2d5-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/../../libexec/x86_64-oe-linux/gcc/x86_64-oe-linux/11.0.1/ld: internal error in format_file_lineno, at ../../gold/dwarf_reader.cc:2278
>    collect2: error: ld returned 1 exit status
>
> * it fails like this only together with gcc-11, with gcc-10.3 it
>    builds fine even with gold
>
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>   recipes-containers/runc/runc-opencontainers_git.bb | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/recipes-containers/runc/runc-opencontainers_git.bb b/recipes-containers/runc/runc-opencontainers_git.bb
> index f3ff9a8..51ba7c9 100644
> --- a/recipes-containers/runc/runc-opencontainers_git.bb
> +++ b/recipes-containers/runc/runc-opencontainers_git.bb
> @@ -8,3 +8,10 @@ SRC_URI = " \
>   RUNC_VERSION = "1.0.0-rc93"
>   
>   CVE_PRODUCT = "runc"
> +
> +# use BFD when ld-is-gold is used to work around:
> +# http://errors.yoctoproject.org/Errors/Details/580099/
> +# CGO_ENABLED=1 x86_64-oe-linux-go build -trimpath  -tags "seccomp seccomp                       netgo osusergo" -ldflags "-w -extldflags -static -X main.gitCommit="fce58ab2d5c488bc573d02712db476a6daa9a60c-dirty" -X main.version=1.0.0-rc93+dev " -o runc .
> +# TOPDIR/tmp-glibc/work/core2-64-oe-linux/runc-opencontainers/1.0.0-rc93+gitAUTOINC+fce58ab2d5-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/../../libexec/x86_64-oe-linux/gcc/x86_64-oe-linux/11.0.1/ld: internal error in format_file_lineno, at ../../gold/dwarf_reader.cc:2278
> +# collect2: error: ld returned 1 exit status

this is because of dwarf-5 defaults in gcc 11 and gold has gotten some
fixed recently fixes these issues, but we are not backporting them yet
and perhaps will wait for binutils 2.37 to get it all. Maybe you should
not use gold as system linker until then to avoid these pitfalls.

> +LDFLAGS_append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
>