wahern / cqueues

Continuation Queues: Embeddable asynchronous networking, threading, and notification framework for Lua on Unix.
http://25thandclement.com/~william/projects/cqueues.html
MIT License
244 stars 37 forks source link

failed build on mac os 10.14.6 #227

Closed chengkai-jia closed 5 years ago

chengkai-jia commented 5 years ago
http 0.3-0 depends on cqueues >= 20161214 (not installed)
Installing https://luarocks.org/cqueues-20190731.51-0.src.rock
enabling Lua 5.1
cp /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/config.h.guess /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/config.h
cd /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src && m4 /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/errno.c.m4 >| /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/errno.c.tmp
cp /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/config.h /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/config.h
cp /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/config.h /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/config.h
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -std=gnu99 -fPIC -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused -Wno-dollar-in-identifier-extension -Wno-deprecated-declarations -O2 -fPIC -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -DSOCKET_DEBUG -DHAVE_CONFIG_H -DDNS_RANDOM=arc4random -c -o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/socket.o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/socket.c
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -std=gnu99 -fPIC -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused -Wno-dollar-in-identifier-extension -Wno-deprecated-declarations -O2 -fPIC -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -DSOCKET_DEBUG -DHAVE_CONFIG_H -DDNS_RANDOM=arc4random -c -o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/dns.o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/dns.c
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -std=gnu99 -fPIC -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused -Wno-dollar-in-identifier-extension -Wno-deprecated-declarations -O2 -fPIC -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -DSOCKET_DEBUG -DHAVE_CONFIG_H -DDNS_RANDOM=arc4random -c -o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/notify.o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/lib/notify.c
mv /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/errno.c.tmp /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/errno.c
mkdir -p /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/5.1
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -std=gnu99 -fPIC -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused -Wno-dollar-in-identifier-extension -Wno-deprecated-declarations -O2 -fPIC -DLUA_COMPAT_APIINTCASTS -I/usr/local/Cellar/openresty@1.13.6.2/1.13.6.2/openresty/luajit/include/luajit-2.1 -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -DCOMPAT53_PREFIX=cqueues -DCQUEUES_VENDOR='"quae@daurnimator.com"' -DCQUEUES_VERSION=20190731L  -c -o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/5.1/cqueues.o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/cqueues.c
mkdir -p /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/5.1
/private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/cqueues.c:145:8: error: redefinition of enumerator '_CLOCK_REALTIME'
enum { CLOCK_REALTIME = 0 };
       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:154:24: note: expanded from macro 'CLOCK_REALTIME'
#define CLOCK_REALTIME _CLOCK_REALTIME
                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:153:1: note: previous definition is here
_CLOCK_REALTIME __CLOCK_AVAILABILITY = 0,
^
/private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/cqueues.c:148:8: error: redefinition of enumerator '_CLOCK_MONOTONIC'
enum { CLOCK_MONOTONIC = 6 };
       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:156:25: note: expanded from macro 'CLOCK_MONOTONIC'
#define CLOCK_MONOTONIC _CLOCK_MONOTONIC
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:155:1: note: previous definition is here
_CLOCK_MONOTONIC __CLOCK_AVAILABILITY = 6,
^
/private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/cqueues.c:152:13: error: typedef redefinition with different types ('int' vs 'enum clockid_t')
typedef int clockid_t;
            ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:171:3: note: previous definition is here
} clockid_t;
  ^
3 errors generated.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -std=gnu99 -fPIC -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused -Wno-dollar-in-identifier-extension -Wno-deprecated-declarations -O2 -fPIC -DLUA_COMPAT_APIINTCASTS -I/usr/local/Cellar/openresty@1.13.6.2/1.13.6.2/openresty/luajit/include/luajit-2.1 -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -I"/usr/local/opt/openresty@1.13.6.2/openssl/include" -DCOMPAT53_PREFIX=cqueues -DCQUEUES_VENDOR='"quae@daurnimator.com"' -DCQUEUES_VERSION=20190731L  -c -o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/5.1/socket.o /private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/socket.c
make: *** [/private/tmp/luarocks_cqueues-20190731.51-0-DaYJZR/cqueues-rel-20190731/src/5.1/cqueues.o] Error 1
make: *** Waiting for unfinished jobs....

Error: Failed installing dependency: https://luarocks.org/http-0.3-0.src.rock - Failed installing dependency: https://luarocks.org/cqueues-20190731.51-0.src.rock - Build error: Failed building.

HOMEBREW_VERSION: 2.1.9 ORIGIN: https://github.com/Homebrew/brew.git HEAD: 3dab11263c7d3ae568bd585932b393ef526fc5b2 Last commit: 4 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: c9f348993918281b1feab396e4652ef36e7952b0 Core tap last commit: 6 hours ago HOMEBREW_PREFIX: /usr/local HOMEBREW_CACHE: /Users/k24k20190715/Library/Caches/Homebrew HOMEBREW_LOGS: /Users/k24k20190715/Library/Logs/Homebrew CPU: octa-core 64-bit kabylake Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Clang: 10.0 build 1001 Git: 2.22.0 => /usr/local/bin/git Curl: 7.54.0 => /usr/bin/curl Java: 1.8.0_212 macOS: 10.14.6-x86_64 CLT: 10.3.0.0.1.1562985497 Xcode: N/A CLT headers: 10.3.0.0.1.1562985497

HOMEBREW_CC: clang HOMEBREW_CXX: clang++ MAKEFLAGS: -j8 CMAKE_PREFIX_PATH: /usr/local CMAKE_INCLUDE_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2:/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers CMAKE_LIBRARY_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries PKG_CONFIG_PATH: /usr/local/opt/libyaml/lib/pkgconfig PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14 HOMEBREW_GIT: git HOMEBREW_SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk ACLOCAL_PATH: /usr/local/share/aclocal PATH: /usr/local/Homebrew/Library/Homebrew/shims/mac/super:/usr/local/opt/coreutils/bin:/usr/local/opt/openresty@1.13.6.2/bin:/usr/bin:/bin:/usr/sbin:/sbin

daurnimator commented 5 years ago

It looks like apple finally caught up with the world and added CLOCK_REALTIME. Try passing CFLAGS="-O2 -fPIC -DHAVE_DECL_CLOCK_REALTIME=1" to luarocks to override cqueues's feature guessing.

chengkai-jia commented 5 years ago

I got this issue when installing kong by homebrew. I‘m not sure how to pass CFLAGS to work around it...

SunshineYang commented 5 years ago

try to execute export CPPFLAGS="-DCLOCK_MONOTONIC -DCLOCK_REALTIME" first . cqueues's feature guessing is not compatible on mac os .

vcunat commented 5 years ago

The last pair of flags fixed compilation for "me" (NixPkgs, not Homebrew).

daurnimator commented 5 years ago

I think I understand the source of the issues now. In this commit I applied

-#define HAVE_DECL_CLOCK_REALTIME (defined CLOCK_REALTIME)
+#ifdef CLOCK_REALTIME
+#define HAVE_DECL_CLOCK_REALTIME 1
+#else
+#define HAVE_DECL_CLOCK_REALTIME 0
+#endif

As "expansion-to-defined" is not a well specified C behaviour. However, it used to get expanded in cqueues.c where the relevant header had already been included. vs now it gets expanded earlier.