Build glibc32 from the main glibc package (RHEL-106470)

Resolves: RHEL-106470
This commit is contained in:
Florian Weimer 2025-07-30 08:17:43 +02:00
parent c429981bd5
commit 6b217b8105
2 changed files with 81 additions and 5 deletions

View File

@ -157,7 +157,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 221%{?dist}
Release: 222%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -280,7 +280,7 @@ local original = rpm.expand("%{macrobody:__debug_install_post}")
-- Avoid embedded newlines that confuse the macro definition.
original = original:match("^%s*(.-)%s*$"):gsub("\\\n", "")
rpm.define("__debug_install_post bash " .. wrapper
.. " " .. sysroot .. " %{_prefix}/%{glibc_ldso} " .. original)
.. " " .. sysroot .. " %{_prefix}%{glibc_ldso} " .. original)
}
# sysroot package support. These contain arch-specific packages, so
@ -1367,6 +1367,10 @@ Requires: basesystem
# after nss_*.x86_64. (See below for the other ordering.)
Recommends: (nss_db(x86-32) if nss_db(x86-64))
Recommends: (nss_hesiod(x86-32) if nss_hesiod(x86-64))
# Deinstall the glibc32 package if present. This helps tests that do
# not run against the compose.
Conflicts: glibc32 <= %{version}-%{release}
Obsoletes: glibc32 <= %{version}-%{release}
%endif
# This is for building auxiliary programs like memusage, nscd
@ -2156,6 +2160,32 @@ that can be installed across architectures.
%dnl %%{without bootstrap}
%endif
##############################################################################
# glibc32 (only for use in building GCC, not shipped)
##############################################################################
%ifarch x86_64
%package -n glibc32
Summary: The GNU libc libraries (32-bit)
Conflicts: glibc(x86-32)
%dnl The gcc package does not use ELF dependencies to install glibc32:
%dnl BuildRequires: (glibc32 or glibc-devel(%{__isa_name}-32))
%dnl Not generating the ELF dependencies for glibc32 makes it less likely
%dnl that the package is selected by accident over glibc.i686.
AutoReqProv: no
%description -n glibc32
This package is only used for internal building of multilib aware
packages, like gcc, due to a technical limitation in the distribution
build environment. Any package which needs both 32-bit and 64-bit
runtimes at the same time must install glibc32 (marked as a 64-bit
package) to access the 32-bit development files during a 64-bit build.
This package is not supported or intended for use outside of the
distribution build enviroment. Regular users can install both 32-bit and
64-bit runtimes and development files without any problems.
%endif
##############################################################################
# Prepare for the build.
##############################################################################
@ -2327,14 +2357,12 @@ build()
--with-nonshared-cflags="$BuildFlagsNonshared" \
--enable-bind-now \
--build=%{target} \
${configure_host} \
--enable-stack-protector=strong \
--enable-tunables \
--enable-systemtap \
${core_with_options} \
%{?glibc_rtld_early_cflags:--with-rtld-early-cflags=%glibc_rtld_early_cflags} \
%ifarch x86_64 %{ix86}
--enable-cet \
%endif
%ifarch %{ix86}
--disable-multi-arch \
%endif
@ -2356,6 +2384,17 @@ build()
popd
}
%ifarch x86_64
# Build for the glibc32 package.
GCC="$GCC -m32" GXX="$GXX -m32" BuildFlags="${BuildFlags/-m64/-m32}" configure_host="--host=i686-linux-gnu" build 32
%endif
configure_host=""
%ifarch x86_64
configure_host="--enable-cet"
%endif
# Default set of compiler options.
build
@ -2398,6 +2437,19 @@ for d in %{glibc_sysroot}%{_libdir}; do
done
%endif
%ifarch x86_64
# Install for the glibc32 package.
pushd build-%{target}-32
%make_build install_root=%{glibc_sysroot} install
popd
pushd %{glibc_sysroot}
rm -rf etc var usr/bin usr/lib/gconv usr/libexec usr/sbin usr/share
rm -f lib/libnss_db* lib/libnss_hesiod* lib/libnsl* usr/lib/libnsl* usr/lib/libnss*
rm usr/lib/libc_malloc_debug.so
strip -g usr/lib/*.o
popd
%endif
# Build and install:
pushd build-%{target}
%make_build install_root=%{glibc_sysroot} install
@ -2704,7 +2756,17 @@ pushd %{glibc_sysroot}/%{sysroot_prefix}
mkdir -p usr/lib usr/lib64
cp -a %{glibc_sysroot}/%{_prefix}/include usr/.
%ifarch x86_64
# 32-bit headers for glibc32 don't go in the sysroot.
rm usr/include/gnu/*-32.h
%endif
for lib in lib lib64; do
%ifarch x86_64
if [ "$lib" = "lib" ]; then
# 32-bit libraries built for glibc32 don't go in the sysroot.
continue
fi
%endif
for pfx in "" %{_prefix}/; do
if test -d %{glibc_sysroot}/$pfx$lib ; then
# Implement UsrMove: everything goes into usr/$lib. Only
@ -3324,7 +3386,20 @@ update_gconv_modules_cache ()
%{sysroot_prefix}
%endif
%ifarch x86_64
%files -n glibc32
%{_includedir}/gnu/lib-names-32.h
%{_includedir}/gnu/stubs-32.h
%{_prefix}/lib/*.a
%{_prefix}/lib/*.o
%{_prefix}/lib/*.so*
%{_prefix}/lib/audit/*
%endif
%changelog
* Wed Jul 30 2025 Florian Weimer <fweimer@redhat.com> - 2.34-222
- Build glibc32 from the main glibc package (RHEL-106470)
* Tue Jul 29 2025 Florian Weimer <fweimer@redhat.com> - 2.34-221
- Use Requires(pre): libgcc%%{_isa} to break libgcc cycle (RHEL-106166)

View File

@ -48,6 +48,7 @@ script_path="$1"
shift
# libc.so.6 always uses this name, so it is simpler to locate.
# This can result in multiple paths, hence the loop below.
libc_path=`find "$sysroot_path" -name libc.so.6`