summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 287997910de0ee8b500773995fb2da3d6df92f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Maintainer: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Earnestly <zibeon@googlemail.com>

# All my PKGBUILDs are managed at https://github.com/eli-schwartz/pkgbuilds

pkgname=glibc-git
pkgver=2.28.r97.g99ea93ca31
pkgrel=1
pkgdesc='GNU C Library'
arch=('i686' 'x86_64')
url='https://www.gnu.org/software/libc/'
license=('GPL' 'LGPL')
groups=('base')
depends=('linux-api-headers' 'tzdata' 'filesystem')
optdepends=('gd: graph image generation with memusage')
makedepends=('git')
# XXX Arch Linux's valgrind package requires an exact version
provides=("glibc=${pkgver%%.r*}")
conflicts=('glibc')
backup=('etc/gai.conf' 'etc/nscd.conf')
options=('staticlibs')
install='glibc-git.install'
source=('git+https://sourceware.org/git/glibc.git'
        'locale-gen'
        '0001-Revert-elf-Correct-absolute-SHN_ABS-symbol-run-time-.patch'
        '0001-test-in-container-fix-Arch-Linux-build-programs-bug.patch'
        'bz20338.patch')
sha256sums=('SKIP'
            '05fbb88877cdddc99ef25e48304d6e5ac236660c20925d461cb4e90ebcb3b7de'
            '3b764c4e5658486d1f9e98a36043eb51705c4eebc9abe3f9edc5049dd5dcdc47'
            'a1f8f7dbe9cbaf81df21a7134b80beea7bedeecd37777c6d2f78f84d0f0548e0'
            '959d4f41edd004bddd9091c4d8c8c3aa07d79a04bfdb89d59f9f26fe5a74d32a')

pkgver() {
    cd glibc
    # wtf is tag "glibc-2.26.9000"
    git describe --exclude '*.*.9000' | sed 's/^glibc-//; s/-/.r/; s/-/./'
}

prepare() {
    mkdir -p build

    cd glibc
    # https://sourceware.org/bugzilla/show_bug.cgi?id=20338
    patch -p1 -i ../bz20338.patch
    # revert commit breaking proprietary electron apps for now; this is lld's fault
    # but it's too serious a regression to break software in the wild until users
    # have a solution. See https://bugs.archlinux.org/task/59550 and
    # https://github.com/electron/electron/issues/13972#issuecomment-411532741
    patch -p1 -i ../0001-Revert-elf-Correct-absolute-SHN_ABS-symbol-run-time-.patch

    # fix build error, turns out to be lack of testing for build-programs=no in configparms
    # make[2]: *** No rule to make target '/build/glibc-git/src/build/support/links-dso-program', needed by 'others'.  Stop.
    patch -p1 -i ../0001-test-in-container-fix-Arch-Linux-build-programs-bug.patch
}

build() {
    cd build

    if [[ ${CARCH} = "i686" ]]; then
        # Hack to fix NPTL issues with Xen, only required on 32bit platforms
        export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
    fi

    { printf 'slibdir=/usr/lib\n'
      printf 'rtlddir=/usr/lib\n'
      printf 'sbindir=/usr/bin\n'
      printf 'rootsbindir=/usr/bin\n'
    } >> configparms

    # remove fortify for building libraries
    CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}

    "$srcdir"/glibc/configure \
        --prefix=/usr \
        --libdir=/usr/lib \
        --libexecdir=/usr/lib \
        --with-headers=/usr/include \
        --with-bugurl=https://bugs.archlinux.org/ \
        --enable-add-ons \
        --enable-bind-now \
        --enable-cet \
        --enable-lock-elision \
        --enable-multi-arch \
        --enable-stack-protector=strong \
        --enable-stackguard-randomization \
        --disable-profile \
        --disable-werror

    printf 'build-programs=no\n' >> configparms
    make

    # Re-enable hardening for programs.
    sed -i '/build-programs=/s/no/yes/' configparms
    { printf 'CC += -D_FORTIFY_SOURCE=2\n'
      printf 'CXX += -D_FORTIFY_SOURCE=2\n'
    } >> configparms
    make

}

check() {
    cd build

    # Remove harding in preparation to run test-suite.
    sed -i '/FORTIFY/d' configparms
    make check || true
}

package() {
    make -C build install_root="$pkgdir" install

    install -dm0755 "$pkgdir"/usr/lib/locale
    install -dm0755 "$pkgdir"/etc/locales
    install -Dm0755 locale-gen "$pkgdir"/usr/bin/locale-gen
    install -Dm0644 glibc/posix/gai.conf "$pkgdir"/etc/gai.conf
    install -Dm0644 glibc/nscd/nscd.conf "$pkgdir"/etc/nscd.conf
    install -Dm0644 glibc/nscd/nscd.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/nscd.conf
    install -Dm0644 glibc/nscd/nscd.service "$pkgdir"/usr/lib/systemd/system/nscd.service

    # Only support UTF-8 charmaps.
    find "$pkgdir"/usr/share/i18n/charmaps ! -name UTF-8.gz -type f -delete

    # We generate these in the post-install with ldconfig -r .
    rm "$pkgdir"/etc/ld.so.cache

    # Shipped in tzdata
    rm -f "$pkgdir"/usr/bin/{tzselect,zdump,zic}

    # handle selectively stripping unless debug packages are requested
    if check_option 'debug' n; then
        options+=('!strip')
        # I use 2> /dev/null for all of these due to many false-positives as it
        # attempts to strip scripts or other unstrippable files.
        find "$pkgdir"/usr/bin -type f -executable -exec strip $STRIP_BINARIES {} + 2> /dev/null || true
        find "$pkgdir"/usr/lib -name '*.a' -type f -exec strip $STRIP_STATIC {} + 2> /dev/null || true

        # Do not strip these for gdb and valgrind functionality.
        find "$pkgdir"/usr/lib \
          -not -name 'ld-*.so' \
          -not -name 'libc-*.so' \
          -not -name 'libpthread-*.so' \
          -not -name 'libthread_db-*.so' \
          -name '*-*.so' -type f -exec strip $STRIP_SHARED {} + 2> /dev/null || true
    fi
}