MCPcopy Create free account
hub / github.com/apache/tvm / _linux_compile

Function _linux_compile

python/tvm/support/cc.py:335–371  ·  view source on GitHub ↗
(
    output, objects, options, compile_cmd, cwd=None, ccache_env=None, compile_shared=False
)

Source from the content-addressed store, hash-verified

333
334
335def _linux_compile(
336 output, objects, options, compile_cmd, cwd=None, ccache_env=None, compile_shared=False
337):
338 cmd = [compile_cmd]
339 if compile_cmd != "nvcc":
340 if compile_shared or output.endswith(".so") or output.endswith(".dylib"):
341 cmd += ["-shared", "-fPIC"]
342 if sys.platform == "darwin":
343 cmd += ["-undefined", "dynamic_lookup"]
344 elif output.endswith(".obj"):
345 cmd += ["-c"]
346 else:
347 if compile_shared or output.endswith(".so") or output.endswith(".dylib"):
348 cmd += ["-shared"]
349 cmd += ["-o", output]
350 if options:
351 cmd += options
352 if isinstance(objects, str):
353 cmd += [objects]
354 else:
355 cmd += objects
356 env = None
357 if ccache_env is not None:
358 if shutil.which("ccache"):
359 cmd.insert(0, "ccache")
360 env = os.environ.copy()
361 env.update(ccache_env)
362 else:
363 raise ValueError("ccache not found")
364
365 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, env=env)
366 (out, _) = proc.communicate()
367 if proc.returncode != 0:
368 msg = "Compilation error:\n"
369 msg += out.decode("utf-8", errors="replace")
370 msg += "\nCommand line: " + " ".join(cmd)
371 raise RuntimeError(msg)
372
373
374def _windows_compile(output, objects, options, cwd=None, ccache_env=None):

Callers 2

create_sharedFunction · 0.85
create_executableFunction · 0.85

Calls 4

copyMethod · 0.45
updateMethod · 0.45
decodeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…