From 5b73145cb17e4e2ccfb4e0bca3067fa9655d48f5 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 4 Aug 2022 14:45:16 -0700 Subject: [PATCH 1/7] 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. --- CMakeLists.txt | 12 ++++++------ 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 +- golang/Makefile | 2 +- python/setup.py | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dc03ee0f40e..a4553e4230cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -503,13 +503,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 6ac3271f49ac..83b7b4417b9e 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 220c6af3bc7e..4a83907ff329 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 e3078906ff55..df560863f091 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 b533030c4b82..2d4d7c42feea 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 438d9db223a8..6b4575032d7d 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 6eba941f7c98..c8eca4a93e06 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 9741d58af434..a2f33314e1ea 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 a2e30c6b0933..0ee61a7e50e4 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 971ca4603314..00de002eb4ee 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 9be5da9d26de..9f123153839e 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/golang/Makefile b/golang/Makefile index 181ecdf368b8..76ac371b628d 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= -DTVM_USE_LIBBACKTRACE=0" +CGO_CXXFLAGS="-std=c++17 -DDMLC_USE_LOGGING_LIBRARY= -DTVM_USE_LIBBACKTRACE=0" CGO_CFLAGS="-I${TVM_BASE}" CGO_LDFLAGS="-ldl -lm" diff --git a/python/setup.py b/python/setup.py index a7ba115e0a76..a75888c83614 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="] + extra_compile_args = ["-std=c++17", "-DDMLC_USE_LOGGING_LIBRARY="] if os.name == "nt": library_dirs = ["tvm", "../build/Release", "../build"] libraries = ["tvm"] From 977a06f8fbb4bd1982cefb51d3dba91c7066bd90 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Mon, 8 Aug 2022 17:07:49 -0700 Subject: [PATCH 2/7] Clang 8.0+ also supports -faligned-new --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4553e4230cb..91a069824278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,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() From 5c05627838fed6158f85702f90582bcb365611c3 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 9 Aug 2022 06:05:59 -0700 Subject: [PATCH 3/7] Set minimum deployment macOS version to 10.13 and iOS version to 10.0 --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91a069824278..3bc4510aeaee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,17 @@ else(MSVC) endif() message(STATUS "Forbidding undefined symbols in shared library, using ${TVM_NO_UNDEFINED_SYMBOLS} on platform ${CMAKE_SYSTEM_NAME}") + # Set the macOS version to >= 10.13 and iOS version to >= 10.0. This is to + # enable libc++ functionality that was unavailable in older versions of the + # OS (shared_mutex in particular). + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_C_FLAGS "-mmacosx-version-min=10.13 ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-mmacosx-version-min=10.13 ${CMAKE_CXX_FLAGS}") + elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS") + set(CMAKE_C_FLAGS "-mios-version-min=10.0 ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-mios-version-min=10.0 ${CMAKE_CXX_FLAGS}") + endif() + # Detect if we're compiling for Hexagon. set(TEST_FOR_HEXAGON_CXX "#ifndef __hexagon__" From 5978beae5c6c1267e1a135e9fd36da9b96b48c2c Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 9 Aug 2022 07:52:46 -0700 Subject: [PATCH 4/7] Make make verbose --- conda/recipe/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipe/build.sh b/conda/recipe/build.sh index 242d6a28b3d3..0b4d6e7b647f 100755 --- a/conda/recipe/build.sh +++ b/conda/recipe/build.sh @@ -56,5 +56,5 @@ cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ ${GPU_OPT} ${TOOLCHAIN_OPT} \ ${SRC_DIR} -make -j${CPU_COUNT} +make -j${CPU_COUNT} VERBOSE=1 cd .. From a16fe86658503184e5807359123620440fdc169d Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 9 Aug 2022 08:31:54 -0700 Subject: [PATCH 5/7] Use CMAKE_OSX_DEPLOYMENT_TARGET to set minimum macOS version (10.12) --- conda/recipe/build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conda/recipe/build.sh b/conda/recipe/build.sh index 0b4d6e7b647f..bfae99f77944 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,7 +55,7 @@ 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} VERBOSE=1 From 7dccf1d6da21e680c555f2dd5951d685a3cde1a6 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 11 Aug 2022 11:04:48 -0700 Subject: [PATCH 6/7] 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. --- conda/build-environment.yaml | 2 +- conda/recipe/meta.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/build-environment.yaml b/conda/build-environment.yaml index 7c7831e25b1b..9581ddf1ea6b 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/meta.yaml b/conda/recipe/meta.yaml index ccdacdcc45d9..22a512493478 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] From f688d40757030e5771a9ff3730c3588b11dd8b17 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 11 Aug 2022 12:58:25 -0700 Subject: [PATCH 7/7] Revert "Set minimum deployment macOS version to 10.13 and iOS version to 10.0" This reverts commit 5c05627838fed6158f85702f90582bcb365611c3. This is no longer needed. --- CMakeLists.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bc4510aeaee..91a069824278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,17 +216,6 @@ else(MSVC) endif() message(STATUS "Forbidding undefined symbols in shared library, using ${TVM_NO_UNDEFINED_SYMBOLS} on platform ${CMAKE_SYSTEM_NAME}") - # Set the macOS version to >= 10.13 and iOS version to >= 10.0. This is to - # enable libc++ functionality that was unavailable in older versions of the - # OS (shared_mutex in particular). - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CMAKE_C_FLAGS "-mmacosx-version-min=10.13 ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-mmacosx-version-min=10.13 ${CMAKE_CXX_FLAGS}") - elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS") - set(CMAKE_C_FLAGS "-mios-version-min=10.0 ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-mios-version-min=10.0 ${CMAKE_CXX_FLAGS}") - endif() - # Detect if we're compiling for Hexagon. set(TEST_FOR_HEXAGON_CXX "#ifndef __hexagon__"