Skip to content

Commit ce66f8d

Browse files
committed
check clang version before applying version-specific changes, like disabling vectorization in llvm 3.4
1 parent 7754411 commit ce66f8d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tools/shared.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,17 @@ def new(*args):
272272

273273
EXPECTED_LLVM_VERSION = (3,2)
274274

275+
actual_clang_version = None
276+
277+
def get_clang_version():
278+
global actual_clang_version
279+
if actual_clang_version is None:
280+
actual_clang_version = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0].split(' ')[2]
281+
return actual_clang_version
282+
275283
def check_clang_version():
276-
expected = 'clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION))
277-
actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0]
284+
expected = '.'.join(map(str, EXPECTED_LLVM_VERSION))
285+
actual = get_clang_version()
278286
if expected in actual:
279287
return True
280288
logging.warning('LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected))
@@ -337,10 +345,10 @@ def find_temp_directory():
337345
# we re-check sanity when the settings are changed)
338346
# We also re-check sanity and clear the cache when the version changes
339347

340-
EMSCRIPTEN_VERSION = '1.8.4'
348+
EMSCRIPTEN_VERSION = '1.8.5'
341349

342350
def generate_sanity():
343-
return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT
351+
return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT + '|' + get_clang_version()
344352

345353
def check_sanity(force=False):
346354
try:
@@ -842,8 +850,6 @@ class Building:
842850
COMPILER_TEST_OPTS = [] # For use of the test runner
843851
JS_ENGINE_OVERRIDE = None # Used to pass the JS engine override from runner.py -> test_benchmark.py
844852

845-
SAFE_OPT_OPTS = ['-disable-loop-vectorization', '-disable-slp-vectorization'] # llvm 3.4
846-
847853
@staticmethod
848854
def get_building_env(native=False):
849855
env = os.environ.copy()
@@ -1165,7 +1171,8 @@ def llvm_opt(filename, opts, out=None):
11651171
if type(opts) is int:
11661172
opts = Building.pick_llvm_opts(opts)
11671173
#opts += ['-debug-pass=Arguments']
1168-
opts += Building.SAFE_OPT_OPTS
1174+
if get_clang_version() == '3.4':
1175+
opts += ['-disable-loop-vectorization', '-disable-slp-vectorization'] # llvm 3.4 has these on by default
11691176
logging.debug('emcc: LLVM opts: ' + str(opts))
11701177
target = out or (filename + '.opt.bc')
11711178
output = Popen([LLVM_OPT, filename] + opts + ['-o', target], stdout=PIPE).communicate()[0]

0 commit comments

Comments
 (0)