# spec file for package glibc
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 Samsung Electronics Co. Ltd.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# Enable this when testing on device to:
# 1. Enable macro to turn on testsuite building ('glibc_run_tests 1')
-# 2. Keep 'build-dir/' folder in build stage as we do not want to rebuild all
+# 2. Keep 'build/' folder in build stage as we do not want to rebuild all
# glibc again on device after invoking rpmbuild --short-circuit -bc ...
# 3. Skip configure and make commands and go directly to 'make check'
%if 0%{?run_tests_on_device}
BuildFlags="$(echo $BuildFlags | sed -e 's#-ffortify=[0-9]*##')"
BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector-strong##')"
BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector##')"
-BuildFlags="$(echo $BuildFlags | sed -e 's/-Wa,-mimplicit-it=thumb//g' | sed -e 's/-mthumb//g')"
+BuildFlags="$(echo $BuildFlags | sed -e 's/-Wa,-mimplicit-it=thumb\(-interwork\)\?//g' | sed -e 's/-mthumb\(-interwork\)\?//g')"
# Turn off all -Wformat enable flags as there are glibc tests that explicitly
# append -Wno-format and with enabled Wformat options that produced warnings
# that turns into errors. Remove -Wformat=1|2 or -Wformat-..-arg
%define enable_stackguard_randomization 0
%endif
-configure_and_build_glibc() {
- local dirname="$1"; shift
- local cflags="$1"; shift
- local addons="$1"; shift
- %{!?glibc_keep_build_dir:
- rm -rf "cc-$dirname"
- }
- mkdir "cc-$dirname"
- cd "cc-$dirname"
- conf_cflags="$cflags -funwind-tables -fPIC"
- %{?asan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST"}
- %{?glibc_dump_configure:patch_configure.pl ..}
- profile="--disable-profile"
-%if %{build_profile}
- if [ "$dirname" = "base" ] ; then
- profile="--enable-profile"
- fi
-%endif
+#
+# Build glibc
+#
+%{!?glibc_keep_build_dir:
+ rm -rf "build"
+ mkdir "build"
+ pushd "build"
+ }
+
+conf_cflags="$BuildFlags -funwind-tables -fPIC"
+%{?asan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST"}
+profile="--disable-profile"
+%{?build_profile:profile="--enable-profile"}
+%{?glibc_dump_configure:patch_configure.pl ..}
+
%{!?glibc_skip_configure:
- CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
- CC="$BuildCC" CXX="$BuildCCplus" ../configure \
- --prefix=%{_prefix} \
- --libexecdir=%{_libexecdir} --infodir=%{_infodir} \
- --enable-add-ons=$addons \
- $profile \
- "$@" \
+ CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
+ CC="$BuildCC" CXX="$BuildCCplus" \
+ ../configure \
+ --prefix=%{_prefix} \
+ --libexecdir=%{_libexecdir} --infodir=%{_infodir} \
+ --enable-add-ons=$add_ons \
+ $profile \
+ --enable-kernel=%{enablekernel} \
+ --enable-bind-now \
+ --enable-obsolete-rpc \
+ --disable-nscd \
+ --disable-experimental-malloc \
+ libc_cv_cc_pie_default=yes \
%if %{enable_stackguard_randomization}
- --enable-stackguard-randomization \
+ --enable-stackguard-randomization \
%endif
- --build=%{target} --host=%{target} \
+ --build=%{target} --host=%{target} \
%ifnarch %{multiarcharches}
- --disable-multi-arch \
+ --disable-multi-arch \
%endif
%ifarch %{ix86} x86_64
- --disable-mathvec \
+ --disable-mathvec \
%endif
- --enable-kernel=%{enablekernel} \
- --enable-bind-now --enable-obsolete-rpc \
- --disable-nscd \
- --disable-experimental-malloc \
- libc_cv_cc_pie_default=yes
}
+
%{!?glibc_skip_make:
- make %{?_smp_mflags}
- %{?glibc_dump_configure:
- dump_configure.pl .. . \
- --project glibc \
- --project-version %{version} \
- --out_db glibc-%{version}-%{release}-%_project-%_repository.db
- }
- %{?glibc_exit_on_make_finish:
- exit 1
- }
- cd ..
+ make %{?_smp_mflags}
+%{?glibc_dump_configure:
+ dump_configure.pl .. . \
+ --project glibc \
+ --project-version %{version} \
+ --out_db glibc-%{version}-%{release}-%_project-%_repository.db
}
-}
-configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --disable-mathvec"
+#
+# Build glibc_post_upgrade binary
+#
+$BuildCC \
+ -static %{optflags} -Os \
+ $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glibc_post_upgrade \
+ -L. -Bcsu \
+ '-DREMOVE_TLS_DIRS' '-DREMOVE_PPC_OPTIMIZE_POWER5' \
+ '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'
+%{!?glibc_keep_build_dir:
+ popd
+ }
+#
+# Build html documentation
+#
+%if %{build_html}
+make %{?_smp_mflags} -C "build" html
+%endif
+
+#
+# Build ASan version of glibc
+#
+%{?asan:
+%ifarch %{asan_arch}
+configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --disable-mathvec"
configure_flags="$configure_flags --disable-sanity-checks"
-build_asan() {
- HERE=%{_builddir}/%{name}-%{version}
- J=${J:-32}
- GLIBC=$HERE
- ASAN_BUILD=$HERE/asan-build
- unset CXXFLAGS
- unset CFLAGS
- unset LDFLAGS
+HERE=%{_builddir}/%{name}-%{version}
+J=${J:-32}
+GLIBC=$HERE
+ASAN_BUILD=$HERE/asan-build
+unset CXXFLAGS
+unset CFLAGS
+unset LDFLAGS
%ifarch %arm
- # Glibc must have both functions' implementations
- CPPFLAGS="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
+# Glibc must have both functions' implementations
+CPPFLAGS="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
%endif
- #chmod +x $HERE/asan-glibc-gcc-wrapper.py
- #build static wrapper, because we don't want asan to intercept allocators
- g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static
+# chmod +x $HERE/asan-glibc-gcc-wrapper.py
+# build static wrapper, because we don't want asan to intercept allocators
+g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static
- rm -rf $ASAN_BUILD
- mkdir -p $ASAN_BUILD
- cd $ASAN_BUILD
-# CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
- CPPFLAGS=$CPPFLAGS \
- CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
+rm -rf $ASAN_BUILD
+mkdir -p $ASAN_BUILD
+pushd $ASAN_BUILD
+# Legacy python wrapper call was:
+# CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
+CPPFLAGS=$CPPFLAGS \
+ CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
- # Quick build - builds only libraries, but does not create symlinks.
- make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
- #make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
- cd $HERE
-}
-
- #
- # Build base glibc
- #
- configure_and_build_glibc base "$BuildFlags" "$add_ons"
-
-%{?asan:
-%ifarch %{asan_arch}
-build_asan
-%endif
-}
-#
-# Build html documentation
-#
-%if %{build_html}
-make -C cc-base html
+# Quick build - builds only libraries, but does not create symlinks.
+make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
+# make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
+popd
%endif
+ }
-#
-# Build glibc_post_upgrade binary
-#
-$BuildCC -static %{optflags} -Os $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glibc_post_upgrade \
- -Lcc-base -Bcc-base/csu \
- '-DREMOVE_TLS_DIRS' '-DREMOVE_PPC_OPTIMIZE_POWER5' \
- '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'
+%{?glibc_exit_on_make_finish:
+ echo "Glibc build is complete and environment is ready, exiting"
+ exit 1
+ }
+
+ }
#
# Build testsuite
%{?glibc_run_tests:
export LD_AS_NEEDED=0
- (make %{?_smp_mflags} -C cc-base check || true) 2>&1 | tee check.log
-}
-
+ (make %{?_smp_mflags} -C build check || true) 2>&1 | tee check.log
+ }
#######################################################################
###
# This has to pass on all platforms!
# Exceptions:
# None!
-make %{?_smp_mflags} -C cc-base check-abi
+make %{?_smp_mflags} -C build check-abi
#######################################################################
###
touch %{buildroot}%{_libdir}/gconv/gconv-modules.cache
# Install base glibc
-make %{?_smp_mflags} install_root=%{buildroot} install -C cc-base
+make %{?_smp_mflags} install_root=%{buildroot} install -C build
%{?glibc_dump_configure:
- install -D -m 0644 cc-base/glibc-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/glibc-%{version}-%{release}-%_project-%_repository.db
+ install -D -m 0644 build/glibc-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/glibc-%{version}-%{release}-%_project-%_repository.db
}
-install_optimized_variant() {
- local dirname="$1"; shift
- local subdir="$1"; shift
- local subdir_up="$1"; shift
-
-cd "cc-$dirname"
-destdir=$RPM_BUILD_ROOT/%{_lib}/$subdir
-mkdir -p $destdir
-# Don't run a complete make install, we know which libraries
-# we want
-for lib in libc math/libm nptl/libpthread rt/librt nptl_db/libthread_db
-do
- libbase=${lib#*/}
- libbaseso=$(basename $RPM_BUILD_ROOT/%{_lib}/${libbase}-*.so)
- # Only install if different from base lib
- if cmp -s ${lib}.so ../cc-base/${lib}.so; then
- ln -sf $subdir_up/$libbaseso $destdir/$libbaseso
- else
- cp -a ${lib}.so $destdir/$libbaseso
- fi
- # Emulate ldconfig
- ln -sf $libbaseso $destdir/$(basename $RPM_BUILD_ROOT/%{_lib}/${libbase}.so.*)
-done
-cd ..
-}
-
-
# Install locales
%if %{build_locales}
- # XXX Do not install locales in parallel!
- cd cc-base
- # localedef creates hardlinks to other locales if possible
- # this will not work if we generate them in parallel.
- # thus we need to run fdupes on /usr/lib/locale/
- # Still, on my system this is a speed advantage:
- # non-parallel build for install-locales: 9:34mins
- # parallel build with fdupes: 7:08mins
- make %{?_smp_mflags} install_root=%{buildroot} localedata/install-locales
- %fdupes %{buildroot}/usr/lib/locale
- cd ..
+# XXX Do not install locales in parallel!
+pushd build
+# localedef creates hardlinks to other locales if possible
+# this will not work if we generate them in parallel.
+# thus we need to run fdupes on /usr/lib/locale/
+# Still, on my system this is a speed advantage:
+# non-parallel build for install-locales: 9:34mins
+# parallel build with fdupes: 7:08mins
+make %{?_smp_mflags} install_root=%{buildroot} localedata/install-locales
+%fdupes %{buildroot}/usr/lib/locale
+popd
%endif
+
# Create file list for glibc-locale package
%{find_lang} libc
mkdir -p %{buildroot}/%{_lib}/obsolete
%endif
-# NPTL <bits/stdio-lock.h> is not usable outside of glibc, so include
-# the generic one (RH#162634)
-# cp -av bits/stdio-lock.h %{buildroot}%{_includedir}/bits/stdio-lock.h
-
-
# Miscelanna:
-install -m 0700 glibc_post_upgrade %{buildroot}%{_sbindir}
+install -m 0700 build/glibc_post_upgrade %{buildroot}%{_sbindir}
install -m 644 %{SOURCE7} %{buildroot}/etc
install -m 644 %{SOURCE5} %{buildroot}/etc
%if %{build_html}
mkdir -p %{buildroot}%{_datadir}/doc/glibc
-cp -p cc-base/manual/libc/*.html %{buildroot}%{_datadir}/doc/glibc
+cp -p build/manual/libc/*.html %{buildroot}%{_datadir}/doc/glibc
%endif
-
#
# Create ld.so.conf
#
%{?glibc_run_tests:
mkdir testresults
- cp --parents $(find cc-base -name "*tests.sum") testresults/
+ find build \
+ \( -name "*tests.sum" -o -name "*.out" -o -name "*.test-result" \) \
+ -exec cp --parents {} testresults/ \;
+ find testresults/ -type f -exec chmod 644 {} \;
cp check.log testresults/
- chmod 644 $(find testresults/ -type f)
}
%post -p %{_sbindir}/glibc_post_upgrade