summaryrefslogtreecommitdiff
path: root/repo/devel/gcc.xibuild
blob: 00db41845bdf59d779af55793c050a4abbae9d46 (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
#!/bin/bash

MAKEDEPS=(grep make libxml2 dejagnu inetutils libiconv)
DEPS=(glibc binutils mpc)

PKG_VER=11.2.0
SOURCE=https://ftp.gnu.org/gnu/gcc/gcc-$PKG_VER/gcc-$PKG_VER.tar.xz

DESC="The GNU Compiler Collection - C and C++ frontends"

prepare () {
    #fix an issue breaking libasan.a

    sed -e '/static.*SIGSTKSZ/d' \
    -e 's/return kAltStackSize/return SIGSTKSZ * 4/' \
    -i libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp

    case $(uname -m) in
      x86_64)
        sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
      ;;
    esac
}

build () {
    mkdir -v build
    cd build

    ../configure                                           \
        --prefix=/usr                                      \
        --disable-multilib                                 \
        --with-system-zlib                                 \
        --enable-languages=c,c++,d,fortran,go,objc,obj-c++ &&
    make
}

check () {
    ulimit -s 32768

    if id -u tester; then
        chown -Rv tester .
        su tester -c "PATH=$PATH make $MAKEFLAGS -k check" || true
        ../contrib/test_summary | grep -A7 Summ || true
    fi
}


package () {
    make DESTDIR=$PKG_DEST install

    mkdir -pv $PKG_DEST/usr/share/gdb/auto-load/usr/lib              &&
    mv -v $PKG_DEST/usr/lib/*gdb.py $PKG_DEST/usr/share/gdb/auto-load/usr/lib &&

    chown -v -R root:root \
        $PKG_DEST/usr/lib/gcc/*linux-gnu/$PKG_VER/include{,-fixed}

    rm -rf $PKG_DEST/usr/lib/gcc/$(gcc -dumpmachine)/$PKG_VER/include-fixed/bits/

    ln -v -sf ../usr/bin/cpp $PKG_DEST/lib          &&
    ln -v -sf gcc $PKG_DEST/usr/bin/cc              &&
    install -v -dm755 $PKG_DEST/usr/lib/bfd-plugins &&
    ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/$PKG_VER/liblto_plugin.so $PKG_DEST/usr/lib/bfd-plugins/

    # sanity checks
    echo 'int main(){}' > dummy.c
    cc dummy.c -v -Wl,--verbose &> dummy.log
    readelf -l a.out | grep ': /lib'

    grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
    grep -B4 '^ /usr/include' dummy.log
    grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
    grep "/lib.*/libc.so.6 " dummy.log
    grep found dummy.log

}