archrelease: copy trunk to extra-x86_64
[arch-packages.git] / glibc / trunk / PKGBUILD
blob20b19b443d8806ab8b2fc6b435294851cd40237c
1 # Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
2 # Maintainer: Frederik Schwan <freswa at archlinux dot org>
3 # Contributor: BartÅ‚omiej Piotrowski <bpiotrowski@archlinux.org>
4 # Contributor: Allan McRae <allan@archlinux.org>
6 # toolchain build order: linux-api-headers->glibc->binutils->gcc->glibc->binutils->gcc
7 # NOTE: valgrind requires rebuilt with each major glibc version
9 pkgbase=glibc
10 pkgname=(glibc lib32-glibc)
11 pkgver=2.37
12 _commit=7c32cb7dd88cf100b0b412163896e30aa2ee671a
13 pkgrel=3
14 arch=(x86_64)
15 url='https://www.gnu.org/software/libc'
16 license=(GPL LGPL)
17 makedepends=(git gd lib32-gcc-libs python)
18 options=(staticlibs !lto)
19 source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
20         locale.gen.txt
21         locale-gen
22         lib32-glibc.conf
23         sdt.h sdt-config.h
24         reenable_DT_HASH.patch
26 validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
27               BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
28 b2sums=('SKIP'
29         'c859bf2dfd361754c9e3bbd89f10de31f8e81fd95dc67b77d10cb44e23834b096ba3caa65fbc1bd655a8696c6450dfd5a096c476b3abf5c7e125123f97ae1a72'
30         '04fbb3b0b28705f41ccc6c15ed5532faf0105370f22133a2b49867e790df0491f5a1255220ff6ebab91a462f088d0cf299491b3eb8ea53534cb8638a213e46e3'
31         '7c265e6d36a5c0dff127093580827d15519b6c7205c2e1300e82f0fb5b9dd00b6accb40c56581f18179c4fbbc95bd2bf1b900ace867a83accde0969f7b609f8a'
32         'a6a5e2f2a627cc0d13d11a82458cfd0aa75ec1c5a3c7647e5d5a3bb1d4c0770887a3909bfda1236803d5bc9801bfd6251e13483e9adf797e4725332cd0d91a0e'
33         '214e995e84b342fe7b2a7704ce011b7c7fc74c2971f98eeb3b4e677b99c860addc0a7d91b8dc0f0b8be7537782ee331999e02ba48f4ccc1c331b60f27d715678'
34         '5fdd133c367af2f5454ea1eea7907de12166fb95eb59dbe33eae16aa9e26209b6585972bc1c80e36a0af4bfb04296acaf940ee78cd624cdcbab9669dff46c051')
36 prepare() {
37   mkdir -p glibc-build lib32-glibc-build
39   [[ -d glibc-$pkgver ]] && ln -s glibc-$pkgver glibc
40   cd glibc
42   # Re-enable `--hash-style=both` for building shared objects due to issues with EPIC's EAC
43   # which relies on DT_HASH to be present in these libs.
44   # reconsider 2023-01
45   patch -Np1 -i "${srcdir}"/reenable_DT_HASH.patch
48 build() {
49   local _configure_flags=(
50       --prefix=/usr
51       --with-headers=/usr/include
52       --with-bugurl=https://bugs.archlinux.org/
53       --enable-bind-now
54       --enable-cet
55       --enable-kernel=4.4
56       --enable-multi-arch
57       --enable-stack-protector=strong
58       --enable-systemtap
59       --disable-crypt
60       --disable-profile
61       --disable-werror
62   )
64   cd "${srcdir}"/glibc-build
66   echo "slibdir=/usr/lib" >> configparms
67   echo "rtlddir=/usr/lib" >> configparms
68   echo "sbindir=/usr/bin" >> configparms
69   echo "rootsbindir=/usr/bin" >> configparms
71   # Credits @allanmcrae
72   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/glibc/PKGBUILD
73   # remove fortify for building libraries
74   CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
76   "${srcdir}"/glibc/configure \
77       --libdir=/usr/lib \
78       --libexecdir=/usr/lib \
79       "${_configure_flags[@]}"
81   # build libraries with fortify disabled
82   echo "build-programs=no" >> configparms
83   make -O
85   # re-enable fortify for programs
86   sed -i "/build-programs=/s#no#yes#" configparms
87   echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
88   make -O
90   # build info pages manually for reproducibility
91   make info
93   cd "${srcdir}"/lib32-glibc-build
94   export CC="gcc -m32 -mstackrealign"
95   export CXX="g++ -m32 -mstackrealign"
97   echo "slibdir=/usr/lib32" >> configparms
98   echo "rtlddir=/usr/lib32" >> configparms
99   echo "sbindir=/usr/bin" >> configparms
100   echo "rootsbindir=/usr/bin" >> configparms
102   "${srcdir}"/glibc/configure \
103       --host=i686-pc-linux-gnu \
104       --libdir=/usr/lib32 \
105       --libexecdir=/usr/lib32 \
106       "${_configure_flags[@]}"
108   # build libraries with fortify disabled
109   echo "build-programs=no" >> configparms
110   make -O
112   # re-enable fortify for programs
113   sed -i "/build-programs=/s#no#yes#" configparms
114   echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
115   make -O
117   # pregenerate C.UTF-8 locale until it is built into glibc
118   # (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8, FS#74864)-
119   elf/ld.so --library-path "$PWD" locale/localedef -c -f ../glibc/localedata/charmaps/UTF-8 -i ../glibc/localedata/locales/C ../C.UTF-8/
122 # Credits for skip_test() and check() @allanmcrae
123 # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/glibc/PKGBUILD
124 skip_test() {
125   test=${1}
126   file=${2}
127   sed -i "s/\b${test}\b//" "${srcdir}"/glibc/${file}
130 check() {
131   cd glibc-build
133   # adjust/remove buildflags that cause false-positive testsuite failures
134   sed -i '/FORTIFY/d' configparms                                     # failure to build testsuite
135   sed -i 's/-Werror=format-security/-Wformat-security/' config.make   # failure to build testsuite
136   sed -i '/CFLAGS/s/-fno-plt//' config.make                           # 16 failures
137   sed -i '/CFLAGS/s/-fexceptions//' config.make                       # 1 failure
138   LDFLAGS=${LDFLAGS/,-z,now/}                                         # 10 failures
140   # The following tests fail due to restrictions in the Arch build system
141   # The correct fix is to add the following to the systemd-nspawn call:
142   # --system-call-filter="@clock @memlock @pkey"
143   skip_test test-errno-linux        sysdeps/unix/sysv/linux/Makefile
144   skip_test tst-mlock2              sysdeps/unix/sysv/linux/Makefile
145   skip_test tst-ntp_gettime         sysdeps/unix/sysv/linux/Makefile
146   skip_test tst-ntp_gettimex        sysdeps/unix/sysv/linux/Makefile
147   skip_test tst-pkey                sysdeps/unix/sysv/linux/Makefile
148   skip_test tst-process_mrelease    sysdeps/unix/sysv/linux/Makefile
149   skip_test tst-ttyname             sysdeps/unix/sysv/linux/Makefile
150   skip_test tst-adjtime             time/Makefile
151   skip_test tst-clock2              time/Makefile
153   make -O check
156 package_glibc() {
157   pkgdesc='GNU C Library'
158   depends=('linux-api-headers>=4.10' tzdata filesystem)
159   optdepends=('gd: for memusagestat'
160               'perl: for mtrace')
161   install=glibc.install
162   backup=(etc/gai.conf
163           etc/locale.gen
164           etc/nscd.conf)
166   make -C glibc-build install_root="${pkgdir}" install
167   rm -f "${pkgdir}"/etc/ld.so.cache
169   # Shipped in tzdata
170   rm -f "${pkgdir}"/usr/bin/{tzselect,zdump,zic}
172   cd glibc
174   install -dm755 "${pkgdir}"/usr/lib/{locale,systemd/system,tmpfiles.d}
175   install -m644 nscd/nscd.conf "${pkgdir}"/etc/nscd.conf
176   install -m644 nscd/nscd.service "${pkgdir}"/usr/lib/systemd/system
177   install -m644 nscd/nscd.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/nscd.conf
178   install -dm755 "${pkgdir}"/var/db/nscd
180   install -m644 posix/gai.conf "${pkgdir}"/etc/gai.conf
182   install -m755 "${srcdir}"/locale-gen "${pkgdir}"/usr/bin
184   # Create /etc/locale.gen
185   install -m644 "${srcdir}"/locale.gen.txt "${pkgdir}"/etc/locale.gen
186   sed -e '1,3d' -e 's|/| |g' -e 's|\\| |g' -e 's|^|#|g' \
187     "${srcdir}"/glibc/localedata/SUPPORTED >> "${pkgdir}"/etc/locale.gen
189   # Add SUPPORTED file to pkg
190   sed -e '1,3d' -e 's|/| |g' -e 's| \\||g' \
191     "${srcdir}"/glibc/localedata/SUPPORTED > "${pkgdir}"/usr/share/i18n/SUPPORTED
193   # install C.UTF-8 so that it is always available
194   install -dm755 "${pkgdir}"/usr/lib/locale
195   cp -r "${srcdir}"/C.UTF-8 -t "${pkgdir}"/usr/lib/locale
196   sed -i '/#C\.UTF-8 /d' "${pkgdir}"/etc/locale.gen
198   # Provide tracing probes to libstdc++ for exceptions, possibly for other
199   # libraries too. Useful for gdb's catch command.
200   install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/include/sys/sdt.h
201   install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/include/sys/sdt-config.h
204 package_lib32-glibc() {
205   pkgdesc='GNU C Library (32-bit)'
206   depends=("glibc=$pkgver")
207   options+=('!emptydirs')
209   cd lib32-glibc-build
211   make install_root="${pkgdir}" install
212   rm -rf "${pkgdir}"/{etc,sbin,usr/{bin,sbin,share},var}
214   # We need to keep 32 bit specific header files
215   find "${pkgdir}"/usr/include -type f -not -name '*-32.h' -delete
217   # Dynamic linker
218   install -d "${pkgdir}"/usr/lib
219   ln -s ../lib32/ld-linux.so.2 "${pkgdir}"/usr/lib/
221   # Add lib32 paths to the default library search path
222   install -Dm644 "${srcdir}"/lib32-glibc.conf "${pkgdir}"/etc/ld.so.conf.d/lib32-glibc.conf
224   # Symlink /usr/lib32/locale to /usr/lib/locale
225   ln -s ../lib/locale "${pkgdir}"/usr/lib32/locale