When we try build Rizin with Muon + TinyCC it can't find the necessary library, while Meson can:
/home/runner/work/rizin/rizin/meson.build:354:33: error library not found
354 | it_lrt = it_cc.find_library('rt', required: true, static: is_static_build)
^
/home/runner/work/rizin/rizin/meson.build:354:20: error in method compiler.find_library()
354 | it_lrt = it_cc.find_library('rt', required: true, static: is_static_build)
^
Error: Process completed with exit code 1.
When you say meson can, what to you mean? I thought meson didn't support tinycc.
Right now muon gets the list of dirs to search through via
cc --print-search-dirs
, which isn't posix. There should maybe be a fallback likeget_option('prefix') / get_option('libdir')
?
Ah, we use our patched fork for that: https://github.com/ret2libc/meson.git There was a PR (https://github.com/mesonbuild/meson/pull/8248) to meson but it was never accepted, so we decided it will be easier to just completely move to Muon for this configuration.
@lattis according to https://bellard.org/tcc/tcc-doc.html#Option-summary there is
-print-search-dirs
(note the single-
)
@~xvilka look at line 316 in compiler.c:
https://git.sr.ht/~lattis/muon/tree/master/item/src/compilers.c#L313
you can try to fix tinycc here with the correct option to pass to tinycc.
There are 2 ways to fix this, both are valid
- patch tcc to accept
-print-search-dirs
&--print-search-dirs
(recommended)- patch muon to append
-print-search-dirs
All GCC versions accept both
-print-search-dirs
&--print-search-dirs
(tested gcc4.7, gcc5 & gcc11), but only-print-search-dirs
is canonical according to the help msggcc 4.7
# i486-slackware-linux-gcc --help | grep print -print-search-dirs Display the directories in the compiler's search path -print-libgcc-file-name Display the name of the compiler's companion library -print-file-name=<lib> Display the full path to library <lib> -print-prog-name=<prog> Display the full path to compiler component <prog> -print-multi-directory Display the root directory for versions of libgcc -print-multi-lib Display the mapping between command line options and -print-multi-os-directory Display the relative path to OS libraries -print-sysroot Display the target libraries directory -print-sysroot-headers-suffix Display the sysroot suffix used to find headers
gcc 11.2
# ./i686-linux-musl-gcc --help | grep print -print-search-dirs Display the directories in the compiler's search path. -print-libgcc-file-name Display the name of the compiler's companion library. -print-file-name=<lib> Display the full path to library <lib>. -print-prog-name=<prog> Display the full path to compiler component <prog>. -print-multiarch Display the target's normalized GNU triplet, used as -print-multi-directory Display the root directory for versions of libgcc. -print-multi-lib Display the mapping between command line options and -print-multi-os-directory Display the relative path to OS libraries. -print-sysroot Display the target libraries directory. -print-sysroot-headers-suffix Display the sysroot suffix used to find headers.
clang also supports
-print-search-dirs
This should be enough to fix this issue, it's the correct GCC parameter, it should work with all compilers that implement some GCC compatibility
diff --git a/src/compilers.c b/src/compilers.c index 4815ab0e..cae3ae91 100644 --- a/src/compilers.c +++ b/src/compilers.c @@ -313,7 +313,7 @@ static bool compiler_get_libdirs(struct workspace *wk, struct obj_compiler *comp) { struct run_cmd_ctx cmd_ctx = { 0 }; - if (!run_cmd_arr(wk, &cmd_ctx, comp->cmd_arr, "--print-search-dirs") + if (!run_cmd_arr(wk, &cmd_ctx, comp->cmd_arr, "-print-search-dirs") || cmd_ctx.status) { goto done; }
But that's only one issue, I found that muon apparently doesn't check compiler options and just adds stuff that breaks older GCC compilers, and other compilers
cc: error: unrecognized command line option ‘-fdiagnostics-color=always’ samu: subcommand failed
I also found compilation issues with older libarchive versions. The minimum supported version is probably 3.2, but I can confirm that 3.3 works ok
Changed to pass
-print-search-dirs
. ~xvilka, can you confirm this fixes the tcc issue?
~lattis, sorry, still didn't help: https://github.com/rizinorg/rizin/actions/runs/7076647158/job/19260119164?pr=3345#step:9:73