Skip to content

Commit 1f802d8

Browse files
committed
receive emscripten llvm and clang build versions, and verify them
1 parent 0f9ccbb commit 1f802d8

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

emscripten-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.35.2
1+
"1.35.2"
22

tests/test_other.py

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def test_emcc(self):
2323
output = Popen([PYTHON, compiler, '-v'], stdout=PIPE, stderr=PIPE).communicate()
2424
self.assertContained('''clang version %s.0 ''' % '.'.join(map(str, EXPECTED_LLVM_VERSION)), output[1].replace('\r', ''), output[1].replace('\r', ''))
2525
self.assertContained('''GNU''', output[0])
26+
self.assertNotContained('this is dangerous', output[0])
27+
self.assertNotContained('this is dangerous', output[1])
2628

2729
# --help
2830
output = Popen([PYTHON, compiler, '--help'], stdout=PIPE, stderr=PIPE).communicate()

tests/test_sanity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_llvm_fastcomp(self):
241241
try_delete(SANITY_FILE)
242242
output = self.check_working(EMCC, 'did not see a source tree above or next to the LLVM root directory')
243243

244-
VERSION_WARNING = 'Emscripten, llvm and clang versions do not match, this is dangerous'
244+
VERSION_WARNING = 'Emscripten, llvm and clang repo versions do not match, this is dangerous'
245245

246246
# add version number
247247
open(path_from_root('tests', 'fake', 'emscripten-version.txt'), 'w').write('waka')

tools/shared.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,32 @@ def check_fastcomp():
370370
logging.critical('you can fall back to the older (pre-fastcomp) compiler core, although that is not recommended, see http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html')
371371
return False
372372

373+
# check repo versions
373374
d = get_fastcomp_src_dir()
375+
shown_repo_version_error = False
374376
if d is not None:
375-
llvm_version = open(os.path.join(d, 'emscripten-version.txt')).read().strip()
377+
llvm_version = get_emscripten_version(os.path.join(d, 'emscripten-version.txt'))
376378
if os.path.exists(os.path.join(d, 'tools', 'clang', 'emscripten-version.txt')):
377-
clang_version = open(os.path.join(d, 'tools', 'clang', 'emscripten-version.txt')).read().strip()
379+
clang_version = get_emscripten_version(os.path.join(d, 'tools', 'clang', 'emscripten-version.txt'))
378380
elif os.path.exists(os.path.join(d, 'tools', 'clang')):
379381
clang_version = '?' # Looks like the LLVM compiler tree has an old checkout from the time before it contained a version.txt: Should update!
380382
else:
381383
clang_version = llvm_version # This LLVM compiler tree does not have a tools/clang, so it's probably an out-of-source build directory. No need for separate versioning.
382384
if EMSCRIPTEN_VERSION != llvm_version or EMSCRIPTEN_VERSION != clang_version:
383-
logging.error('Emscripten, llvm and clang versions do not match, this is dangerous (%s, %s, %s)', EMSCRIPTEN_VERSION, llvm_version, clang_version)
385+
logging.error('Emscripten, llvm and clang repo versions do not match, this is dangerous (%s, %s, %s)', EMSCRIPTEN_VERSION, llvm_version, clang_version)
384386
logging.error('Make sure to use the same branch in each repo, and to be up-to-date on each. See http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html')
387+
shown_repo_version_error = True
385388
else:
386389
logging.warning('did not see a source tree above or next to the LLVM root directory (guessing based on directory of %s), could not verify version numbers match' % LLVM_COMPILER)
390+
391+
# check build versions. don't show it if the repos are wrong, user should fix that first
392+
if not shown_repo_version_error:
393+
clang_v = Popen([CLANG, '--version'], stdout=PIPE).communicate()[0]
394+
llvm_build_version, clang_build_version = clang_v.split('(emscripten ')[1].split(')')[0].split(' : ')
395+
if EMSCRIPTEN_VERSION != llvm_build_version or EMSCRIPTEN_VERSION != clang_build_version:
396+
logging.error('Emscripten, llvm and clang build versions do not match, this is dangerous (%s, %s, %s)', EMSCRIPTEN_VERSION, llvm_build_version, clang_build_version)
397+
logging.error('Make sure to rebuild llvm and clang after updating repos')
398+
387399
return True
388400
except Exception, e:
389401
logging.warning('could not check fastcomp: %s' % str(e))
@@ -428,6 +440,9 @@ def find_temp_directory():
428440
else:
429441
return '/tmp'
430442

443+
def get_emscripten_version(path):
444+
return open(path).read().strip().replace('"', '')
445+
431446
# Check that basic stuff we need (a JS engine to compile, Node.js, and Clang and LLVM)
432447
# exists.
433448
# The test runner always does this check (through |force|). emcc does this less frequently,
@@ -436,7 +451,7 @@ def find_temp_directory():
436451
# We also re-check sanity and clear the cache when the version changes
437452

438453
try:
439-
EMSCRIPTEN_VERSION = open(path_from_root('emscripten-version.txt')).read().strip()
454+
EMSCRIPTEN_VERSION = get_emscripten_version(path_from_root('emscripten-version.txt'))
440455
try:
441456
parts = map(int, EMSCRIPTEN_VERSION.split('.'))
442457
EMSCRIPTEN_VERSION_MAJOR = parts[0]

0 commit comments

Comments
 (0)