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

junrushao 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 e3d031bc7c [CMake][MSVC] Disable permissive mode for MSVC builds 
(#16343)
e3d031bc7c is described below

commit e3d031bc7cef6f61c287b1f642c0c928612c018c
Author: Eric Lunderberg <[email protected]>
AuthorDate: Thu Jan 4 13:21:58 2024 -0600

    [CMake][MSVC] Disable permissive mode for MSVC builds (#16343)
    
    [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.
---
 CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a55a629bd..09c656f8cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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 "")
 

Reply via email to