Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable firesim to use conda #1140

Merged
merged 10 commits into from
Apr 13, 2022
20 changes: 15 additions & 5 deletions scripts/build-toolchains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,22 @@ else
module_make riscv-gnu-toolchain linux
fi

module_all riscv-isa-sim --prefix="${RISCV}"
# disable boost explicitly for https://github.com/riscv-software-src/riscv-isa-sim/issues/834
# since we don't have it in our requirements
module_all riscv-isa-sim --prefix="${RISCV}" --with-boost=no
timsnyder-siv marked this conversation as resolved.
Show resolved Hide resolved
# build static libfesvr library for linking into firesim driver (or others)
echo '==> Installing libfesvr static library'
module_make riscv-isa-sim libfesvr.a
cp -p "${SRCDIR}/riscv-isa-sim/build/libfesvr.a" "${RISCV}/lib/"

CC= CXX= module_all riscv-pk --prefix="${RISCV}" --host=riscv${XLEN}-unknown-elf
CC= CXX= CFLAGS= CPPFLAGFS= CXXFLAGS= LDFLAGS= DEBUG_CXXFLAGS= DEBUG_CPPFLAGS= DEBUG_CFLAGS= OBJCOPY= \
module_all riscv-pk --prefix="${RISCV}" --host=riscv${XLEN}-unknown-elf
module_all riscv-tests --prefix="${RISCV}/riscv${XLEN}-unknown-elf" --with-xlen=${XLEN}

# Common tools (not in any particular toolchain dir)

CC= CXX= SRCDIR="$(pwd)/toolchains" module_all libgloss --prefix="${RISCV}/riscv${XLEN}-unknown-elf" --host=riscv${XLEN}-unknown-elf

CC= CXX= CFLAGS= CPPFLAGFS= CXXFLAGS= LDFLAGS= DEBUG_CXXFLAGS= DEBUG_CPPFLAGS= DEBUG_CFLAGS= \
SRCDIR="$(pwd)/toolchains" module_all libgloss --prefix="${RISCV}/riscv${XLEN}-unknown-elf" --host=riscv${XLEN}-unknown-elf
if [ -z "$IGNOREQEMU" ] ; then
echo "=> Starting qemu build"
dir="$(pwd)/toolchains/qemu"
Expand All @@ -186,8 +189,15 @@ if [ -z "$IGNOREQEMU" ] ; then
git -C "$dir" submodule foreach --quiet --recursive '! grep -q "git\.qemu\.org" .gitmodules 2>/dev/null' && \
echo "==> PLEASE REMOVE qemu URL-REWRITING from scripts/build-toolchains.sh. It is no longer needed!" && exit 1

ld_directive="$LD"
if [[ -n "${LD_GOLD:-z}" ]]; then
# conda bfd ld suffers from https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/1907789
# so use GOLD to link instead
ld_directive="$LD_GOLD"
fi

# now actually do the build
SRCDIR="$(pwd)/toolchains" module_build qemu --prefix="${RISCV}" --target-list=riscv${XLEN}-softmmu --disable-werror
LD="$ld_directive" SRCDIR="$(pwd)/toolchains" module_build qemu --prefix="${RISCV}" --target-list=riscv${XLEN}-softmmu --disable-werror
fi

# make Dromajo
Expand Down
33 changes: 17 additions & 16 deletions scripts/build-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,30 @@ module_prepare() ( # <submodule> [ignored-submodule..]
echo "=> Starting ${name} build"
echo "==> Initializing ${name} submodule"
if [ $# -gt 0 ] ; then
git submodule update --init "${dir}"
(set -x; git submodule update --init "${dir}")
while [ -n "$1" ] ; do
git -C "${dir}" config submodule."${1}".update none
(set -x; git -C "${dir}" config submodule."${1}".update none)
shift
done
fi
git submodule update --init --recursive "${dir}"
(set -x; git submodule update --init --recursive "${dir}")
)

module_run() ( # <submodule> <command..>
set -e
echo "=> cd ${SRCDIR}/${1}"
cd "${SRCDIR}/${1}"
shift
"$@"
(set -x; "$@")
)

module_make() ( # <submodule> <target..>
set -e -o pipefail
cd "${SRCDIR}/${1}/build"
build_dir="${SRCDIR}/${1}/build"
shift
"${MAKE}" "$@" | tee "build-${1:-make}.log"
(set -x; "${MAKE}" -C "$build_dir" "$@") | tee "build-${1:-make}.log"
if [ -n "$CLEANAFTERINSTALL" ] ; then
"${MAKE}" clean # get rid of intermediate files
(set -x; "${MAKE}" -C "$build_dir" clean) # get rid of intermediate files
fi
)

Expand All @@ -59,33 +60,33 @@ module_build() ( # <submodule> [configure-arg..]
name=$1
shift

echo "==> cd ${SRCDIR}/${name}"
cd "${SRCDIR}/${name}"

if [ -e build ] ; then
echo "==> Removing existing ${name}/build directory"
rm -rf build
(set -x; rm -rf build)
fi
if ! [ -e configure ] ; then
echo "==> Updating autoconf files for ${name}"
find . -iname configure.ac -type f -print0 |
while read -r -d '' file ; do
mkdir -p -- "${file%/*}/m4"
(set -x; mkdir -p -- "${file%/*}/m4")
done
autoreconf -i
(set -x; autoreconf -i)
fi

mkdir -p build
cd build
(set -x; mkdir -p build)
{
export PATH="${RISCV:+${RISCV}/bin:}${PATH}"
echo "==> Configuring ${name}"
../configure "$@"
(set -x; cd build && ../configure "$@")
echo "==> Building ${name}"
"${MAKE}"
(set -x; "${MAKE}" -C build)
echo "==> Installing ${name}"
"${MAKE}" install
(set -x; "${MAKE}" -C build install)
if [ -n "$CLEANAFTERINSTALL" ] ; then
"${MAKE}" clean # get rid of intermediate files
(set -x; "${MAKE}" -C build clean) # get rid of intermediate files
fi
} 2>&1 | tee build.log
)
Expand Down