TVM wont compile using llvm on windows

Hello all,
Hope you are having a great day.
This is a followup question to this one. basically I tried building the tvm using VS 2019, it built successfully but it seems it wont work unless it is built with llvm. (better update the installation guide imho).
For using LLVM, the prebuilt binaries wont work as they dont not come with llvm-config.exe. so one must built LLVM from source. I downloaded the latest LLVM source code ( LLVM 9.0.1 source code (.sig) ) and using the following command built it :

  1. Unzip and extract the source code (e.g. into \llvm-9.0.1.src.tar\llvm-9.0.1.src)
  2. cd into the root of the directory (i.e. \llvm-9.0.1.src )
  3. execute cmd or powershell in it and run :
       cmake .
  1. the Visual Studio project files will be generated, after than open LLVM.sln and choose Release and build the whole thing.
  2. navigate to Release folder there you have your bin folder which includes llvm-config.exe add this files path to the cmake.config like this :
    change
     set(USE_LLVM OFF)
    

to

      set(USE_LLVM D:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/bin/llvm-config.exe)
       

Note:
Now, llvm source code doesnt come with clang!. clang has a separate source code! Therefore, one needs to get clang as well, as with GCC tvm wont compile (explained here ) .

  1. Grab LLVM prebubilt binarys : * Windows 9.0.1 (64-bit) (.sig)
  2. install it and add it to all Users PATH.

You are now ready to start building tvm.

  1. navigate to the root of TVM. (i.e cd tvm)
  2. create a build directory : (i.e. mkdir build)
  3. copy the cmake config file into the build directory (i.e 'copy cmake.config build`)
  4. cd into the build directory, (i.e. cd build )
  5. if you do not have Ninja build system, download it (Ninja)and add it to your system PATH :
  6. Execute these commands :
cmake .. -G Ninja 
ninja

cmake will generate project files necessary for ninja to builld tvm. and then by executing ninja we will start the final building process.

However, after doing all of this, I’m facing with the following errors :

PS D:\Codes\tvm_testbed\tvm_llvm\build> cmake .. -G Ninja
-- The C compiler identification is Clang 9.0.1 with GNU-like command-line
-- The CXX compiler identification is Clang 9.0.1 with GNU-like command-line
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build in Debug mode
-- Build with RPC support...
-- Build with Graph runtime support...
-- Build VTA runtime with target: sim
-- Found OpenCL: C:/Windows/System32/OpenCL.dll
-- Build with OpenCL support
-- Use llvm-config=D:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/bin/llvm-config.exe
-- D:\Codes\tvm_testbed\tools\llvm-9.0.1.src.tar\llvm-9.0.1.src\Release\include
-- Found LLVM_INCLUDE_DIRS=D:\Codes\tvm_testbed\tools\llvm-9.0.1.src.tar\llvm-9.0.1.src\Release\include
-- Found LLVM_DEFINITIONS= -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Found TVM_LLVM_VERSION=90
-- Build with LLVM
-- Set TVM_LLVM_VERSION=90
-- Build with contrib.sort
-- Build with contrib.hybriddump
-- Performing Test SUPPORT_CXX11
-- Performing Test SUPPORT_CXX11 - Failed
-- Build with c++11
-- Build with thread support...
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Codes/tvm_testbed/tvm_llvm/build
PS D:\Codes\tvm_testbed\tvm_llvm\build> ninja
[1/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/nn/nn.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/nn/nn.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/nn/nn.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\nn\nn.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/nn/nn.cc.obj -c ../src/relay/op/nn/nn.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[2/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/nn/pooling.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/nn/pooling.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/nn/pooling.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\nn\pooling.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/nn/pooling.cc.obj -c ../src/relay/op/nn/pooling.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[3/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/nn/sparse.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/nn/sparse.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/nn/sparse.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\nn\sparse.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/nn/sparse.cc.obj -c ../src/relay/op/nn/sparse.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[4/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/nn/pad.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/nn/pad.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/nn/pad.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\nn\pad.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/nn/pad.cc.obj -c ../src/relay/op/nn/pad.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[5/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/tensor/transform.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/tensor/transform.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/tensor/transform.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\tensor\transform.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/tensor/transform.cc.obj -c ../src/relay/op/tensor/transform.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[6/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/nn/convolution.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/nn/convolution.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/nn/convolution.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\nn\convolution.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/nn/convolution.cc.obj -c ../src/relay/op/nn/convolution.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[7/315] Building CXX object CMakeFiles/vta_fsim.dir/vta/src/device_api.cc.obj
FAILED: CMakeFiles/vta_fsim.dir/vta/src/device_api.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DTA_TARGET=sim -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -DUSE_FSIM_TLPP -DVTA_COHERENT_ACCESSES=true -DVTA_COMPUTE_ADDR=0x43C02000 -DVTA_COMPUTE_BIAS_ADDR_OFFSET=40 -DVTA_COMPUTE_DONE_RD_OFFSET=24 -DVTA_COMPUTE_DONE_WR_OFFSET=16 -DVTA_COMPUTE_UOP_ADDR_OFFSET=32 -DVTA_FETCH_ADDR=0x43C00000 -DVTA_FETCH_INSN_ADDR_OFFSET=24 -DVTA_FETCH_INSN_COUNT_OFFSET=16 -DVTA_HW_VER=0.0.1 -DVTA_IP_REG_MAP_RANGE=0x1000 -DVTA_LOAD_ADDR=0x43C01000 -DVTA_LOAD_INP_ADDR_OFFSET=16 -DVTA_LOAD_WGT_ADDR_OFFSET=24 -DVTA_LOG_ACC_BUFF_SIZE=17 -DVTA_LOG_ACC_WIDTH=5 -DVTA_LOG_BATCH=0 -DVTA_LOG_BLOCK=4 -DVTA_LOG_BLOCK_IN=4 -DVTA_LOG_BLOCK_OUT=4 -DVTA_LOG_BUS_WIDTH=6 -DVTA_LOG_INP_BUFF_SIZE=15 -DVTA_LOG_INP_WIDTH=3 -DVTA_LOG_OUT_BUFF_SIZE=15 -DVTA_LOG_OUT_WIDTH=3 -DVTA_LOG_UOP_BUFF_SIZE=15 -DVTA_LOG_WGT_BUFF_SIZE=18 -DVTA_LOG_WGT_WIDTH=3 -DVTA_STORE_ADDR=0x43C03000 -DVTA_STORE_OUT_ADDR_OFFSET=16 -Dvta_fsim_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/vta_fsim.dir/vta/src/device_api.cc.obj -MF CMakeFiles\vta_fsim.dir\vta\src\device_api.cc.obj.d -o CMakeFiles/vta_fsim.dir/vta/src/device_api.cc.obj -c ../vta/src/device_api.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[8/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/nn/upsampling.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/nn/upsampling.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/nn/upsampling.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\nn\upsampling.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/nn/upsampling.cc.obj -c ../src/relay/op/nn/upsampling.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[9/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/tensor/binary.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/tensor/binary.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/tensor/binary.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\tensor\binary.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/tensor/binary.cc.obj -c ../src/relay/op/tensor/binary.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[10/315] Building CXX object CMakeFiles/tvm.dir/src/relay/op/tensor/reduce.cc.obj
FAILED: CMakeFiles/tvm.dir/src/relay/op/tensor/reduce.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -DDMLC_USE_FOPEN64=0 -DNDEBUG -DTVM_LLVM_VERSION=90 -DTVM_THREADPOOL_USE_OPENMP=0 -Dtvm_EXPORTS -I../include -I../3rdparty/dlpack/include -I../3rdparty/dmlc-core/include -I../3rdparty/rang/include -I../3rdparty/compiler-rt -I../3rdparty/picojson -I../vta/include -I"C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/include" -ID:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/include -I../topi/include -std=c++11 -O0 -g -Wall -fPIC  -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    -D_CRT_SECURE_NO_DEPRECATE  -D_CRT_SECURE_NO_WARNINGS  -D_CRT_NONSTDC_NO_DEPRECATE  -D_CRT_NONSTDC_NO_WARNINGS  -D_SCL_SECURE_NO_DEPRECATE  -D_SCL_SECURE_NO_WARNINGS  -DUNICODE  -D_UNICODE  -D__STDC_CONSTANT_MACROS  -D__STDC_FORMAT_MACROS  -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/tvm.dir/src/relay/op/tensor/reduce.cc.obj -MF CMakeFiles\tvm.dir\src\relay\op\tensor\reduce.cc.obj.d -o CMakeFiles/tvm.dir/src/relay/op/tensor/reduce.cc.obj -c ../src/relay/op/tensor/reduce.cc
CLANG_~1: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
ninja: build stopped: subcommand failed.

So My questions are:
What am I missing here or doing wrong here?
Is windows really supported?
Shouldnt the official installation guide, change at least for saying whether they need, clang/or llvm? as llvm is an infrusctructure, but clang as you know is a compiler.
Does TVM utilize LLVM infrastructure in some ways? or does it simply need the clang compiler ?
This could shed some light on the requirements and ease of debugging .

Your kind help is greatly appreciated Thank you all in advance

1 Like

OK, it seems clang by default supports only C++98 standard and C++11 is not enabled by default!
I also found out, the llvm github repo, also includes clang and building directly from llvm github repo, one can also build clang! simultaneously!
I’m going to give this a try again using the full llvm package (from its github repo) and see how things turn out. if God wills, everything will be ok! I’ll update this post when done!

You don not need to build with llvm-config, instead, build using set(USE_LLVM ON)

Thanks a lot. in that case, how do I make sure, clang is set to use C++11? will it work out of the box that way?

we will need to use the MSVC as compiler in normal cases(instead of clang)

I’m lost here! TVM explicitly says to compile it using llvm (that I guess means clang, as llvm is an infrastructure used for lots of things (compilers, etc)!). and when switching to clang, its by default c++98, unless we use -std=c++11 to enable c++11. I’m a bit confused as how to go about this honestly! any clarification is greatly appreciated

sorry, tvm links LLVM as a library dependency so tvm need to link against libLLVM. We do not have to use clang as a compiler though.

Any compiler on the native platform works. In the case of windows, you need to build LLVM from source via the official guide which gives you libLLVM, and then build with (USE_LLVM ON) in MSVC will automatically links the libLLVM to the tvm library.

1 Like

Thanks a gazillion times. it makes sense now. I’ll give it a try and update this thread figers crossed :slight_smile:

By the way when removing that llv-config.exe from the cmake config and setting set(LLVM ON) I get this message, should I continue or I need to make some changes?

     CMake Error at cmake/util/FindLLVM.cmake:36 (find_package):
     Could not find a package configuration file provided by "LLVM" with any of
     the following names:

        LLVMConfig.cmake
        llvm-config.cmake

the llvm, clang bins/libs are added to PATH though!

adding set(LLVM_DIR C:/Program Files/LLVM/bin/) to the config file or doing

cmake -DCMAKE_PREFIX_PATH=C:/Program Files/LLVM/bin/ -G "Visual Studio 16 2019" ..

does nothing! The only way it works is to setting set(USE_LLVM D:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/Release/bin/llvm-config.exe)

I’m building tvm using msv, having llvm found by the cmake. I’ll update how things went!

Update:
OK, it seems building with llvm-config.exe doesnt play nice on windows and creates a hell lot of issues!(ref) one issue is :

Severity	Code	Description	Project	File	Line	Suppression State
Error	C1083	Cannot open include file: 'llvm/ExecutionEngine/MCJIT.h': No such file or directory (compiling source file D:\Codes\tvm_testbed\tvm_llvm\src\target\llvm\codegen_amdgpu.cc)	tvm	D:\Codes\tvm_testbed\tvm_llvm\src\target\llvm\llvm_common.h	28	

Anyway in order to fix this, it seems instead, one should set the LLVM_DIR in the config.cmake like this :

set(USE_LLVM ON)
set(LLVM_DIR D:/Codes/tvm_testbed/tools/llvm-9.0.1.src.tar/llvm-9.0.1.src/lib/cmake/llvm/)

and then go for the building procedure (e.g. like this):

cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release" .

and then open the LLVM.sln file and build it ultimately!

Side note : when everything is built successfully, dont forgert to add the release directory to your PATH so that when installing the python wrapper you dont face with missing dlls, or dlls can’t be found errors!

1 Like

god. finnally your method work!