You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by kp...@apache.org on 2022/08/11 22:21:59 UTC

[tvm] branch main updated: Update C++ standard to C++17 (#12337)

This is an automated email from the ASF dual-hosted git repository.

kparzysz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 99f5e921a5 Update C++ standard to C++17 (#12337)
99f5e921a5 is described below

commit 99f5e921a51691529c48037dd20a44cf0edec147
Author: Krzysztof Parzyszek <kp...@quicinc.com>
AuthorDate: Thu Aug 11 17:21:53 2022 -0500

    Update C++ standard to C++17 (#12337)
    
    * Update C++ standard to C++17
    
    LLVM has switched to C++17 in its development branch. Follow suit to be
    able to compile LLVM headers.
    
    * Clang 8.0+ also supports -faligned-new
    
    * Make make verbose
    
    * Use CMAKE_OSX_DEPLOYMENT_TARGET to set minimum macOS version (10.12)
    
    * Update llvmdev version in conda to >= 11
    
    Something seems to be wrong with the llvmdev 10.0.0 packages, since the
    LLVM unit test fails on Windows. It works fine when LLVM 10 is compiled
    from sources.
---
 CMakeLists.txt                                      | 14 +++++++-------
 apps/android_camera/app/src/main/jni/Application.mk |  2 +-
 apps/android_deploy/app/src/main/jni/Application.mk |  2 +-
 apps/android_rpc/app/src/main/jni/Application.mk    |  2 +-
 apps/bundle_deploy/Makefile                         |  2 +-
 apps/dso_plugin_module/Makefile                     |  2 +-
 apps/extension/Makefile                             |  2 +-
 apps/howto_deploy/Makefile                          |  2 +-
 apps/howto_deploy/tvm_runtime_pack.cc               |  2 +-
 apps/rocm_rpc/Makefile                              |  2 +-
 apps/tf_tvmdsoop/CMakeLists.txt                     |  2 +-
 conda/build-environment.yaml                        |  2 +-
 conda/recipe/build.sh                               |  6 ++++--
 conda/recipe/meta.yaml                              |  6 +++---
 golang/Makefile                                     |  2 +-
 python/setup.py                                     |  2 +-
 16 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a321f64b3a..4bc4d1823f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -202,7 +202,7 @@ else(MSVC)
       set(TVM_VISIBILITY_FLAG "-fvisibility=hidden")
     endif(HIDE_PRIVATE_SYMBOLS)
   endif ()
-  if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
+  if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND
       CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
     set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}")
   endif()
@@ -505,13 +505,13 @@ include(cmake/modules/RustExt.cmake)
 
 include(CheckCXXCompilerFlag)
 if(NOT MSVC)
-  check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14)
-  set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
-  set(CMAKE_CUDA_STANDARD 14)
+  check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17)
+  set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_CUDA_STANDARD 17)
 else()
-  check_cxx_compiler_flag("/std:c++14" SUPPORT_CXX14)
-  set(CMAKE_CXX_FLAGS "/std:c++14 ${CMAKE_CXX_FLAGS}")
-  set(CMAKE_CUDA_STANDARD 14)
+  check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17)
+  set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_CUDA_STANDARD 17)
 endif()
 
 set(LIBINFO_FILE ${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc)
diff --git a/apps/android_camera/app/src/main/jni/Application.mk b/apps/android_camera/app/src/main/jni/Application.mk
index 6ac3271f49..83b7b4417b 100644
--- a/apps/android_camera/app/src/main/jni/Application.mk
+++ b/apps/android_camera/app/src/main/jni/Application.mk
@@ -31,7 +31,7 @@ include $(config)
 APP_ABI ?= all
 APP_STL := c++_shared
 
-APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
+APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
 ifeq ($(USE_OPENCL), 1)
     APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
 endif
diff --git a/apps/android_deploy/app/src/main/jni/Application.mk b/apps/android_deploy/app/src/main/jni/Application.mk
index 220c6af3bc..4a83907ff3 100644
--- a/apps/android_deploy/app/src/main/jni/Application.mk
+++ b/apps/android_deploy/app/src/main/jni/Application.mk
@@ -27,7 +27,7 @@ include $(config)
 
 APP_STL := c++_static
 
-APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
+APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
 ifeq ($(USE_OPENCL), 1)
 	APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
 endif
diff --git a/apps/android_rpc/app/src/main/jni/Application.mk b/apps/android_rpc/app/src/main/jni/Application.mk
index e3078906ff..df560863f0 100644
--- a/apps/android_rpc/app/src/main/jni/Application.mk
+++ b/apps/android_rpc/app/src/main/jni/Application.mk
@@ -31,7 +31,7 @@ include $(config)
 APP_ABI ?= armeabi-v7a arm64-v8a x86 x86_64 mips
 APP_STL := c++_shared
 
-APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
+APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
 ifeq ($(USE_OPENCL), 1)
     APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
 endif
diff --git a/apps/bundle_deploy/Makefile b/apps/bundle_deploy/Makefile
index b533030c4b..2d4d7c42fe 100644
--- a/apps/bundle_deploy/Makefile
+++ b/apps/bundle_deploy/Makefile
@@ -28,7 +28,7 @@ ENABLE_TVM_PLATFORM_ABORT_BACKTRACE ?= 1
 
 DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
 PKG_COMPILE_OPTS = -g -Wall -O2 -fPIC
-PKG_CXXFLAGS = ${PKG_COMPILE_OPTS} -std=c++14 \
+PKG_CXXFLAGS = ${PKG_COMPILE_OPTS} -std=c++17 \
 	-I${TVM_ROOT}/include \
 	-I${DMLC_CORE}/include \
 	-I${TVM_ROOT}/3rdparty/dlpack/include \
diff --git a/apps/dso_plugin_module/Makefile b/apps/dso_plugin_module/Makefile
index 438d9db223..6b4575032d 100644
--- a/apps/dso_plugin_module/Makefile
+++ b/apps/dso_plugin_module/Makefile
@@ -16,7 +16,7 @@
 # under the License.
 
 TVM_ROOT=$(shell cd ../..; pwd)
-PKG_CFLAGS = -std=c++14 -O2 -fPIC\
+PKG_CFLAGS = -std=c++17 -O2 -fPIC\
 	-I${TVM_ROOT}/include\
 	-I${TVM_ROOT}/3rdparty/dmlc-core/include\
 	-I${TVM_ROOT}/3rdparty/dlpack/include\
diff --git a/apps/extension/Makefile b/apps/extension/Makefile
index 6eba941f7c..c8eca4a93e 100644
--- a/apps/extension/Makefile
+++ b/apps/extension/Makefile
@@ -17,7 +17,7 @@
 
 # Minimum Makefile for the extension package
 TVM_ROOT=$(shell cd ../..; pwd)
-PKG_CFLAGS = -std=c++14 -O2 -fPIC\
+PKG_CFLAGS = -std=c++17 -O2 -fPIC\
 	-I${TVM_ROOT}/include\
 	-I${TVM_ROOT}/3rdparty/dmlc-core/include\
 	-I${TVM_ROOT}/3rdparty/dlpack/include\
diff --git a/apps/howto_deploy/Makefile b/apps/howto_deploy/Makefile
index 9741d58af4..a2f33314e1 100644
--- a/apps/howto_deploy/Makefile
+++ b/apps/howto_deploy/Makefile
@@ -19,7 +19,7 @@
 TVM_ROOT=$(shell cd ../..; pwd)
 DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
 
-PKG_CFLAGS = -std=c++14 -O2 -fPIC\
+PKG_CFLAGS = -std=c++17 -O2 -fPIC\
 	-I${TVM_ROOT}/include\
 	-I${DMLC_CORE}/include\
 	-I${TVM_ROOT}/3rdparty/dlpack/include\
diff --git a/apps/howto_deploy/tvm_runtime_pack.cc b/apps/howto_deploy/tvm_runtime_pack.cc
index a2e30c6b09..0ee61a7e50 100644
--- a/apps/howto_deploy/tvm_runtime_pack.cc
+++ b/apps/howto_deploy/tvm_runtime_pack.cc
@@ -24,7 +24,7 @@
  *   include in your project.
  *
  *  - Copy this file into your project which depends on tvm runtime.
- *  - Compile with -std=c++14
+ *  - Compile with -std=c++17
  *  - Add the following include path
  *     - /path/to/tvm/include/
  *     - /path/to/tvm/3rdparty/dmlc-core/include/
diff --git a/apps/rocm_rpc/Makefile b/apps/rocm_rpc/Makefile
index 971ca46033..00de002eb4 100644
--- a/apps/rocm_rpc/Makefile
+++ b/apps/rocm_rpc/Makefile
@@ -21,7 +21,7 @@ ROCM_PATH=/opt/rocm
 TVM_ROOT=$(shell cd ../..; pwd)
 DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
 
-PKG_CFLAGS = -std=c++14 -O2 -fPIC\
+PKG_CFLAGS = -std=c++17 -O2 -fPIC\
 	-I${TVM_ROOT}/include\
 	-I${DMLC_CORE}/include\
 	-I${TVM_ROOT}/3rdparty/dlpack/include\
diff --git a/apps/tf_tvmdsoop/CMakeLists.txt b/apps/tf_tvmdsoop/CMakeLists.txt
index 9be5da9d26..9f12315383 100644
--- a/apps/tf_tvmdsoop/CMakeLists.txt
+++ b/apps/tf_tvmdsoop/CMakeLists.txt
@@ -17,7 +17,7 @@
 cmake_minimum_required(VERSION 3.2)
 project(tf_tvmdsoop C CXX)
 
-set(TFTVM_COMPILE_FLAGS -std=c++14)
+set(TFTVM_COMPILE_FLAGS -std=c++17)
 set(BUILD_TVMDSOOP_ONLY ON)
 set(CMAKE_CURRENT_SOURCE_DIR ${TVM_ROOT})
 set(CMAKE_CURRENT_BINARY_DIR ${TVM_ROOT}/build)
diff --git a/conda/build-environment.yaml b/conda/build-environment.yaml
index 7c7831e25b..9581ddf1ea 100644
--- a/conda/build-environment.yaml
+++ b/conda/build-environment.yaml
@@ -27,7 +27,7 @@ channels:
 dependencies:
   - conda-build
   - git
-  - llvmdev ==10.0.0
+  - llvmdev >=11
   - numpy
   - pytest
   - cython
diff --git a/conda/recipe/build.sh b/conda/recipe/build.sh
index 242d6a28b3..bfae99f779 100755
--- a/conda/recipe/build.sh
+++ b/conda/recipe/build.sh
@@ -21,10 +21,12 @@ set -u
 
 GPU_OPT=""
 TOOLCHAIN_OPT=""
+MACOS_OPT=""
 
 if [ "$target_platform" == "osx-64" ]; then
     # macOS 64 bits
     GPU_OPT="-DUSE_METAL=ON"
+    MACOS_OPT="-DCMAKE_OSX_DEPLOYMENT_TARGET=10.12"
 elif [ "$target_platform" == "linux-64" ]; then
     TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=${RECIPE_DIR}/cross-linux.cmake"
 fi
@@ -53,8 +55,8 @@ cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" \
       -DUSE_LLVM=ON \
       -DINSTALL_DEV=ON \
       -DUSE_LIBBACKTRACE=AUTO \
-      ${GPU_OPT} ${TOOLCHAIN_OPT} \
+      ${GPU_OPT} ${TOOLCHAIN_OPT} ${MACOS_OPT} \
       ${SRC_DIR}
 
-make -j${CPU_COUNT}
+make -j${CPU_COUNT} VERBOSE=1
 cd ..
diff --git a/conda/recipe/meta.yaml b/conda/recipe/meta.yaml
index ccdacdcc45..22a5124934 100644
--- a/conda/recipe/meta.yaml
+++ b/conda/recipe/meta.yaml
@@ -44,7 +44,7 @@ requirements:
     - make # [not win]
   host:
     - zlib
-    - llvmdev ==10.0.0
+    - llvmdev >=11
 
 outputs:
   - name: {{ pkg_name }}-libs
@@ -59,11 +59,11 @@ outputs:
         - make # [not win]
       host:
         - zlib
-        - llvmdev ==10.0.0
+        - llvmdev >=11
         - {{ pin_compatible('cudatoolkit', lower_bound=cuda_version, max_pin='x.x') }}  # [cuda]
         - cudnn >=7.6.0  # [cuda]
       run:
-        - llvmdev ==10.0.0
+        - llvmdev >=11
         - {{ pin_compatible('cudatoolkit', lower_bound=cuda_version, max_pin='x.x') }}  # [cuda]
         - cudnn >=7.6.0  # [cuda]
 
diff --git a/golang/Makefile b/golang/Makefile
index 181ecdf368..76ac371b62 100644
--- a/golang/Makefile
+++ b/golang/Makefile
@@ -25,7 +25,7 @@ NATIVE_SRC = tvm_runtime_pack.cc
 GOPATH=$(CURDIR)/gopath
 GOPATHDIR=${GOPATH}/src/${TARGET}/
 CGO_CPPFLAGS="-I. -I${TVM_BASE}/ -I${TVM_BASE}/3rdparty/dmlc-core/include -I${TVM_BASE}/include -I${TVM_BASE}/3rdparty/dlpack/include/"
-CGO_CXXFLAGS="-std=c++14 -DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h> -DTVM_USE_LIBBACKTRACE=0"
+CGO_CXXFLAGS="-std=c++17 -DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h> -DTVM_USE_LIBBACKTRACE=0"
 CGO_CFLAGS="-I${TVM_BASE}"
 CGO_LDFLAGS="-ldl -lm"
 
diff --git a/python/setup.py b/python/setup.py
index a7ba115e0a..a75888c836 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -118,7 +118,7 @@ def config_cython():
             subdir = "_cy2"
         ret = []
         path = "tvm/_ffi/_cython"
-        extra_compile_args = ["-std=c++14", "-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>"]
+        extra_compile_args = ["-std=c++17", "-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>"]
         if os.name == "nt":
             library_dirs = ["tvm", "../build/Release", "../build"]
             libraries = ["tvm"]