Build failed for CIRCT project

Hi all,
I am new to MLIR and CIRCT. I built MLIR successfully. However I run into this error when build circt.
[9/229] Building CXX object lib/Dialec…CTHandshake.dir/HandshakeDialect.cpp.o
FAILED: lib/Dialect/Handshake/CMakeFiles/obj.CIRCTHandshake.dir/HandshakeDialect.cpp.o
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I…/llvm/llvm/include -I…/llvm/build/include -I…/llvm/mlir/include -I…/llvm/build/tools/mlir/include -I…/include -Iinclude -fno-exceptions -fno-rtti -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wmisleading-indentation -fdiagnostics-color -g -fno-exceptions -fno-rtti -std=gnu++1z -MD -MT lib/Dialect/Handshake/CMakeFiles/obj.CIRCTHandshake.dir/HandshakeDialect.cpp.o -MF lib/Dialect/Handshake/CMakeFiles/obj.CIRCTHandshake.dir/HandshakeDialect.cpp.o.d -o lib/Dialect/Handshake/CMakeFiles/obj.CIRCTHandshake.dir/HandshakeDialect.cpp.o -c …/lib/Dialect/Handshake/HandshakeDialect.cpp
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
[14/229] Building CXX object lib/Conve…ticLogic.dir/AffineToStaticLogic.cpp.o
FAILED: lib/Conversion/AffineToStaticLogic/CMakeFiles/obj.CIRCTAffineToStaticLogic.dir/AffineToStaticLogic.cpp.o
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I…/llvm/llvm/include -I…/llvm/build/include -I…/llvm/mlir/include -I…/llvm/build/tools/mlir/include -I…/include -Iinclude -fno-exceptions -fno-rtti -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wmisleading-indentation -fdiagnostics-color -g -fno-exceptions -fno-rtti -std=gnu++1z -MD -MT lib/Conversion/AffineToStaticLogic/CMakeFiles/obj.CIRCTAffineToStaticLogic.dir/AffineToStaticLogic.cpp.o -MF lib/Conversion/AffineToStaticLogic/CMakeFiles/obj.CIRCTAffineToStaticLogic.dir/AffineToStaticLogic.cpp.o.d -o lib/Conversion/AffineToStaticLogic/CMakeFiles/obj.CIRCTAffineToStaticLogic.dir/AffineToStaticLogic.cpp.o -c …/lib/Conversion/AffineToStaticLogic/AffineToStaticLogic.cpp
In file included from …/lib/Conversion/AffineToStaticLogic/AffineToStaticLogic.cpp:32:0:
…/llvm/mlir/include/mlir/Transforms/DialectConversion.h: In instantiation of ‘mlir::ConversionTarget::addDynamicallyLegalOp(Callable&&)::<lambda(mlir::Operation*)> [with OpT = mlir::scf::IfOp; Callable = bool (&)(mlir::scf::IfOp)]’:
…/llvm/mlir/include/mlir/Transforms/DialectConversion.h:727:37: required from ‘struct mlir::ConversionTarget::addDynamicallyLegalOp(Callable&&) [with OpT = mlir::scf::IfOp; Callable = bool (&)(mlir::scf::IfOp); typename std::enable_if<(! typename llvm::detail::detector<void, llvm::detail::is_invocable, Callable, mlir::Operation*>::value_t:: value)>::type = void]::<lambda(class mlir::Operation*)>’
…/llvm/mlir/include/mlir/Transforms/DialectConversion.h:726:31: required from ‘typename std::enable_if<(! typename llvm::detail::detector<void, llvm::detail::is_invocable, Callable, mlir::Operation*>::value_t:: value)>::type mlir::ConversionTarget::addDynamicallyLegalOp(Callable&&) [with OpT = mlir::scf::IfOp; Callable = bool (&)(mlir::scf::IfOp); typename std::enable_if<(! typename llvm::detail::detector<void, llvm::detail::is_invocable, Callable, mlir::Operation*>::value_t:: value)>::type = void]’
…/lib/Conversion/AffineToStaticLogic/AffineToStaticLogic.cpp:223:58: required from here
…/llvm/mlir/include/mlir/Transforms/DialectConversion.h:727:37: error: variable ‘callback’ has function type
[=](Operation *op) { return callback(cast(op)); });
^~~~~~~~
…/llvm/mlir/include/mlir/Transforms/DialectConversion.h:727:37: error: variable ‘callback’ has function type
…/llvm/mlir/include/mlir/Transforms/DialectConversion.h:727:55: error: use of ‘decltype(auto) llvm::cast(From*) [with To = mlir::scf::IfOp; From = mlir::Operation]’ before deduction of ‘auto’
[=](Operation *op) { return callback(cast(op)); });
~~~~~~~^~

I struggling for two days, if someone can help me. Thanks in advance!

My guess is your /usr/bin/c++ is pretty old. Perhaps install clang-8 at least?

Thanks, stephen, I will have a try

1 Like

Hi, stephen, my clang-12 locate at /usr/bin/clang-12, do I need to use is like```
-DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang+±12 -DLLVM_ENABLE_LLD=ON

1 Like

Yup! That should work.