[PATCH 1/3] build: validate that system capstone works before using it

Daniel P. Berrangé posted 3 patches 4 years, 7 months ago
[PATCH 1/3] build: validate that system capstone works before using it
Posted by Daniel P. Berrangé 4 years, 7 months ago
Some versions of capstone have shipped a broken pkg-config file which
puts the -I path without the trailing '/capstone' suffix. This breaks
the ability to "#include <capstone.h>". Upstream and most distros have
fixed this, but a few stragglers remain, notably FreeBSD.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 meson.build | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/meson.build b/meson.build
index d8a92666fb..9979ddae71 100644
--- a/meson.build
+++ b/meson.build
@@ -1425,6 +1425,19 @@ if capstone_opt in ['enabled', 'auto', 'system']
                         kwargs: static_kwargs, method: 'pkg-config',
                         required: capstone_opt == 'system' or
                                   capstone_opt == 'enabled' and not have_internal)
+
+  # Some versions of capstone have broken pkg-config file
+  # that reports a wrong -I path, causing the #include to
+  # fail later. If the system has such a broken version
+  # do not use it.
+  if capstone.found() and not cc.compiles('#include <capstone.h>',
+                                          dependencies: [capstone])
+    capstone = not_found
+    if capstone_opt == 'system'
+      error('system capstone requested, it it does not appear to work')
+    endif
+  endif
+
   if capstone.found()
     capstone_opt = 'system'
   elif have_internal
-- 
2.31.1


Re: [PATCH 1/3] build: validate that system capstone works before using it
Posted by Thomas Huth 4 years, 7 months ago
On 25/06/2021 19.22, Daniel P. Berrangé wrote:
> Some versions of capstone have shipped a broken pkg-config file which
> puts the -I path without the trailing '/capstone' suffix. This breaks
> the ability to "#include <capstone.h>". Upstream and most distros have
> fixed this, but a few stragglers remain, notably FreeBSD.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   meson.build | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index d8a92666fb..9979ddae71 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1425,6 +1425,19 @@ if capstone_opt in ['enabled', 'auto', 'system']
>                           kwargs: static_kwargs, method: 'pkg-config',
>                           required: capstone_opt == 'system' or
>                                     capstone_opt == 'enabled' and not have_internal)
> +
> +  # Some versions of capstone have broken pkg-config file
> +  # that reports a wrong -I path, causing the #include to
> +  # fail later. If the system has such a broken version
> +  # do not use it.
> +  if capstone.found() and not cc.compiles('#include <capstone.h>',
> +                                          dependencies: [capstone])
> +    capstone = not_found
> +    if capstone_opt == 'system'
> +      error('system capstone requested, it it does not appear to work')
> +    endif
> +  endif

Reviewed-by: Thomas Huth <thuth@redhat.com>


Re: [PATCH 1/3] build: validate that system capstone works before using it
Posted by Alex Bennée 4 years, 7 months ago
Daniel P. Berrangé <berrange@redhat.com> writes:

> Some versions of capstone have shipped a broken pkg-config file which
> puts the -I path without the trailing '/capstone' suffix. This breaks
> the ability to "#include <capstone.h>". Upstream and most distros have
> fixed this, but a few stragglers remain, notably FreeBSD.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée

Re: [PATCH 1/3] build: validate that system capstone works before using it
Posted by Willian Rampazzo 4 years, 7 months ago
On Fri, Jun 25, 2021 at 2:22 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> Some versions of capstone have shipped a broken pkg-config file which
> puts the -I path without the trailing '/capstone' suffix. This breaks
> the ability to "#include <capstone.h>". Upstream and most distros have
> fixed this, but a few stragglers remain, notably FreeBSD.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  meson.build | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>

Reviewed-by: Willian Rampazzo <willianr@redhat.com>