Add (optional) llvm plugin.

This commit is contained in:
Nick Clifton 2020-06-15 17:33:58 +01:00
parent c4f24c4ee5
commit 9f46ccb4ce
3 changed files with 43 additions and 21 deletions

1
.gitignore vendored
View File

@ -136,3 +136,4 @@
/annobin-9.19.tar.xz /annobin-9.19.tar.xz
/annobin-9.20.tar.xz /annobin-9.20.tar.xz
/annobin-9.21.tar.xz /annobin-9.21.tar.xz
/annobin-9.22.tar.xz

View File

@ -1,7 +1,7 @@
Name: annobin Name: annobin
Summary: Annotate and examine compiled binary files Summary: Annotate and examine compiled binary files
Version: 9.21 Version: 9.22
Release: 1%{?dist} Release: 1%{?dist}
License: GPLv3+ License: GPLv3+
# ProtocolURL: https://fedoraproject.org/wiki/Toolchain/Watermark # ProtocolURL: https://fedoraproject.org/wiki/Toolchain/Watermark
@ -22,9 +22,12 @@ License: GPLv3+
# time check for debuginfod support. # time check for debuginfod support.
%bcond_with debuginfod %bcond_with debuginfod
# Use "--with clangplugin" to build the annobin plugin for clang. # Use "--with clangplugin" to build the annobin plugin for Clang.
%bcond_with clangplugin %bcond_with clangplugin
# Use "--with llvmplugin" to build the annobin plugin for LLVM.
%bcond_with llvmplugin
# Set this to zero to disable the requirement for a specific version of gcc. # Set this to zero to disable the requirement for a specific version of gcc.
# This should only be needed if there is some kind of problem with the version # This should only be needed if there is some kind of problem with the version
# checking logic or when building on RHEL-7 or earlier. # checking logic or when building on RHEL-7 or earlier.
@ -109,7 +112,10 @@ Requires: gcc
BuildRequires: gcc gcc-plugin-devel gcc-c++ BuildRequires: gcc gcc-plugin-devel gcc-c++
%if %{with clangplugin} %if %{with clangplugin}
BuildRequires: clang clang-devel llvm llvm-devel BuildRequires: clang clang-devel llvm llvm-devel compiler-rt
%endif
%if %{with llvmplugin}
BuildRequires: clang clang-devel llvm llvm-devel compiler-rt
%endif %endif
%description %description
@ -120,7 +126,11 @@ Note - the plugin is automatically enabled in gcc builds via flags
provided by the redhat-rpm-macros package. provided by the redhat-rpm-macros package.
%if %{with clangplugin} %if %{with clangplugin}
Also provides a plugin for clang which performs a similar function. Also provides a plugin for Clang which performs a similar function.
%endif
%if %{with llvmplugin}
Also provides a plugin for LLVM which performs a similar function.
%endif %endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -162,6 +172,8 @@ hardening options.
# Instead it just uses dlopen() with no pathname prefix. So we # Instead it just uses dlopen() with no pathname prefix. So we
# construct a (hopefully good) path and rely upon users of annobin # construct a (hopefully good) path and rely upon users of annobin
# knowing about this location. # knowing about this location.
# FIXME2: Currently this same path is hardcoded into the Makefile.in
# files in the clang-plugin and llvm-plugin source directories...
%global ANNOBIN_CLANG_PLUGIN_DIR /usr/lib64/clang/%(clang -dumpversion)/lib %global ANNOBIN_CLANG_PLUGIN_DIR /usr/lib64/clang/%(clang -dumpversion)/lib
%endif %endif
@ -189,13 +201,30 @@ touch doc/annobin.info
%build %build
CONFIG_ARGS=
%if %{with debuginfod} %if %{with debuginfod}
%configure --quiet --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR} --with-debuginfod || cat config.log CONFIG_ARGS="$CONFIG_ARGS --with-debuginfod"
%else %else
%configure --quiet --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR} || cat config.log CONFIG_ARGS="$CONFIG_ARGS --without-debuginfod"
%endif %endif
%if %{with clangplugin}
CONFIG_ARGS="$CONFIG_ARGS --with-clang"
%endif
%if %{with llvmplugin}
CONFIG_ARGS="$CONFIG_ARGS --with-llvm"
%endif
%if %{without tests}
CONFIG_ARGS="$CONFIG_ARGS --without-test"
%endif
%configure --quiet --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR} ${CONFIG_ARGS} || cat config.log
%make_build %make_build
# Rebuild the plugin, this time using the plugin itself! This # Rebuild the plugin, this time using the plugin itself! This
# ensures that the plugin works, and that it contains annotations # ensures that the plugin works, and that it contains annotations
# of its own. This could mean that we end up with a plugin with # of its own. This could mean that we end up with a plugin with
@ -210,22 +239,12 @@ BUILD_FLAGS="-fplugin=%{_tmppath}/tmp_annobin.so -fplugin-arg-tmp_annobin-rename
make -C gcc-plugin CXXFLAGS="%{optflags} $BUILD_FLAGS" make -C gcc-plugin CXXFLAGS="%{optflags} $BUILD_FLAGS"
rm %{_tmppath}/tmp_annobin.so rm %{_tmppath}/tmp_annobin.so
%if %{with clangplugin}
# FIXME: The symbolic link should not be needed.
ln -f -s ../annobin-global.h clang-plugin
make -C clang-plugin annobin.so
%endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
%install %install
%make_install %make_install
rm -f %{buildroot}%{_infodir}/dir rm -f %{buildroot}%{_infodir}/dir
%if %{with clangplugin}
install -Dpm0755 -t %{buildroot}%{ANNOBIN_CLANG_PLUGIN_DIR} clang-plugin/annobin.so
%endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
%if %{with tests} %if %{with tests}
@ -246,10 +265,6 @@ fi
%files %files
%{ANNOBIN_GCC_PLUGIN_DIR} %{ANNOBIN_GCC_PLUGIN_DIR}
%{_bindir}/built-by
%{_bindir}/check-abi
%{_bindir}/hardened
%{_bindir}/run-on-binaries-in
%license COPYING3 LICENSE %license COPYING3 LICENSE
%exclude %{_datadir}/doc/annobin-plugin/COPYING3 %exclude %{_datadir}/doc/annobin-plugin/COPYING3
%exclude %{_datadir}/doc/annobin-plugin/LICENSE %exclude %{_datadir}/doc/annobin-plugin/LICENSE
@ -264,6 +279,9 @@ fi
%if %{with clangplugin} %if %{with clangplugin}
%{ANNOBIN_CLANG_PLUGIN_DIR} %{ANNOBIN_CLANG_PLUGIN_DIR}
%endif %endif
%if %{with llvmplugin}
%{ANNOBIN_CLANG_PLUGIN_DIR}
%endif
%if %{with annocheck} %if %{with annocheck}
%files annocheck %files annocheck
@ -274,6 +292,9 @@ fi
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
%changelog %changelog
* Mon Jun 15 2020 Nick Clifton <nickc@redhat.com> - 9.22-1
- Add (optional) llvm plugin.
* Wed Apr 22 2020 Nick Clifton <nickc@redhat.com> - 9.21-1 * Wed Apr 22 2020 Nick Clifton <nickc@redhat.com> - 9.21-1
- Annobin: Fall back on using the flags if the option cannot be found in cl_options. (#1817659) - Annobin: Fall back on using the flags if the option cannot be found in cl_options. (#1817659)

View File

@ -1 +1 @@
SHA512 (annobin-9.21.tar.xz) = baf1c9f90b6bcfdc5db865a5f897edcac4abe6449cf520cdec856bbca9741a937798196603b486259d0981216b2e8363ee003a9c5d1cfffe5a2a65284ab53e34 SHA512 (annobin-9.22.tar.xz) = c39e6086993acca320db5e02aa72d1bfe4428bec18c98e38fad5d67afe617b7f06c2c5b9c7bad09d0df9d3b2585411e88598c9ab5e4930f5e0c27b36a5c4fc69