google / clif Goto Github PK
View Code? Open in Web Editor NEWBinding generator to wrap C++ for Python using LLVM.
License: Apache License 2.0
Binding generator to wrap C++ for Python using LLVM.
License: Apache License 2.0
Consider the file vector.h
namespace example {
template<typename Real>
class Vector{
public:
Vector() { }
void Set(int i, Real r){
//Sets i-th element equal to r
}
};
template<class ObjectType>
class ObjectTypeHolder {
public:
typedef ObjectType T;
ObjectTypeHolder() { }
void FailTerribly(ObjectTypeHolder<T> *other){
// Fails...
}
void DoNothing(ObjectTypeHolder<T> &other){
//Does not fail...
}
};
}
We wrap it in vector.clif
from "vector.h":
namespace `example`:
class `Vector<float>` as Vector:
def Set(self, i:int, r:float)
class `ObjectTypeHolder< Vector<float> >` as VectorHolder:
def DoNothing(self, other:VectorHolder)
def FailTerribly(self, other:VectorHolder)
Which raises the following issue when doing python setup.py install
vector-clifwrap.cc: In function ‘PyObject* vector_clifwrap::pyVectorHolder::wrapFailTerribly(PyObject*, PyObject*, PyObject*)’:
vector-clifwrap.cc:218:60: error: ‘Vector’ was not declared in this scope
::example::ObjectTypeHolder< ::example::ObjectTypeHolder<Vector<float> >::T> * arg1;
^
vector-clifwrap.cc:218:60: note: suggested alternative:
In file included from vector-clifwrap.h:9:0,
from vector-clifwrap.cc:11:
vector.h:9:8: note: ‘example::Vector’
class Vector{
^
vector-clifwrap.cc:218:72: error: template argument 1 is invalid
::example::ObjectTypeHolder< ::example::ObjectTypeHolder<Vector<float> >::T> * arg1;
^
vector-clifwrap.cc:218:74: error: template argument 1 is invalid
::example::ObjectTypeHolder< ::example::ObjectTypeHolder<Vector<float> >::T> * arg1;
^
vector-clifwrap.cc:218:78: error: expected initializer before ‘>’ token
::example::ObjectTypeHolder< ::example::ObjectTypeHolder<Vector<float> >::T> * arg1;
^
vector-clifwrap.cc:219:28: error: ‘arg1’ was not declared in this scope
if (!Clif_PyObjAs(a[0], &arg1)) return ArgError("FailTerribly", names[0], "::example::ObjectTypeHolder< ::example::ObjectTypeHolder<
^
vector-clifwrap.cc:226:21: error: ‘arg1’ was not declared in this scope
c->FailTerribly(arg1);
^
error: command 'gcc' failed with exit status 1
As you may see, this error does not happen for DoNothing
and it goes away if we do not expose FailTerribly
in the clif file. For comparison, here are the important parts from the produced code in both methods:
if (!PyArg_ParseTupleAndKeywords(args, kw, "O:DoNothing", names, &a[0])) return nullptr;
::example::ObjectTypeHolder< ::example::Vector<float> >* arg1;
if (!PyArg_ParseTupleAndKeywords(args, kw, "O:FailTerribly", names, &a[0])) return nullptr;
::example::ObjectTypeHolder< ::example::ObjectTypeHolder<Vector<float> >::T> * arg1;
What would be the general advice to wrap such cases?
I saw the following rule in the python primer.
A Python name, say to name a function argument type, can only be used after a construct with that name has been previously defined. It could either be defined in the same Clif file where it is used, or in another Clif wrapping imported by the Clif file.
Given that we can not use a Python name before a construct with that name has been defined, is there a way of wrapping a header file defining multiple classes that refer to each other in their method arguments and/or return values in a cyclical fashion?
Consider the following example header list.h
.
class ListBase {
public:
int Length();
Slice GetSlice(int origin, int length);
};
class List : public ListBase {
public:
List(int length);
Resize(int length);
};
class Slice : public ListBase {
public:
Slice(const List &list, int origin, int length);
Slice(const Slice &other);
};
I am having trouble wrapping the ListBase::GetSlice
method since its return value is a Slice
and the corresponding Python name is not defined until later. Here is the CLIF API description that is failing.
from "list.h":
class ListBase:
def Length(self) -> int
def GetSlice(self, origin: int, length: int) -> Slice # This causes an error
class List(ListBase):
@add__init__
def `List` as NewFromLength(self, length: int)
def Resize(self, length: int)
class Slice(ListBase):
@add__init__
def `Slice` as NewFromList(self, list: List, origin: int, length: int)
@add__init__
def `Slice` as NewFromSlice(self, other: Slice)
I guess what is needed here is some form of forward declaration for the Slice
class. Is there a way of achieving this is CLIF?
More generally, is there a way of wrapping a set of header files defining classes that refer to classes defined in the other header files that are also being wrapped in a cyclical fashion? For instance, list.h
defines class List
which refers to class Map
defined in map.h
and Map
refers back to List
in its own definition.
There is an issue in line 275 of clif/python/stltypes.h
when trying to iterate over a vector<bool>
. I believe this to be caused by an optimization in C++11, where vector<bool>
holds bits instead of bytes, and cannot return bool&
.
For example, consider the following header file (boollist.h
):
template<class BasicType> class BasicVectorHolder {
public:
typedef std::vector<BasicType> T;
BasicVectorHolder() { }
void Clear() { t_.clear(); }
T &Value() { return t_; }
private:
T t_;
};
where BasicType
can be float, double, bool, etc...
The following clif code would work without any issues:
from "boollist.h":
class `BasicVectorHolder<float>` as FloatVectorHolder:
T:list<float> = property(`Value`)
def Clear(self)
However, if we were to replace float
with bool
:
from "boollist.h":
class `BasicVectorHolder<bool>` as BoolVectorHolder:
T:list<bool> = property(`Value`)
def Clear(self)
This would fail with the following error message:
In file included from boollist-clifwrap.cc:12:0:
/home/victor/opt/clif/python/stltypes.h: In instantiation of 'PyObject* clif::py::ListFromSizableCont(T&&, clif::py::PostConv) [with T = const std::vector<bool, std::allocator<bool> >&; PyObject = _object]':
/home/victor/opt/clif/python/stltypes.h:404:33: required from 'PyObject* clif::Clif_PyObjFrom(const std::vector<T, Args ...>&, clif::py::PostConv) [with T = bool; Args = {std::allocator<bool>}; PyObject = _object]'
boollist-clifwrap.cc:181:68: required from here
/home/victor/opt/clif/python/stltypes.h:275:3: error: invalid initialization of non-const reference of type 'bool&' from an rvalue of type 'std::_Bit_const_iterator::const_reference {aka bool}'
for (auto& v : c) {
^
What would be the recommended way to work-around this?
I try to wrap a API that supports signal/slot concepts with clif since it supports callback functions using std::function. I wrapped the boost::signals2 type inside a wrapper class to hide it from clif. However trying to generate the bindings for this code:
#include <boost/signals2.hpp>
#include <functional>
namespace Zypp{
template<typename Sig1, typename Sig2>
class SignalWrap
{
public:
typedef typename boost::signals2::signal<Sig1 (Sig2)> SignalType;
void onSignal (std::function<Sig1(Sig2)> cb) {
m_sig.connect(cb);
}
SignalType &sig() {
return m_sig;
}
private:
SignalType m_sig;
};
class MyClass
{
public:
MyClass()
{
}
int executeCallback ( int value )
{
return m_sig.sig()(value).get();
}
SignalWrap<int, int> m_sig;
};
}
using this clif file:
from "pycliff/MyClass.h":
namespace `Zypp`:
class `SignalWrap<int, int>` as SignalIntInt:
def onSignal (self, cb: (d: int) -> int)
class MyClass:
def executeCallback(self, d: int) -> int
@getter
def `m_sig` as getSig(self) -> SignalIntInt
Will always result in a error like this:
No suitable matches found for m_sig on line 9.
Non-matching types.
Compare:
Clif Type: "Zypp::SignalWrap<int, int>" with
C++ Type: "::Zypp::SignalWrap<int, int>"
Removing the getter will make it compile , but of course I can not access the signal type. There is a workaround to have a connectToSignal() function per available signal but actually getting the signal type directly would be preferrable.
The same result is visible for subclassing the signal, e.g:
class MySignal : public boost::signals2::signal<int (int)>
{
...
}
i am in examples folder. clif compiled and run ok. however
i run
make callbacks
In file included from /dev/stdin:1:
/opt/clif/python/types.h:28:10: fatal error: 'map' file not found
#include
^~~~~
_BackendError: Matcher failed with status 1
make[3]: *** [callbacks/python/CMakeFiles/callbacks] Error 4
make[2]: *** [callbacks/python/CMakeFiles/callbacks.dir/all] Error 2
make[1]: *** [callbacks/python/CMakeFiles/callbacks.dir/rule] Error 2
make: *** [callbacks] Error 2
I have added this to CMakeLists:
-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
it now shows a different error:make callbacks
No suitable matches found for Set (with C++ name: clif_example::callbacks::Set) on line 21.
Function parameter types didn't match.
Rejected Candidate:
clif_example::callbacks::Set at /opt/clif/../clif/examples/callbacks/callbacks.h:41:1
Parameter 2.
Compare:
Clif Type: "clif_example::callbacks::Data" with
C++ Type: "::std::shared_ptr< ::clif_example::callbacks::Data>"
Do all output parameters follow all input parameters?
_BackendError: Matcher failed with status 1
make[3]: *** [callbacks/python/CMakeFiles/callbacks] Error 4
make[2]: *** [callbacks/python/CMakeFiles/callbacks.dir/all] Error 2
make[1]: *** [callbacks/python/CMakeFiles/callbacks.dir/rule] Error 2
make: *** [callbacks] Error 2
The detail problem:
+++ dirname ./INSTALL.sh
++ cd .
++ pwd
+ CLIFSRC_DIR=/root/clif
+ BUILD_DIR=/root/clif/build
+ declare -a CMAKE_G_FLAG
+ declare -a MAKE_PARALLELISM
+ which ninja
+ CMAKE_G_FLAGS=()
+ MAKE_OR_NINJA=make
+ MAKE_PARALLELISM=(-j 2)
+ [[ -r /proc/cpuinfo ]]
++ cat /proc/cpuinfo
++ grep -c '^processor'
+ N_CPUS=32
+ [[ 32 -gt 0 ]]
+ MAKE_PARALLELISM=(-j $N_CPUS)
+ MAKE_INSTALL_PARALLELISM=(${MAKE_PARALLELISM[@]})
+ echo 'Using make for the clif backend build.'
Using make for the clif backend build.
+ [[ '' =~ ^-?-h ]]
+ [[ -n '' ]]
++ which python3
+ PYTHON=/usr/local/bin/python3
+ echo -n 'Using Python interpreter: /usr/local/bin/python3'
Using Python interpreter: /usr/local/bin/python3+ [[ '' -eq 1 ]]
+ mkdir -p /root/clif/build
+ cd /root/clif/build
+ cmake -DPYTHON_EXECUTABLE=/usr/local/bin/python3 /root/clif
-- Checking for module 'protobuf'
-- No package 'protobuf' found
CMake Error at /usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:463 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:643 (_pkg_check_modules_internal)
clif/cmake/modules/CLIFUtils.cmake:31 (pkg_check_modules)
clif/CMakeLists.txt:22 (include)
Thanking for you help!
Hello all,
My name is Dimitar Dobrev, one of the lead developers behind https://github.com/mono/CppSharp. I could not help but notice that your project, while initially targeting a different language, has the same purpose. CppSharp is Clang-based as well and despite the name, it's not bound to C# or .NET, generators for any languages can be added. I think we could cooperate on the subject so I would like to offer you a discussion.
Feature request: a bazel build rule for CLIF :D
The separated LLVM libraries for linking are outdated. I have to manually replace these separated libraries
clangAST
clangASTMatchers
clangFrontend
clangSema
clangSerialization
clangTooling
with clang-cpp in the file backend/CMakeLists.txt
However, the bazel build fails and it probably is related to the outdated versions.
Since CLIF is a "C++ wrapper generators for various languages." and a replacement of SWIG, I would like to have the C# (.NET netstandard2.0 TFM) support...
note: For google/or-tools we may use CLIF instead of SWIG but we need the C# support first !!!
On High Sierra I installed
pip3 install 'pyparsing>=2.2.0'
pip3 install virtualenv
pip3 install virtualenvwrapper
brew install protobuf --with-python3
git clone https://github.com/google/clif.git
export PATH=/usr/local/opt/llvm/bin:$PATH
cd clif;
./INSTALL.sh python3
c++ and cc in /usr/local/bin (already on PATH) are symlinked to /usr/local/opt/llvm/bin/clang++ and clang respectively.
./Install.sh python3
runs for quite a while but ultimately fails:
_ParseError: unhashable type
make[3]: *** [tools/clif/python/utils/proto_util.cc] Error 3
make[2]: *** [tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/all] Error 2
make[1]: *** [tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/rule] Error 2
make: *** [clif_python_utils_proto_util] Error 2
I'm not sure how to proceed.
The below link in clif/clif/python/README.md is broken. Should replace http://go with GitHub pages?
The Status
and StatusOr<T>
classes in Python wrappers
https://github.com/google/clif/blame/main/clif/python/README.md#L38
I am trying to install Pykaldi compatible fork of clif in Ubuntu 18.04. Error log is enclosed. Please help to resolve the issue:
Destination /home/pp/nfr/pykaldi-master/tools/clif already exists.
/home/pp/.local/bin/ninja
Using ninja for the clif backend build.
/home/pp/nfr/pykaldi-master/tools/clif/../clif_backend/build_matcher
Start Compiling
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Targeting X86
-- Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.5")
-- Clang version: 5.0.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pp/nfr/pykaldi-master/tools/clif_backend/build_matcher
[11/12] Building CXX object tools/clif...n_utils_proto_util.dir/proto_util.cc.o
In file included from /usr/include/python2.7/Python.h:83:0,
from tools/clif/python/utils/proto_util.cc:7:
tools/clif/python/utils/proto_util.cc: In function ‘bool clif_python_utils_proto__util_clifwrap::Ready()’:
/usr/include/python2.7/object.h:769:22: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
((PyObject*)(op))->ob_refcnt++)
^
tools/clif/python/utils/proto_util.cc:985:3: note: in expansion of macro ‘Py_INCREF’
Py_INCREF(&pyProtoTypeInfo::wrapper_Type); // For PyModule_AddObject to steal.
^~~~~~~~~
/usr/include/python2.7/object.h:769:22: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
((PyObject*)(op))->ob_refcnt++)
^
tools/clif/python/utils/proto_util.cc:987:3: note: in expansion of macro ‘Py_INCREF’
Py_INCREF(&pyMethodInfo::wrapper_Type); // For PyModule_AddObject to steal.
^~~~~~~~~
/usr/include/python2.7/object.h:769:22: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
((PyObject*)(op))->ob_refcnt++)
^
tools/clif/python/utils/proto_util.cc:989:3: note: in expansion of macro ‘Py_INCREF’
Py_INCREF(&pyServiceInfo::wrapper_Type); // For PyModule_AddObject to steal.
^~~~~~~~~
/usr/include/python2.7/object.h:769:22: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
((PyObject*)(op))->ob_refcnt++)
^
tools/clif/python/utils/proto_util.cc:991:3: note: in expansion of macro ‘Py_INCREF’
Py_INCREF(&pyProtoFileInfo::wrapper_Type); // For PyModule_AddObject to steal.
^~~~~~~~~
[12/12] Linking CXX shared library tools/clif/python/utils/proto_util.so
[160/490] Building CXX object lib/Fuzzer/CMakeFiles/LLVMFuzzerNoMainObjects.dir/FuzzerIOPosix.cpp.o
/home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/lib/Fuzzer/FuzzerIOPosix.cpp: In function ‘void fuzzer::RawPrint(const char*)’:
/home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/lib/Fuzzer/FuzzerIOPosix.cpp:118:8: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
write(2, Str, strlen(Str));
[260/490] Building C object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o
FAILED: tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o
/usr/bin/gcc -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/tools/c-index-test -I/home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/tools/clang/tools/c-index-test -I/home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/tools/clang/include -Itools/clang/include -Iinclude -I/home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/include -isystem /usr/share/doc/libxml2 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -fPIC -Werror=date-time -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu89 -MD -MT tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o -MF tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o.d -o tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o -c /home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/tools/clang/tools/c-index-test/c-index-test.c
/home/pp/nfr/pykaldi-master/tools/clif_backend/llvm/tools/clang/tools/c-index-test/c-index-test.c:15:10: fatal error: libxml/parser.h: No such file or directory
#include <libxml/parser.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
[261/490] Building CXX object tools/clang/tools/clang-check/CMakeFiles/clang-check.dir/ClangCheck.cpp.o
ninja: build stopped: subcommand failed.
The issue title is my best guess of what is happening. Here is a simplified example.
Consider this source file.
#ifndef TEST_H_
#define TEST_H_
struct Stats {
float mean;
float var;
bool compute;
// This constructor matches copy/move constructors generated by the compiler
Stats(const bool &compute_): mean(0.0), var(0.1), compute(compute_) { }
// These constructors are fine.
// Stats(const bool compute_): mean(0.0), var(0.1), compute(compute_) { }
// Stats(bool &compute_): mean(0.0), var(0.1), compute(compute_) { }
// Stats(bool compute_): mean(0.0), var(0.1), compute(compute_) { }
};
#endif
This is the wrapper.
from "test.h":
class Stats:
mean: float
var: float
compute: bool
def __init__(self, compute_: bool)
This is what I am getting from pyclif.
No suitable matches found for Stats on line 2.
Multiple C++ symbols with same name found. Possibilities include:
Rejected Candidate:
Stats::Stats at ./test.h:10:3
Rejected Candidate:
Stats::Stats at ./test.h:4:8
Rejected Candidate:
Stats::Stats at ./test.h:4:8
_BackendError: Matcher failed with status 1
When I run following command:
clang++ clif/backend/CMakeFiles/clif-matcher.dir/matcher_main.cc.o -o clif/backend/clif-matcher -L/public/home/yangjiangroup/fanghailing/softwares_pub/protobuf-cpp_v3.17.3_d20210714/lib -Wl,-rpath,/public/home/yangjiangroup/fanghailing/softwares_pub/protobuf-cpp_v3.17.3_d20210714/lib: clif/backend/libclifMatcher.a clif/protos/libclifAstProto.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangAST.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangASTMatchers.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangFrontend.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangSema.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangSerialization.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangTooling.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVM-13git.so -lprotobuf -lpthread /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangFrontend.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangParse.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangSerialization.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangSema.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangEdit.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangAnalysis.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangASTMatchers.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangAST.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMFrontendOpenMP.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMTransformUtils.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMAnalysis.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMObject.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMBitReader.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMMCParser.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMMC.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMDebugInfoCodeView.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMTextAPI.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangDriver.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMProfileData.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMCore.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMBinaryFormat.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMRemarks.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMBitstreamReader.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMOption.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangFormat.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangToolingInclusions.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangToolingCore.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangRewrite.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangLex.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libclangBasic.a /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMSupport.a -lrt -ldl -lpthread -lm /usr/lib64/libz.so /usr/lib64/libtinfo.so /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVMDemangle.a
I get error:
ld: error: undefined symbol: typeinfo for llvm::cl::GenericOptionValue
referenced by matcher_main.cc
clif/backend/CMakeFiles/clif-matcher.dir/matcher_main.cc.o:(typeinfo for llvm::cl::OptionValueCopy<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >)
referenced by matcher_main.cc
clif/backend/CMakeFiles/clif-matcher.dir/matcher_main.cc.o:(typeinfo for llvm::cl::OptionValueCopy)
did you mean: vtable for llvm::cl::GenericOptionValue
defined in: /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVM-13git.so
ld: error: undefined symbol: typeinfo for llvm::cl::Option
referenced by matcher_main.cc
clif/backend/CMakeFiles/clif-matcher.dir/matcher_main.cc.o:(typeinfo for llvm::cl::list<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >)
did you mean: vtable for llvm::cl::Option
defined in: /public/home/yangjiangroup/fanghailing/softwares_pub/lib/libLLVM-13git.so
ld: error: undefined symbol: typeinfo for clang::ast_matchers::MatchFinder::MatchCallback
referenced by ast.cc
ast.cc.o:(typeinfo for clif::TranslationUnitAST::ConversionFunctionFinder) in archive clif/backend/libclifMatcher.a
collect2: error: ld returned 1 exit status
I user clang13 and lld
Any idear about this?
by the way:
I commit a line /clif/backend/matcher.h:544
Google it? haha
I have run the Dockerfile for prereqs and changed the basic image to ubuntu 20.04 and didn't pass the whole process. I was wondering it is supported on ubuntu 20.04 or any other suggestion to install clif in a basic image of ubuntu 20.04. Thanks
Hi,
For a larger c++ project with at least 50 headers, is it possible to use a generator to automate the process ?
Hi,
I get the following error during installation using ./INSTALL.sh. I am using the clang and llvm 11.0.0 on Centos 7
Scanning dependencies of target clif-matcher
[100%] Building CXX object clif/backend/CMakeFiles/clif-matcher.dir/matcher_main.cc.o
[100%] Linking CXX executable clif-matcher
CMakeFiles/clif-matcher.dir/matcher_main.cc.o:(.data.rel.ro._ZTIN4llvm2cl4listINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbNS0_6parserIS7_EEEE[_ZTIN4llvm2cl4listINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbNS0_6parserIS7_EEEE]+0x18): undefined reference to typeinfo for llvm::cl::Option' CMakeFiles/clif-matcher.dir/matcher_main.cc.o:(.data.rel.ro._ZTIN4llvm2cl15OptionValueCopyIbEE[_ZTIN4llvm2cl15OptionValueCopyIbEE]+0x10): undefined reference to
typeinfo for llvm::cl::GenericOptionValue'
CMakeFiles/clif-matcher.dir/matcher_main.cc.o:(.data.rel.ro._ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE[_ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE]+0x10): undefined reference to typeinfo for llvm::cl::GenericOptionValue' libclifMatcher.a(ast.cc.o):(.data.rel.ro._ZTIN4clif18TranslationUnitAST24ConversionFunctionFinderE[_ZTIN4clif18TranslationUnitAST24ConversionFunctionFinderE]+0x10): undefined reference to
typeinfo for clang::ast_matchers::MatchFinder::MatchCallback'
~]$ pip install 'pyparsing>=2.2.0'
Collecting pyparsing>=2.2.0
Using cached https://files.pythonhosted.org/packages/42/47/e6d51aef3d0393f7d343592d63a73beee2a8d3d69c22b053e252c6cfacd5/pyparsing-2.2.1-py2.py3-none-any.whl
cliff 1.4.4 has requirement pyparsing<=1.5.7, but you'll have pyparsing 2.2.1 which is incompatible.
Installing collected packages: pyparsing
Found existing installation: pyparsing 1.5.6
Cannot uninstall 'pyparsing'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Then after I install pyparsing 2.2.0 via the comment here: [https://github.com//issues/23], it compiles and installs nicely.
I attach file with INSTALL.sh output.
I think it is some sort of compilation error, not missing library or sth.
install_fail.txt
/tmp/example/bin/pip install .
Processing /opt/clif/examples/templates
Installing collected packages: pyclif-example-templates
Running setup.py install for pyclif-example-templates ... error
Complete output from command /tmp/example/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/nc/4fm6m_fd3t79jz6qyp6bhpjm0000gn/T/pip-9jr86d37
-build/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /var/fol
ders/nc/4fm6m_fd3t79jz6qyp6bhpjm0000gn/T/pip-npr_8vht-record/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/example/include/site/p
ython3.5/pyclif-example-templates:
running install
running build
running build_ext
building 'templates' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.5
creating build/temp.macosx-10.7-x86_64-3.5/python
creating build/temp.macosx-10.7-x86_64-3.5/Users
creating build/temp.macosx-10.7-x86_64-3.5
creating build/temp.macosx-10.7-x86_64-3.5/opt
creating build/temp.macosx-10.7-x86_64-3.5/opt/clif
creating build/temp.macosx-10.7-x86_64-3.5/opt/clif/python
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/opt -I/anaconda3/includ
e/python3.5m -c python/templates.cc -o build/temp.macosx-10.7-x86_64-3.5/python/templates.o -std=c++11
In file included from python/templates.cc:8:
/opt/clif/python/ptr_util.h:25:10: fatal error: 'type_traits' file not found
#include <type_traits>
^
1 error generated.
error: command 'gcc' failed with exit status 1
After yesterday's update, rudimentary wrappers I had previously written for the C++ iostream and stringstream types stopped working. For some reason CLIF now generates the basic_stream conversion methods twice.
I was able to replicate the situation in this simplified setup.
#ifndef TEST_H_
#define TEST_H_
template <class T>
class base2 {
public:
bool good() { return true; }
};
template <class T>
class derived1 : virtual public base2<T> {};
template <class T>
class derived2 : virtual public base2<T> {};
template <class T>
class derived3 : public derived1<T>, public derived2<T> {};
typedef derived3<char> derived3_char;
#endif
CLIF wrapper:
from "test.h":
class derived3_char:
def good(self) -> bool
The definition for as_base2_char is repeated in the CLIF output (.cc).
...
// Implicit cast this as ::derived1<char>*
static PyObject* as_derived1_char(PyObject* self) {
::derived1<char>* p = ::clif::python::Get(reinterpret_cast<wrapper*>(self)->cpp)
;
if (p == nullptr) return nullptr;
return PyCapsule_New(p, C("::derived1<char>"), nullptr);
}
// Implicit cast this as ::derived2<char>*
static PyObject* as_derived2_char(PyObject* self) {
::derived2<char>* p = ::clif::python::Get(reinterpret_cast<wrapper*>(self)->cpp);
if (p == nullptr) return nullptr;
return PyCapsule_New(p, C("::derived2<char>"), nullptr);
}
// Implicit cast this as ::base2<char>*
static PyObject* as_base2_char(PyObject* self) {
::base2<char>* p = ::clif::python::Get(reinterpret_cast<wrapper*>(self)->cpp);
if (p == nullptr) return nullptr;
return PyCapsule_New(p, C("::base2<char>"), nullptr);
}
// Implicit cast this as ::base2<char>*
static PyObject* as_base2_char(PyObject* self) {
::base2<char>* p = ::clif::python::Get(reinterpret_cast<wrapper*>(self)->cpp);
if (p == nullptr) return nullptr;
return PyCapsule_New(p, C("::base2<char>"), nullptr);
}
...
It seems this issue arises only in the case of virtual inheritance.
I came across this issue a few days ago. From what I can tell, the code generated for __delitem__
when wrapping the derived class overrides the code generated for __setitem__
when wrapping the base class. If __setitem__
is wrapped in the derived class in addition to the base class, then it works as expected.
I am trying to install Clif v0.4 from source in CentOS 7 as a prerequisite for DeepVariant. I am using CMake 1.15.2 and GCC 8.2.0. I have a Python environment (Python 3.6.12) named deepvariant in Anaconda3 that is running with virtualenv 20.4.2 and pyparsing 2.2.0 installed. The latest Absiel is installed and the path is set using the absl_DIR environment variable. Protobuf 3.15.1 and Glog 0.4.0 are installed and the paths are set using:
export PKG_CONFIG_PATH="/opt/apps/glog/0.4.0:/opt/apps/protobuf/3.15.1/cpp"
pkg-config --cflags protobuf libglog
Using CMake, I install Clif using the following command, specifying where the python prerequisites can be installed:
cmake .. \
-DPYTHON_INCLUDE_DIR="/opt/apps/Anaconda3/2020.07/envs/deepvariant/include/" \
-DPYTHON_LIBRARY="/opt/apps/Anaconda3/2020.07/envs/deepvariant/lib/" \
-DPYTHON_EXECUTABLE="/opt/apps/Anaconda3/2020.07/envs/deepvariant/bin/python3"
Unfortunately, I run into the following error:
(deepvariant) [root@machine]# cmake .. -DPYTHON_INCLUDE_DIR= ...
CMake Error at clif/cmake/modules/CLIFUtils.cmake:37 (find_package):
Could not find a configuration file for package "LLVM" that is compatible
with requested version "11".
The following configuration files were considered but not accepted:
/usr/local/lib/cmake/llvm/LLVMConfig.cmake, version: 11.1.0
Call Stack (most recent call first):
clif/CMakeLists.txt:22 (include)
-- Configuring incomplete, errors occurred!
See also "/opt/apps/clif/0.4/build/CMakeFiles/CMakeOutput.log".
See also "/opt/apps/clif/0.4/build/CMakeFiles/CMakeError.log".
Originally, the latest main branch of LLVM was installed to /opt/apps/llvm/latest/ but I received an error stating that version 13.x.x git was installed there and was not compatible. Over night, I built the 11.1.0 release version of LLVM and let it install to /usr/local/... so that Clif could easily find it. I repeatably hit this compatibility error. Clif did not specify any minor release or patch incompatibilities for LLVM 11+ so I assumed that version 11+ should work just fine. How do I complete this installation? Please advise.
It'd be great to incorporate Clif into Bazel workspaces. Will we see Skylark rules to do so?
[x] Bug (Typo)
unncessary
, however expect to see unnecessary
.sinature
, however expect to see signature
.inheritence
, however expect to see inheritance
.hierarhies
, however expect to see hierarchies
.formattting
, however expect to see formatting
.exising
, however expect to see existing
.errorneously
, however expect to see erroneously
.elmement
, however expect to see element
.compatiblity
, however expect to see compatibility
.Semi-automated issue generated by
https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md
To avoid wasting CI processing resources a branch with the fix has been
prepared but a pull request has not yet been created. A pull request fixing
the issue can be prepared from the link below, feel free to create it or
request @timgates42 create the PR. Alternatively if the fix is undesired please
close the issue with a small comment about the reasoning.
https://github.com/timgates42/clif/pull/new/bugfix_typos
Thanks.
Trying to install pykaldi on macOS Catalina for python3.8 and currently stuck on building pyclif:
[100%] Building CXX object tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/proto_util.cc.o
with the error:
/Users/kkawabat/pykaldi/tools/clif_backend/build_matcher/tools/clif/python/utils/proto_util.cc:314:3: error: cannot initialize a
member subobject of type 'Py_ssize_t' (aka 'long') with an rvalue of type 'nullptr_t'
nullptr, // tp_print
^~~~~~~
I believe this is due to changes to tp_print
for python3.8 (see footnote for python type objects)
Changed in version 3.8: This slot was used for print formatting in Python 2.x. In Python 3.0 to 3.7, it was reserved and named tp_print.
it used to be of type printfunc
but now it'sPy_ssize_t
which cannot be typed as nullptr
Line 15 in 83ca1bc
C++ header
template<typename Real>
class ArrayBase {
bool IsZero(Real cutoff = 1.0e-06) const;
};
CLIF:
from "array.h":
class `ArrayBase<float>` as ArrayBase:
def IsZero(self, cutoff: float) -> bool
Error:
No suitable matches found for IsZero on line 8.
Parameter counts differ.
Rejected Candidate:
ArrayBase<float>::IsZero at /home/dogan/tools/pyarray/array.h:45:3
Parameter counts differ. Clif declares 1 required parameters vs. C++ declaration has 0
_BackendError: Matcher failed with status 1
I tried building on Ubuntu 16.04 using ninja and it failed with the following error:
CMake Error at tools/clif/backend/CMakeLists.txt:15 (include_directories):
include_directories given empty-string as include directory.
I installed protobuf from source following the directions here.
Here's the output from the full run:
kkiningh@mew:~/Workspace/clif/clif$ ./INSTALL.sh
+ INSTALL_DIR=/home/kkiningh/opt
+ CLIFSRC_DIR=/home/kkiningh/Workspace/clif/clif
+ LLVM_DIR=/home/kkiningh/Workspace/clif/clif/../clif_backend
+ BUILD_DIR=/home/kkiningh/Workspace/clif/clif/../clif_backend/build_matcher
++ cmake --version
++ head -1
++ cut -f3 '-d '
+ CV=3.5.1
+ CV=(${CV//./ })
+ (( CV[0] < 3 || CV[0] == 3 && CV[1] < 5 ))
++ protoc --version
++ cut -f2 '-d '
+ PV=3.3.0
+ PV=(${PV//./ })
+ (( PV[0] < 3 || PV[0] == 3 && PV[1] < 2 ))
++++ which protoc
+++ dirname /usr/bin/protoc
++ dirname /usr/bin
+ PROTOC_PREFIX_PATH=/usr
+ declare -a CMAKE_G_FLAG
+ declare -a MAKE_PARALLELISM
+ which ninja
/usr/bin/ninja
+ CMAKE_G_FLAGS=(-G Ninja)
+ MAKE_OR_NINJA=ninja
+ MAKE_PARALLELISM=()
+ echo 'Using ninja for the clif backend build.'
Using ninja for the clif backend build.
+ [[ '' =~ ^-?-h ]]
+ PYTHON=python
+ [[ -n '' ]]
+ echo -n 'Using Python interpreter: '
Using Python interpreter: + which python
/usr/bin/python
+ CLIF_VIRTUALENV=/home/kkiningh/opt/clif
+ CLIF_PIP=/home/kkiningh/opt/clif/bin/pip
+ virtualenv -p python /home/kkiningh/opt/clif
Running virtualenv with interpreter /usr/bin/python
New python executable in /home/kkiningh/opt/clif/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
+ /home/kkiningh/opt/clif/bin/pip install --upgrade pip
Requirement already up-to-date: pip in /home/kkiningh/opt/clif/lib/python2.7/site-packages
+ /home/kkiningh/opt/clif/bin/pip install --upgrade setuptools
Requirement already up-to-date: setuptools in /home/kkiningh/opt/clif/lib/python2.7/site-packages
Requirement already up-to-date: appdirs>=1.4.0 in /home/kkiningh/opt/clif/lib/python2.7/site-packages (from setuptools)
Requirement already up-to-date: packaging>=16.8 in /home/kkiningh/opt/clif/lib/python2.7/site-packages (from setuptools)
Requirement already up-to-date: six>=1.6.0 in /home/kkiningh/opt/clif/lib/python2.7/site-packages (from setuptools)
Requirement already up-to-date: pyparsing in /home/kkiningh/opt/clif/lib/python2.7/site-packages (from packaging>=16.8->setuptools)
+ mkdir -p /home/kkiningh/Workspace/clif/clif/../clif_backend
+ cd /home/kkiningh/Workspace/clif/clif/../clif_backend
+ svn co https://llvm.org/svn/llvm-project/llvm/trunk@299535 llvm
Checked out revision 299535.
+ cd llvm/tools
+ svn co https://llvm.org/svn/llvm-project/cfe/trunk@299535 clang
Checked out revision 299535.
+ '[' '!' '(' -e clif ')' ']'
+ mkdir -p /home/kkiningh/Workspace/clif/clif/../clif_backend/build_matcher
+ cd /home/kkiningh/Workspace/clif/clif/../clif_backend/build_matcher
+ cmake -DCMAKE_INSTALL_PREFIX=/home/kkiningh/opt/clif/clang -DCMAKE_PREFIX_PATH=/usr -DLLVM_INSTALL_TOOLCHAIN_ONLY=true -DCMAKE_BUILD_TYPE=Release -G Ninja /home/kkiningh/Workspace/clif/clif/../clif_backend/llvm
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for dirent.h
-- Looking for dirent.h - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for execinfo.h
-- Looking for execinfo.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for link.h
-- Looking for link.h - found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for malloc/malloc.h
-- Looking for malloc/malloc.h - not found
-- Looking for ndir.h
-- Looking for ndir.h - not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for sys/dir.h
-- Looking for sys/dir.h - found
-- Looking for sys/ioctl.h
-- Looking for sys/ioctl.h - found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for sys/ndir.h
-- Looking for sys/ndir.h - not found
-- Looking for sys/param.h
-- Looking for sys/param.h - found
-- Looking for sys/resource.h
-- Looking for sys/resource.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for sys/uio.h
-- Looking for sys/uio.h - found
-- Looking for termios.h
-- Looking for termios.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - not found
-- Looking for zlib.h
-- Looking for zlib.h - found
-- Looking for fenv.h
-- Looking for fenv.h - found
-- Looking for FE_ALL_EXCEPT
-- Looking for FE_ALL_EXCEPT - found
-- Looking for FE_INEXACT
-- Looking for FE_INEXACT - found
-- Looking for mach/mach.h
-- Looking for mach/mach.h - not found
-- Looking for histedit.h
-- Looking for histedit.h - not found
-- Looking for CrashReporterClient.h
-- Looking for CrashReporterClient.h - not found
-- Looking for linux/magic.h
-- Looking for linux/magic.h - found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Looking for pthread_getspecific in pthread
-- Looking for pthread_getspecific in pthread - found
-- Looking for pthread_rwlock_init in pthread
-- Looking for pthread_rwlock_init in pthread - found
-- Looking for pthread_mutex_lock in pthread
-- Looking for pthread_mutex_lock in pthread - found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for compress2 in z
-- Looking for compress2 in z - found
-- Looking for setupterm in tinfo
-- Looking for setupterm in tinfo - found
-- Looking for xar_open in xar
-- Looking for xar_open in xar - not found
-- Looking for arc4random
-- Looking for arc4random - not found
-- Looking for backtrace
-- Looking for backtrace - found
-- Looking for _Unwind_Backtrace
-- Looking for _Unwind_Backtrace - found
-- Looking for getpagesize
-- Looking for getpagesize - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for getrusage
-- Looking for getrusage - found
-- Looking for setrlimit
-- Looking for setrlimit - found
-- Looking for isatty
-- Looking for isatty - found
-- Looking for futimens
-- Looking for futimens - found
-- Looking for futimes
-- Looking for futimes - found
-- Looking for posix_fallocate
-- Looking for posix_fallocate - found
-- Looking for sigaltstack
-- Looking for sigaltstack - found
-- Looking for writev
-- Looking for writev - found
-- Looking for lseek64
-- Looking for lseek64 - found
-- Looking for mallctl
-- Looking for mallctl - not found
-- Looking for mallinfo
-- Looking for mallinfo - found
-- Looking for malloc_zone_statistics
-- Looking for malloc_zone_statistics - not found
-- Looking for mkdtemp
-- Looking for mkdtemp - found
-- Looking for mkstemp
-- Looking for mkstemp - found
-- Looking for mktemp
-- Looking for mktemp - found
-- Looking for getcwd
-- Looking for getcwd - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for getrlimit
-- Looking for getrlimit - found
-- Looking for posix_spawn
-- Looking for posix_spawn - found
-- Looking for pread
-- Looking for pread - found
-- Looking for realpath
-- Looking for realpath - found
-- Looking for sbrk
-- Looking for sbrk - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for strerror_r
-- Looking for strerror_r - found
-- Looking for strerror_s
-- Looking for strerror_s - not found
-- Looking for setenv
-- Looking for setenv - found
-- Looking for dlopen
-- Looking for dlopen - found
-- Looking for dladdr
-- Looking for dladdr - not found
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Looking for pthread_getname_np in pthread
-- Looking for pthread_getname_np in pthread - found
-- Looking for pthread_setname_np in pthread
-- Looking for pthread_setname_np in pthread - found
-- Performing Test HAVE_INT64_T
-- Performing Test HAVE_INT64_T - Success
-- Performing Test HAVE_UINT64_T
-- Performing Test HAVE_UINT64_T - Success
-- Performing Test HAVE_U_INT64_T
-- Performing Test HAVE_U_INT64_T - Success
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- Performing Test SUPPORTS_VARIADIC_MACROS_FLAG
-- Performing Test SUPPORTS_VARIADIC_MACROS_FLAG - Success
-- Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG
-- Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG - Failed
-- Performing Test HAS_MAYBE_UNINITIALIZED
-- Performing Test HAS_MAYBE_UNINITIALIZED - Success
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Sphinx disabled.
-- Go bindings disabled.
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Success
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test CXX_SUPPORTS_FPIC - Success
-- Building with -fPIC
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_CXX11
-- Performing Test CXX_SUPPORTS_CXX11 - Success
-- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG
-- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG - Success
-- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
-- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Failed
-- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
-- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Failed
-- Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG
-- Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Failed
-- Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG
-- Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Success
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Failed
-- Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG
-- Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG - Failed
-- Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG
-- Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG - Failed
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Failed
-- Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS
-- Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS - Success
-- Performing Test C_SUPPORTS_FFUNCTION_SECTIONS
-- Performing Test C_SUPPORTS_FFUNCTION_SECTIONS - Success
-- Performing Test CXX_SUPPORTS_FFUNCTION_SECTIONS
-- Performing Test CXX_SUPPORTS_FFUNCTION_SECTIONS - Success
-- Performing Test C_SUPPORTS_FDATA_SECTIONS
-- Performing Test C_SUPPORTS_FDATA_SECTIONS - Success
-- Performing Test CXX_SUPPORTS_FDATA_SECTIONS
-- Performing Test CXX_SUPPORTS_FDATA_SECTIONS - Success
-- Found PythonInterp: /usr/bin/python2.7 (found version "2.7.12")
-- Constructing LLVMBuild project information
-- Found Subversion: /usr/bin/svn (found version "1.9.3")
-- Targeting AArch64
-- Targeting AMDGPU
-- Targeting ARM
-- Targeting BPF
-- Targeting Hexagon
-- Targeting Lanai
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting RISCV
-- Targeting Sparc
-- Targeting SystemZ
-- Targeting X86
-- Targeting XCore
-- Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.5")
-- Looking for sys/resource.h
-- Looking for sys/resource.h - found
-- Clang version: 5.0.0
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Failed
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'protobuf'
-- Found protobuf, version 3.3.0
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found version "2.7.12")
CMake Error at tools/clif/backend/CMakeLists.txt:15 (include_directories):
include_directories given empty-string as include directory.
Is there any chance that this can be built and used with Bazel? It would be sweet to be able to generate c++ wrappers simply in bazel.
I've run the INSTALL.sh script with the following command to install using Python 3.6 as interpreter. I have Python 2.7, Python 3.5 and Python 3.6 installed on my Ubuntu 16.04LTS
./INSTALL.sh python3.6
It found correctly the interpreter Python 3.6, but the cmake of the install script finds Python 2.7 PythonLibs and PythonInterp on my PC. So the command pyclif runs with Python 2.7 instead of Python 3.6 as I would have wanted.
I traced the problem to the file CLIFUtils.cmake in clif/cmake/modules where the CMake finds Python 2.7 paths. I fixed this by adding 3 new flags indicating where my PythonLibs and PythonInterp paths are on my system inside INSTALL.sh.
The original cmake command at line 100 of the INSTALL.sh script:
cmake -DCMAKE_INSTALL_PREFIX="$CLIF_VIRTUALENV/clang" \
-DCMAKE_PREFIX_PATH="$PROTOC_PREFIX_PATH" \
-DLLVM_INSTALL_TOOLCHAIN_ONLY=true \
-DCMAKE_BUILD_TYPE=Release \
"${CMAKE_G_FLAGS[@]}" "$LLVM_DIR/llvm"
"$MAKE_OR_NINJA" "${MAKE_PARALLELISM[@]}" clif-matcher
"$MAKE_OR_NINJA" "${MAKE_PARALLELISM[@]}" install
After adding Python path flags (my own paths)
cmake -DCMAKE_INSTALL_PREFIX="$CLIF_VIRTUALENV/clang" \
-DCMAKE_PREFIX_PATH="$PROTOC_PREFIX_PATH" \
-DLLVM_INSTALL_TOOLCHAIN_ONLY=true \
-DCMAKE_BUILD_TYPE=Release \
-DPYTHON_INCLUDE_DIR="/usr/include/python3.6" \
-DPYTHON_LIBRARY="/usr/lib/x86_64-linux-gnu/libpython3.6m.so" \
-DPYTHON_EXECUTABLE="/usr/bin/python3.6" \
"${CMAKE_G_FLAGS[@]}" "$LLVM_DIR/llvm"
"$MAKE_OR_NINJA" "${MAKE_PARALLELISM[@]}" clif-matcher
"$MAKE_OR_NINJA" "${MAKE_PARALLELISM[@]}" install
Not for me, but for future users it would be nice if INSTALL.sh also changed PythonLibs and PythonInterp paths for the specified interpreter or if this workaround (if correct) was specified in the documentation.
The primer promises a wrap_protos
example in clif/examples/wrap_protos
but it is not there.
We have identified 1
possible instance of outdated documentation:
DPYTHON_INCLUDE_DIR
was deleted but the change has not been reflected in the current version of the README fileThis is part of a research project that aims to automatically detect outdated documentation in GitHub repositories. We are evaluating the validity of our approach by identifying instances of outdated documentation in real-world projects.
We hope that this research will be a step towards keeping documentation up-to-date. If this has been helpful, consider updating the documentation to keep it in sync with the source code. If this has not been helpful, consider updating this issue with an explanation, so that we can improve our approach. Thanks!
What is the standard/recommended way of handling the error "Function template can't be specialized with these arguments." ?
Consider the following header file.
template<typename Real>
class ArrayBase {
public:
void CopyFromArray(const ArrayBase<Real> &v);
template<typename OtherReal>
void CopyFromArray(const ArrayBase<OtherReal> &v);
};
This CLIF wrapping
from "array.h":
class `ArrayBase<float>` ArrayBase:
def CopyFromArray(self, a: ArrayBase) # This is the error
leads to this error
No suitable matches found for CopyFromArray on line 5.
Multiple C++ symbols with same name found. Possibilities include:
Rejected Candidate:
ArrayBase<float>::CopyFromArray at /home/dogan/tools/pyarray/array.h:110:3
Rejected Candidate:
ArrayBase<float>::CopyFromArray<float> at /home/dogan/tools/pyarray/array.h:118:3
No suitable matches found for CopyFromArray on line 5.
Function template can't be specialized with these arguments.
Hi, I meet this error while installing the cliff:
CMake Error at clif/cmake/modules/CLIFUtils.cmake:35 (find_package):
By not providing "Findabsl.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "absl", but
CMake did not find one.
Could not find a package configuration file provided by "absl" with any of
the following names:
abslConfig.cmake
absl-config.cmake
Any help would be appreciated!
I'm not entirely certain I'm following the right steps, but this is what I understood from the docs.
mkdir build
cd build
cmake ..
cmake --build . --config Release --target check
The final step gives the error:
NMAKE : fatal error U1073: don't know how to make 'check'
Running cmake -version
return the following information:
C:\Users\USERNAME\pybind11\build>cmake -version
cmake version 3.12.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Reporting error when I run INSTALL.sh script to install CLIF.
All run ok until the make command "$MAKE_OR_NINJA" "${MAKE_PARALLELISM[@]}" clif-matcher clif_python_utils_proto_util.
the reported error:
[ 97%] Built target LLVMX86Utils
[100%] Built target LLVMX86CodeGen
[100%] Built target clifMatcher
[100%] Built target clang
[100%] Built target clif-matcher
[100%] Linking CXX static library ../../../lib/libproto_util_cc.a
[100%] Built target proto_util_cc
[100%] Generating proto_util.cc, proto_util.h, proto_util.init.cc
Traceback (most recent call last):
File "/home/kery/Downloads/clif_backend/llvm/tools/clif/pyclif.py", line 37, in
from clif.protos import ast_pb2
File "/home/kery/Downloads/clif_backend/build_matcher/tools/clif/protos/ast_pb2.py", line 21, in
serialized_pb=b'\n\tast.proto\x12\x0b\x63lif.protos"\xcc\x01\n\x03\x41ST\x12\x0e\n\x06source\x18\x01 \x01(\t\x12\x19\n\x11usertype_includes\x18\x02 \x03(\t\x12 \n\x05\x64\x65\x63ls\x18\x03 \x03(\x0b\x32\x11.clif.protos.Decl\x12\x12\n\nextra_init\x18\x04 \x03(\t\x12\x18\n\x10\x63\x61tch_exceptions\x18\x05 \x01(\x08\x12&\n\x08typemaps\x18\x06 \x03(\x0b\x32\x14.clif.protos.Typemap\x12"\n\x06macros\x18\x07 \x03(\x0b\x32\x12.clif.protos.Macro"\xc9\x03\n\x04\x44\x65\x63l\x12(\n\x08\x64\x65\x63ltype\x18\x01 \x01(\x0e\x32\x16.clif.protos.Decl.Type\x12(\n\x06\x63lass_\x18\n \x01(\x0b\x32\x16.clif.protos.ClassDeclH\x00\x12%\n\x04\x65num\x18\x0b \x01(\x0b\x32\x15.clif.protos.EnumDeclH\x00\x12#\n\x03var\x18\x0c \x01(\x0b\x32\x14.clif.protos.VarDeclH\x00\x12'\n\x05\x63onst\x18\r \x01(\x0b\x32\x16.clif.protos.ConstDeclH\x00\x12%\n\x04\x66unc\x18\x0e \x01(\x0b\x32\x15.clif.protos.FuncDeclH\x00\x12)\n\x05\x66\x64\x65\x63l\x18\x0f \x01(\x0b\x32\x18.clif.protos.ForwardDeclH\x00\x12\x10\n\x08\x63pp_file\x18\x02 \x01(\t\x12\x11\n\tnot_found\x18\x03 \x01(\t\x12\x13\n\x0bline_number\x18\x04 \x01(\x05\x12\x12\n\nnamespace_\x18\x05 \x01(\t"P\n\x04Type\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x08\n\x04\x45NUM\x10\x01\x12\x07\n\x03VAR\x10\x02\x12\t\n\x05\x43ONST\x10\x03\x12\x08\n\x04\x46UNC\x10\x04\x12\x08\n\x04TYPE\x10\x05\x12\t\n\x05\x43LASS\x10\x06\x42\x06\n\x04\x64\x65\x63l"\xc8\x03\n\tClassDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name\x12 \n\x05\x62\x61ses\x18\x02 \x03(\x0b\x32\x11.clif.protos.Name\x12"\n\x07members\x18\x03 \x03(\x0b\x32\x11.clif.protos.Decl\x12\r\n\x05\x66inal\x18\x04 \x01(\x08\x12\x12\n\x06shared\x18\x05 \x01(\x08\x42\x02\x18\x01\x12\x1e\n\x10\x63pp_has_def_ctor\x18\x06 \x01(\x08:\x04true\x12\x1f\n\x17\x63pp_has_trivial_defctor\x18\x0c \x01(\x08\x12\x1c\n\x14\x63pp_has_trivial_dtor\x18\r \x01(\x08\x12!\n\x13\x63pp_has_public_dtor\x18\t \x01(\x08:\x04true\x12\x12\n\nasync_dtor\x18\n \x01(\x08\x12\x1a\n\x0c\x63pp_copyable\x18\x07 \x01(\x08:\x04true\x12\x14\n\x0c\x63pp_abstract\x18\x08 \x01(\x08\x12.\n\tcpp_bases\x18\x0b \x03(\x0b\x32\x1b.clif.protos.ClassDecl.Base\x1a\x39\n\x04\x42\x61se\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x10\n\x08\x66ilename\x18\x03 \x01(\t"\x84\x01\n\x08\x45numDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name\x12"\n\x07members\x18\x02 \x03(\x0b\x32\x11.clif.protos.Name\x12\x12\n\nenum_class\x18\x03 \x01(\x08\x12\x1f\n\x04item\x18\x04 \x01(\x0b\x32\x11.clif.protos.Type"\x9b\x01\n\x07VarDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name\x12\x1f\n\x04type\x18\x02 \x01(\x0b\x32\x11.clif.protos.Type\x12&\n\x07\x63pp_get\x18\x03 \x01(\x0b\x32\x15.clif.protos.FuncDecl\x12&\n\x07\x63pp_set\x18\x04 \x01(\x0b\x32\x15.clif.protos.FuncDecl"\n\tConstDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name\x12\x1f\n\x04type\x18\x02 \x01(\x0b\x32\x11.clif.protos.Type\x12\r\n\x05value\x18\x03 \x01(\t"|\n\tParamDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name\x12\x1f\n\x04type\x18\x02 \x01(\x0b\x32\x11.clif.protos.Type\x12\x16\n\x0e\x63pp_exact_type\x18\x04 \x01(\t\x12\x15\n\rdefault_value\x18\x03 \x01(\t"\x85\x03\n\x08\x46uncDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name\x12&\n\x06params\x18\x02 \x03(\x0b\x32\x16.clif.protos.ParamDecl\x12'\n\x07returns\x18\x03 \x03(\x0b\x32\x16.clif.protos.ParamDecl\x12'\n\x07\x65xcepts\x18\x04 \x03(\x0b\x32\x16.clif.protos.Exception\x12\x10\n\x08postproc\x18\x05 \x01(\t\x12\x13\n\x0b\x63onstructor\x18\x12 \x01(\x08\x12\x13\n\x0b\x63lassmethod\x18\x0b \x01(\x08\x12\x13\n\x0bpy_keep_gil\x18\x0c \x01(\x08\x12\x0f\n\x07virtual\x18\x0f \x01(\x08\x12\x1b\n\x13ignore_return_value\x18\x10 \x01(\x08\x12\x17\n\x0f\x63pp_void_return\x18\r \x01(\x08\x12\x14\n\x0c\x63pp_noexcept\x18\x0e \x01(\x08\x12\x16\n\x0e\x63pp_opfunction\x18\x11 \x01(\x08\x12\x18\n\x10\x63pp_const_method\x18\x13 \x01(\x08".\n\x0b\x46orwardDecl\x12\x1f\n\x04name\x18\x01 \x01(\x0b\x32\x11.clif.protos.Name"(\n\x04Name\x12\x0e\n\x06native\x18\x01 \x01(\t\x12\x10\n\x08\x63pp_name\x18\x02 \x01(\t"\xc5\x02\n\x04Type\x12\x11\n\tlang_type\x18\x01 \x01(\t\x12\x10\n\x08\x63pp_type\x18\x02 \x01(\t\x12!\n\x06params\x18\x03 \x03(\x0b\x32\x11.clif.protos.Type\x12'\n\x08\x63\x61llable\x18\x04 \x01(\x0b\x32\x15.clif.protos.FuncDecl\x12\x1e\n\x10\x63pp_has_def_ctor\x18\x05 \x01(\x08:\x04true\x12\x1a\n\x0c\x63pp_copyable\x18\x06 \x01(\x08:\x04true\x12\x17\n\x0f\x63pp_raw_pointer\x18\x07 \x01(\x08\x12\x1c\n\x14\x63pp_toptr_conversion\x18\x08 \x01(\x08\x12 \n\x18\x63pp_touniqptr_conversion\x18\x0b \x01(\x08\x12\x14\n\x0c\x63pp_abstract\x18\t \x01(\x08\x12!\n\x13\x63pp_has_public_dtor\x18\n \x01(\x08:\x04true"*\n\tException\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07\x63hecked\x18\x02 \x01(\x08"3\n\tTypeTable\x12&\n\x08typemaps\x18\x01 \x03(\x0b\x32\x14.clif.protos.Typemap"F\n\x07Typemap\x12\x11\n\tlang_type\x18\x01 \x01(\t\x12\x10\n\x08\x63pp_type\x18\x02 \x03(\t\x12\x16\n\x0epostconversion\x18\x03 \x01(\t")\n\x05Macro\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\ndefinition\x18\x02 \x01(\x0c'
TypeError: new() got an unexpected keyword argument 'serialized_options'
tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/build.make:61: recipe for target 'tools/clif/python/utils/proto_util.cc' failed
make[3]: *** [tools/clif/python/utils/proto_util.cc] Error 1
CMakeFiles/Makefile2:44984: recipe for target 'tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/all' failed
make[2]: *** [tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/all] Error 2
CMakeFiles/Makefile2:44991: recipe for target 'tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/rule' failed
make[1]: *** [tools/clif/python/utils/CMakeFiles/clif_python_utils_proto_util.dir/rule] Error 2
Makefile:10300: recipe for target 'clif_python_utils_proto_util' failed
make: *** [clif_python_utils_proto_util] Error 2
I've attached the log file containing all stdout & stderr for INSTALL.sh.
Could you please show me how to solve it?
clif_install.log
Since CLIF is a "C++ wrapper generators for various languages." and a replacement of SWIG, I would like to have the Java (Java 8.0) support...
note: For google/or-tools we may use CLIF instead of SWIG but we need the Java support first !!!
I am having some trouble getting a package with inter-dependent modules to work. Everything builds fine, but upon load of the dependent module, I get undefined symbol errors for the dependencies.
I put together a minimal example based on the CLIF OSS samples wrappod/wrapfunc (attached). It can be built and run via the showme.sh script from within the wrapcomb directory.
Thanks!
After make successful. I got the file 'ast_pb2.py', but still some files missing below here.
cp "$BUILD_DIR/clif/python/utils/proto_util.cc" clif/python/utils/
cp "$BUILD_DIR/clif/python/utils/proto_util_clif.h" clif/python/utils/
cp "$BUILD_DIR/clif/python/utils/proto_util.init.cc" clif/python/utils/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.