[cfe-dev] Can't compile MLIR with clang on windows

Diana Picus via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 20 03:36:31 PDT 2021


Hi,

I'm trying to compile MLIR on Windows on Arm with a clang-cl.exe that I
compiled at commit 945df8bc4cf.

I'm running into an issue in mlir-tblgen\RewriterGen.cpp [1]. I'm attaching
the whole error dump, but here's the TL;DR version:

error: implicit instantiation of undefined template
'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>,
8> &>'
[...]
llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(303,37): note: in
instantiation of template class
'mlir::tblgen::FmtObject<std::tuple<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>,
8> &>>>' requested here
  auto nativeCodeCall = std::string(tgfmt(

I'm not sure I understand the issue correctly, but in any case here's my
interpretation:
There are 2 versions of tgfmt, a templated one with a parameter pack [2],
and a non-templated one that takes an ArrayRef<std::string> as a parameter.
I would expect a call with SmallVector<std::string, 8> to just use the
non-templated overload, but we never get to that part because we're
erroring out while trying to find a format adapter. I think SFINAE doesn't
kick in in this case, because the error is not in "an immediate context of
the function type". However, removing the build_format_adapter definition
that uses the missing_format_adapter [3] makes it work, because I guess in
that case the error is pushed into the immediate context (i.e. we error out
because we don't have a suitable build_format_adapter, not later on because
we don't have a missing_format_adapter).

Am I understanding this right? Is it reasonable to remove
missing_format_adapter in order to make build_format_adapter more
SFINAE-friendly? Or is there a more principled fix?

Thanks,
Diana

[1]
https://github.com/llvm/llvm-project/blob/951f362e2560fe1c9c05f487107fd9882d45d867/mlir/tools/mlir-tblgen/RewriterGen.cpp#L303
[2]
https://github.com/llvm/llvm-project/blob/5bc9cc1332aa042b68fb5efa9fb50eaaf2d54f79/mlir/include/mlir/TableGen/Format.h#L255
[3]
https://github.com/llvm/llvm-project/blob/d480f968ad8b56d3ee4a6b6df5532d485b0ad01e/llvm/include/llvm/Support/FormatVariadicDetails.h#L156
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210920/4c0d73df/attachment.html>
-------------- next part --------------
FAILED: tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/RewriterGen.cpp.obj
C:\Work\diana.picus\install-compiler-rt\bin\clang-cl.exe  /nologo -TP -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\mlir\tools\mlir-tblgen -IC:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen -Iinclude -IC:\Work\diana.picus\llvm-project\llvm\include -IC:\Work\diana.picus\llvm-project\mlir\include -Itools\mlir\include -fms-compatibility-version=19.14 /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /Brepro /bigobj /W4  -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation /Gw /MD /O2 /Ob2    /EHs-c- /GR- -UNDEBUG -std:c++14 /showIncludes /Fotools\mlir\tools\mlir-tblgen\CMakeFiles\mlir-tblgen.dir\RewriterGen.cpp.obj /Fdtools\mlir\tools\mlir-tblgen\CMakeFiles\mlir-tblgen.dir\ -c C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp
In file included from C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp:13:
In file included from C:\Work\diana.picus\llvm-project\mlir\include\mlir/Support/IndentedOstream.h:18:
In file included from C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/raw_ostream.h:16:
In file included from C:\Work\diana.picus\llvm-project\llvm\include\llvm/ADT/SmallVector.h:26:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\functional:12:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\tuple(189,9): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>'
    _Ty _Val;
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\tuple(730,23): note: in instantiation of template class 'std::_Tuple_val<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>>' requested here
    _Tuple_val<_This> _Myfirst; // the stored element
                      ^
C:\Work\diana.picus\llvm-project\mlir\include\mlir/TableGen/Format.h(181,9): note: in instantiation of template class 'std::tuple<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>>' requested here
  Tuple parameters;
        ^
C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(303,37): note: in instantiation of template class 'mlir::tblgen::FmtObject<std::tuple<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>>>' requested here
  auto nativeCodeCall = std::string(tgfmt(
                                    ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
In file included from C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp:13:
In file included from C:\Work\diana.picus\llvm-project\mlir\include\mlir/Support/IndentedOstream.h:18:
In file included from C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/raw_ostream.h:16:
In file included from C:\Work\diana.picus\llvm-project\llvm\include\llvm/ADT/SmallVector.h:26:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\functional:12:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\tuple(189,9): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>'
    _Ty _Val;
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\tuple(730,23): note: in instantiation of template class 'std::_Tuple_val<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>>' requested here
    _Tuple_val<_This> _Myfirst; // the stored element
                      ^
C:\Work\diana.picus\llvm-project\mlir\include\mlir/TableGen/Format.h(181,9): note: in instantiation of template class 'std::tuple<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>>' requested here
  Tuple parameters;
        ^
C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(987,24): note: in instantiation of template class 'mlir::tblgen::FmtObject<std::tuple<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>>>' requested here
  std::string symbol = tgfmt(fmt, &fmtCtx.addSubst("_loc", locToUse), attrs);
                       ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
In file included from C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp:15:
C:\Work\diana.picus\llvm-project\mlir\include\mlir/TableGen/Format.h(263,11): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>'
          llvm::detail::build_format_adapter(std::forward<Ts>(vals))...));
          ^
C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(303,37): note: in instantiation of function template specialization 'mlir::tblgen::tgfmt<llvm::SmallVector<std::basic_string<char>, 8> &>' requested here
  auto nativeCodeCall = std::string(tgfmt(
                                    ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(156,1): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>'
build_format_adapter(T &&) {
^
C:\Work\diana.picus\llvm-project\mlir\include\mlir/TableGen/Format.h(263,25): note: in instantiation of function template specialization 'llvm::detail::build_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>' requested here
          llvm::detail::build_format_adapter(std::forward<Ts>(vals))...));
                        ^
C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(303,37): note: in instantiation of function template specialization 'mlir::tblgen::tgfmt<llvm::SmallVector<std::basic_string<char>, 8> &>' requested here
  auto nativeCodeCall = std::string(tgfmt(
                                    ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(157,10): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>'
  return missing_format_adapter<T>();
         ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
In file included from C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp:15:
C:\Work\diana.picus\llvm-project\mlir\include\mlir/TableGen/Format.h(263,11): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>'
          llvm::detail::build_format_adapter(std::forward<Ts>(vals))...));
          ^
C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(987,24): note: in instantiation of function template specialization 'mlir::tblgen::tgfmt<llvm::SmallVector<std::basic_string<char>, 16> &>' requested here
  std::string symbol = tgfmt(fmt, &fmtCtx.addSubst("_loc", locToUse), attrs);
                       ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(156,1): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>'
build_format_adapter(T &&) {
^
C:\Work\diana.picus\llvm-project\mlir\include\mlir/TableGen/Format.h(263,25): note: in instantiation of function template specialization 'llvm::detail::build_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>' requested here
          llvm::detail::build_format_adapter(std::forward<Ts>(vals))...));
                        ^
C:\Work\diana.picus\llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(987,24): note: in instantiation of function template specialization 'mlir::tblgen::tgfmt<llvm::SmallVector<std::basic_string<char>, 16> &>' requested here
  std::string symbol = tgfmt(fmt, &fmtCtx.addSubst("_loc", locToUse), attrs);
                       ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(157,10): error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 16> &>'
  return missing_format_adapter<T>();
         ^
C:\Work\diana.picus\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(54,29): note: template is declared here
template <typename T> class missing_format_adapter;
                            ^
8 errors generated.


More information about the cfe-dev mailing list