|
20 | 20 |
|
21 | 21 | import functools |
22 | 22 | import hashlib |
| 23 | +import logging |
23 | 24 | import os |
24 | 25 | import shutil |
25 | 26 | import subprocess |
|
36 | 37 | IS_WINDOWS = sys.platform == "win32" |
37 | 38 | BACKEND_STR = Literal["cuda", "hip"] |
38 | 39 |
|
| 40 | +logger = logging.getLogger(__name__) |
| 41 | + |
39 | 42 |
|
40 | 43 | @functools.lru_cache |
41 | 44 | def _detect_gpu_backend() -> BACKEND_STR: |
@@ -590,16 +593,22 @@ def build_ninja(build_dir: str) -> None: |
590 | 593 | status = _run_command_in_dev_prompt(args=command, cwd=build_dir, capture_output=True) |
591 | 594 | else: |
592 | 595 | status = subprocess.run(check=False, args=command, cwd=build_dir, capture_output=True) |
| 596 | + encoding = "oem" if IS_WINDOWS else "utf-8" |
593 | 597 | if status.returncode != 0: |
594 | 598 | msg = [f"ninja exited with status {status.returncode}"] |
595 | | - encoding = "oem" if IS_WINDOWS else "utf-8" |
596 | 599 | if status.stdout: |
597 | 600 | msg.append(f"stdout:\n{status.stdout.decode(encoding)}") |
598 | 601 | if status.stderr: |
599 | 602 | msg.append(f"stderr:\n{status.stderr.decode(encoding)}") |
600 | 603 |
|
601 | 604 | raise RuntimeError("\n".join(msg)) |
602 | 605 |
|
| 606 | + LOG_BUILD = os.environ.get("TVM_FFI_CPP_EXTENSION_LOG_BUILD", "0") |
| 607 | + if LOG_BUILD in ("1", "stdout"): |
| 608 | + logger.info("ninja build stdout:\n%s", status.stdout.decode(encoding)) |
| 609 | + if LOG_BUILD in ("1", "stderr"): |
| 610 | + logger.info("ninja build stderr:\n%s", status.stderr.decode(encoding)) |
| 611 | + |
603 | 612 |
|
604 | 613 | # Translation table for escaping C++ string literals |
605 | 614 | _CPP_ESCAPE_TABLE = str.maketrans( |
|
0 commit comments