Upstream-Status: Backport
Signed-off-by: Ross Burton <ross.burton@intel.com>

From ce24f0d6a9be22ba61d80cd254e0409de2eaffd7 Mon Sep 17 00:00:00 2001
From: Jussi Pakkanen <jpakkane@gmail.com>
Date: Thu, 27 Dec 2018 23:43:35 +0200
Subject: [PATCH] Default libdir is "lib" when cross compiling. Closes #2535.

---
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index ff810683..9ee23a69 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -298,6 +298,7 @@ class CoreData:
         # Only to print a warning if it changes between Meson invocations.
         self.pkgconf_envvar = os.environ.get('PKG_CONFIG_PATH', '')
         self.config_files = self.__load_config_files(options.native_file)
+        self.libdir_cross_fixup()
 
     @staticmethod
     def __load_config_files(filenames):
@@ -309,6 +310,13 @@ class CoreData:
                      for f in filenames]
         return filenames
 
+    def libdir_cross_fixup(self):
+        # By default set libdir to "lib" when cross compiling since
+        # getting the "system default" is always wrong on multiarch
+        # platforms as it gets a value like lib/x86_64-linux-gnu.
+        if self.cross_files:
+            self.builtins['libdir'].value = 'lib'
+
     def sanitize_prefix(self, prefix):
         if not os.path.isabs(prefix):
             raise MesonException('prefix value {!r} must be an absolute path'
