From ba9d1737a8528c95d0d1ee6b273a030e84e62195 Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Thu, 26 Feb 2015 15:19:17 -0800 Subject: [PATCH] RocksDB on FreeBSD support Summary: This patch will update the Makefile and source code so that we can build RocksDB successfully on FreeBSD 10 and 11 (64-bit and 32-bit) I have also encountered some problems when running tests on FreeBSD, I will try to fix them individually in different diffs Notes: - FreeBSD uses clang as it's default compiler (http://lists.freebsd.org/pipermail/freebsd-current/2012-September/036480.html) - GNU C++ compiler have C++ 11 problems on FreeBSD (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193528) - make is not gmake on FreeBSD (http://www.khmere.com/freebsd_book/html/ch01.html) Test Plan: Using VMWare Fusion Create 4 VM machines (FreeBSD 11 64-bit, FreeBSD 11 32-bit, FreeBSD 10 64-bit, FreeBSD 10 32-bit) - pkg install git gmake gflags archivers/snappy - git clone https://github.com/facebook/rocksdb.git - apply this patch - setenv CXX c++ - setenv CPATH /usr/local/include/ - setenv LIBRARY_PATH /usr/local/lib/ - gmake db_bench - make sure compilation is successful and db_bench is running - gmake all - make sure compilation is successful Reviewers: sdong, igor Reviewed By: igor Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D33891 --- Makefile | 2 +- Vagrantfile | 17 +++++++++++++++++ build_tools/build_detect_platform | 21 +++++++++++++++++---- port/port_posix.h | 6 +++++- util/log_buffer.h | 1 + util/xfunc.h | 1 + 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9b2467034..98e64be94 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CFLAGS += ${EXTRA_CFLAGS} CXXFLAGS += ${EXTRA_CXXFLAGS} LDFLAGS += $(EXTRA_LDFLAGS) MACHINE ?= $(shell uname -m) -ARFLAGS = rs +ARFLAGS = rsD ifneq ($(MAKECMDGOALS),dbg) OPT += -O2 -fno-omit-frame-pointer diff --git a/Vagrantfile b/Vagrantfile index cdee5db53..c517182e2 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,4 +13,21 @@ Vagrant.configure("2") do |config| box.vm.box = "chef/centos-6.5" end + config.vm.define "FreeBSD10" do |box| + box.vm.guest = :freebsd + box.vm.box = "robin/freebsd-10" + # FreeBSD does not support 'mount_virtualbox_shared_folder', use NFS + box.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" + box.vm.network "private_network", ip: "10.0.1.10" + + # build everything after creating VM, skip using --no-provision + box.vm.provision "shell", inline: <<-SCRIPT + pkg install -y gmake clang35 + export CXX=/usr/local/bin/clang++35 + cd /vagrant + gmake clean + gmake all OPT=-g + SCRIPT + end + end diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 80f50610a..002c6f1e8 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -75,6 +75,10 @@ if test -z "$TARGET_OS"; then TARGET_OS=`uname -s` fi +if test -z "$TARGET_ARCHITECTURE"; then + TARGET_ARCHITECTURE=`uname -m` +fi + if test -z "$CLANG_SCAN_BUILD"; then CLANG_SCAN_BUILD=scan-build fi @@ -300,12 +304,16 @@ EOF fi fi -# Test whether -Wshorten-64-to-32 is available -$CXX $CFLAGS -x c++ - -o /dev/null -Wshorten-64-to-32 2>/dev/null </dev/null < + #include + #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) +#elif defined(OS_OPENBSD) || defined(OS_NETBSD) ||\ defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID) #include #include diff --git a/util/log_buffer.h b/util/log_buffer.h index 2d790086e..b5cf1d555 100644 --- a/util/log_buffer.h +++ b/util/log_buffer.h @@ -5,6 +5,7 @@ #pragma once +#include #include "rocksdb/env.h" #include "util/arena.h" #include "util/autovector.h" diff --git a/util/xfunc.h b/util/xfunc.h index c37149a30..e7e2e9736 100644 --- a/util/xfunc.h +++ b/util/xfunc.h @@ -4,6 +4,7 @@ // of patent rights can be found in the PATENTS file in the same directory. #pragma once +#include #include namespace rocksdb {