Skip to content

Commit b66f170

Browse files
authored
emcc.py: Avoid mutating user_args in get_cflags. NFC (#17493)
The addition of `-msimd128` to `user_args` here only effects the lines below within this function, since `user_args` is not what we pass to clang.
1 parent 49da56e commit b66f170

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

emcc.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ class Mode(Enum):
220220
class EmccState:
221221
def __init__(self, args):
222222
self.mode = Mode.COMPILE_AND_LINK
223-
self.orig_args = args
223+
# Using tuple here to prevent accidental mutation
224+
self.orig_args = tuple(args)
224225
self.has_dash_c = False
225226
self.has_dash_E = False
226227
self.has_dash_S = False
@@ -791,13 +792,9 @@ def array_contains_any_of(hay, needles):
791792
if n in hay:
792793
return True
793794

794-
# relaxed-simd implies simd128.
795-
if '-mrelaxed-simd' in user_args:
796-
user_args += ['-msimd128']
797-
798795
if array_contains_any_of(user_args, SIMD_INTEL_FEATURE_TOWER) or array_contains_any_of(user_args, SIMD_NEON_FLAGS):
799-
if '-msimd128' not in user_args:
800-
exit_with_error('Passing any of ' + ', '.join(SIMD_INTEL_FEATURE_TOWER + SIMD_NEON_FLAGS) + ' flags also requires passing -msimd128!')
796+
if '-msimd128' not in user_args and '-mrelaxed-simd' not in user_args:
797+
exit_with_error('Passing any of ' + ', '.join(SIMD_INTEL_FEATURE_TOWER + SIMD_NEON_FLAGS) + ' flags also requires passing -msimd128 (or -mrelaxed-simd)!')
801798
cflags += ['-D__SSE__=1']
802799

803800
if array_contains_any_of(user_args, SIMD_INTEL_FEATURE_TOWER[1:]):
@@ -1255,7 +1252,7 @@ def phase_parse_arguments(state):
12551252
"""The first phase of the compiler. Parse command line argument and
12561253
populate settings.
12571254
"""
1258-
newargs = state.orig_args.copy()
1255+
newargs = list(state.orig_args)
12591256

12601257
# Scan and strip emscripten specific cmdline warning flags.
12611258
# This needs to run before other cmdline flags have been parsed, so that

0 commit comments

Comments
 (0)