|
44 | 44 | from tools.response_file import substitute_response_files
|
45 | 45 | from tools import config
|
46 | 46 | from tools import cache
|
47 |
| -from tools import link |
48 | 47 | from tools.settings import default_setting, user_settings, settings, MEM_SIZE_SETTINGS, COMPILE_TIME_SETTINGS
|
49 | 48 | from tools.utils import read_file, removeprefix
|
50 | 49 |
|
@@ -628,20 +627,24 @@ def run(args):
|
628 | 627 | if state.mode == Mode.POST_LINK_ONLY:
|
629 | 628 | if len(input_files) != 1:
|
630 | 629 | exit_with_error('--post-link requires a single input file')
|
| 630 | + # Delay import of link.py to avoid processing this file when only compiling |
| 631 | + from tools import link |
631 | 632 | link.run_post_link(input_files[0][1], options, state, newargs)
|
632 | 633 | return 0
|
633 | 634 |
|
634 | 635 | ## Compile source code to object files
|
635 | 636 | linker_inputs = phase_compile_inputs(options, state, newargs, input_files)
|
636 | 637 |
|
637 |
| - if state.mode != Mode.COMPILE_AND_LINK: |
| 638 | + if state.mode == Mode.COMPILE_AND_LINK: |
| 639 | + # Delay import of link.py to avoid processing this file when only compiling |
| 640 | + from tools import link |
| 641 | + return link.run(linker_inputs, options, state, newargs) |
| 642 | + else: |
638 | 643 | logger.debug('stopping after compile phase')
|
639 | 644 | for flag in state.link_flags:
|
640 | 645 | diagnostics.warning('unused-command-line-argument', "argument unused during compilation: '%s'" % flag[1])
|
641 | 646 | return 0
|
642 | 647 |
|
643 |
| - return link.run(linker_inputs, options, state, newargs) |
644 |
| - |
645 | 648 |
|
646 | 649 | def normalize_boolean_setting(name, value):
|
647 | 650 | # boolean NO_X settings are aliases for X
|
|
0 commit comments