From 06f70257e1e2116796dd0561846fb910ab4768cb Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 23 Oct 2025 10:15:10 -0700 Subject: [PATCH] Remove FAST_MATH internal settings This was just added #25513, but using a setting for this was overkill. --- src/settings_internal.js | 5 ----- tools/cmdline.py | 5 +++-- tools/link.py | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/settings_internal.js b/src/settings_internal.js index d475180b40954..ae89b4b194730 100644 --- a/src/settings_internal.js +++ b/src/settings_internal.js @@ -260,11 +260,6 @@ var ASYNCIFY_IMPORTS_EXCEPT_JS_LIBS = []; var WARN_DEPRECATED = true; -// Enable fast math optimizations in wasm-opt when -ffast-math is passed. -// This enables aggressive floating-point optimizations that may violate -// IEEE 754 semantics but can improve performance. -var FAST_MATH = 0; - // WebGL 2 provides new garbage-free entry points to call to WebGL. Use // those always when possible. // We currently set this to false for certain browser when large memory sizes diff --git a/tools/cmdline.py b/tools/cmdline.py index 6fa339962d7ab..c115d1b953b0f 100644 --- a/tools/cmdline.py +++ b/tools/cmdline.py @@ -112,6 +112,7 @@ def __init__(self): self.sanitize_minimal_runtime = False self.sanitize = set() self.lib_dirs = [] + self.fast_math = False def is_int(s): @@ -302,7 +303,7 @@ def consume_arg_file(): settings.DEBUG_LEVEL = max(settings.DEBUG_LEVEL, 1) elif requested_level == 'fast': # -Ofast typically includes -ffast-math semantics - settings.FAST_MATH = 1 + options.fast_math = True requested_level = 3 settings.SHRINK_LEVEL = 0 else: @@ -552,7 +553,7 @@ def consume_arg_file(): elif arg == '-fignore-exceptions': settings.DISABLE_EXCEPTION_CATCHING = 1 elif arg == '-ffast-math': - settings.FAST_MATH = 1 + options.fast_math = True elif check_arg('--default-obj-ext'): exit_with_error('--default-obj-ext is no longer supported by emcc') elif arg.startswith('-fsanitize=cfi'): diff --git a/tools/link.py b/tools/link.py index 0dc696e988ec2..e9eee770d7705 100644 --- a/tools/link.py +++ b/tools/link.py @@ -360,7 +360,7 @@ def should_run_binaryen_optimizer(): return settings.OPT_LEVEL >= 2 -def get_binaryen_passes(): +def get_binaryen_passes(options): passes = [] optimizing = should_run_binaryen_optimizer() # wasm-emscripten-finalize will strip the features section for us @@ -392,7 +392,7 @@ def get_binaryen_passes(): passes += ['--pass-arg=post-emscripten-side-module'] if optimizing: passes += [building.opt_level_to_str(settings.OPT_LEVEL, settings.SHRINK_LEVEL)] - if settings.FAST_MATH: + if options.fast_math: passes += ['--fast-math'] # when optimizing, use the fact that low memory is never used (1024 is a # hardcoded value in the binaryen pass). we also cannot do it when the stack @@ -2292,7 +2292,7 @@ def phase_binaryen(target, options, wasm_target): # run wasm-opt if we have work for it: either passes, or if we are using # source maps (which requires some extra processing to keep the source map # but remove DWARF) - passes = get_binaryen_passes() + passes = get_binaryen_passes(options) if passes: # if asyncify is used, we will use it in the next stage, and so if it is # the only reason we need intermediate debug info, we can stop keeping it