Skip to content

Commit

Permalink
Unify handling of deprecated settings (emscripten-core#21355)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
sbc100 authored and mrolig5267319 committed Feb 23, 2024
1 parent 45d3e2b commit f025e37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f025e37

Please sign in to comment.