enable symbol versioning for dynamic linker (#1875587)

This commit is contained in:
Miroslav Lichvar 2022-11-30 15:30:59 +01:00
parent 49be85802b
commit 080f0e9f9d

View File

@ -129,17 +129,18 @@ common_options="\
abi=6
if true; then
for opts in "-novs" ""; do
for char in narrowc widec; do
mkdir $char$abi
pushd $char$abi
mkdir "$char$abi$opts"
pushd "$char$abi$opts"
ln -s ../configure .
[ $char = widec ] && progs=yes || progs=no
[ $char = widec ] && ! [[ $opts =~ -novs ]] && progs=yes || progs=no
%configure $(
echo $common_options --with-abi-version=$abi
[ $char = widec ] && echo --enable-widec
[[ $opts =~ -novs ]] || echo --with-versioned-syms
[ $progs = yes ] || echo --without-progs
)
@ -148,9 +149,20 @@ if true; then
popd
done
fi
done
%install
# libraries with unversioned symbols will be used for building other
# applications to keep compatibility with distributions that don't enable
# the ncurses symbol versioning (following the upstream default)
make -C narrowc6-novs DESTDIR=$RPM_BUILD_ROOT install.libs
make -C widec6-novs DESTDIR=$RPM_BUILD_ROOT install.libs
rm -f ${RPM_BUILD_ROOT}%{_libdir}/lib{*.a,ncurses++*.*}
chmod 755 ${RPM_BUILD_ROOT}%{_libdir}/lib*.so.*.*
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}/ncurses-novs
mv ${RPM_BUILD_ROOT}%{_libdir}/lib*.so.* \
${RPM_BUILD_ROOT}%{_libdir}/ncurses-novs
make -C narrowc6 DESTDIR=$RPM_BUILD_ROOT install.libs
rm ${RPM_BUILD_ROOT}%{_libdir}/lib{tic,tinfo}.so.6*
make -C widec6 DESTDIR=$RPM_BUILD_ROOT install.{libs,progs,data,includes,man}
@ -195,13 +207,20 @@ for l in $RPM_BUILD_ROOT%{_includedir}/*.h; do
ln -s ../$(basename $l) $RPM_BUILD_ROOT%{_includedir}/ncursesw
done
# don't require -ltinfo when linking with --no-add-needed
for l in $RPM_BUILD_ROOT%{_libdir}/libncurses{,w}.so; do
# redirect ld to libraries with unversioned symbols
for l in $RPM_BUILD_ROOT%{_libdir}/lib{{form,menu,ncurses,panel}{,w},tic,tinfo}.so; do
soname=$(basename $(readlink $l))
rm -f $l
echo "INPUT($soname -ltinfo)" > $l
# don't require -ltinfo when linking with --no-add-needed
[[ "$soname" =~ ^libncurses ]] && extra=" -ltinfo" || extra=""
echo "INPUT(%{_libdir}/ncurses-novs/$soname$extra)" > $l
done
# and filter the generated provides/requires
%global __provides_exclude \\(NCURSES
%global __requires_exclude \\(NCURSES
%global __provides_exclude_from ^%{_libdir}/ncurses-novs
rm -f $RPM_BUILD_ROOT%{_libdir}/libcurses{,w}.so
echo "INPUT(-lncurses)" > $RPM_BUILD_ROOT%{_libdir}/libcurses.so
echo "INPUT(-lncursesw)" > $RPM_BUILD_ROOT%{_libdir}/libcursesw.so
@ -246,6 +265,7 @@ xz NEWS
%doc c++/README*
%doc misc/ncurses.supp
%{_bindir}/ncurses*-config
%{_libdir}/ncurses-novs/lib*.so.6*
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%dir %{_includedir}/ncurses