From d3173800ee2af48be6a295f421f8c1c63114832d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 14 Feb 2024 14:08:39 -0800 Subject: [PATCH] Unify handling of deprecated settings Unlike `LEGACY_SETTINGS`, deprecated settings can continue to be used and the values passed in will continue to be honored. Once folks have stopped using them we can move them to `LEGACY_SETTINGS`. --- test/test_other.py | 2 +- tools/link.py | 11 ++++------- tools/settings.py | 10 ++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index 1d47353caec4..5f5d0d4022c0 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -8514,7 +8514,7 @@ def test_exported_runtime_methods_metadce(self, use_legacy_name): setting_name = 'EXTRA_EXPORTED_RUNTIME_METHODS' err = self.run_process([EMCC, test_file('hello_world.c'), '-Os', '-s%s=%s' % (setting_name, ','.join(exports))], stderr=PIPE).stderr if use_legacy_name: - self.assertContained('warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]', err) + self.assertContained('warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated (please use EXPORTED_RUNTIME_METHODS instead). Please open a bug if you have a continuing need for this setting [-Wdeprecated]', err) js = read_file('a.out.js') for export in exports: self.assertContained(f'Module["{export}"]', js) diff --git a/tools/link.py b/tools/link.py index b38539e4eee8..57f32d09280e 100644 --- a/tools/link.py +++ b/tools/link.py @@ -38,7 +38,7 @@ from .shared import in_temp, safe_copy, do_replace, OFormat from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS, STATICLIB_ENDINGS from .shared import unsuffixed, unsuffixed_basename, get_file_suffix -from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS +from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS, DEPRECATED_SETTINGS from .minimal_runtime_shell import generate_minimal_runtime_html import tools.line_endings @@ -698,14 +698,11 @@ def phase_linker_setup(options, state, newargs): final_suffix = get_file_suffix(target) - if 'SUPPORT_ERRNO' in user_settings: - diagnostics.warning('deprecated', 'SUPPORT_ERRNO is deprecated since emscripten no longer uses the setErrNo library function') - - if 'DEMANGLE_SUPPORT' in user_settings: - diagnostics.warning('deprecated', 'DEMANGLE_SUPPORT is deprecated since mangled names no longer appear in stack traces') + for s, reason in DEPRECATED_SETTINGS.items(): + if s in user_settings: + diagnostics.warning('deprecated', f'{s} is deprecated ({reason}). Please open a bug if you have a continuing need for this setting') if settings.EXTRA_EXPORTED_RUNTIME_METHODS: - diagnostics.warning('deprecated', 'EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead') settings.EXPORTED_RUNTIME_METHODS += settings.EXTRA_EXPORTED_RUNTIME_METHODS # If no output format was specified we try to deduce the format based on diff --git a/tools/settings.py b/tools/settings.py index 67d01f2b9885..cd54d540cea8 100644 --- a/tools/settings.py +++ b/tools/settings.py @@ -109,6 +109,16 @@ 'RUNTIME_LINKED_LIBS', }.union(PORTS_SETTINGS) +# Unlike `LEGACY_SETTINGS`, deprecated settings can still be used +# both on the command line and in the emscripten codebase. +# +# At some point in the future, once folks have stopped using these +# settings we can move them to `LEGACY_SETTINGS`. +DEPRECATED_SETTINGS = { + 'SUPPORT_ERRNO': 'emscripten no longer uses the setErrNo library function', + 'EXTRA_EXPORTED_RUNTIME_METHODS': 'please use EXPORTED_RUNTIME_METHODS instead', + 'DEMANGLE_SUPPORT': 'mangled names no longer appear in stack traces', +} # Settings that don't need to be externalized when serializing to json because they # are not used by the JS compiler.