123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- # Build script for gcc.
- #
- # Copyright (c) 2016-2018 Matias Fonzo, <selk@dragora.org>.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- version=7.3.0
- # Prerequisites
- gmp_version=6.1.2
- mpfr_version=4.0.1
- mpc_version=1.1.0
- isl_version=0.19
- cd -- "$TMPDIR"
- rm -rf gcc-${version} gmp-${gmp_version} \
- mpfr-${mpfr_version} mpc-${mpc_version} isl-${isl_version}
- unpack "${worktree}/sources/gcc-${version}.tar.gz" \
- "${worktree}/sources/gmp-${gmp_version}.tar.lz" \
- "${worktree}/sources/mpfr-${mpfr_version}.tar.bz2" \
- "${worktree}/sources/mpc-${mpc_version}.tar.gz" \
- "${worktree}/sources/isl-${isl_version}.tar.bz2"
- # Build instructions
- cd gcc-${version}
- # Apply specific patches for the support in musl.
- # http://port70.net/~nsz/musl/gcc-7.3.0
- patch -Np1 -i "${worktree}/patches/gcc/0001-ssp_nonshared.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0003-cilkrts.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0004-libatomic-test-fix.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0005-libgomp-test-fix.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0006-libitm-test-fix.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0007-libvtv-test-fix.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0008-static-pie-support.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0009-j2.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0010-s390x-muslldso.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0011-microblaze-pr65649.diff"
- patch -Np1 -i "${worktree}/patches/gcc/0012-ldbl128-config.diff"
- # Hard code default paths to look in /tools
- for file in \
- gcc/config/linux.h gcc/config/i386/linux.h gcc/config/i386/linux64.h \
- gcc/config/arm/linux-eabi.h gcc/config/arm/linux-elf.h \
- gcc/config/mips/linux.h \
- gcc/config/rs6000/linux64.h gcc/config/rs6000/sysv4.h \
- gcc/config/aarch64/aarch64-linux.h \
- gcc/config/microblaze/linux.h \
- gcc/config/sh/linux.h ; \
- do
- if test ! -f "$file"
- then
- echo "WARNING: ${0}: Non-existent file: $file" 1>&2
- continue;
- fi
- sed -i \
- -e 's@/lib\(64\)\{0,1\}\(32\)\{0,1\}/ld@/tools&@g' \
- -e 's@/usr@/tools@g' "$file"
- echo '
- #undef STANDARD_STARTFILE_PREFIX_1
- #undef STANDARD_STARTFILE_PREFIX_2
- #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
- #define STANDARD_STARTFILE_PREFIX_2 ""' >> "$file"
- done
- # Make symlinks for requisites
- ln -s ../gmp-${gmp_version} gmp
- ln -s ../mpfr-${mpfr_version} mpfr
- ln -s ../mpc-${mpc_version} mpc
- ln -s ../isl-${isl_version} isl
- # Apply patches for MPFR
- (
- cd mpfr || exit 1
- for file in "${worktree}"/patches/mpfr/patch??*
- do
- if test -f "$file"
- then
- rm -f PATCHES
- patch -p1 < "$file"
- fi
- done
- )
- # Build in a separate directory
- rm -rf ../gcc-build
- mkdir ../gcc-build
- cd ../gcc-build
- # Import and export toolchain variables
- . "${worktree}/stages/env.d/cross-staticenv"
- ../gcc-${version}/configure \
- AR="$AR" AS="$AS" LD="$LD" RANLIB="$RANLIB" READELF="$READELF" STRIP="$STRIP" \
- CC="$BTCC" CXX="$BTCXX" \
- CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
- --prefix=/tools \
- --libdir=/tools/lib${libSuffix} \
- --build=$host \
- --host=$target \
- --target=$target \
- --enable-languages=c,c++ \
- --enable-clocale=generic \
- --enable-tls \
- --enable-libstdcxx-time \
- --enable-install-libiberty \
- --enable-fully-dynamic-string \
- --enable-default-pie \
- --disable-symvers \
- --disable-bootstrap \
- --disable-libstdcxx-pch \
- --disable-gnu-indirect-function \
- --disable-libmudflap \
- --disable-libsanitizer \
- --disable-libmpx \
- --disable-nls \
- --with-local-prefix=/tools \
- --with-native-system-header-dir=/tools/include \
- $multilib_options \
- $gcc_options
- make -j${jobs} all \
- AS_FOR_TARGET="$AS" \
- LD_FOR_TARGET="$LD"
- make -j${jobs} install
- # Unset some imported variables from file
- unset AR AS LD RANLIB READELF STRIP
- cleanup()
- {
- cd -- "$TMPDIR" && rm -rf gcc-${version} \
- gmp-${gmp_version} mpfr-${mpfr_version} \
- mpc-${mpc_version} isl-${isl_version}
- }
|