chaincodelabs / libmultiprocess

C++ library and code generator making it easy to call functions and reference objects in different processes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error: 'Proxy' has no member named 'include'

dongcarl opened this issue · comments

I've wiped away my libmultiprocess repo and tried to build and install it again, but am running into problems.

$ cmake ..
-- The CXX compiler identification is GNU 10.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/dongcarl/.local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- 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 C++ include kj/filesystem.h
-- Looking for C++ include kj/filesystem.h - found
-- Performing Test HAVE_PTHREAD_GETNAME_NP
-- Performing Test HAVE_PTHREAD_GETNAME_NP - Success
-- Performing Test HAVE_PTHREAD_THREADID_NP
-- Performing Test HAVE_PTHREAD_THREADID_NP - Failed
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP - Failed
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dongcarl/src/libmultiprocess/build
$ make -j(nproc)
[ 14%] Compiling Cap'n Proto schema include/mp/proxy.capnp
Scanning dependencies of target multiprocess
[ 28%] Building CXX object CMakeFiles/multiprocess.dir/include/mp/proxy.capnp.c++.o
[ 42%] Building CXX object CMakeFiles/multiprocess.dir/src/mp/util.cpp.o
[ 57%] Building CXX object CMakeFiles/multiprocess.dir/src/mp/proxy.cpp.o
[ 71%] Linking CXX static library libmultiprocess.a
[ 71%] Built target multiprocess
Scanning dependencies of target mpgen
[ 85%] Building CXX object CMakeFiles/mpgen.dir/src/mp/gen.cpp.o
/home/dongcarl/src/libmultiprocess/src/mp/gen.cpp: In function ‘void Generate(kj::StringPtr, kj::StringPtr, kj::StringPtr, kj::ArrayPtr<const kj::StringPtr>)’:
/home/dongcarl/src/libmultiprocess/src/mp/gen.cpp:166:77: warning: ‘capnp::ParsedSchema capnp::SchemaParser::parseDiskFile(kj::StringPtr, kj::StringPtr, kj::ArrayPtr<const kj::StringPtr>) const’ is deprecated [-Wdeprecated-declarations]
  166 |     auto file_schema = parser.parseDiskFile(src_file, src_file, import_paths);
      |                                                                             ^
In file included from /home/dongcarl/src/libmultiprocess/src/mp/gen.cpp:9:
/usr/include/capnp/schema-parser.h:101:16: note: declared here
  101 |   ParsedSchema parseDiskFile(kj::StringPtr displayName, kj::StringPtr diskPath,
      |                ^~~~~~~~~~~~~
[100%] Linking CXX executable mpgen
[100%] Built target mpgen
$ make -j(nproc) check
[ 35%] Built target multiprocess
[ 50%] Built target mpgen
[ 57%] Generating src/mp/test/foo.capnp.h, src/mp/test/foo.capnp.c++, src/mp/test/foo.capnp.proxy.h, src/mp/test/foo.capnp.proxy-server.c++, src/mp/test/foo.capnp.proxy-client.c++, src/mp/test/foo.capnp.proxy-types.c++, src/mp/test/foo.capnp.proxy-types.h
/home/dongcarl/src/libmultiprocess/test/src/mp/test/foo.capnp:11:8-15: error: 'Proxy' has no member named 'include'
/home/dongcarl/src/libmultiprocess/test/src/mp/test/foo.capnp:12:8-20: error: 'Proxy' has no member named 'includeTypes'
terminate called after throwing an instance of 'std::runtime_error'
  what():  Invoking /usr/bin/capnp failed
make[3]: *** [test/CMakeFiles/mptest.dir/build.make:82: test/src/mp/test/foo.capnp.h] Aborted (core dumped)
make[2]: *** [CMakeFiles/Makefile2:578: test/CMakeFiles/mptest.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:207: test/CMakeFiles/check.dir/rule] Error 2
make: *** [Makefile:209: check] Error 2

I get the same error when doing make -j1 check...

$ git rev-parse HEAD
d576d975debdc9090bd2582f83f49c76c0061698
$ pacman -Qi capnproto | grep '^Version'
Version         : 0.8.0-1
$ pacman -Qi cmake | grep '^Version'
Version         : 3.19.2-1

Jonatack reported a similar problem bitcoin/bitcoin#19160 (comment), but it was fixed by doing a clean build.

I think this can only happen if you have a proxy.capnp that doesn't have the new include and includeProxy directives

annotation include(file): Text;
annotation includeTypes(file): Text;
# Extra include paths to add to generated files.
added in #43.

I'm not sure why these would be missing if you have a clean checkout and build. Is it possible you ran make install previously and it is picking up a proxy.capnp installed somewhere else on your system? Hopefully it isn't this since I would want the local proxy.capnp to take precedence over an external one, but it's something to check.

make VERBOSE=1 check output could be useful to see what the include order is. For me it does seem like local include directory is listed before the install include directory

[ 57%] Generating src/mp/test/foo.capnp.h, src/mp/test/foo.capnp.c++, src/mp/test/foo.capnp.proxy.h, src/mp/test/foo.capnp.proxy-server.c++, src/mp/test/foo.capnp.proxy-client.c++, src/mp/test/foo.capnp.proxy-types.c++, src/mp/test/foo.capnp.proxy-types.h
cd /home/russ/src/libmultiprocess/build/test && ../mpgen /home/russ/src/libmultiprocess/test /home/russ/src/libmultiprocess/test/src /home/russ/src/libmultiprocess/test/src/mp/test/foo.capnp /home/russ/src/libmultiprocess/include /home/russ/src/capnp/c++/prefix/include

but I don't recall exactly how these are processsed

I see the code is actually hardcoding install paths before command line paths, so the following change might fix the problem without having to clear a previous install:

diff --git a/src/mp/gen.cpp b/src/mp/gen.cpp
index 4a0c1cc..36ba16a 100644
--- a/src/mp/gen.cpp
+++ b/src/mp/gen.cpp
@@ -598,6 +598,9 @@ int main(int argc, char** argv)
     auto fs = kj::newDiskFilesystem();
     auto cwd = fs->getCurrentPath();
 #endif
+    for (size_t i = 4; i < argc; ++i) {
+        import_paths.push_back(argv[i]);
+    }
     for (const char* path : {CMAKE_INSTALL_PREFIX "/include", capnp_PREFIX "/include"}) {
 #ifdef HAVE_KJ_FILESYSTEM
         KJ_IF_MAYBE(dir, fs->getRoot().tryOpenSubdir(cwd.evalNative(path))) { import_paths.emplace_back(path); }
@@ -605,9 +608,6 @@ int main(int argc, char** argv)
         import_paths.emplace_back(path);
 #endif
     }
-    for (size_t i = 4; i < argc; ++i) {
-        import_paths.push_back(argv[i]);
-    }
     Generate(argv[1], argv[2], argv[3], {import_paths.data(), import_paths.size()});
     return 0;
 }

I'm not sure why these would be missing if you have a clean checkout and build. Is it possible you ran make install previously and it is picking up a proxy.capnp installed somewhere else on your system? Hopefully it isn't this since I would want the local proxy.capnp to take precedence over an external one, but it's something to check.

Yes I think that is the case! My /usr/local/include/mp/proxy.capnp does not have the 2 new lines:

--- /usr/local/include/mp/proxy.capnp	2020-12-09 11:56:57.000000000 -0500
+++ /home/dongcarl/src/libmultiprocess/include/mp/proxy.capnp	2021-02-16 15:19:23.480285524 -0500
@@ -7,6 +7,10 @@
 using Cxx = import "/capnp/c++.capnp";
 $Cxx.namespace("mp");
 
+annotation include(file): Text;
+annotation includeTypes(file): Text;
+# Extra include paths to add to generated files.
+
 annotation wrap(interface, struct): Text;
 # Wrap capnp interface generating ProxyClient / ProxyServer C++ classes that
 # forward calls to a C++ interface with same methods and parameters. Text

I will try your diff to src/mp/gen.cpp and see if that works. It worked! make check passed and a subsequent make install made the aforementioned diff disappear. Probably a good idea to push it to master?

Friendly ping! ☺️

Friendly ping! ☺️

Sorry for delay. Merged fix above in #47. Thanks for finding the issue and testing the fix!