Skip to content

Commit

Permalink
Initial support for multiple LLVM versions
Browse files Browse the repository at this point in the history
See #11362
  • Loading branch information
sbc100 committed Jul 15, 2020
1 parent 61a9d08 commit f056cdd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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'))

Expand Down
14 changes: 6 additions & 8 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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


Expand Down

0 comments on commit f056cdd

Please sign in to comment.