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"]
|
[submodule "generators/rocket-chip-inclusive-cache"]
|
||||||
path = generators/rocket-chip-inclusive-cache
|
path = generators/rocket-chip-inclusive-cache
|
||||||
url = https://github.com/chipsalliance/rocket-chip-inclusive-cache.git
|
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 " --verbose -v : Verbose printout"
|
||||||
echo " --use-unpinned-deps -ud : Use unpinned conda environment"
|
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 " --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 -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)"
|
echo " --skip-conda : Skip Conda initialization (step 1)"
|
||||||
@@ -60,6 +61,7 @@ VERBOSE_FLAG=""
|
|||||||
USE_UNPINNED_DEPS=false
|
USE_UNPINNED_DEPS=false
|
||||||
USE_LEAN_CONDA=false
|
USE_LEAN_CONDA=false
|
||||||
SKIP_LIST=()
|
SKIP_LIST=()
|
||||||
|
BUILD_CIRCT=false
|
||||||
|
|
||||||
# getopts does not support long options, and is inflexible
|
# getopts does not support long options, and is inflexible
|
||||||
while [ "$1" != "" ];
|
while [ "$1" != "" ];
|
||||||
@@ -75,6 +77,8 @@ do
|
|||||||
--use-lean-conda)
|
--use-lean-conda)
|
||||||
USE_LEAN_CONDA=true
|
USE_LEAN_CONDA=true
|
||||||
SKIP_LIST+=(4 6 7 8 9) ;;
|
SKIP_LIST+=(4 6 7 8 9) ;;
|
||||||
|
--build-circt)
|
||||||
|
BUILD_CIRCT=true ;;
|
||||||
-ud | --use-unpinned-deps )
|
-ud | --use-unpinned-deps )
|
||||||
USE_UNPINNED_DEPS=true ;;
|
USE_UNPINNED_DEPS=true ;;
|
||||||
--skip | -s)
|
--skip | -s)
|
||||||
@@ -306,13 +310,20 @@ if run_step "10"; then
|
|||||||
PREFIX=$RISCV
|
PREFIX=$RISCV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git submodule update --init $CYDIR/tools/install-circt &&
|
if [ "$BUILD_CIRCT" = true ] ; then
|
||||||
$CYDIR/tools/install-circt/bin/download-release-or-nightly-circt.sh \
|
echo "Building CIRCT from source, and installing to $PREFIX"
|
||||||
-f circt-full-static-linux-x64.tar.gz \
|
$CYDIR/scripts/build-circt-from-source.sh --prefix $PREFIX
|
||||||
-i $PREFIX \
|
else
|
||||||
-v version-file \
|
echo "Downloading CIRCT from nightly build"
|
||||||
-x $CYDIR/conda-reqs/circt.json \
|
|
||||||
-g null
|
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
|
exit_if_last_command_failed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ cd "$RDIR"
|
|||||||
software/spec2017 \
|
software/spec2017 \
|
||||||
tools/dsptools \
|
tools/dsptools \
|
||||||
tools/rocket-dsp-utils \
|
tools/rocket-dsp-utils \
|
||||||
|
tools/circt \
|
||||||
vlsi/hammer-mentor-plugins
|
vlsi/hammer-mentor-plugins
|
||||||
do
|
do
|
||||||
"$1" "${name%/}"
|
"$1" "${name%/}"
|
||||||
|
|||||||
1
tools/circt
Submodule
1
tools/circt
Submodule
Submodule tools/circt added at 9e0c1696f3
Reference in New Issue
Block a user