Skip to content

Commit 25835aa

Browse files
committed
Switch default backend from 'fastcomp' to 'upstream'
When users as for 'latest' or just '1.39.0' we now default to the upstream llvm backend. For versions before 1.39.0 we continue to default to fastcomp. Fixes: emscripten-core/emscripten#5488
1 parent e047fe4 commit 25835aa

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

emsdk.py

+30-10
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ def find_used_python():
19411941

19421942

19431943
def version_key(ver):
1944-
return list(map(int, re.split('[._-]', ver)))
1944+
return tuple(map(int, re.split('[._-]', ver)))
19451945

19461946

19471947
# A sort function that is compatible with both Python 2 and Python 3 using a
@@ -2710,14 +2710,29 @@ def extract_bool_arg(name):
27102710

27112711
releases_info = load_releases_info()['releases']
27122712

2713+
def report_upstream_by_default():
2714+
print('''\
2715+
** NOTICE **: The default SDK changed from `fastcomp` to `upstream`.
2716+
If you have problems, or wish to revert back to fastcomp for some other reason
2717+
you can add `-fastcomp` to explitly install that fastcomp-based
2718+
SDK. .e.g ./emsdk install latest-fastcomp.
2719+
''', file=sys.stderr)
2720+
27132721
# Replace meta-packages with the real package names.
27142722
if cmd in ('update', 'install', 'activate'):
27152723
for i in range(2, len(sys.argv)):
27162724
arg = sys.argv[i]
2717-
if arg in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit', 'latest-fastcomp', 'latest-releases-fastcomp'):
2725+
if arg in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit'):
2726+
# This is effectly the default SDK
2727+
report_upstream_by_default()
2728+
sys.argv[i] = str(find_latest_releases_sdk('upstream'))
2729+
elif arg in ('latest-fastcomp', 'latest-releases-fastcomp'):
27182730
sys.argv[i] = str(find_latest_releases_sdk('fastcomp'))
27192731
elif arg in ('latest-upstream', 'latest-clang-upstream', 'latest-releases-upstream'):
27202732
sys.argv[i] = str(find_latest_releases_sdk('upstream'))
2733+
elif arg in ('tot', 'sdk-tot'):
2734+
report_upstream_by_default()
2735+
sys.argv[i] = str(find_tot_sdk('upstream'))
27212736
elif arg == 'tot-upstream':
27222737
sys.argv[i] = str(find_tot_sdk('upstream'))
27232738
elif arg in ('tot-fastcomp', 'sdk-nightly-latest'):
@@ -2728,17 +2743,23 @@ def extract_bool_arg(name):
27282743
# x.y.z[-(upstream|fastcomp_])
27292744
# sdk-x.y.z[-(upstream|fastcomp_])-64bit
27302745
# TODO: support short notation for old builds too?
2731-
upstream = False
2746+
backend = None
27322747
if '-upstream' in arg:
27332748
arg = arg.replace('-upstream', '')
2734-
upstream = True
2749+
backend = 'upstream'
27352750
elif '-fastcomp' in arg:
27362751
arg = arg.replace('-fastcomp', '')
2737-
upstream = False
2752+
backend = 'fastcomp'
27382753
arg = arg.replace('sdk-', '').replace('-64bit', '').replace('tag-', '')
27392754
release_hash = releases_info.get(arg, None) or releases_info.get('sdk-' + arg + '-64bit')
27402755
if release_hash:
2741-
sys.argv[i] = 'sdk-releases-%s-%s-64bit' % ('upstream' if upstream else 'fastcomp', release_hash)
2756+
if backend is None:
2757+
if version_key(arg) >= (1, 39, 0):
2758+
report_upstream_by_default()
2759+
backend = 'upstream'
2760+
else:
2761+
backend = 'fastcomp'
2762+
sys.argv[i] = 'sdk-releases-%s-%s-64bit' % (backend, release_hash)
27422763

27432764
if cmd == 'list':
27442765
print('')
@@ -2747,12 +2768,12 @@ def extract_bool_arg(name):
27472768
print('The *recommended* precompiled SDK download is %s (%s).' % (find_latest_releases_version(), find_latest_releases_hash()))
27482769
print()
27492770
print('To install/activate it, use one of:')
2750-
print(' latest [default (fastcomp) backend]')
2751-
print(' latest-upstream [upstream LLVM wasm backend]')
2771+
print(' latest [default (llvm) backend]')
2772+
print(' latest-fastcomp [legacy (fastcomp) backend]')
27522773
print('')
27532774
print('Those are equivalent to installing/activating the following:')
27542775
print(' %s' % find_latest_releases_version())
2755-
print(' %s-upstream' % find_latest_releases_version())
2776+
print(' %s-fastcomp' % find_latest_releases_version())
27562777
print('')
27572778
else:
27582779
print('Warning: your platform does not have precompiled SDKs available.')
@@ -2764,7 +2785,6 @@ def extract_bool_arg(name):
27642785
releases_versions.reverse()
27652786
for ver in releases_versions:
27662787
print(' %s' % ver)
2767-
print(' %s-upstream' % ver)
27682788
print()
27692789

27702790
# Use array to work around the lack of being able to mutate from enclosing

test.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def hack_emsdk(marker, replacement):
6161
# Tests
6262

6363
print('test .emscripten contents (latest was installed/activated in test.sh)')
64-
assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read()
65-
assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read()
64+
assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read()
65+
assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()
6666

6767
print('building proper system libraries')
6868

@@ -114,23 +114,22 @@ def run_emsdk(cmd):
114114
else:
115115
emsdk = './emsdk'
116116

117-
test_lib_building(fastcomp_emcc, use_asmjs_optimizer=True)
117+
test_lib_building(upstream_emcc, use_asmjs_optimizer=True)
118118

119119
print('update')
120120
run_emsdk('update-tags')
121121

122-
print('test latest-releases-upstream')
123-
run_emsdk('install latest-upstream')
124-
run_emsdk('activate latest-upstream')
122+
print('test latest-releases-fastcomp')
123+
run_emsdk('install latest-fastcomp')
124+
run_emsdk('activate latest-fastcomp')
125125

126-
test_lib_building(upstream_emcc, use_asmjs_optimizer=False)
126+
test_lib_building(fastcomp_emcc, use_asmjs_optimizer=False)
127127
assert open(os.path.expanduser('~/.emscripten')).read().count('LLVM_ROOT') == 1
128-
assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()
129-
assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read()
130-
128+
assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read()
129+
assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read()
131130

132131
print('verify version')
133-
checked_call_with_output(upstream_emcc + ' -v', TAGS['latest'], stderr=subprocess.STDOUT)
132+
checked_call_with_output(fastcomp_emcc + ' -v', TAGS['latest'], stderr=subprocess.STDOUT)
134133

135134
print('clear cache')
136135
check_call(upstream_emcc + ' --clear-cache')
@@ -160,8 +159,8 @@ def run_emsdk(cmd):
160159
print('another install must re-download')
161160
checked_call_with_output(emsdk + ' install 1.38.33', expected='Downloading:', unexpected='already exist in destination')
162161
run_emsdk('activate 1.38.33')
163-
assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read()
164-
assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read()
162+
assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()
163+
assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read()
165164

166165
print('test specific release (new, full name)')
167166
run_emsdk('install sdk-1.38.33-upstream-64bit')

0 commit comments

Comments
 (0)