Open Begasus opened 1 year ago
This started out for me as I went to update to cutter's version to 2.2.1. We already had some conversation on that PR about it, thought I'd drop it here so it's easier to detect. Previous PR and work-around: https://github.com/haikuports/haikuports/pull/8713
Adding output log ... CMakeOutput.log.txt
With patching still working (although still without decompiler)
Wondering ... isn't there an option to force the search with pkg-config (as the pkgconfig files are already present)?
Hey @Begasus , sorry for the late reply but how did you install Rizin? Is there a package for Rizin on Haiku? Could you paste the content of /boot/system/lib/cmake/rz_core/rz_coreConfig.cmake please?
Also, could you tell me the exact path the rz_core library is in Haiku?
Quite busy atm on haikuports side, so sorry for not getting back sooner, I'll try to add some files for the build process and mentioned one.
rz_core in installed in /boot/system/lib (default on 64bit system) and /boot/system/lib/x86 (defaults for 32bit hybrid).
Build log: Build_Rizin.txt
Contets of rz_coreConfig.cmake:
################################################################################
#
# This module provides the following imported targets, if found:
#
# rz_core::rz_core
#
# This file is intended to be consumed by clients who wish to use rz_core from CMake.
# The recommended way to use find this module is using `find_package(Rizin COMPONENTS ...)`.
#
# Provides the following variables
# rz_core_FOUND - Flag for indicating that rz_core package has been found
# rz_core_VERSION - Version of rz_core
# rz_core_INCLUDE_DIRS - Directories to include
# rz_core_LIBRARY - Path to the single library that this module represents, without dependencies
# rz_core_LIBRARIES - Libraries to link
# rz_core_LIBRARY_DIRS - Library directories to search for link libraries
# rz_core_PLUGINDIR - Directory where plugins are placed, without the prefix part
#
################################################################################
set(RIZIN_MODULE_PREFIXED rz_core)
set(rz_core_VERSION 0.6.2)
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
set(rz_core_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/develop/headers/librz" "${PACKAGE_PREFIX_DIR}/develop/headers/librz/sdb")
set_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
find_library(rz_core_LIBRARY NAMES rz_core HINTS "${rz_core_LIBRARY_DIRS}" NO_DEFAULT_PATH REQUIRED)
set(rz_core_LIBRARIES "${rz_core_LIBRARY}")
set(_rz_core_DEPENDENCIES rz_magic rz_util rz_demangler rz_diff rz_reg rz_syscall rz_search rz_cons rz_analysis rz_socket rz_type rz_io rz_lang rz_hash rz_flag rz_parse rz_egg rz_debug rz_crypto rz_config rz_bin rz_asm rz_bp rz_sign rz_il)
set(rz_core_PLUGINDIR /packages/rizin-0.6.2-1/.self/data/rizin/cutter/plugins)
include(CMakeFindDependencyMacro)
get_filename_component(_rizin_cmake_path "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set(_rz_core_DEPENDENCY_TARGETS)
foreach(_module_dep ${_rz_core_DEPENDENCIES})
if (NOT ${_module_dep}_FOUND)
find_dependency(${_module_dep} PATHS ${_rizin_cmake_path} NO_DEFAULT_PATH)
endif()
if (NOT ${_module_dep}_FOUND)
set(rz_core_FOUND False)
return()
endif()
list(APPEND rz_core_INCLUDE_DIRS "${${_module_dep}_INCLUDE_DIRS}")
list(APPEND rz_core_LIBRARIES "${${_module_dep}_LIBRARIES}")
list(APPEND _rz_core_DEPENDENCY_TARGETS "${_module_dep}::${_module_dep}")
endforeach()
list(REMOVE_DUPLICATES rz_core_INCLUDE_DIRS)
list(REMOVE_DUPLICATES rz_core_LIBRARIES)
if(NOT TARGET rz_core::rz_core)
add_library(rz_core::rz_core SHARED IMPORTED)
target_link_libraries(rz_core::rz_core INTERFACE ${_rz_core_DEPENDENCY_TARGETS})
set_target_properties(rz_core::rz_core PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${rz_core_INCLUDE_DIRS}")
set_target_properties(rz_core::rz_core PROPERTIES
IMPORTED_LOCATION "${rz_core_LIBRARY}")
endif()
set(rz_core_TARGET rz_core::rz_core)
For the record, this is our recipe to build rizin for Haiku. https://github.com/haikuports/haikuports/blob/master/dev-util/rizin/rizin-0.6.2.recipe
Can you also share the rz_userconf.h file of rizin?
I'm not 100% sure yet, but I think you should set the --prefix
to /boot/system
if that's where you are actually going to install rizin. Instead, in the meson logs I see this:
prefix : /packages/rizin-0.6.2-1/.self
bindir : bin
libdir : lib
includedir : develop/headers/librz
datadir : data
wwwroot : data/rizin/www
sdb : data/rizin
sigdb : data/rizin/sigdb
themes : data/rizin/cons
fortunes : data/rizin/fortunes
flags : data/rizin/flag
hud : data/rizin/hud
plugins : /packages/rizin-0.6.2-1/.self/data/rizin/cutter/plugins
bindings : lib/rizin-bindings
prefix is set in the recipe (as you could have seen in the link in my previous comment), just in case pasting it here:
meson build \
--buildtype=release \
--wrap=default \
--prefix=$prefix \
--bindir=$commandBinDir \
--datadir=$dataDir \
--libdir=$libDir \
--includedir=$includeDir \
--mandir=$manDir \
-D default_library=shared \
-D rizin_plugins=$dataDir/rizin/cutter/plugins \
-D use_sys_capstone=enabled \
-D use_sys_magic=enabled \
-D use_sys_libmspack=enabled \
-D use_sys_libzip=enabled \
-D use_sys_zlib=enabled \
-D use_sys_lzma=enabled \
-D use_sys_lz4=enabled \
-D use_sys_xxhash=enabled \
-D use_sys_openssl=enabled \
-D enable_tests=false \
-D enable_rz_test=false \
-D subprojects_check=false
ninja -C build
$prefix actually points to /boot/system
Content of rz_userconf.h:
#ifndef RZ_CONFIGURE_H
#define RZ_CONFIGURE_H
#include "rz_build_version.h"
// clang-format off
#define RZ_CHECKS_LEVEL 1
#define DEBUGGER 1
#define HAVE_THREADS 1
#define HAVE_PTHREAD 1
#define HAVE_LZMA 1
#define HAVE_ZLIB 1
#define HAVE_DECL_ADDR_NO_RANDOMIZE 0
#define HAVE_DECL_PROCCTL_ASLR_CTL 0
#define HAVE_ARC4RANDOM_UNIFORM 0
#define HAVE_EXPLICIT_BZERO 0
#define HAVE_EXPLICIT_MEMSET 0
#define HAVE_CLOCK_NANOSLEEP 1
#define HAVE_SIGACTION 1
#define HAVE_PIPE 1
#define HAVE_EXECV 1
#define HAVE_EXECVE 1
#define HAVE_EXECVP 1
#define HAVE_EXECL 1
#define HAVE_SYSTEM 1
#define HAVE_REALPATH 1
#define HAVE_PIPE2 0
#define HAVE_ENVIRON 1
#define HAVE_OPENPTY 0
#define HAVE_FORKPTY 0
#define HAVE_LOGIN_TTY 0
#define HAVE_SHM_OPEN 1
#define HAVE_LIB_MAGIC 1
#define USE_LIB_MAGIC 1
#define HAVE_LIB_XXHASH 1
#define USE_LIB_XXHASH 1
#define HAVE_LIB_SSL 1
#define HAVE_PTRACE 0
#define USE_PTRACE_WRAP 0
#define HAVE_FORK 1
#define HAVE_STRLCPY 1
#define HAVE_STRNLEN 1
#define WANT_DYLINK 1
#define WITH_GPL 1
#define HAVE_JEMALLOC 1
#define IS_IOS 0
#define RZ_BUILD_DEBUG 0
#define WITH_SWIFT_DEMANGLER 1
#define HAVE_COPYFILE 0
#define HAVE_COPY_FILE_RANGE 0
#define HAVE_BACKTRACE 0
#define HAVE___BUILTIN_BSWAP16 1
#define HAVE___BUILTIN_BSWAP32 1
#define HAVE___BUILTIN_BSWAP64 1
#define HAVE_POSIX_MEMALIGN 1
#define HAVE__ALIGNED_MALLOC 0
#define HAVE_HEADER_LINUX_ASHMEM_H 0
#define HAVE_HEADER_SYS_SHM_H 0
#define HAVE_HEADER_SYS_IPC_H 1
#define HAVE_HEADER_SYS_MMAN_H 1
#define HAVE_HEADER_INTTYPES_H 1
#define RZ_IS_PORTABLE 0
#define RZ_BINDIR_DEPTH 1
// clang-format on
#define RZ_PREFIX "/packages/rizin-0.6.2-1/.self"
#define RZ_BINDIR "bin"
#define RZ_LIBDIR "lib"
#define RZ_INCDIR "develop/headers/librz"
#define RZ_DATDIR "data"
#define RZ_WWWROOT "data/rizin/www"
#define RZ_PLUGINS "/packages/rizin-0.6.2-1/.self/data/rizin/cutter/plugins"
#define RZ_DATADIR "data/rizin"
#define RZ_SDB "data/rizin"
#define RZ_SIGDB "data/rizin/sigdb"
#define RZ_THEMES "data/rizin/cons"
#define RZ_FORTUNES "data/rizin/fortunes"
#define RZ_FLAGS "data/rizin/flag"
#define RZ_HUD "data/rizin/hud"
#define RZ_SDB_ARCH_PLATFORMS RZ_JOIN_3_PATHS(RZ_SDB, "asm", "platforms")
#define RZ_SDB_ARCH_CPUS RZ_JOIN_3_PATHS(RZ_SDB, "asm", "cpus")
#define RZ_SDB_TYPES RZ_JOIN_2_PATHS(RZ_SDB, "types")
#define RZ_SDB_OPCODES RZ_JOIN_2_PATHS(RZ_SDB, "opcodes")
#define RZ_SDB_REG RZ_JOIN_2_PATHS(RZ_SDB, "reg")
#define RZ_SDB_MAGIC RZ_JOIN_2_PATHS(RZ_SDB, "magic")
#define RZ_SDB_FORMAT RZ_JOIN_2_PATHS(RZ_SDB, "format")
#define RZ_PDB RZ_JOIN_2_PATHS(RZ_DATADIR, "pdb")
#define RZ_PROJECTS RZ_JOIN_2_PATHS(RZ_DATADIR, "projects")
#define RZ_BINRC RZ_JOIN_2_PATHS(RZ_DATADIR, "rc.d")
#define RZ_HOME_PREFIX ".local"
#define RZ_HOME_CONFIGDIR RZ_JOIN_2_PATHS(".config", "rizin")
#define RZ_HOME_CACHEDIR RZ_JOIN_2_PATHS(".cache", "rizin")
#define RZ_HOME_HISTORY RZ_JOIN_2_PATHS(RZ_HOME_CACHEDIR, "history")
#define RZ_HOME_CONFIG_RC RZ_JOIN_2_PATHS(RZ_HOME_CONFIGDIR, "rizinrc")
#define RZ_HOME_CONFIG_RC_DIR RZ_JOIN_2_PATHS(RZ_HOME_CONFIGDIR, "rizinrc.d")
#define RZ_GLOBAL_RC RZ_JOIN_2_PATHS(RZ_DATADIR, "rizinrc")
#define RZ_HOME_RC ".rizinrc"
// This is an optional extra prefix used to load plugins, sdb files, sdb files,
// etc. It can be outside the default prefix. Used e.g. by Homebrew to load
// plugins from the general /opt/homebrew prefix instead of the version specific
// prefix e.g. /opt/homebrew/Cellar/rizin/0.x.y/
// clang-format off
#define RZ_EXTRA_PREFIX 0
// clang-format on
#endif
prefix is set in the recipe (as you could have seen in the link in my previous comment), just in case pasting it here:
I've looked at the recipe and I see where it is set, however...
$prefix actually points to /boot/system
This is not what the rizin build logs say.
prefix : /packages/rizin-0.6.2-1/.self
bindir : bin
libdir : lib
includedir : develop/headers/librz
Content of rz_userconf.h:
#define RZ_PREFIX "/packages/rizin-0.6.2-1/.self" #define RZ_BINDIR "bin" #define RZ_LIBDIR "lib" #define RZ_INCDIR "develop/headers/librz" #define RZ_DATDIR "data" #define RZ_WWWROOT "data/rizin/www" #define RZ_PLUGINS "/packages/rizin-0.6.2-1/.self/data/rizin/cutter/plugins"
You can see it here as well that RZ_PREFIX/aka prefix is not /boot/system. Is it a symlink maybe? Anyway, I think it would be better to set it straight to /boot/system if possible.
Packages are created as archived ones, once they are installed all the contect is available in /boot/system, as all our packages are and can be found by other packages requiring them. Installing directly to /boot/system is not possible as the system directories are read-only. Building them is done in a chroot environment where the packages are "mounted" and available by for others.
Right, in those cases I think the common approach is to use the prefix that you would like to have (/boot/system
in this case) but use a destdir during the install phase. Would that work for Haiku?
It would be something like this:
$ meson setup --prefix=/boot/system build
$ meson compile -C build
$ meson install -C build --destdir=/tmp/dir/
$ tree /tmp/dir/
/tmp/dir
└── boot
└── system
├── bin
│ ├── rizin
│ ├── rz-asm
│ ├── rz-ax
│ ├── rz-bin
│ ├── rz-diff
│ ├── rz-find
│ ├── rz-gg
│ ├── rz-hash
│ ├── rz-run
│ ├── rz-sign
│ └── rz-test
├── include
│ └── librz
│ ├── rz_agraph.h
│ ├── rz_analysis.h
│ ├── rz_asm.h
│ ├── rz_basefind.h
│ ├── rz_bin.h
[...]
Need to still investigate this, doing other ports in between, will get back to you, but so far this has never been done in our ports.
Any news here?
At least no progress, tried a few things on my end with no luck. (has been a while though)
OK, tried using the mentioned way setting prefix to /boot/system etc. , still getting an error not finding rz_core
waiting for build package cutter-2.3.4-1 to be activated
Building ...
CMake Error at /boot/system/lib/cmake/rz_core/rz_coreConfig.cmake:35 (find_library):
Could not find rz_core_LIBRARY using the following names: rz_core
Call Stack (most recent call first):
/boot/system/lib/cmake/Rizin/RizinConfig.cmake:96 (find_package)
CMakeLists.txt:78 (find_package)
From rz_userconf.h:
#define RZ_PREFIX "/boot/system"
#define RZ_BINDIR "bin"
#define RZ_LIBDIR "lib"
#define RZ_INCDIR "develop/headers/librz"
#define RZ_DATDIR "data"
#define RZ_WWWROOT "data/rizin/www"
#define RZ_PLUGINS "/boot/system/data/rizin/cutter/plugins"
#define RZ_DATADIR "data/rizin"
#define RZ_SDB "data/rizin"
#define RZ_SIGDB "data/rizin/sigdb"
#define RZ_THEMES "data/rizin/cons"
#define RZ_FORTUNES "data/rizin/fortunes"
#define RZ_FLAGS "data/rizin/flag"
#define RZ_HUD "data/rizin/hud"
From rz_coreConfig.cmake:
set(rz_core_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/develop/headers/librz" "${PACKAGE_PREFIX_DIR}/develop/headers/librz/sdb")
set_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
find_library(rz_core_LIBRARY NAMES rz_core HINTS "${rz_core_LIBRARY_DIRS}" NO_DEFAULT_PATH REQUIRED)
set(rz_core_LIBRARIES "${rz_core_LIBRARY}")
set(_rz_core_DEPENDENCIES rz_magic rz_util rz_demangler rz_diff rz_reg rz_syscall rz_search rz_cons rz_analysis rz_socket rz_type rz_io rz_lang rz_hash rz_flag rz_parse rz_egg rz_debug rz_crypto rz_config rz_bin rz_asm rz_bp rz_sign rz_il)
set(rz_core_PLUGINDIR /boot/system/data/rizin/cutter/plugins)
@Begasus could you paste a bit more from the rz_coreConfig.cmake
file? In particular, i'd be interested in the line get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}.....)
. Thanks a lot! Hopefully we can fix this!
From a default build:
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
When using --prefix=/boot/system
:
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../../../boot/system" ABSOLUTE)
EDIT: got the wrong file for the second line :)
@Begasus is there a fast way for me to test a Haiku machine?
@ret2libc Quickest way I guess would be to setup a VM:
pkgman full-sync
(pkgman is our package manager)-DCMAKE_INSTALL_PREFIX=/boot/home/config/non-packaged
(this path is also in $PATH so being detected by the system).pkgman install liblzma_devel
(this will also install the basic package providing only the libraries if not installed already).If you need assistance, I'm mostly online and can be contacted at IRC (OFTC #haiku), or over matrix (@begasushaiku:matrix.org)
EDIT, for liblzma you need xz_utils_devel (you can search for a library/cmd etc like: pkgman search lib:liblzma
or pkgman search devel:liblzma
or just pkgman search liblzma
).
Still something off in the cmake config files, but atleast got a build for Cutter and not patching it for rizin with the following:
cp -rf $sourceDir2/cutter-translations-$srcGitRev_2/* src/translations
rzLibDir="$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib$secondaryArchSubDir"
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release \
$cmakeDirArgs \
-DCMAKE_INSTALL_BINDIR=$prefix/bin \
-DCUTTER_ENABLE_PYTHON=ON \
-DCUTTER_USE_ADDITIONAL_RIZIN_PATHS=ON \
-DCUTTER_EXTRA_PLUGIN_DIRS=$dataDir/rizin/cutter/plugins \
-DCUTTER_USE_BUNDLED_RIZIN=OFF \
-DCUTTER_QT6=ON \
-Drz_core_LIBRARY=$rzLibDir/librz_core.so \
-Drz_magic_LIBRARY=$rzLibDir/librz_magic.so \
-Drz_util_LIBRARY=$rzLibDir/librz_util.so \
-Drz_demangler_LIBRARY=$rzLibDir/librz_demangler.so \
-Drz_diff_LIBRARY=$rzLibDir/librz_diff.so \
-Drz_reg_LIBRARY=$rzLibDir/librz_reg.so \
-Drz_syscall_LIBRARY=$rzLibDir/librz_syscall.so \
-Drz_search_LIBRARY=$rzLibDir/librz_search.so \
-Drz_analysis_LIBRARY=$rzLibDir/librz_analysis.so \
-Drz_crypto_LIBRARY=$rzLibDir/librz_crypto.so \
-Drz_flag_LIBRARY=$rzLibDir/librz_flag.so \
-Drz_hash_LIBRARY=$rzLibDir/librz_hash.so \
-Drz_parse_LIBRARY=$rzLibDir/librz_parse.so \
-Drz_asm_LIBRARY=$rzLibDir/librz_asm.so \
-Drz_config_LIBRARY=$rzLibDir/librz_config.so \
-Drz_bin_LIBRARY=$rzLibDir/librz_bin.so \
-Drz_io_LIBRARY=$rzLibDir/librz_io.so \
-Drz_socket_LIBRARY=$rzLibDir/librz_socket.so \
-Drz_type_LIBRARY=$rzLibDir/librz_type.so \
-Drz_il_LIBRARY=$rzLibDir/librz_il.so \
-Drz_lang_LIBRARY=$rzLibDir/librz_lang.so \
-Drz_egg_LIBRARY=$rzLibDir/librz_egg.so \
-Drz_debug_LIBRARY=$rzLibDir/librz_debug.so \
-Drz_bp_LIBRARY=$rzLibDir/librz_bp.so \
-Drz_sign_LIBRARY=$rzLibDir/librz_sign.so \
-Drz_cons_LIBRARY=$rzLibDir/librz_cons.so \
-DCMAKE_CXX_FLAGS="-fpermissive" -Wno-dev
make -C build $jobArgs
This works for Cutter and for rzghidra, problem now is that I can't get Cutter to pickup the plugin (doesn't show up in preferences). :) Anyway, progress :)
So it seems it can find it's headers fine with (from config files):
set(rz_core_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/develop/headers/librz" "${PACKAGE_PREFIX_DIR}/develop/headers/librz/sdb")
But doesn't find the actual library here?:
set_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
find_library(rz_core_LIBRARY NAMES rz_core HINTS "${rz_core_LIBRARY_DIRS}" NO_DEFAULT_PATH REQUIRED)
set(rz_core_LIBRARIES "${rz_core_LIBRARY}")
EDIT: it boils down where rz_core_LIBRARY_DIRS
is defined, from what I gather it's done with a python script, but didn't find where or how it picks it up. I could sed the path into the cmake config files, but there are quite a bit in there. :)
set_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
is wrong... it should be
set_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/develop/lib")
on Haiku.
set_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
is wrong... it should beset_and_check(rz_core_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/develop/lib")
on Haiku.
Yeah as used in the current settings I'm using for Cutter:
rzLibDir="$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib$secondaryArchSubDir"
I thought fixCMake
was supposed to make that change... But I've seen some HaikuPorts recipes doing it manually...
I thought
fixCMake
was supposed to make that change... But I've seen some HaikuPorts recipes doing it manually...
Skipped my mind! ... checking ;)
EDIT: that didn't work, path is not "fixed"
@XVilka looks like it searches in $libDir ($prefix/lib) for the *.so files, those are moved into our develop packages and end up in $developLibDir ($prefix/develop/lib) hence cutter not finding them.
With some finetuning together with @mtl1979 this came out and is working fine on 64bit and 32bit Haiku:
sed -i 's,\${PACKAGE_PREFIX_DIR}/lib,${PACKAGE_PREFIX_DIR}/develop/lib,g'
$libDir/cmake/rz_*/rz_*Config.cmake
Work environment
rizin -v
full output, not truncated (mandatory)commit: 8c3dc83f8db0a6392496fc5cef8188df1dd09b25
Expected behavior
Cutter finds and uses rizin libraries/headers
Actual behavior
Cutter fails to find the rizin installation when running cmake
CMakeOutput.log.txt
Steps to reproduce the behavior
Download cutter source archive Run cmake in Terminal:
I've got a "fix" by re-importing the previous method to find rizin, but it's not a good one (although Cutter builds and runs fine on Haiku).