2020 slows down compilation).
2121"""
2222
23- from tools .toolchain_profiler import ToolchainProfiler
24-
2523import logging
2624import os
2725import shlex
2826import shutil
2927import sys
30- import time
3128import tarfile
29+ import time
3230from dataclasses import dataclass
3331from enum import Enum , auto , unique
3432
35-
36- from tools import shared , system_libs , utils , cmdline
37- from tools import diagnostics , building , compile
38- from tools .shared import unsuffixed_basename , get_file_suffix
39- from tools .shared import exit_with_error , DEBUG
40- from tools .shared import in_temp
41- from tools .shared import DYLIB_EXTENSIONS
33+ from tools import (
34+ building ,
35+ cache ,
36+ cmdline ,
37+ compile ,
38+ config ,
39+ diagnostics ,
40+ shared ,
41+ system_libs ,
42+ utils ,
43+ )
4244from tools .cmdline import CLANG_FLAGS_WITH_ARGS
4345from tools .response_file import substitute_response_files
44- from tools import config
45- from tools import cache
46- from tools .settings import default_setting , user_settings , settings , COMPILE_TIME_SETTINGS
47- from tools .utils import read_file
46+ from tools .settings import (
47+ COMPILE_TIME_SETTINGS ,
48+ default_setting ,
49+ settings ,
50+ user_settings ,
51+ )
52+ from tools .shared import DEBUG , DYLIB_EXTENSIONS , exit_with_error , in_temp
53+ from tools .toolchain_profiler import ToolchainProfiler
54+ from tools .utils import get_file_suffix , read_file , unsuffixed_basename
4855
4956logger = logging .getLogger ('emcc' )
5057
@@ -250,10 +257,6 @@ def run(args):
250257 print (f'libraries: ={ cache .get_lib_dir (absolute = True )} ' )
251258 return 0
252259
253- if '-print-resource-dir' in args :
254- shared .check_call ([clang ] + args )
255- return 0
256-
257260 if '-print-libgcc-file-name' in args or '--print-libgcc-file-name' in args :
258261 settings .limit_settings (None )
259262 compiler_rt = system_libs .Library .get_usable_variations ()['libcompiler_rt' ]
@@ -292,6 +295,10 @@ def run(args):
292295
293296 phase_setup (options , state )
294297
298+ if '-print-resource-dir' in args or any (a .startswith ('--print-prog-name' ) for a in args ):
299+ shared .exec_process ([clang ] + compile .get_cflags (tuple (args )) + args )
300+ assert False , 'exec_process should not return'
301+
295302 if '--cflags' in args :
296303 # Just print the flags we pass to clang and exit. We need to do this after
297304 # phase_setup because the setup sets things like SUPPORT_LONGJMP.
@@ -308,7 +315,7 @@ def run(args):
308315 linker_args = separate_linker_flags (newargs )[1 ]
309316 linker_args = [f .value for f in linker_args ]
310317 # Delay import of link.py to avoid processing this file when only compiling
311- from tools import link
318+ from tools import link # noqa: PLC0415
312319 link .run_post_link (options .input_files [0 ], options , linker_args )
313320 return 0
314321
@@ -513,7 +520,7 @@ def get_clang_command_asm():
513520 else :
514521 cmd = get_clang_command () + newargs
515522 shared .exec_process (cmd )
516- assert False , 'exec_process does not return'
523+ assert False , 'exec_process should not return'
517524
518525 # In COMPILE_AND_LINK we need to compile source files too, but we also need to
519526 # filter out the link flags
@@ -566,7 +573,7 @@ def compile_source_file(input_file):
566573 if not shared .SKIP_SUBPROCS :
567574 assert os .path .exists (output_file )
568575 if options .save_temps :
569- shutil .copyfile (output_file , shared .unsuffixed_basename (input_file ) + '.o' )
576+ shutil .copyfile (output_file , utils .unsuffixed_basename (input_file ) + '.o' )
570577 return output_file
571578
572579 # Compile input files individually to temporary locations.
0 commit comments