(folly) make check on OSX Yosemite (10.10)
authorHans Fugal <fugalh@fb.com>
Thu, 8 Jan 2015 22:49:01 +0000 (14:49 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:05 +0000 (11:01 -0800)
Summary:
This switches from gcc-4.9 provided by Homebrew to the default g++ (clang) from Yosemite.

$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

Absolute path for double-conversion, so make in `test/` works.

gtest-1.7.0 (Using 1.6.0 causes compilation errors in Yosemite)

Various portability fixes.

Enhancements/fixes to `configure.ac` and associated source code for better portability.

Test Plan:
It builds and runs (yay)
Two tests fail, not sure whether that's specific to osx. Will investigate and make any fixes in a follow-up diff

Reviewed By: pgriess@fb.com

Subscribers: trunkagent, folly-diffs@, exa

FB internal diff: D1768669

Tasks: 5936226

Signature: t1:1768669:1420728580:dd6919c21e0edf30788e523b16e3a5b923e2d7f0

folly/Conv.h
folly/SpinLock.h
folly/bootstrap-osx-homebrew.sh
folly/configure.ac
folly/detail/SpinLockImpl.h
folly/detail/ThreadLocalDetail.h
folly/test/.gitignore [new file with mode: 0644]
folly/test/Makefile.am
folly/test/SpinLockTest.cpp
folly/test/sorted_vector_test.cpp

index 4d6fb0dd8398aa9dbfcd5a7064082967eb6f3009..5a196463dd79df1ee6fbfd73375c65be3a23a39e 100644 (file)
@@ -658,6 +658,11 @@ struct HasLengthEstimator : std::false_type {};
 template <class Src>
 constexpr typename std::enable_if<
   !std::is_fundamental<Src>::value
+#ifdef FOLLY_HAVE_INT128_T
+  // On OSX 10.10, is_fundamental<__int128> is false :-O
+  && !std::is_same<__int128, Src>::value
+  && !std::is_same<unsigned __int128, Src>::value
+#endif
   && !IsSomeString<Src>::value
   && !std::is_convertible<Src, const char*>::value
   && !std::is_convertible<Src, StringPiece>::value
index ac6ed35bb431783bbd39414ff94717a3c22a4af7..2e2356c938e76f9fb45ab50f06ea8618a4586e45 100644 (file)
@@ -24,7 +24,7 @@ namespace folly {
 typedef SpinLockMslImpl SpinLock;
 #elif __APPLE__
 typedef SpinLockAppleImpl SpinLock;
-#elif __ANDROID__
+#elif FOLLY_HAVE_PTHREAD_SPINLOCK_T
 typedef SpinLockPthreadMutexImpl SpinLock;
 #else
 typedef SpinLockPthreadImpl SpinLock;
index 6565f4b67271f4d6e54ce8511c359d7d6e745539..da1f73ed24be33542696bfa1a2cce41a809a41b1 100755 (executable)
@@ -9,8 +9,8 @@ brewget() {
     brew install $@ || brew upgrade $@
 }
 
-# tool dependencies: autotools, scons (for double-conversion), and gcc 4.9
-brewget autoconf automake libtool scons gcc
+# tool dependencies: autotools and scons (for double-conversion)
+brewget autoconf automake libtool scons
 
 # dependencies
 brewget glog gflags boost libevent
@@ -18,7 +18,6 @@ brewget glog gflags boost libevent
 # Install the double-conversion library.
 # NB their install target installs the libs but not the headers, hence the
 # CPPFLAGS and link shenanigans.
-DOUBLE_CONVERSION_CPPFLAGS="-I./double-conversion/src"
 test -d double-conversion || {
     git clone https://github.com/floitsch/double-conversion.git
     pushd double-conversion/src
@@ -31,7 +30,15 @@ scons
 # (this won't work if you've already installed libdouble-conversion into a
 # default search path)
 rm -f libdouble-conversion*dylib
+DOUBLE_CONVERSION_HOME=$(pwd)
 popd
 
 autoreconf -i
-./configure CPPFLAGS="-I./double-conversion/src" LDFLAGS="-L./double-conversion" CXX=g++-4.9
+./configure CPPFLAGS=-I"$DOUBLE_CONVERSION_HOME/src" LDFLAGS=-L"$DOUBLE_CONVERSION_HOME"
+
+pushd test
+test -d gtest-1.7.0 || {
+    curl -O https://googletest.googlecode.com/files/gtest-1.7.0.zip
+    unzip gtest-1.7.0.zip
+}
+popd
index 3f66657c2b81c957bb64b17c701789ce99178d01..5c2aa81f4ed3d3c1d52aacf1c6dcb94e672eae2f 100644 (file)
@@ -92,10 +92,8 @@ AC_C_INLINE
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
 AC_C_VOLATILE
-AC_CHECK_TYPE([__int128],
-  [AC_DEFINE([HAVE_INT128_T], [1], [Define if __int128 exists])],
-  [AC_DEFINE([HAVE_INT128_T], [0], [Define if __int128 does not exist])])
-AC_CHECK_TYPES([ptrdiff_t])
+AC_CHECK_TYPE([__int128], AC_DEFINE([HAVE_INT128_T], [1], [Define if we have __int128]))
+AC_CHECK_TYPES([ptrdiff_t, pthread_spinlock_t])
 
 AC_CACHE_CHECK(
   [for ifunc support],
@@ -274,6 +272,7 @@ AC_CHECK_FUNCS([getdelim \
                 pow \
                 strerror \
                 pthread_yield \
+                pthread_atfork \
                 malloc_size \
                 malloc_usable_size \
                 memrchr \
index 1d65add9552989cc45939d373084d2741738d8f3..f1f4e06e96bc5bb9525b344bb39f1a1dfcc39d71 100644 (file)
@@ -84,7 +84,7 @@ class SpinLockAppleImpl {
 #include <pthread.h>
 #include <folly/Exception.h>
 
-#if !__ANDROID__ && !__APPLE__
+#if FOLLY_HAVE_PTHREAD_SPINLOCK_T
 
 // Apple and Android systems don't have pthread_spinlock_t, so we can't support
 // this version on those platforms.
@@ -122,7 +122,7 @@ class SpinLockPthreadImpl {
 
 }
 
-#endif // !__ANDROID__ && !__APPLE__
+#endif // FOLLY_HAVE_PTHREAD_SPINLOCK_T
 
 namespace folly {
 
index 4f08acd587b53e6780755466661df7abbee312f4..283e1dfcb2eb980567cdc8680892e0745db964bb 100644 (file)
@@ -207,14 +207,18 @@ struct StaticMeta {
     int ret = pthread_key_create(&pthreadKey_, &onThreadExit);
     checkPosixError(ret, "pthread_key_create failed");
 
-    // pthread_atfork is not part of the Android NDK at least as of n9d. If
-    // something is trying to call native fork() directly at all with Android's
-    // process management model, this is probably the least of the problems.
-#if !__ANDROID__
+#if FOLLY_HAVE_PTHREAD_ATFORK
     ret = pthread_atfork(/*prepare*/ &StaticMeta::preFork,
                          /*parent*/ &StaticMeta::onForkParent,
                          /*child*/ &StaticMeta::onForkChild);
     checkPosixError(ret, "pthread_atfork failed");
+#elif !__ANDROID__
+    // pthread_atfork is not part of the Android NDK at least as of n9d. If
+    // something is trying to call native fork() directly at all with Android's
+    // process management model, this is probably the least of the problems.
+    //
+    // But otherwise, this is a problem.
+    #warning pthread_atfork unavailable
 #endif
   }
   ~StaticMeta() {
diff --git a/folly/test/.gitignore b/folly/test/.gitignore
new file mode 100644 (file)
index 0000000..7e563b8
--- /dev/null
@@ -0,0 +1,2 @@
+*.log
+*.trs
index 6dfd6e6121120295e933442be88de05ff6b1c630..85eee0db39742225c319ce9e604abe4ab281055f 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS = . function_benchmark
 
 ACLOCAL_AMFLAGS = -I m4
 
-CPPFLAGS += -Igtest-1.6.0/include
+CPPFLAGS += -Igtest-1.7.0/include
 
 TESTS= \
        sorted_vector_types_test \
@@ -17,11 +17,11 @@ TESTS= \
 check_LTLIBRARIES = libgtestmain.la libgtest.la
 check_PROGRAMS =
 
-libgtestmain_la_CPPFLAGS = -Igtest-1.6.0 -Igtest-1.6.0/src
-libgtestmain_la_SOURCES = gtest-1.6.0/src/gtest-all.cc gtest-1.6.0/src/gtest_main.cc
+libgtestmain_la_CPPFLAGS = -Igtest-1.7.0 -Igtest-1.7.0/src
+libgtestmain_la_SOURCES = gtest-1.7.0/src/gtest-all.cc gtest-1.7.0/src/gtest_main.cc
 
-libgtest_la_CPPFLAGS = -Igtest-1.6.0 -Igtest-1.6.0/src
-libgtest_la_SOURCES = gtest-1.6.0/src/gtest-all.cc
+libgtest_la_CPPFLAGS = -Igtest-1.7.0 -Igtest-1.7.0/src
+libgtest_la_SOURCES = gtest-1.7.0/src/gtest-all.cc
 
 noinst_HEADERS = FBStringTestBenchmarks.cpp.h \
                 FBVectorTestBenchmarks.cpp.h
@@ -127,7 +127,7 @@ concurrent_skiplist_test_LDADD = libgtest.la $(top_builddir)/libfolly.la
 TESTS += concurrent_skiplist_test
 
 concurrent_skiplist_benchmark_SOURCES = ConcurrentSkipListBenchmark.cpp
-concurrent_skiplist_benchmark_LDADD = $(top_builddir)/libfollybenchmark.la $(top_builddir)/libfolly.la
+concurrent_skiplist_benchmark_LDADD = libgtestmain.la $(top_builddir)/libfollybenchmark.la $(top_builddir)/libfolly.la
 check_PROGRAMS += concurrent_skiplist_benchmark
 
 histogram_test_SOURCES = HistogramTest.cpp
index 847efcf5147447cab89eb9b8416fb9fc85992dbb..7ce90d71e9aee48d9801b591ba0bcb4a17948e89 100644 (file)
@@ -146,7 +146,7 @@ TEST(SpinLock, AppleTryLock) {
 }
 #endif
 
-#if !__ANDROID__
+#if FOLLY_HAVE_PTHREAD_SPINLOCK_T
 TEST(SpinLock, PthreadCorrectness) {
   correctnessTest<folly::SpinLockPthreadImpl>();
 }
index ca806aa0a01f05584de80809358b2dfb3fcc02b6..2b75a5202866d7e01fce4966a1cb48220141b703 100644 (file)
@@ -207,7 +207,7 @@ TEST(SortedVectorTypes, Sizes) {
   typedef sorted_vector_set<int,std::less<int>,
     std::allocator<int>,OneAtATimePolicy> SetT;
   typedef sorted_vector_map<int,int,std::less<int>,
-    std::allocator<int>,OneAtATimePolicy> MapT;
+    std::allocator<std::pair<int,int>>,OneAtATimePolicy> MapT;
 
   EXPECT_EQ(sizeof(SetT), sizeof(std::vector<int>));
   EXPECT_EQ(sizeof(MapT), sizeof(std::vector<std::pair<int,int> >));