Skip to content

Commit e06f93b

Browse files
authored
Remove special parsing of -x (language) flag. NFC (emscripten-core#23474)
1 parent a0cc695 commit e06f93b

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

emcc.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def __init__(self):
183183
self.dash_E = False
184184
self.dash_S = False
185185
self.dash_M = False
186+
self.input_language = None
186187

187188

188189
def create_reproduce_file(name, args):
@@ -698,7 +699,7 @@ def phase_parse_arguments(state):
698699
settings.WARN_DEPRECATED = 0
699700

700701
for i in range(len(newargs)):
701-
if newargs[i] in ('-l', '-L', '-I', '-z', '--js-library', '-o'):
702+
if newargs[i] in ('-l', '-L', '-I', '-z', '--js-library', '-o', '-x'):
702703
# Scan for flags that can be written as either one or two arguments
703704
# and normalize them to the single argument form.
704705
if newargs[i] == '--js-library':
@@ -951,20 +952,6 @@ def phase_compile_inputs(options, state, newargs):
951952

952953
system_libs.ensure_sysroot()
953954

954-
def get_language_mode(args):
955-
return_next = False
956-
for item in args:
957-
if return_next:
958-
return item
959-
if item == '-x':
960-
return_next = True
961-
continue
962-
if item.startswith('-x'):
963-
return removeprefix(item, '-x')
964-
return ''
965-
966-
language_mode = get_language_mode(newargs)
967-
968955
def get_clang_command():
969956
return compiler + get_cflags(state.orig_args)
970957

@@ -1039,7 +1026,7 @@ def compile_source_file(i, input_file):
10391026
elif building.is_ar(input_file):
10401027
logger.debug(f'using static library: {input_file}')
10411028
linker_inputs.append((i, input_file))
1042-
elif language_mode:
1029+
elif options.input_language:
10431030
compile_source_file(i, input_file)
10441031
elif input_file == '-':
10451032
exit_with_error('-E or -x required when input is from standard input')
@@ -1453,6 +1440,9 @@ def consume_arg_file():
14531440
options.dash_E = True
14541441
elif arg in ('-M', '-MM'):
14551442
options.dash_M = True
1443+
elif arg.startswith('-x'):
1444+
# TODO(sbc): Handle multiple -x flags on the same command line
1445+
options.input_language = arg
14561446
elif arg == '-fsyntax-only':
14571447
options.syntax_only = True
14581448
elif arg in SIMD_INTEL_FEATURE_TOWER or arg in SIMD_NEON_FLAGS:

0 commit comments

Comments
 (0)