rizinorg / ideas

Features that would be nice to have but they are not in the roadmap
3 stars 0 forks source link

Support building with Muon buildsystem #18

Closed XVilka closed 2 years ago

XVilka commented 2 years ago

Muon buildsystem is the Meson-compatible implementation in pure C language. It supports the majority of the Meson features.

eli-schwartz commented 2 years ago

The main benefit of py3_exe = import('python').find_installation() will be that it is:

If you just need a program implementation, you can try just using find_program() without the module usage.

eli-schwartz commented 2 years ago

Note that as of today muon added very basic support for the python module find_installation, so if you are just using it as an exe, that will work. But it is still a bit inefficient to go through the module system for this.

XVilka commented 2 years ago

Now it's missing pkgconfig module: https://todo.sr.ht/~lattis/muon/3

XVilka commented 2 years ago
[i] ℤ ~/rizin/muon/build/muon setup build                                                                                                                                                                                         17:16:24 
info detected compiler gcc 11.2.1 (cc)
info configuring 'rizin', version: v0.3.0-git
/home/akochkov/rizin/rizin_copy/meson.build:41:10: error: function is_subproject not found
 41 | if meson.is_subproject()
               ^
XVilka commented 2 years ago

The only remaining problem is:

info [libzip] sizeof off_t: -1
info [libzip] sizeof off_t: 8
info [libzip] sizeof size_t: 8
info [libzip] configuring '/home/xvilka/rizin/rizin_copy/build/subprojects/libzip-1.7.3/config.h
/home/xvilka/rizin/rizin_copy/subprojects/libzip-1.7.3/cmake-config.h.in:49:26: error extraneous characters on #cmakedefine line
 49 | #cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
                               ^
/home/xvilka/rizin/rizin_copy/subprojects/libzip-1.7.3/meson.build:115:12: error in function configure_file()
115 | config_h = configure_file(
                 ^
/home/xvilka/rizin/rizin_copy/meson.build:568:17: error in function subproject()
568 |   libzip_proj = subproject('libzip', default_options: [
                      ^

Caused by this piece of code:

config_h = configure_file(
  input: 'cmake-config.h.in',
  output: 'config.h',
  configuration: conf_data,
  format: 'cmake@',
)

Note, it has nothing to do with the cmake module of Meson, AFAIK.

I am not sure if it's a problem in Muon or something else.

And if I remove these lines compilation fails because of the missing config.h. cc @ret2libc

Reported at https://todo.sr.ht/~lattis/muon/51

XVilka commented 2 years ago

With the following changes latest Muon from git successfully finishes muon setup build:

diff --git a/meson.build b/meson.build
index bd968f79ad..ad35b04a26 100644
--- a/meson.build
+++ b/meson.build
@@ -11,7 +11,7 @@ project('rizin', 'c',
 py3_exe = import('python').find_installation()
 git_exe = find_program('git', required: false)
 pkgconfig_mod = import('pkgconfig')
-cmake_mod = import('cmake')
+cmake_mod = import('cmake', required: false)

 # Python scripts used during the build process
 create_tags_rz_py = files('sys/create_tags_rz.py')
diff --git a/subprojects/libuv.wrap b/subprojects/libuv.wrap
index e290982083..4e4198e528 100644
--- a/subprojects/libuv.wrap
+++ b/subprojects/libuv.wrap
@@ -1,9 +1,8 @@
 [wrap-file]
 directory = libuv-v1.40.0

-source_url = https://raw.githubusercontent.com/rizinorg/fallback-repo/main/libuv-v1.40.0.tar.gz
 source_filename = libuv-v1.40.0.tar.gz
 source_hash = 61a90db95bac00adec1cc5ddc767ebbcaabc70242bd1134a7a6b1fb1d498a194
-source_fallback_url = https://dist.libuv.org/dist/v1.40.0/libuv-v1.40.0.tar.gz
+source_url = https://dist.libuv.org/dist/v1.40.0/libuv-v1.40.0.tar.gz

 patch_directory = libuv-v1.40.0
diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap
index 41923456fe..9284d5bd2c 100644
--- a/subprojects/zlib.wrap
+++ b/subprojects/zlib.wrap
@@ -1,7 +1,6 @@
 [wrap-file]
 directory = zlib-1.2.12
-source_url = https://raw.githubusercontent.com/rizinorg/fallback-repo/main/zlib-1.2.12.tar.gz
 source_filename = zlib-1.2.12.tar.gz
 source_hash = 91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9
 patch_directory = zlib-1.2.12
-source_fallback_url = https://zlib.net/fossils/zlib-1.2.12.tar.gz
+source_url = https://zlib.net/fossils/zlib-1.2.12.tar.gz

However, during the ninja -C build phase there is still error remain:

cc -std=c99 -g -Og -Wpedantic -Wextra -Wall -Werror=sizeof-pointer-memaccess -I subprojects/libzip-1.7.3 -I ../subprojects/libzip-1.7.3 -I ../subprojects/libzip-1.7.3/lib -fpic -MD -MQ subprojects/libzip-1.7.3/liblibzip.a.p/lib/zip_name_locate.c.o -MF subprojects/libzip-1.7.3/liblibzip.a.p/lib/zip_name_locate.c.o.d -o subprojects/libzip-1.7.3/liblibzip.a.p/lib/zip_name_locate.c.o -c ../subprojects/libzip-1.7.3/lib/zip_name_locate.c
../subprojects/libzip-1.7.3/lib/zip_name_locate.c: In function ‘_zip_name_locate’:
../subprojects/libzip-1.7.3/lib/zip_name_locate.c:65:41: error: ‘strcasecmp’ undeclared (first use in this function); did you mean ‘strncmp’?
   65 |         cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
      |                                         ^~~~~~~~~~
      |                                         strncmp
../subprojects/libzip-1.7.3/lib/zip_name_locate.c:65:41: note: each undeclared identifier is reported only once for each function it appears in
[1251/1781] compiling c subprojects/libzip-1.7.3/liblibzip.a.p/lib/zip_memdup.c.o

Full Ninja log here: muon_ninja.zip

cc @wargio @ret2libc @thestr4ng3r

ret2libc commented 2 years ago

@XVilka provide full meson log please. I'm more interested in the meson checks than what ninja executed.

XVilka commented 2 years ago

@ret2libc here you go: muon_setup_build.zip

ret2libc commented 2 years ago

it seems the problem is that strings.h is not included in that file because zipint.h is included only later (and that's where HAVE_STRINGS_H is defined).

ret2libc commented 2 years ago

gonna work on that in the next days. I think the easiest approach is to have a new file in subprojects/packagefiles/libzip/zip_name_locate_patched.c which just does #include "config.h" #include "zip_name_locate.c" and then use zip_name_locate_patched.c in the meson.build file instead of the original file.

XVilka commented 2 years ago

@ret2libc I wonder if this is something we could report mainstream to avoid the need for patching in later releases.

ret2libc commented 2 years ago

Yeah, likely.

ret2libc commented 2 years ago

I think this should work now, except for the

-cmake_mod = import('cmake')
+cmake_mod = import('cmake', required: false)
XVilka commented 2 years ago

@ret2libc latest particular bug was fixed but linking still fails:

ninja: Entering directory `build'
[1/644] linking static subprojects/tree-sitter-0.20.6/libtree_sitter.a
[2/644] linking static subprojects/zlib-1.2.12/libz.a
[3/644] linking static subprojects/lz4-1.9.3/liblz4.a
[4/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/easy_preset.c.o
[5/644] linking subprojects/libuv-v1.40.0/libuv.so
FAILED: subprojects/libuv-v1.40.0/libuv.so 
cc  -o subprojects/libuv-v1.40.0/libuv.so subprojects/libuv-v1.40.0/libuv.so.p/src/fs-poll.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/idna.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/inet.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/random.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/strscpy.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/threadpool.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/timer.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/uv-common.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/uv-data-getter-setters.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/version.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/async.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/core.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/dl.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/fs.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/getaddrinfo.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/getnameinfo.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/loop-watcher.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/loop.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/pipe.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/poll.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/process.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/random-devurandom.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/signal.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/stream.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/tcp.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/thread.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/tty.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/udp.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/linux-core.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/linux-inotify.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/linux-syscalls.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/procfs-exepath.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/pthread-fixes.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/random-getrandom.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/random-sysctl-linux.c.o subprojects/libuv-v1.40.0/libuv.so.p/src/unix/proctitle.c.o -pthread -shared -Wl,-soname,libuv.so -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group /usr/lib64/libm.so /usr/lib64/libdl.a -Wl,--end-group
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/fs-poll.c.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/idna.c.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/inet.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/random.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/threadpool.c.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/timer.c.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/uv-common.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/uv-data-getter-setters.c.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/version.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/async.c.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/core.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/dl.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/fs.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/getaddrinfo.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/getnameinfo.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/loop.c.o: relocation R_X86_64_32 against symbol `uv__work_done' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/pipe.c.o: relocation R_X86_64_32S against symbol `uv__server_io' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/poll.c.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/process.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/random-devurandom.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/signal.c.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/stream.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/tcp.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/thread.c.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/tty.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/udp.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/linux-core.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/linux-inotify.c.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/procfs-exepath.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/random-sysctl-linux.c.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: subprojects/libuv-v1.40.0/libuv.so.p/src/unix/proctitle.c.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
[6/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/filter_common.c.o
[7/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/stream_flags_common.c.o
[8/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/vli_size.c.o
[9/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/hardware_physmem.c.o
[10/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/auto_decoder.c.o
[11/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/easy_decoder_memusage.c.o
[12/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/block_buffer_decoder.c.o
[13/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/block_header_decoder.c.o
[14/644] linking static librz/core/librz_core.a
[15/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/filter_buffer_decoder.c.o
[16/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/index.c.o
[17/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/alone_decoder.c.o
[18/644] compiling c subprojects/xz-5.2.5/src/liblzma/liblzma.a.p/common/block_decoder.c.o
ninja: build stopped: subcommand failed.