tensorflow / mlir

"Multi-Level Intermediate Representation" Compiler Infrastructure
1.74k stars 260 forks source link

Build failure - re. TableGen / MLIRContext #114

Closed bondhugula closed 5 years ago

bondhugula commented 5 years ago

The current master tip fails to build with these errors: HEAD: c03072b1e5648fd21a3055a9ebd6d21fc3ed403c (cmake conf same as in README

[257/347] Building CXX object projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o
In file included from /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:24:
In file included from /home/uday/llvm-project/llvm/utils/unittest/googlemock/include/gmock/gmock.h:58:
In file included from /home/uday/llvm-project/llvm/utils/unittest/googlemock/include/gmock/gmock-actions.h:48:
In file included from /home/uday/llvm-project/llvm/utils/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:49:
/home/uday/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1392:11: warning: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Wsign-compare]
  if (lhs == rhs) {
      ~~~ ^  ~~~
/home/uday/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1421:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned long, int>' requested here
    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
           ^
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:63:3: note: in instantiation of function template specialization 'testing::internal::EqHelper<false>::Compare<unsigned long, int>' requested here
  ASSERT_EQ(expectedValues.size(), 3);
  ^
/home/uday/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1956:32: note: expanded from macro 'ASSERT_EQ'
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                               ^
/home/uday/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1939:63: note: expanded from macro 'GTEST_ASSERT_EQ'
                      EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
                                                              ^
1 warning generated.
[266/347] Linking CXX executable projects/mlir/unittests/TableGen/MLIRTableGenTests
FAILED: projects/mlir/unittests/TableGen/MLIRTableGenTests 
: && /usr/lib64/ccache/clang++  -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++14 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -g  -Wl,-allow-shlib-undefined projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/EnumsGenTest.cpp.o projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/FormatTest.cpp.o  -o projects/mlir/unittests/TableGen/MLIRTableGenTests  lib/libLLVMSupport.a -lpthread lib/libgtest_main.a lib/libgtest.a -lpthread lib/libLLVMMLIRTableGen.a -lpthread lib/libLLVMTableGen.a lib/libLLVMSupport.a -lz -lrt -ldl -ltinfo -lpthread -lm lib/libLLVMDemangle.a && :
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::test::TestStruct::get(mlir::IntegerAttr, mlir::FloatAttr, mlir::ElementsAttr, mlir::MLIRContext*)':
/home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:18: undefined reference to `mlir::Identifier::get(llvm::StringRef, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:22: undefined reference to `mlir::Identifier::get(llvm::StringRef, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:26: undefined reference to `mlir::Identifier::get(llvm::StringRef, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:29: undefined reference to `mlir::DictionaryAttr::get(llvm::ArrayRef<std::pair<mlir::Identifier, mlir::Attribute> >, mlir::MLIRContext*)'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::test::TestStruct::classof(mlir::Attribute)':
/home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:37: undefined reference to `mlir::DictionaryAttr::size() const'
/usr/bin/ld: /home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:40: undefined reference to `mlir::DictionaryAttr::get(llvm::StringRef) const'
/usr/bin/ld: /home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:44: undefined reference to `mlir::DictionaryAttr::get(llvm::StringRef) const'
/usr/bin/ld: /home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:48: undefined reference to `mlir::DictionaryAttr::get(llvm::StringRef) const'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::test::TestStruct::sample_integer() const':
/home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:57: undefined reference to `mlir::DictionaryAttr::get(llvm::StringRef) const'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::test::TestStruct::sample_float() const':
/home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:65: undefined reference to `mlir::DictionaryAttr::get(llvm::StringRef) const'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o:/home/uday/llvm-project/build/projects/mlir/unittests/TableGen/StructAttrGenTest.cpp.inc:73: more undefined references to `mlir::DictionaryAttr::get(llvm::StringRef) const' follow
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_ClassofTrue_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:52: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:55: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::getTestStruct(mlir::MLIRContext*)':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:36: undefined reference to `mlir::IntegerType::get(unsigned int, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:37: undefined reference to `mlir::IntegerAttr::get(mlir::Type, long)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:40: undefined reference to `mlir::FloatAttr::get(mlir::Type, double)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:42: undefined reference to `mlir::RankedTensorType::get(llvm::ArrayRef<long>, mlir::Type)'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_ClassofExtraFalse_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:60: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:62: undefined reference to `mlir::DictionaryAttr::getValue() const'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:70: undefined reference to `mlir::Identifier::get(llvm::StringRef, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:75: undefined reference to `mlir::DictionaryAttr::get(llvm::ArrayRef<std::pair<mlir::Identifier, mlir::Attribute> >, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:77: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_ClassofBadNameFalse_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:82: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:84: undefined reference to `mlir::DictionaryAttr::getValue() const'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:92: undefined reference to `mlir::Identifier::get(llvm::StringRef, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:96: undefined reference to `mlir::DictionaryAttr::get(llvm::ArrayRef<std::pair<mlir::Identifier, mlir::Attribute> >, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:98: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_ClassofMissingFalse_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:103: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:105: undefined reference to `mlir::DictionaryAttr::getValue() const'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:113: undefined reference to `mlir::DictionaryAttr::get(llvm::ArrayRef<std::pair<mlir::Identifier, mlir::Attribute> >, mlir::MLIRContext*)'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:115: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_GetFloat_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:119: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:122: undefined reference to `mlir::FloatAttr::getValueAsDouble() const'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:123: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_GetInteger_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:127: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:130: undefined reference to `mlir::IntegerAttr::getInt() const'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:131: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::StructsGenTest_GetElements_Test::TestBody()':
/home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:135: undefined reference to `mlir::MLIRContext::MLIRContext()'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:141: undefined reference to `mlir::DenseElementsAttr::getIntValues() const'
/usr/bin/ld: /home/uday/llvm-project/llvm/projects/mlir/unittests/TableGen/StructsGenTest.cpp:144: undefined reference to `mlir::MLIRContext::~MLIRContext()'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `llvm::detail::result_pair<llvm::iterator_range<mlir::DenseElementsAttr::IntElementIterator> >::value() const':
/home/uday/llvm-project/llvm/include/llvm/ADT/STLExtras.h:1443: undefined reference to `mlir::DenseElementsAttr::IntElementIterator::operator*() const'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::FloatType::getF16(mlir::MLIRContext*)':
/home/uday/llvm-project/llvm/projects/mlir/include/mlir/IR/StandardTypes.h:130: undefined reference to `mlir::FloatType::get(mlir::StandardTypes::Kind, mlir::MLIRContext*)'
/usr/bin/ld: projects/mlir/unittests/TableGen/CMakeFiles/MLIRTableGenTests.dir/StructsGenTest.cpp.o: in function `mlir::DenseElementsAttr mlir::DenseElementsAttr::get<int, void>(mlir::ShapedType const&, llvm::ArrayRef<int>)':
/home/uday/llvm-project/llvm/projects/mlir/include/mlir/IR/Attributes.h:586: undefined reference to `mlir::DenseElementsAttr::getRawIntOrFloat(mlir::ShapedType, llvm::ArrayRef<char>, long, bool)'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
[279/347] Building CXX object projects/mlir/test/lib/TestDialect/CMakeFiles/MLIRTestDialect.dir/TestPatterns.cpp.o
ninja: build stopped: subcommand failed.
bondhugula commented 5 years ago

A clean build with GCC fails early with this:

      |            ~~~~~~~~~^~~~~~~~~~
/home/uday/llvm-project/llvm/lib/Support/YAMLTraits.cpp:417:21: note: remove ‘std::move’ call
[122/1545] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Path.cpp.o
/home/uday/llvm-project/llvm/lib/Support/Path.cpp: In static member function ‘static llvm::Expected<llvm::sys::fs::TempFile> llvm::sys::fs::TempFile::create(const llvm::Twine&, unsigned int)’:
/home/uday/llvm-project/llvm/lib/Support/Path.cpp:1243:19: warning: redundant move in return statement [-Wredundant-move]
 1243 |   return std::move(Ret);
      |          ~~~~~~~~~^~~~~
/home/uday/llvm-project/llvm/lib/Support/Path.cpp:1243:19: note: remove ‘std::move’ call
[128/1545] Building C object lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o 
/usr/lib64/ccache/cc -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/home/uday/llvm-project/llvm/lib/Support -I/usr/include/libxml2 -Iinclude -I/home/uday/llvm-project/llvm/include -fPIC -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-comment -fdiagnostics-color -g -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o   -c /home/uday/llvm-project/llvm/lib/Support/regcomp.c
In file included from /home/uday/llvm-project/llvm/lib/Support/regcomp.c:51:
/home/uday/llvm-project/llvm/include/llvm/Support/Compiler.h:152:30: error: missing ')' after "__has_attribute"
  152 | #if __has_cpp_attribute(clang::reinitializes)
      |                              ^
/home/uday/llvm-project/llvm/include/llvm/Support/Compiler.h:152:31: error:  ':' without preceding '?'
  152 | #if __has_cpp_attribute(clang::reinitializes)
      |                               ^
/home/uday/llvm-project/llvm/include/llvm/Support/Compiler.h:255:30: error: missing ')' after "__has_attribute"
  255 | #elif __has_cpp_attribute(gnu::fallthrough)
      |                              ^
/home/uday/llvm-project/llvm/include/llvm/Support/Compiler.h:255:31: error:  ':' without preceding '?'
  255 | #elif __has_cpp_attribute(gnu::fallthrough)
      |                               ^
/home/uday/llvm-project/llvm/include/llvm/Support/Compiler.h:267:30: error: missing ')' after "__has_attribute"
  267 | #if __has_cpp_attribute(clang::require_constant_initialization)
      |                              ^
/home/uday/llvm-project/llvm/include/llvm/Support/Compiler.h:267:31: error:  ':' without preceding '?'
  267 | #if __has_cpp_attribute(clang::require_constant_initialization)
      |                               ^
[135/1545] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/JSONBackend.cpp.o
/home/uday/llvm-project/llvm/lib/TableGen/JSONBackend.cpp: In member function ‘llvm::json::Value {anonymous}::JSONEmitter::translateInit(const llvm::Init&)’:

It appears to go further with clang, but fails with the messages in the original post.

freedomtan commented 5 years ago

Add MLIRIR to dependencies should work

diff --git a/unittests/TableGen/CMakeLists.txt b/unittests/TableGen/CMakeLists.txt
index c7ca252a..3c58db38 100644
--- a/unittests/TableGen/CMakeLists.txt
+++ b/unittests/TableGen/CMakeLists.txt
@@ -18,4 +18,4 @@ add_dependencies(MLIRTableGenTests MLIRTableGenEnumsIncGen)
 add_dependencies(MLIRTableGenTests MLIRTableGenStructAttrIncGen)

 target_link_libraries(MLIRTableGenTests
-  PRIVATE LLVMMLIRTableGen)
+  PRIVATE LLVMMLIRTableGen MLIRIR)
bondhugula commented 5 years ago

The errors with GCC were LLVM related and are gone with an update to its tip. But the MLIRContext / TableGen errors are due to a missing dep as mentioned by @freedomtan

antiagainst commented 5 years ago

Thanks for the repot and the fix, @bondhugula and @freedomtan! https://github.com/tensorflow/mlir/commit/3776ee295d7d1b3e848a3181e1ab8b0082edd4ec should have fixed this. :)