Thanks, Yuanjie.  I see how your patch changes multiarch() to return quickly and thus avoid dpkg if the user provides a sysroot or libdir, but it also comments out some checking to verify that the dynamic linker is in the correct location and executable.  (I'm referring to the following hunk from your patch.)  It looks like your changes disable this verification by commenting some of it out.

+@@ -661,16 +669,16 @@ ld_path_name = os.path.dirname(ldlib)
+ ld_full_path = "../" + ldlib
+ ld_file = find_lib(ld_file_name)
+
+-if ld_path_name != "/lib":
+-    if os.access(dest_path + "/" + ld_file_name, os.F_OK):
+-        os.remove(dest_path + "/" + ld_file_name)
++#if ld_path_name != "/lib":
++#    if os.access(dest_path + "/" + ld_file_name, os.F_OK):
++#        os.remove(dest_path + "/" + ld_file_name)
+
+-if not os.path.exists(dest_path + "/../" + ld_path_name):
+-    os.mkdir(dest_path + "/../" + ld_path_name)
++#if not os.path.exists(dest_path + "/../" + ld_path_name):
++#    os.mkdir(dest_path + "/../" + ld_path_name)
+
+-if not os.access(dest_path + "/" + ld_full_path, os.F_OK):
+-    debug(DEBUG_NORMAL, "I: stripping and copying dynamic linker to " + ld_full_path)
++if not os.access(dest_path + "/" + ld_file_name, os.F_OK):
++    debug(DEBUG_NORMAL, "I: stripping and copying dynamic linker to " + ld_file_name)
+     command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
+-            ld_file, dest_path + "/" + ld_full_path)
++            ld_file, dest_path + "/" + ld_file_name)
+
+-os.chmod(dest_path + "/" + ld_full_path, 0755)
++os.chmod(dest_path + "/" + ld_file_name, 0755)

Looking at the change you submitted upstream (https://lists.debian.org/debian-boot/2015/07/msg00018.html), it looks like there was an additional hunk that got missed in the poky commit.  Is the above hunk dependent on the missing one below?
@@ -441,6 +447,8 @@ if not ldlib:
 if not ldlib:
     sys.exit("E: Dynamic linker not found, aborting.")
 
+ldlib = sysroot + ldlib
+
 debug(DEBUG_NORMAL, "I: Using", ldlib, "as dynamic linker.")
 
 # Check for rpaths
Reverting the last hunk in your poky commit fixes the mklibs error we encounter in our multilib setup containing /lib and /lib64 symlinks to the linker.

On Sun, May 15, 2016 at 11:02 PM, Yuanjie Huang <yuanjie.huang@windriver.com> wrote:
Hi Kyle,

The fix_cross_compile.patch is related when we pass the sysroot or libdir to mklibs, in such case it is wrong to call dpkg-architecture as info on build machine instead of target will be returned.

Thanks,
Yuanjie


On 05/12/2016 04:00 AM, Kyle Russell wrote:
++    if sysroot != "" or libdir != "":
++        return paths
+     devnull = open('/dev/null', 'w')
+     dpkg_architecture = subprocess.Popen(
+         ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'],