OCaml 4.14.0 rebuild
[arch-packages.git] / glibc / trunk / PKGBUILD
blob1ca8a701aca09f46fef239fc54211b02f8144df6
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.36
12 _commit=c804cd1c00adde061ca51711f63068c103e94eef
13 pkgrel=1
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=(debug 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         disable-clone3.diff
26 validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
27               BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
28 b2sums=('SKIP'
29         '46d533d25c7a2ce4ae75d452eee7ebb8e3ce4d191af9be3daa43718b78cb81d33cfd8046a117a15d87de9f5e940448c66005b0490515bf731c9e4691c53908d6'
30         '04fbb3b0b28705f41ccc6c15ed5532faf0105370f22133a2b49867e790df0491f5a1255220ff6ebab91a462f088d0cf299491b3eb8ea53534cb8638a213e46e3'
31         '7c265e6d36a5c0dff127093580827d15519b6c7205c2e1300e82f0fb5b9dd00b6accb40c56581f18179c4fbbc95bd2bf1b900ace867a83accde0969f7b609f8a'
32         'a6a5e2f2a627cc0d13d11a82458cfd0aa75ec1c5a3c7647e5d5a3bb1d4c0770887a3909bfda1236803d5bc9801bfd6251e13483e9adf797e4725332cd0d91a0e'
33         '214e995e84b342fe7b2a7704ce011b7c7fc74c2971f98eeb3b4e677b99c860addc0a7d91b8dc0f0b8be7537782ee331999e02ba48f4ccc1c331b60f27d715678'
34         'edef5f724f68ea95c6b0127bd13a10245f548afc381b2d0a6d1d06ee9f87b7dd89c6becd35d5ae722bf838594eb870a747f67f07f46e7d63f8c8d1a43cce4a52')
36 prepare() {
37   mkdir -p glibc-build lib32-glibc-build
39   [[ -d glibc-$pkgver ]] && ln -s glibc-$pkgver glibc
40   cd glibc
42   # Disable clone3 syscall for now
43   # Can be removed when eletron{9,11,12} and discord are removed or patched:
44   # https://github.com/electron/electron/commit/993ecb5bdd5c57024c8718ca6203a8f924d6d574
45   # Patch src: https://patchwork.ozlabs.org/project/glibc/patch/87eebkf8ph.fsf@oldenburg.str.redhat.com/
46   patch -Np1 -i "${srcdir}"/disable-clone3.diff
49 build() {
50   local _configure_flags=(
51       --prefix=/usr
52       --with-headers=/usr/include
53       --with-bugurl=https://bugs.archlinux.org/
54       --enable-bind-now
55       --enable-cet
56       --enable-kernel=4.4
57       --enable-multi-arch
58       --enable-stack-protector=strong
59       --enable-systemtap
60       --disable-profile
61       --disable-crypt
62       --disable-werror
63   )
65   cd "$srcdir/glibc-build"
67   echo "slibdir=/usr/lib" >> configparms
68   echo "rtlddir=/usr/lib" >> configparms
69   echo "sbindir=/usr/bin" >> configparms
70   echo "rootsbindir=/usr/bin" >> configparms
72   # Credits @allanmcrae
73   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/glibc/PKGBUILD
74   # remove fortify for building libraries
75   CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
77   "$srcdir/glibc/configure" \
78       --libdir=/usr/lib \
79       --libexecdir=/usr/lib \
80       "${_configure_flags[@]}"
82   # build libraries with fortify disabled
83   echo "build-programs=no" >> configparms
84   make -O
86   # re-enable fortify for programs
87   sed -i "/build-programs=/s#no#yes#" configparms
88   echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
89   make -O
91   # build info pages manually for reproducibility
92   make info
94   cd "$srcdir/lib32-glibc-build"
95   export CC="gcc -m32 -mstackrealign"
96   export CXX="g++ -m32 -mstackrealign"
98   echo "slibdir=/usr/lib32" >> configparms
99   echo "rtlddir=/usr/lib32" >> configparms
100   echo "sbindir=/usr/bin" >> configparms
101   echo "rootsbindir=/usr/bin" >> configparms
103   "$srcdir/glibc/configure" \
104       --host=i686-pc-linux-gnu \
105       --libdir=/usr/lib32 \
106       --libexecdir=/usr/lib32 \
107       "${_configure_flags[@]}"
109   # build libraries with fortify disabled
110   echo "build-programs=no" >> configparms
111   make -O
113   # re-enable fortify for programs
114   sed -i "/build-programs=/s#no#yes#" configparms
115   echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
116   make -O
118   # pregenerate C.UTF-8 locale until it is built into glibc
119   # (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8, FS#74864)
120   locale/localedef -c -f ../glibc/localedata/charmaps/UTF-8 -i ../glibc/localedata/locales/C ../C.UTF-8/
123 # Credits for skip_test() and check() @allanmcrae
124 # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/glibc/PKGBUILD
125 skip_test() {
126   test=$1
127   file=$2
128   sed -i "s/\b$test\b//" $srcdir/glibc/$file
131 check() {
132   cd glibc-build
134   # adjust/remove buildflags that cause false-positive testsuite failures
135   sed -i '/FORTIFY/d' configparms                                     # failure to build testsuite
136   sed -i 's/-Werror=format-security/-Wformat-security/' config.make   # failure to build testsuite
137   sed -i '/CFLAGS/s/-fno-plt//' config.make                           # 16 failures
138   sed -i '/CFLAGS/s/-fexceptions//' config.make                       # 1 failure
139   LDFLAGS=${LDFLAGS/,-z,now/}                                         # 10 failures
141   # The following tests fail due to restrictions in the Arch build system
142   # The correct fix is to add the following to the systemd-nspawn call:
143   # --system-call-filter="@clock @memlock @pkey"
144   skip_test test-errno-linux        sysdeps/unix/sysv/linux/Makefile
145   skip_test tst-mlock2              sysdeps/unix/sysv/linux/Makefile
146   skip_test tst-ntp_gettime         sysdeps/unix/sysv/linux/Makefile
147   skip_test tst-ntp_gettimex        sysdeps/unix/sysv/linux/Makefile
148   skip_test tst-pkey                sysdeps/unix/sysv/linux/Makefile
149   skip_test tst-process_mrelease    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   # install C.UTF-8 so that it is always available
190   install -dm755 "$pkgdir/usr/lib/locale"
191   cp -r "$srcdir/C.UTF-8" -t "$pkgdir/usr/lib/locale"
192   sed -i '/#C\.UTF-8 /d' "$pkgdir/etc/locale.gen"
194   # Provide tracing probes to libstdc++ for exceptions, possibly for other
195   # libraries too. Useful for gdb's catch command.
196   install -Dm644 "$srcdir/sdt.h" "$pkgdir/usr/include/sys/sdt.h"
197   install -Dm644 "$srcdir/sdt-config.h" "$pkgdir/usr/include/sys/sdt-config.h"
200 package_lib32-glibc() {
201   pkgdesc='GNU C Library (32-bit)'
202   depends=("glibc=$pkgver")
203   options+=('!emptydirs')
205   cd lib32-glibc-build
207   make install_root="$pkgdir" install
208   rm -rf "$pkgdir"/{etc,sbin,usr/{bin,sbin,share},var}
210   # We need to keep 32 bit specific header files
211   find "$pkgdir/usr/include" -type f -not -name '*-32.h' -delete
213   # Dynamic linker
214   install -d "$pkgdir/usr/lib"
215   ln -s ../lib32/ld-linux.so.2 "$pkgdir/usr/lib/"
217   # Add lib32 paths to the default library search path
218   install -Dm644 "$srcdir/lib32-glibc.conf" "$pkgdir/etc/ld.so.conf.d/lib32-glibc.conf"
220   # Symlink /usr/lib32/locale to /usr/lib/locale
221   ln -s ../lib/locale "$pkgdir/usr/lib32/locale"