richardhundt / shine

A Shiny Lua Dialect
Other
231 stars 18 forks source link

nanomsg support #53

Closed romix closed 10 years ago

romix commented 10 years ago

Richard,

You've experimented with ZeroMQ already. May be nanomsg could be used instead of ZeroMQ?

nanomsg claims to be nextgen ZeroMQ, fully POSIX API compliant, faster, written in C, MIT-licensed. And there are a few Lua bindings available.

richardhundt commented 10 years ago

On 4/7/14 12:04 AM, romix wrote:

Richard,

You've experimented with ZeroMQ already. May be nanomsg could be used instead of ZeroMQ?

Hell, I clearly haven't been paying attention. Yeah. This is exactly what I need. Small, clean, fast and written by the same guy.

ZeroMQ is already out of Shine anyway (the bindings are in a separate github repo now). Nanomsg will solve my threading library (I can ditch that stoopid Pipe implementation now).

Thanks for this.

romix commented 10 years ago

You're welcome! :-)

richardhundt commented 10 years ago

Initial support for nanomsg is in and integrated into the event loop. So nanomsg sockets can be mixed with regular sockets, and fibers as well as threads and nothing should block.

romix commented 10 years ago

Cool! Thanks!

But it does not build for me:

../boot/bin/shnc  -n "sys.thread"    sys/thread.shn   shine/build/sys_thread.o
../boot/bin/shnc  -n "sys.nanomsg"   sys/nanomsg.shn   shine/build/sys_nanomsg.o
tvmjit: .../shine/boot/src/shnc.raw:0: sys/nanomsg.shn: No such file or directory
stack traceback:
    [C]: in function 'assert'
    ...shine/boot/src/shnc.raw: in function 'start'
    ../boot/bin/shnc:2: in main chunk
    [C]: at 0x0100001680
make[1]: *** [shine/build/libs/sys.so] Error 1
richardhundt commented 10 years ago

On 4/7/14 9:23 PM, romix wrote:

Cool! Thanks!

But it does not build for me:

../boot/bin/shnc -n "sys.thread" sys/thread.shn shine/build/sys_thread.o ../boot/bin/shnc -n "sys.nanomsg" sys/nanomsg.shn shine/build/sys_nanomsg.o tvmjit: .../shine/boot/src/shnc.raw:0: sys/nanomsg.shn: No such file or directory stack traceback: [C]: in function 'assert' ...shine/boot/src/shnc.raw: in function 'start' ../boot/bin/shnc:2: in main chunk [C]: at 0x0100001680 make[1]: *\ [shine/build/libs/sys.so] Error 1

— Reply to this email directly or view it on GitHub https://github.com/richardhundt/shine/issues/53#issuecomment-39772268.

Try now?

romix commented 10 years ago

Yep. Works :-)

richardhundt commented 10 years ago

forgot to push earlier :(

dvv commented 10 years ago

notice that it does require to be compiled with -fPIC, or shine doesn't build

../boot/bin/shinec  -n "net.nanomsg" net/nanomsg.shn /home/dvv/projects/LUA/shine/build/net_nanomsg.o
cc -O2 -Wall -shared -fPIC -o /home/dvv/projects/LUA/shine/build/libs/net.so -lm -ldl \
/home/dvv/projects/LUA/shine/build/net_socket.o /home/dvv/projects/LUA/shine/build/net_http.o /home/dvv/projects/LUA/shine/build/net_uri.o \
/home/dvv/projects/LUA/shine/build/net_nanomsg.o  -Wl,--whole-archive /home/dvv/projects/LUA/shine/build/libnanomsg.a  -Wl,--no-whole-archive -Wl,-E
/usr/bin/ld: /home/dvv/projects/LUA/shine/build/libnanomsg.a(ep.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/dvv/projects/LUA/shine/build/libnanomsg.a(ep.o): error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:58: recipe for target '/home/dvv/projects/LUA/shine/build/libs/net.so' failed

I had to patch lib/Makefile

${DEPDIR}/nanomsg/Makefile:
  cd ${DEPDIR}/nanomsg && ./autogen.sh && CFLAGS='$(CFLAGS) -fPIC ' ./configure --prefix=${BUILD} --with-pic

to fix that.

[dvv@pagocmb lib]$ uname -a
Linux pagocmb 3.15.5-2-ARCH #1 SMP PREEMPT Fri Jul 11 07:56:02 CEST 2014 x86_64 GNU/Linux
[dvv@pagocmb lib]$ gcc --version
gcc (GCC) 4.9.1
richardhundt commented 10 years ago

I've bumped nanomsg submodule in master and it doesn't seem to be a problem on my ubuntu VM. Could you check if this patch is still needed?

dvv commented 10 years ago

will do. is there any nanomsg sample btw?

richardhundt commented 10 years ago

https://github.com/richardhundt/shine/blob/master/sample/thread.shn

dvv commented 10 years ago

cloned afresh. still

cc -O2 -Wall -shared -fPIC -o /home/dvv/projects/LUA/shine/build/libs/net.so -lm -ldl -pthread \
/home/dvv/projects/LUA/shine/build/net_socket.o /home/dvv/projects/LUA/shine/build/net_http.o /home/dvv/projects/LUA/shine/build/net_uri.o \
/home/dvv/projects/LUA/shine/build/net_nanomsg.o  -Wl,--whole-archive /home/dvv/projects/LUA/shine/build/libnanomsg.a  -Wl,--no-whole-archive -Wl,-E -lrt -lanl
/usr/bin/ld: /home/dvv/projects/LUA/shine/build/libnanomsg.a(libnanomsg_la-ep.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/dvv/projects/LUA/shine/build/libnanomsg.a(libnanomsg_la-ep.o): error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:58: recipe for target '/home/dvv/projects/LUA/shine/build/libs/net.so' failed
dvv commented 10 years ago
CFLAGS='$(CFLAGS) -fPIC ' 

is needed, seems.