Skip to content

Commit 3355efe

Browse files
authored
[emcc.py] Simplify compiler modes. NFC (#23466)
As a followup to #23454 we no longer need to distinguish between the some of these compiler modes. Specifically, `PCH` and `PREPROCESS_ONLY` are now subsumed by `COMPILE_ONLY` since all these modes simply exec clang and exit.
1 parent 9d4abe8 commit 3355efe

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

emcc.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@
101101

102102
@unique
103103
class Mode(Enum):
104-
PREPROCESS_ONLY = auto()
105-
PCH = auto()
104+
# Used any time we are not linking, including PCH, pre-processing, etc
106105
COMPILE_ONLY = auto()
106+
# Only when --post-link is specified
107107
POST_LINK_ONLY = auto()
108+
# This is the default mode, in the absence of any flags such as -c, -E, etc
108109
COMPILE_AND_LINK = auto()
109110

110111

@@ -826,14 +827,10 @@ def phase_setup(options, state, newargs):
826827

827828
if options.post_link:
828829
state.mode = Mode.POST_LINK_ONLY
829-
elif options.dash_E or options.dash_M:
830-
state.mode = Mode.PREPROCESS_ONLY
831-
elif has_header_inputs:
832-
state.mode = Mode.PCH
833-
elif options.dash_c or options.dash_S or options.syntax_only:
830+
elif has_header_inputs or options.dash_c or options.dash_S or options.syntax_only or options.dash_E or options.dash_M:
834831
state.mode = Mode.COMPILE_ONLY
835832

836-
if state.mode in (Mode.COMPILE_ONLY, Mode.PREPROCESS_ONLY):
833+
if state.mode == Mode.COMPILE_ONLY:
837834
for key in user_settings:
838835
if key not in COMPILE_TIME_SETTINGS:
839836
diagnostics.warning(
@@ -983,23 +980,6 @@ def get_clang_command_preprocessed():
983980
def get_clang_command_asm():
984981
return compiler + get_target_flags()
985982

986-
# preprocessor-only (-E/-M) support
987-
if state.mode == Mode.PREPROCESS_ONLY:
988-
cmd = get_clang_command() + newargs
989-
# Do not compile, but just output the result from preprocessing stage or
990-
# output the dependency rule. Warning: clang and gcc behave differently
991-
# with -MF! (clang seems to not recognize it)
992-
logger.debug(('just preprocessor: ' if options.dash_E else 'just dependencies: ') + ' '.join(cmd))
993-
shared.exec_process(cmd)
994-
assert False, 'exec_process does not return'
995-
996-
# Precompiled headers support
997-
if state.mode == Mode.PCH:
998-
cmd = get_clang_command() + newargs
999-
logger.debug(f"running (for precompiled headers): {cmd[0]} {' '.join(cmd[1:])}")
1000-
shared.exec_process(cmd)
1001-
assert False, 'exec_process does not return'
1002-
1003983
if state.mode == Mode.COMPILE_ONLY:
1004984
if options.output_file and get_file_suffix(options.output_file) == '.bc' and not settings.LTO and '-emit-llvm' not in state.orig_args:
1005985
diagnostics.warning('emcc', '.bc output file suffix used without -flto or -emit-llvm. Consider using .o extension since emcc will output an object file, not a bitcode file')

0 commit comments

Comments
 (0)