(options, state, newargs)
| 503 | |
| 504 | @ToolchainProfiler.profile_block('compile inputs') |
| 505 | def phase_compile_inputs(options, state, newargs): |
| 506 | if shared.run_via_emxx: |
| 507 | compiler = [shared.CLANG_CXX] |
| 508 | else: |
| 509 | compiler = [shared.CLANG_CC] |
| 510 | |
| 511 | if config.COMPILER_WRAPPER: |
| 512 | logger.debug('using compiler wrapper: %s', config.COMPILER_WRAPPER) |
| 513 | compiler.insert(0, config.COMPILER_WRAPPER) |
| 514 | |
| 515 | system_libs.ensure_sysroot() |
| 516 | |
| 517 | def get_clang_command(): |
| 518 | return compiler + compile.get_cflags(state.orig_args) |
| 519 | |
| 520 | def get_clang_command_preprocessed(): |
| 521 | return compiler + compile.get_clang_flags(state.orig_args) |
| 522 | |
| 523 | def get_clang_command_asm(): |
| 524 | return compiler + compile.get_target_flags() |
| 525 | |
| 526 | if state.mode == Mode.COMPILE_ONLY: |
| 527 | if options.output_file and get_file_suffix(options.output_file) == '.bc' and not settings.LTO and '-emit-llvm' not in state.orig_args: |
| 528 | 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') |
| 529 | if all(get_file_suffix(i) in ASSEMBLY_EXTENSIONS for i in options.input_files): |
| 530 | cmd = get_clang_command_asm() + newargs |
| 531 | else: |
| 532 | cmd = get_clang_command() + newargs |
| 533 | shared.exec_process(cmd) |
| 534 | assert False, 'exec_process should not return' |
| 535 | |
| 536 | # In COMPILE_AND_LINK we need to compile source files too, but we also need to |
| 537 | # filter out the link flags |
| 538 | assert state.mode == Mode.COMPILE_AND_LINK |
| 539 | assert not options.dash_c |
| 540 | compile_args, linker_args = separate_linker_flags(newargs) |
| 541 | |
| 542 | # Map of file basenames to how many times we've seen them. We use this to generate |
| 543 | # unique `_NN` suffix for object files in cases when we are compiling multiple sources that |
| 544 | # have the same basename. e.g. `foo/utils.c` and `bar/utils.c` on the same command line. |
| 545 | seen_names = {} |
| 546 | |
| 547 | def uniquename(name): |
| 548 | if name not in seen_names: |
| 549 | # No suffix needed the first time we see given name. |
| 550 | seen_names[name] = 1 |
| 551 | return name |
| 552 | |
| 553 | unique_suffix = '_%d' % seen_names[name] |
| 554 | seen_names[name] += 1 |
| 555 | base, ext = os.path.splitext(name) |
| 556 | return base + unique_suffix + ext |
| 557 | |
| 558 | def get_object_filename(input_file): |
| 559 | objfile = unsuffixed_basename(input_file) + '.o' |
| 560 | return in_temp(uniquename(objfile)) |
| 561 | |
| 562 | def compile_source_file(input_file): |
no test coverage detected