(output, objects, options, cwd=None, ccache_env=None)
| 372 | |
| 373 | |
| 374 | def _windows_compile(output, objects, options, cwd=None, ccache_env=None): |
| 375 | compiler = os.getenv("TVM_WIN_CC", default="clang") |
| 376 | win_target = os.getenv("TVM_WIN_TARGET", default="x86_64") |
| 377 | cmd = [compiler] |
| 378 | cmd += ["-O2"] |
| 379 | cmd += ["--target=" + win_target] |
| 380 | |
| 381 | if output.endswith(".so") or output.endswith(".dll"): |
| 382 | cmd += ["-shared"] |
| 383 | elif output.endswith(".obj"): |
| 384 | cmd += ["-c"] |
| 385 | |
| 386 | if isinstance(objects, str): |
| 387 | objects = [objects] |
| 388 | cmd += ["-o", output] |
| 389 | cmd += objects |
| 390 | if options: |
| 391 | cmd += options |
| 392 | env = None |
| 393 | if ccache_env is not None: |
| 394 | if shutil.which("ccache"): |
| 395 | cmd.insert(0, "ccache") |
| 396 | env = os.environ.copy() |
| 397 | env.update(ccache_env) |
| 398 | else: |
| 399 | raise ValueError("ccache not found") |
| 400 | |
| 401 | try: |
| 402 | proc = subprocess.Popen( |
| 403 | cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, env=env |
| 404 | ) |
| 405 | (out, _) = proc.communicate() |
| 406 | except FileNotFoundError: |
| 407 | raise RuntimeError( |
| 408 | "Can not find the LLVM clang for Windows clang.exe)." |
| 409 | "Make sure it's installed" |
| 410 | " and the installation directory is in the %PATH% environment " |
| 411 | "variable. Prebuilt binaries can be found at: https://llvm.org/" |
| 412 | ) |
| 413 | if proc.returncode != 0: |
| 414 | msg = "Compilation error:\n" |
| 415 | msg += " ".join(cmd) + "\n" |
| 416 | msg += out.decode("utf-8", errors="replace") |
| 417 | |
| 418 | raise RuntimeError(msg) |
no test coverage detected
searching dependent graphs…