echuraev commented on code in PR #14876:
URL: https://github.com/apache/tvm/pull/14876#discussion_r1197386816
##########
python/tvm/contrib/cc.py:
##########
@@ -83,6 +84,47 @@ def create_shared(output, objects, options=None, cc=None):
raise ValueError("Unsupported platform")
+def _linux_ar(output, inputs, ar):
+ ar = ar or "ar"
+
+ libname = os.path.basename(output)
+ if not libname.startswith("lib"):
+ libname = "lib" + libname
+ temp = _utils.tempdir()
+ temp_output = temp.relpath(libname)
+ cmd = [ar, "-crs", temp_output]
+ objects = _tar.untar_files(temp, inputs)
+
+ cmd += objects
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
+ (out, _) = proc.communicate()
+ if proc.returncode != 0:
+ msg = "AR error:\n"
+ msg += py_str(out)
+ msg += "\nCommand line: " + " ".join(cmd)
+ raise RuntimeError(msg)
+
+ shutil.move(temp_output, output)
+
+
+def create_staticlib(output, inputs, ar=None):
+ """Create shared library.
+
+ Parameters
+ ----------
+ output : str
+ The target shared library.
+
+ objects : List[str]
+ List of inputs files.
+ """
Review Comment:
Could you please also add a description of `ar`?
##########
python/tvm/contrib/cc.py:
##########
@@ -83,6 +84,47 @@ def create_shared(output, objects, options=None, cc=None):
raise ValueError("Unsupported platform")
+def _linux_ar(output, inputs, ar):
+ ar = ar or "ar"
+
+ libname = os.path.basename(output)
+ if not libname.startswith("lib"):
+ libname = "lib" + libname
+ temp = _utils.tempdir()
+ temp_output = temp.relpath(libname)
+ cmd = [ar, "-crs", temp_output]
+ objects = _tar.untar_files(temp, inputs)
+
+ cmd += objects
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
+ (out, _) = proc.communicate()
+ if proc.returncode != 0:
+ msg = "AR error:\n"
+ msg += py_str(out)
+ msg += "\nCommand line: " + " ".join(cmd)
+ raise RuntimeError(msg)
+
+ shutil.move(temp_output, output)
+
+
+def create_staticlib(output, inputs, ar=None):
+ """Create shared library.
+
+ Parameters
+ ----------
+ output : str
+ The target shared library.
+
+ objects : List[str]
Review Comment:
```suggestion
inputs : List[str]
```
##########
python/tvm/contrib/cc.py:
##########
@@ -83,6 +84,47 @@ def create_shared(output, objects, options=None, cc=None):
raise ValueError("Unsupported platform")
+def _linux_ar(output, inputs, ar):
+ ar = ar or "ar"
+
+ libname = os.path.basename(output)
+ if not libname.startswith("lib"):
+ libname = "lib" + libname
+ temp = _utils.tempdir()
+ temp_output = temp.relpath(libname)
+ cmd = [ar, "-crs", temp_output]
+ objects = _tar.untar_files(temp, inputs)
Review Comment:
I took a look in the implementation of `untar_files` and it is not clear to
me why you need this function? From my point of view, you can use `cmd +=
inputs`.
Also, the second concern is that from the name of the function
`untar_files`, I have concluded that it works with archives and extract files
from it. But it is not clear, without reading the implementation of the
function, how it works with list of non-tar files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]