-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Building and Installing on FreeBSD 8.2
dcicppin edited this page Feb 12, 2012
·
50 revisions
Actually you can use almost any FreeBSD version to build HipHop, I've built ot on 8.1, 8.2 and 9.0, all 64bit.
mkdir -p /usr/src/lib/libc/gen
freebsd-update fetch
freebsd-update install
pkg_add -r cmake flex bison re2c openssl gd libxml2 pcre oniguruma boost-libs libmemcached libmcrypt binutils expat mysql50-client wget tbb icu openldap24-client libexecinfo gcc44 gawk git cclient mc
* gcc44 seems to be the most optimal option, other versions produce broken or buggy builds.
cd /usr/local/lib ln -s libc-client4.a libc-client.a ln -s libc-client4.so libc-client.so ln -s libc-client4.so.9 libc-client.so.9
hphp-freebsd-20120212.patch:
--- src.orig/hphp/main.cpp 2012-02-11 21:30:15.000000000 +0300
+++ src/hphp/main.cpp 2012-02-11 21:48:33.000000000 +0300
@@ -524,7 +524,7 @@
int process(const ProgramOptions &po) {
if (po.coredump) {
-#if defined(__APPLE__)
+#if defined(__APPLE__)||defined(__FreeBSD__)
struct rlimit rl;
getrlimit(RLIMIT_CORE, &rl);
rl.rlim_cur = 80000000LL;
--- src.orig/runtime/base/builtin_functions.cpp 2012-02-11 21:30:15.000000000 +0300
+++ src/runtime/base/builtin_functions.cpp 2012-02-11 22:02:03.000000000 +0300
@@ -34,6 +34,12 @@
#include
+#ifdef __FreeBSD__
+# ifdef isset
+# undef isset
+# endif
+#endif
+
using namespace std;
namespace HPHP {
--- src.orig/runtime/base/builtin_functions.h 2012-02-11 21:30:15.000000000 +0300
+++ src/runtime/base/builtin_functions.h 2012-02-11 21:39:26.000000000 +0300
@@ -32,7 +32,7 @@
#include
#include
-#ifdef __APPLE__
+#if defined(__APPLE__)||defined(__FreeBSD__)
# ifdef isset
# undef isset
# endif
--- src.orig/runtime/base/util/thrift_buffer.h 2012-02-11 21:30:15.000000000 +0300
+++ src/runtime/base/util/thrift_buffer.h 2012-02-11 21:49:43.000000000 +0300
@@ -22,7 +22,7 @@
#include
#include
-#if defined(__FREEBSD__)
+#if defined(__FreeBSD__)
# include
# elif defined(__APPLE__)
# include
@@ -34,7 +34,7 @@
#if !defined(htonll) && !defined(ntohll)
#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if defined(__FREEBSD__)
+# if defined(__FreeBSD__)
# define htonll(x) bswap64(x)
# define ntohll(x) bswap64(x)
# elif defined(__APPLE__)
--- src.orig/runtime/base/zend/zend_string.cpp 2012-02-11 21:30:15.000000000 +0300
+++ src/runtime/base/zend/zend_string.cpp 2012-02-11 21:49:51.000000000 +0300
@@ -2412,7 +2412,7 @@
// crypt
#include
-#if !defined(__APPLE__) && !defined(__FREEBSD__)
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
# include
#endif
--- src.orig/runtime/eval/debugger/debugger_proxy.cpp 2012-02-11 21:30:15.000000000 +0300
+++ src/runtime/eval/debugger/debugger_proxy.cpp 2012-02-11 21:42:32.000000000 +0300
@@ -118,7 +118,7 @@
m_thread = 0;
notify();
} else {
- m_thread = Process::GetThreadId();
+ m_thread = (int64)Process::GetThreadId();
}
if (mode == Normal) {
m_jump.reset();
@@ -576,7 +576,7 @@
DThreadInfoPtr DebuggerProxy::createThreadInfo(const std::string &desc) {
DThreadInfoPtr info(new DThreadInfo());
- info->m_id = Process::GetThreadId();
+ info->m_id = (int64)Process::GetThreadId();
info->m_desc = desc;
Transport *transport = g_context->getTransport();
if (transport) {
--- src.orig/runtime/eval/debugger/cmd/cmd_interrupt.h 2012-02-11 21:30:15.000000000 +0300
+++ src/runtime/eval/debugger/cmd/cmd_interrupt.h 2012-02-11 21:41:37.000000000 +0300
@@ -35,7 +35,7 @@
: DebuggerCommand(KindOfInterrupt),
m_interrupt(interrupt), m_program(program ? program : ""),
m_site(site), m_pendingJump(false) {
- m_threadId = Process::GetThreadId();
+ m_threadId = (int64)Process::GetThreadId();
if (error) m_errorMsg = error;
}
--- src.orig/runtime/ext/ext.h 2012-02-11 21:30:16.000000000 +0300
+++ src/runtime/ext/ext.h 2012-02-11 21:46:53.000000000 +0300
@@ -85,3 +85,9 @@
#include
#include
#include
+
+#ifdef __FreeBSD__
+# ifdef isset
+# undef isset
+# endif
+#endif
--- src.orig/runtime/ext/ext_hotprofiler.cpp 2012-02-11 21:30:16.000000000 +0300
+++ src/runtime/ext/ext_hotprofiler.cpp 2012-02-11 21:43:34.000000000 +0300
@@ -25,6 +25,7 @@
#ifdef __FreeBSD__
# include
+# include
# include
# define cpu_set_t cpuset_t
# define SET_AFFINITY(pid, size, mask) \
--- src.orig/runtime/ext/ext_iconv.cpp 2012-02-11 21:30:16.000000000 +0300
+++ src/runtime/ext/ext_iconv.cpp 2012-02-11 22:26:05.000000000 +0300
@@ -152,7 +152,7 @@
out_left = buf_growth - out_left;
out_p = d.reserve(out_left);
- if (iconv(cd, (char **)&in_p, &in_left, (char **)&out_p, &out_left) ==
+ if (iconv(cd, (const char **)&in_p, &in_left, (char **)&out_p, &out_left) ==
(size_t)-1) {
#if ICONV_SUPPORTS_ERRNO
switch (errno) {
@@ -239,7 +239,7 @@
out_buffer = (char *)malloc(out_size + 1);
out_p = out_buffer;
- result = iconv(cd, (char **)&in_p, &in_size, (char **)&out_p, &out_left);
+ result = iconv(cd, (const char **)&in_p, &in_size, (char **)&out_p, &out_left);
if (result == (size_t)(-1)) {
free(out_buffer);
return PHP_ICONV_ERR_UNKNOWN;
@@ -293,7 +293,7 @@
out_p = out_buf;
while (in_left > 0) {
- result = iconv(cd, (char **)&in_p, &in_left, (char **)&out_p, &out_left);
+ result = iconv(cd, (const char **)&in_p, &in_left, (char **)&out_p, &out_left);
out_size = bsz - out_left;
if (result == (size_t)(-1)) {
if (errno == E2BIG && in_left > 0) {
@@ -393,7 +393,7 @@
prev_in_left = in_left;
- if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left)
+ if (iconv(cd, (const char **)&in_p, &in_left, (char **) &out_p, &out_left)
== (size_t)-1) {
if (prev_in_left == in_left) {
break;
@@ -497,7 +497,7 @@
prev_in_left = in_left;
- if (iconv(cd1, (char **)&in_p, &in_left, (char **) &out_p, &out_left) ==
+ if (iconv(cd1, (const char **)&in_p, &in_left, (char **) &out_p, &out_left) ==
(size_t)-1) {
if (prev_in_left == in_left) {
break;
@@ -619,7 +619,7 @@
prev_in_left = in_left;
- if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) ==
+ if (iconv(cd, (const char **)&in_p, &in_left, (char **) &out_p, &out_left) ==
(size_t)-1) {
if (prev_in_left == in_left) {
#if ICONV_SUPPORTS_ERRNO
@@ -1408,7 +1408,7 @@
out_left = out_size - out_reserved;
- if (iconv(cd, (char **)&in_p, &in_left,
+ if (iconv(cd, (const char **)&in_p, &in_left,
(char **)&out_p, &out_left) == (size_t)-1) {
#if ICONV_SUPPORTS_ERRNO
switch (errno) {
@@ -1503,7 +1503,7 @@
out_p = buf;
out_left = out_size;
- if (iconv(cd, (char **)&in_p, &in_left,
+ if (iconv(cd, (const char **)&in_p, &in_left,
(char **)&out_p, &out_left) == (size_t)-1) {
#if ICONV_SUPPORTS_ERRNO
switch (errno) {
--- src.orig/runtime/ext/ext_ipc.cpp 2012-02-11 21:30:16.000000000 +0300
+++ src/runtime/ext/ext_ipc.cpp 2012-02-11 21:49:08.000000000 +0300
@@ -28,10 +28,10 @@
using namespace std;
-#if defined(__APPLE__) || defined(__FREEBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
#include
#define MSGBUF_MTYPE(b) (b)->msg_magic
-#define MSGBUF_MTEXT(b) (b)->msg_bufc
+#define MSGBUF_MTEXT(b) (b)->msg_ptr
#else
#define MSGBUF_MTYPE(b) (b)->mtype
#define MSGBUF_MTEXT(b) (b)->mtext
@@ -207,7 +207,7 @@
int64 realflags = 0;
if (flags != 0) {
-#if !defined(__APPLE__) && !defined(__FREEBSD__)
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
if (flags & k_MSG_EXCEPT) realflags |= MSG_EXCEPT;
#endif
if (flags & k_MSG_NOERROR) realflags |= MSG_NOERROR;
--- src.orig/runtime/ext/ext_posix.cpp 2012-02-11 21:30:16.000000000 +0300
+++ src/runtime/ext/ext_posix.cpp 2012-02-11 21:49:18.000000000 +0300
@@ -229,7 +229,7 @@
ret.set("release", String(u.release, CopyString));
ret.set("version", String(u.version, CopyString));
ret.set("machine", String(u.machine, CopyString));
-#if defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(__FREEBSD__)
+#if defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(__FreeBSD__)
ret.set("domainname", String(u.domainname, CopyString));
#endif
return ret;
--- src.orig/runtime/ext/thrift/transport.h 2012-02-11 21:30:16.000000000 +0300
+++ src/runtime/ext/thrift/transport.h 2012-02-11 21:50:04.000000000 +0300
@@ -24,7 +24,7 @@
#include
#include
#include
-#if defined(__FREEBSD__)
+#if defined(__FreeBSD__)
# include
#elif defined(__APPLE__)
# include
@@ -36,7 +36,7 @@
#include
#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if defined(__FREEBSD__)
+# if defined(__FreeBSD__)
# define htonll(x) bswap64(x)
# define ntohll(x) bswap64(x)
# elif defined(__APPLE__)
--- src.orig/test/test_cpp_base.cpp 2012-02-11 21:30:16.000000000 +0300
+++ src/test/test_cpp_base.cpp 2012-02-11 22:58:04.000000000 +0300
@@ -29,6 +29,10 @@
#include
#include
+#if defined(__FreeBSD__)
+# define s6_addr32 __u6_addr.__u6_addr32
+#endif
+
using namespace std;
///////////////////////////////////////////////////////////////////////////////
--- src.orig/util/alloc.cpp 2012-02-11 21:30:17.000000000 +0300
+++ src/util/alloc.cpp 2012-02-11 22:38:30.000000000 +0300
@@ -14,6 +14,9 @@
+----------------------------------------------------------------------+
*/
+#if defined(__FreeBSD__)
+#include
+#endif
#include
#include
#include
@@ -82,6 +85,7 @@
}
void flush_thread_stack() {
+#if !defined(__FreeBSD__)
uintptr_t top = get_stack_top() & ~(PAGE_SIZE - 1);
// s_stackLimit is already aligned
ASSERT(top >= s_stackLimit);
@@ -92,6 +96,7 @@
fprintf(stderr, "%s failed to madvise with error %d\n", __func__, errno);
abort();
}
+#endif
}
///////////////////////////////////////////////////////////////////////////////
--- src.orig/util/async_func.h 2012-02-11 21:30:17.000000000 +0300
+++ src/util/async_func.h 2012-02-11 21:38:05.000000000 +0300
@@ -104,6 +104,7 @@
* the work to AsyncFuncImpl::threadFuncImpl().
*/
static void *ThreadFunc(void *obj) {
+#if !defined(__FreeBSD__)
pthread_attr_t info;
size_t stacksize, guardsize;
void *stackaddr;
@@ -121,6 +122,7 @@
ASSERT(stacksize >= PTHREAD_STACK_MIN);
Util::s_stackLimit = uintptr_t(stackaddr) + guardsize;
Util::s_stackSize = stacksize;
+#endif
((AsyncFuncImpl*)obj)->threadFuncImpl();
return NULL;
--- src.orig/util/process.h 2012-02-11 21:30:17.000000000 +0300
+++ src/util/process.h 2012-02-11 21:37:26.000000000 +0300
@@ -119,7 +119,11 @@
* Thread's process identifier.
*/
static pid_t GetThreadPid() {
+#if defined(__FreeBSD__)
+ return 0;
+#else
return syscall(SYS_gettid);
+#endif
}
/**
--- src.orig/util/util.h 2012-02-11 21:30:17.000000000 +0300
+++ src/util/util.h 2012-02-11 21:48:01.000000000 +0300
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
/**
hphp-libmemcached-1.0.patch:
--- CMake.orig/FindLibmemcached.cmake 2012-02-12 02:24:49.000000000 +0400
+++ CMake/FindLibmemcached.cmake 2012-02-12 02:40:24.000000000 +0400
@@ -14,7 +14,7 @@
SET(LIBMEMCACHED_FIND_QUIETLY TRUE)
ENDIF ()
-FIND_PATH(LIBMEMCACHED_INCLUDE_DIR libmemcached/memcached.h)
+FIND_PATH(LIBMEMCACHED_INCLUDE_DIR libmemcached-1.0/memcached.h)
FIND_LIBRARY(LIBMEMCACHED_LIBRARY memcached)
@@ -26,8 +26,8 @@
SET(LIBMEMCACHED_VERSION 0)
IF(LIBMEMCACHED_FOUND)
- if (EXISTS "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached/configure.h")
- FILE(READ "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached/configure.h" _MEMCACHE_VERSION_CONENTS)
+ if (EXISTS "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached-1.0/configure.h")
+ FILE(READ "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached-1.0/configure.h" _MEMCACHE_VERSION_CONENTS)
STRING(REGEX REPLACE ".*#define LIBMEMCACHED_VERSION_STRING \"([0-9.]+)\".*" "\\1" LIBMEMCACHED_VERSION "${_MEMCACHE_VERSION_CONENTS}")
endif()
ENDIF()
--- src.orig/runtime/ext/ext_memcache.cpp 2012-02-12 02:24:53.000000000 +0400
+++ src/runtime/ext/ext_memcache.cpp 2012-02-12 13:10:06.000000000 +0400
@@ -431,7 +431,7 @@
memcached_stat_st *memc_stat,
memcached_return_t *ret) {
char **curr_key;
- char **stat_keys = memcached_stat_get_keys(ptr, memc_stat, ret);
+ char **stat_keys = memcached_stat_get_keys(const_cast(ptr), memc_stat, ret);
if (*ret != MEMCACHED_SUCCESS) {
if (stat_keys) {
Download libevent from: https://github.com/downloads/libevent/libevent/libevent-1.4.13-stable.tar.gz
Download curl from: http://curl.haxx.se/download/curl-7.20.0.tar.gz
build.hphp.freebsd.sh:
#!/bin/tcsh
# HipHop-PHP build script by LouiSe@louise.hu
setenv BUILD_HOME /home/louise/hiphop
setenv CC /usr/local/bin/gcc44
setenv CXX /usr/local/bin/g++44
## Get latest sources from GIT repository
git clone git://github.com/facebook/hiphop-php.git
cd hiphop-php
git submodule init
git submodule update
cd ..
## Patch libevent
rm -rf libevent-1.4.13-stable
tar xvzpf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
cp ../hiphop-php/src/third_party/libevent-1.4.13.fb-changes.diff .
patch -p1 < libevent-1.4.13.fb-changes.diff
./configure --prefix=${BUILD_HOME}
make
make install
cd ..
## Patch curl
rm -rf curl-7.20.0
tar xvzpf curl-7.20.0.tar.gz
cd curl-7.20.0
cp ../hiphop-php/src/third_party/libcurl.fb-changes.diff .
patch -p1 < libcurl.fb-changes.diff
./configure --prefix=${BUILD_HOME}
make
make install
cd ..
## Initializing HipHop and CMAKE environment
setenv HPHP_HOME ${BUILD_HOME}/hiphop-php
setenv HPHP_LIB ${HPHP_HOME}/bin
setenv CMAKE_PREFIX_PATH ${HPHP_HOME}/../
## Build HipHop
cd hiphop-php
rm CMakeCache.txt
cmake .
make
cd ..