From 4a481c857fa89d83263abf630053a74f5f65b21f Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Fri, 12 Feb 2016 16:30:55 +0100 Subject: [PATCH 1/7] Problem: socket limit is still 4K on Windows Solution: fix in CMakeLists.txt (already fixed in builds/msvc) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 669c5ff0..ebe4d89d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,8 +368,8 @@ set (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) # platform specifics if (WIN32) - # Socket limit is 4K (can be raised arbitrarily) - add_definitions (-DFD_SETSIZE=4096) + # Socket limit is 16K (can be raised arbitrarily) + add_definitions (-DFD_SETSIZE=16384) add_definitions (-D_CRT_SECURE_NO_WARNINGS) endif () From 8559770cf3fde90ba61ca01f9041679126aa5fd3 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Fri, 12 Feb 2016 16:32:07 +0100 Subject: [PATCH 2/7] Problem: in builds/gyp, socket limit is 4K on Windows Solution: raise to 16K --- builds/gyp/project.gyp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builds/gyp/project.gyp b/builds/gyp/project.gyp index 17d0e6d2..ed78fde5 100644 --- a/builds/gyp/project.gyp +++ b/builds/gyp/project.gyp @@ -22,7 +22,9 @@ [ 'OS=="win"', { 'defines': [ 'ZMQ_HAVE_WINDOWS=1', - 'ZMQ_STATIC' + 'ZMQ_STATIC', + 'FD_SETSIZE=16384', + '_CRT_SECURE_NO_WARNINGS' ], 'libraries': [ 'ws2_32', From 9bebd4dce963d8d7230f7baef41428acca3aa087 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Fri, 12 Feb 2016 17:29:36 +0100 Subject: [PATCH 3/7] Problem: local build should do its own .gitignore Solution: add .gitignore in builds/gyp --- .gitignore | 4 ---- builds/gyp/.gitignore | 5 +++++ builds/gyp/project.gyp | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 builds/gyp/.gitignore diff --git a/.gitignore b/.gitignore index 53a23470..899ad9f1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,6 @@ autom4te.cache *.html *.pdf *.ps -.* *~ .*~ curve_keygen @@ -170,6 +169,3 @@ zeromq-*.zip core build test-suite.log -project.Makefile -libzmq.target.mk -out/ diff --git a/builds/gyp/.gitignore b/builds/gyp/.gitignore new file mode 100644 index 00000000..9cd51481 --- /dev/null +++ b/builds/gyp/.gitignore @@ -0,0 +1,5 @@ +project.Makefile +*.mk +out/ +Makefile + diff --git a/builds/gyp/project.gyp b/builds/gyp/project.gyp index ed78fde5..f8323a0c 100644 --- a/builds/gyp/project.gyp +++ b/builds/gyp/project.gyp @@ -5,7 +5,6 @@ # # gyp --depth=. --format=make # make -# { 'includes': [ 'project-tests.gypi', @@ -21,7 +20,7 @@ 'conditions': [ [ 'OS=="win"', { 'defines': [ - 'ZMQ_HAVE_WINDOWS=1', + 'ZMQ_HAVE_WINDOWS', 'ZMQ_STATIC', 'FD_SETSIZE=16384', '_CRT_SECURE_NO_WARNINGS' @@ -34,12 +33,12 @@ }], [ 'OS=="mac"', { 'defines': [ - 'ZMQ_HAVE_OSX=1' + 'ZMQ_HAVE_OSX' ] }], [ 'OS=="linux"', { 'defines': [ - 'ZMQ_HAVE_LINUX=1' + 'ZMQ_HAVE_LINUX' ], 'libraries': [ '-lpthread' From c78e4f33a3f486765bd6809c0be2e467fd4de154 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Fri, 12 Feb 2016 22:16:35 +0100 Subject: [PATCH 4/7] Problem: if src/platform.hpp still exists, gyp uses this Gyp needs its own platform.hpp; there is no way to delete this file automatically. Solution: copy gyp's platform.hpp into src, so that things build properly no matter what the starting state. If you build with gyp and then try to build using autotools' makefile, you'll get an error from the platform.hpp. --- builds/gyp/platform.hpp | 5 +++++ builds/gyp/project.gyp | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/builds/gyp/platform.hpp b/builds/gyp/platform.hpp index ae3db3e3..0b50178d 100644 --- a/builds/gyp/platform.hpp +++ b/builds/gyp/platform.hpp @@ -33,6 +33,11 @@ // This file provides the configuration for Linux, Windows, and OS/X // as determined by ZMQ_HAVE_XXX macros passed from project.gyp +// Check that we're being called from our gyp makefile +#ifndef ZMQ_GYP_BUILD +# error "foreign platform.hpp detected, please re-configure" +#endif + // Set for all platforms #define ZMQ_HAVE_CURVE 1 #define ZMQ_USE_TWEETNACL 1 diff --git a/builds/gyp/project.gyp b/builds/gyp/project.gyp index f8323a0c..37130338 100644 --- a/builds/gyp/project.gyp +++ b/builds/gyp/project.gyp @@ -15,7 +15,10 @@ '.' ], 'defines': [ - 'ZMQ_CUSTOM_PLATFORM_HPP' + '_REENTRANT', + '_THREAD_SAFE', + 'ZMQ_CUSTOM_PLATFORM_HPP', + 'ZMQ_GYP_BUILD' ], 'conditions': [ [ 'OS=="win"', { @@ -264,6 +267,14 @@ '../../src/yqueue.hpp', '../../src/zmq.cpp', '../../src/zmq_utils.cpp' + ], + 'copies': [ + { + 'destination': '../../src', + 'files': [ + 'platform.hpp' + ] + } ] } ] From 3443da216f4773a1e28373c481b0bc611655b48a Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Sat, 13 Feb 2016 11:19:40 +0100 Subject: [PATCH 5/7] Problem: node-gyp defaults to -fno-rtti, which breaks libzmq Solution: override in project.gyp, for Linux and OS/X. --- builds/gyp/project.gyp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builds/gyp/project.gyp b/builds/gyp/project.gyp index 37130338..58c0a105 100644 --- a/builds/gyp/project.gyp +++ b/builds/gyp/project.gyp @@ -37,12 +37,18 @@ [ 'OS=="mac"', { 'defines': [ 'ZMQ_HAVE_OSX' - ] + ], + 'xcode_settings': { + 'GCC_ENABLE_CPP_RTTI': 'YES' + } }], [ 'OS=="linux"', { 'defines': [ 'ZMQ_HAVE_LINUX' ], + 'cflags_cc!': [ + '-fno-rtti' + ], 'libraries': [ '-lpthread' ] From 7129187f877317fe6af8a5ece3638782ceb0d602 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Sat, 13 Feb 2016 11:56:47 +0100 Subject: [PATCH 6/7] Problem: getting various warnings in tweetnacl libzmq used to switch off pedantic checks when using tweetnacl. As this is now the default, that means pedantic checks are always off. This is not good. Solution: in tweetnacl.c alone, use a GCC pragma to disable sign comparison warnings. We could also clean the code up yet this is simpler. In other code, we still want those warnings, hence I've used a pragma rather than global compile option. Second, use -Wno-long-long all the time, as this warning does not work with a pragma. I removed code that set -wno-long-long, for MinGW and Solaris. Related problem 2: --with-relaxed is badly named This option switches off pedantic checks, so should be called --disable-pedantic. 'with' is for optional packages. --- .gitignore | 3 +++ configure.ac | 26 ++++++-------------------- src/tweetnacl.c | 2 ++ src/tweetnacl.h | 1 + 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 899ad9f1..23c62096 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,9 @@ autom4te.cache *.ps *~ .*~ +.deps +.dirstamp +.libs curve_keygen test_heartbeats test_msg_ffn diff --git a/configure.ac b/configure.ac index 41590714..fc31404b 100644 --- a/configure.ac +++ b/configure.ac @@ -101,17 +101,9 @@ AC_RUN_IFELSE( AC_MSG_RESULT([$libzmq_tipc_support]) -AC_ARG_WITH([relaxed], - [AS_HELP_STRING([--with-relaxed], - [switch off pedantic compiler])], - [zmq_relaxed="yes"], - []) - -if test "x$zmq_relaxed" = "xyes"; then - libzmq_pedantic="no" -else - libzmq_pedantic="yes" -fi +AC_ARG_ENABLE([pedantic], + [AS_HELP_STRING([--disable-pedantic], [disable pedantic compiler checks [default=enabled]])], + [libzmq_pedantic=$enableval], [libzmq_pedantic=yes]) AC_ARG_WITH([militant], [AS_HELP_STRING([--with-militant], @@ -137,8 +129,8 @@ libzmq_on_android="no" libzmq_on_linux="no" libzmq_on_gnu="no" -# Set some default features required by 0MQ code. -CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" +# Set some default features required by ZeroMQ code +CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -Wno-long-long $CPPFLAGS" # For host type checks AC_CANONICAL_HOST @@ -255,10 +247,6 @@ case "${host_os}" in [AC_MSG_ERROR([cannot link with rpcrt4.dll.])]) AC_CHECK_LIB(iphlpapi, main, , [AC_MSG_ERROR([cannot link with iphlpapi.dll.])]) - # mingw defines __int64_t as long long - AC_LANG_PUSH([C++]) - LIBZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-long-long]) - AC_LANG_POP([C++]) libzmq_on_mingw="yes" libzmq_dso_visibility="no" @@ -434,7 +422,7 @@ AS_IF([test "x$with_libsodium" = "xyes"], [ AC_ARG_ENABLE([curve], AS_HELP_STRING([--disable-curve], [disable CURVE security [default=no]])) - +x if test "x$enable_curve" == "xno"; then curve_library="" AC_MSG_NOTICE([CURVE security is disabled]) @@ -450,7 +438,6 @@ elif test "x$with_libsodium" == "xyes"; then case "${host_os}" in *solaris*) LDFLAGS="-lssp $LDFLAGS" - CPPFLAGS="-Wno-long-long $CPPFLAGS" ;; esac else @@ -458,7 +445,6 @@ else AC_DEFINE(ZMQ_HAVE_CURVE, [1], [Using curve encryption]) AC_DEFINE(ZMQ_USE_TWEETNACL, [1], [Using tweetnacl for curve encryption]) curve_library="tweetnacl" - libzmq_pedantic="no" # Disable pedantic warnings fi AM_CONDITIONAL(USE_LIBSODIUM, test "$curve_library" == "libsodium") diff --git a/src/tweetnacl.c b/src/tweetnacl.c index 01cbb7e1..7fb4e76c 100644 --- a/src/tweetnacl.c +++ b/src/tweetnacl.c @@ -30,6 +30,8 @@ #include "platform.hpp" #if defined (ZMQ_USE_TWEETNACL) +#pragma GCC diagnostic ignored "-Wsign-compare" + #include "tweetnacl.h" #define FOR(i,n) for (i = 0;i < n;++i) diff --git a/src/tweetnacl.h b/src/tweetnacl.h index b152642e..4a292e01 100644 --- a/src/tweetnacl.h +++ b/src/tweetnacl.h @@ -31,6 +31,7 @@ #define TWEETNACL_H #include "platform.hpp" + #if defined (ZMQ_USE_TWEETNACL) #define crypto_box_SECRETKEYBYTES 32 From 94c7087e36ca7a005cf7476f9990280e4e202b17 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Wed, 17 Feb 2016 12:40:44 +0100 Subject: [PATCH 7/7] Problem: piece of garbage ended up in configure.ac Solution: remove it --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fc31404b..6663add7 100644 --- a/configure.ac +++ b/configure.ac @@ -422,7 +422,7 @@ AS_IF([test "x$with_libsodium" = "xyes"], [ AC_ARG_ENABLE([curve], AS_HELP_STRING([--disable-curve], [disable CURVE security [default=no]])) -x + if test "x$enable_curve" == "xno"; then curve_library="" AC_MSG_NOTICE([CURVE security is disabled])