From: Philip Jameson Date: Thu, 31 Aug 2017 01:00:36 +0000 (-0700) Subject: Don't use symbolizer on OSX X-Git-Tag: v2017.09.04.00~5 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4717bdadf28139ef19b81315879892ed972fe7a5;p=folly.git 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 --- diff --git a/folly/Makefile.am b/folly/Makefile.am index 18aa5bd4..e42b0eaf 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -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 diff --git a/folly/SingletonStackTrace.cpp b/folly/SingletonStackTrace.cpp index 48bb72cf..f5d5f97b 100644 --- a/folly/SingletonStackTrace.cpp +++ b/folly/SingletonStackTrace.cpp @@ -13,8 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include + +#ifdef FOLLY_USE_SYMBOLIZER #include -#include +#include // @manual namespace folly { @@ -53,5 +57,5 @@ SetStackTraceGetter setStackTraceGetter; SetStackTraceGetter __attribute__((__init_priority__(101))) setStackTraceGetter; #endif } - } +#endif diff --git a/folly/configure.ac b/folly/configure.ac index 2d5ca29c..181f4687 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -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 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) diff --git a/folly/experimental/Makefile.am b/folly/experimental/Makefile.am index b32b1003..51cee1ba 100644 --- a/folly/experimental/Makefile.am +++ b/folly/experimental/Makefile.am @@ -1,4 +1,4 @@ -if HAVE_LIBDWARF +if USE_SYMBOLIZER MAYBE_SYMBOLIZER = symbolizer endif if EXCEPTION_TRACER diff --git a/folly/fibers/test/StackOverflow.cpp b/folly/fibers/test/StackOverflow.cpp index cd91fa2d..3c0892c9 100644 --- a/folly/fibers/test/StackOverflow.cpp +++ b/folly/fibers/test/StackOverflow.cpp @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include + #include #include diff --git a/folly/init/Init.cpp b/folly/init/Init.cpp index d44a6d44..50f132e5 100644 --- a/folly/init/Init.cpp +++ b/folly/init/Init.cpp @@ -19,9 +19,10 @@ #include #include +#include #ifdef FOLLY_USE_SYMBOLIZER -#include +#include // @manual #endif #include diff --git a/folly/init/Makefile.am b/folly/init/Makefile.am index 4b6367e0..32aee329 100644 --- a/folly/init/Makefile.am +++ b/folly/init/Makefile.am @@ -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)