11.3.1-4.3

Compile the cross binaries as PIE/-z now

Resolves: #2155452
This commit is contained in:
Marek Polacek 2022-12-21 14:51:59 -05:00
parent c8c6d760a7
commit 9e2005ad2a

View File

@ -128,7 +128,7 @@
Summary: Various compilers (C, C++, Objective-C, ...)
Name: gcc
Version: %{gcc_version}
Release: %{gcc_release}.2%{?dist}
Release: %{gcc_release}.3%{?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
@ -1206,6 +1206,7 @@ CONFIGURE_OPTS_CROSS="\
--enable-languages=c,c++ --disable-bootstrap --disable-libsanitizer \
--host=%{gcc_target_platform} --build=%{gcc_target_platform} \
--disable-multilib --disable-libstdcxx-pch --disable-libcc1 \
--enable-host-pie --enable-host-bind-now \
"
CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
@ -1250,6 +1251,8 @@ cd ..
# Build cross compilers here.
%if %{build_cross}
echo ==================== BUILD CROSS =========================
# Get out of obj-%{gcc_target_platform}.
pushd ..
for crossarch in %{cross_targets}; do
mkdir obj-$crossarch
cd obj-$crossarch
@ -1271,23 +1274,26 @@ for crossarch in %{cross_targets}; do
esac
# Temporarily replace DEV-PHASE.
cp -p ../../gcc/DEV-PHASE{.cross,}
cp -p ../gcc/DEV-PHASE{.cross,}
CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
CXXFLAGS="`echo " $OPT_FLAGS " | sed 's/ -Wall / /g;s/ -fexceptions / /g' \
| sed 's/ -Wformat-security / -Wformat -Wformat-security /'`" \
XCFLAGS="$OPT_FLAGS" TCFLAGS="$OPT_FLAGS" \
../../configure $CONFIGURE_OPTS_BASE $CONFIGURE_OPTS_CROSS \
../configure $CONFIGURE_OPTS_BASE $CONFIGURE_OPTS_CROSS \
--with-sysroot=/usr/$crossarch/sys-root/el9/ \
--with-gxx-include-dir="/usr/$crossarch/sys-root/el9/%{_prefix}/include/c++/%{gcc_major}" \
--target=$crossarch \
$CONFIGURE_OPTS_FOR_ARCH
make %{?_smp_mflags}
make %{?_smp_mflags} LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
# Restore DEV-PHASE.
cp -p ../../gcc/DEV-PHASE{.native,}
cp -p ../gcc/DEV-PHASE{.native,}
# Out of obj-$crossarch.
cd ..
done
# Go back to obj-%{gcc_target_platform}.
popd
echo ==================== BUILD CROSS END =========================
%endif
@ -1493,25 +1499,27 @@ chmod 644 %{buildroot}%{_infodir}/gnat*
%if %{build_cross}
echo ==================== INSTALL CROSS =========================
# Our of obj-%{gcc_target_platform}.
pushd ..
for crossarch in %{cross_targets}; do
cd obj-$crossarch
CROSS_LIBPATH=%{buildroot}%{_prefix}/lib/gcc/$crossarch/%{gcc_major}/
# Temporarily replace DEV-PHASE.
cp -p ../../gcc/DEV-PHASE{.cross,}
cp -p ../gcc/DEV-PHASE{.cross,}
# --with-gxx-include-dir= doesn't prefix its argument with $(DESTDIR)
# and you can't install things into /usr unless you're root.
mkdir scratch
scratchdir=`pwd`/scratch
cd $crossarch/libstdc++-v3
pushd $crossarch/libstdc++-v3
for i in `find . -name Makefile`; do
cp -a $i $i.save
sed -i -e 's?^gxx_include_dir = .*$?gxx_include_dir = '$scratchdir'?' $i
touch -r $i.save $i
done
cd ../..
popd
# Use -j1, because build-many-glibcs says:
# Parallel "make install" for GCC has race conditions that can
@ -1528,14 +1536,14 @@ for crossarch in %{cross_targets}; do
infodir=%{buildroot}%{_infodir} install
# Restore DEV-PHASE.
cp -p ../../gcc/DEV-PHASE{.native,}
cp -p ../gcc/DEV-PHASE{.native,}
# Restore Makefiles with the old gxx_include_dir.
cd $crossarch/libstdc++-v3
pushd $crossarch/libstdc++-v3
for i in `find . -name Makefile`; do
mv -f $i.save $i
done
cd ../..
popd
# We're not shipping C++ headers; nuke 'em.
rm -rf $scratchdir
@ -1604,6 +1612,8 @@ INPUT( =%{_prefix}/lib/gcc/$crossarch/%{gcc_major}/libitm.a )" > $CROSS_LIBPATH/
#ln -s ../../libexec/gcc/$crossarch/%{gcc_major}/liblto_plugin.so \
# %{buildroot}%{_libdir}/$crossarch/bfd-plugins/
done
# Back to obj-%{gcc_target_platform}.
popd
echo ==================== INSTALL CROSS END =========================
%endif
@ -3562,6 +3572,9 @@ end
%endif
%changelog
* Wed Dec 21 2022 Marek Polacek <polacek@redhat.com> 11.3.1-4.3
- compile the cross binaries as PIE/-z now (#2155452)
* Mon Dec 19 2022 Marek Polacek <polacek@redhat.com> 11.3.1-4.2
- ship libitm.spec in cross-gcc (#2154462)