This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add forgotten directory Support to unittests cmake
ClosedPublic

Authored by arjunp on Dec 20 2021, 3:56 AM.

Details

Summary

The Support directory was removed from the unittests cmake when the directory
was removed in 204c3b551626a925dfdc3822a6f240bdc8ef5d3a. Subsequent commits
added the directory back but seem to have missed adding it back to the cmake.

This patch also removes MLIRSupportIndentedStream from the list of linked
libraries to avoid an ODR violation (it's already part of MLIRSupport which
is also being linked here). Otherwise ASAN complains:

=================================================================
==102592==ERROR: AddressSanitizer: odr-violation (0x7fbdf214eee0):
  [1] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
  [2] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
These globals were registered at these points:
  [1]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf214a61b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupportIndentedOstream.so.14git+0x661b)

  [2]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf2061c4b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupport.so.14git+0x11bc4b)

==102592==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY AddressSanitizer: odr-violation: global 'vtable for mlir::raw_indented_ostream' at /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
==102592==ABORTING

Also fixing a build issue with DebugAction::classof under Windows.

Diff Detail

Event Timeline

arjunp created this revision.Dec 20 2021, 3:56 AM
arjunp requested review of this revision.Dec 20 2021, 3:56 AM
arjunp edited the summary of this revision. (Show Details)Dec 20 2021, 3:57 AM
jpienaar accepted this revision.Dec 20 2021, 8:00 AM

Thanks (I'm actually surprised indented ostream is included in support, I seem to recall creating separate target so that one need not include ostream deps unless needed, but that changed in https://github.com/llvm/llvm-project/commit/7f163931b9421c61fe1859fd8b2d97e7f5a39c73 )

This revision is now accepted and ready to land.Dec 20 2021, 8:00 AM

@jpienaar The windows build failure seems to be somehow related, but I don't immediately see why. Do you know why this happens?

[3209/4391] Building CXX object tools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\DebugActionTest.cpp.obj
FAILED: tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.obj
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=1 -DMLIR_INCLUDE_TESTS -DMLIR_ROCM_CONVERSIONS_ENABLED=1 -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\unittests\Support -IC:\ws\w9\llvm-project\premerge-checks\mlir\unittests\Support -Iinclude -IC:\ws\w9\llvm-project\premerge-checks\llvm\include -IC:\ws\w9\llvm-project\premerge-checks\mlir\include -Itools\mlir\include -IC:\ws\w9\llvm-project\premerge-checks\llvm\utils\unittest\googletest\include -IC:\ws\w9\llvm-project\premerge-checks\llvm\utils\unittest\googlemock\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2  /EHs-c- /GR- -UNDEBUG -std:c++14 /showIncludes /Fotools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\DebugActionTest.cpp.obj /Fdtools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\ /FS -c C:\ws\w9\llvm-project\premerge-checks\mlir\unittests\Support\DebugActionTest.cpp
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2275: 'mlir::DebugAction<>::Handler': illegal use of this type as an expression
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): note: see declaration of 'mlir::DebugAction<>::Handler'
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(207): note: while compiling class template member function 'bool mlir::DebugAction<>::Handler::classof(const mlir::DebugActionManager::HandlerBase *)'
C:\ws\w9\llvm-project\premerge-checks\llvm\include\llvm/Support/Casting.h(58): note: see reference to function template instantiation 'bool mlir::DebugAction<>::Handler::classof(const mlir::DebugActionManager::HandlerBase *)' being compiled
C:\ws\w9\llvm-project\premerge-checks\mlir\unittests\Support\DebugActionTest.cpp(72): note: see reference to class template instantiation 'mlir::DebugAction<>::Handler' being compiled
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2672: 'mlir::TypeID::get': no matching overloaded function found
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2974: 'mlir::TypeID::get': invalid template argument for 'Trait', type expected
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/TypeID.h(74): note: see declaration of 'mlir::TypeID::get'
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2974: 'mlir::TypeID::get': invalid template argument for 'T', type expected
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/TypeID.h(72): note: see declaration of 'mlir::TypeID::get'
[3210/4391] Building CXX object tools\mlir\lib\IR\CMakeFiles\obj.MLIRIR.dir\BuiltinAttributes.cpp.obj
[3211/4391] Building CXX object tools\mlir\lib\IR\CMakeFiles\obj.MLIRIR.dir\Builders.cpp.obj
[3212/4391] Building CXX object tools\mlir\lib\IR\CMakeFiles\obj.MLIRIR.dir\Dialect.cpp.obj
[3213/4391] Building CXX object tools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\MathExtrasTest.cpp.obj
[3214/4391] Building CXX object tools\mlir\lib\IR\CMakeFiles\obj.MLIRIR.dir\AsmPrinter.cpp.obj
[3215/4391] Building CXX object tools\mlir\lib\IR\CMakeFiles\obj.MLIRIR.dir\BuiltinTypes.cpp.obj
[3216/4391] Building CXX object tools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\DebugCounterTest.cpp.obj
FAILED: tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.obj
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=1 -DMLIR_INCLUDE_TESTS -DMLIR_ROCM_CONVERSIONS_ENABLED=1 -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\unittests\Support -IC:\ws\w9\llvm-project\premerge-checks\mlir\unittests\Support -Iinclude -IC:\ws\w9\llvm-project\premerge-checks\llvm\include -IC:\ws\w9\llvm-project\premerge-checks\mlir\include -Itools\mlir\include -IC:\ws\w9\llvm-project\premerge-checks\llvm\utils\unittest\googletest\include -IC:\ws\w9\llvm-project\premerge-checks\llvm\utils\unittest\googlemock\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2  /EHs-c- /GR- -UNDEBUG -std:c++14 /showIncludes /Fotools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\DebugCounterTest.cpp.obj /Fdtools\mlir\unittests\Support\CMakeFiles\MLIRSupportTests.dir\ /FS -c C:\ws\w9\llvm-project\premerge-checks\mlir\unittests\Support\DebugCounterTest.cpp
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2275: 'mlir::DebugAction<>::Handler': illegal use of this type as an expression
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): note: see declaration of 'mlir::DebugAction<>::Handler'
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(207): note: while compiling class template member function 'bool mlir::DebugAction<>::Handler::classof(const mlir::DebugActionManager::HandlerBase *)'
C:\ws\w9\llvm-project\premerge-checks\llvm\include\llvm/Support/Casting.h(58): note: see reference to function template instantiation 'bool mlir::DebugAction<>::Handler::classof(const mlir::DebugActionManager::HandlerBase *)' being compiled
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(117): note: see reference to class template instantiation 'mlir::DebugAction<>::Handler' being compiled
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(153): note: see reference to function template instantiation 'mlir::FailureOr<bool> mlir::DebugActionManager::shouldExecute::<lambda_4e18c69d5c62edaf33e00a22762266d6>::operator ()<To,>(To *) const' being compiled
        with
        [
            To=mlir::DebugAction<>::Handler
        ]
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(121): note: see reference to function template instantiation 'mlir::FailureOr<bool> mlir::DebugActionManager::dispatchToHandler<ActionType,bool,mlir::DebugActionManager::shouldExecute::<lambda_4e18c69d5c62edaf33e00a22762266d6>&,>(HandlerCallbackT)' being compiled
        with
        [
            ActionType=`anonymous-namespace'::CounterAction,
            HandlerCallbackT=mlir::DebugActionManager::shouldExecute::<lambda_4e18c69d5c62edaf33e00a22762266d6> &
        ]
C:\ws\w9\llvm-project\premerge-checks\mlir\unittests\Support\DebugCounterTest.cpp(33): note: see reference to function template instantiation 'bool mlir::DebugActionManager::shouldExecute<`anonymous-namespace'::CounterAction,>(void)' being compiled
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2672: 'mlir::TypeID::get': no matching overloaded function found
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2974: 'mlir::TypeID::get': invalid template argument for 'Trait', type expected
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/TypeID.h(74): note: see declaration of 'mlir::TypeID::get'
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/DebugAction.h(209): error C2974: 'mlir::TypeID::get': invalid template argument for 'T', type expected
C:\ws\w9\llvm-project\premerge-checks\mlir\include\mlir/Support/TypeID.h(72): note: see declaration of 'mlir::TypeID::get'

Is this an actual bug leading to test failure under Windows?

Since the directory wasn't built, this is just exposing a unit-test that probably never compiled with Windows.

Okay, I will refrain from landing until the windows build is fixed. Maybe @rriddle might have a better idea about this issue?

Can you try to replace line 209 with just TypeID::get<Handler>(); in include/mlir/Support/DebugAction.h ?

arjunp updated this revision to Diff 396205.Dec 25 2021, 12:20 PM

Trying Mehdi's suggestion.

This revision was automatically updated to reflect the committed changes.
arjunp added a comment.EditedDec 26 2021, 8:05 AM

I'm not really sure how a compiler-rt test could fail with this change, but this was the only change in the blame list so I reverted. Does compiler-rt depend on MLIR? How should we proceed? @mehdi_amini @jpienaar

I'm not really sure how a compiler-rt test could fail with this change, but this was the only change in the blame list so I reverted. Does compiler-rt depend on MLIR? How should we proceed? @mehdi_amini @jpienaar

Do you have a link to the bot that failed?

It is likely a fluke by the way: I tend to ignore these bots that are flaky.

An easy thing is to go back to the builder page: https://lab.llvm.org/buildbot/#/builders/197 and see that subsequent builds in between your commit and the revert were green, which confirms clearly that it was a flaky test.

Oh, I see. Thanks for the tip, I'm re-landing this.

arjunp edited the summary of this revision. (Show Details)Dec 27 2021, 1:06 AM
peixin added a subscriber: peixin.Feb 19 2022, 12:55 AM

I got an error when running ninja check-mlir after this commit. When reverting this patch in current main branch (commit 357b18e2821c7be7fb0ae6cbde3f8cade8195d93), it works ok.
Build commands:
$ cmake -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../install -DLLVM_TARGETS_TO_BUILD="AArch64" -DLLVM_ENABLE_PROJECTS="clang;flang;mlir;openmp" -DCMAKE_CXX_STANDARD=17 ../llvm-project/llvm
$ ninja -j
$ ninja check-mlir
[4/19] Building CXX object tools/mlir/unittests...iles/MLIRSupportTests.dir/DebugActionTest.cpp.o
FAILED: tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o
FAILED: tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o
/.../release-9.3.0/bin/g++ -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_INCLUDE_TESTS -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/mlir/unittests/Support -I/.../llvm-project/mlir/unittests/Support -Iinclude -I/.../llvm-project/llvm/include -I/.../llvm-project/mlir/include -Itools/mlir/include -I/.../llvm-project/llvm/utils/unittest/googletest/include -I/.../llvm-project/llvm/utils/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -g -Wno-variadic-macros -fno-exceptions -fno-rtti -Wno-suggest-override -std=c++17 -MD -MT tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o -MF tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o.d -o tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o -c /.../llvm-project/mlir/unittests/Support/DebugActionTest.cpp
...
/.../llvm-project/mlir/include/mlir/Support/DebugAction.h:196:49: error: call of overloaded ‘get()’ is ambiguous

196 |     Handler() : HandlerBase(TypeID::get<Handler>()) {}
    |                             ~~~~~~~~~~~~~~~~~~~~^~

/.../llvm-project/mlir/include/mlir/Support/DebugAction.h:208:61: error: call of overloaded ‘get()’ is ambiguous

208 |       return handler->getHandlerID() == TypeID::get<Handler>();
    |                                         ~~~~~~~~~~~~~~~~~~~~^~

...
$ arch
aarch64
$ ninja --version
1.10.1
$ cmake --version
cmake version 3.20.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

I got an error when running ninja check-mlir after this commit.

This is a known issue with building in C++17 mode and GCC: https://github.com/llvm/llvm-project/issues/53447