Default libdir is "lib" when cross compiling. Closes #2535.

pull/4691/head
Jussi Pakkanen 6 years ago
parent ab3aeeffe9
commit da5da5977a
  1. 7
      docs/markdown/snippets/crosslib.md
  2. 8
      mesonbuild/coredata.py
  3. 13
      run_unittests.py

@ -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.

@ -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'

@ -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

Loading…
Cancel
Save