# Maintainer: Natanael Copa pkgname=gcc pkgver=4.7.2 _piepatchver=0.5.3 _specs_ver=0.2.0 _specs_gcc_ver=4.4.3 _uclibc_abiver=0.9.32 pkgrel=0 pkgdesc="The GNU Compiler Collection" url="http://gcc.gnu.org" arch="all" license="GPL LGPL" depends="binutils libgomp libobjc" makedepends="bison flex gmp-dev mpfr-dev texinfo mpc1-dev gawk zlib-dev zip cloog-dev" subpackages="$pkgname-doc libstdc++:libcxx g++:gpp libgcc libgomp" replaces="libstdc++" # disable Go til we have getcontex/setcontext LANG_GO=off if [ -n "$BOOTSTRAP" ]; then LANG_OBJC=off LANG_JAVA=off LANG_FORTRAN=off fi _languages=c,c++ if [ "$LANG_OBJC" != "off" ]; then subpackages="$subpackages libobjc" _languages="$_languages,objc" fi if [ "$LANG_JAVA" != "off" ]; then subpackages="$subpackages $pkgname-java libgcj" makedepends="$makedepends paxctl" _languages="$_languages,java" fi if [ "$LANG_GO" != "off" ]; then subpackages="$subpackages $pkgname-go libgo" _languages="$_languages,go" fi if [ "$LANG_FORTRAN" != "off" ]; then subpackages="$subpackages gfortran libgfortran libquadmath" _languages="$_languages,fortran" fi source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-$pkgver.tar.bz2 http://distfiles.gentoo.org/distfiles/gcc-4.7.1-piepatches-v${_piepatchver}.tar.bz2 http://distfiles.gentoo.org/distfiles/gcc-$_specs_gcc_ver-specs-$_specs_ver.tar.bz2 ftp://sourceware.org/pub/java/ecj-latest.jar 11_all_default-warn-format-security.patch 12_all_default-warn-trampolines.patch 15_all_libgomp-Werror.patch 16_all_libgo-Werror-pr53679.patch 29_all_arm_armv4t-default.patch 49_all_gcc-4.7-x86-libitm-pr52695.patch 51_all_libiberty-pic.patch 67_all_gcc-poison-system-directories.patch 74_all_gcc47_cloog-dl.patch gcc-spec-env.patch pt_gnu_eh_frame.patch uclibc-getipinfo.patch gcc-4.7-dynamic-linker.patch gcc-4.6-pr32219.patch boehem-gc-uclibc.patch gcc-pure64.patch gcc-go.patch " # we build out-of-tree _gccdir="$srcdir"/gcc-$pkgver _builddir="$srcdir/build" prepare() { cd "$_gccdir" # verify we have set CHOST if [ -z "$CHOST" ]; then error "CHOST not set" return 1 fi # PIE patches from gentoo # thanks to Zorry for hard work on those patches for i in "$srcdir"/piepatch/*.patch; do msg "Applying $i" patch -t -p0 -i $i || patch -t -p1 -i $i || return 1 done # Gentoo and uclibc patches _err= for i in $source; do case "$i" in *.patch) msg "Applying $i" patch -p1 -i "$srcdir"/$i || _err="$_err $i" ;; esac done if [ -n "$_err" ]; then error "The following patches failed:" for i in $_err; do echo " $i" done return 1 fi #PR33200 sed -i 's/use_fixproto=yes/:/' gcc/config.gcc || return 1 # enable hardened cflags by default # building gcc wih PIE seem to hit some strange bug. we probably run # out of some resource. so we disable PIE for gcc while enabling it # by default for everything else. local _hard_cflags="-DEFAULT_PIE_SSP -DEFAULT_RELRO -DEFAULT_BIND_NOW" sed -e "/^ALL_CFLAGS/iHARD_CFLAGS = ${_hard_cflags}" \ -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \ -i gcc/Makefile.in || return 1 # see http://gcc.gnu.org/ml/java/2008-04/msg00027.html mv "$srcdir"/ecj-latest.jar ecj.jar echo ${pkgver} > gcc/BASE-VER } build() { local _dynamic_linker= cd "$_gccdir" export CFLAGS="-fno-stack-protector" [ -z "$CBUILD" ] && CBUILD="$CHOST" [ -z "$CTARGET" ] && CTARGET="$CHOST" case "$CHOST" in x86_64-*-uclibc) _dynamic_linker="--with-dynamic-linker=ld64-uClibc.so.$_uclibc_abiver" ;; *-uclibc) _dynamic_linker="--with-dynamic-linker=ld-uClibc.so.$_uclibc_abiver" ;; *) _dynamic_linker= ;; esac # --enable-target-optspace is broken on powerpc if [ "$CARCH" != "powerpc" ]; then _target_optspace="--enable-target-optspace" fi msg "Building the following:" echo "" echo " CBUILD=$CBUILD" echo " CHOST=$CHOST" echo " CTARGET=$CTARGET" echo " languages=$_languages" echo " dynamic_linker=$_dynamic_linker" echo " target_optspace=$_target_optspace" echo "" mkdir -p "$_builddir" cd "$_builddir" "$_gccdir"/configure --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --build=${CBUILD} \ --host=${CHOST} \ --target=${CTARGET} \ --with-pkgversion="Alpine ${pkgver}-r${pkgrel}" \ --disable-altivec \ --disable-build-with-cxx \ --disable-checking \ --disable-fixed-point \ --disable-libssp \ --disable-libstdcxx-pch \ --disable-multilib \ --disable-nls \ --disable-werror \ --enable-__cxa_atexit \ --enable-cld \ --enable-esp \ --enable-cloog-backend \ --enable-languages=$_languages \ --enable-shared \ $_target_optspace \ --enable-tls \ --enable-threads \ $_dynamic_linker \ --with-dynamic-linker-prefix=/lib \ --with-system-zlib \ --without-system-libunwind \ || return 1 make || return 1 } package() { cd "$_builddir" make -j1 DESTDIR="${pkgdir}" install || return 1 find "$pkgdir" -name '*.la' -delete || return 1 ln -s gcc "$pkgdir"/usr/bin/cc # binutils provides libiberty.a rm -f "$pkgdir"/usr/lib/libiberty.a # install the specs cd "$srcdir"/specs install -d "$pkgdir"/usr/share/gcc for i in *.specs; do install -m644 $i "$pkgdir"/usr/share/gcc/$i || return 1 done # we dont support gcj -static # and saving 35MB is not bad. find "$pkgdir" -name libgcj.a -o -name libgtkpeer.a \ -o -name libgjsmalsa.a -o -name libgcj-tools.a \ -o -name libjvm.a -o -name libgij.a -o -name libgcj_bc.a \ -o -name libjavamath.a \ | xargs rm -f \ || return 1 [ "$LANG_JAVA" = "on" ] && \ sed -i -e 's/lib: /&%{static:%eJava programs cannot be linked statically}/' \ "$pkdir"/usr/lib/libgcj.spec # remove ffi rm "$pkgdir"/usr/lib/libffi* "$pkgdir"/usr/share/man/man3/ffi* \ || return 1 find "$pkgdir" -name 'ffi*.h' | xargs rm -f mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/lib mv "$pkgdir"/usr/lib/*-gdb.py \ "$pkgdir"/usr/share/gdb/python/auto-load/usr/lib/ paxctl -c -pmrs "$pkgdir"/usr/libexec/gcc/*/*/cc1 || return 1 } libcxx() { pkgdesc="GNU C++ standard runtime library" depends= mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libstdc++.so.* "$subpkgdir"/usr/lib/ } gpp() { pkgdesc="GNU C++ standard library and compiler" depends="libstdc++" local libexec=usr/libexec/gcc/${CHOST:-$_chost}/$pkgver mkdir -p "$subpkgdir/$libexec" \ "$subpkgdir"/usr/bin \ "$subpkgdir"/usr/include \ "$subpkgdir"/usr/lib \ mv "$pkgdir/$libexec/cc1plus" "$subpkgdir/$libexec/" paxctl -c -pmrs "$subpkgdir/$libexec/cc1plus" || return 1 mv "$pkgdir"/usr/lib/*++* "$subpkgdir"/usr/lib/ mv "$pkgdir"/usr/include/c++ "$subpkgdir"/usr/include/ mv "$pkgdir"/usr/bin/*++ "$subpkgdir"/usr/bin/ } libobjc() { pkgdesc="GNU ObjectiveC library" replaces="objc" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/*objc* "$subpkgdir"/usr/lib/ } libgcc() { pkgdesc="GNU C compiler runtime libraries" depends= mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libgcc_s.so.* "$subpkgdir"/usr/lib/ } libgomp() { pkgdesc="GCC shared-memory parallel programming API library" depends= replaces="gcc" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libgomp.so.* "$subpkgdir"/usr/lib/ } java() { pkgdesc="Java support for GCC" depends="zlib-dev" paxctl -c -pm "$pkgdir"/usr/libexec/gcc/*/*/ecj1 || return 1 mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib cd "$pkgdir"/usr/bin mv gcj gcj-dbtool gjavah gcjh jcf-dump "$subpkgdir"/usr/bin/ cd "$pkgdir" for i in $(find usr/ -name ecj1 -o -name jc1 -o -name jvgenmain); do mkdir -p "$subpkgdir"/${i%/*} mv "$pkgdir"/$i "$subpkgdir"/$i || return 1 done for i in "$pkgdir"/usr/lib/libgcj*.so; do if [ -L "$i" ]; then mv "$i" "$subpkgdir"/usr/lib/ fi done mv \ "$pkgdir"/usr/lib/libgij.so \ "$pkgdir"/usr/lib/libgcj.spec \ "$subpkgdir"/usr/lib/ } libgcj() { pkgdesc="Java runtime library for gcc" # libgcj_bc.so moved from gcc-java to libgcj replaces="gcc-java" mkdir -p "$subpkgdir"/usr/bin cd "$pkgdir"/usr/bin paxctl -c -pmsE "$pkgdir"/usr/bin/gij || return 1 mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\ gnative2ascii gorbd grmic grmid grmiregistry gserialver \ gtnameserv i486-alpine-linux-uclibc-gcj jv-convert \ rebuild-gcj-db \ "$subpkgdir"/usr/bin/ cd "$pkgdir" for i in $(find usr/lib -name jc1 -o -name jvgenmain); do mkdir -p "$subpkgdir"/${i%/*} mv "$pkgdir"/$i "$subpkgdir"/$i || return 1 done mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/gcj-* \ "$pkgdir"/usr/lib/libgcj_bc.so \ "$pkgdir"/usr/lib/libgcj*.so.* \ "$pkgdir"/usr/lib/libgij.so.* \ "$pkgdir"/usr/lib/logging.properties \ "$pkgdir"/usr/lib/security \ "$subpkgdir"/usr/lib/ \ || return 1 mkdir -p "$subpkgdir"/usr/share/ mv "$pkgdir"/usr/share/java "$subpkgdir"/usr/share/ } libgo() { pkgdesc="Go runtime library for GCC" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libgo.so.* "$subpkgdir"/usr/lib/ } go() { pkgdesc="Go support for GCC" depends="libgo" local libexec=usr/libexec/gcc/${CHOST:-$_chost}/$pkgver mkdir -p "$subpkgdir"/$libexec \ "$subpkgdir"/usr/lib \ "$subpkgdir"/usr/bin || return 1 mv "$pkgdir"/usr/lib/go "$subpkgdir"/usr/lib/ || return 1 mv "$pkgdir"/usr/bin/*gccgo "$subpkgdir"/usr/bin/ || return 1 mv "$pkgdir"/$libexec/go1 "$subpkgdir"/$libexec/ || return 1 mv "$pkgdir"/usr/lib/libgo.a \ "$pkgdir"/usr/lib/libgo.so \ "$pkgdir"/usr/lib/libgobegin.a \ "$subpkgdir"/usr/lib/ || return 1 } libgfortran() { pkgdesc="Fortran runtime library for GCC" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libgfortran.so.* "$subpkgdir"/usr/lib/ } libquadmath() { replaces="gcc" pkgdesc="128-bit math library for GCC" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libquadmath.so.* "$subpkgdir"/usr/lib/ } gfortran() { pkgdesc="GNU Fortran Compiler" depends="$depends libgfortran libquadmath" replaces="gcc" local libexec=usr/libexec/gcc/${CHOST:-$_chost}/$pkgver local gcclibs=usr/lib/gcc/${CHOST:-$_chost}/$pkgver mkdir -p "$subpkgdir"/$libexec \ "$subpkgdir"/$gcclibs \ "$subpkgdir"/usr/lib \ "$subpkgdir"/usr/bin || return 1 mv "$pkgdir"/usr/bin/*gfortran "$subpkgdir"/usr/bin/ || return 1 mv "$pkgdir"/usr/lib/libgfortran.a \ "$pkgdir"/usr/lib/libgfortran.so \ "$pkgdir"/usr/lib/libquadmath.a \ "$pkgdir"/usr/lib/libquadmath.so \ "$subpkgdir"/usr/lib/ || return 1 mv "$pkgdir"/$libexec/f951 \ "$subpkgdir"/$libexec mv "$pkgdir"/$gcclibs/libgfortranbegin.a \ "$subpkgdir"/$gcclibs } md5sums="cc308a0891e778cfda7a151ab8a6e762 gcc-4.7.2.tar.bz2 2e1d99664efcdbd86549a40ddf37d405 gcc-4.7.1-piepatches-v0.5.3.tar.bz2 441c76504e1d97170117c294e65c7a72 gcc-4.4.3-specs-0.2.0.tar.bz2 d7cd6a27c8801e66cbaa964a039ecfdb ecj-latest.jar 34e4a0260e9dbd434ac84b9dda381240 11_all_default-warn-format-security.patch 1570f30f65f1c4941d2bd690a7148836 12_all_default-warn-trampolines.patch 6862cb5268fef68a4a1906e0c4ea0d46 15_all_libgomp-Werror.patch 2a6a0be54c283c311a39bba359cc01f4 16_all_libgo-Werror-pr53679.patch 681499caf97fbdb4d5c97e312cddf47c 29_all_arm_armv4t-default.patch 4e35639c74fe4b6111f74a91bb3d52a8 49_all_gcc-4.7-x86-libitm-pr52695.patch d8692c56f04b92667096f59d843e95c5 51_all_libiberty-pic.patch 406fc6f29ab3d746eaef0202c50fd7e9 67_all_gcc-poison-system-directories.patch f24f07ed008324eaecb0f75417c99116 74_all_gcc47_cloog-dl.patch a695d7648509b4f8e18b389a19e6037c gcc-spec-env.patch ab83248e10b2bf4b3d9240de0fefb52b pt_gnu_eh_frame.patch 6cc2385c5bbd6d0da6eaedd53c8bf547 uclibc-getipinfo.patch ac11128f201ee00287f8852697cb86a6 gcc-4.7-dynamic-linker.patch 32e8e4c0e23ed8f5de95a591cb30f1da gcc-4.6-pr32219.patch 2c6cb49bb9bfd8b6e690222e66ccc901 boehem-gc-uclibc.patch 94c36cc724f5c5d6c8cb8650195ee83d gcc-pure64.patch c94014ece84407a36d239417a2bad25d gcc-go.patch"