diff --git a/recipes-openharmony/openharmony/musl-ldso-paths-sanity-check.inc b/recipes-openharmony/openharmony/musl-ldso-paths-sanity-check.inc
new file mode 100644
index 0000000000000000000000000000000000000000..bfa1971c9c513a75971153421801de55bbfa65eb
--- /dev/null
+++ b/recipes-openharmony/openharmony/musl-ldso-paths-sanity-check.inc
@@ -0,0 +1,29 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+# This post do_install() function checks if all subfloders copied from
+# system/lib/module are set in the distro variable MUSL_LDSO_PATHS.
+#
+# This variable is used to generate the content of the file
+# /etc/ld-musl-${MUSL_LDSO_ARCH}.path so this function stops bitbake
+# if one of the coipied folder from /system/lib/module/* is not in
+# MUSL_LDSO_PATHS.
+
+musl_ldso_paths_sanity_check() {
+	cd "${D}/${libdir}"
+	MODULE_LIB_PATHS="$(find module -type d)"
+	for folder in ${MODULE_LIB_PATHS}; do
+		PAT="(^|[[:space:]])${folder}([[:space:]]|$)"
+		if [[ ! "${MUSL_LDSO_PATHS}" =~ ${PAT} ]]; then
+			echo
+			echo "'${folder}' not in MUSL_LDSO_PATHS"
+			echo "Add it in conf/distro/include/musl-ldso-paths.inc"
+			echo
+
+			return 1
+		fi
+	done
+}
+
+do_install[postfuncs] += "musl_ldso_paths_sanity_check"
diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
index 22a8fb3439e9b4d6d4fdc7e7b4874d66edc83c9d..64d987d026343348fff6901e45f2abb3b21eedcf 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
@@ -17,6 +17,7 @@ DEPENDS += "bison-native"
 DEPENDS += "ruby-native"
 
 require ${PN}-sources-${OPENHARMONY_VERSION}.inc
+require musl-ldso-paths-sanity-check.inc
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/openharmony-${OPENHARMONY_VERSION}:"
 FILESEXTRAPATHS:prepend := "${THISDIR}/openharmony-standard-${OPENHARMONY_VERSION}:"
diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb
index 6d79c434dcd29eaf7af583dfc8cc8849c6a2d435..99cd4d145f95c71c6102ef3b78db451e30ee64c4 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb
@@ -23,6 +23,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/openharmony-standard-${OPENHARMONY_VERSIO
 
 require ${PN}-sources-${OPENHARMONY_VERSION}.inc
 require java-tools.inc
+require musl-ldso-paths-sanity-check.inc
 
 SRC_URI += "${@bb.utils.contains('PTEST_ENABLED', '1', 'file://run-ptest', '', d)}"