cloudflare/ClickHouse
Publicmirrored fromhttps://github.com/cloudflare/ClickHouse
ci/build-gcc-from-sources.sh
47lines · modecode
unknown
| 1 | #!/usr/bin/env bash |
| 2 | set -e -x |
| 3 | |
| 4 | source default-config |
| 5 | |
| 6 | ./install-os-packages.sh curl |
| 7 | |
| 8 | if [[ "${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) |
| 10 | fi |
| 11 | |
| 12 | GCC_VERSION_SHORT=$(echo "$GCC_SOURCES_VERSION" | grep -oE '[0-9]' | head -n1) |
| 13 | |
| 14 | echo "Will download ${GCC_SOURCES_VERSION} (short version: $GCC_VERSION_SHORT)." |
| 15 | |
| 16 | THREADS=$(grep -c ^processor /proc/cpuinfo) |
| 17 | |
| 18 | mkdir "${WORKSPACE}/gcc" |
| 19 | pushd "${WORKSPACE}/gcc" |
| 20 | |
| 21 | wget https://ftpmirror.gnu.org/gcc/${GCC_SOURCES_VERSION}/${GCC_SOURCES_VERSION}.tar.xz |
| 22 | tar xf ${GCC_SOURCES_VERSION}.tar.xz |
| 23 | pushd ${GCC_SOURCES_VERSION} |
| 24 | ./contrib/download_prerequisites |
| 25 | popd |
| 26 | mkdir gcc-build |
| 27 | pushd gcc-build |
| 28 | ../${GCC_SOURCES_VERSION}/configure --enable-languages=c,c++ --disable-multilib |
| 29 | make -j $THREADS |
| 30 | $SUDO make install |
| 31 | |
| 32 | popd |
| 33 | popd |
| 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 | |
| 40 | echo '/usr/local/lib64' | $SUDO tee /etc/ld.so.conf.d/10_local-lib64.conf |
| 41 | $SUDO ldconfig |
| 42 | |
| 43 | hash gcc g++ |
| 44 | gcc --version |
| 45 | |
| 46 | export CC=gcc |
| 47 | export CXX=g++ |