c7f31d293c49dcf286dbb821b9a5f4dfc97cd69a
[platform/upstream/glibc.git] / packaging / glibc.spec
1 #
2 # spec file for package glibc
3 #
4 # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 # Copyright (c) 2021 Samsung Electronics Co. Ltd.
6 #
7 # All modifications and additions to the file contributed by third parties
8 # remain the property of their copyright owners, unless otherwise agreed
9 # upon. The license for this file, and modifications and additions to the
10 # file, is the same license as for the pristine package itself (unless the
11 # license for the pristine package is not an Open Source License, in which
12 # case the license is the MIT License). An "Open Source License" is a
13 # license that conforms to the Open Source Definition (Version 1.9)
14 # published by the Open Source Initiative.
15
16 %if 0%{?run_tests}
17 %define glibc_run_tests 1
18 %endif
19
20 # Enable this when testing on device to:
21 # 1. Enable macro to turn on testsuite building ('glibc_run_tests 1')
22 # 2. Keep 'build/' folder in build stage as we do not want to rebuild all
23 # glibc again on device after invoking rpmbuild --short-circuit -bc ...
24 # 3. Skip configure and make commands and go directly to 'make check'
25 %if 0%{?run_tests_on_device}
26 %define glibc_run_tests 1
27 %define glibc_keep_build_dir 1
28 %define glibc_skip_configure 1
29 %define glibc_skip_make 1
30 %endif
31
32 # Exit right after 'make ..' step to keep all object files produced by glibc build
33 %if 0%{?exit_on_make_finish}
34 %define glibc_exit_on_make_finish 1
35 %endif
36
37 %if 0%{?dump_configure}
38 %define glibc_dump_configure 1
39 %endif
40
41 # Prepare separate ld.so for qemu-accel
42 %define qemu_accel_arch x86_64 %ix86
43
44 %ifarch %qemu_accel_arch
45 %define glibc_build_qemu_accel_ld_so 1
46 # default path in qemu
47 %define emul_path /emul
48 %endif
49
50 # This will avoid building some parts of glibc
51 %define asan_arch x86_64 armv7l aarch64
52 %define hwasan_arch aarch64
53 %bcond_with    fast_build
54 Name:           glibc
55 Summary:        Standard Shared Libraries (from the GNU C Library)
56 License:        LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
57 Group:          Base/Libraries
58 BuildRequires:  fdupes
59 BuildRequires:  makeinfo
60 BuildRequires:  xz
61 BuildRequires:  gcc-c++
62 BuildRequires:  gettext-tools
63 BuildRequires:  libstdc++-devel
64 BuildRequires:  bison
65 BuildRequires:  python3-base
66 %{?asan:
67 %ifarch %asan_arch
68 #BuildRequires:  python
69 BuildRequires:  glibc-devel-static
70 %endif
71 }
72 %if 0%{?glibc_dump_configure}
73 BuildRequires: configure-dumper
74 %endif
75 #BuildRequires:  pkgconfig(systemd)
76 %define _filter_GLIBC_PRIVATE 1
77 %if %_target_cpu == "i686"
78 # For i686 let's only build what's different from i586, so
79 # no need to build documentation
80 %define build_profile 1
81 %define build_locales 0
82 %define build_html 0
83 %else
84 %if %{with fast_build}
85 %define build_profile 0
86 %define build_locales 0
87 %define build_html 0
88 %else
89 # Default:
90 %define build_profile 1
91 %define build_locales 0
92 %define build_html 0
93 %endif
94 %endif
95
96 %define disable_assert 0
97 %define enable_stackguard_randomization 1
98 %define multiarcharches %{ix86} x86_64
99
100 %ifarch x86_64
101 %define enablekernel 2.6.16
102 %else
103 %define enablekernel 2.6.16
104 %endif
105 Conflicts:      kernel < %{enablekernel}
106 %ifarch armv7l armv7hl
107 # The old runtime linker link gets not provided by rpm find.provides, but it exists
108 Provides:       ld-linux.so.3
109 Provides:       ld-linux.so.3(GLIBC_2.4)
110 %endif
111 Version:        2.37
112 Release:        0
113 %define glibc_major_version %{version}
114 %define git_id 0a8262a1b2
115
116 Url:            http://www.gnu.org/software/libc/libc.html
117 Source:         glibc-%{version}.tar.xz
118 Source5:        nsswitch.conf
119 Source7:        bindresvport.blacklist
120 Source8:        glibc_post_upgrade.c
121 Source9:        glibc.rpmlintrc
122 Source10:       baselibs.conf
123 # For systemd
124 Source1001:     glibc.manifest
125
126 Requires(pre):  filesystem
127 Provides:       rtld(GNU_HASH)
128
129 %description
130 The GNU C Library provides the most important standard libraries used
131 by nearly all programs: the standard C library, the standard math
132 library, and the POSIX thread library. A system is not functional
133 without these libraries.
134
135 %package info
136 Summary:        Info Files for the GNU C Library
137 License:        GFDL-1.1
138 Group:          Documentation
139 BuildArch:      noarch
140
141 %description info
142 This package contains the documentation for the GNU C library stored as
143 info files. Due to a lack of resources, this documentation is not
144 complete and is partially out of date.
145
146 %package html
147 Summary:        HTML Documentation for the GNU C Library
148 License:        GFDL-1.1
149 Group:          Documentation
150 BuildArch:      noarch
151
152 %description html
153 This package contains the HTML documentation for the GNU C library. Due
154 to a lack of resources, this documentation is not complete and is
155 partially out of date.
156
157 %package i18ndata
158 Summary:        Database Sources for 'locale'
159 License:        GPL-2.0+ and MIT
160 Group:          Base/Libraries
161 BuildArch:      noarch
162
163 %description i18ndata
164 This package contains the data needed to build the locale data files to
165 use the internationalization features of the GNU libc. It is normally
166 not necessary to install this packages, the data files are already
167 created.
168
169 %package locale
170 Summary:        Locale Data for Localized Programs
171 License:        GPL-2.0+ and MIT and LGPL-2.1+
172 Requires(post): /usr/bin/cat
173 Requires:       glibc = %{version}
174 %description locale
175 Locale data for the internationalisation features of the GNU C library.
176
177 %package profile
178 Summary:        Libc Profiling and Debugging Versions
179 License:        LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
180 Group:          Base/Utilities
181 Requires:       glibc = %{version}
182
183 %description profile
184 This package contains special versions of the GNU C library which are
185 necessary for profiling and debugging.
186
187 %package devel
188 Summary:        Include Files and Libraries Mandatory for Development
189 License:        BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
190 Requires:       glibc = %{version}
191 Requires:       linux-kernel-headers
192 # TODO: REMOVE ME
193 # Currently needed for correct install order to enable patching statx.h on aarch64
194 Requires:       gcc
195
196 %description devel
197 These libraries are needed to develop programs which use the standard C
198 library.
199
200 %package devel-static
201 Summary:        C library static libraries for -static linking
202 License:        BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
203 Requires:       %{name}-devel = %{version}
204 # Provide Fedora name for package to make packaging easier
205 Provides:       %{name}-static = %version
206
207 %description devel-static
208 The glibc-devel-static package contains the C library static libraries
209 for -static linking.  You don't need these, unless you link statically,
210 which is highly discouraged.
211
212 %package devel-utils
213 Summary:        Development utilities from GNU C library
214 License:        LGPL-2.1+
215 Requires:       glibc = %{version}
216
217 %description devel-utils
218 The glibc-devel-utils package contains various binaries which can be helpful during program
219 debugging.
220
221 If you are unsure if you need this, don't install this package.
222
223 %package extra
224 Summary:        Extra binaries from GNU C Library
225 License:        LGPL-2.1+
226 Requires:       glibc = %{version}
227
228 %description extra
229 The glibc-extra package contains some extra binaries for glibc that
230 are not essential but recommend to use.
231
232 makedb: A program to create a database for nss
233
234 %package obsolete
235 Summary:        Obsolete Shared Libraries from the GNU C Library
236 License:        LGPL-2.0+
237 Requires:       glibc = %{version}
238
239 %description obsolete
240 This package provides some old libraries from the GNU C Library which
241 are no longer supported. Additional it provides a compatibility library
242 for old binaries linked against glibc 2.0.
243
244 Install this package if you need one of this libraries to get old
245 binaries working, but since this libraries are not supported and there
246 is no gurantee that they work for you, you should try to get newer
247 versions of your software.
248
249 %package testresults
250 Summary:       Testsuite results
251 License:       LGPL-2.1+
252 Group:         Development/Languages
253 %description testresults
254 Results from running the glibc testsuites.
255
256 %{?asan:
257 %ifarch %asan_arch
258 %package asan
259 Summary:     glibc with ASan instrumentation
260 License:     LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
261 Requires:    glibc = %{version}
262 Requires:    rpm
263
264 %description asan
265 This package provides glibc with ASan instrumentation
266
267 %post asan
268 ln -s --force /%{_lib}/libc-%{version}-asan.so /%{_lib}/libc.so.6
269
270 %preun asan
271 ln -s --force /%{_lib}/libc-%{version}.so /%{_lib}/libc.so.6
272
273 %endif
274 }
275
276 %{?hwasan:
277 %ifarch %hwasan_arch
278 %package hwasan
279 Summary:     glibc with Hwasan instrumentation
280 License:     LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
281 Requires:    glibc = %{version}
282 Requires:    rpm
283
284 %description hwasan
285 This package provides glibc with Hwasan instrumentation
286
287 %post hwasan
288 ln -s --force /%{_lib}/libc-%{version}-hwasan.so /%{_lib}/libc.so.6
289
290 %preun hwasan
291 ln -s --force /%{_lib}/libc-%{version}.so /%{_lib}/libc.so.6
292
293 %endif
294 }
295
296 %{?glibc_dump_configure:
297 %package configure-dump
298 Summary:       GNU Glibc configure dump
299 License:       GPL-3.0+
300 Group:         Development/Languages
301 %description configure-dump
302 This package contains dump of configure variables of Glibc
303 }
304
305 %{?glibc_build_qemu_accel_ld_so:
306 %package accel-ldso
307 Summary:       ld.so file for qemu-accel
308 License:       GPL-3.0+
309 Group:         Development/Languages
310 %description accel-ldso
311 This package contains an ld.so configured to run from /emul directory
312 }
313
314 %prep
315 %setup -n glibc-%{version} -q
316 cp %{SOURCE1001} .
317
318 %build
319 %{?asan:%gcc_unforce_options}
320 %{?hwasan:%gcc_unforce_options}
321 if [ -x /bin/uname.bin ]; then
322         /bin/uname.bin -a
323 else
324         uname -a
325 fi
326 uptime || :
327 ulimit -a
328 nice
329 # We do not want configure to figure out the system its building one
330 # to support a common ground and thus set build and host to the
331 # target_cpu.
332 %ifarch %arm
333 %define target %{_target_cpu}-tizen-linux-gnueabi
334 %else
335 %define target %{_target_cpu}-tizen-linux
336 %endif
337 # Don't use as-needed, it breaks glibc assumptions
338 # Before enabling it, run the testsuite and verify that it
339 # passes completely
340 export LD_AS_NEEDED=0
341 # Adjust glibc version.h
342 echo "#define CONFHOST \"%{target}\"" >> version.h
343 echo "#define GITID \"%{git_id}\"" >> version.h
344 #
345 # Default CFLAGS and Compiler
346 #
347 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//" | sed -e 's/-flto\(=[^[:space:]]\+\)\? //')
348 BuildFlags="$BuildFlags -O2 -g -U_FORTIFY_SOURCE"
349 BuildFlags="$(echo $BuildFlags | sed -e 's#-ffortify=[0-9]*##')"
350 BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector-strong##')"
351 BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector##')"
352 BuildFlags="$(echo $BuildFlags | sed -e 's/-Wa,-mimplicit-it=thumb\(-interwork\)\?//g' | sed -e 's/-mthumb\(-interwork\)\?//g')"
353 # Turn off all -Wformat enable flags as there are glibc tests that explicitly
354 # append -Wno-format and with enabled Wformat options that produced warnings
355 # that turns into errors. Remove -Wformat=1|2 or -Wformat-..-arg
356 BuildFlags="$(echo $BuildFlags | sed -re 's/-Wformat((=[1-2])|((-\w+)+))?(\s|$)//g')"
357
358 %ifarch %arm
359 # Support DA build with armv8 cpu in 32bit mode: prevent Werror on sqrt function
360 (echo ${BuildFlags} | grep '\-march=armv8') && BuildFlags="${BuildFlags} -Wno-error=unused-variable"
361 %endif
362
363 BuildCC="%__cc"
364 BuildCCplus="%__cxx"
365 add_ons=",libidn"
366
367 BuildFlags="$BuildFlags -g"
368
369 %ifarch %arm aarch64
370 # Glibc must have both functions' implementations
371 BuildFlags="$BuildFlags -U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
372 %endif
373 %if %{disable_assert}
374         BuildFlags="$BuildFlags -DNDEBUG=1"
375 %endif
376 %ifarch %ix86
377         add_ons=$add_ons
378 %endif
379 %ifarch %arm aarch64
380         add_ons=$add_ons
381 %endif
382 %ifarch mipsel
383         # fails to build otherwise - need to recheck and fix
384         %define enable_stackguard_randomization 0
385 %endif
386
387 #
388 # Build glibc
389 #
390 %{!?glibc_keep_build_dir:
391   rm -rf "build"
392   mkdir "build"
393   pushd "build"
394  }
395
396 conf_cflags="$BuildFlags -funwind-tables -fPIC"
397 %{?asan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST"}
398 %{?hwasan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST -Wno-error=pragmas"}
399 profile="--disable-profile"
400 %{?build_profile:profile="--enable-profile"}
401 %{?glibc_dump_configure:patch_configure.pl ..}
402
403 function glibc_configure () {
404   local aux_options=${@:1}
405
406   CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
407   CC="$BuildCC" CXX="$BuildCCplus" \
408   ../configure \
409   --prefix=%{_prefix} \
410   --libexecdir=%{_libexecdir} --infodir=%{_infodir} \
411 %ifarch riscv64
412   --libdir=%{_libdir} \
413 %endif
414   --enable-add-ons=$add_ons \
415   $profile \
416   --enable-kernel=%{enablekernel} \
417   --enable-bind-now \
418   --disable-nscd \
419   --disable-experimental-malloc \
420   libc_cv_cc_pie_default=yes \
421 %ifarch riscv64
422   libc_cv_slibdir="/%{_lib}" \
423   libc_cv_complocaledir="%{_prefix}/lib/locale" \
424 %endif
425 %if %{enable_stackguard_randomization}
426   --enable-stackguard-randomization \
427 %endif
428   --build=%{target} --host=%{target} \
429 %ifnarch %{multiarcharches}
430   --disable-multi-arch \
431 %endif
432 %ifarch %{ix86} x86_64
433   --disable-mathvec \
434 %endif
435 %if 0%{?enable_static_pie}
436   --enable-static-pie \
437 %endif
438   ${aux_options}
439
440 }
441
442 %{!?glibc_skip_configure:
443   glibc_configure
444 }
445
446 %{!?glibc_skip_make:
447   make %{?_smp_mflags}
448 %{?glibc_dump_configure:
449     dump_configure.pl .. . \
450     --project glibc \
451     --project-version %{version} \
452     --out_db glibc-%{version}-%{release}-%_project-%_repository.db
453  }
454
455 #
456 # Build glibc_post_upgrade binary
457 #
458 $BuildCC \
459     -static %{optflags} -Os \
460     $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glibc_post_upgrade \
461     -L. -Bcsu \
462     '-DREMOVE_TLS_DIRS' '-DREMOVE_PPC_OPTIMIZE_POWER5' \
463     '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'
464
465 %{!?glibc_keep_build_dir:
466   popd
467  }
468
469 # Prepare directory for qemu-accel ld.so
470 %{?glibc_build_qemu_accel_ld_so:
471   mkdir "qemu-accel-ldso"
472   pushd "qemu-accel-ldso"
473
474   echo -e "# Begin configparms\nslibdir=%{emul_path}%{_libdir}\nsysconfdir=%{emul_path}%{_sysconfdir}\n# End configparms" > configparms
475   glibc_configure --sysconfdir=%{emul_path}%{_sysconfdir} libc_cv_slibdir=%{emul_path}%{_libdir} libc_cv_sysconfdir=%{emul_path}%{_sysconfdir}
476
477   make %{?_smp_mflags}
478   popd
479 }
480
481 #
482 # Build html documentation
483 #
484 %if %{build_html}
485 make %{?_smp_mflags} -C "build" html
486 %endif
487
488 #
489 # Build ASan version of glibc
490 #
491 %{?asan:
492 %ifarch %{asan_arch}
493 configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --disable-mathvec"
494 configure_flags="$configure_flags --disable-sanity-checks"
495
496 HERE=%{_builddir}/%{name}-%{version}
497 J=${J:-32}
498 GLIBC=$HERE
499 ASAN_BUILD=$HERE/asan-build
500 unset CXXFLAGS
501 unset CFLAGS
502 unset LDFLAGS
503 %ifarch %{arm} aarch64
504 # Glibc must have both functions' implementations
505 CPPFLAGS="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
506 %endif
507 CPPFLAGS+=" -DASAN_INIT_FIRST"
508
509 # chmod +x $HERE/asan-glibc-gcc-wrapper.py
510 # build static wrapper, because we don't want asan to intercept allocators
511 g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static
512
513 rm -rf $ASAN_BUILD
514 mkdir -p $ASAN_BUILD
515 pushd $ASAN_BUILD
516 # Legacy python wrapper call was:
517 #   CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
518 CPPFLAGS=$CPPFLAGS \
519         CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
520
521 # Quick build - builds only libraries, but does not create symlinks.
522 make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
523 # make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
524 popd
525 %endif
526 }
527
528 %{?hwasan:
529 %ifarch %{hwasan_arch}
530 configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --disable-mathvec"
531 configure_flags="$configure_flags --disable-sanity-checks"
532
533 HERE=%{_builddir}/%{name}-%{version}
534 J=${J:-32}
535 GLIBC=$HERE
536 ASAN_BUILD=$HERE/hwasan-build
537 unset CXXFLAGS
538 unset CFLAGS
539 unset LDFLAGS
540 %ifarch %arm aarch64
541 # Glibc must have both functions' implementations
542 CPPFLAGS="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
543 %endif
544 CPPFLAGS+=" -DASAN_INIT_FIRST"
545
546 # chmod +x $HERE/asan-glibc-gcc-wrapper.py
547 # build static wrapper, because we don't want asan to intercept allocators
548 g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static -DHWASAN_BUILD
549
550 rm -rf $ASAN_BUILD
551 mkdir -p $ASAN_BUILD
552 pushd $ASAN_BUILD
553 # Legacy python wrapper call was:
554 #   CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
555 CPPFLAGS=$CPPFLAGS \
556         CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
557
558 # Quick build - builds only libraries, but does not create symlinks.
559 make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
560 # make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
561 popd
562 %endif
563 }
564
565 %{?glibc_exit_on_make_finish:
566   echo "Glibc build is complete and environment is ready, exiting"
567   exit 1
568  }
569 }
570
571 #
572 # Build testsuite
573 #
574 # #check sections could be redefined/disabled, so keep this inside #build
575
576 %{?glibc_run_tests:
577   export LD_AS_NEEDED=0
578   (make %{?_smp_mflags} -k -C build check || true) 2>&1 | tee check.log
579  }
580
581 #######################################################################
582 ###
583 ### CHECK
584 ###
585 #######################################################################
586
587 %check
588 # The testsuite will fail if asneeded is used
589 export LD_AS_NEEDED=0
590 # This has to pass on all platforms!
591 # Exceptions:
592 # None!
593 make %{?_smp_mflags} -k -C build check-abi
594
595 #######################################################################
596 ###
597 ### INSTALL
598 ###
599 #######################################################################
600
601 %install
602 # We don't want to strip the .symtab from our libraries in find-debuginfo.sh,
603 # certainly not from libpthread.so.* because it is used by libthread_db to find
604 # some non-exported symbols in order to detect if threading support
605 # should be enabled.  These symbols are _not_ exported, and we can't easily
606 # export them retroactively without changing the ABI.  So we have to
607 # continue to "export" them via .symtab, instead of .dynsym :-(
608 # But we also want to keep .symtab and .strtab of other libraries since some
609 # debugging tools currently require these sections directly inside the main
610 # files - specifically valgrind and PurifyPlus.
611 export STRIP_KEEP_SYMTAB=*.so*
612
613 # Make sure we will create the gconv-modules.cache
614 mkdir -p %{buildroot}%{_libdir}/gconv
615 touch %{buildroot}%{_libdir}/gconv/gconv-modules.cache
616
617 # Install base glibc
618 make %{?_smp_mflags} install_root=%{buildroot} install -C build
619
620 %{?glibc_dump_configure:
621   install -D -m 0644 build/glibc-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/glibc-%{version}-%{release}-%_project-%_repository.db
622 }
623
624 # Install locales
625 %if %{build_locales}
626 # XXX Do not install locales in parallel!
627 pushd build
628 # localedef creates hardlinks to other locales if possible
629 # this will not work if we generate them in parallel.
630 # thus we need to run fdupes on  /usr/lib/locale/
631 # Still, on my system this is a speed advantage:
632 # non-parallel build for install-locales: 9:34mins
633 # parallel build with fdupes: 7:08mins
634 make %{?_smp_mflags} install_root=%{buildroot} localedata/install-locales
635 %fdupes %{buildroot}/usr/lib/locale
636 popd
637 %endif
638
639 # Create file list for glibc-locale package
640 %{find_lang} libc
641
642 # Prepare obsolete/, used only on some architectures:
643 export RPM_BUILD_ROOT
644 %ifarch %ix86
645 mkdir -p %{buildroot}/%{_lib}/obsolete
646 %endif
647
648 # Prepare symlinks to versioned libraries
649 ln -sf libpthread.so.0 %{buildroot}%{_libdir}/libpthread.so
650 ln -sf libutil.so.1 %{buildroot}%{_libdir}/libutil.so
651 ln -sf librt.so.1 %{buildroot}%{_libdir}/librt.so
652 ln -sf libdl.so.2 %{buildroot}%{_libdir}/libdl.so
653 ln -sf libm.so.6 %{buildroot}%{_libdir}/libm.so
654 ln -sf libresolv.so.2 %{buildroot}%{_libdir}/libresolv.so
655
656 # Miscelanna:
657
658 install -m 0700 build/glibc_post_upgrade %{buildroot}%{_sbindir}
659
660 install -m 644 %{SOURCE7} %{buildroot}/etc
661 install -m 644 %{SOURCE5} %{buildroot}/etc
662 install -m 644 posix/gai.conf %{buildroot}/etc
663
664 mkdir -p %{buildroot}/etc/default
665
666 %if %{build_html}
667 mkdir -p %{buildroot}%{_datadir}/doc/glibc
668 cp -p build/manual/libc/*.html %{buildroot}%{_datadir}/doc/glibc
669 %endif
670
671 #
672 # Create ld.so.conf
673 #
674 cat > %{buildroot}/etc/ld.so.conf <<EOF
675 %if "%{_lib}" == "lib64"
676 /usr/local/lib64
677 %endif
678 /usr/local/lib
679 include /etc/ld.so.conf.d/*.conf
680 # /lib64, /lib, /usr/lib64 and /usr/lib gets added
681 # automatically by ldconfig after parsing this file.
682 # So, they do not need to be listed.
683 EOF
684 # Add ldconfig cache directory for directory ownership
685 mkdir -p %{buildroot}/var/cache/ldconfig
686 # Empty the ld.so.cache:
687 rm -f %{buildroot}/etc/ld.so.cache
688 touch %{buildroot}/etc/ld.so.cache
689
690 # Don't look at ldd! We don't wish a /bin/sh requires
691 chmod 644 %{buildroot}%{_bindir}/ldd
692
693 # Remove timezone data, now coming in standalone package:
694 for i in sbin/sln usr/bin/tzselect usr/sbin/zic usr/bin/zdump etc/localtime; do
695         rm -f %{buildroot}/$i
696 done
697 rm -rf %{buildroot}%{_datadir}/zoneinfo
698
699 %ifarch armv7hl
700 # Provide compatibility link
701 ln -s ld-linux-armhf.so.3 %{buildroot}/lib/ld-linux.so.3
702 %endif
703
704 %ifarch %ix86
705 # Provide compatibility link
706 ln -s ld-linux.so.2 %{buildroot}/lib/ld-linux.so
707 %endif
708
709 %ifarch riscv64
710 # Provide compatibility link
711 mkdir -p %{buildroot}/lib/
712 ln -s %{_libdir}/ld-linux-riscv64-lp64d.so.1 %{buildroot}/lib/ld-linux-riscv64-lp64d.so.1
713 crts="Mcrt1.o Scrt1.o crt1.o crti.o crtn.o gcrt1.o"
714 for crtfile in ${crts}; do
715     ln -sf %{_libdir}/${crtfile} %{buildroot}/lib/${crtfile}
716 done
717 %endif
718
719 # Move getconf to %{_libexecdir}/getconf/ to avoid cross device link
720 mv %{buildroot}%{_bindir}/getconf %{buildroot}%{_libexecdir}/getconf/getconf
721 ln -s %{_libexecdir}/getconf/getconf %{buildroot}%{_bindir}/getconf
722
723 #######################################################################
724 ###
725 ### ...
726 ###
727 #######################################################################
728
729 %{?asan:
730 %ifarch %{asan_arch}
731 HERE=%{_builddir}/%{name}-%{version}
732 GLIBC=$HERE
733 ASAN_BUILD=$HERE/asan-build
734 cp $ASAN_BUILD/libc.so %{buildroot}/%{_lib}/libc-%{version}-asan.so
735 %endif
736 }
737
738 %{?hwasan:
739 %ifarch %{hwasan_arch}
740 HERE=%{_builddir}/%{name}-%{version}
741 GLIBC=$HERE
742 ASAN_BUILD=$HERE/hwasan-build
743 cp $ASAN_BUILD/libc.so %{buildroot}/%{_lib}/libc-%{version}-hwasan.so
744 %endif
745 }
746
747 %{?glibc_run_tests:
748   mkdir testresults
749   find build \
750        \( -name "*tests.sum" -o -name "*.out" -o -name "*.test-result" \) \
751        -exec cp --parents {} testresults/ \;
752   find testresults/ -type f -exec chmod 644 {} \;
753   cp check.log testresults/
754 }
755
756 %{?glibc_build_qemu_accel_ld_so:
757   pushd qemu-accel-ldso
758   make -C ../elf objdir=`pwd` install_root=%{buildroot} ldso_install
759   popd
760 }
761
762 %post -p %{_sbindir}/glibc_post_upgrade
763
764 %postun -p /sbin/ldconfig
765
766 %post locale
767 for l in /usr/share/locale/locale.alias %{_libdir}/gconv/gconv-modules; do
768         [ -d "$l.d" ] || continue
769         echo "###X# The following is autogenerated from extra files in the .d directory:" >>"$l"
770         cat "$l.d"/* >>"$l"
771 done
772 /usr/sbin/iconvconfig
773
774 %post info
775 %install_info --info-dir=%{_infodir} %{_infodir}/libc.info.gz
776
777 %postun info
778 %install_info_delete --info-dir=%{_infodir} %{_infodir}/libc.info.gz
779
780 %post devel
781 # TODO: REMOVE ME AFTER ISSUE IS IDENTIFIED
782 find %{_libdir}/gcc -name 'statx.h' -exec sed -e 's/__glibc_has_include/__has_include/' -i {} \;
783
784 %post devel-static
785 # TODO: REMOVE ME AFTER ISSUE IS IDENTIFIED
786 find %{_libdir}/gcc -name 'statx.h' -exec sed -e 's/__glibc_has_include/__has_include/' -i {} \;
787
788 %files
789 %manifest %{name}.manifest
790 # glibc
791 %defattr(-,root,root)
792 %license LICENSES COPYING COPYING.LIB
793 %config(noreplace) /etc/bindresvport.blacklist
794 %config /etc/ld.so.conf
795 %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache
796 %config(noreplace) /etc/rpc
797 %verify(not md5 size mtime) %config(noreplace) /etc/nsswitch.conf
798 %verify(not md5 size mtime) %config(noreplace) /etc/gai.conf
799
800 # Each architecture has a different name for the dynamic linker:
801 %ifarch %arm
802 %ifarch armv7hl
803 /lib/ld-linux-armhf.so.3
804 %endif
805 # Keep as compatibility link for armv7lh
806 /lib/ld-linux.so.3
807 %endif
808 %ifarch x86_64
809 /lib64/ld-linux-x86-64.so.2
810 %endif
811 %ifarch %ix86 %sparc
812 /lib/ld-linux.so.2
813 %endif
814 %ifarch %ix86
815 /lib/ld-linux.so
816 %endif
817 %ifarch aarch64
818 /lib/ld-linux-aarch64.so.1
819 %endif
820 %ifarch riscv64
821 /lib64/ld-linux-riscv64-lp64d.so.1
822 /lib/ld-linux-riscv64-lp64d.so.1
823 /lib/*.o
824 %endif
825
826 /%{_lib}/libanl.so.1
827 /%{_lib}/libc.so*
828 /%{_lib}/libcrypt.so*
829 /%{_lib}/libdl.so*
830 /%{_lib}/libm.so*
831 /%{_lib}/libnsl.so.1
832 /%{_lib}/libnss_compat.so.2
833 /%{_lib}/libnss_db.so.2
834 /%{_lib}/libnss_dns.so.2
835 /%{_lib}/libnss_files.so.2
836 /%{_lib}/libnss_optfiles.so.2
837 /%{_lib}/libnss_hesiod.so.2
838 /%{_lib}/libpthread.so*
839 /%{_lib}/libthread_db.so.1
840 /%{_lib}/libresolv.so.2
841 /%{_lib}/librt.so*
842 /%{_lib}/libutil.so*
843 /%{_lib}/libc_malloc_debug.so.0
844 %define optimized_libs() \
845         %dir %attr(0755,root,root) /%{_lib}/%1\
846         /%{_lib}/%1/libc.so.6*\
847         /%{_lib}/%1/libm.so.6*\
848         /%{_lib}/%1/libpthread.so*\
849         /%{_lib}/%1/librt.so.1\
850         /%{_lib}/%1/libthread_db.so.1
851
852 %dir %attr(0700,root,root) /var/cache/ldconfig
853 /sbin/ldconfig
854 %{_bindir}/ld.so
855 %{_bindir}/gencat
856 %{_bindir}/getconf
857 %{_bindir}/getent
858 %{_bindir}/iconv
859 %attr(755,root,root) %{_bindir}/ldd
860 %{_bindir}/locale
861 %{_bindir}/localedef
862 %dir %attr(0755,root,root) %{_libexecdir}/getconf
863 %{_libexecdir}/getconf/*
864 %{_sbindir}/glibc_post_upgrade
865 %{_sbindir}/iconvconfig
866 /%{_lib}/libBrokenLocale.so.1
867
868 %ifarch %ix86
869
870 %files obsolete
871 %manifest %{name}.manifest
872 %license COPYING.LIB
873 %defattr (755,root,root,755)
874 %dir /%{_lib}/obsolete/
875         # %dir /{_lib}/obsolete/noversion
876         # /{_lib}/obsolete/noversion/libNoVersion.so.1
877 %endif
878
879 %files locale -f libc.lang
880 %manifest %{name}.manifest
881 %license COPYING COPYING.LIB
882 %defattr(-,root,root)
883 %{_datadir}/locale/locale.alias
884 %if %{build_locales}
885 /usr/lib/locale/*
886 %endif
887 %{_libdir}/gconv
888
889 %{?asan:
890 %ifarch %{asan_arch}
891 %files asan
892 %manifest %{name}.manifest
893 /%{_lib}/libc-%{version}-asan.so
894 %endif
895 }
896
897 %{?hwasan:
898 %ifarch %{hwasan_arch}
899 %files hwasan
900 %manifest %{name}.manifest
901 /%{_lib}/libc-%{version}-hwasan.so
902 %endif
903 }
904
905 %files devel
906 %manifest %{name}.manifest
907 %defattr(-,root,root)
908 %license COPYING COPYING.LIB
909 %doc NEWS README
910 %{_includedir}/*
911 %{_libdir}/*.o
912 %{_libdir}/*.so
913 # These static libraries are needed even for shared builds
914 %{_libdir}/libc_nonshared.a
915 %{_libdir}/libg.a
916 %ifarch ppc ppc64 s390 s390x sparc sparcv8 sparcv9 sparcv9v
917 # This is not built on sparc64.
918         %{_libdir}/libnldbl_nonshared.a
919 %endif
920 %{_libdir}/libmcheck.a
921
922 %files devel-static
923 %manifest %{name}.manifest
924 %defattr(-,root,root)
925 %{_libdir}/libBrokenLocale.a
926 %{_libdir}/libanl.a
927 %{_libdir}/libc.a
928 %{_libdir}/libcrypt.a
929 %{_libdir}/libdl.a
930 %{_libdir}/libm.a
931 %{_libdir}/libpthread.a
932 %{_libdir}/libresolv.a
933 %{_libdir}/librt.a
934 %{_libdir}/libutil.a
935
936 %files info
937 %manifest %{name}.manifest
938 %defattr(-,root,root)
939 %doc %{_infodir}/libc.info.gz
940 %doc %{_infodir}/libc.info-?.gz
941 %doc %{_infodir}/libc.info-??.gz
942
943 %if %{build_html}
944 %files html
945 %manifest %{name}.manifest
946 %defattr(-,root,root)
947 %doc %{_prefix}/share/doc/glibc
948 %endif
949
950 %files i18ndata
951 %manifest %{name}.manifest
952 %defattr(-,root,root)
953 %{_prefix}/share/i18n
954
955 %if %{build_profile}
956 %files profile
957 %manifest %{name}.manifest
958 %license COPYING COPYING.LIB
959 %defattr(-,root,root)
960 %{_libdir}/libc_p.a
961 %{_libdir}/libBrokenLocale_p.a
962 %{_libdir}/libanl_p.a
963 %{_libdir}/libm_p.a
964 %{_libdir}/libcrypt_p.a
965 %{_libdir}/libpthread_p.a
966 %{_libdir}/libresolv_p.a
967 %{_libdir}/librt_p.a
968 %{_libdir}/libutil_p.a
969 %{_libdir}/libdl_p.a
970 %endif
971
972 %files devel-utils
973 %manifest %{name}.manifest
974 %defattr(-,root,root)
975 /%{_lib}/libmemusage.so
976 /%{_lib}/libpcprofile.so
977 /%{_libdir}/libBrokenLocale.so
978 /%{_lib}/libthread_db.so.1
979 /%{_libdir}/libthread_db.so
980 %dir /%{_libdir}/audit
981 /%{_libdir}/audit/sotruss-lib.so
982 # These need gd-devel for building
983 # %%{_bindir}/memusage
984 # %%{_bindir}/memusagestat
985 %{_bindir}/mtrace
986 %{_bindir}/pcprofiledump
987 %{_bindir}/sotruss
988 %{_bindir}/xtrace
989 %{_bindir}/pldd
990 %{_bindir}/sprof
991
992 %files extra
993 %manifest %{name}.manifest
994 %license COPYING.LIB
995 %defattr(-,root,root)
996 %{_bindir}/makedb
997 /var/db/Makefile
998
999 %{?glibc_run_tests:
1000 %files testresults
1001 %defattr(-,root,root)
1002 %doc testresults/check.log
1003 %doc testresults/*
1004 }
1005
1006 %{?glibc_dump_configure:
1007 %files configure-dump
1008 %manifest glibc.manifest
1009 %{_datadir}/glibc-%{version}-%{release}-%_project-%_repository.db
1010 }
1011
1012 %{?glibc_build_qemu_accel_ld_so:
1013 %files accel-ldso
1014 %manifest glibc.manifest
1015 %{emul_path}
1016 }
1017
1018 %docs_package