Add script to build circt-from-source - from submodule
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -148,3 +148,6 @@
|
||||
[submodule "generators/rocket-chip-inclusive-cache"]
|
||||
path = generators/rocket-chip-inclusive-cache
|
||||
url = https://github.com/chipsalliance/rocket-chip-inclusive-cache.git
|
||||
[submodule "tools/circt"]
|
||||
path = tools/circt
|
||||
url = https://github.com/llvm/circt.git
|
||||
|
||||
97
scripts/build-circt-from-source.sh
Executable file
97
scripts/build-circt-from-source.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/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 submodules"
|
||||
(
|
||||
cd $RDIR/tools
|
||||
git submodule update --init circt
|
||||
cd circt
|
||||
git submodule init
|
||||
git submodule update
|
||||
)
|
||||
|
||||
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=DEBUG \
|
||||
-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=DEBUG \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=$PREFIX
|
||||
ninja
|
||||
)
|
||||
|
||||
echo "Installing CIRCT to $PREFIX"
|
||||
(
|
||||
cd $RDIR/tools/circt/build
|
||||
ninja install
|
||||
)
|
||||
|
||||
1
tools/circt
Submodule
1
tools/circt
Submodule
Submodule tools/circt added at 9e0c1696f3
Reference in New Issue
Block a user