Update annobin plugin patch

Resolves: #2030667
This commit is contained in:
Marek Polacek 2022-01-13 15:21:04 -05:00
parent 15ef8b4add
commit df40126a22

179
gcc.spec
View File

@ -115,29 +115,19 @@
%ifarch x86_64
%global multilib_32_arch i686
%endif
# Use "--without annobin-plugin" to disable the building of the annobin plugin for GCC.
%bcond_without annobin_plugin
# Use "--without tests" to disable the testsuite.
# Not technically needed for building the annobin plugin, but this has been added
# because not running the testsuites makes building the gcc rpms a *lot* faster.
%bcond_without tests
# The next line has been stolen from redhat-rpm-config.spec.
# We install the version info into a file in this directory, rather than
# gcc's plugin directory, because there is no reliable way for redhat-rpm-config
# to determine the name of gcc's plugin directory.
# FIXME: We need a way to cope if more than one version of gcc is installed.
%global rrcdir /usr/lib/rpm/redhat
# A file that records information about the built gcc-annobin plugin.
%global gver %{rrcdir}/gcc-annobin-plugin-version-info
Summary: Various compilers (C, C++, Objective-C, ...)
Name: gcc
Version: %{gcc_version}
Release: %{gcc_release}.4%{?dist}
Release: %{gcc_release}.5%{?dist}
# libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
# GCC Runtime Exception.
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
@ -225,13 +215,6 @@ BuildRequires: doxygen >= 1.7.1
BuildRequires: graphviz, dblatex, texlive-collection-latex, docbook5-style-xsl
%endif
%if %{with annobin_plugin}
# Starting with release 10.01 annobin fixed a bug in its configure scripts which prevented them from working with a built but not installed compiler
BuildRequires: annobin >= 10.01
# See The %%install phase for why we need xz.
BuildRequires: xz
%endif
Requires: cpp = %{version}-%{release}
# Need .eh_frame ld optimizations
# Need proper visibility support
@ -800,6 +783,25 @@ NVidia PTX. OpenMP and OpenACC programs linked with -fopenmp will
by default add PTX code into the binaries, which can be offloaded
to NVidia PTX capable devices if available.
%package plugin-annobin
Summary: The annobin plugin for gcc, built by the installed version of gcc
Requires: gcc = %{version}-%{release}
# Starting with release 10.01 annobin fixed a bug in its configure scripts
# which prevented them from working with a built but not installed compiler
BuildRequires: annobin >= 10.01
# Starting with release 9.93 annobin-plugin-gcc puts a copy of the sources
# in /usr/src/annobin
# FIXME: Currently the annobin-plugin-gcc subpackage only exists in Fedora.
# For RHEL-9 the annobin package does everything.
# BuildRequires: annobin-plugin-gcc
# Needed in order to be able to decompress the annobin source tarball.
BuildRequires: xz
%description plugin-annobin
This package adds a version of the annobin plugin for gcc. This version
of the plugin is explicitly built by the same version of gcc that is installed
so that there cannot be any synchronization problems.
%prep
%setup -q -n gcc-%{version}-%{DATE} -a 1 -a 2 -a 3
%patch0 -p0 -b .hack~
@ -1234,7 +1236,6 @@ done)
rm -f rpm.doc/changelogs/gcc/ChangeLog.[1-9]
find rpm.doc -name \*ChangeLog\* | xargs bzip2 -9
%if %{with annobin_plugin}
# Get the annobin sources. Note these are not added to the rpm as SOURCE4
# because if they were the build phase would try to include them as part of
# gcc itself, and this causes problems. Instead we locate the sources in
@ -1250,65 +1251,64 @@ then
echo "Unpacking annobin sources"
rm -fr annobin-*
tar xvf %{annobin_source_dir}/latest-annobin.tar.xz
else
echo "Unable to locate annobin sources (expected to find: %{annobin_source_dir}/latest-annobin.tar.xz)"
echo "These should be provided by installing the annobin-plugin-gcc package"
exit 1
fi
# Setting this as a local symbol because using %%global does not appear to work.
annobin_dir=$(find . -maxdepth 1 -type d -name "annobin*")
# Setting this as a local symbol because using %%global does not appear to work.
annobin_dir=$(find . -maxdepth 1 -type d -name "annobin*")
# Now build the annobin plugin using the just built compiler.
echo "annobin directory = ${annobin_dir}"
cd ${annobin_dir}
# Now build the annobin plugin using the just built compiler.
echo "annobin directory = ${annobin_dir}"
cd ${annobin_dir}
# Work out where this version of gcc stores its plugins.
# Work out where this version of gcc stores its plugins.
%global ANNOBIN_GCC_PLUGIN_DIR %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/plugin
CONFIG_ARGS="--quiet"
CONFIG_ARGS="$CONFIG_ARGS --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR}"
CONFIG_ARGS="$CONFIG_ARGS --without-annocheck"
CONFIG_ARGS="$CONFIG_ARGS --without-tests"
CONFIG_ARGS="--quiet"
CONFIG_ARGS="$CONFIG_ARGS --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR}"
CONFIG_ARGS="$CONFIG_ARGS --without-annocheck"
CONFIG_ARGS="$CONFIG_ARGS --without-tests"
CONFIG_ARGS="$CONFIG_ARGS --disable-rpath"
comp_dir="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/"
ccompiler="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/xgcc -B $comp_dir"
cxxcompiler="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/xg++ -B $comp_dir"
comp_dir="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/"
ccompiler="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/xgcc -B $comp_dir"
cxxcompiler="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/xg++ -B $comp_dir"
comp_flags="%build_cflags"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/gcc"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/include"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/include/%{gcc_target_platform}"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/libstdc++-v3/libsupc++"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/include"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/libcpp/include"
comp_flags="%build_cflags"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/gcc"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/include"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/include/%{gcc_target_platform}"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/libstdc++-v3/libsupc++"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/include"
comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/libcpp/include"
ld_flags="%build_ldflags"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/libstdc++-v3/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/src/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/libstdc++-v3/libsupc++/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/libsupc++/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libgcc/.libs"
ld_flags="$ld_flags -Wl,-rpath,/usr/%{_lib}"
ld_flags="%build_ldflags"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/libstdc++-v3/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/src/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/libstdc++-v3/libsupc++/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/libsupc++/.libs"
ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libgcc/.libs"
ld_flags="$ld_flags -Wl,-rpath,/usr/%{_lib}"
# libtool works with CFLAGS but ignores LDFLAGS, so we have to combine them.
comp_flags="$comp_flags $ld_flags"
# libtool works with CFLAGS but ignores LDFLAGS, so we have to combine them.
comp_flags="$comp_flags $ld_flags"
echo "Configuring the annobin plugin"
CC="${ccompiler}" CFLAGS="${comp_flags}" \
CXX="${cxxcompiler}" CXXFLAGS="${comp_flags}" \
LDFLAGS="${ld_flags}" \
./configure ${CONFIG_ARGS} || cat config.log
echo "Configuring the annobin plugin"
CC="${ccompiler}" CFLAGS="${comp_flags}" \
CXX="${cxxcompiler}" CXXFLAGS="${comp_flags}" \
LDFLAGS="${ld_flags}" \
./configure ${CONFIG_ARGS} || cat config.log
echo "Building the annobin plugin"
make
echo "Building the annobin plugin"
make
echo "Annobin plugin build complete"
echo "Annobin plugin build complete"
else
echo "Unable to locate annobin sources (expected to find: %{annobin_source_dir}/latest-annobin.tar.xz)"
echo "These should be provided by installing the annobin package"
exit 1
fi
popd
# endif for %{with annobin_plugin}
%endif
%install
rm -rf %{buildroot}
@ -2106,9 +2106,7 @@ echo gcc-%{version}-%{release}.%{_arch} > $FULLPATH/rpmver
ln -s ../../libexec/gcc/%{gcc_target_platform}/%{gcc_major}/liblto_plugin.so \
%{buildroot}%{_libdir}/bfd-plugins/
%if %{with annobin_plugin}
# Rename the plugin to gcc-annobin.
# Rename the annobin plugin to gcc-annobin.
mkdir -p %{buildroot}%{ANNOBIN_GCC_PLUGIN_DIR}
pushd %{buildroot}%{ANNOBIN_GCC_PLUGIN_DIR}
@ -2116,12 +2114,6 @@ annobin_dir=$(find %{_builddir} -maxdepth 1 -type d -name "annobin*")
echo "annobin directory = ${annobin_dir}"
cp ${annobin_dir}/gcc-plugin/.libs/annobin.so.0.0.0 gcc-annobin.so.0.0.0
# Compress the plugin so that it cannot be stripped or examined by check-rpath.
# The problem with check-rpath is that the plugin contains a path to the built
# but not installed version of the libstdc++ library, and this is insecure.
# In practice this is not a problem as the plugin does not load the library, but
# there is no way to tell check-rpath this fact.
xz -9 gcc-annobin.so.0.0.0
rm -f gcc-annobin.so.0 gcc-annobin.so
ln -s gcc-annobin.so.0.0.0 gcc-annobin.so.0
@ -2150,30 +2142,7 @@ echo "%{version}-%{release}" > %{buildroot}%{gver}
# script, but it does make the file more useful to humans.
echo "%{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so.0.0.0 was built by gcc version %{gcc_version}-%{gcc_release} from the ${annobin_dir} sources" >> %{buildroot}%{gver}
popd
# endif for %{with annobin_plugin}
%endif
%if %{with annobin_plugin}
%post
pushd %{ANNOBIN_GCC_PLUGIN_DIR} > /dev/null
# Uncompress the annobin plugin now that the %%install phase is over.
xz -d gcc-annobin.so.0.0.0.xz
rm -f gcc-annobin.so.0 gcc-annobin.so
ln -s gcc-annobin.so.0.0.0 gcc-annobin.so.0
ln -s gcc-annobin.so.0.0.0 gcc-annobin.so
popd > /dev/null
%endif
%if %{with annobin_plugin}
%preun
pushd %{ANNOBIN_GCC_PLUGIN_DIR} > /dev/null
# Compress the annobin plugin before it is removed. This avoids a warning from rpm.
rm -f gcc-annobin.so.0 gcc-annobin.so
xz -9 gcc-annobin.so.0.0.0
popd > /dev/null
%endif
%if %{with tests}
%check
cd obj-%{gcc_target_platform}
@ -2226,9 +2195,6 @@ tar cf - testlogs-%{_target_platform}-%{version}-%{release} | xz -9e \
| uuencode testlogs-%{_target_platform}.tar.xz || :
rm -rf testlogs-%{_target_platform}-%{version}-%{release}
# endif for the if {with tests} above.
%endif
%post go
%{_sbindir}/update-alternatives --install \
%{_prefix}/bin/go go %{_prefix}/bin/go.gcc 92 \
@ -2295,10 +2261,6 @@ end
%ldconfig_scriptlets -n libgo
%files -f %{name}.lang
%if %{with annobin_plugin}
%{ANNOBIN_GCC_PLUGIN_DIR}
%{gver}
%endif
%{_prefix}/bin/cc
%{_prefix}/bin/c89
%{_prefix}/bin/c99
@ -3324,7 +3286,16 @@ end
%{_prefix}/%{_lib}/libgomp-plugin-nvptx.so.*
%endif
%files plugin-annobin
%{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so
%{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so.0
%{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so.0.0.0
%{gver}
%changelog
* Thu Jan 13 2022 Marek Polacek <polacek@redhat.com> 11.2.1-7.5
- update annobin plugin patch (#2030667)
* Fri Jan 7 2022 Marek Polacek <polacek@redhat.com> 11.2.1-7.4
- update annobin plugin patch (#2030667)