1 # Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>
2 # Contributor: Martin Schmölzer <mschmoelzer@gmail.com>
9 pkgdesc='The GNU Compiler Collection - cross compiler for ARM EABI (bare-metal) target'
11 url='https://gcc.gnu.org/'
12 license=(GPL LGPL FDL)
13 depends=($_target-binutils zlib libmpc libisl zstd)
14 makedepends=(gmp mpfr $_target-newlib)
15 optdepends=('arm-none-eabi-newlib: Standard C library optimized for embedded systems')
16 options=(!emptydirs !strip !lto)
17 source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz{,.sig})
18 #ftp://gcc.gnu.org/pub/gcc/snapshots/$_snapshot/gcc-$_snapshot.tar.xz
19 sha256sums=('61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86'
21 validpgpkeys=(33C235A34C46AA3FFB293709A328C3A2C3C45C06 # Jakub Jelinek <jakub@redhat.com>
22 D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62 # Jakub Jelinek <jakub@redhat.com>
23 13975A70E63C361C73AE69EF6EEB81F8981C74C7) # Richard Guenther <richard.guenther@gmail.com>
25 if [ -n "$_snapshot" ]; then
26 _basedir=gcc-$_snapshot
34 echo $pkgver > gcc/BASE-VER
36 mkdir "$srcdir"/build-{gcc,gcc-nano}
40 "$srcdir"/$_basedir/configure \
43 --with-sysroot=/usr/$_target \
44 --with-native-system-header-dir=/include \
45 --libexecdir=/usr/lib \
46 --enable-languages=c,c++ \
48 --disable-decimal-float \
51 --disable-libmudflap \
52 --disable-libquadmath \
54 --disable-libstdcxx-pch \
63 --with-headers=/usr/$_target/include \
64 --with-python-dir=share/gcc-arm-none-eabi \
70 --enable-gnu-indirect-function \
71 --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
72 --with-pkgversion='Arch Repository' \
73 --with-bugurl='https://bugs.archlinux.org/' \
74 --with-multilib-list=rmprofile
76 make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
81 # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
82 # TODO: properly deal with the build issues resulting from this
83 CFLAGS=${CFLAGS/-Werror=format-security/}
84 CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
86 cd "$srcdir"/build-gcc
87 export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
88 export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
91 # Build libstdc++ without exceptions support (the 'nano' variant)
92 cd "$srcdir"/build-gcc-nano
93 export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
94 export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
99 cd "$srcdir"/build-gcc
100 make DESTDIR="$pkgdir" install -j1
102 cd "$srcdir"/build-gcc-nano
103 make DESTDIR="$pkgdir.nano" install -j1
104 # we need only libstdc nano files
105 multilibs=( $("$pkgdir"/usr/bin/$_target-gcc -print-multi-lib 2>/dev/null) )
106 for multilib in "${multilibs[@]}"; do
107 dir="${multilib%%;*}"
108 from_dir="$pkgdir".nano/usr/$_target/lib/"$dir"
109 to_dir="$pkgdir"/usr/$_target/lib/"$dir"
110 cp -f "$from_dir"/libstdc++.a "$to_dir"/libstdc++_nano.a
111 cp -f "$from_dir"/libsupc++.a "$to_dir"/libsupc++_nano.a
114 # strip target binaries
115 find "$pkgdir"/usr/lib/gcc/$_target/$pkgver "$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 '{}' \;
117 # strip host binaries
118 find "$pkgdir"/usr/bin/ "$pkgdir"/usr/lib/gcc/$_target/$pkgver -type f -and \( -executable \) -exec strip '{}' \;
120 # Remove files that conflict with host gcc package
121 rm -r "$pkgdir"/usr/share/man/man7
122 rm -r "$pkgdir"/usr/share/info
123 rm "$pkgdir"/usr/lib/libcc1.*