Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Build flang
#!/bin/bash -ex
export STAGEDIR=$(pwd)
export INSTALLDIR=$(pwd)/install
export BUILDDIR=$(pwd)/build
export BUILDFLANGDIR=$(pwd)/build-flang
mkdir -p ${BUILDDIR}
mkdir -p ${BUILDFLANGDIR}
#################
# Checkout code #
#################
# LLVM
cd $STAGEDIR
git clone --depth 1 -b release_40 https://github.com/llvm-mirror/llvm.git
# Clang
cd $STAGEDIR/llvm/tools
git clone --depth 1 -b flang_release_40 https://github.com/flang-compiler/clang.git
# OpenMP RTL
cd $STAGEDIR/llvm/projects
git clone --depth 1 -b release_40 https://github.com/llvm-mirror/openmp.git
# Flang itself
cd $STAGEDIR
git clone https://github.com/flang-compiler/flang.git
##############
# Build code #
##############
# Build llvm + clang
cd $BUILDDIR
cmake ../llvm/ \
-G Ninja \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=$INSTALLDIR
ninja
ninja install
# Build flang
cd $BUILDFLANGDIR
cmake ../flang \
-DCMAKE_INSTALL_PREFIX=$INSTALLDIR \
-DCMAKE_CXX_COMPILER=$INSTALLDIR/bin/clang++ \
-DCMAKE_C_COMPILER=$INSTALLDIR/bin/clang \
-DCMAKE_Fortran_COMPILER=$INSTALLDIR/bin/flang
make
make install
######################
# Environment script #
######################
echo "export PATH=$INSTALLDIR/bin:\$PATH" > flang-env.sh
echo "export LD_LIBRARY_PATH=$INSTALLDIR/lib:\$LD_LIBRARY_PATH" >> flang-env.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment