summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-12-27 23:43:35 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2018-12-30 00:51:19 +0200
commitda5da5977ab975480570b06b72df98318f2efd23 (patch)
tree25bd67ae292b092df226dd354a7d54f4da2c880e
parentab3aeeffe92bc874d5f5a04af0ae9dc568a09ce7 (diff)
downloadmeson-da5da5977ab975480570b06b72df98318f2efd23.tar.gz
Default libdir is "lib" when cross compiling. Closes #2535.
-rw-r--r--docs/markdown/snippets/crosslib.md7
-rw-r--r--mesonbuild/coredata.py8
-rwxr-xr-xrun_unittests.py13
3 files changed, 28 insertions, 0 deletions
diff --git a/docs/markdown/snippets/crosslib.md b/docs/markdown/snippets/crosslib.md
new file mode 100644
index 000000000..14fcc81cf
--- /dev/null
+++ b/docs/markdown/snippets/crosslib.md
@@ -0,0 +1,7 @@
+## Libdir defaults to `lib` when cross compiling
+
+Previously `libdir` defaulted to the value of the build machine such
+as `lib/x86_64-linux-gnu`, which is almost always incorrect when cross
+compiling. It now defaults to plain `lib` when cross compiling. Native
+builds remain unchanged and will point to the current system's library
+dir.
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index d70c23038..4e2f3e008 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -299,6 +299,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):
@@ -348,6 +349,13 @@ class CoreData:
raise MesonException('Cannot find specified cross file: ' + filename)
+ 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_file is not None:
+ 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'
diff --git a/run_unittests.py b/run_unittests.py
index f8ede9b89..be7ae5765 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -4528,6 +4528,7 @@ endian = 'little'
max_count = max(max_count, line.count(search_term))
self.assertEqual(max_count, 1, 'Export dynamic incorrectly deduplicated.')
+
class LinuxCrossArmTests(BasePlatformTests):
'''
Tests that cross-compilation to Linux/ARM works
@@ -4564,6 +4565,18 @@ class LinuxCrossArmTests(BasePlatformTests):
self.assertRegex(compdb[0]['command'], '-D_FILE_OFFSET_BITS=64.*-U_FILE_OFFSET_BITS')
self.build()
+ def test_cross_libdir(self):
+ # When cross compiling "libdir" should default to "lib"
+ # rather than "lib/x86_64-linux-gnu" or something like that.
+ testdir = os.path.join(self.common_test_dir, '1 trivial')
+ self.init(testdir)
+ for i in self.introspect('--buildoptions'):
+ if i['name'] == 'libdir':
+ self.assertEqual(i['value'], 'lib')
+ return
+ self.assertTrue(False, 'Option libdir not in introspect data.')
+
+
class LinuxCrossMingwTests(BasePlatformTests):
'''
Tests that cross-compilation to Windows/MinGW works