folly: Installation with homebrew fails (Mac)

I am trying to install folly on my Mac using homebrew: brew install folly. I need follyas it is a dependency of watchman.

Unfortunately it fails and I receive the following error:

Last 15 lines from /Users/xxx/Library/Logs/Homebrew/folly/02.cmake:
/tmp/folly-20230629-51773-87s7za/folly-2023.06.26.00/folly/io/async/fdsock/AsyncFdSocket.cpp:129:16: error: cannot initialize object parameter of type 'folly::AsyncSocket' with an expression of type 'folly::AsyncFdSocket'
  AsyncSocket::setSendMsgParamCB(&sendMsgCob_);
               ^~~~~~~~~~~~~~~~~
/tmp/folly-20230629-51773-87s7za/folly-2023.06.26.00/folly/io/async/fdsock/AsyncFdSocket.cpp:136:16: error: cannot initialize object parameter of type 'folly::AsyncSocket' with an expression of type 'folly::AsyncFdSocket'
  AsyncSocket::releaseIOBuf(std::move(buf), callback);
               ^~~~~~~~~~~~
/tmp/folly-20230629-51773-87s7za/folly-2023.06.26.00/folly/io/async/fdsock/AsyncFdSocket.cpp:298:18: error: cannot initialize object parameter of type 'folly::AsyncSocket' with an expression of type 'folly::AsyncFdSocket'
    AsyncSocket::failRead(__func__, ex);
                 ^~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/folly_base.dir/folly/io/async/fdsock/AsyncFdSocket.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/folly_base.dir/all] Error 2
make: *** [all] Error 2

Thank you so much for any help or guidance! ๐Ÿ˜ƒ

PS My mac is running on macOS 10.15, which is officially no longer supported by homebrew. Nevertheless, I hope there is some sort of solution / workaround.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15

Most upvoted comments

@sryze I have no idea how you have found that workaround, but thank you so much! ๐Ÿš€

I think you meant this though (wrong version number):

sudo nano /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/i386/_param.h

Just to clarify for anyone else running into this issue, you would have to change following line:

#define       __DARWIN_ALIGN32(p)       ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)

to:

#define       __DARWIN_ALIGN32(p)       ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)

I have the same issue with upgrading folly on Catalina (itโ€™s a dependency of a package that I have previously installed).

==> cmake -S . -B build/shared -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH=@loader_path/../lib -DCMAKE_LIBRARY_ARCHITECTURE=x86_64 -DFOLLY_USE_JEMALLOC=OFF
==> cmake --build build/shared
Last 15 lines from /Users/szx/Library/Logs/Homebrew/folly/02.cmake:
  void failWrite(
       ^
/tmp/folly-20231009-82200-n3a2wj/folly-2023.10.02.00/folly/io/async/AsyncSocket.h:1821:8: note: candidate function not viable: requires 2 arguments, but 4 were provided
  void failWrite(const char* fn, const AsyncSocketException& ex);
       ^
/tmp/folly-20231009-82200-n3a2wj/folly-2023.10.02.00/folly/io/async/fdsock/AsyncFdSocket.cpp:147:3: error: cannot initialize object parameter of type 'folly::AsyncSocket' with an expression of type 'folly::AsyncFdSocket'
  writeChain(callback, std::move(buf), flags);
  ^~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/folly_base.dir/folly/io/async/fdsock/AsyncFdSocket.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/folly_base.dir/all] Error 2

But whatโ€™s funny is that I can build the same version of folly (v2023.10.02.00) successfully from git with the same cmake flags as Homebrew uses and same clang version.

Update:

The actual error from my Homebrew build is below. It looks like brew normally prints only the last error which is not helpful here.

/tmp/folly-20231009-69505-k2af9s/folly-2023.10.02.00/folly/io/async/fdsock/AsyncFdSocket.h:236:25: error: non-type template argument is not a constant expression
    std::array<uint8_t, CMSG_SPACE(sizeof(int) * kMaxFdsPerSocketMsg)>
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/socket.h:652:33: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/folly-20231009-69505-k2af9s/folly-2023.10.02.00/folly/io/async/fdsock/AsyncFdSocket.h:236:25: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression

Clang version:

folly-2023.10.02.00 % /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Update 2

It turns out that Homebrew uses MacOSX SDK 10.15 instead of 11.1 which comes with Xcode 12 and which is used by CMake by default. In 10.15 there is a bug in the definition of __DARWIN_ALIGN32 that causes it to produce a non-constant value.

Workaround:

  • sudo vim /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/i386/_param.h
  • remove (char *) casts

@marnixhoh look I tried to search a little, but precisely I can not tell you however I found this ! Practically reading problems of other users it seems that your version is compatible with folly of 2021. So i suggest you to try some version of 2021 to see if it works: version: https://github.com/facebook/folly/releases?page=8 supporto macOS #1545 2021.03.08.00 #72752