Commit 4717bdad authored by Philip Jameson's avatar Philip Jameson Committed by Facebook Github Bot

Don't use symbolizer on OSX

Summary:
When trying to build with targets files on OSX, I couldn't use the symbolizer because it needs StackTrace, which requires libunwind and elf. This makes it so that we only build on linux for now. This also makes it so that we set FOLLY_USE_SYMBOLIZER in autoconf, since that wasn't set before.

Does a few things surrounding usage of the symbolizer library:
- Introduce FOLLY_USE_SYMBOLIZER in folly-config.h and USE_SYMBOLIZER as an AM definition
-- Filter some code out of init and some other random libs that optionally need the symbolizer
- Fix libdwarf detection. Previously on a fresh ubuntu container, we didn't find libdwarf/dwarf.h, so we stopped trying before looking at dwarf.h

Reviewed By: yfeldblum

Differential Revision: D5644352

fbshipit-source-id: f0a3580c41122e5e8fdfd17a9fdbb0921be21401
parent faa5f598
......@@ -160,14 +160,6 @@ nobase_follyinclude_HEADERS = \
experimental/observer/SimpleObservable-inl.h \
experimental/ProgramOptions.h \
experimental/ReadMostlySharedPtr.h \
experimental/symbolizer/Elf.h \
experimental/symbolizer/Elf-inl.h \
experimental/symbolizer/ElfCache.h \
experimental/symbolizer/Dwarf.h \
experimental/symbolizer/LineReader.h \
experimental/symbolizer/SignalHandler.h \
experimental/symbolizer/StackTrace.h \
experimental/symbolizer/Symbolizer.h \
experimental/Select64.h \
experimental/StampedPtr.h \
experimental/StringKeyedCommon.h \
......@@ -662,6 +654,27 @@ libfolly_la_SOURCES += \
fibers/TimeoutController.cpp
endif
if USE_SYMBOLIZER
nobase_follyinclude_HEADERS += \
experimental/symbolizer/Elf.h \
experimental/symbolizer/Elf-inl.h \
experimental/symbolizer/ElfCache.h \
experimental/symbolizer/Dwarf.h \
experimental/symbolizer/LineReader.h \
experimental/symbolizer/SignalHandler.h \
experimental/symbolizer/StackTrace.h \
experimental/symbolizer/Symbolizer.h
libfolly_la_SOURCES += \
experimental/symbolizer/Elf.cpp \
experimental/symbolizer/ElfCache.cpp \
experimental/symbolizer/Dwarf.cpp \
experimental/symbolizer/LineReader.cpp \
experimental/symbolizer/SignalHandler.cpp \
experimental/symbolizer/StackTrace.cpp \
experimental/symbolizer/Symbolizer.cpp
endif
libfollybasesse42_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LT_VERSION)
libfollybasesse42_la_CXXFLAGS = -msse4.2 -mpclmul
......
......@@ -13,8 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/portability/Config.h>
#ifdef FOLLY_USE_SYMBOLIZER
#include <folly/Singleton.h>
#include <folly/experimental/symbolizer/Symbolizer.h>
#include <folly/experimental/symbolizer/Symbolizer.h> // @manual
namespace folly {
......@@ -53,5 +57,5 @@ SetStackTraceGetter setStackTraceGetter;
SetStackTraceGetter __attribute__((__init_priority__(101))) setStackTraceGetter;
#endif
}
}
#endif
......@@ -547,12 +547,8 @@ AC_ARG_ENABLE([follytestmain],
[use_follytestmain=${enableval}], [use_follytestmain=yes])
# libdwarf used to install in /usr/include, now installs in /usr/include/libdwarf.
AC_CHECK_HEADERS([libdwarf/dwarf.h dwarf.h], [break])
# Check whether we have both the library and the header
have_libdwarf=no
AS_IF([test "x${ac_cv_header_libdwarf_dwarf_h}" = xyes], [have_libdwarf=yes])
AS_IF([test "x${ac_cv_header_dwarf_h}" = xyes], [have_libdwarf=yes])
AC_CHECK_HEADERS([libdwarf/dwarf.h dwarf.h], [have_libdwarf=yes])
AC_ARG_ENABLE([mobile],
AS_HELP_STRING([--enable-mobile],
......@@ -567,6 +563,24 @@ AC_ARG_ENABLE([exception-tracer],
AS_HELP_STRING([--enable-exception-tracer], [enables building exception tracer]),
[build_exception_tracer=${enableval}], [build_exception_tracer=no])
AC_ARG_ENABLE([symbolizer],
AS_HELP_STRING([--enable-symbolizer], [try to build symbolizer if possible]),
[folly_try_use_symbolizer=${enableval}], [folly_try_use_symbolizer=yes])
folly_use_symbolizer=no
if test "$folly_try_use_symbolizer" = yes; then
if test "$build_os" = "linux-gnu" && test "$have_libdwarf" = yes; then
AC_CHECK_HEADER(
[elf.h],
AC_CHECK_LIB([unwind], [backtrace], [folly_use_symbolizer=yes]),
)
fi
fi
if test "$folly_use_symbolizer" = yes; then
AC_DEFINE([USE_SYMBOLIZER], [1], [Define to 1 if we should use the symbolizer in init])
fi
# Include directory that contains "folly" so #include <folly/Foo.h> works
AM_CPPFLAGS='-I$(top_srcdir)/..'
AM_CPPFLAGS="$AM_CPPFLAGS $BOOST_CPPFLAGS $OPENSSL_INCLUDES"
......@@ -594,6 +608,7 @@ AM_CONDITIONAL([FOLLY_TESTMAIN], [test "x${use_follytestmain}" = "xyes"])
AM_CONDITIONAL([HAVE_LIBDWARF], [test "x${have_libdwarf}" = "xyes"])
AM_CONDITIONAL([HAVE_BOOST_CONTEXT], [test "x${ax_cv_boost_context}" = "xyes"])
AM_CONDITIONAL([EXCEPTION_TRACER], [test "x${build_exception_tracer}" = "xyes"])
AM_CONDITIONAL([USE_SYMBOLIZER], [test "x${folly_use_symbolizer}" = "xyes"])
# remove pkg-config deps from dependent libraries
# (at least for pkg-config file purposes)
......
if HAVE_LIBDWARF
if USE_SYMBOLIZER
MAYBE_SYMBOLIZER = symbolizer
endif
if EXCEPTION_TRACER
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/experimental/symbolizer/SignalHandler.h>
#include <folly/fibers/FiberManagerMap.h>
#include <folly/init/Init.h>
......
......@@ -19,9 +19,10 @@
#include <glog/logging.h>
#include <folly/Singleton.h>
#include <folly/portability/Config.h>
#ifdef FOLLY_USE_SYMBOLIZER
#include <folly/experimental/symbolizer/SignalHandler.h>
#include <folly/experimental/symbolizer/SignalHandler.h> // @manual
#endif
#include <folly/portability/GFlags.h>
......
......@@ -2,10 +2,6 @@ SUBDIRS = .
lib_LTLIBRARIES = libfollyinit.la
if HAVE_LIBDWARF
FOLLY_SYMBOLIZER=$(top_builddir)/experimental/symbolizer/libfollysymbolizer.la
endif
libfollyinit_la_SOURCES = Init.cpp
libfollyinit_la_LIBADD = $(top_builddir)/libfolly.la $(FOLLY_SYMBOLIZER)
libfollyinit_la_LIBADD = $(top_builddir)/libfolly.la
libfollyinit_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LT_VERSION)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment