From 25835aa01bf4e551377a13bdc480ff3048bf8aa8 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 16 Oct 2019 14:23:33 -0700 Subject: [PATCH 1/2] 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: https://github.com/emscripten-core/emscripten/issues/5488 --- emsdk.py | 40 ++++++++++++++++++++++++++++++---------- test.py | 25 ++++++++++++------------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/emsdk.py b/emsdk.py index 8f5b439088..337e953b30 100755 --- a/emsdk.py +++ b/emsdk.py @@ -1941,7 +1941,7 @@ def find_used_python(): def version_key(ver): - return list(map(int, re.split('[._-]', ver))) + return tuple(map(int, re.split('[._-]', ver))) # A sort function that is compatible with both Python 2 and Python 3 using a @@ -2710,14 +2710,29 @@ def extract_bool_arg(name): releases_info = load_releases_info()['releases'] + def report_upstream_by_default(): + print('''\ +** NOTICE **: The default SDK changed from `fastcomp` to `upstream`. +If you have problems, or wish to revert back to fastcomp for some other reason +you can add `-fastcomp` to explitly install that fastcomp-based +SDK. .e.g ./emsdk install latest-fastcomp. +''', file=sys.stderr) + # Replace meta-packages with the real package names. if cmd in ('update', 'install', 'activate'): for i in range(2, len(sys.argv)): arg = sys.argv[i] - if arg in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit', 'latest-fastcomp', 'latest-releases-fastcomp'): + if arg in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit'): + # This is effectly the default SDK + report_upstream_by_default() + sys.argv[i] = str(find_latest_releases_sdk('upstream')) + elif arg in ('latest-fastcomp', 'latest-releases-fastcomp'): sys.argv[i] = str(find_latest_releases_sdk('fastcomp')) elif arg in ('latest-upstream', 'latest-clang-upstream', 'latest-releases-upstream'): sys.argv[i] = str(find_latest_releases_sdk('upstream')) + elif arg in ('tot', 'sdk-tot'): + report_upstream_by_default() + sys.argv[i] = str(find_tot_sdk('upstream')) elif arg == 'tot-upstream': sys.argv[i] = str(find_tot_sdk('upstream')) elif arg in ('tot-fastcomp', 'sdk-nightly-latest'): @@ -2728,17 +2743,23 @@ def extract_bool_arg(name): # x.y.z[-(upstream|fastcomp_]) # sdk-x.y.z[-(upstream|fastcomp_])-64bit # TODO: support short notation for old builds too? - upstream = False + backend = None if '-upstream' in arg: arg = arg.replace('-upstream', '') - upstream = True + backend = 'upstream' elif '-fastcomp' in arg: arg = arg.replace('-fastcomp', '') - upstream = False + backend = 'fastcomp' arg = arg.replace('sdk-', '').replace('-64bit', '').replace('tag-', '') release_hash = releases_info.get(arg, None) or releases_info.get('sdk-' + arg + '-64bit') if release_hash: - sys.argv[i] = 'sdk-releases-%s-%s-64bit' % ('upstream' if upstream else 'fastcomp', release_hash) + if backend is None: + if version_key(arg) >= (1, 39, 0): + report_upstream_by_default() + backend = 'upstream' + else: + backend = 'fastcomp' + sys.argv[i] = 'sdk-releases-%s-%s-64bit' % (backend, release_hash) if cmd == 'list': print('') @@ -2747,12 +2768,12 @@ def extract_bool_arg(name): print('The *recommended* precompiled SDK download is %s (%s).' % (find_latest_releases_version(), find_latest_releases_hash())) print() print('To install/activate it, use one of:') - print(' latest [default (fastcomp) backend]') - print(' latest-upstream [upstream LLVM wasm backend]') + print(' latest [default (llvm) backend]') + print(' latest-fastcomp [legacy (fastcomp) backend]') print('') print('Those are equivalent to installing/activating the following:') print(' %s' % find_latest_releases_version()) - print(' %s-upstream' % find_latest_releases_version()) + print(' %s-fastcomp' % find_latest_releases_version()) print('') else: print('Warning: your platform does not have precompiled SDKs available.') @@ -2764,7 +2785,6 @@ def extract_bool_arg(name): releases_versions.reverse() for ver in releases_versions: print(' %s' % ver) - print(' %s-upstream' % ver) print() # Use array to work around the lack of being able to mutate from enclosing diff --git a/test.py b/test.py index 20c695bf33..3dd41b9c57 100755 --- a/test.py +++ b/test.py @@ -61,8 +61,8 @@ def hack_emsdk(marker, replacement): # Tests print('test .emscripten contents (latest was installed/activated in test.sh)') -assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read() -assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read() +assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read() +assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read() print('building proper system libraries') @@ -114,23 +114,22 @@ def run_emsdk(cmd): else: emsdk = './emsdk' -test_lib_building(fastcomp_emcc, use_asmjs_optimizer=True) +test_lib_building(upstream_emcc, use_asmjs_optimizer=True) print('update') run_emsdk('update-tags') -print('test latest-releases-upstream') -run_emsdk('install latest-upstream') -run_emsdk('activate latest-upstream') +print('test latest-releases-fastcomp') +run_emsdk('install latest-fastcomp') +run_emsdk('activate latest-fastcomp') -test_lib_building(upstream_emcc, use_asmjs_optimizer=False) +test_lib_building(fastcomp_emcc, use_asmjs_optimizer=False) assert open(os.path.expanduser('~/.emscripten')).read().count('LLVM_ROOT') == 1 -assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read() -assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read() - +assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read() +assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read() print('verify version') -checked_call_with_output(upstream_emcc + ' -v', TAGS['latest'], stderr=subprocess.STDOUT) +checked_call_with_output(fastcomp_emcc + ' -v', TAGS['latest'], stderr=subprocess.STDOUT) print('clear cache') check_call(upstream_emcc + ' --clear-cache') @@ -160,8 +159,8 @@ def run_emsdk(cmd): print('another install must re-download') checked_call_with_output(emsdk + ' install 1.38.33', expected='Downloading:', unexpected='already exist in destination') run_emsdk('activate 1.38.33') -assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read() -assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read() +assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read() +assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read() print('test specific release (new, full name)') run_emsdk('install sdk-1.38.33-upstream-64bit') From 702fc60a370fdbde346645126a50a1c1a156e749 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 21 Oct 2019 13:58:54 -0700 Subject: [PATCH 2/2] fix test --- emsdk.py | 4 ++-- test.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/emsdk.py b/emsdk.py index 337e953b30..b746481ed3 100755 --- a/emsdk.py +++ b/emsdk.py @@ -2714,8 +2714,8 @@ def report_upstream_by_default(): print('''\ ** NOTICE **: The default SDK changed from `fastcomp` to `upstream`. If you have problems, or wish to revert back to fastcomp for some other reason -you can add `-fastcomp` to explitly install that fastcomp-based -SDK. .e.g ./emsdk install latest-fastcomp. +you can add `-fastcomp` to explicitly install that fastcomp-based +SDK, .e.g ./emsdk install latest-fastcomp. ''', file=sys.stderr) # Replace meta-packages with the real package names. diff --git a/test.py b/test.py index 3dd41b9c57..e3cd3a03fa 100755 --- a/test.py +++ b/test.py @@ -159,8 +159,8 @@ def run_emsdk(cmd): print('another install must re-download') checked_call_with_output(emsdk + ' install 1.38.33', expected='Downloading:', unexpected='already exist in destination') run_emsdk('activate 1.38.33') -assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read() -assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read() +assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read() +assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read() print('test specific release (new, full name)') run_emsdk('install sdk-1.38.33-upstream-64bit')