@@ -113,9 +113,6 @@ def __init__(self, args):
113113 self .mode = Mode .COMPILE_AND_LINK
114114 # Using tuple here to prevent accidental mutation
115115 self .orig_args = tuple (args )
116- self .has_dash_c = False
117- self .has_dash_E = False
118- self .has_dash_S = False
119116 # List of link options paired with their position on the command line [(i, option), ...].
120117 self .link_flags = []
121118 self .lib_dirs = []
@@ -179,6 +176,11 @@ def __init__(self):
179176 self .shared = False
180177 self .relocatable = False
181178 self .reproduce = None
179+ self .syntax_only = False
180+ self .dash_c = False
181+ self .dash_E = False
182+ self .dash_S = False
183+ self .dash_M = False
182184
183185
184186def create_reproduce_file (name , args ):
@@ -817,17 +819,13 @@ def phase_setup(options, state, newargs):
817819 # so it won't think about generating native x86 SSE code.
818820 newargs = [x for x in newargs if x not in SIMD_INTEL_FEATURE_TOWER and x not in SIMD_NEON_FLAGS ]
819821
820- state .has_dash_c = '-c' in newargs or '--precompile' in newargs
821- state .has_dash_S = '-S' in newargs
822- state .has_dash_E = '-E' in newargs
823-
824822 if options .post_link :
825823 state .mode = Mode .POST_LINK_ONLY
826- elif state . has_dash_E or '-M' in newargs or '-MM' in newargs or '-fsyntax-only' in newargs :
824+ elif options . dash_E or options . dash_M :
827825 state .mode = Mode .PREPROCESS_ONLY
828826 elif has_header_inputs :
829827 state .mode = Mode .PCH
830- elif state . has_dash_c or state . has_dash_S :
828+ elif options . dash_c or options . dash_S or options . syntax_only :
831829 state .mode = Mode .COMPILE_ONLY
832830
833831 if state .mode in (Mode .COMPILE_ONLY , Mode .PREPROCESS_ONLY ):
@@ -984,7 +982,7 @@ def get_clang_command_preprocessed():
984982 def get_clang_command_asm ():
985983 return compiler + get_target_flags () + compile_args
986984
987- # preprocessor-only (-E) support
985+ # preprocessor-only (-E/-M ) support
988986 if state .mode == Mode .PREPROCESS_ONLY :
989987 inputs = [i [1 ] for i in input_files ]
990988 cmd = get_clang_command () + inputs
@@ -993,7 +991,7 @@ def get_clang_command_asm():
993991 # Do not compile, but just output the result from preprocessing stage or
994992 # output the dependency rule. Warning: clang and gcc behave differently
995993 # with -MF! (clang seems to not recognize it)
996- logger .debug (('just preprocessor ' if state . has_dash_E else 'just dependencies: ' ) + ' ' .join (cmd ))
994+ logger .debug (('just preprocessor: ' if options . dash_E else 'just dependencies: ' ) + ' ' .join (cmd ))
997995 shared .exec_process (cmd )
998996 assert False , 'exec_process does not return'
999997
@@ -1026,7 +1024,7 @@ def get_clang_command_asm():
10261024 # In COMPILE_AND_LINK we need to compile source files too, but we also need to
10271025 # filter out the link flags
10281026 assert state .mode == Mode .COMPILE_AND_LINK
1029- assert not state . has_dash_c
1027+ assert not options . dash_c
10301028 compile_args = filter_out_link_flags (compile_args )
10311029 linker_inputs = []
10321030 seen_names = {}
@@ -1069,7 +1067,7 @@ def compile_source_file(i, input_file):
10691067 # First, generate LLVM bitcode. For each input file, we get base.o with bitcode
10701068 for i , input_file in input_files :
10711069 file_suffix = get_file_suffix (input_file )
1072- if file_suffix in SOURCE_ENDINGS + ASSEMBLY_ENDINGS or (state . has_dash_c and file_suffix == '.bc' ):
1070+ if file_suffix in SOURCE_ENDINGS + ASSEMBLY_ENDINGS or (options . dash_c and file_suffix == '.bc' ):
10731071 compile_source_file (i , input_file )
10741072 elif file_suffix in DYNAMICLIB_ENDINGS :
10751073 logger .debug (f'using shared library: { input_file } ' )
@@ -1486,6 +1484,16 @@ def consume_arg_file():
14861484 exit_with_error (f'unsupported target: { options .target } (emcc only supports wasm64-unknown-emscripten and wasm32-unknown-emscripten)' )
14871485 elif check_arg ('--use-port' ):
14881486 ports .handle_use_port_arg (settings , consume_arg ())
1487+ elif arg in ('-c' , '--precompile' ):
1488+ options .dash_c = True
1489+ elif arg == '-S' :
1490+ options .dash_S = True
1491+ elif arg == '-E' :
1492+ options .dash_E = True
1493+ elif arg in ('-M' , '-MM' ):
1494+ options .dash_M = True
1495+ elif arg == '-fsyntax-only' :
1496+ options .syntax_only = True
14891497
14901498 if should_exit :
14911499 sys .exit (0 )
0 commit comments