-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1806 from ucb-bar/circt-source
Add support for building CIRCT from source
- Loading branch information
Showing
5 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env bash | ||
|
||
# exit script if any command fails | ||
set -e | ||
set -o pipefail | ||
|
||
RDIR=$(git rev-parse --show-toplevel) | ||
|
||
# get helpful utilities | ||
source $RDIR/scripts/utils.sh | ||
|
||
common_setup | ||
|
||
# Allow user to override MAKE | ||
[ -n "${MAKE:+x}" ] || MAKE=$(command -v gnumake || command -v gmake || command -v make) | ||
readonly MAKE | ||
|
||
usage() { | ||
echo "usage: ${0}" | ||
echo "" | ||
echo "Options" | ||
echo " --prefix -p PREFIX : Install destination." | ||
echo " --help -h : Display this message" | ||
exit "$1" | ||
} | ||
|
||
PREFIX="" | ||
|
||
# getopts does not support long options, and is inflexible | ||
while [ "$1" != "" ]; | ||
do | ||
case $1 in | ||
-h | -H | --help | help ) | ||
usage 3 ;; | ||
-p | --prefix ) | ||
shift | ||
PREFIX=$(realpath $1) ;; | ||
* ) | ||
error "invalid option $1" | ||
usage 1 ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ -z "$PREFIX" ] ; then | ||
error "ERROR: Prefix not given." | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
echo "Cloning CIRCT" | ||
( | ||
cd $RDIR/tools | ||
git submodule update --init --progress circt | ||
) | ||
echo "Cloning CIRCT/LLVM" | ||
( | ||
cd $RDIR/tools/circt | ||
git submodule init | ||
# The settings in circt/.gitmodules don't "stick", so force-set them here | ||
git config submodule.llvm.shallow true | ||
git config submodule.llvm.branch main | ||
git submodule update --recommend-shallow --progress llvm | ||
) | ||
|
||
echo "Building CIRCT's LLVM/MLIR" | ||
( | ||
cd $RDIR/tools/circt | ||
rm -rf llvm/build | ||
mkdir llvm/build | ||
cd llvm/build | ||
cmake -G Ninja ../llvm \ | ||
-DLLVM_ENABLE_PROJECTS="mlir" \ | ||
-DLLVM_TARGETS_TO_BUILD="host" \ | ||
-DLLVM_ENABLE_ASSERTIONS=ON \ | ||
-DCMAKE_BUILD_TYPE=RELEASE \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON | ||
ninja | ||
) | ||
|
||
echo "Building CIRCT" | ||
( | ||
cd $RDIR/tools/circt | ||
rm -rf build | ||
mkdir build | ||
cd build | ||
cmake -G Ninja .. \ | ||
-DMLIR_DIR=../llvm/build/lib/cmake/mlir \ | ||
-DLLVM_DIR=../llvm/build/lib/cmake/llvm \ | ||
-DLLVM_ENABLE_ASSERTIONS=ON \ | ||
-DCMAKE_BUILD_TYPE=RELEASE \ | ||
-DCMAKE_INSTALL_PREFIX=$PREFIX | ||
ninja | ||
) | ||
|
||
echo "Installing CIRCT to $PREFIX" | ||
( | ||
cd $RDIR/tools/circt/build | ||
ninja install | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters