summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b6d34416dd1f970027b77035933c3a76bd3cbe24 (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
147
148
149
150
151
152
153
154
155
156
157
# Maintainer:  Chris Severance aur.severach aATt spamgourmet dott com
# Contributor: Sebastiaan Lokhorst <sebastiaanlokhorst@gmail.com>
# Contributor: Sven-Hendrik Haase <svenstaro@gmail.com>
# Contributor: Ruben Van Boxem <vanboxem.ruben@gmail.com>
# Contributor: Allan McRae <allan@archlinux.org>

set -u
_pkgver='5'
pkgname="gcc${_pkgver//./}"
pkgver="${_pkgver}.5.0"
_islver='0.18'
pkgrel='3'
pkgdesc="The GNU Compiler Collection (${_pkgver}.x)"
arch=('x86_64')
arch+=('i686')
url='https://gcc.gnu.org/gcc-5/'
license=('GPL' 'LGPL' 'FDL' 'custom')
depends=('glibc' 'binutils' 'libmpc')
options=('!emptydirs')
source=(
  "http://gcc.gnu.org/pub/gcc/releases/gcc-${pkgver}/gcc-${pkgver}.tar.xz"
  "http://isl.gforge.inria.fr/isl-${_islver}.tar.bz2"
  # Fix build with glibc 2.28, which removes <sys/ustat.h>
  'glibc2.28-ustat.patch'
  'glibc2.30-ipc_perm.patch'
)
md5sums=('0f70424213b4a1113c04ba66ddda0c1f'
         '11436d6b205e516635b666090b94ab32'
         '75b0fabc92d4e2735baa897f231e7d68'
         '04e73dd6a55a90a4fee9999a915580d3')
sha256sums=('530cea139d82fe542b358961130c69cfde8b3d14556370b65823d2f91f0ced87'
            '6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b'
            '335839750f0cf15ce0f6099673daf164db674c6442b00efcbc46c4f195cfa29d'
            '95d619636a2bae64acc01fdbe18ad61b4b0483217ee00eac372f0b0bec073f32')

PKGEXT='.pkg.tar.gz'

  _basedir="gcc-${pkgver}"

prepare() {
  set -u
  cd "${_basedir}"

  # link isl for in-tree builds
  ln -s "../isl-${_islver}" 'isl'

  # Do not run fixincludes
  sed -e 's@\./fixinc\.sh@-c true@' -i 'gcc/Makefile.in'

  local _pt
  for _pt in "${source[@]%%::*}"; do
    _pt="${_pt##*/}"
    if [[ "${_pt}" = *.patch ]]; then
      set +u; msg2 "Patch ${_pt}"; set -u
      patch -Nup0 -i "${srcdir}/${_pt}"
    fi
  done

  # Arch Linux installs x86_64 libraries /lib
  case "${CARCH}" in
  'x86_64') sed -e '/m64=/ s/lib64/lib/' -i 'gcc/config/i386/t-linux64' ;;
  esac

  echo "${pkgver}" > 'gcc/BASE-VER'

  # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
  sed -e '/^ac_cpp=/ s/\$CPPFLAGS/\$CPPFLAGS -O2/' -i {libiberty,gcc}/configure

  rm -rf 'gcc-build'
  mkdir 'gcc-build'

  set +u
}

build() {
  set -u
  cd "${_basedir}/gcc-build"

  if [ ! -s 'Makefile' ]; then
    # using -pipe causes spurious test-suite failures
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
    CFLAGS="${CFLAGS/-pipe/}"
    CXXFLAGS="${CXXFLAGS/-pipe/}"

    # Flags from new compilers that old compilers don't recognize
    CFLAGS="${CFLAGS/-fno-plt/}"
    CXXFLAGS="${CXXFLAGS/-fno-plt/}"

    CFLAGS="${CFLAGS/-Wformat-overflow=[0-9]/}"
    CXXFLAGS="${CXXFLAGS/-Wformat-overflow=[0-9]/}"

    #CXXFLAGS+=" -std=c++14" # CXXFLAGS is ignored by later stages, can't put into CPPFLAGS which works in all stages. Used below.
    CPPFLAGS+=" -O2 -Wno-implicit-fallthrough -Wno-expansion-to-defined -Wno-unused-result -Wno-cast-function-type -Wno-switch"

    # The following options are one per line, mostly sorted so they are easy to diff compare to other gcc packages.
    ../configure \
      --build="${CHOST}" \
      --disable-libssp \
      --disable-libstdcxx-pch \
      --disable-libunwind-exceptions \
      --disable-multilib \
      --disable-werror \
      --enable-__cxa_atexit \
      --enable-checking='release' \
      --enable-clocale='gnu' \
      --with-isl \
      --enable-gnu-indirect-function \
      --enable-gnu-unique-object \
      --enable-languages='c,c++,fortran,lto' \
      --enable-libmpx \
      --enable-linker-build-id \
      --enable-lto \
      --enable-plugin \
      --enable-shared \
      --enable-threads='posix' \
      --enable-version-specific-runtime-libs \
      --infodir='/usr/share/info' \
      --libdir='/usr/lib' \
      --libexecdir='/usr/lib' \
      --mandir='/usr/share/man' \
      --program-suffix="-${_pkgver}" \
      --with-bugurl='https://bugs.archlinux.org/' \
      --with-linker-hash-style='gnu' \
      --with-system-zlib \
      --prefix='/usr' \
      CXX='g++ -std=c++14'
#      CXX='g++-6.3' CC='gcc-6.3'
  fi

  local _nproc="$(nproc)"; _nproc=$((_nproc>8?8:_nproc))
  # without LD_PRELOAD, the build fails for some people with:
  #    [Makefile:605: libstdc++.la] Error 139
  LD_PRELOAD='/usr/lib/libstdc++.so' \
  nice make -s -j "${_nproc}"
  set +u
}

package() {
  set -u
  cd "${_basedir}/gcc-build"

  LD_PRELOAD='/usr/lib/libstdc++.so' \
  make -j1 DESTDIR="${pkgdir}" install

  ## Lazy way of dealing with conflicting man and info pages and locales...
  rm -rf "${pkgdir}/usr/share"/{info,locale,man}

  # Move potentially conflicting stuff to version specific subdirectory
  [[ -d "${pkgdir}/usr/lib" ]] && mv "${pkgdir}/usr/lib"/lib* "${pkgdir}/usr/lib/gcc/${CHOST}/${pkgver}/"
  [[ -d "${pkgdir}/usr/lib/gcc/${CHOST}/lib/" ]] && mv "${pkgdir}/usr/lib/gcc/${CHOST}/lib"/lib* "${pkgdir}/usr/lib/gcc/${CHOST}/${pkgver}/"

  # Install Runtime Library Exception
  install -Dpm644 '../COPYING.RUNTIME' \
    "${pkgdir}/usr/share/licenses/${pkgname}/RUNTIME.LIBRARY.EXCEPTION" || :
  set +u
}
set +u