|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright (C) 2021 Intel Corporation |
| 5 | +# |
| 6 | +# SPDX-License-Identifier: MIT |
| 7 | +# |
| 8 | + |
| 9 | +set -e |
| 10 | +# BUILD_OS supported value [ ubuntu1804, ubuntu2004 ] default ubuntu2004 |
| 11 | +# LLVM_VERSION supported value [ 10, 11, 12 ] default 11 |
| 12 | +# COMPILER supported value [ gcc, clang ] default gcc |
| 13 | +# OWN_CMAKE_FLAGS not suported but can be use as WA (each flag should be with -D prefix) default empty |
| 14 | +# example run: BUILD_OS=ubuntu2004 LLVM_VERSION=11 COMPILER=gcc sh /home/buildIGC.sh |
| 15 | + |
| 16 | +echo "====================BUILD IGC=========================" |
| 17 | +echo "[Build Status] build script started" |
| 18 | +if [ -z ${BUILD_OS+x} ]; then |
| 19 | + echo "[Build Status] BUILD_OS is unset, use default ubuntu2004"; |
| 20 | + BUILD_OS="ubuntu2004" |
| 21 | +else |
| 22 | + echo "[Build Status] BUILD_OS = ${BUILD_OS}" |
| 23 | +fi |
| 24 | +if [ -z ${LLVM_VERSION+x} ]; then |
| 25 | + echo "[Build Status] LLVM_VERSION is unset, use default 11"; |
| 26 | + LLVM_VERSION="11" |
| 27 | +else |
| 28 | + echo "[Build Status] LLVM_VERSION = ${LLVM_VERSION}" |
| 29 | +fi |
| 30 | +if [ -z ${COMPILER+x} ]; then |
| 31 | + echo "[Build Status] COMPILER is unset, use default gcc"; |
| 32 | + COMPILER="gcc" |
| 33 | +else |
| 34 | + echo "[Build Status] COMPILER = ${COMPILER}" |
| 35 | +fi |
| 36 | +if [ -z ${OWN_CMAKE_FLAGS+x} ]; then |
| 37 | + echo "[Build Status] OWN_CMAKE_FLAGS is unset, use default EMPTY"; |
| 38 | + OWN_CMAKE_FLAGS="" |
| 39 | +else |
| 40 | + echo "[Build Status] OWN_CMAKE_FLAGS = ${OWN_CMAKE_FLAGS}" |
| 41 | +fi |
| 42 | + |
| 43 | + |
| 44 | +apt-get update |
| 45 | +apt-get install -y flex bison libz-dev cmake curl wget build-essential git software-properties-common |
| 46 | +apt-get update |
| 47 | +echo "[Build Status] flex bison libz-dev cmake curl wget build-essential git software-properties-common INSTALLED" |
| 48 | + |
| 49 | +if [ "$BUILD_OS" = "ubuntu1804" ]; then |
| 50 | + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - |
| 51 | + apt-add-repository "deb https://apt.kitware.com/ubuntu/ bionic main" |
| 52 | + apt update |
| 53 | + apt-get install -y cmake |
| 54 | + echo "[Build Status] new cmake on Ubuntu18.04 INSTALLED" |
| 55 | + wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - |
| 56 | + add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$LLVM_VERSION main" |
| 57 | + apt update |
| 58 | + echo '[Build Status] LLVM "$LLVM_VERSION" on Ubuntu18.04 PREPARED' |
| 59 | +fi |
| 60 | +apt-get install -y llvm-"$LLVM_VERSION" llvm-"$LLVM_VERSION"-dev clang-"$LLVM_VERSION" liblld-"$LLVM_VERSION" liblld-"$LLVM_VERSION"-dev |
| 61 | +echo "[Build Status] LLVM INSTALLED" |
| 62 | + |
| 63 | +mkdir workspace |
| 64 | +cd workspace |
| 65 | +/usr/bin/git version |
| 66 | +/usr/bin/git clone https://github.com/intel/intel-graphics-compiler ./igc |
| 67 | +cd igc |
| 68 | +echo "[Build Status] IGC commit hash below:" |
| 69 | +/usr/bin/git log -1 --format='%H' |
| 70 | +/usr/bin/git clone https://github.com/intel/vc-intrinsics ../vc-intrinsics |
| 71 | +/usr/bin/git clone https://github.com/KhronosGroup/SPIRV-Headers.git ../SPIRV-Headers |
| 72 | +/usr/bin/git clone https://github.com/KhronosGroup/SPIRV-Tools.git ../SPIRV-Tools |
| 73 | +/usr/bin/git clone --branch llvm_release_"$LLVM_VERSION"0 https://github.com/KhronosGroup/SPIRV-LLVM-Translator ../llvm-project/llvm/projects/llvm-spirv |
| 74 | +echo "[Build Status] All necessary repository CLONED" |
| 75 | +mkdir build |
| 76 | +cd build |
| 77 | +curl -s https://api.github.com/repos/intel/intel-graphics-compiler/releases/latest | grep browser_download_url | egrep 'opencl_|core_' | cut -d '"' -f 4 | wget -qi - |
| 78 | +dpkg -i *.deb |
| 79 | +echo "[Build Status] Old IGC with opencl-clang downloaded and INSTALLED, WA to install opencl-clang" |
| 80 | + |
| 81 | +if [ "$BUILD_OS" = "ubuntu1804" ] && [ "$LLVM_VERSION" = "11" ]; then |
| 82 | + LLVM_VERSION_PREFERRED="$LLVM_VERSION".1.0 |
| 83 | +else |
| 84 | + LLVM_VERSION_PREFERRED="$LLVM_VERSION".0.0 |
| 85 | +fi |
| 86 | +echo "[Build Status] LLVM_VERSION_PREFERRED = $LLVM_VERSION_PREFERRED" |
| 87 | + |
| 88 | +CONFIG_VARS="-DIGC_OPTION__LLVM_MODE=Prebuilds -DIGC_OPTION__LLVM_PREFERRED_VERSION=$LLVM_VERSION_PREFERRED" |
| 89 | +case $COMPILER in |
| 90 | + "clang") |
| 91 | + CONFIG_VARS="$CONFIG_VARS -DCMAKE_C_COMPILER=clang-$LLVM_VERSION -DCMAKE_CXX_COMPILER=clang++-$LLVM_VERSION" |
| 92 | + ;; |
| 93 | +esac |
| 94 | +CONFIG_VARS="$CONFIG_VARS $OWN_CMAKE_FLAGS" |
| 95 | +echo "[Build Status] CONFIG_VARS = $CONFIG_VARS" |
| 96 | + |
| 97 | +cmake ../ $CONFIG_VARS |
| 98 | +echo "[Build Status] Cmake created" |
| 99 | + |
| 100 | +make -j`nproc` |
| 101 | +echo "[Build Status] make DONE" |
| 102 | +echo "====================BUILD IGC=========================" |
0 commit comments