Skip to content

Instantly share code, notes, and snippets.

@rofirrim
Created June 17, 2017 14:47
Show Gist options
  • Save rofirrim/4af6d876f9ea9aea0957cb2d830de05d to your computer and use it in GitHub Desktop.
Save rofirrim/4af6d876f9ea9aea0957cb2d830de05d to your computer and use it in GitHub Desktop.
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