Skip to content

Instantly share code, notes, and snippets.

@danslo
Created July 3, 2013 19:03
Show Gist options
  • Save danslo/5921745 to your computer and use it in GitHub Desktop.
Save danslo/5921745 to your computer and use it in GitHub Desktop.
diff --git hphp/hhvm/CMakeLists.txt hphp/hhvm/CMakeLists.txt
index 775d168..acedec5 100644
--- hphp/hhvm/CMakeLists.txt
+++ hphp/hhvm/CMakeLists.txt
@@ -3,6 +3,7 @@ auto_sources(files "*.cpp" "")
list(APPEND CXX_SOURCES ${files})
add_executable(hhvm ${CXX_SOURCES})
+if (NOT APPLE)
target_link_libraries(hhvm hphp_analysis hphp_runtime_static ext_hhvm_static hphp_system
-Wl,-uregister_libevent_server)
@@ -11,6 +12,10 @@ add_custom_command(TARGET hhvm POST_BUILD
ARGS "--add-section" "systemlib=${HPHP_HOME}/bin/systemlib.php"
"${CMAKE_CURRENT_SOURCE_DIR}/hhvm"
COMMENT "Embedding systemlib.php in hhvm")
+else()
+ target_link_libraries(hhvm hphp_analysis hphp_runtime_static ext_hhvm_static hphp_system -Wl,-sectcreate,__text,systemlib,${HPHP_HOME}/bin/systemlib.php)
+endif()
+
add_dependencies(hhvm systemlib)
install(TARGETS hhvm DESTINATION bin)
diff --git hphp/util/embedded_data.cpp hphp/util/embedded_data.cpp
index f98e73e..25ecab7 100644
--- hphp/util/embedded_data.cpp
+++ hphp/util/embedded_data.cpp
@@ -27,9 +27,14 @@
#include <string.h>
#include <unistd.h>
+#ifdef __APPLE__
+#include <mach-o/getsect.h>
+#endif
+
namespace HPHP { namespace Util {
bool get_embedded_data(const char *section, embedded_data* desc) {
+#ifndef __APPLE__
GElf_Shdr shdr;
size_t shstrndx;
char *name;
@@ -68,6 +73,15 @@ bool get_embedded_data(const char *section, embedded_data* desc) {
return true;
}
}
+#else
+ const struct section_64 *sect = getsectbyname("__text", section);
+ if (sect) {
+ desc->m_filename = "hhvm";
+ desc->m_start = sect->offset;
+ desc->m_len = sect->size;
+ return true;
+ }
+#endif
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment