rizinorg / rizin

UNIX-like reverse engineering framework and command-line toolset.
https://rizin.re
GNU Lesser General Public License v3.0
2.71k stars 363 forks source link

Build Improvements for Packaging #2013

Closed carlocab closed 2 years ago

carlocab commented 2 years ago

Is your feature request related to a problem? Please describe. @ebmmy was kind enough to work on packaging Rizin for Homebrew. See Homebrew/homebrew-core#89709.

While trying to get the build to pass in Homebrew CI, we encountered issues in meson being able to find Homebrew xxhash and libmagic.

libmagic is found via Meson's find_library. Unfortunately, find_library doesn't seem to know how to find Homebrew-installed libraries by default, so we worked around this by adding a dirs argument to the find_library call.

xxhash is found using Meson's dependency, which uses pkg-config. Unfortunately, pkg-config looks for an xxhash.pc, but a default xxhash build installs only libxxhash.pc. We worked around this by creating a symlink, but it would be nice if this were not needed.

Describe the solution you'd like For libmagic, it might help if there were additional options in meson_options.txt that allow passing the path to the directory containing libmagic, which is then passed to the dirs argument of find_library. This would allow us to pass this as a flag to meson rather than modifying your build script (which can be a bit fragile).

I'm not sure if a similar fix would work for xxhash, but since meson.build seems to fall back to find_library when dependency doesn't work, this might too.

Describe alternatives you've considered We could keep carrying around our workarounds, but it would be nice if we didn't have to. Finding fixes here would also ensure that your users who encounter the same problems we did (outside of Homebrew) wouldn't have to discover our workarounds for themselves.

Additional context As mentioned above, this is related to Homebrew/homebrew-core#89709.

ret2libc commented 2 years ago

@ebmmy was kind enough to work on packaging Rizin for Homebrew. See Homebrew/homebrew-core#89709.

Amazing!! <3 Thanks a lot for this, it's much appreciated.

I will work through the rest of your report to find the best solution.

ret2libc commented 2 years ago

xxhash is found using Meson's dependency, which uses pkg-config. Unfortunately, pkg-config looks for an xxhash.pc, but a default xxhash build installs only libxxhash.pc. We worked around this by creating a symlink, but it would be nice if this were not needed.

Nice catch, I think indeed I should replace dependency('xxhash'..) with dependency('libxxhash') because also on Ubuntu, Fedora and Arch linux the file is called libxxhash.pc. I guess this was a mistake on my side and with this change the find_library fallback should not be needed.

carlocab commented 2 years ago

That makes sense. Maybe a dependency('libmagic'...) would work for our libmagic issue too? We have a libmagic.pc. Is there any reason libmagic doesn't use the dependency-with-fallback-to-find_library pattern for the other dependencies?

ret2libc commented 2 years ago

libmagic is found via Meson's find_library. Unfortunately, find_library doesn't seem to know how to find Homebrew-installed libraries by default, so we worked around this by adding a dirs argument to the find_library call.

Same for this. We should probably just use dependency('libmagic'...).

ret2libc commented 2 years ago

Is there any reason libmagic doesn't use the dependency-with-fallback-to-find_library pattern for the other dependencies?

From the top of my head I think I did it that way because I couldn't find the .pc files, but I could be wrong as well and I could have just missed those files. The safest approach is probably to use the dependency + find_library fallback approach for both libs.

carlocab commented 2 years ago

I couldn't find the .pc files

libmagic's .pc file is also called libmagic.pc, so that might also be why dependency('magic'...) doesn't work.

ret2libc commented 2 years ago

@carlocab is it ok if we reference homebrew in our INSTALL section as a way to install Rizin on Mac after the formula will be mergd?

carlocab commented 2 years ago

Of course; that's more than okay. :)

ret2libc commented 2 years ago

@carlocab https://github.com/rizinorg/rizin/pull/2023

carlocab commented 2 years ago

Thanks!

XVilka commented 2 years ago

@carlocab the fix is now included in the 0.3.3 release: https://github.com/rizinorg/rizin/releases/tag/v0.3.3

carlocab commented 2 years ago

Yep, I noticed. Thanks for the update!