Skip to content

Commit

Permalink
[CMake][MSVC] Disable permissive mode for MSVC builds (#16343)
Browse files Browse the repository at this point in the history
[CMake][MSVC] Use /permissive- flag for MSVC builds

The C++ standard requires two-phase name resolution for templates.  By
default, MSVC uses a non-standard name resolution, in which all names
are looked up when a template is instantiated.  This has caused
MSVC-specific compilation
errors, ([example](https://github.com/apache/tvm/actions/runs/7400684492/job/20134841480?pr=16183)),
which are quite difficult to debug.

This commit updates adds the `/permissive-` flag when building TVM
with MSVC, disabling the non-standard name resolution.
  • Loading branch information
Lunderberg authored Jan 4, 2024
1 parent ae7d9db commit e3d031b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
add_compile_options(/bigobj)

# Use standard-conforming two-phase name resolution for templates.
# This minimizes the differences between g++/clang builds on Linux,
# and MSVC builds on Windows.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")

# MSVC already errors on undefined symbols, no additional flag needed.
set(TVM_NO_UNDEFINED_SYMBOLS "")

Expand Down

0 comments on commit e3d031b

Please sign in to comment.