From f056cdd3cf097cb3ed1d3ea4f083a3ca043932e2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 15 Jul 2020 08:51:29 -0700 Subject: [PATCH] Initial support for multiple LLVM versions See #11362 --- tests/test_other.py | 2 +- tests/test_sanity.py | 10 +++++----- tools/shared.py | 14 ++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/test_other.py b/tests/test_other.py index 7cc8b022008ee..ea76d82648f48 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -208,7 +208,7 @@ def test_emcc_v(self): for compiler in [EMCC, EMXX]: # -v, without input files proc = run_process([compiler, '-v'], stdout=PIPE, stderr=PIPE) - self.assertContained('clang version %s' % shared.expected_llvm_version(), proc.stderr) + self.assertContained('clang version %s' % shared.supported_llvm_versions()[-1], proc.stderr) self.assertContained('GNU', proc.stderr) self.assertNotContained('this is dangerous', proc.stdout) self.assertNotContained('this is dangerous', proc.stderr) diff --git a/tests/test_sanity.py b/tests/test_sanity.py index 053321c87fd85..00d4145868e83 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -20,7 +20,7 @@ from tools.shared import NODE_JS, PYTHON, EMCC, SPIDERMONKEY_ENGINE, V8_ENGINE from tools.shared import CONFIG_FILE, EM_CONFIG, LLVM_ROOT, CANONICAL_TEMP_DIR from tools.shared import run_process, try_delete -from tools.shared import expected_llvm_version, Cache, Settings +from tools.shared import supported_llvm_versions, Cache, Settings from tools import shared, system_libs SANITY_FILE = shared.Cache.get_path('sanity.txt') @@ -268,7 +268,7 @@ def test_llvm(self): with open(CONFIG_FILE, 'a') as f: f.write('LLVM_ROOT = "' + self.in_dir('fake') + '"') - real_version_x, real_version_y = (int(x) for x in expected_llvm_version().split('.')) + real_version_x, real_version_y = (int(x) for x in supported_llvm_versions()[-1].split('.')) if shared.get_llvm_target() == shared.WASM_TARGET: make_fake_llc(self.in_dir('fake', 'llc'), 'wasm32 - WebAssembly 32-bit') make_fake_lld(self.in_dir('fake', 'wasm-ld')) @@ -318,7 +318,7 @@ def test_llvm_fastcomp(self): f.write('LLVM_ROOT = "' + self.in_dir('fake', 'bin') + '"') # print '1', open(CONFIG_FILE).read() - make_fake_clang(self.in_dir('fake', 'bin', 'clang'), expected_llvm_version()) + make_fake_clang(self.in_dir('fake', 'bin', 'clang'), supported_llvm_versions()[-1]) make_fake_llc(self.in_dir('fake', 'bin', 'llc'), 'no j-s backend for you!') self.check_working(EMCC, WARNING) @@ -487,7 +487,7 @@ def test_cache_clearing_auto(self): # Changing LLVM_ROOT, even without altering .emscripten, clears the cache restore_and_set_up() self.ensure_cache() - make_fake_clang(self.in_dir('fake', 'bin', 'clang'), expected_llvm_version()) + make_fake_clang(self.in_dir('fake', 'bin', 'clang'), supported_llvm_versions()[-1]) make_fake_llc(self.in_dir('fake', 'bin', 'llc'), 'got wasm32 backend! WebAssembly 32-bit') with env_modify({'EM_LLVM_ROOT': self.in_dir('fake', 'bin')}): self.assertTrue(os.path.exists(Cache.dirname)) @@ -718,7 +718,7 @@ def make_fake(report): # doesn't actually use it. f.write('BINARYEN_ROOT= "%s"\n' % self.in_dir('fake', 'bin')) - make_fake_clang(self.in_dir('fake', 'bin', 'clang'), expected_llvm_version()) + make_fake_clang(self.in_dir('fake', 'bin', 'clang'), supported_llvm_versions()[-1]) make_fake_llc(self.in_dir('fake', 'bin', 'llc'), report) make_fake_lld(self.in_dir('fake', 'bin', 'wasm-ld')) diff --git a/tools/shared.py b/tools/shared.py index 3cb3aec4b1ae7..56e82a695f69c 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -412,11 +412,11 @@ def fix_js_engine(old, new): return new -def expected_llvm_version(): +def supported_llvm_versions(): if get_llvm_target() == WASM_TARGET: - return "12.0" + return ('11.0', '12.0') else: - return "6.0" + return ("6.0") def get_clang_version(): @@ -430,13 +430,11 @@ def get_clang_version(): def check_llvm_version(): - # Let LLVM 12 roll in - return True - expected = expected_llvm_version() + supported = supported_llvm_versions() actual = get_clang_version() - if expected in actual: + if actual in supported: return True - diagnostics.warning('version-check', 'LLVM version appears incorrect (seeing "%s", expected "%s")', actual, expected) + diagnostics.warning('version-check', 'unsupported LLVM version (seeing "%s", supported: %s)', actual, supported) return False