FrozenGene commented on a change in pull request #4749: [AutoTVM] Support to 
pass additional compiler options
URL: https://github.com/apache/incubator-tvm/pull/4749#discussion_r374597354
 
 

 ##########
 File path: python/tvm/module.py
 ##########
 @@ -162,13 +162,20 @@ def export_library(self,
                     f.write(_PackImportsToC(self, is_system_lib))
                 files.append(path_cc)
 
-        if has_c_module:
-            options = []
-            if "options" in kwargs:
-                opts = kwargs["options"]
-                options = opts if isinstance(opts, (list, tuple)) else [opts]
-            opts = options + ["-I" + path for path in find_include_path()]
-            kwargs.update({'options': opts})
+        # Make sure we won't pass {'options': None} or {'options': [None, 
'-std=c++11', ...]}
+        # to compiler. We can not prevent users doing the following code:
+        # f.export_library(path_dso, cc.create_shared, options=None)
+        # f.export_library(path_dso, cc.create_shared, options=[None, 
'-std=c++11'])
+        if "options" in kwargs or has_c_module:
+            opts = kwargs["options"] if "options" in kwargs else None
+            options = opts if isinstance(opts, (list, tuple)) else [opts]
+            options = [opt for opt in options if opt]
+            if has_c_module:
+                options = options + ["-I" + path for path in 
find_include_path()]
+            if not options:
+                del kwargs["options"]
+            else:
+                kwargs.update({'options': options})
 
 Review comment:
   Done. Please review it again.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to