Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson: do not use add_global_arguments() #3706

Closed
wants to merge 2 commits into from

Conversation

XVilka
Copy link
Member

@XVilka XVilka commented Aug 1, 2023

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

add_global_arguments() prevents using Rizin as a subproject for Meson WrapDB: #3454

wrapdb on  rizin                                                                                                                                                                                           13:49:03
ℤ meson setup builddir -Dwraps=rizin
The Meson build system
Version: 1.2.0
Source dir: /Users/user/Rizin/wrapdb
Build dir: /Users/user/Rizin/wrapdb/builddir
Build type: native build
Project name: wrapdb
Project version: undefined
Host machine cpu family: aarch64
Host machine cpu: aarch64

Executing subproject rizin

rizin| Project name: rizin
rizin| Project version: v0.6.0
rizin| C compiler for the host machine: cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
rizin| C linker for the host machine: cc ld64 820.1
rizin| Program python3 found: YES (/opt/homebrew/opt/[email protected]/bin/python3.11)
rizin| Program git found: YES (/usr/bin/git)
rizin| Message: rizin lib version: 0.6
rizin| Compiler for C supports arguments --std=gnu99: YES

subprojects/rizin/meson.build:83:2: ERROR: Function 'add_global_arguments' cannot be used in subprojects because there is no way to make that reliable.
Please only call this if is_subproject() returns false. Alternatively, define a variable that
contains your language-specific arguments and add it to the appropriate *_args kwarg in each target.

Switch to use add_project_arguments() instead:

https://mesonbuild.com/Reference-manual_functions.html#add_project_arguments

Necessary for #3454

Test plan

CI is green

@XVilka XVilka added this to the 0.6.0 milestone Aug 1, 2023
Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember this was done to transmit args to rizin subprojects as well. Please check rizin builds well everywhere

@XVilka
Copy link
Member Author

XVilka commented Aug 1, 2023

Sigh, looks like Meson isn't advanced enough to fallback from gnu99 to c99. It's such an obvious thing to do: mesonbuild/meson#10332

@XVilka XVilka marked this pull request as draft August 1, 2023 06:42
@XVilka XVilka force-pushed the dist-meson-subproject-fixes branch from b95d467 to 645d0e2 Compare August 1, 2023 06:59
@XVilka
Copy link
Member Author

XVilka commented Aug 1, 2023

Curiously, Meson uses SPDX in license: field but it never checked if the identifier is even valid: fsfe/reuse-tool#816

@XVilka XVilka force-pushed the dist-meson-subproject-fixes branch from 645d0e2 to 99671e9 Compare August 1, 2023 07:13
@github-actions github-actions bot added the WinDbg label Aug 1, 2023
@XVilka XVilka modified the milestones: 0.6.0, 0.7.0 Aug 1, 2023
@XVilka
Copy link
Member Author

XVilka commented Aug 1, 2023

No easy solution, moving to the next release

@amibranch
Copy link
Contributor

amibranch commented Oct 18, 2024

I'm currently looking to add rizin as a meson-subproject to projects and came across the same problems. What's the state? I don't see any blocker in the license problem, to replace add_global_arguments with add_project_arguments?
I wasn't able to compile (a rebased) state of this change, as rzrar and rzwinkd seem to require -D*:c_std=gnu99 (instead of c99).
Also note that using rizin in a subproject correctly, requires some more fixes. I've created a dedicated branch, containing two additional commits (and rebased on dev):
dev...amibranch:rizin:rizin_as_subproject

  • A first commit including all necessary changes I found so far, in order to add rizin as subproject to other projects
  • A second commit, containing changes to the default c_std-option and a small change, necessary for muon

However, I couldn't yet test the CI on my branch and the results from the PR are expired

@XVilka
Copy link
Member Author

XVilka commented Oct 18, 2024

@amibranch could you please send a PR with your changes?

This was referenced Oct 19, 2024
@XVilka XVilka force-pushed the dist-meson-subproject-fixes branch from 99671e9 to 8ada452 Compare October 21, 2024 10:36
@XVilka
Copy link
Member Author

XVilka commented Oct 21, 2024

Sigh:

 FAILED: subprojects/libzip-1.9.2/liblibzip.a.p/lib/zip_name_locate.c.o 
cc -std=c99 -g -Og -Wall -fdiagnostics-color=always -I subprojects/libzip-1.9.2 -I ../subprojects/libzip-1.9.2 -I ../subprojects/libzip-1.9.2/lib -fPIC -MD -MQ subprojects/libzip-1.9.2/liblibzip.a.p/lib/zip_name_locate.c.o -MF subprojects/libzip-1.9.2/liblibzip.a.p/lib/zip_name_locate.c.o.d -o subprojects/libzip-1.9.2/liblibzip.a.p/lib/zip_name_locate.c.o -c ../subprojects/libzip-1.9.2/lib/zip_name_locate.c
../subprojects/libzip-1.9.2/lib/zip_name_locate.c: In function ‘_zip_name_locate’:
../subprojects/libzip-1.9.2/lib/zip_name_locate.c:76:41: error: ‘strcasecmp’ undeclared (first use in this function); did you mean ‘strncmp’?
   76 |         cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
      |                                         ^~~~~~~~~~
      |                                         strncmp
../subprojects/libzip-1.9.2/lib/zip_name_locate.c:76:41: note: each undeclared identifier is reported only once for each function it appears in
FAILED: subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_dirent.c.o 
cc -Isubprojects/libzip-1.9.2/liblibzip.a.p -Isubprojects/libzip-1.9.2 -I../subprojects/libzip-1.9.2 -I../subprojects/libzip-1.9.2/lib -Isubprojects/zlib-1.3.1 -I../subprojects/zlib-1.3.1 -I../subprojects/xz-5.2.9/src/liblzma/api -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=c99 -O3 -Wno-cpp -fPIC -DLZMA_API_STATIC -MD -MQ subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_dirent.c.o -MF subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_dirent.c.o.d -o subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_dirent.c.o -c ../subprojects/libzip-1.9.2/lib/zip_dirent.c
../subprojects/libzip-1.9.2/lib/zip_dirent.c: In function ‘_zip_u2d_time’:
../subprojects/libzip-1.9.2/lib/zip_dirent.c:1095:11: error: implicit declaration of function ‘localtime_r’; did you mean ‘localtime’? [-Werror=implicit-function-declaration]
 1095 |     tpm = localtime_r(&intime, &tm);
      |           ^~~~~~~~~~~
      |           localtime
../subprojects/libzip-1.9.2/lib/zip_dirent.c:1095:9: error: assignment to ‘struct tm *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 1095 |     tpm = localtime_r(&intime, &tm);
      |         ^
gcc -Isubprojects/libzip-1.9.2/liblibzip.a.p -Isubprojects/libzip-1.9.2 -I../subprojects/libzip-1.9.2 -I../subprojects/libzip-1.9.2/lib -Isubprojects/zlib-1.3.1 -I../subprojects/zlib-1.3.1 -I../subprojects/xz-5.2.9/src/liblzma/api -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=c99 -O3 -DRZ_ASSERT_STDOUT=1 -Wno-cpp -fPIC -DLZMA_API_STATIC -MD -MQ subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_fdopen.c.o -MF subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_fdopen.c.o.d -o subprojects/libzip-1.9.2/liblibzip.a.p/lib_zip_fdopen.c.o -c ../subprojects/libzip-1.9.2/lib/zip_fdopen.c
../subprojects/libzip-1.9.2/lib/zip_fdopen.c: In function ‘zip_fdopen’:
../subprojects/libzip-1.9.2/lib/zip_fdopen.c:62:15: error: implicit declaration of function ‘fdopen’; did you mean ‘fopen’? [-Werror=implicit-function-declaration]
   62 |     if ((fp = fdopen(fd, "rb")) == NULL) {
      |               ^~~~~~
      |               fopen
../subprojects/libzip-1.9.2/lib/zip_fdopen.c:62:13: error: assignment to ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
   62 |     if ((fp = fdopen(fd, "rb")) == NULL) {
      |             ^
cc1: all warnings being treated as errors

@amibranch amibranch mentioned this pull request Oct 22, 2024
5 tasks
@amibranch
Copy link
Contributor

@XVilka , I could base #4684 on this PR (and set the destination branch) - or we close this PR and #4684 will take over and be merged in dev (which means one round of reviews and CI). Your preference?

@XVilka XVilka closed this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants