编译时报错如下:
In file included from $HOME/opt/workspace/doris/incubator-doris/thirdparty/src/llvm-3.4.2.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:196:0:
$HOME/opt/workspace/doris/incubator-doris/thirdparty/src/llvm-3.4.2.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:307:72: error: size of array 'assertion_failed__1093' is negative
typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
^
$HOME/opt/workspace/doris/incubator-doris/thirdparty/src/llvm-3.4.2.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:301:30: note: in expansion of macro 'IMPL_COMPILER_ASSERT'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
^~~~~~~~~~~~~~~~~~~~
$HOME/opt/workspace/doris/incubator-doris/thirdparty/src/llvm-3.4.2.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1472:3: note: in expansion of macro 'COMPILER_CHECK'
COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
^~~~~~~~~~~~~~
$HOME/opt/workspace/doris/incubator-doris/thirdparty/src/llvm-3.4.2.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:1093:1: note: in expansion of macro 'CHECK_TYPE_SIZE'
CHECK_TYPE_SIZE(__kernel_fd_set);
看上去似乎是有点静态检查失败了。
看一下__kernel_fd_set
的定义:$GCCHOME/include/linux/posix_types.h
#undef __NFDBITS
#define __NFDBITS (8 * sizeof(unsigned long))
#undef __FD_SETSIZE
#define __FD_SETSIZE 51200
#undef __FDSET_LONGS
#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
#undef __FDELT
#define __FDELT(d) ((d) / __NFDBITS)
#undef __FDMASK
#define __FDMASK(d) (1UL << ((d) % __NFDBITS))
typedef struct {
unsigned long fds_bits [__FDSET_LONGS];
} __kernel_fd_set;
果然最大fd
数量是 51200
在能编译过的机器(ubuntu 18.04)上这个值是: 1024
#undef __FD_SETSIZE
#define __FD_SETSIZE 1024
typedef struct {
unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))];
} __kernel_fd_set;
然后修改一下__sanitizer___kernel_fd_set
typedef struct {
unsigned long fds_bits[1024 / (8 * sizeof(long))];
} __sanitizer___kernel_fd_set;
改好之后,就能编译了