[PATCH] Add more checks for headers and libraries in the meson build
Nick Clifton
nickc@redhat.com
Mon Jun 23 13:41:27 GMT 2025
Hi Tulio,
> annocheck depends on libiberty.h.
Actually this is a mistake in the annocheck sources. They should not
be including libiberty.h from the system's include directory, but
instead they should be using a local copy of libiberty.h.
The reason is that annocheck includes its own copies of the libiberty
sources. This allowed me to a) add my own fixes to the libiberty sources
which were not being done upstream. (Mainly for resource leaks). And
b) remove a dependency upon libiberty and hence the binutils-devel
package.
So please could fix this by copying the current version of libiberty.h
to annocheck/libiberty and then changing the include from:
#include <libiberty.h>
to:
#include "libiberty/libiberty.h"
Thanks.
> diff --git a/clang-plugin/meson.build b/clang-plugin/meson.build
> index 0c415db..5240a76 100644
> --- a/clang-plugin/meson.build
> +++ b/clang-plugin/meson.build
> @@ -6,6 +6,11 @@ clang = find_program('clang++')
> search_dirs = run_command(clang , '--print-search-dirs', check: true).stdout().strip()
> install_dir = search_dirs.split('\n')[1].split(':')[1].replace('=', '').strip()
>
> +# Use the default c++ compiler just to find if the needed libraries are
> +# installed.
> +cxx.find_library('LLVM')
> +cxx.find_library('clang-cpp')
> +
> clang_plugin = custom_target(
> 'annobin-for-clang.so',
> input: 'annobin.cpp',
> diff --git a/gcc-plugin/meson.build b/gcc-plugin/meson.build
> index e0ee998..b234369 100644
> --- a/gcc-plugin/meson.build
> +++ b/gcc-plugin/meson.build
> @@ -55,6 +55,23 @@ endif
> # using GCC, even if the environment wants another compiler.
> gxx = find_program('g++')
> plugin_dev_path = run_command(gxx, '-print-file-name=plugin', check: true).stdout().strip()
> +
> +# Use the default c++ compiler just to find if the needed dependencies are
> +# installed.
> +plugin_inc_path = join_paths(plugin_dev_path, 'include')
> +fs = import('fs')
> +if not fs.is_dir(plugin_inc_path)
> + error(
> + 'Could not find ',
> + plugin_inc_path,
> + '\nAre the development files for GCC plugins installed?',
> + )
> +endif
> +inc = include_directories(plugin_inc_path)
> +if not cxx.has_header('plugin.h', include_directories: inc)
> + error('Could not find GCC\'s plugin.h')
> +endif
> +
> gcc_plugin = custom_target(
> 'annobin.so',
> input: ['annobin.cc', target_plugin],
> @@ -68,7 +85,7 @@ gcc_plugin = custom_target(
> '-DHAVE_CONFIG_H',
> '-I' + join_paths(meson.current_source_dir(), '..'),
> '-I' + join_paths(meson.current_build_dir(), '..'),
> - '-I' + join_paths(plugin_dev_path, 'include'),
> + '-I' + join_paths(plugin_inc_path),
> '-o', '@OUTPUT@',
> ]
> )
> diff --git a/llvm-plugin/meson.build b/llvm-plugin/meson.build
> index 17930b3..317f046 100644
> --- a/llvm-plugin/meson.build
> +++ b/llvm-plugin/meson.build
> @@ -6,6 +6,10 @@ clang = find_program('clang++')
> search_dirs = run_command(clang , '--print-search-dirs', check: true).stdout().strip()
> install_dir = search_dirs.split('\n')[1].split(':')[1].replace('=', '').strip()
>
> +# Use the default c++ compiler just to find if the needed libraries are
> +# installed.
> +cxx.find_library('LLVM')
> +
> llvm_plugin = custom_target(
> 'annobin-for-llvm.so',
> input: 'annobin.cpp',
This change is OK.
Cheers
Nick
More information about the Annobin
mailing list