chaincodelabs / libmultiprocess

C++ library and code generator making it easy to call functions and reference objects in different processes
MIT License
29 stars 20 forks source link

Build fail in bitcoin core on macOS #52

Closed promag closed 3 years ago

promag commented 3 years ago

Trying to build bitcoin/bitcoin@a3d7a9864b on macOS results in the following error:

➜  ipc-echo git:(pr/ipc-echo) make
Making all in src
  CXX      ipc/capnp/libbitcoin_ipc_a-echo.capnp.proxy-client.o
In file included from ipc/capnp/echo.capnp.proxy-client.c++:3:
In file included from ./ipc/capnp/echo.capnp.proxy-types.h:6:
./ipc/capnp/echo.capnp.proxy.h:17:35: error: use of undeclared identifier 'interfaces'
    static constexpr auto impl = &interfaces::Echo::echo;
                                  ^
./ipc/capnp/echo.capnp.proxy.h:57:103: error: use of undeclared identifier 'interfaces'
struct ProxyClient<ipc::capnp::messages::Echo> : public ProxyClientCustom<ipc::capnp::messages::Echo, interfaces::Echo>
                                                                                                      ^
./ipc/capnp/echo.capnp.proxy.h:60:11: error: 'ProxyClientCustom' is not a class, namespace, or enumeration
    using ProxyClientCustom::ProxyClientCustom;
          ^
/usr/local/include/mp/proxy.h:77:7: note: 'ProxyClientCustom' declared here
class ProxyClientCustom : public ProxyClientBase<Interface, Impl>
      ^
/usr/local/include/mp/proxy.h:163:14: error: implicit instantiation of undefined template 'mp::FunctionTraits<const auto>'
    : public FunctionTraits<decltype(ProxyMethod<MethodParams>::impl)>
             ^
/usr/local/include/mp/proxy.h:173:41: note: in instantiation of template class 'mp::ProxyMethodTraits<ipc::capnp::messages::Echo::EchoParams, void>' requested here
struct ProxyClientMethodTraits : public ProxyMethodTraits<MethodParams>
                                        ^
./ipc/capnp/echo.capnp.proxy.h:65:14: note: in instantiation of template class 'mp::ProxyClientMethodTraits<ipc::capnp::messages::Echo::EchoParams>' requested here
    typename M1::Result echo(M1::Param<0> echo);
             ^
/usr/local/include/mp/proxy.h:123:8: note: template is declared here
struct FunctionTraits;
       ^
In file included from ipc/capnp/echo.capnp.proxy-client.c++:3:
In file included from ./ipc/capnp/echo.capnp.proxy-types.h:6:
./ipc/capnp/echo.capnp.proxy.h:65:34: error: no template named 'Param' in 'mp::ProxyClientMethodTraits<ipc::capnp::messages::Echo::EchoParams>'
    typename M1::Result echo(M1::Param<0> echo);
                             ~~~~^
./ipc/capnp/echo.capnp.proxy.h:69:103: error: use of undeclared identifier 'interfaces'
struct ProxyServer<ipc::capnp::messages::Echo> : public ProxyServerCustom<ipc::capnp::messages::Echo, interfaces::Echo>
                                                                                                      ^
./ipc/capnp/echo.capnp.proxy.h:72:11: error: 'ProxyServerCustom' is not a class, namespace, or enumeration
    using ProxyServerCustom::ProxyServerCustom;
          ^
/usr/local/include/mp/proxy.h:115:8: note: 'ProxyServerCustom' declared here
struct ProxyServerCustom : public ProxyServerBase<Interface, Impl>
       ^
In file included from ipc/capnp/echo.capnp.proxy-client.c++:3:
In file included from ./ipc/capnp/echo.capnp.proxy-types.h:6:
./ipc/capnp/echo.capnp.proxy.h:74:31: error: unknown type name 'DestroyContext'
    kj::Promise<void> destroy(DestroyContext call_context) override;
                              ^
./ipc/capnp/echo.capnp.proxy.h:75:28: error: unknown type name 'EchoContext'
    kj::Promise<void> echo(EchoContext call_context) override;
                           ^
./ipc/capnp/echo.capnp.proxy.h:79:18: error: use of undeclared identifier 'interfaces'
struct ProxyType<interfaces::Echo>
                 ^
In file included from ipc/capnp/echo.capnp.proxy-client.c++:4:
In file included from /usr/local/include/mp/proxy-types.h:8:
/usr/local/include/mp/proxy-io.h:33:37: warning: parameter 'connection' shadows member inherited from type 'InvokeContext' [-Wshadow-field]
    ClientInvokeContext(Connection& connection, ThreadContext& thread_context)
                                    ^
/usr/local/include/mp/proxy-io.h:27:17: note: declared here
    Connection& connection;
                ^
/usr/local/include/mp/proxy-io.h:160:16: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
        return std::move(logger);
               ^
/usr/local/include/mp/proxy-io.h:160:16: note: remove std::move call here
        return std::move(logger);
               ^~~~~~~~~~      ~
ipc/capnp/echo.capnp.proxy-client.c++:10:1: error: no type named 'Result' in 'mp::ProxyClientMethodTraits<ipc::capnp::messages::Echo::EchoParams>'; did you mean 'echo_fields::Result'?
ProxyClient<ipc::capnp::messages::Echo>::M1::Result ProxyClient<ipc::capnp::messages::Echo>::echo(M1::Param<0> echo) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo_fields::Result
./ipc/capnp/echo.capnp.proxy.h:43:8: note: 'echo_fields::Result' declared here
struct Result
       ^
ipc/capnp/echo.capnp.proxy-client.c++:10:94: error: redefinition of 'echo' as different kind of symbol
ProxyClient<ipc::capnp::messages::Echo>::M1::Result ProxyClient<ipc::capnp::messages::Echo>::echo(M1::Param<0> echo) {
                                                                                             ^
./ipc/capnp/echo.capnp.proxy.h:65:25: note: previous definition is here
    typename M1::Result echo(M1::Param<0> echo);
                        ^
ipc/capnp/echo.capnp.proxy-client.c++:10:103: error: no member named 'Param' in 'mp::ProxyClientMethodTraits<ipc::capnp::messages::Echo::EchoParams>'
ProxyClient<ipc::capnp::messages::Echo>::M1::Result ProxyClient<ipc::capnp::messages::Echo>::echo(M1::Param<0> echo) {
                                                                                                  ~~~~^
ipc/capnp/echo.capnp.proxy-client.c++:10:112: error: use of undeclared identifier 'echo'; did you mean 'ecvt'?
ProxyClient<ipc::capnp::messages::Echo>::M1::Result ProxyClient<ipc::capnp::messages::Echo>::echo(M1::Param<0> echo) {
                                                                                                               ^~~~
                                                                                                               ecvt
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdlib.h:201:7: note: 'ecvt' declared here
char    *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
         ^
ipc/capnp/echo.capnp.proxy-client.c++:10:117: error: expected ';' after top level declarator
ProxyClient<ipc::capnp::messages::Echo>::M1::Result ProxyClient<ipc::capnp::messages::Echo>::echo(M1::Param<0> echo) {
                                                                                                                    ^
                                                                                                                    ;
In file included from ipc/capnp/echo.capnp.proxy-client.c++:4:
/usr/local/include/mp/proxy-types.h:1365:23: error: no member named 'm_context' in 'mp::ProxyClient<ipc::capnp::messages::Echo>'
    if (!proxy_client.m_context.connection) {
         ~~~~~~~~~~~~ ^
ipc/capnp/echo.capnp.proxy-client.c++:8:5: note: in instantiation of function template specialization 'mp::clientInvoke<mp::ProxyClient<ipc::capnp::messages::Echo>, capnp::Request<ipc::capnp::messages::Echo::DestroyParams, ipc::capnp::messages::Echo::DestroyResults> (ipc::capnp::messages::Echo::Client::*)(kj::Maybe<capnp::MessageSize>), mp::ClientParam<mp::Accessor<mp::echo_fields::Context, 17>> >' requested here
    clientInvoke(*this, &ipc::capnp::messages::Echo::Client::destroyRequest, MakeClientParam<Accessor<echo_fields::Context, FIELD_IN | FIELD_BOXED>>());
    ^
In file included from ipc/capnp/echo.capnp.proxy-client.c++:4:
/usr/local/include/mp/proxy-types.h:1370:64: error: no member named 'm_context' in 'mp::ProxyClient<ipc::capnp::messages::Echo>'
        g_thread_context.thread_name = ThreadName(proxy_client.m_context.connection->m_loop.m_exe_name);
                                                  ~~~~~~~~~~~~ ^
/usr/local/include/mp/proxy-types.h:1381:22: error: no member named 'm_context' in 'mp::ProxyClient<ipc::capnp::messages::Echo>'
        proxy_client.m_context.connection->m_loop.logPlain()
        ~~~~~~~~~~~~ ^
/usr/local/include/mp/proxy-types.h:1385:54: error: no member named 'm_context' in 'mp::ProxyClient<ipc::capnp::messages::Echo>'
    ClientInvokeContext invoke_context{*proxy_client.m_context.connection, g_thread_context};
                                        ~~~~~~~~~~~~ ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
make[2]: *** [ipc/capnp/libbitcoin_ipc_a-echo.capnp.proxy-client.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

I've followed 805eb73 build and install instructions.

On the bitcoin folder, I've made a fresh clone and configure.

ryanofsky commented 3 years ago

Thanks for reporting this!

Trying to build bitcoin/bitcoin@a3d7a98 on macOS results in the following error:

I am able to reproduce this, and this is caused by #43. The reason it happens is that the version of https://github.com/bitcoin/bitcoin/pull/19160 built here is a few months old, originally pushed 2020-11-24, and not compatible with the current version of libmultiprocess after #43.

There are three ways to fix it:

1) Update https://github.com/bitcoin/bitcoin/pull/19160 pull from a3d7a9864b1 pr/ipc-echo.19 to pr/ipc-echo.24 or newer.

2) Downgrade libmultiprocess from the version you have installed to an older version preceding PR #43

3) Apply the following changes manually:

git diff pr/ipc-echo.19..pr/ipc-echo.24 src/ipc/capnp/*.capnp
diff --git a/src/ipc/capnp/echo.capnp b/src/ipc/capnp/echo.capnp
index cedf6f2718e..1bdd81321ca 100644
--- a/src/ipc/capnp/echo.capnp
+++ b/src/ipc/capnp/echo.capnp
@@ -8,6 +8,8 @@ using Cxx = import "/capnp/c++.capnp";
 $Cxx.namespace("ipc::capnp::messages");

 using Proxy = import "/mp/proxy.capnp";
+$Proxy.include("interfaces/echo.h");
+$Proxy.include("ipc/capnp/echo.capnp.h");

 interface Echo $Proxy.wrap("interfaces::Echo") {
     destroy @0 (context :Proxy.Context) -> ();
diff --git a/src/ipc/capnp/init.capnp b/src/ipc/capnp/init.capnp
index 06f767b02c5..78f1c7f8cd9 100644
--- a/src/ipc/capnp/init.capnp
+++ b/src/ipc/capnp/init.capnp
@@ -9,6 +9,8 @@ $Cxx.namespace("ipc::capnp::messages");

 using Echo = import "echo.capnp";
 using Proxy = import "/mp/proxy.capnp";
+$Proxy.include("ipc/capnp/init.h");
+$Proxy.includeTypes("ipc/capnp/init-types.h");

 interface Init $Proxy.wrap("interfaces::Init") {
     construct @0 (threadMap: Proxy.ThreadMap) -> (threadMap :Proxy.ThreadMap);
promag commented 3 years ago

🤦 I thought I was on the latest version, not sure what happened as I usually fetch the latest version. Sorry for the noise!

ryanofsky commented 3 years ago

Not noise at all! Definitely could have provided clearer build errors here. I filed https://github.com/chaincodelabs/libmultiprocess/issues/54 to track this.