From bef95cf5fd7aad65541af22c06994c5c8900f9f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?=
 <bernhard.rosenkraenzer.ext@huawei.com>
Date: Fri, 18 Mar 2022 16:26:25 +0100
Subject: [PATCH] recipes-devtools: Fix go with musl
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix go hardcoding glibc's dynamic linker location into musl binaries

Signed-off-by: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
---
 .../recipes-devtools/go/go_%.bbappend         | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 meta-oniro-core/recipes-devtools/go/go_%.bbappend

diff --git a/meta-oniro-core/recipes-devtools/go/go_%.bbappend b/meta-oniro-core/recipes-devtools/go/go_%.bbappend
new file mode 100644
index 00000000..12f2ae9b
--- /dev/null
+++ b/meta-oniro-core/recipes-devtools/go/go_%.bbappend
@@ -0,0 +1,25 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+do_configure:prepend () {
+    # FIXME quick and dirty workaround for
+    # https://github.com/golang/go/issues/51790
+    # until we've fixed this properly
+
+    if [ "${@d.getVar("TARGET_LIBC")}" = "musl" ]; then
+        sed -i -e 's,ld-linux-x86-64.so.2,ld-musl-x86_64.so.1,' ${S}/src/cmd/link/internal/amd64/obj.go
+        if echo ${@d.getVar("TARGET_FPU")} | grep -q soft; then
+            sed -i -e 's,ld-linux.so.3,ld-musl-arm.so.1,' ${S}/src/cmd/link/internal/arm/obj.go
+        else
+            sed -i -e 's,ld-linux.so.3,ld-musl-armhf.so.1,' ${S}/src/cmd/link/internal/arm/obj.go
+        fi
+        sed -i -e 's,ld-linux-aarch64.so.1,ld-musl-aarch64.so.1,' ${S}/src/cmd/link/internal/arm64/obj.go
+        sed -i -e 's,ld.so.1,ld-musl-mips.so.1,' ${S}/src/cmd/link/internal/mips/obj.go
+        sed -i -e 's,ld64.so.1,ld-musl-mips64.so.1,' ${S}/src/cmd/link/internal/mips64/obj.go
+        sed -i -e 's,ld64.so.1,ld-musl-powerpc64.so.1,' ${S}/src/cmd/link/internal/ppc64/obj.go
+        sed -i -e 's,ld.so.1,ld-musl-riscv64.so.1,' ${S}/src/cmd/link/internal/riscv64/obj.go
+        sed -i -e 's,ld64.so.1,ld-musl-s390x.so.1,' ${S}/src/cmd/link/internal/s390x/obj.go
+        sed -i -e 's,ld-linux.so.2,ld-musl-i386.so.1,' ${S}/src/cmd/link/internal/x86/obj.go
+    fi
+}
-- 
GitLab