Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable folly::Symbolizer for HHVM #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions folly/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ list(REMOVE_ITEM files
${FOLLY_DIR}/experimental/exception_tracer/StackTrace.cpp
${FOLLY_DIR}/experimental/io/AsyncIO.cpp
${FOLLY_DIR}/experimental/io/HugePageUtil.cpp
${FOLLY_DIR}/experimental/symbolizer/StackTrace.cpp
${FOLLY_DIR}/experimental/symbolizer/ElfCache.cpp
${FOLLY_DIR}/experimental/symbolizer/ElfUtil.cpp
${FOLLY_DIR}/experimental/symbolizer/SignalHandler.cpp
${FOLLY_DIR}/init/Init.cpp
Expand All @@ -78,14 +76,22 @@ list(REMOVE_ITEM hfiles
${FOLLY_DIR}/experimental/exception_tracer/ExceptionTracer.h
${FOLLY_DIR}/experimental/exception_tracer/StackTrace.h
${FOLLY_DIR}/experimental/io/AsyncIO.h
${FOLLY_DIR}/experimental/symbolizer/StackTrace.h
${FOLLY_DIR}/experimental/symbolizer/ElfCache.h
${FOLLY_DIR}/experimental/symbolizer/SignalHandler.h
${FOLLY_DIR}/init/Init.h
# io/Compression requires snappy library
# Don't add dep until we need it
${FOLLY_DIR}/io/Compression.h
)
if (NOT ENABLE_FOLLY_SYMBOLIZER)
list(REMOVE_ITEM files
${FOLLY_DIR}/experimental/symbolizer/StackTrace.cpp
${FOLLY_DIR}/experimental/symbolizer/ElfCache.cpp
)
list(REMOVE_ITEM hfiles
${FOLLY_DIR}/experimental/symbolizer/StackTrace.h
${FOLLY_DIR}/experimental/symbolizer/ElfCache.h
)
endif()

CHECK_CXX_SOURCE_COMPILES("#include <bits/functexcept.h>
int main() {
Expand Down Expand Up @@ -148,6 +154,17 @@ target_include_directories(folly PUBLIC ${FOLLY_ROOT})

target_link_libraries(folly boost)

# 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 enforces the
# order in which the libraries are linked.
if (ENABLE_FOLLY_SYMBOLIZER)
SET(UNWIND_LIB -lgcc_s -lunwind)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what happens on mac (clang) with and without this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested on either mac or clang, which is why I protected this option under GCC in the related PR in HHVM: facebook/hhvm#8123

Do you think it is better to include the GCC requirement in folly as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually use Folly's build system - but given that https://github.com/facebook/folly/blob/9656bacc814ce9efd24e178ed5e127c5c365a248/CMake/FollyConfigChecks.cmake checks for elf.h , mac's most likely not going to be an issue - but Clang should work.

cc @simpkins

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fredemmott can you please clarify if I should change anything for Clang?

target_link_libraries(folly ${UNWIND_LIB})
endif()

find_package(Glog REQUIRED)
target_include_directories(folly PUBLIC ${LIBGLOG_INCLUDE_DIR})
target_link_libraries(folly ${LIBGLOG_LIBRARY})
Expand Down