From b66abe91277dc8ba2283d406232bdfe9438ea546 Mon Sep 17 00:00:00 2001
From: Esben Haabendal <esben.haabendal@huawei.com>
Date: Wed, 29 Jun 2022 15:52:48 +0200
Subject: [PATCH] openharmony: Fix path to musl loader on armhf targets

Signed-off-by: Esben Haabendal <esben.haabendal@huawei.com>
---
 recipes-openharmony/openharmony/openharmony-standard_3.0.bb | 6 ++++++
 recipes-openharmony/openharmony/openharmony-standard_3.1.bb | 6 ++++++
 .../prebuilts/files/build/common/musl/BUILD.gn              | 2 +-
 .../prebuilts/files/third_party/musl/BUILD.gn               | 5 +++--
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
index 1c82fdb5..1a8a349a 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
@@ -95,6 +95,12 @@ GN_ARGS += 'node_path="${RECIPE_SYSROOT_NATIVE}/usr/bin"'
 GN_ARGS += 'host_toolchain="//oniro:host_toolchain"'
 GN_ARGS += 'install_oniro_third_party=false'
 
+# OpenHarmony build system needs a bit of help to be able to find the right
+# ld-musl-*.so path
+inherit linuxloader
+MUSL_LDSO_ARCH = "${@get_musl_loader_arch(d)}"
+GN_ARGS += 'musl_arch="${MUSL_LDSO_ARCH}"'
+
 # OpenHarmony unit tests are statically linked and therefore not stripped
 # binaries sum up to almost 80GB which makes it difficult to build OpenHarmony
 # with tests on a normal desktop, let alone the CI runner
diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb
index 60d06e91..eddcc674 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb
@@ -117,6 +117,12 @@ GN_ARGS += 'flex_path="${RECIPE_SYSROOT_NATIVE}/usr/bin/flex"'
 GN_ARGS += 'bison_path="${RECIPE_SYSROOT_NATIVE}/usr/bin/bison"'
 GN_ARGS += 'flex_includedir="${RECIPE_SYSROOT_NATIVE}/usr/include"'
 
+# OpenHarmony build system needs a bit of help to be able to find the right
+# ld-musl-*.so path
+inherit linuxloader
+MUSL_LDSO_ARCH = "${@get_musl_loader_arch(d)}"
+GN_ARGS += 'musl_arch="${MUSL_LDSO_ARCH}"'
+
 # OpenHarmony unit tests are statically linked and therefore not stripped
 # binaries sum up to almost 80GB which makes it difficult to build OpenHarmony
 # with tests on a normal desktop, let alone the CI runner
diff --git a/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn b/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn
index 1393e369..2099b702 100644
--- a/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn
+++ b/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn
@@ -4,7 +4,7 @@
 
 group("musl_install") {
   deps = [
-    "//third_party/musl:ld-musl-arm.so",
+    "//third_party/musl:ld-musl.so",
     "//third_party/musl:libc.so",
   ]
 }
diff --git a/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn b/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn
index 266afcde..7b2ea067 100644
--- a/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn
+++ b/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn
@@ -4,9 +4,10 @@
 
 import("//build/ohos.gni")
 import("//oniro/third_party.gni")
+import("musl_config.gni")
 
-ohos_prebuilt_executable("ld-musl-arm.so") {
-  source = "//oniro/sysroots/target/lib/ld-musl-arm.so.1"
+ohos_prebuilt_executable("ld-musl.so") {
+  source = "//oniro/sysroots/target/lib/ld-musl-${musl_arch}.so.1"
   subsystem_name = "common"
   part_name = "common"
   install_enable = install_oniro_third_party
-- 
GitLab