gcc upgraded to snapshot 8-20190201
[dragora.git] / recipes / devel / gcc / recipe
bloba4292b7b6b2ac6257ebbcc88684ebc5acb812e6f
1 # Build recipe for GCC.
3 # Copyright (c) 2015-2019 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 program=gcc
18 version=8-20190201
19 release=1
21 # Set 'outdir' for a nice and well-organized output directory
22 outdir="${outdir}/${arch}/devel"
24 tarname=${program}-${version}.tar.xz
26 # Remote source(s)
27 #fetch=http://gnu.c3sl.ufpr.br/ftp/gcc/gcc-${version}/$tarname
28 fetch=ftp://gcc.gnu.org/pub/gcc/snapshots/${version}/$tarname
30 homepage=http://www.gnu.org/software/gcc
31 license="GPLv2+, GPLv3+, LGPLv2.1, LGPLv3 + GCC runtime library exception"
33 description="
34 The GNU C Compiler Collection.
36 The GNU Compiler Collection (GCC) is a compiler system produced by the
37 GNU Project supporting various programming languages.  GCC is a key
38 component of the GNU toolchain.  The Free Software Foundation (FSF)
39 distributes GCC under the GNU General Public License (GNU GPL).
41 For more information about GCC, visit:  $homepage
44 # Source documentation
45 docs="COPYING* README"
46 docsdir="${docdir}/${program}-${version}"
48 # System-dependent
49 MACHTYPE="$(cc -dumpmachine)"
51 build()
53     set -e
55     unpack "${tardir}/$tarname"
57     cd "$srcdir"
59     # Set sane permissions
60     chmod -R u+w,go-w,a+rX-s .
62     # Apply specific patches for the support in musl.
63     # http://port70.net/~nsz/musl/gcc-8.2.0
65     #patch -Np1 -i "${worktree}/patches/gcc/0001-ssp_nonshared.patch"
66     patch -Np1 -i "${worktree}/patches/gcc/musl-libssp.diff"
67     patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.patch"
68     patch -Np1 -i "${worktree}/patches/gcc/0003-libatomic-test-fix.patch"
69     patch -Np1 -i "${worktree}/patches/gcc/0004-libgomp-test-fix.patch"
70     patch -Np1 -i "${worktree}/patches/gcc/0005-libitm-test-fix.patch"
71     patch -Np1 -i "${worktree}/patches/gcc/0006-libvtv-test-fix.patch"
72     patch -Np1 -i "${worktree}/patches/gcc/0007-j2.patch"
73     patch -Np1 -i "${worktree}/patches/gcc/0008-s390x-muslldso.patch"
74     patch -Np1 -i "${worktree}/patches/gcc/0009-microblaze-pr65649.patch"
75     patch -Np1 -i "${worktree}/patches/gcc/0010-ldbl128-config.patch"
76     patch -Np1 -i "${worktree}/patches/gcc/0011-m68k.patch"
77     patch -Np1 -i "${worktree}/patches/gcc/0012-static-pie.patch"
79     # Create a separate build directory
80     rm -rf ../gcc-build
81     mkdir ../gcc-build
82     cd ../gcc-build
84     ../${program}-${version}/configure SED=sed \
85     CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
86      $configure_args \
87      $multilib_options \
88      $gcc_options \
89      --libdir=/usr/lib${libSuffix} \
90      --mandir=$mandir \
91      --infodir=$infodir \
92      --enable-bootstrap \
93      --enable-languages=c,c++,objc,obj-c++,fortran \
94      --enable-clocale=generic \
95      --enable-threads=posix \
96      --enable-tls \
97      --enable-nls \
98      --enable-lto \
99      --enable-libstdcxx-time \
100      --enable-checking=release \
101      --enable-fully-dynamic-string \
102      --enable-default-ssp \
103      --enable-default-pie \
104      --disable-libssp \
105      --disable-symvers \
106      --disable-libitm \
107      --disable-gnu-indirect-function \
108      --disable-libstdcxx-pch \
109      --disable-libmudflap \
110      --disable-libsanitizer \
111      --disable-libmpx \
112      --disable-libcilkrts \
113      --with-system-zlib \
114      --build=$MACHTYPE \
115      --host=$MACHTYPE \
116      --target=$MACHTYPE
118     make -j${jobs} V=1 \
119      BOOT_LDFLAGS="$QILDFLAGS" \
120      BOOT_CFLAGS="$QICFLAGS" \
121      BOOT_CXXFLAGS="$QICXXFLAGS"
123     make -j${jobs} V=1 DESTDIR="$destdir" install
125     # Strip ELF executables only excluding shared objects
126     find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
127      cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
129     # Back to source dir
130     cd .. && cd "$srcdir"
132     # Provide minimal libssp_nonshared.a so we don't need libssp from GCC
134     cc $QICFLAGS -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
135                  -o __stack_chk_fail_local.o
136     ar r libssp_nonshared.a __stack_chk_fail_local.o
138     cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
139     strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"
141     # Move misplaced file(s) for GDB
142     mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
143     mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
144        "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
146     # Provide compatibility and make soft links for package size
147     (
148         cd "${destdir}/usr/bin" || exit 1
149         mv gcc gcc-${version}
150         ln -sf gcc-${version} gcc
151         ln -sf gcc cc
152         ln -sf gcc-${version} ${MACHTYPE}-gcc
153         ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
155         mv g++ g++-gcc-${version}
156         ln -sf g++-gcc-${version} g++
157         ln -sf g++ c++
158         ln -sf g++-gcc-${version} ${MACHTYPE}-g++
159         ln -sf g++-gcc-${version} ${MACHTYPE}-c++
161         mv gfortran gfortran-${version}
162         ln -sf gfortran-${version} gfortran
163         ln -sf gfortran-${version} ${MACHTYPE}-gfortran
164         # Extra symlinks for fortran
165         ln -sf gfortran g77
166         ln -sf g77 f77
167         ln -sf gfortran g95
168         ln -sf g95 f95
170         mv gcc-ar gcc-ar-${version}
171         ln -sf gcc-ar-${version} gcc-ar
172         ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
174         mv gcc-nm gcc-nm-${version}
175         ln -sf gcc-nm-${version} gcc-nm
176         ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
178         mv gcc-ranlib gcc-ranlib-${version}
179         ln -sf gcc-ranlib-${version} gcc-ranlib
180         ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
181     )
182     (
183         mkdir -p "${destdir}/lib" && \
184         cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
185     )
187     # Compress info documents deleting index file for the package
188     if test -d "${destdir}/$infodir"
189     then
190         rm -f "${destdir}/${infodir}/dir"
191         lzip -9 "${destdir}/${infodir}"/* || true
192     fi
194     # Compress and link man pages (if needed)
195     if test -d "${destdir}/$mandir"
196     then
197         (
198             cd "${destdir}/$mandir"
199             find . -type f -exec lzip -9 '{}' +
200             find . -type l | while read -r file
201             do
202                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
203                 rm -- "$file"
204             done
205         )
206     fi
208     # Copy documentation
209     mkdir -p "${destdir}${docsdir}"
210     cp -p $docs "${destdir}${docsdir}/"
212     # Delete temporary build directory
213     cd -- "$TMPDIR"
214     if test -d ./gcc-build
215     then
216         rm -rf ./gcc-build
217     fi