MCPcopy Index your code
hub / github.com/apache/tvm / create_staticlib

Function create_staticlib

python/tvm/support/ndk.py:80–127  ·  view source on GitHub ↗

Create static library: Parameters ---------- output : str The target static library. inputs : list List of object files or tar files

(output, inputs)

Source from the content-addressed store, hash-verified

78
79
80def create_staticlib(output, inputs):
81 """Create static library:
82
83 Parameters
84 ----------
85 output : str
86 The target static library.
87
88 inputs : list
89 List of object files or tar files
90 """
91 if "TVM_NDK_CC" not in os.environ:
92 raise RuntimeError(
93 "Require environment variable TVM_NDK_CC to be the NDK standalone compiler"
94 )
95 output_name = os.path.basename(output)
96
97 temp = _utils.tempdir()
98 tmp_output = temp.relpath("lib" + output_name)
99 objects = _tar.normalize_file_list_by_unpacking_tars(temp, inputs)
100
101 compiler = os.environ["TVM_NDK_CC"]
102 base_path = os.path.dirname(compiler)
103 ar_path = os.path.join(base_path, "llvm-ar")
104 cmd = [ar_path]
105 cmd += ["qcs", tmp_output]
106 cmd += objects
107
108 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
109 (out, _) = proc.communicate()
110 if proc.returncode != 0:
111 msg = "AR error:\n"
112 msg += out.decode("utf-8", errors="replace")
113 msg += "\nCommand line: " + " ".join(cmd)
114 raise RuntimeError(msg)
115
116 ranlib_path = os.path.join(base_path, "llvm-ranlib")
117 cmd = [ranlib_path]
118 cmd += [tmp_output]
119 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
120 (out, _) = proc.communicate()
121 if proc.returncode != 0:
122 msg = "Ranlib error:\n"
123 msg += out.decode("utf-8", errors="replace")
124 msg += "\nCommand line: " + " ".join(cmd)
125 raise RuntimeError(msg)
126
127 shutil.move(tmp_output, output)
128
129
130create_staticlib.output_format = "a"

Callers

nothing calls this directly

Calls 3

relpathMethod · 0.80
joinMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…