From 99f57feeae5d78e2657f6c4b4de61b81cdad4749 Mon Sep 17 00:00:00 2001 From: Florin Papa Date: Thu, 8 Feb 2018 16:59:46 -0800 Subject: [PATCH 1/2] Add separate cmake file for setting OS variables In the Options.cmake file, MAP_TEXT_HUGE_PAGES and ENABLE_FOLLY_SYMBOLIZER are set depending on the value of the LINUX variable, which is only set in a file included later - HPHPCompiler.cmake. This causes these 2 variables not to be visible in third-party modules the first time configure is run (subsequent times the variables are taken from the cmake cache). This change fixes this behavior by adding a new cmake file that sets the OS variables and including it before Options.cmake. --- CMake/HPHPCompiler.cmake | 17 ----------------- CMake/SetOSVars.cmake | 16 ++++++++++++++++ CMakeLists.txt | 1 + 3 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 CMake/SetOSVars.cmake diff --git a/CMake/HPHPCompiler.cmake b/CMake/HPHPCompiler.cmake index c1677f9707eb6b..b68d21323f01be 100644 --- a/CMake/HPHPCompiler.cmake +++ b/CMake/HPHPCompiler.cmake @@ -1,20 +1,3 @@ -set(FREEBSD FALSE) -if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") - set(FREEBSD TRUE) -endif() -set(LINUX FALSE) -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set(LINUX TRUE) -endif() -set(DARWIN FALSE) -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") - set(DARWIN TRUE) -endif() -set(WINDOWS FALSE) -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") - set(WINDOWS TRUE) -endif() - # Do this until cmake has a define for ARMv8 INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES(" diff --git a/CMake/SetOSVars.cmake b/CMake/SetOSVars.cmake new file mode 100644 index 00000000000000..6bc8383918445b --- /dev/null +++ b/CMake/SetOSVars.cmake @@ -0,0 +1,16 @@ +set(FREEBSD FALSE) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") + set(FREEBSD TRUE) +endif() +set(LINUX FALSE) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set(LINUX TRUE) +endif() +set(DARWIN FALSE) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + set(DARWIN TRUE) +endif() +set(WINDOWS FALSE) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") + set(WINDOWS TRUE) +endif() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c5b932f72fb6c1..6679a5ace13e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ SET(TP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party") SET(TP_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party") include(MSVCDefaults) +include(SetOSVars) include(Options) include(HPHPCompiler) include(HPHPFindLibs) From 01d7370695e7148daa959d7175966a85dcd8f6bd Mon Sep 17 00:00:00 2001 From: Florin Papa Date: Wed, 7 Feb 2018 10:33:30 -0800 Subject: [PATCH 2/2] Enable folly::Symbolizer for debug symbols This change depends on https://github.com/hhvm/hhvm-third-party/pull/123, which enables 2 additional source files to be compiled and adds libunwind as a dependency for folly. The "-lgcc_s" added before "-lunwind" is used to solve a linking order issue that causes "_Ux86_64_setcontext" to be called from libunwind instead of libgcc_s and messes up the signal mask (more details here http://savannah.nongnu.org/bugs/?48486). The libgcc_s dependency is already part of HHVM, this change enforces the order in which the libraries are linked. By enabling folly::Symbolizer, HHVM will show debug symbols (in stacktraces, perf, GDB) when huge pages are enabled (default behavior for open source builds). Also, one nice side-effect is that this change causes HHVM to show symbols in backtraces (after a crash) for non-huge-pages builds, which were missing for some reason. --- CMake/Options.cmake | 5 ++++- hphp/CMakeLists.txt | 4 ++++ hphp/util/portability.h | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMake/Options.cmake b/CMake/Options.cmake index b7fd522eb0d6fd..776ff37e9b65b3 100644 --- a/CMake/Options.cmake +++ b/CMake/Options.cmake @@ -31,7 +31,10 @@ option(ENABLE_PROXYGEN_SERVER "Build the Proxygen HTTP server" ON) option(ENABLE_SPLIT_DWARF "Reduce linker memory usage by putting debugging information into .dwo files" OFF) IF (LINUX) - option(MAP_TEXT_HUGE_PAGES "Remap hot static code onto huge pages" ON) + option(MAP_TEXT_HUGE_PAGES "Remap hot static code onto huge pages" ON) + IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + option(ENABLE_FOLLY_SYMBOLIZER "Use folly::Symbolizer to obtain debug symbols when mapping text section onto huge pages" ON) + ENDIF() ENDIF() IF (NOT DEFAULT_CONFIG_DIR) diff --git a/hphp/CMakeLists.txt b/hphp/CMakeLists.txt index 4d4a8bd0214aeb..5daa62eeefb7bb 100644 --- a/hphp/CMakeLists.txt +++ b/hphp/CMakeLists.txt @@ -108,6 +108,10 @@ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/tools/oss-repo-mode add_definitions("-DUSE_CMAKE") +if (ENABLE_FOLLY_SYMBOLIZER) + add_definitions(-DUSE_FOLLY_SYMBOLIZER) +endif() + enable_language(ASM) link_libraries(folly) diff --git a/hphp/util/portability.h b/hphp/util/portability.h index 2e79788e0fb4e2..3c7a9cb23ac5f2 100644 --- a/hphp/util/portability.h +++ b/hphp/util/portability.h @@ -231,7 +231,6 @@ ////////////////////////////////////////////////////////////////////// #if FACEBOOK -#define USE_FOLLY_SYMBOLIZER 1 // Linking in libbfd is a gigantic PITA, but if folly symbolizer doesn't // work on your platform, you'll need to figure it out. #define HAVE_LIBBFD 1