From c6c287bfa32214e61f8aa920c33f779db6455e5e Mon Sep 17 00:00:00 2001
From: Tianqi Chen <tqchen@users.noreply.github.com>
Date: Mon, 4 Sep 2017 17:53:18 -0700
Subject: [PATCH] [SETUP] Always use relpath for setup (#421)

* [SETUP] Always use relpath for setup

* [CMAKE] Fix cmake llvm build
---
 CMakeLists.txt                   | 5 ++++-
 python/setup.py                  | 4 +++-
 src/codegen/llvm/codegen_llvm.cc | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e60c5732..2748e6f9d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -129,7 +129,10 @@ if(USE_LLVM)
   message(STATUS "Build with LLVM support...")
   include_directories(${LLVM_INCLUDE_DIRS})
   add_definitions(${LLVM_DEFINITIONS})
-  add_definitions(-DTVM_LLVM_VERSION=${LLVM_PACKAGE_VERSION})
+  string(REPLACE "." "" TVM_LLVM_VERSION ${LLVM_PACKAGE_VERSION})
+  string(SUBSTRING ${TVM_LLVM_VERSION} 0 2 TVM_LLVM_VERSION)
+  message(STATUS "TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION})
+  add_definitions(-DTVM_LLVM_VERSION=${TVM_LLVM_VERSION})
   llvm_map_components_to_libnames(LLVM_LIBS all)
   list(REMOVE_ITEM LLVM_LIBS LTO)
   list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS})
diff --git a/python/setup.py b/python/setup.py
index 3ac721a7a..a997c6f52 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -88,9 +88,11 @@ if "bdist_wheel" in sys.argv:
         "include_package_data": True
     }
 else:
+    curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
+    rpath = os.path.relpath(LIB_PATH[0], curr_path)
     setup_kwargs = {
         "include_package_data": True,
-        "data_files": [('tvm', [LIB_PATH[0]])]
+        "data_files": [('tvm', [rpath])]
     }
 
 setup(name='tvm',
diff --git a/src/codegen/llvm/codegen_llvm.cc b/src/codegen/llvm/codegen_llvm.cc
index 2d6b4c1b7..30437bb91 100644
--- a/src/codegen/llvm/codegen_llvm.cc
+++ b/src/codegen/llvm/codegen_llvm.cc
@@ -1151,7 +1151,7 @@ void CodeGenLLVM::VisitStmt_(const AssertStmt* op) {
   // TODO(tqchen) move these pattern to a generic scope info visitor.
   if (const EQ* eq = op->condition.as<EQ>()) {
     const Mod* mod = eq->a.as<Mod>();
-    int64_t factor, offset;
+    int64_t factor = 0, offset = 0;
     if (mod && arith::GetConst(eq->b, &offset)) {
       const Variable *var = mod->a.as<Variable>();
       if (var && arith::GetConst(mod->b, &factor)) {
-- 
GitLab