Add AS_NEEDED libstdc++.so.6 when only needed through libstdc++_nonshared

Resolves: RHEL-84680
This commit is contained in:
Siddhesh Poyarekar 2025-06-12 14:23:03 -04:00
parent 973853c2ee
commit 513ae75408

View File

@ -1101,20 +1101,6 @@ make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now profiledbootstrap
%endif
echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
%{oformat}
INPUT ( %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/%{_lib}/libstdc++.so.6 -lstdc++_nonshared%{nonsharedver} )' \
> %{gcc_target_platform}/libstdc++-v3/src/.libs/libstdc++_system.so
%if 0
# Relink libcc1 against -lstdc++_nonshared:
sed -i -e '/^postdeps/s/-lstdc++/-lstdc++_system/' libcc1/libtool
rm -f libcc1/libcc1.la
make -C libcc1 libcc1.la
%endif
CC="`%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cc`"
CXX="`%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cxx` `%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-includes`"
@ -1497,11 +1483,18 @@ echo '/* GNU ld script */
%{oformat}
INPUT ( %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/%{_lib}/libgomp.so.1 )' > libgomp.so
%define libstdcxx_so %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/%{_lib}/libstdc++.so.6
%define libstdcxx_so_link INPUT ( %{libstdcxx_so} -lstdc++_nonshared AS_NEEDED (%{libstdcxx_so}) )
%define libstdcxx64_so %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/lib64/libstdc++.so.6
%define libstdcxx64_so_link INPUT ( %{libstdcxx64_so} -lstdc++_nonshared AS_NEEDED (%{libstdcxx64_so}) )
%define libstdcxx32_so %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/lib/libstdc++.so.6
%define libstdcxx32_so_link INPUT ( %{libstdcxx32_so} -lstdc++_nonshared AS_NEEDED (%{libstdcxx32_so}) )
echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
%{oformat}
INPUT ( %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/%{_lib}/libstdc++.so.6 -lstdc++_nonshared )' > libstdc++.so
%{libstdcxx_so_link}' > libstdc++.so
rm -f libgfortran.so
echo '/* GNU ld script
Use the shared library, but some functions are only in
@ -1597,7 +1590,7 @@ echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
%{oformat2}
INPUT ( %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/lib64/libstdc++.so.6 -lstdc++_nonshared )' > 64/libstdc++.so
%{libstdcxx64_so_link}' > 64/libstdc++.so
rm -f 64/libgfortran.so
echo '/* GNU ld script
Use the shared library, but some functions are only in
@ -1685,7 +1678,7 @@ echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
%{oformat2}
INPUT ( %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/lib/libstdc++.so.6 -lstdc++_nonshared )' > 32/libstdc++.so
%{libstdcxx32_so_link}' > 32/libstdc++.so
rm -f 32/libgfortran.so
echo '/* GNU ld script
Use the shared library, but some functions are only in
@ -1992,7 +1985,7 @@ echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
%{oformat}
INPUT ( %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/%{_lib}/libstdc++.so.6 -lstdc++_nonshared )' \
%{libstdcxx_so_link}' \
> %{gcc_target_platform}/libstdc++-v3/src/.libs/libstdc++.so
cp -a %{gcc_target_platform}/libstdc++-v3/src/.libs/libstdc++_nonshared%{nonsharedver}.a \
%{gcc_target_platform}/libstdc++-v3/src/.libs/libstdc++_nonshared.a
@ -2896,6 +2889,8 @@ fi
%changelog
* Thu Jun 12 2025 Siddhesh Poyarekar <siddhesh@redhat.com> 15.1.1-2.2
- Tune for z16 on s390x by default on RHEL10 and later (RHEL-94282)
- Add AS_NEEDED libstdc++.so.6 when only needed through libstdc++_nonshared
(RHEL-84680)
* Fri Jun 6 2025 Marek Polacek <polacek@redhat.com> 15.1.1-2.1
- configure with --enable-host-pie --enable-host-bind-now (RHEL-95595)