aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-10 14:16:45 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-02-02 12:42:48 -0800
commit6f532b72c85e38880cf7953098bb91e8f3feb696 (patch)
treeb0bbd5e653904f54b03439e851a092763b4ef87f /run_unittests.py
parentbffc94b08f713cc9916009575664b132aee76bcf (diff)
downloadmeson-6f532b72c85e38880cf7953098bb91e8f3feb696.zip
meson-6f532b72c85e38880cf7953098bb91e8f3feb696.tar.gz
meson-6f532b72c85e38880cf7953098bb91e8f3feb696.tar.bz2
Add support for LLVM's thinLTO
This uses a separate option, b_lto_mode. It works in conjunction with b_lto_threads. Fixes #7493
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index aff94c4..2b8812a 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2864,6 +2864,31 @@ class AllPlatformTests(BasePlatformTests):
for e in expected:
self.assertIn(e, s['parameters'])
+ @skip_if_not_base_option('b_lto_mode')
+ @skip_if_not_base_option('b_lto_threads')
+ def test_lto_mode(self):
+ testdir = os.path.join(self.common_test_dir, '6 linkshared')
+
+ env = get_fake_env(testdir, self.builddir, self.prefix)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
+ if cc.get_id() != 'clang':
+ raise unittest.SkipTest('Only clang currently supports thinLTO')
+ if cc.linker.id not in {'ld.lld', 'ld.gold', 'ld64', 'lld-link'}:
+ raise unittest.SkipTest('thinLTO requires ld.lld, ld.gold, ld64, or lld-link')
+ elif is_windows():
+ raise unittest.SkipTest('LTO not (yet) supported by windows clang')
+
+ self.init(testdir, extra_args=['-Db_lto=true', '-Db_lto_mode=thin', '-Db_lto_threads=8'])
+ self.build()
+ self.run_tests()
+
+ expected = set(cc.get_lto_compile_args(threads=8, mode='thin'))
+ targets = self.introspect('--targets')
+ # This assumes all of the targets support lto
+ for t in targets:
+ for s in t['target_sources']:
+ assert expected.issubset(set(s['parameters'])), f'Incorrect values for {t["name"]}'
+
def test_dist_git(self):
if not shutil.which('git'):
raise unittest.SkipTest('Git not found')