Skip to content

Commit

Permalink
Update C++ standard to C++17 (#12337)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Krzysztof Parzyszek authored Aug 11, 2022
1 parent 7e14441 commit 99f5e92
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 25 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion apps/android_camera/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/android_deploy/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion apps/android_rpc/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/bundle_deploy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion apps/dso_plugin_module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion apps/howto_deploy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion apps/howto_deploy/tvm_runtime_pack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion apps/rocm_rpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion apps/tf_tvmdsoop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion conda/build-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ channels:
dependencies:
- conda-build
- git
- llvmdev ==10.0.0
- llvmdev >=11
- numpy
- pytest
- cython
Expand Down
6 changes: 4 additions & 2 deletions conda/recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ..
6 changes: 3 additions & 3 deletions conda/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ requirements:
- make # [not win]
host:
- zlib
- llvmdev ==10.0.0
- llvmdev >=11

outputs:
- name: {{ pkg_name }}-libs
Expand All @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion golang/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 99f5e92

Please sign in to comment.