Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation with homebrew fails (Mac) #2031

Closed
marnixhoh opened this issue Jun 30, 2023 · 15 comments
Closed

Installation with homebrew fails (Mac) #2031

marnixhoh opened this issue Jun 30, 2023 · 15 comments

Comments

@marnixhoh
Copy link

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.

@Di3go-Opr3a
Copy link

I really think the problem is because it is no longer supported. Have you tried if to see if it is possible to upgrade your macOs ? Otherwise, you can try using a version manager such as "asdf" or "pyenv" to handle different versions of dependencies

@marnixhoh
Copy link
Author

@Di3go-Opr3a Thank you for your reply! Unfortunately, upgrading my os is not possible as my Macbook Pro does not support any newer versions of macOs...

Yeah I was considering that but the problem is that I can't seem to find folly's changelog anywhere. So I can't check which version might work for me

@Di3go-Opr3a
Copy link

@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

@marnixhoh
Copy link
Author

@Di3go-Opr3a Thank you sooo much for digging into this for me. I tried installing the version of Folly at the time of #1545 and it worked!

It would be really nice if Folly's changelog would be public somewhere, so I could find the last version that is supported for my OS. Oh well...

Thank you so much again!! Really appreciate it 😄

@sid-bhargav
Copy link

@marnixhoh @Di3go-Opr3a Hi! I apologize if this is sort of stupid question but I'm having the same issue as you and since I'm new to macOS I'm a little bit confused about what to do.

How do I install an older release of folly? And when I try to install watchman with homebrew once more will it not try to update my installation of folly?

Again, I apologize if these are trivial questions. I have struggled to understand what to Google and where to learn how to do this, so any guidance on where to learn more about this would also be greatly appreciated.

Thanks for your time.

@marnixhoh
Copy link
Author

Hi @sid-bhargav! Let me quickly try to help you out here ;)

Installing older versions of software with homebrew is notoriously cumbersome, but it can be done. I recommend checking out this link: https://github.com/orgs/Homebrew/discussions/155#discussioncomment-133894

To your next question, I just found that out myself, after I successfully installed an older version of folly... When installing the latest or even older versions of a package through homebrew, it will download the latest version of its dependencies. This effectively means that installing watchman through homebrew with an older version of folly is not possible. (at least not to my knowledge.)

I hope I have answered your questions here and if you do end up finding a way to install watchman with an older version of folly using homebrew then please let me know 😄

@sryze
Copy link

sryze commented Oct 8, 2023

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
Copy link
Author

marnixhoh commented Nov 5, 2023

@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)

@sryze
Copy link

sryze commented Nov 5, 2023

Ah, yes, I meant 10.15. Glad that it helped you 😃

@Tony-MK
Copy link

Tony-MK commented Nov 7, 2023

@sryze, Thank you so much. 😄 🚀
It worked on my Mac, which is running macOS 10.15.7.

@Paras534
Copy link

i had also done this but it gives me still this:

Last 15 lines from /Users/Paras/Library/Logs/Homebrew/folly/02.cmake:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/netinet/in.h:659:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/netinet6/in6.h:171:2: error: unknown type name 'sa_family_t'
sa_family_t sin6_family; /* AF_INET6 (sa_family_t) /
^
In file included from /tmp/folly-20231130-4920-ztd55l/folly-2023.11.27.00/folly/FileUtil.cpp:26:
In file included from /tmp/folly-20231130-4920-ztd55l/folly-2023.11.27.00/folly/net/NetOps.h:99:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/un.h:78:2: error: unknown type name 'sa_family_t'
sa_family_t sun_family; /
[XSI] AF_UNIX */
^
11 errors generated.
make[2]: *** [CMakeFiles/folly_base.dir/folly/FileUtil.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/folly_base.dir/all] Error 2
make: *** [all] Error 2

@barracuda156
Copy link

folly has been broken by a few commits in the beginning of 2023. See: #2099

@barracuda156
Copy link

@marnixhoh Well, even if that works to bypass the problem at hand, hacking the SDK is not something desirable, and is likely to cause unknown number of breakages, since no software will expect that.

@barracuda156
Copy link

Perhaps placing something like this in an appropriate folly header gonna work:

#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 110000
#ifdef __DARWIN_ALIGN32
#undef __DARWIN_ALIGN32
#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
#endif
#endif

@barracuda156
Copy link

Adding this to folly/io/async/fdsock/AsyncFdSocket.h:

#ifdef __APPLE__
#include <AvailabilityMacros.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
#ifdef __DARWIN_ALIGN32
#undef __DARWIN_ALIGN32
#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
#endif
#endif
#endif

@sryze Thank you for finding the cause of the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants