Skip to content

fix: isolate tvm-ffi from TVM's C++20 build standard - #20162

Closed
mvanhorn wants to merge 1 commit into
apache:mainfrom
mvanhorn:fix/20042-isolate-tvm-ffi-cxx-standard
Closed

fix: isolate tvm-ffi from TVM's C++20 build standard#20162
mvanhorn wants to merge 1 commit into
apache:mainfrom
mvanhorn:fix/20042-isolate-tvm-ffi-cxx-standard

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

TVM sets CMAKE_CXX_STANDARD to 20 globally, then adds the vendored tvm-ffi project, whose sources are intended to compile as C++17. Because CMake's cxx_std_17 feature is a minimum rather than an exact standard, the parent setting causes tvm-ffi sources to compile as C++20 and exposes a recursive std::optional constraint failure with the reporter's newer Clang/GCC standard-library combination. The reporter's attempted local standard isolation allowed compilation to progress through the original error, while the later LLVM link errors came from the separately configured ROCm LLVM toolchain. No prior or competing PR is recorded in the supplied issue bundle.

Testing

  • Configure a normal Ninja build and confirm compile commands for 3rdparty/tvm-ffi contain an explicit C++17 mode or no newer-standard flag, while TVM src/ commands retain C++20.
  • Configure with a compiler whose default language mode is already C++17 and confirm the validation accepts an omitted explicit C++17 flag for tvm-ffi without weakening the C++20 assertion for TVM.
  • Exercise the existing CI build path and confirm the original std::optional<tvm::ffi::Optional<VisitInterrupt>> compilation failure no longer occurs on a modern Clang using GCC 16 standard-library headers.
  • Deliberately allow the dependency to inherit a C++20 flag and confirm the build driver stops before compilation with a diagnostic that identifies the mismatched tvm-ffi compile command.

What changed

In CMakeLists.txt, save TVM's C++20 setting immediately before add_subdirectory(3rdparty/tvm-ffi), temporarily select C++17 while the dependency creates its targets, and restore the saved value immediately afterward so all subsequent TVM targets retain the project standard. Keep the change at the parent/dependency boundary rather than altering tvm-ffi headers or adding a source-level workaround for the reported template instantiation. Extend tests/scripts/task_build.py after CMake configuration to inspect the generated compile database and assert that C++ sources under 3rdparty/tvm-ffi are not compiled with a C++20 flag while representative TVM C++ sources still are.

Fixes #20042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] build CXX standard conflicts: tvm-ffi expects cxx_std_17 while tvm now upgraded to 20

2 participants