blob: c3215cf2f6985b9d014149acd5590e5fbe4833ea (
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
|
# Maintainer : Daniel Bermond <dbermond@archlinux.org>
# Contributor: Valentín Kivachuk <vk18496@gmail.com>
_target=mips64-linux-gnu
pkgname="${_target}-gcc"
pkgver=14.2.0
_majorver="${pkgver%%.*}"
pkgrel=1
pkgdesc='The GNU Compiler Collection - cross compiler for the MIPS64 target (for the toolchain with GNU C library and with multilib ABI)'
arch=('x86_64')
url='https://gcc.gnu.org/'
license=('GPL-3.0-with-GCC-exception' 'GFDL-1.3-or-later')
depends=('gmp' 'libmpc' "${_target}-binutils" "${_target}-glibc" 'libisl' 'mpfr' 'sh' 'zlib' 'zstd')
makedepends=("${_target}-linux-api-headers")
provides=('mips64-linux-gnuabi64-gcc' 'mips64-linux-gnuabi32-gcc'
'mips64-linux-gnuabin32-gcc' "${pkgname}-bootstrap")
conflicts=('mips64-linux-gnuabi64-gcc' 'mips64-linux-gnuabi32-gcc'
'mips64-linux-gnuabin32-gcc' "${pkgname}-bootstrap")
options=('!emptydirs' '!strip' 'staticlibs' '!lto')
source=("https://sourceware.org/pub/gcc/releases/gcc-${pkgver}/gcc-${pkgver}.tar.xz"{,.sig}
'010-gcc-Wno-format-security.patch'
'020-gcc-config-mips-multilib.patch')
sha256sums=('a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9'
'SKIP'
'ae8f9bc913cef8d538003242d4661fddaf7cf261da17e978c7e7db995c7a1a97'
'cf51b274ea9a15f5618c7ec0c1b8fa981fe3bf1fa34005833c9de346af37628f')
validpgpkeys=('13975A70E63C361C73AE69EF6EEB81F8981C74C7' # Richard Guenther <richard.guenther@gmail.com>
'D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62') # Jakub Jelinek <jakub@redhat.com>
_ABIS=('64' 'n32' '32')
_DEFAULT_ABI='64' # gcc defaults to 'n32' ABI for MIPS64
prepare() {
mkdir -p build
patch -d "gcc-${pkgver}" -Np1 -i "${srcdir}/010-gcc-Wno-format-security.patch"
patch -d "gcc-${pkgver}" -Np1 -i "${srcdir}/020-gcc-config-mips-multilib.patch"
}
build() {
cd build
# using -pipe causes spurious test-suite failures
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
local _opt
for _opt in '-pipe' '-Werror=format-security' '-fstack-clash-protection' '-fcf-protection'
do
export CFLAGS="${CFLAGS/"$_opt"/}"
export CXXFLAGS="${CXXFLAGS/"$_opt"/}"
done
# position independent code (PIE) is troublesome in MIPS, as
# it can cause this error when building software with gcc:
# cc1: error: position-independent code requires ‘-mabicalls’
# (this error is not always solved when using '-mabicalls')
# https://github.com/crosstool-ng/crosstool-ng/issues/948
# https://gcc.gnu.org/legacy-ml/gcc-patches/2012-08/msg00237.html
"${srcdir}/gcc-${pkgver}/configure" \
--build="$CHOST" \
--host="$CHOST" \
--target="$_target" \
--prefix='/usr' \
--libdir='/usr/lib' \
--libexecdir='/usr/lib' \
--mandir='/usr/share/man' \
--with-sysroot="/usr/${_target}" \
--with-build-sysroot="/usr/${_target}" \
--with-native-system-header-dir='/include' \
--with-abi="$_DEFAULT_ABI" \
--with-gnu-as \
--with-gnu-ld \
--enable-languages='c,c++,fortran' \
--with-isl \
--with-linker-hash-style='gnu' \
--with-system-zlib \
--enable-__cxa_atexit \
--enable-cet='auto' \
--enable-checking='release' \
--enable-clocale='gnu' \
--disable-default-pie \
--enable-default-ssp \
--enable-gnu-indirect-function \
--enable-gnu-unique-object \
--enable-install-libiberty \
--enable-linker-build-id \
--enable-lto \
--enable-multilib \
--enable-plugin \
--enable-shared \
--enable-threads='posix' \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libunwind-exceptions \
--disable-werror \
--disable-libsanitizer
make
}
check() {
# disable libphobos test to avoid segfaults and other possible problems
sed -i '/maybe-check-target-libphobos \\/d' build/Makefile
# do not abort on error as some are "expected"
make -C build -k check || true
"gcc-${pkgver}/contrib/test_summary"
}
package() {
make -C build DESTDIR="$pkgdir" install-gcc install-target-{libgcc,libstdc++-v3,libgomp,libgfortran,libquadmath}
# allow using gnuabi${_abi} executables
local _abi
local _bin
for _abi in "${_ABIS[@]}"
do
for _bin in c++ cpp g++ gcc "gcc-${pkgver}"
do
if [ "$_abi" = "$_DEFAULT_ABI" ]
then
ln -s "${_target}-${_bin}" "${pkgdir}/usr/bin/${_target/gnu/"gnuabi${_abi}"}-${_bin}"
else
cat <<- __EOF__ | install -D -m755 /dev/stdin "${pkgdir}/usr/bin/${_target/gnu/"gnuabi${_abi}"}-${_bin}"
#!/bin/sh
exec ${_target}-${_bin} -mabi='${_abi}' "\$@"
__EOF__
fi
case "$_bin" in
cpp|g++|gcc)
ln -s "${_target}-${_bin}.1.gz" "${pkgdir}/usr/share/man/man1/${_target/gnu/"gnuabi${_abi}"}-${_bin}.1.gz"
;;
esac
done
done
install -D -m644 "gcc-${pkgver}/COPYING.RUNTIME" \
"${pkgdir}/usr/share/licenses/${pkgname}/RUNTIME.LIBRARY.EXCEPTION"
# remove conflicting files
rm -r "${pkgdir}/usr/share"/{"gcc-${pkgver}",info,locale,man/man7}
# strip target binaries
find "${pkgdir}/usr/lib/gcc/${_target}" "${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/lib/gcc/${_target}" -type f -and \( -executable \) -exec strip '{}' \;
}
|