Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions emar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
import sys
from tools import shared

cmd = [shared.LLVM_AR] + sys.argv[1:]
sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode)
shared.exec_process([shared.LLVM_AR] + sys.argv[1:])
19 changes: 4 additions & 15 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,17 +934,6 @@ def get_clang_output_extension(state):
return '.o'


def exec_subprocess_and_exit(cmd):
if utils.WINDOWS:
shared.check_call(cmd)
sys.exit(0)
else:
shared.print_compiler_stage(cmd)
sys.stdout.flush()
sys.stderr.flush()
os.execv(cmd[0], cmd)


@ToolchainProfiler.profile_block('compile inputs')
def phase_compile_inputs(options, state, newargs, input_files):
if shared.run_via_emxx:
Expand Down Expand Up @@ -993,7 +982,7 @@ def get_clang_command_asm():
# output the dependency rule. Warning: clang and gcc behave differently
# with -MF! (clang seems to not recognize it)
logger.debug(('just preprocessor ' if state.has_dash_E else 'just dependencies: ') + ' '.join(cmd))
exec_subprocess_and_exit(cmd)
shared.exec_process(cmd)

# Precompiled headers support
if state.mode == Mode.PCH:
Expand All @@ -1005,7 +994,7 @@ def get_clang_command_asm():
if options.output_file:
cmd += ['-o', options.output_file]
logger.debug(f"running (for precompiled headers): {cmd[0]} {' '.join(cmd[1:])}")
exec_subprocess_and_exit(cmd)
shared.exec_process(cmd)

if state.mode == Mode.COMPILE_ONLY:
inputs = [i[1] for i in input_files]
Expand All @@ -1020,7 +1009,7 @@ def get_clang_command_asm():
ext = get_clang_output_extension(state)
if not options.output_file and options.default_object_extension != ext:
# If we are using a non-standard output file extention we cannot use
# exec_subprocess_and_exit here since we need to rename the files
# exec_process here since we need to rename the files
# after clang runs (since clang does not support --default-obj-ext)
# TODO: Remove '--default-obj-ext' to reduce this complexity
shared.check_call(cmd)
Expand All @@ -1030,7 +1019,7 @@ def get_clang_command_asm():
shutil.move(output, new_output)
sys.exit(0)
else:
exec_subprocess_and_exit(cmd)
shared.exec_process(cmd)

# In COMPILE_AND_LINK we need to compile source files too, but we also need to
# filter out the link flags
Expand Down
9 changes: 1 addition & 8 deletions emranlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@
import sys
from tools import shared


def run():
newargs = [shared.LLVM_RANLIB] + sys.argv[1:]
return shared.run_process(newargs, stdin=sys.stdin, check=False).returncode


if __name__ == '__main__':
sys.exit(run())
shared.exec_process([shared.LLVM_RANLIB] + sys.argv[1:])
3 changes: 1 addition & 2 deletions emstrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
import sys
from tools import shared

cmd = [shared.LLVM_STRIP] + sys.argv[1:]
sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode)
shared.exec_process([shared.LLVM_STRIP] + sys.argv[1:])
3 changes: 1 addition & 2 deletions tools/emdwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

from tools import shared

cmd = [shared.LLVM_DWP] + sys.argv[1:]
sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode)
shared.exec_process([shared.LLVM_DWP] + sys.argv[1:])
3 changes: 1 addition & 2 deletions tools/emnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

from tools import shared

cmd = [shared.LLVM_NM] + sys.argv[1:]
sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode)
shared.exec_process([shared.LLVM_NM] + sys.argv[1:])
11 changes: 11 additions & 0 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ def check_call(cmd, *args, **kw):
exit_with_error("'%s' failed: %s", shlex_join(cmd), str(e))


def exec_process(cmd):
if utils.WINDOWS:
rtn = run_process(cmd, stdin=sys.stdin, check=False).returncode
sys.exit(rtn)
else:
print_compiler_stage(cmd)
sys.stdout.flush()
sys.stderr.flush()
os.execv(cmd[0], cmd)


def run_js_tool(filename, jsargs=[], node_args=[], **kw): # noqa: mutable default args
"""Execute a javascript tool.

Expand Down