build fixes for GNU/kFreeBSD (#6992)

Summary:
Upstream https://salsa.debian.org/mariadb-team/mariadb-10.4/-/blob/master/debian/patches/rocksdb-kfreebsd.patch
by jrtc27.

Fixes https://github.com/facebook/rocksdb/issues/5223.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6992

Reviewed By: zhichao-cao

Differential Revision: D22084150

Pulled By: ajkr

fbshipit-source-id: 1822311ba16f112a15065b2180ce89d36af9cafc
This commit is contained in:
Andrew Kryczka 2020-06-18 09:50:05 -07:00 committed by Facebook GitHub Bot
parent 223b57eeb8
commit 312f23c92d
4 changed files with 20 additions and 6 deletions

View File

@ -95,7 +95,7 @@ if(MSVC)
option(WITH_XPRESS "build with windows built in compression" OFF) option(WITH_XPRESS "build with windows built in compression" OFF)
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc) include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)
else() else()
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
# FreeBSD has jemalloc as default malloc # FreeBSD has jemalloc as default malloc
# but it does not have all the jemalloc files in include/... # but it does not have all the jemalloc files in include/...
set(WITH_JEMALLOC ON) set(WITH_JEMALLOC ON)
@ -448,6 +448,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DOS_LINUX) add_definitions(-DOS_LINUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS") elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
add_definitions(-DOS_SOLARIS) add_definitions(-DOS_SOLARIS)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
add_definitions(-DOS_GNU_KFREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions(-DOS_FREEBSD) add_definitions(-DOS_FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD") elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")

View File

@ -192,6 +192,17 @@ EOF
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread"
# PORT_FILES=port/freebsd/freebsd_specific.cc # PORT_FILES=port/freebsd/freebsd_specific.cc
;; ;;
GNU/kFreeBSD)
PLATFORM=OS_GNU_KFREEBSD
COMMON_FLAGS="$COMMON_FLAGS -DOS_GNU_KFREEBSD"
if [ -z "$USE_CLANG" ]; then
COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp"
else
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
fi
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt"
# PORT_FILES=port/gnu_kfreebsd/gnu_kfreebsd_specific.cc
;;
NetBSD) NetBSD)
PLATFORM=OS_NETBSD PLATFORM=OS_NETBSD
COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD" COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD"

9
env/env_posix.cc vendored
View File

@ -41,7 +41,7 @@
#include <time.h> #include <time.h>
#include <algorithm> #include <algorithm>
// Get nano time includes // Get nano time includes
#if defined(OS_LINUX) || defined(OS_FREEBSD) #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD)
#elif defined(__MACH__) #elif defined(__MACH__)
#include <Availability.h> #include <Availability.h>
#include <mach/clock.h> #include <mach/clock.h>
@ -249,7 +249,8 @@ class PosixEnv : public CompositeEnvWrapper {
} }
uint64_t NowNanos() override { uint64_t NowNanos() override {
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_AIX) #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) || \
defined(OS_AIX)
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec; return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
@ -269,8 +270,8 @@ class PosixEnv : public CompositeEnvWrapper {
} }
uint64_t NowCPUNanos() override { uint64_t NowCPUNanos() override {
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_AIX) || \ #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) || \
(defined(__MACH__) && defined(__MAC_10_12)) defined(OS_AIX) || (defined(__MACH__) && defined(__MAC_10_12))
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec; return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;

View File

@ -36,7 +36,7 @@ namespace port {
namespace { namespace {
#if defined(OS_LINUX) || defined(OS_FREEBSD) #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD)
const char* GetExecutableName() { const char* GetExecutableName() {
static char name[1024]; static char name[1024];