taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.05k stars 2.26k forks source link

[MSVC] Taichi failed with error G030630B7: static assertion failed: Unexpected size #8520

Open NEIL-smtg opened 2 months ago

NEIL-smtg commented 2 months ago

Describe the bug We've been using MSVC to build Taichi, and we've recently encountered the following error:

error G030630B7: static_assert failed "Unexpected size"
static_assert(false, "Unexpected size");
^             ~~~~~

Our developer has suggested the compiler that was used needs to implement the Defect Report https://cplusplus.github.io/CWG/issues/2518.html (which has been implemented by MSVC and Clang).

To Reproduce:

  1. Open "x64 Native Tools Command Prompt for VS 2022"
  2. git clone https://github.com/taichi-dev/taichi.git
  3. cd /d C:\gitP\taichi-dev\taichi\bin
  4. copy "C:\gitP\taichi-dev\taichi\bin\clang\bin\clang++.exe" "C:\gitP\taichi-dev\taichi\bin\clang\bin\clang.exe"
  5. python -m pip install --upgrade pip
  6. set PATH=%APPDATA%\Python\Python311\Scripts;C:\gitP\taichi-dev\taichi\bin\llvm\bin;C:\gitP\taichi-dev\taichi\bin\clang\bin;%PATH%
  7. pip3 install --user gitpython
  8. pip3 install --user pybind11
  9. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64
  10. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DCMAKE_TOOLCHAIN_FILE=C:\gitP\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DTI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -Dgtest_force_shared_crt=TRUE -DPYTHON_EXECUTABLE=C:\Python311\python.exe .. 2>&1
  11. msbuild /m /p:Platform=x64 /p:Configuration=Release taichi.sln /t:Rebuild 2>&1

Expected result: Build successfully.

Log/Screenshots Build (1).log (search error G030630B7)

Operating system Windows server 2022 data center

StephanTLavavej commented 2 months ago

Note that this involves https://github.com/microsoft/STL/pull/4591 , a very recent change to MSVC's STL. To reproduce this, you'll either need to build and consume our open-source STL, or wait for VS 2022 17.11 Preview 2 to ship which will contain this change.

bobcao3 commented 1 week ago

It seems like fmtlib is also involved in that log. We are fixing some of these issues rn as we try to bump our dependencies, and static analysis (and static_assert) has been producing a lot of errors we didn't noticed before