Added option for compatibility with older glibc versions (experimental) [#METR-2944].

This commit is contained in:
Alexey Milovidov 2016-06-27 09:34:10 +03:00
parent cd0aa36dba
commit 30ce038312
2 changed files with 60 additions and 3 deletions

View File

@ -36,14 +36,29 @@ IF (NOT AARCH64)
SET(MACHINE_FLAGS "-msse4 -mpopcnt")
ENDIF()
SET(COMMON_WARNING_FLAGS "-Wall -Werror")
set (GLIBC_COMPATIBILITY FALSE CACHE BOOL "Set to TRUE to enable compatibility with older glibc libraries")
if ($ENV{GLIBC_COMPATIBILITY})
set (GLIBC_COMPATIBILITY TRUE)
endif()
if (GLIBC_COMPATIBILITY)
SET(GLIBC_COMPATIBILITY_COMPILE_FLAGS "-include ${ClickHouse_SOURCE_DIR}/libs/libcommon/include/common/glibc_compatibility.h")
SET(GLIBC_COMPATIBILITY_LINK_FLAGS "-Wl,--wrap=memcpy")
endif()
SET(CMAKE_BUILD_COLOR_MAKEFILE ON)
SET(CMAKE_CXX_FLAGS "-std=gnu++1y -Wall -Werror -Wnon-virtual-dtor ${MACHINE_FLAGS}")
SET(CMAKE_CXX_FLAGS "-std=gnu++1y ${COMMON_WARNING_FLAGS} -Wnon-virtual-dtor ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
SET(CMAKE_C_FLAGS "-Wall -Werror ${MACHINE_FLAGS}")
SET(CMAKE_C_FLAGS "${COMMON_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g")
SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${GLIBC_COMPATIBILITY_LINK_FLAGS}")
# cmake -DCMAKE_BUILD_TYPE=Debug ..
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")

View File

@ -0,0 +1,42 @@
/// Include this file with -include compiler parameter.
/// And add -Wl,--wrap=memcpy for linking.
#if defined (__cplusplus)
extern "C" {
#endif
#include <stdlib.h>
#include <sys/select.h>
inline long int __fdelt_chk(long int d)
{
if (d < 0 || d >= FD_SETSIZE)
abort();
return d / __NFDBITS;
}
#include <sys/poll.h>
inline int __poll_chk(struct pollfd * fds, nfds_t nfds, int timeout, __SIZE_TYPE__ fdslen)
{
if (fdslen / sizeof(*fds) < nfds)
abort();
return poll(fds, nfds, timeout);
}
void * __memcpy_glibc_2_2_5(void *, const void *, size_t);
__asm__(".symver __memcpy_glibc_2_2_5, memcpy@GLIBC_2.2.5");
inline void * __wrap_memcpy(void * dest, const void * src, size_t n)
{
return __memcpy_glibc_2_2_5(dest, src, n);
}
#if defined (__cplusplus)
}
#endif