2 # spec file for package glibc
4 # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
6 # All modifications and additions to the file contributed by third parties
7 # remain the property of their copyright owners, unless otherwise agreed
8 # upon. The license for this file, and modifications and additions to the
9 # file, is the same license as for the pristine package itself (unless the
10 # license for the pristine package is not an Open Source License, in which
11 # case the license is the MIT License). An "Open Source License" is a
12 # license that conforms to the Open Source Definition (Version 1.9)
13 # published by the Open Source Initiative.
15 # This will avoid building some parts of glibc
16 %define asan_arch x86_64 armv7l aarch64
17 %bcond_with fast_build
19 Summary: Standard Shared Libraries (from the GNU C Library)
20 License: LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
23 BuildRequires: makeinfo
25 BuildRequires: gcc-c++
26 BuildRequires: gettext-tools
27 BuildRequires: libstdc++-devel
30 #BuildRequires: python
31 BuildRequires: glibc-devel-static
34 #BuildRequires: pkgconfig(systemd)
35 %define _filter_GLIBC_PRIVATE 1
36 %if %_target_cpu == "i686"
37 # For i686 let's only build what's different from i586, so
38 # no need to build documentation
39 %define build_profile 1
40 %define build_locales 0
43 %if %{with fast_build}
44 %define build_profile 0
45 %define build_locales 0
49 %define build_profile 1
50 %define build_locales 0
55 %define disable_assert 0
56 %define enable_stackguard_randomization 1
57 %define multiarcharches %{ix86} x86_64
60 %define enablekernel 2.6.16
62 %define enablekernel 2.6.16
64 Conflicts: kernel < %{enablekernel}
65 %ifarch armv7l armv7hl
66 # The old runtime linker link gets not provided by rpm find.provides, but it exists
67 Provides: ld-linux.so.3
68 Provides: ld-linux.so.3(GLIBC_2.4)
72 %define glibc_major_version 2.24
73 %define git_id 4e42b5b8f89f
75 Url: http://www.gnu.org/software/libc/libc.html
76 Source: glibc-%{version}.tar.xz
77 Source5: nsswitch.conf
78 Source7: bindresvport.blacklist
79 Source8: glibc_post_upgrade.c
80 Source9: glibc.rpmlintrc
81 Source10: baselibs.conf
83 Source1001: glibc.manifest
85 Requires(pre): filesystem
86 Provides: rtld(GNU_HASH)
89 The GNU C Library provides the most important standard libraries used
90 by nearly all programs: the standard C library, the standard math
91 library, and the POSIX thread library. A system is not functional
92 without these libraries.
95 Summary: Info Files for the GNU C Library
101 This package contains the documentation for the GNU C library stored as
102 info files. Due to a lack of resources, this documentation is not
103 complete and is partially out of date.
106 Summary: HTML Documentation for the GNU C Library
112 This package contains the HTML documentation for the GNU C library. Due
113 to a lack of resources, this documentation is not complete and is
114 partially out of date.
117 Summary: Database Sources for 'locale'
118 License: GPL-2.0+ and MIT
119 Group: Base/Libraries
122 %description i18ndata
123 This package contains the data needed to build the locale data files to
124 use the internationalization features of the GNU libc. It is normally
125 not necessary to install this packages, the data files are already
129 Summary: Locale Data for Localized Programs
130 License: GPL-2.0+ and MIT and LGPL-2.1+
131 Requires(post): /usr/bin/cat
132 Requires: glibc = %{version}
134 Locale data for the internationalisation features of the GNU C library.
137 Summary: Libc Profiling and Debugging Versions
138 License: LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
139 Group: Base/Utilities
140 Requires: glibc = %{version}
143 This package contains special versions of the GNU C library which are
144 necessary for profiling and debugging.
147 Summary: Include Files and Libraries Mandatory for Development
148 License: BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
149 Requires: glibc = %{version}
150 Requires: linux-kernel-headers
153 These libraries are needed to develop programs which use the standard C
156 %package devel-static
157 Summary: C library static libraries for -static linking
158 License: BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
159 Requires: %{name}-devel = %{version}
160 # Provide Fedora name for package to make packaging easier
161 Provides: %{name}-static = %version
163 %description devel-static
164 The glibc-devel-static package contains the C library static libraries
165 for -static linking. You don't need these, unless you link statically,
166 which is highly discouraged.
169 Summary: Development utilities from GNU C library
171 Requires: glibc = %{version}
173 %description devel-utils
174 The glibc-devel-utils package contains various binaries which can be helpful during program
177 If you are unsure if you need this, don't install this package.
180 Summary: Extra binaries from GNU C Library
182 Requires: glibc = %{version}
185 The glibc-extra package contains some extra binaries for glibc that
186 are not essential but recommend to use.
188 makedb: A program to create a database for nss
191 Summary: Obsolete Shared Libraries from the GNU C Library
193 Requires: glibc = %{version}
195 %description obsolete
196 This package provides some old libraries from the GNU C Library which
197 are no longer supported. Additional it provides a compatibility library
198 for old binaries linked against glibc 2.0.
200 Install this package if you need one of this libraries to get old
201 binaries working, but since this libraries are not supported and there
202 is no gurantee that they work for you, you should try to get newer
203 versions of your software.
208 Summary: glibc with ASan instrumentation
209 License: LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
210 Requires: glibc = %{version}
213 This package provides glibc with ASan instrumentation
216 ln -s --force /%{_lib}/libc-2.24-asan.so /%{_lib}/libc.so.6
219 ln -s --force /%{_lib}/libc-2.24.so /%{_lib}/libc.so.6
225 %setup -n glibc-%{version} -q
229 %{?asan:%gcc_unforce_options}
230 if [ -x /bin/uname.bin ]; then
238 # We do not want configure to figure out the system its building one
239 # to support a common ground and thus set build and host to the
242 %define target %{_target_cpu}-tizen-linux-gnueabi
244 %define target %{_target_cpu}-tizen-linux
246 # Don't use as-needed, it breaks glibc assumptions
247 # Before enabling it, run the testsuite and verify that it
249 export LD_AS_NEEDED=0
250 # Adjust glibc version.h
251 echo "#define CONFHOST \"%{target}\"" >> version.h
252 echo "#define GITID \"%{git_id}\"" >> version.h
254 # Default CFLAGS and Compiler
256 BuildFlags=$(echo %{optflags} | sed -e "s/-Wp,-D_FORTIFY_SOURCE=2//g" | sed -e "s/-ffast-math//" | sed -e "s/atom/i686/g" | sed -e "s/-fexceptions//" | sed -e "s/-fno-omit-frame-pointer//" )
257 BuildFlags="$BuildFlags -O2 -g -U_FORTIFY_SOURCE"
258 BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector##' -e 's#-ffortify=[0-9]*##')"
259 BuildFlags="$(echo $BuildFlags | sed -e 's/-Wa,-mimplicit-it=thumb//g' | sed -e 's/-mthumb//g')"
260 # Turn off all -Wformat enable flags as there are glibc tests that explicitly
261 # append -Wno-format and with enabled Wformat options that produced warnings
262 # that turns into errors. Remove -Wformat=1|2 or -Wformat-..-arg
263 BuildFlags="$(echo $BuildFlags | sed -re 's/-Wformat((=[1-2])|((-\w+)+))?(\s|$)//g')"
269 BuildFlags="$BuildFlags -g"
270 %if %{disable_assert}
271 BuildFlags="$BuildFlags -DNDEBUG=1"
280 # fails to build otherwise - need to recheck and fix
281 %define enable_stackguard_randomization 0
284 configure_and_build_glibc() {
285 local dirname="$1"; shift
286 local cflags="$1"; shift
287 local addons="$1"; shift
290 conf_cflags="$cflags -funwind-tables -fPIC"
291 %{?asan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST "}
293 profile="--disable-profile"
295 if [ "$dirname" = "base" ] ; then
296 profile="--enable-profile"
299 CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
300 CC="$BuildCC" CXX="$BuildCCplus" ../configure \
301 --prefix=%{_prefix} \
302 --libexecdir=%{_libexecdir} --infodir=%{_infodir} \
303 --enable-add-ons=$addons \
306 %if %{enable_stackguard_randomization}
307 --enable-stackguard-randomization \
309 --build=%{target} --host=%{target} \
310 %ifnarch %{multiarcharches}
311 --disable-multi-arch \
313 %ifarch %{ix86} x86_64
316 --enable-kernel=%{enablekernel} \
317 --enable-bind-now --enable-obsolete-rpc \
319 libc_cv_pie_default=yes
320 # explicitly set CFLAGS to use the full CFLAGS (not the reduced one for configure)
321 make %{?_smp_mflags} #CFLAGS="$cflags" BUILD_CFLAGS="$cflags"
325 configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --disable-mathvec"
327 configure_flags="$configure_flags --disable-sanity-checks"
330 HERE=%{_builddir}/%{name}-%{version}
333 ASAN_BUILD=$HERE/asan-build
337 #chmod +x $HERE/asan-glibc-gcc-wrapper.py
338 #build static wrapper, because we don't want asan to intercept allocators
339 g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static
344 # CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
345 CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
347 # Quick build - builds only libraries, but does not create symlinks.
348 make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
349 #make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
356 configure_and_build_glibc base "$BuildFlags" "$add_ons"
364 # Build html documentation
371 # Build glibc_post_upgrade binary
373 $BuildCC -static %{optflags} -Os $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glibc_post_upgrade \
374 -Lcc-base -Bcc-base/csu \
375 '-DREMOVE_TLS_DIRS' '-DREMOVE_PPC_OPTIMIZE_POWER5' \
376 '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'
379 #######################################################################
383 #######################################################################
386 # The testsuite will fail if asneeded is used
387 export LD_AS_NEEDED=0
388 # This has to pass on all platforms!
391 make %{?_smp_mflags} -C cc-base check-abi
393 #######################################################################
397 #######################################################################
400 # We don't want to strip the .symtab from our libraries in find-debuginfo.sh,
401 # certainly not from libpthread.so.* because it is used by libthread_db to find
402 # some non-exported symbols in order to detect if threading support
403 # should be enabled. These symbols are _not_ exported, and we can't easily
404 # export them retroactively without changing the ABI. So we have to
405 # continue to "export" them via .symtab, instead of .dynsym :-(
406 # But we also want to keep .symtab and .strtab of other libraries since some
407 # debugging tools currently require these sections directly inside the main
408 # files - specifically valgrind and PurifyPlus.
409 export STRIP_KEEP_SYMTAB=*.so*
411 # Make sure we will create the gconv-modules.cache
412 mkdir -p %{buildroot}%{_libdir}/gconv
413 touch %{buildroot}%{_libdir}/gconv/gconv-modules.cache
416 make %{?_smp_mflags} install_root=%{buildroot} install -C cc-base
418 install_optimized_variant() {
419 local dirname="$1"; shift
420 local subdir="$1"; shift
421 local subdir_up="$1"; shift
424 destdir=$RPM_BUILD_ROOT/%{_lib}/$subdir
426 # Don't run a complete make install, we know which libraries
428 for lib in libc math/libm nptl/libpthread rt/librt nptl_db/libthread_db
431 libbaseso=$(basename $RPM_BUILD_ROOT/%{_lib}/${libbase}-*.so)
432 # Only install if different from base lib
433 if cmp -s ${lib}.so ../cc-base/${lib}.so; then
434 ln -sf $subdir_up/$libbaseso $destdir/$libbaseso
436 cp -a ${lib}.so $destdir/$libbaseso
439 ln -sf $libbaseso $destdir/$(basename $RPM_BUILD_ROOT/%{_lib}/${libbase}.so.*)
447 # XXX Do not install locales in parallel!
449 # localedef creates hardlinks to other locales if possible
450 # this will not work if we generate them in parallel.
451 # thus we need to run fdupes on /usr/lib/locale/
452 # Still, on my system this is a speed advantage:
453 # non-parallel build for install-locales: 9:34mins
454 # parallel build with fdupes: 7:08mins
455 make %{?_smp_mflags} install_root=%{buildroot} localedata/install-locales
456 %fdupes %{buildroot}/usr/lib/locale
459 # Create file list for glibc-locale package
462 # Prepare obsolete/, used only on some architectures:
463 export RPM_BUILD_ROOT
465 mkdir -p %{buildroot}/%{_lib}/obsolete
468 # NPTL <bits/stdio-lock.h> is not usable outside of glibc, so include
469 # the generic one (RH#162634)
470 # cp -av bits/stdio-lock.h %{buildroot}%{_includedir}/bits/stdio-lock.h
475 install -m 0700 glibc_post_upgrade %{buildroot}%{_sbindir}
477 install -m 644 %{SOURCE7} %{buildroot}/etc
478 install -m 644 %{SOURCE5} %{buildroot}/etc
479 install -m 644 posix/gai.conf %{buildroot}/etc
481 mkdir -p %{buildroot}/etc/default
482 install -m 644 nis/nss %{buildroot}/etc/default/
484 mkdir -p %{buildroot}%{_includedir}/resolv
485 install -m 0644 resolv/mapv4v6addr.h %{buildroot}%{_includedir}/resolv/
486 install -m 0644 resolv/mapv4v6hostent.h %{buildroot}%{_includedir}/resolv/
489 mkdir -p %{buildroot}%{_datadir}/doc/glibc
490 cp -p cc-base/manual/libc/*.html %{buildroot}%{_datadir}/doc/glibc
497 cat > %{buildroot}/etc/ld.so.conf <<EOF
498 %if "%{_lib}" == "lib64"
502 include /etc/ld.so.conf.d/*.conf
503 # /lib64, /lib, /usr/lib64 and /usr/lib gets added
504 # automatically by ldconfig after parsing this file.
505 # So, they do not need to be listed.
507 # Add ldconfig cache directory for directory ownership
508 mkdir -p %{buildroot}/var/cache/ldconfig
509 # Empty the ld.so.cache:
510 rm -f %{buildroot}/etc/ld.so.cache
511 touch %{buildroot}/etc/ld.so.cache
513 # Don't look at ldd! We don't wish a /bin/sh requires
514 chmod 644 %{buildroot}%{_bindir}/ldd
516 # Remove timezone data, now coming in standalone package:
517 for i in sbin/sln usr/bin/tzselect usr/sbin/zic usr/sbin/zdump etc/localtime; do
518 rm -f %{buildroot}/$i
520 rm -rf %{buildroot}%{_datadir}/zoneinfo
523 # Provide compatibility link
524 ln -s ld-%{glibc_major_version}.so %{buildroot}/lib/ld-linux.so.3
527 # Move getconf to %{_libexecdir}/getconf/ to avoid cross device link
528 mv %{buildroot}%{_bindir}/getconf %{buildroot}%{_libexecdir}/getconf/getconf
529 ln -s %{_libexecdir}/getconf/getconf %{buildroot}%{_bindir}/getconf
531 #######################################################################
535 #######################################################################
539 HERE=%{_builddir}/%{name}-%{version}
541 ASAN_BUILD=$HERE/asan-build
542 cp $ASAN_BUILD/libc.so %{buildroot}/%{_lib}/libc-2.24-asan.so
546 %post -p %{_sbindir}/glibc_post_upgrade
548 %postun -p /sbin/ldconfig
551 for l in /usr/share/locale/locale.alias %{_libdir}/gconv/gconv-modules; do
552 [ -d "$l.d" ] || continue
553 echo "###X# The following is autogenerated from extra files in the .d directory:" >>"$l"
556 /usr/sbin/iconvconfig
559 %install_info --info-dir=%{_infodir} %{_infodir}/libc.info.gz
562 %install_info_delete --info-dir=%{_infodir} %{_infodir}/libc.info.gz
565 %manifest %{name}.manifest
567 %defattr(-,root,root)
568 %license LICENSES COPYING COPYING.LIB
569 %config(noreplace) /etc/bindresvport.blacklist
570 %config /etc/ld.so.conf
571 %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache
572 %config(noreplace) /etc/rpc
573 %verify(not md5 size mtime) %config(noreplace) /etc/nsswitch.conf
574 %verify(not md5 size mtime) %config(noreplace) /etc/gai.conf
575 %config(noreplace) /etc/default/nss
576 /%{_lib}/ld-%{glibc_major_version}.so
578 # Each architecture has a different name for the dynamic linker:
581 /%{_lib}/ld-linux-armhf.so.3
582 # Keep compatibility link
583 /%{_lib}/ld-linux.so.3
585 /%{_lib}/ld-linux.so.3
589 /%{_lib}/ld-linux-x86-64.so.2
592 /%{_lib}/ld-linux.so.2
595 /lib/ld-linux-aarch64.so.1
596 /%{_lib}/ld-linux-aarch64.so.1
599 /%{_lib}/libanl-%{glibc_major_version}.so
601 /%{_lib}/libc-%{glibc_major_version}.so
603 /%{_lib}/libcidn-%{glibc_major_version}.so
604 /%{_lib}/libcidn.so.1
605 /%{_lib}/libcrypt-%{glibc_major_version}.so
606 /%{_lib}/libcrypt.so.1
607 /%{_lib}/libdl-%{glibc_major_version}.so
609 /%{_lib}/libm-%{glibc_major_version}.so
611 /%{_lib}/libnsl-%{glibc_major_version}.so
613 /%{_lib}/libnss_compat-%{glibc_major_version}.so
614 /%{_lib}/libnss_compat.so.2
615 /%{_lib}/libnss_db-%{glibc_major_version}.so
616 /%{_lib}/libnss_db.so.2
617 /%{_lib}/libnss_dns-%{glibc_major_version}.so
618 /%{_lib}/libnss_dns.so.2
619 /%{_lib}/libnss_files-%{glibc_major_version}.so
620 /%{_lib}/libnss_files.so.2
621 /%{_lib}/libnss_hesiod-%{glibc_major_version}.so
622 /%{_lib}/libnss_hesiod.so.2
623 /%{_lib}/libnss_nis-%{glibc_major_version}.so
624 /%{_lib}/libnss_nis.so.2
625 /%{_lib}/libnss_nisplus-%{glibc_major_version}.so
626 /%{_lib}/libnss_nisplus.so.2
627 /%{_lib}/libpthread-%{glibc_major_version}.so
628 /%{_lib}/libpthread.so.0
629 /%{_lib}/libthread_db-1.0.so
630 /%{_lib}/libthread_db.so.1
631 /%{_lib}/libresolv-%{glibc_major_version}.so
632 /%{_lib}/libresolv.so.2
633 /%{_lib}/librt-%{glibc_major_version}.so
635 /%{_lib}/libutil-%{glibc_major_version}.so
636 /%{_lib}/libutil.so.1
637 %define optimized_libs() \
638 %dir %attr(0755,root,root) /%{_lib}/%1\
639 /%{_lib}/%1/libc-%{glibc_major_version}.so\
640 /%{_lib}/%1/libc.so.6*\
641 /%{_lib}/%1/libm-%{glibc_major_version}.so\
642 /%{_lib}/%1/libm.so.6*\
643 /%{_lib}/%1/libpthread-%{glibc_major_version}.so\
644 /%{_lib}/%1/libpthread.so.0\
645 /%{_lib}/%1/librt-%{glibc_major_version}.so\
646 /%{_lib}/%1/librt.so.1\
647 /%{_lib}/%1/libthread_db-1.0.so\
648 /%{_lib}/%1/libthread_db.so.1
650 %dir %attr(0700,root,root) /var/cache/ldconfig
656 %attr(755,root,root) %{_bindir}/ldd
657 %ifarch %ix86 sparc sparcv9
662 %dir %attr(0755,root,root) %{_libexecdir}/getconf
663 %{_libexecdir}/getconf/*
664 %{_sbindir}/glibc_post_upgrade
665 %{_sbindir}/iconvconfig
666 /%{_lib}/libBrokenLocale-%{glibc_major_version}.so
667 /%{_lib}/libBrokenLocale.so.1
672 %manifest %{name}.manifest
674 %defattr (755,root,root,755)
675 %dir /%{_lib}/obsolete/
676 #%dir /%{_lib}/obsolete/noversion
677 #/%{_lib}/obsolete/noversion/libNoVersion-%{glibc_major_version}.so
678 #/%{_lib}/obsolete/noversion/libNoVersion.so.1
681 %files locale -f libc.lang
682 %manifest %{name}.manifest
683 %license COPYING COPYING.LIB
684 %defattr(-,root,root)
685 %{_datadir}/locale/locale.alias
694 %manifest %{name}.manifest
695 /%{_lib}/libc-2.24-asan.so
700 %manifest %{name}.manifest
701 %defattr(-,root,root)
702 %license COPYING COPYING.LIB
703 %doc NEWS README BUGS CONFORMANCE
708 # These static libraries are needed even for shared builds
709 %{_libdir}/libc_nonshared.a
712 %ifarch ppc ppc64 s390 s390x sparc sparcv8 sparcv9 sparcv9v
713 # This is not built on sparc64.
714 %{_libdir}/libnldbl_nonshared.a
716 %{_libdir}/libmcheck.a
717 %{_libdir}/libpthread_nonshared.a
718 %{_libdir}/librpcsvc.a
721 %manifest %{name}.manifest
722 %defattr(-,root,root)
723 %{_libdir}/libBrokenLocale.a
726 %{_libdir}/libcrypt.a
730 %{_libdir}/libpthread.a
731 %{_libdir}/libresolv.a
736 %manifest %{name}.manifest
737 %defattr(-,root,root)
738 %doc %{_infodir}/libc.info.gz
739 %doc %{_infodir}/libc.info-?.gz
740 %doc %{_infodir}/libc.info-??.gz
744 %manifest %{name}.manifest
745 %defattr(-,root,root)
746 %doc %{_prefix}/share/doc/glibc
750 %manifest %{name}.manifest
751 %defattr(-,root,root)
752 %{_prefix}/share/i18n
756 %manifest %{name}.manifest
757 %license COPYING COPYING.LIB
758 %defattr(-,root,root)
760 %{_libdir}/libBrokenLocale_p.a
761 %{_libdir}/libanl_p.a
763 %{_libdir}/libcrypt_p.a
764 %{_libdir}/libpthread_p.a
765 %{_libdir}/libresolv_p.a
766 %{_libdir}/libnsl_p.a
768 %{_libdir}/librpcsvc_p.a
769 %{_libdir}/libutil_p.a
774 %manifest %{name}.manifest
775 %defattr(-,root,root)
776 /%{_lib}/libmemusage.so
777 /%{_lib}/libpcprofile.so
778 /%{_libdir}/libBrokenLocale.so
779 /%{_lib}/libSegFault.so
780 /%{_lib}/libthread_db-1.0.so
781 /%{_lib}/libthread_db.so.1
782 /%{_libdir}/libthread_db.so
783 %dir /%{_libdir}/audit
784 /%{_libdir}/audit/sotruss-lib.so
785 # These need gd-devel for building
786 # %%{_bindir}/memusage
787 # %%{_bindir}/memusagestat
789 %{_bindir}/pcprofiledump
797 %manifest %{name}.manifest
799 %defattr(-,root,root)