Skip to content

Commit

Permalink
Only download llvm when necessary (#9)
Browse files Browse the repository at this point in the history
llvm-config is now found by the following order:

1. the value of env var LLVM_CONFIG_CMD
2. the installed llvm-config-14 in the Ubuntu 22.04 images
3. download clang+llvm 13 and use the downloaded binary
  • Loading branch information
gfengTT authored Jul 19, 2024
1 parent 05bf431 commit 9c685f9
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,34 @@ echo $PYBUDA_ROOT
cd $PYBUDA_ROOT
export TVM_HOME=$PYBUDA_ROOT/third_party/tvm

# Download / untar LLVM
cd $PYBUDA_ROOT/third_party
if [ ! -d "$PYBUDA_ROOT/third_party/llvm" ]; then
wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
LLVM_TAR=$PYBUDA_ROOT/third_party/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
LLVM_DIR=$PYBUDA_ROOT/third_party/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04
tar -xf $LLVM_TAR && mv $LLVM_DIR $PYBUDA_ROOT/third_party/llvm && rm -f $LLVM_TAR
fi

cd $TVM_HOME
git submodule init; git submodule update

mkdir -p build
cp $TVM_HOME/cmake/config.cmake $TVM_HOME/build
cd $TVM_HOME/build

# Link the LLVM thats just been downloaded
LLVM_LINK=$PYBUDA_ROOT/third_party/llvm/bin/llvm-config

if [[ -n $LLVM_CONFIG_CMD && -e $LLVM_CONFIG_CMD ]]; then
# pass in through environment variable
echo Using "$LLVM_CONFIG_CMD" as LLVM_LINK
LLVM_LINK="$LLVM_CONFIG_CMD"
elif [[ -e /usr/bin/llvm-config-14 ]]; then
# should be present; llvm-14 is included in our ubuntu 22.04 images
echo Using /usr/bin/llvm-config-14 as LLVM_LINK
LLVM_LINK=/usr/bin/llvm-config-14
else
# Download / untar LLVM
echo Downloading llvm
if [ ! -d "$PYBUDA_ROOT/third_party/llvm" ]; then
wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
LLVM_TAR=$PYBUDA_ROOT/third_party/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
LLVM_DIR=$PYBUDA_ROOT/third_party/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04
tar -xf $LLVM_TAR && mv $LLVM_DIR $PYBUDA_ROOT/third_party/llvm && rm -f $LLVM_TAR
fi
# Link the LLVM thats just been downloaded
LLVM_LINK=$PYBUDA_ROOT/third_party/llvm/bin/llvm-config
fi
sed -i "s#/usr/bin/llvm-config#$LLVM_LINK#g" $TVM_HOME/build/config.cmake

if [[ "$TVM_BUILD_CONFIG" == "debug" ]]; then
Expand Down

0 comments on commit 9c685f9

Please sign in to comment.