hhvm/homebrew-hhvm

Can not find libelf/libdwarf when attempting to install into a custom prefix

dfings opened this issue · 7 comments

Description

When trying to install hhvm, I get the following error:

CMake Error at /Users/dfingal/homebrew/Cellar/cmake/3.19.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find LibDwarf (missing: LIBELF_FOUND)
Call Stack (most recent call first):
  /Users/dfingal/homebrew/Cellar/cmake/3.19.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
  CMake/FindLibDwarf.cmake:50 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMake/HPHPFindLibs.cmake:265 (find_package)
  CMakeLists.txt:106 (include)

This is on an install with a custom homebrew in my home directory (/Users/dfingal/homebrew/)

Context and Logs

Parameter Value
OS X Version: 10.15.7
Homebrew Version: 2.7.4
Xcode Version: 12.3

Output of clang -v:

Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Build logs:
https://gist.github.com/dfings/90be449372fe6016f3b4fe67aaed1a2d

We currently use FindLibElf.cmake and FindLibDwarf.cmake which use a specified list of paths instead of using pkg-config. While there is a copyright notice, it only mentions the original author, not project, so I can't find a newer version or history to understand why pkg-config is not being used here - or if it would be safe to switch.

It would be good to use pkg-config if possible, but testing this on all supported platforms would be very time consuming (there are 22 libraries with a similar setup which may also give you problems if this is resolved) - and it's unlikely we'll be able to spare that time soon.

That said, these two libraries check the CPATH and LIBRARY_PATH variables for includes and libraries respectively; if set to the paths in your homebrew prefix, you may be able to build, if there are not other dependencies with similar problems that do not respect those paths. If successful, the build may take several hours (depending on your computer) and will need a lot of RAM - 8GB may be insufficient.

Atry commented

Is this issue fixed by facebook/hhvm@1d99b20 ?

Yep

It would be good to use pkg-config if possible, but testing this on all supported platforms would be very time consuming

Ended up having to do this

Atry commented

It is not really fixed according to my test

==> Installing hhvm/hhvm/hhvm-nightly
==> cmake -DCMAKE_INSTALL_SYSCONFDIR=/Users/atry/homebrew/etc -DDEFAULT_CONFIG_DIR=/Users/atry/homebrew/etc/hhvm -DSYSTEM_PCRE_HAS_JIT=0 -DENABLE_MCROUTER=OFF -DENABLE_EXTENSION_MCROUTER=OFF -DENABLE_EXTENSION_IMAP=OFF -DMYSQL_UNIX_SOCK_ADDR=/tmp/mysql.sock -DCMAKE_C_FL
Last 15 lines from /Users/atry/Library/Logs/Homebrew/hhvm-nightly/01.cmake:
-- Could NOT find LibElf (missing: LIBELF_INCLUDE_DIRS) 
-- Performing Test ELF_GETSHDRSTRNDX
-- Performing Test ELF_GETSHDRSTRNDX - Failed
CMake Error at /Users/atry/homebrew/Cellar/cmake/3.22.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find LibDwarf (missing: LIBELF_FOUND)
Call Stack (most recent call first):
  /Users/atry/homebrew/Cellar/cmake/3.22.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  CMake/FindLibDwarf.cmake:61 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMake/HPHPFindLibs.cmake:259 (find_package)
  CMakeLists.txt:79 (include)


-- Configuring incomplete, errors occurred!
See also "/tmp/hhvm-nightly-20220202-9823-23ujv6/hhvm-nightly-2022.01.29/CMakeFiles/CMakeOutput.log".
See also "/tmp/hhvm-nightly-20220202-9823-23ujv6/hhvm-nightly-2022.01.29/CMakeFiles/CMakeError.log".

Do not report this issue to Homebrew/brew or Homebrew/core!

Atry commented

I think facebook/hhvm@1d99b20 did not change FindLibElf.cmake. We need to apply similar approach to FindLibElf.cmake

Also, see https://docs.hhvm.com/hhvm/installation/building-from-source#building-hhvm__macos for extra variables that need setting.

Though, in general, hhvm's mac build is only tested with homebrew using it's default paths (as that is required for the binaries to be reusable)