Commit 6d079c14 authored by Hans Fugal's avatar Hans Fugal Committed by Viswanath Sivakumar

(folly) make check on OSX Yosemite (10.10)

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
parent 32f335ca
...@@ -658,6 +658,11 @@ struct HasLengthEstimator : std::false_type {}; ...@@ -658,6 +658,11 @@ struct HasLengthEstimator : std::false_type {};
template <class Src> template <class Src>
constexpr typename std::enable_if< constexpr typename std::enable_if<
!std::is_fundamental<Src>::value !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 && !IsSomeString<Src>::value
&& !std::is_convertible<Src, const char*>::value && !std::is_convertible<Src, const char*>::value
&& !std::is_convertible<Src, StringPiece>::value && !std::is_convertible<Src, StringPiece>::value
......
...@@ -24,7 +24,7 @@ namespace folly { ...@@ -24,7 +24,7 @@ namespace folly {
typedef SpinLockMslImpl SpinLock; typedef SpinLockMslImpl SpinLock;
#elif __APPLE__ #elif __APPLE__
typedef SpinLockAppleImpl SpinLock; typedef SpinLockAppleImpl SpinLock;
#elif __ANDROID__ #elif FOLLY_HAVE_PTHREAD_SPINLOCK_T
typedef SpinLockPthreadMutexImpl SpinLock; typedef SpinLockPthreadMutexImpl SpinLock;
#else #else
typedef SpinLockPthreadImpl SpinLock; typedef SpinLockPthreadImpl SpinLock;
......
...@@ -9,8 +9,8 @@ brewget() { ...@@ -9,8 +9,8 @@ brewget() {
brew install $@ || brew upgrade $@ brew install $@ || brew upgrade $@
} }
# tool dependencies: autotools, scons (for double-conversion), and gcc 4.9 # tool dependencies: autotools and scons (for double-conversion)
brewget autoconf automake libtool scons gcc brewget autoconf automake libtool scons
# dependencies # dependencies
brewget glog gflags boost libevent brewget glog gflags boost libevent
...@@ -18,7 +18,6 @@ brewget glog gflags boost libevent ...@@ -18,7 +18,6 @@ brewget glog gflags boost libevent
# Install the double-conversion library. # Install the double-conversion library.
# NB their install target installs the libs but not the headers, hence the # NB their install target installs the libs but not the headers, hence the
# CPPFLAGS and link shenanigans. # CPPFLAGS and link shenanigans.
DOUBLE_CONVERSION_CPPFLAGS="-I./double-conversion/src"
test -d double-conversion || { test -d double-conversion || {
git clone https://github.com/floitsch/double-conversion.git git clone https://github.com/floitsch/double-conversion.git
pushd double-conversion/src pushd double-conversion/src
...@@ -31,7 +30,15 @@ scons ...@@ -31,7 +30,15 @@ scons
# (this won't work if you've already installed libdouble-conversion into a # (this won't work if you've already installed libdouble-conversion into a
# default search path) # default search path)
rm -f libdouble-conversion*dylib rm -f libdouble-conversion*dylib
DOUBLE_CONVERSION_HOME=$(pwd)
popd popd
autoreconf -i 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
...@@ -92,10 +92,8 @@ AC_C_INLINE ...@@ -92,10 +92,8 @@ AC_C_INLINE
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_HEADER_TIME AC_HEADER_TIME
AC_C_VOLATILE AC_C_VOLATILE
AC_CHECK_TYPE([__int128], AC_CHECK_TYPE([__int128], AC_DEFINE([HAVE_INT128_T], [1], [Define if we have __int128]))
[AC_DEFINE([HAVE_INT128_T], [1], [Define if __int128 exists])], AC_CHECK_TYPES([ptrdiff_t, pthread_spinlock_t])
[AC_DEFINE([HAVE_INT128_T], [0], [Define if __int128 does not exist])])
AC_CHECK_TYPES([ptrdiff_t])
AC_CACHE_CHECK( AC_CACHE_CHECK(
[for ifunc support], [for ifunc support],
...@@ -274,6 +272,7 @@ AC_CHECK_FUNCS([getdelim \ ...@@ -274,6 +272,7 @@ AC_CHECK_FUNCS([getdelim \
pow \ pow \
strerror \ strerror \
pthread_yield \ pthread_yield \
pthread_atfork \
malloc_size \ malloc_size \
malloc_usable_size \ malloc_usable_size \
memrchr \ memrchr \
......
...@@ -84,7 +84,7 @@ class SpinLockAppleImpl { ...@@ -84,7 +84,7 @@ class SpinLockAppleImpl {
#include <pthread.h> #include <pthread.h>
#include <folly/Exception.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 // Apple and Android systems don't have pthread_spinlock_t, so we can't support
// this version on those platforms. // this version on those platforms.
...@@ -122,7 +122,7 @@ class SpinLockPthreadImpl { ...@@ -122,7 +122,7 @@ class SpinLockPthreadImpl {
} }
#endif // !__ANDROID__ && !__APPLE__ #endif // FOLLY_HAVE_PTHREAD_SPINLOCK_T
namespace folly { namespace folly {
......
...@@ -207,14 +207,18 @@ struct StaticMeta { ...@@ -207,14 +207,18 @@ struct StaticMeta {
int ret = pthread_key_create(&pthreadKey_, &onThreadExit); int ret = pthread_key_create(&pthreadKey_, &onThreadExit);
checkPosixError(ret, "pthread_key_create failed"); checkPosixError(ret, "pthread_key_create failed");
// pthread_atfork is not part of the Android NDK at least as of n9d. If #if FOLLY_HAVE_PTHREAD_ATFORK
// 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__
ret = pthread_atfork(/*prepare*/ &StaticMeta::preFork, ret = pthread_atfork(/*prepare*/ &StaticMeta::preFork,
/*parent*/ &StaticMeta::onForkParent, /*parent*/ &StaticMeta::onForkParent,
/*child*/ &StaticMeta::onForkChild); /*child*/ &StaticMeta::onForkChild);
checkPosixError(ret, "pthread_atfork failed"); 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 #endif
} }
~StaticMeta() { ~StaticMeta() {
......
...@@ -2,7 +2,7 @@ SUBDIRS = . function_benchmark ...@@ -2,7 +2,7 @@ SUBDIRS = . function_benchmark
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
CPPFLAGS += -Igtest-1.6.0/include CPPFLAGS += -Igtest-1.7.0/include
TESTS= \ TESTS= \
sorted_vector_types_test \ sorted_vector_types_test \
...@@ -17,11 +17,11 @@ TESTS= \ ...@@ -17,11 +17,11 @@ TESTS= \
check_LTLIBRARIES = libgtestmain.la libgtest.la check_LTLIBRARIES = libgtestmain.la libgtest.la
check_PROGRAMS = check_PROGRAMS =
libgtestmain_la_CPPFLAGS = -Igtest-1.6.0 -Igtest-1.6.0/src libgtestmain_la_CPPFLAGS = -Igtest-1.7.0 -Igtest-1.7.0/src
libgtestmain_la_SOURCES = gtest-1.6.0/src/gtest-all.cc gtest-1.6.0/src/gtest_main.cc 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_CPPFLAGS = -Igtest-1.7.0 -Igtest-1.7.0/src
libgtest_la_SOURCES = gtest-1.6.0/src/gtest-all.cc libgtest_la_SOURCES = gtest-1.7.0/src/gtest-all.cc
noinst_HEADERS = FBStringTestBenchmarks.cpp.h \ noinst_HEADERS = FBStringTestBenchmarks.cpp.h \
FBVectorTestBenchmarks.cpp.h FBVectorTestBenchmarks.cpp.h
...@@ -127,7 +127,7 @@ concurrent_skiplist_test_LDADD = libgtest.la $(top_builddir)/libfolly.la ...@@ -127,7 +127,7 @@ concurrent_skiplist_test_LDADD = libgtest.la $(top_builddir)/libfolly.la
TESTS += concurrent_skiplist_test TESTS += concurrent_skiplist_test
concurrent_skiplist_benchmark_SOURCES = ConcurrentSkipListBenchmark.cpp 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 check_PROGRAMS += concurrent_skiplist_benchmark
histogram_test_SOURCES = HistogramTest.cpp histogram_test_SOURCES = HistogramTest.cpp
......
...@@ -146,7 +146,7 @@ TEST(SpinLock, AppleTryLock) { ...@@ -146,7 +146,7 @@ TEST(SpinLock, AppleTryLock) {
} }
#endif #endif
#if !__ANDROID__ #if FOLLY_HAVE_PTHREAD_SPINLOCK_T
TEST(SpinLock, PthreadCorrectness) { TEST(SpinLock, PthreadCorrectness) {
correctnessTest<folly::SpinLockPthreadImpl>(); correctnessTest<folly::SpinLockPthreadImpl>();
} }
......
...@@ -207,7 +207,7 @@ TEST(SortedVectorTypes, Sizes) { ...@@ -207,7 +207,7 @@ TEST(SortedVectorTypes, Sizes) {
typedef sorted_vector_set<int,std::less<int>, typedef sorted_vector_set<int,std::less<int>,
std::allocator<int>,OneAtATimePolicy> SetT; std::allocator<int>,OneAtATimePolicy> SetT;
typedef sorted_vector_map<int,int,std::less<int>, 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(SetT), sizeof(std::vector<int>));
EXPECT_EQ(sizeof(MapT), sizeof(std::vector<std::pair<int,int> >)); EXPECT_EQ(sizeof(MapT), sizeof(std::vector<std::pair<int,int> >));
......
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