Merge pull request #1806 from ucb-bar/circt-source
Add support for building CIRCT from source
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
|
||||
|
||||
102
scripts/build-circt-from-source.sh
Executable file
102
scripts/build-circt-from-source.sh
Executable file
@@ -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
|
||||
)
|
||||
|
||||
@@ -39,6 +39,7 @@ usage() {
|
||||
echo " --verbose -v : Verbose printout"
|
||||
echo " --use-unpinned-deps -ud : Use unpinned conda environment"
|
||||
echo " --use-lean-conda : Install a leaner version of the repository (Smaller conda env, no FireSim, no FireMarshal)"
|
||||
echo " --build-circt : Builds CIRCT from source, instead of downloading the precompiled binary"
|
||||
|
||||
echo " --skip -s N : Skip step N in the list above. Use multiple times to skip multiple steps ('-s N -s M ...')."
|
||||
echo " --skip-conda : Skip Conda initialization (step 1)"
|
||||
@@ -60,6 +61,7 @@ VERBOSE_FLAG=""
|
||||
USE_UNPINNED_DEPS=false
|
||||
USE_LEAN_CONDA=false
|
||||
SKIP_LIST=()
|
||||
BUILD_CIRCT=false
|
||||
|
||||
# getopts does not support long options, and is inflexible
|
||||
while [ "$1" != "" ];
|
||||
@@ -75,6 +77,8 @@ do
|
||||
--use-lean-conda)
|
||||
USE_LEAN_CONDA=true
|
||||
SKIP_LIST+=(4 6 7 8 9) ;;
|
||||
--build-circt)
|
||||
BUILD_CIRCT=true ;;
|
||||
-ud | --use-unpinned-deps )
|
||||
USE_UNPINNED_DEPS=true ;;
|
||||
--skip | -s)
|
||||
@@ -306,13 +310,20 @@ if run_step "10"; then
|
||||
PREFIX=$RISCV
|
||||
fi
|
||||
|
||||
git submodule update --init $CYDIR/tools/install-circt &&
|
||||
$CYDIR/tools/install-circt/bin/download-release-or-nightly-circt.sh \
|
||||
-f circt-full-static-linux-x64.tar.gz \
|
||||
-i $PREFIX \
|
||||
-v version-file \
|
||||
-x $CYDIR/conda-reqs/circt.json \
|
||||
-g null
|
||||
if [ "$BUILD_CIRCT" = true ] ; then
|
||||
echo "Building CIRCT from source, and installing to $PREFIX"
|
||||
$CYDIR/scripts/build-circt-from-source.sh --prefix $PREFIX
|
||||
else
|
||||
echo "Downloading CIRCT from nightly build"
|
||||
|
||||
git submodule update --init $CYDIR/tools/install-circt &&
|
||||
$CYDIR/tools/install-circt/bin/download-release-or-nightly-circt.sh \
|
||||
-f circt-full-static-linux-x64.tar.gz \
|
||||
-i $PREFIX \
|
||||
-v version-file \
|
||||
-x $CYDIR/conda-reqs/circt.json \
|
||||
-g null
|
||||
fi
|
||||
exit_if_last_command_failed
|
||||
fi
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ cd "$RDIR"
|
||||
software/spec2017 \
|
||||
tools/dsptools \
|
||||
tools/rocket-dsp-utils \
|
||||
tools/circt \
|
||||
vlsi/hammer-mentor-plugins
|
||||
do
|
||||
"$1" "${name%/}"
|
||||
|
||||
1
tools/circt
Submodule
1
tools/circt
Submodule
Submodule tools/circt added at 9e0c1696f3
Reference in New Issue
Block a user