aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-02-02 22:17:13 +0000
committerGitHub <noreply@github.com>2021-02-02 22:17:13 +0000
commitcd94cf8995bcddc40e627e94037e549b7a18b20e (patch)
tree309dea74fed132ce63058abf99e81a7e44ed1c43 /run_unittests.py
parent65b3d67c7e55ef4ccee496f53d18af859711b29e (diff)
parent6f532b72c85e38880cf7953098bb91e8f3feb696 (diff)
downloadmeson-cd94cf8995bcddc40e627e94037e549b7a18b20e.zip
meson-cd94cf8995bcddc40e627e94037e549b7a18b20e.tar.gz
meson-cd94cf8995bcddc40e627e94037e549b7a18b20e.tar.bz2
Merge pull request #8087 from dcbaker/submit/lto-extensions
Add option for thinLTO
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 2a14f78..2b8812a 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2843,6 +2843,52 @@ class AllPlatformTests(BasePlatformTests):
self.build()
self.run_tests()
+ @skip_if_not_base_option('b_lto_threads')
+ def test_lto_threads(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' and is_windows():
+ raise unittest.SkipTest('LTO not (yet) supported by windows clang')
+
+ self.init(testdir, extra_args=['-Db_lto=true', '-Db_lto_threads=8'])
+ self.build()
+ self.run_tests()
+
+ expected = set(cc.get_lto_compile_args(threads=8))
+ targets = self.introspect('--targets')
+ # This assumes all of the targets support lto
+ for t in targets:
+ for s in t['target_sources']:
+ 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')