CodeCommitsIssuesPull requestsActionsInsightsSecurity
d4eb358752a2890a7d8d10b15872182228f19e05

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ci/build-gcc-from-sources.sh

47lines · modecode

1#!/usr/bin/env bash
2set -e -x
3
4source default-config
5
6./install-os-packages.sh curl
7
8if [[ "${GCC_SOURCES_VERSION}" == "latest" ]]; then
9 GCC_SOURCES_VERSION=$(curl -sSL https://ftpmirror.gnu.org/gcc/ | grep -oE 'gcc-[0-9]+(\.[0-9]+)+' | sort -Vr | head -n1)
10fi
11
12GCC_VERSION_SHORT=$(echo "$GCC_SOURCES_VERSION" | grep -oE '[0-9]' | head -n1)
13
14echo "Will download ${GCC_SOURCES_VERSION} (short version: $GCC_VERSION_SHORT)."
15
16THREADS=$(grep -c ^processor /proc/cpuinfo)
17
18mkdir "${WORKSPACE}/gcc"
19pushd "${WORKSPACE}/gcc"
20
21wget https://ftpmirror.gnu.org/gcc/${GCC_SOURCES_VERSION}/${GCC_SOURCES_VERSION}.tar.xz
22tar xf ${GCC_SOURCES_VERSION}.tar.xz
23pushd ${GCC_SOURCES_VERSION}
24./contrib/download_prerequisites
25popd
26mkdir gcc-build
27pushd gcc-build
28../${GCC_SOURCES_VERSION}/configure --enable-languages=c,c++ --disable-multilib
29make -j $THREADS
30$SUDO make install
31
32popd
33popd
34
35$SUDO ln -sf /usr/local/bin/gcc /usr/local/bin/gcc-${GCC_GCC_SOURCES_VERSION_SHORT}
36$SUDO ln -sf /usr/local/bin/g++ /usr/local/bin/g++-${GCC_GCC_SOURCES_VERSION_SHORT}
37$SUDO ln -sf /usr/local/bin/gcc /usr/local/bin/cc
38$SUDO ln -sf /usr/local/bin/g++ /usr/local/bin/c++
39
40echo '/usr/local/lib64' | $SUDO tee /etc/ld.so.conf.d/10_local-lib64.conf
41$SUDO ldconfig
42
43hash gcc g++
44gcc --version
45
46export CC=gcc
47export CXX=g++