Skip to content

Commit 8aed097

Browse files
authored
Reduce overhead of sanity checks on compiler startup (#20734)
Stop included the llvm version in the sanity file. The the cost of running `clang --version` is fairly significant. On my machine this was about 25% of the `emcc` overhead (compared to just calling clang). With this change we no longer check the llvm version when compiling and only when linking. The idea here is that for most project link commands are more rare that compile commands. The slight downside is that we won't catch folks using the wrong version of clang until they get to link time. See: #18623
1 parent 807770e commit 8aed097

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tools/link.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,12 @@ def phase_linker_setup(options, state, newargs):
626626
system_libpath = '-L' + str(cache.get_lib_dir(absolute=True))
627627
state.add_link_flag(sys.maxsize, system_libpath)
628628

629+
# We used to do this check during on startup during `check_sanity`, but
630+
# we now only do it when linking, in order to reduce the overhead when
631+
# only compiling.
632+
if not shared.SKIP_SUBPROCS:
633+
shared.check_llvm_version()
634+
629635
autoconf = os.environ.get('EMMAKEN_JUST_CONFIGURE') or 'conftest.c' in state.orig_args or 'conftest.cpp' in state.orig_args
630636
if autoconf:
631637
# configure tests want a more shell-like style, where we emit return codes on exit()

tools/shared.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,10 @@ def set_version_globals():
412412

413413

414414
def generate_sanity():
415-
return f'{EMSCRIPTEN_VERSION}|{config.LLVM_ROOT}|{get_clang_version()}'
415+
return f'{EMSCRIPTEN_VERSION}|{config.LLVM_ROOT}\n'
416416

417417

418+
@memoize
418419
def perform_sanity_checks():
419420
# some warning, mostly not fatal checks - do them even if EM_IGNORE_SANITY is on
420421
check_node_version()
@@ -485,14 +486,10 @@ def sanity_is_correct():
485486
pass
486487
if sanity_data == expected:
487488
logger.debug(f'sanity file up-to-date: {sanity_file}')
488-
# Even if the sanity file is up-to-date we still need to at least
489-
# check the llvm version. This comes at no extra performance cost
490-
# since the version was already extracted and cached by the
491-
# generate_sanity() call above.
489+
# Even if the sanity file is up-to-date we still run the checks
490+
# when force is set.
492491
if force:
493492
perform_sanity_checks()
494-
else:
495-
check_llvm_version()
496493
return True # all is well
497494
return False
498495

0 commit comments

Comments
 (0)