summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a60ece82ffb1c0edb90482511468e9612494b25b (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
# Maintainer: Joey Dumont <joey.dumont@gmail.com>
_target=mips64-ultra-elf
pkgname=${_target}-gcc-stage1
_gccver=13.2.0
_islver=0.24
pkgver=13.2.0_r172.97ae725
pkgrel=1
pkgdesc="The GNU Compiler Collection. Stage 1 for toolchain building (${_target})"
arch=('x86_64')
license=('GPL' 'LGPL' 'FDL')
url="http://www.gnu.org/software/gcc/"
depends=(libmpc zstd)
makedepends=(gmp mpfr git "${_target}-binutils")
optdepends=("${_target}-newlib: Standard C library optimized for embedded systems")
options=(!emptydirs)
source=("http://gcc.gnu.org/pub/gcc/releases/gcc-${_gccver}/gcc-${_gccver}.tar.xz"
        "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${_islver}.tar.bz2"
        "git+https://github.com/glankk/n64.git#branch=n64-ultra"
        "gcc13-Wno-format-security.patch")
sha256sums=('e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da'
            'fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0'
            'SKIP'
            '75bcf36e10fd50f7b21d80db4fcc9b58d2c658f2c749b7cf2f9369b31f147a6d')

pkgver() {
  cd "${srcdir}/n64/"
  printf "%s_r%s.%s" "${_gccver}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "gcc-${_gccver}"

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

  echo "${_gccver}" > gcc/BASE-VER

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

  # -- Patch Werror=format-security issues.
  patch --strip=1 --input="$srcdir"/gcc13-Wno-format-security.patch

  mkdir "${srcdir}"/build-gcc

  # -- Copy the files from the source.
  CP_DIR="${srcdir}/gcc-${_gccver}"

  cd "${srcdir}/n64"
  cp config/gcc/mips/* "${CP_DIR}/gcc/config/mips/"
  cat config/gcc/config.gcc.ultra >> "${CP_DIR}/gcc/config.gcc"

}

build() {
  cd build-gcc

  export CFLAGS="$CFLAGS -Wno-format-security"
  export CXXFLAGS="$CXXFLAGS -Wno-format-security"
  export CFLAGS_FOR_TARGET="-Os -g -ffunction-sections -fdata-sections"
  export CXXFLAGS_FOR_TARGET="-Os -g -ffunction-sections -fdata-sections"

  "${srcdir}"/gcc-${_gccver}/configure \
    --prefix=/usr \
    --libdir=/usr/${_target}/lib \
    --libexecdir=/usr/${_target}/lib \
    --target=${_target} \
    --host="$CHOST" \
    --build="$CHOST" \
    --with-arch=vr4300 \
    --with-abi=32 \
    --with-sysroot=/usr/${_target}/n64-sysroot/ \
    --enable-languages=c \
    --enable-sjlj-exceptions \
    --with-gnu-as \
    --with-gnu-ld \
    --with-python-dir=share/gcc-${_target} \
    --with-newlib \
    --without-headers \
    --without-included-gettext \
    --enable-checking=release \
    --disable-build-format-warnings \
    --disable-decimal-float \
    --disable-gold \
    --disable-libatomic \
    --disable-libgcj \
    --disable-libgomp \
    --disable-libitm \
    --disable-libquadmath \
    --disable-libquadmath-support \
    --disable-libsanitizer \
    --disable-libssp \
    --disable-libunwind-exceptions \
    --disable-libvtv \
    --enable-multilib \
    --disable-nls \
    --disable-shared \
    --disable-threads \
    --disable-werror \
    --enable-plugin

  make
}

package() {
  cd build-gcc

  make DESTDIR="${pkgdir}" install

  # strip target binaries
  find "$pkgdir"/usr/${_target}/lib/gcc/$_target/${_gccver} "$pkgdir"/usr/$_target/lib -type f -and \( -name \*.a -or -name \*.o \) -exec $_target-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;

  # strip host binaries
  find "$pkgdir"/usr/bin/ "$pkgdir"/usr/${_target}/lib/gcc/$_target/${_gccver} -type f -and \( -executable \) -exec strip '{}' \;

  # Remove files that conflict with host gcc package
  rm -r "$pkgdir"/usr/share/man/man7
  rm -r "$pkgdir"/usr/share/info
  rm "$pkgdir"/usr/${_target}/lib/libcc1.*
}