summaryrefslogtreecommitdiff
path: root/PKGBUILD
blob: 37a57345cc29c18bd7390031e5425ad9500ceb38 (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
# Maintainer: jc_gargma <jc_gargma@iserlohn-fortress.net>
# Maintainer (Arch): Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor (Arch): Martin Schmölzer <mschmoelzer@gmail.com>

# # I maintain this because:
# Not in an official repo and I use it

# binutils -> gcc-bootstrap -> newlib -> gcc -> newlib -> gcc

_target=arm-none-eabi
pkgname=$_target-gcc
pkgver=9.2.0
_islver=0.22
pkgrel=1
pkgdesc='The GNU Compiler Collection - cross compiler for ARM EABI (bare-metal) target'
arch=(x86_64 i686 armv7h aarch64)
url='https://gcc.gnu.org/'
license=(GPL LGPL FDL)
depends=($_target-binutils libmpc zlib)
makedepends=(gmp mpfr $_target-newlib)
optdepends=("$_target-newlib: Standard C library ($_target target)")
options=(!emptydirs !strip)
source=(https://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-$pkgver.tar.xz{,.sig}
        http://isl.gforge.inria.fr/isl-$_islver.tar.xz)
b2sums=('41a5e148f9a6857d6599679964c203533f76f330ad527fbe7c5e746d78f6f6f6d6d0f330a67cb1e794e155be8d1cd6e986bcc8a116d620dca410b78f0bcdd453'
        'SKIP'
        '1cb2125761adec02d9f337e8730faa5bc3a4e63cb7d968f7f4de3a3360b1f9be6caf6a27031f02df1ebe149fb70b6a32bdddbe8ae03032b8ff366f4eac274483')
validpgpkeys=(33C235A34C46AA3FFB293709A328C3A2C3C45C06) # Jakub Jelinek <jakub@redhat.com>

prepare() {
  cd gcc-$pkgver

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

  echo $pkgver > gcc/BASE-VER

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

  mkdir $srcdir/build-{gcc,gcc-nano}
}

_build_gcc() {
  $srcdir/gcc-$pkgver/configure \
    --target=$_target \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --with-sysroot=/usr/$_target \
    --with-native-system-header-dir=/include \
    --enable-languages=c,c++ \
    --enable-plugins \
    --disable-decimal-float \
    --disable-libffi \
    --disable-libgomp \
    --disable-libmudflap \
    --disable-libquadmath \
    --disable-libssp \
    --disable-libstdcxx-pch \
    --disable-nls \
    --disable-shared \
    --disable-threads \
    --disable-tls \
    --with-gnu-as \
    --with-gnu-ld \
    --with-system-zlib \
    --with-newlib \
    --with-headers=/usr/$_target/include \
    --with-python-dir=share/gcc-$_target \
    --with-gmp \
    --with-mpfr \
    --with-mpc \
    --with-isl \
    --with-libelf \
    --enable-gnu-indirect-function \
    --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
    --with-pkgversion='Arch Repository' \
    --with-bugurl='https://bugs.archlinux.org/' \
    --with-multilib-list=rmprofile

  make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
}

build() {
  cd $srcdir/build-gcc
  export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
  export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
  _build_gcc

  # Build libstdc++ without exceptions support (the 'nano' variant)
  cd $srcdir/build-gcc-nano
  export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
  export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'  
  _build_gcc
}

package() {
  cd $srcdir/build-gcc
  make DESTDIR="$pkgdir" install -j1

  cd $srcdir/build-gcc-nano
  make DESTDIR="$pkgdir.nano" install -j1
  # we need only libstdc nano files
  multilibs=( $($pkgdir/usr/bin/$_target-gcc -print-multi-lib 2>/dev/null) )
  for multilib in "${multilibs[@]}"; do
    dir="${multilib%%;*}"
    from_dir=$pkgdir.nano/usr/$_target/lib/$dir
    to_dir=$pkgdir/usr/$_target/lib/$dir
    cp -f $from_dir/libstdc++.a $to_dir/libstdc++_nano.a
    cp -f $from_dir/libsupc++.a $to_dir/libsupc++_nano.a
  done

  # strip target binaries
  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 '{}' \;

  # strip host binaries
  find "$pkgdir"/usr/bin/ "$pkgdir"/usr/lib/gcc/$_target/$pkgver -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/lib/libcc1.*
}