steve-o / openpgm

Automatically exported from code.google.com/p/openpgm
57 stars 44 forks source link

Will not compile on MacOS 10.14.6 #65

Closed Jeducious closed 4 years ago

Jeducious commented 4 years ago

Hi there :)

My purpose for using openpgm is I would like to compile libzmq with the option to use openpgm. We're building a distributed compute platform called Crowdrender. The project will be open source and we are building a discovery mechanism for worker nodes to find clients, multicast seems like a great way to do this and since we're already using zmq, I'd like to not revenant the wheel and use their EPGM and PGM protocol support.

The problem is, on macOS I cannot get openpgm to compile and so far I have not found any built binaries for MacOS either. I tried using Cmake and generating a project for Xcode, and I also installed Scons and tried to compile but both methods fail in more or less the same way.

First, IPV6_PKTINFO has apparently been deprecated, if you look at the macOS SDK, in usr/include/netinet6.in6.h you'll find the following;

#if 0 /* obsoleted during 2292bis -> 3542 */
/* no data; ND reachability confirm (cmsg only/not in of RFC3542) */
#define IPV6_REACHCONF          45
#endif
/* more new socket options introduced in RFC3542 */
#define IPV6_3542PKTINFO        46 /* in6_pktinfo; send if, src addr */
#define IPV6_3542HOPLIMIT       47 /* int; send hop limit */
#define IPV6_3542NEXTHOP        48 /* sockaddr; next hop addr */
#define IPV6_3542HOPOPTS        49 /* ip6_hbh; send hop-by-hop option */
#define IPV6_3542DSTOPTS        50 /* ip6_dest; send dst option befor rthdr */
#define IPV6_3542RTHDR          51 /* ip6_rthdr; send routing header */

#define **IPV6_PKTINFO**    IPV6_3542PKTINFO

This is a problem since in libpgm, the sockaddr.c file has a reference to this, which fails now when compiling

#ifdef IPV6_RECVPKTINFO
        retval = setsockopt (s, IPPROTO_IPV6, IPV6_RECVPKTINFO, (const char*)&optval, sizeof(optval));
#else
        retval = setsockopt (s, IPPROTO_IPV6, IPV6_PKTINFO, (const char*)&optval, sizeof(optval));
#endif

I should point out that sockaddr.c currently does not have a valid reference to IPV6_RECVPKTINFO as far as I can tell because it does not include netinet/in.h from the macOS SDK. So in Xcode this fails. Also it appeared that config.h was missing so a whole bunch of #defines were missing too. Building with Scons seemed to fix that problem though.

Anyway, the compilation progressed after I commented out the #else block of the define (see above). But then I ran into an error I could not progress past. In recv.c, on line 216

#if !defined(IP_PKTINFO) && !defined(IP_RECVDSTADDR)
#   error "No defined CMSG type for IPv4 destination address."
#endif

            if (IPPROTO_IPV6 == cmsg->cmsg_level && 
                IPV6_PKTINFO == cmsg->cmsg_type)

I get the following error from Scons:

gcc -o ref/debug-Darwin-x86_64/recv.o -c -pipe -Wall -Wextra -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Wno-inline -Wno-unused-function -pedantic -march=native -std=gnu99 -D_REENTRANT -DUSE_GALOIS_MUL_LUT -DHAVE_CONFIG_H -DPGM_DEBUG -ggdb -DGETTEXT_PACKAGE='"pgm"' -Iref/debug-Darwin-x86_64/include -Iinclude -Iinclude recv.c
warning: unknown warning option '-Wunsafe-loop-optimizations'; did you mean '-Wunavailable-declarations'? [-Wunknown-warning-option]
In file included from recv.c:40:
In file included from include/impl/framework.h:30:
In file included from include/pgm/atomic.h:46:
include/pgm/types.h:96:10: warning: keyword is hidden by macro definition [-Wkeyword-macro]
#       define restrict
               ^
recv.c:216:8: error: use of undeclared identifier 'IPV6_PKTINFO'
                            IPV6_PKTINFO == cmsg->cmsg_type)

So, to reproduce, all I need to do, is to git clone the project to a local directory, then run: Scons inside the folder where the Sconstruct script is. The result is that the compile begins, but then fails when I get to the first reference to IPV6_PKTINFO.

I did attempt to replace IPV6_PKTINFO with IPV6_RECVPKTINFO in recv.c since the code in sockaddr.c did suggest that IPV6_RECVPKTINFO is preferred, however, this did not work, an error referring to use of a undeclared identifier was generated, despite recv.c including netinet/in.h, which in turn includes netinet6.in6.h which contains IPV6_RECVPKTINFO.

So, I tried! But I failed :(

I'd really like to try getting pgm to work for macOS, and also do the same for win and linux since our software is going to be cross platform. However at the moment I have to divert time to working on other parts of our system. I really hope this issue will get picked up and worked on though, I am happy to spend some time working with the core contributors to find a solution.

Best Wishes

James

steve-o commented 4 years ago

Every macOS version appears to slightly break IPv6 a little. Generally all the platform fixes are in the tree and very much pending a new release. Let me check on the latest and report back.

On Thu, Jun 18, 2020 at 2:51 Jeducious notifications@github.com wrote:

Hi there :)

My purpose for using openpgm is I would like to compile libzmq https://github.com/zeromq/libzmq#build with the option to use openpgm. We're building a distributed compute platform called Crowdrender https://www.crowd-render.coml. The project will be open source and we are building a discovery mechanism for worker nodes to find clients, multicast seems like a great way to do this and since we're already using zmq, I'd like to not revenant the wheel and use their EPGM and PGM protocol support.

The problem is, on macOS I cannot get openpgm to compile and so far I have not found any built binaries for MacOS either. I tried using Cmake and generating a project for Xcode, and I also installed Scons and tried to compile but both methods fail in more or less the same way.

First, IPV6_PKTINFO has apparently been deprecated, if you look at the macOS SDK, in usr/include/netinet6.in6.h you'll find the following;

`#if 0 / obsoleted during 2292bis -> 3542 / /* no data; ND reachability confirm (cmsg only/not in of RFC3542)

/ #define IPV6_REACHCONF 45 #endif / more new socket options introduced in RFC3542 / #define IPV6_3542PKTINFO 46 / in6_pktinfo; send if, src addr / #define IPV6_3542HOPLIMIT 47 / int; send hop limit / #define IPV6_3542NEXTHOP 48 / sockaddr; next hop addr / #define IPV6_3542HOPOPTS 49 / ip6_hbh; send hop-by-hop option / #define IPV6_3542DSTOPTS 50 / ip6_dest; send dst option befor rthdr / #define IPV6_3542RTHDR 51 / ip6_rthdr; send routing header */

define IPV6_PKTINFO IPV6_3542PKTINFO`

This is a problem since in libpgm, the sockaddr.c file has a reference to this, which fails now when compiling

ifdef IPV6_RECVPKTINFO retval = setsockopt (s, IPPROTO_IPV6,

IPV6_RECVPKTINFO, (const char)&optval, sizeof(optval)); #else retval = setsockopt (s, IPPROTO_IPV6, IPV6_PKTINFO, (const char)&optval, sizeof(optval)); #endif

I should point out that sockaddr.c currently does not have a valid reference to IPV6_RECVPKTINFO as far as I can tell because it does not include netinet/in.h from the macOS SDK. So in Xcode this fails. Also it appeared that config.h was missing so a whole bunch of #defines were missing too. Building with Scons seemed to fix that problem though.

Anyway, the compilation progressed after I commented out the #else block of the define (see above). But then I ran into an error I could not progress past. In recv.c, on line 216

`#endif

if !defined(IP_PKTINFO) && !defined(IP_RECVDSTADDR)

error "No defined CMSG type for IPv4 destination address."

endif

  if (IPPROTO_IPV6 == cmsg->cmsg_level &&
      **IPV6_PKTINFO** == cmsg->cmsg_type)`

I get the following error from Scons:

`gcc -o ref/debug-Darwin-x86_64/recv.o -c -pipe -Wall -Wextra -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Wno-inline -Wno-unused-function -pedantic -march=native -std=gnu99 -D_REENTRANT -DUSE_GALOIS_MUL_LUT -DHAVE_CONFIG_H -DPGM_DEBUG -ggdb -DGETTEXT_PACKAGE='"pgm"' -Iref/debug-Darwin-x86_64/include -Iinclude -Iinclude recv.c warning: unknown warning option '-Wunsafe-loop-optimizations'; did you mean '-Wunavailable-declarations'? [-Wunknown-warning-option] In file included from recv.c:40: In file included from include/impl/framework.h:30: In file included from include/pgm/atomic.h:46: include/pgm/types.h:96:10: warning: keyword is hidden by macro definition [-Wkeyword-macro] define restrict

       ^

recv.c:216:8: error: use of undeclared identifier 'IPV6_PKTINFO' IPV6_PKTINFO == cmsg->cmsg_type)`

So, to reproduce, all I need to do, is to git clone the project to a local directory, then run: Scons inside the folder where the Sconstruct script is. The result is that the compile begins, but then fails when I get to the first reference to IPV6_PKTINFO.

I did attempt to replace IPV6_PKTINFO with IPV6_RECVPKTINFO in recv.c since the code in sockaddr.c did suggest that IPV6_RECVPKTINFO is preferred, however, this did not work, an error referring to use of a undeclared identifier was generated, despite recv.c including netinet/in.h, which in turn includes netinet6.in6.h which contains IPV6_RECVPKTINFO.

So, I tried! But I failed :(

I'd really like to try getting pgm to work for macOS, and also do the same for win and linux since our software is going to be cross platform. However at the moment I have to divert time to working on other parts of our system. I really hope this issue will get picked up and worked on though, I am happy to spend some time working with the core contributors to find a solution.

Best Wishes

James

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/steve-o/openpgm/issues/65, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7EQ4765CDOPMKIBWP4WLRXG2PHANCNFSM4OBIYZAA .

Jeducious commented 4 years ago

Thanks Steve :) I'll look forward to hearing from you then.

steve-o commented 4 years ago

Minor update: It builds with the SConstruct.OSX1011, but doesn't appear to receive any data.

On Thu, Jun 18, 2020 at 5:35 PM Jeducious notifications@github.com wrote:

Thanks Steve :) I'll look forward to hearing from you then.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/steve-o/openpgm/issues/65#issuecomment-646317886, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7EQ6V5W52RBVSXS6SCQLRXKCCZANCNFSM4OBIYZAA .

Jeducious commented 4 years ago

I saw that option in cmake, but wasn't sure if it referred to OS 10.11 or X11 xD given openPGM is about multicasting I probably should have guessed? Also Cmake showed that it had 'figured out' what OS it was building for, so I just built as is without touching any options at all.

I've found that uninformed tinkering always ends me up in trouble :)

Also I am a noob to Scons, can I try what you tried? I just type scons inside the dir with the Sconstruct script to do a 'normal' build, how do I built with Sconstruct.OSX1011? Is it

scons SConstruct.OSX1011

??

steve-o commented 4 years ago

IP/PGM works with send and received, UDP/PGM works send-only. Looks like macOS is blocking the receive. I need to test multiple hosts. Will push an update to the repo with minor fixes.

On Thu, Jun 18, 2020 at 7:28 PM Jeducious notifications@github.com wrote:

I saw that option in cmake, but wasn't sure if it referred to OS 10.11 or X11 xD given openPGM is about multicasting I probably should have guessed? Also Cmake showed that it had 'figured out' what OS it was building for, so I just built as is without touching any options at all.

I've found that uninformed tinkering always ends me up in trouble :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/steve-o/openpgm/issues/65#issuecomment-646354759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7EQ7HAEVE3RIWUISUKX3RXKPKPANCNFSM4OBIYZAA .

Jeducious commented 4 years ago

Ooooo so close! I'm keen to try again with the build when you think its good to go :)

steve-o commented 4 years ago

All working now. Don't forget to disable the firewall when testing, :(

On Thu, Jun 18, 2020 at 7:49 PM Jeducious notifications@github.com wrote:

Ooooo so close! I'm keen to try again with the build when you think its good to go :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/steve-o/openpgm/issues/65#issuecomment-646360494, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7EQZEV556PCF7C22F5ADRXKRZZANCNFSM4OBIYZAA .

Jeducious commented 4 years ago

Hi Steve, awesome, I'll test and get back to you. Is there a diff I can view? Would be great to learn what the problem was :)

steve-o commented 4 years ago

Just make sure to use the parameters inside SConstruct.OSX1015. The last commit basically cleans up the warnings from GCC updates and similar, nothing major. Your real blocker was not using the platform appropriate flags. Autoconf doesn't work out of the box on macOS and I don't have CMake installed on this platform, so only SCons is supported here.

https://github.com/steve-o/openpgm/commit/21d19837c63168afba62b434db494029a9c5927c