naver/arcus

OS X Yosemite 에서 arcus build 문제

whchoi83 opened this issue · 5 comments

현재 OS X Yosemite 버전에서 arcus build 시 문제가 발생합니다.

arcus-memcached 에서는 아래와 같은 문제가 발생하며

In file included from config_parser.c:27:
./include/memcached/util.h:43:9: error: 'htonll' macro redefined [-Werror,-Wmacro-redefined]
#define htonll mc_htonll
        ^
/usr/include/sys/_endian.h:141:9: note: previous definition is here
#define htonll(x)       __DARWIN_OSSwapInt64(x)
        ^
In file included from config_parser.c:27:
./include/memcached/util.h:44:9: error: 'ntohll' macro redefined [-Werror,-Wmacro-redefined]
#define ntohll mc_ntohll
        ^
/usr/include/sys/_endian.h:140:9: note: previous definition is here
#define ntohll(x)       __DARWIN_OSSwapInt64(x)
        ^
2 errors generated.
make[2]: *** [config_parser.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

zookeeper 의 경우 아래와 같은 문제가 발생합니다.

./include/recordio.h:76:9: error: expected ')'
int64_t htonll(int64_t v);
        ^
/usr/include/sys/_endian.h:141:25: note: expanded from macro 'htonll'
#define htonll(x)       __DARWIN_OSSwapInt64(x)
                        ^
/usr/include/libkern/_OSByteOrder.h:78:30: note: expanded from macro '__DARWIN_OSSwapInt64'
    (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
                             ^
./include/recordio.h:76:9: note: to match this '('
/usr/include/sys/_endian.h:141:25: note: expanded from macro 'htonll'
#define htonll(x)       __DARWIN_OSSwapInt64(x)
                        ^
/usr/include/libkern/_OSByteOrder.h:78:5: note: expanded from macro '__DARWIN_OSSwapInt64'
    (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
    ^
In file included from src/zookeeper.c:27:
In file included from ./include/zookeeper.h:34:
./include/recordio.h:76:9: error: conflicting types for '__builtin_constant_p'
int64_t htonll(int64_t v);
        ^
/usr/include/sys/_endian.h:141:25: note: expanded from macro 'htonll'
#define htonll(x)       __DARWIN_OSSwapInt64(x)
                        ^
/usr/include/libkern/_OSByteOrder.h:78:6: note: expanded from macro '__DARWIN_OSSwapInt64'
    (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
     ^
./include/recordio.h:76:9: note: '__builtin_constant_p' is a builtin with type 'int ()'
/usr/include/sys/_endian.h:141:25: note: expanded from macro 'htonll'
#define htonll(x)       __DARWIN_OSSwapInt64(x)
                        ^
/usr/include/libkern/_OSByteOrder.h:78:6: note: expanded from macro '__DARWIN_OSSwapInt64'
    (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
     ^
2 errors generated.
make[1]: *** [zookeeper.lo] Error 1
make: *** [all] Error 2

두 경우 모두 OS X Yosemite 버전에서 아래와 같이 사용하기 때문에 발생합니다.

#define htonll(x)       __DARWIN_OSSwapInt64(x)
#define ntohll(x)       __DARWIN_OSSwapInt64(x)

zookeeper 의 경우 zookeeper issue:commit 을 적용하여 해결할 수 있습니다.

arcus-memcached 의 경우 include/memcached/util.h 에서
기존 내용에서

42 #ifndef HAVE_HTONLL
43 #define htonll mc_htonll
44 #define ntohll mc_ntohll

아래 내용으로 변경하면 해결 가능합니다.

42 #ifndef HAVE_HTONLL
43 #undef htonll
44 #undef ntohll
45 #define htonll mc_htonll
46 #define ntohll mc_ntohll

단 undef 후에 다시 define 해서 사용할 경우 (__DARWIN_OSSwapInt64(x)을 사용하지 않게 할 경우) 문제가 없는지 검증이 필요합니다.

Mavericks 버전에서는 이런 이슈가 없었던 걸로 기억나는 데,
Yosemite 버전에서 새로 발생한 문제인가 보네요..

memcached의 configure.ac에는
해당 OS에서 htonll() 함수 제공 여부를 검사하는 부분이 있습니다.

Yosemite에서는 /usr/include/sys/_endian.h 파일에 define이 있는 상태이므로,
이러한 header 파일을 incldue하여 htonll() 제공 여부를 검사하도록 해 보았으면 합니다.

즉, configure.ac 파일에 아래 내용이 있는 데,
<sys/_endian.h>를 include하는 line을 추가하여 compile해 보았으면 합니다.

AC_DEFUN([AC_C_HTONLL],
[
    AC_MSG_CHECKING([for htonll])
    have_htoll="no"
    AC_RUN_IFELSE([
       AC_LANG_PROGRAM([
#include <sys/types.h>
#include <netinet/in.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h> */
#endif
       ], [
          return htonll(0);
       ])
    ], [
      have_htoll="yes"
      AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])
    ])

    AC_MSG_RESULT([$have_htoll])
])

AC_C_HTONLL

arcus-zookeeper의 경우엔, 향후에 base ZooKeeper의 버전을 올리는 것으로 해결해야 할 것 같습니다.

configure.ac 파일을 수정했는데도 build 가 되지 않아 자세히 살펴봤는데 특이한 점이 있습니다.
/usr/include/sys/_endian.h header file 의 경우 OS X Yosemite 의 netinet/in.h 에서 참조하고 있습니다.
configure 시에도

checking for socklen_t... yes
checking for htonll... yes
checking for library containing pthread_create... none required

로 출력됩니다.

하지만 HAVE_HTONLL 이 1로 define 되지 않는 것인지 계속 에러가 발생합니다.

arcus-memcached 문제는 해결 완료했습니다.
commit : naver/arcus-memcached@64a0364