This commit is contained in:
Ivan Blinkov 2018-12-12 20:26:19 +03:00
commit c8abf91abe
7 changed files with 33 additions and 24 deletions

View File

@ -1,7 +1,5 @@
SET(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/base64) SET(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/base64)
set(base64_compile_instructions "")
LIST(LENGTH base64_compile_instructions 0)
macro(cast_to_bool var instruction) macro(cast_to_bool var instruction)
if (HAVE_${var}) if (HAVE_${var})
set(base64_${var} 1) set(base64_${var} 1)
@ -11,27 +9,20 @@ macro(cast_to_bool var instruction)
endif() endif()
endmacro() endmacro()
cast_to_bool(NEON32 "") # TODO flags
cast_to_bool(NEON64 "") # TODO flags
cast_to_bool(SSSE3 "-mssse3") cast_to_bool(SSSE3 "-mssse3")
cast_to_bool(SSE41 "-msse4.1") cast_to_bool(SSE41 "-msse4.1")
cast_to_bool(SSE42 "-msse4.2") cast_to_bool(SSE42 "-msse4.2")
cast_to_bool(AVX "-mavx") cast_to_bool(AVX "-mavx")
cast_to_bool(AVX2 "-mavx2") cast_to_bool(AVX2 "-mavx2")
# write config.h file, to include it in application
file(READ config-header.tpl header)
file(WRITE config.h ${header})
file(APPEND config.h "#define HAVE_SSSE3 ${base64_SSSE3}\n")
file(APPEND config.h "#define HAVE_SSE41 ${base64_SSE41}\n")
file(APPEND config.h "#define HAVE_SSE42 ${base64_SSE42}\n")
file(APPEND config.h "#define HAVE_AVX ${base64_AVX}\n")
file(APPEND config.h "#define HAVE_AVX2 ${base64_AVX2}\n")
set(HAVE_FAST_UNALIGNED_ACCESS 0) set(HAVE_FAST_UNALIGNED_ACCESS 0)
if (${base64_SSSE3} OR ${base64_SSE41} OR ${base64_SSE42} OR ${base64_AVX} OR ${base64_AVX2}) if(HAVE_SSSE3 OR HAVE_SSE41 OR HAVE_SSE42 OR HAVE_AVX OR HAVE_AVX2)
set(HAVE_FAST_UNALIGNED_ACCESS 1) set(HAVE_FAST_UNALIGNED_ACCESS 1)
endif () endif ()
file(APPEND config.h "#define HAVE_FAST_UNALIGNED_ACCESS " ${HAVE_FAST_UNALIGNED_ACCESS} "\n") configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_library(base64 ${LINK_MODE} add_library(base64 ${LINK_MODE}
${LIBRARY_DIR}/lib/lib.c ${LIBRARY_DIR}/lib/lib.c
@ -46,7 +37,7 @@ add_library(base64 ${LINK_MODE}
${LIBRARY_DIR}/lib/arch/ssse3/codec.c ${LIBRARY_DIR}/lib/arch/ssse3/codec.c
${LIBRARY_DIR}/lib/codecs.h ${LIBRARY_DIR}/lib/codecs.h
config.h) ${CMAKE_CURRENT_BINARY_DIR}/config.h)
target_compile_options(base64 PRIVATE ${base64_SSSE3_opt} ${base64_SSE41_opt} ${base64_SSE42_opt} ${base64_AVX_opt} ${base64_AVX2_opt}) target_compile_options(base64 PRIVATE ${base64_SSSE3_opt} ${base64_SSE41_opt} ${base64_SSE42_opt} ${base64_AVX_opt} ${base64_AVX2_opt})
target_include_directories(base64 PRIVATE ${LIBRARY_DIR}/include .) target_include_directories(base64 PRIVATE ${LIBRARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -1,2 +0,0 @@
#define HAVE_NEON32 0
#define HAVE_NEON64 0

View File

@ -0,0 +1,8 @@
#define HAVE_NEON32 @base64_NEON32@
#define HAVE_NEON64 @base64_NEON64@
#cmakedefine HAVE_SSSE3 @base64_SSSE3@
#cmakedefine HAVE_SSE41 @base64_SSE41@
#cmakedefine HAVE_SSE42 @base64_SSE42@
#cmakedefine HAVE_AVX @base64_AVX@
#cmakedefine HAVE_AVX2 @base64_AVX2@
#cmakedefine HAVE_FAST_UNALIGNED_ACCESS @HAVE_FAST_UNALIGNED_ACCESS@

View File

@ -291,6 +291,11 @@ target_include_directories (clickhouse_common_io BEFORE PRIVATE ${COMMON_INCLUDE
add_subdirectory (programs) add_subdirectory (programs)
add_subdirectory (tests) add_subdirectory (tests)
if (GLIBC_COMPATIBILITY AND NOT CLICKHOUSE_SPLIT_BINARY)
MESSAGE(STATUS "Some symbols from glibc will be replaced for compatibility")
target_link_libraries(dbms PUBLIC glibc-compatibility)
endif()
if (ENABLE_TESTS) if (ENABLE_TESTS)
macro (grep_gtest_sources BASE_DIR DST_VAR) macro (grep_gtest_sources BASE_DIR DST_VAR)
# Cold match files that are not in tests/ directories # Cold match files that are not in tests/ directories

View File

@ -71,7 +71,6 @@ DictionarySourceFactory::DictionarySourceFactory() : log(&Poco::Logger::get("Dic
void DictionarySourceFactory::registerSource(const std::string & source_type, Creator create_source) void DictionarySourceFactory::registerSource(const std::string & source_type, Creator create_source)
{ {
LOG_DEBUG(log, "Register dictionary source type `" + source_type + "`");
if (!registered_sources.emplace(source_type, std::move(create_source)).second) if (!registered_sources.emplace(source_type, std::move(create_source)).second)
throw Exception("DictionarySourceFactory: the source name '" + source_type + "' is not unique", ErrorCodes::LOGICAL_ERROR); throw Exception("DictionarySourceFactory: the source name '" + source_type + "' is not unique", ErrorCodes::LOGICAL_ERROR);
} }

View File

@ -83,10 +83,6 @@ else ()
message (WARNING "Non default allocator is disabled. This is not recommended for production Linux builds.") message (WARNING "Non default allocator is disabled. This is not recommended for production Linux builds.")
endif () endif ()
if (GLIBC_COMPATIBILITY)
set (GLIBC_COMPATIBILITY_LIBRARIES glibc-compatibility)
endif ()
if (USE_INTERNAL_MEMCPY) if (USE_INTERNAL_MEMCPY)
set (MEMCPY_LIBRARIES memcpy) set (MEMCPY_LIBRARIES memcpy)
endif () endif ()
@ -114,7 +110,6 @@ target_link_libraries (common
PRIVATE PRIVATE
${MALLOC_LIBRARIES} ${MALLOC_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${GLIBC_COMPATIBILITY_LIBRARIES}
${MEMCPY_LIBRARIES}) ${MEMCPY_LIBRARIES})
if (RT_LIBRARY) if (RT_LIBRARY)

View File

@ -1,10 +1,23 @@
/** We have to replace glibc getrandom only when glibc version is higher than 2.25.
* In previous versions of glibc this function doesn't exist
* and old kernels may be missing SYS_getrandom syscall.
*/
#include <features.h>
#if defined(__GLIBC__) && __GLIBC__ >= 2
# define GLIBC_MINOR __GLIBC_MINOR__
#elif defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 2
# define GLIBC_MINOR __GNU_LIBRARY_MINOR__
#endif
#if defined(GLIBC_MINOR) && GLIBC_MINOR >= 25
#include <unistd.h> #include <unistd.h>
#include <syscall.h> #include <syscall.h>
#include "syscall.h" #include "syscall.h"
ssize_t getrandom(void *buf, size_t buflen, unsigned flags) ssize_t getrandom(void *buf, size_t buflen, unsigned flags)
{ {
/// There was cancellable syscall (syscall_cp), but I don't care too. /// There was cancellable syscall (syscall_cp), but I don't care too.
return syscall(SYS_getrandom, buf, buflen, flags); return syscall(SYS_getrandom, buf, buflen, flags);
} }
#endif