fix: isolate tvm-ffi from TVM's C++20 build standard - #20162
Closed
mvanhorn wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TVM sets
CMAKE_CXX_STANDARDto 20 globally, then adds the vendoredtvm-ffiproject, whose sources are intended to compile as C++17. Because CMake'scxx_std_17feature is a minimum rather than an exact standard, the parent setting causestvm-ffisources to compile as C++20 and exposes a recursivestd::optionalconstraint 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
3rdparty/tvm-fficontain an explicit C++17 mode or no newer-standard flag, while TVMsrc/commands retain C++20.tvm-ffiwithout weakening the C++20 assertion for TVM.std::optional<tvm::ffi::Optional<VisitInterrupt>>compilation failure no longer occurs on a modern Clang using GCC 16 standard-library headers.tvm-fficompile command.What changed
In
CMakeLists.txt, save TVM's C++20 setting immediately beforeadd_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 alteringtvm-ffiheaders or adding a source-level workaround for the reported template instantiation. Extendtests/scripts/task_build.pyafter CMake configuration to inspect the generated compile database and assert that C++ sources under3rdparty/tvm-ffiare not compiled with a C++20 flag while representative TVM C++ sources still are.Fixes #20042