8

I would like to build Facebook's Proxygen c++ http libraries out of github with Ubuntu 16.04. Here's the environment I set up along with the deps.sh command to install dependencies:

gcc --version
  gcc (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609
export CPPFLAGS="-std=c++14"
export CXXFLAGS="-std=c++14"
git clone git@github.com:facebook/proxygen.git
cd proxygen/proxygen && ./deps.sh

That got me most of the way through building its folly dependency, but I am getting an incomplete type error:

libtool: compile:  g++ -DHAVE_CONFIG_H -I./.. -pthread -I/usr/include -std=c++14 -std=gnu++1y -std=c++14 -MT io/async/AsyncPipe.lo -MD -MP -MF io/async/.deps/AsyncPipe.Tpo -c io/async/AsyncPipe.cpp  -fPIC -DPIC -o io/async/.libs/AsyncPipe.o
In file included from /usr/include/c++/5/bits/move.h:57:0,
                 from /usr/include/c++/5/bits/stl_pair.h:59,
                 from /usr/include/c++/5/utility:70,
                 from /usr/include/c++/5/algorithm:60,
                 from ./../folly/Conv.h:26,
                 from Conv.cpp:16:
/usr/include/c++/5/type_traits: In instantiation of ‘struct std::make_unsigned<__int128>’:
Conv.cpp:528:52:   required from ‘folly::detail::ConversionResult<T> folly::detail::digits_to(const char*, const char*) [with Tgt = __int128]’
Conv.cpp:658:16:   required from here
/usr/include/c++/5/type_traits:1757:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128, false, false>’
     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
                                                              ^
/usr/include/c++/5/type_traits:1721:11: note: declaration of ‘class std::__make_unsigned_selector<__int128, false, false>’
     class __make_unsigned_selector;
           ^
/usr/include/c++/5/type_traits: In instantiation of ‘struct std::make_unsigned<__int128 unsigned>’:
Conv.cpp:528:52:   required from ‘folly::detail::ConversionResult<T> folly::detail::digits_to(const char*, const char*) [with Tgt = __int128 unsigned]’
Conv.cpp:661:16:   required from here

Has anyone tried or solved this? I'm not familiar with the code base yet. Tia.

moodboom
  • 6,225
  • 2
  • 41
  • 45
  • FYI the boost version pulled in by Ubuntu 16.04 is 1.58.0. – moodboom Aug 06 '16 at 16:36
  • 1
    Your compiler options now looks like "-std=c++14 -std=gnu++1y -std=c++14". If you try to compile code like this : #include int main () { auto a = std::make_unsigned<__int128> (); } you will fail, because of compilation options. Just delete CPPFLAGS, CXXFLAGS. – vadikrobot Aug 12 '16 at 12:02
  • Thanks @vadikrobot. I didn't have [gnu++1y] set, that's why I was trying c++14. – moodboom Aug 12 '16 at 13:59

1 Answers1

9

TL;DR Proxygen needs GNU extensions; use -std=gnu++11 or -std=gnu++14


Why do you need to override C++ standard when building proxygen and its dependencies? Folly itself specifies -std=gnu++1y. If you remove

export CPPFLAGS="-std=c++14"
export CXXFLAGS="-std=c++14"

and try to build it, it almost will, the only change that I had to make to folly is to fix membarrier.

If you insist on using -std=c++14, then the problem actually is not in folly, it's in libstdc++ handling of GNU extensions, this simple line:

typedef std::make_unsigned<__int128>::type int128_type;

Will easily compile with -std=gnu++11 or -std=gnu++1y, but will fail with any of -std=c++11 or -std=c++14. And it's hard to tell, whether it is a bug (because the compiler provides __int128 type (and folly detects that in its configure script, BTW) but C++ library has problems with it) or a feature (because __int128 is an extension in the first place and one should use some GNU variant of standard to properly get it).

moodboom
  • 6,225
  • 2
  • 41
  • 45
Roman Khimov
  • 4,807
  • 1
  • 27
  • 35
  • This is exactly what I was looking for, you saved me the time of working backwards to discovering that GNU extention. Appreciate the patch for folly, as well. – moodboom Aug 12 '16 at 13:41
  • 1
    Now to actually compile... without CPPFLAGS, using gcc 5.4.0, I get "checking if g++ supports C++1y features with -std=gnu++1y... no - configure: error: Could not find cxx1y support in g++". I added support for gnu++14 and away we go. – moodboom Aug 12 '16 at 14:18
  • Final result: built with no errors, all tests passed. Thanks Roman. FYI I didn't need the folly patch. – moodboom Aug 12 '16 at 15:23
  • Roman, once I got to the installation step, I found that I did need your membarrier patch. Thank you. – moodboom Aug 14 '16 at 04:57