fix: select medany toolchain and available GDB
This commit is contained in:
+4
-3
@@ -18,9 +18,9 @@ JDK_SHA256="d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331"
|
|||||||
MILL_URL="https://github.com/com-lihaoyi/mill/releases/download/$MILL_VERSION/$MILL_VERSION"
|
MILL_URL="https://github.com/com-lihaoyi/mill/releases/download/$MILL_VERSION/$MILL_VERSION"
|
||||||
MILL_SHA256="ebe83649cd63acd33608f6d14452c074be2ed7d00cd2f69f88573d3f6909774f"
|
MILL_SHA256="ebe83649cd63acd33608f6d14452c074be2ed7d00cd2f69f88573d3f6909774f"
|
||||||
|
|
||||||
CIRCT_ARCHIVE="circt-full-shared-linux-x64.tar.gz"
|
CIRCT_ARCHIVE="firrtl-bin-linux-x64.tar.gz"
|
||||||
CIRCT_URL="https://github.com/llvm/circt/releases/download/firtool-$FIRTOOL_VERSION/$CIRCT_ARCHIVE"
|
CIRCT_URL="https://github.com/llvm/circt/releases/download/firtool-$FIRTOOL_VERSION/$CIRCT_ARCHIVE"
|
||||||
CIRCT_SHA256="dde442dcd0ada92e6f7db26f4744667471f7be61d10f2876297efb435fc9a5ec"
|
CIRCT_SHA256="10bf9b135a65e5d93fb0555e967eac4258400ee629731ba68a69be6b7f9781ce"
|
||||||
|
|
||||||
Z3_ARCHIVE="z3-$Z3_VERSION-x64-glibc-2.39.zip"
|
Z3_ARCHIVE="z3-$Z3_VERSION-x64-glibc-2.39.zip"
|
||||||
Z3_URL="https://github.com/Z3Prover/z3/releases/download/z3-$Z3_VERSION/$Z3_ARCHIVE"
|
Z3_URL="https://github.com/Z3Prover/z3/releases/download/z3-$Z3_VERSION/$Z3_ARCHIVE"
|
||||||
@@ -85,7 +85,8 @@ if [[ ! -x "$TOOLS_ROOT/mill/$MILL_VERSION/mill" ]]; then
|
|||||||
"${SUDO[@]}" install -m 0755 "$work_dir/mill" "$TOOLS_ROOT/mill/$MILL_VERSION/mill"
|
"${SUDO[@]}" install -m 0755 "$work_dir/mill" "$TOOLS_ROOT/mill/$MILL_VERSION/mill"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -x "$TOOLS_ROOT/circt/firtool-$FIRTOOL_VERSION/bin/firtool" ]]; then
|
if ! "$TOOLS_ROOT/circt/firtool-$FIRTOOL_VERSION/bin/firtool" --version \
|
||||||
|
>/dev/null 2>&1; then
|
||||||
download "$CIRCT_URL" "$work_dir/$CIRCT_ARCHIVE" "$CIRCT_SHA256"
|
download "$CIRCT_URL" "$work_dir/$CIRCT_ARCHIVE" "$CIRCT_SHA256"
|
||||||
mkdir -p "$work_dir/circt"
|
mkdir -p "$work_dir/circt"
|
||||||
tar -xzf "$work_dir/$CIRCT_ARCHIVE" -C "$work_dir/circt"
|
tar -xzf "$work_dir/$CIRCT_ARCHIVE" -C "$work_dir/circt"
|
||||||
|
|||||||
@@ -29,17 +29,17 @@ done
|
|||||||
export Z3_LIB_DIR="${Z3_LIB_DIR:-$_gps_z3_dir}"
|
export Z3_LIB_DIR="${Z3_LIB_DIR:-$_gps_z3_dir}"
|
||||||
|
|
||||||
_gps_riscv_gcc=""
|
_gps_riscv_gcc=""
|
||||||
if [[ -n "${TOOLCHAIN:-}" ]]; then
|
if [[ -n "${RISCV_TOOLCHAIN:-}" ]]; then
|
||||||
_gps_candidates=("$TOOLCHAIN")
|
|
||||||
elif [[ -n "${RISCV_TOOLCHAIN:-}" ]]; then
|
|
||||||
_gps_candidates=("$RISCV_TOOLCHAIN" "$RISCV_TOOLCHAIN/bin")
|
_gps_candidates=("$RISCV_TOOLCHAIN" "$RISCV_TOOLCHAIN/bin")
|
||||||
|
elif [[ -n "${TOOLCHAIN:-}" ]]; then
|
||||||
|
_gps_candidates=("$TOOLCHAIN")
|
||||||
else
|
else
|
||||||
_gps_candidates=(
|
_gps_candidates=(
|
||||||
"$GPS_ROOT/tools/local/riscv/bin"
|
"$GPS_ROOT/tools/local/riscv/bin"
|
||||||
/tools/toolchains-medany/bin
|
/tools/toolchains-medany/bin
|
||||||
|
/tools/toolchains/rvtc-medany/bin
|
||||||
/tools/toolchain/bin
|
/tools/toolchain/bin
|
||||||
/tools/toolchains/bin
|
/tools/toolchains/bin
|
||||||
/tools/toolchains/rvtc-medany/bin
|
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,27 @@ if [[ -n "$TOOLCHAIN" ]]; then
|
|||||||
fi
|
fi
|
||||||
check riscv-gcc "$riscv_gcc" --version
|
check riscv-gcc "$riscv_gcc" --version
|
||||||
|
|
||||||
|
if [[ -n "$riscv_gcc" && -x "$riscv_gcc" ]]; then
|
||||||
|
medany_dir="$(mktemp -d "${TMPDIR:-/tmp}/gps-medany-check.XXXXXXXX")"
|
||||||
|
printf '%s\n' \
|
||||||
|
'#include <stdlib.h>' \
|
||||||
|
'void _start(void) { void *p = malloc(16); free(p); for (;;) {} }' \
|
||||||
|
> "$medany_dir/check.c"
|
||||||
|
if "$riscv_gcc" \
|
||||||
|
-march=rv64imafdc_zicsr_zifencei -mabi=lp64d -mcmodel=medany \
|
||||||
|
-Os -ffreestanding -fno-builtin -static -nostartfiles \
|
||||||
|
-Wl,-Ttext=0x80000000 -Wl,--unresolved-symbols=ignore-all \
|
||||||
|
"$medany_dir/check.c" -Wl,--start-group -lc -lgcc -Wl,--end-group \
|
||||||
|
-o "$medany_dir/check.elf" >/dev/null 2>&1; then
|
||||||
|
printf 'OK %-10s %s\n' riscv-libc 'medany @ 0x80000000'
|
||||||
|
else
|
||||||
|
printf 'INCOMPAT %-10s %s\n' riscv-libc \
|
||||||
|
'libc is not medany; select RISCV_TOOLCHAIN=/tools/toolchains/rvtc-medany'
|
||||||
|
status=1
|
||||||
|
fi
|
||||||
|
rm -rf "$medany_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$(uname -s)" != Linux || "$(uname -m)" != x86_64 ]]; then
|
if [[ "$(uname -s)" != Linux || "$(uname -m)" != x86_64 ]]; then
|
||||||
printf 'WARNING Kilitli JDK/CIRCT paketleri Linux-x86_64 icindir.\n'
|
printf 'WARNING Kilitli JDK/CIRCT paketleri Linux-x86_64 icindir.\n'
|
||||||
fi
|
fi
|
||||||
|
|||||||
+15
-4
@@ -21,23 +21,32 @@ VIVADO ?= $(lastword $(sort $(wildcard /tools/Xilinx/*/Vivado/bin/vivado) $(shel
|
|||||||
# TOOLCHAIN keeps compatibility with the existing software Makefiles.
|
# TOOLCHAIN keeps compatibility with the existing software Makefiles.
|
||||||
RISCV_TOOLCHAIN ?=
|
RISCV_TOOLCHAIN ?=
|
||||||
_RISCV_SEARCH_DIRS := \
|
_RISCV_SEARCH_DIRS := \
|
||||||
|
$(if $(strip $(RISCV_TOOLCHAIN)),$(RISCV_TOOLCHAIN) $(RISCV_TOOLCHAIN)/bin) \
|
||||||
$(TOOLCHAIN) \
|
$(TOOLCHAIN) \
|
||||||
$(RISCV_TOOLCHAIN) \
|
|
||||||
$(RISCV_TOOLCHAIN)/bin \
|
|
||||||
$(PROJECT_TOOLS_DIR)/riscv/bin \
|
$(PROJECT_TOOLS_DIR)/riscv/bin \
|
||||||
/tools/toolchains-medany/bin \
|
/tools/toolchains-medany/bin \
|
||||||
|
/tools/toolchains/rvtc-medany/bin \
|
||||||
/tools/toolchain/bin \
|
/tools/toolchain/bin \
|
||||||
/tools/toolchains/bin \
|
/tools/toolchains/bin
|
||||||
/tools/toolchains/rvtc-medany/bin
|
|
||||||
_RISCV_GCC := $(firstword \
|
_RISCV_GCC := $(firstword \
|
||||||
$(foreach d,$(_RISCV_SEARCH_DIRS),$(wildcard $(d)/riscv64-unknown-elf-gcc)) \
|
$(foreach d,$(_RISCV_SEARCH_DIRS),$(wildcard $(d)/riscv64-unknown-elf-gcc)) \
|
||||||
$(foreach d,$(_RISCV_SEARCH_DIRS),$(wildcard $(d)/riscv64-none-elf-gcc)) \
|
$(foreach d,$(_RISCV_SEARCH_DIRS),$(wildcard $(d)/riscv64-none-elf-gcc)) \
|
||||||
$(shell command -v riscv64-unknown-elf-gcc 2>/dev/null) \
|
$(shell command -v riscv64-unknown-elf-gcc 2>/dev/null) \
|
||||||
$(shell command -v riscv64-none-elf-gcc 2>/dev/null))
|
$(shell command -v riscv64-none-elf-gcc 2>/dev/null))
|
||||||
|
|
||||||
|
# An explicit RISCV_TOOLCHAIN is authoritative, including over an old
|
||||||
|
# TOOLCHAIN/RISCV_PREFIX inherited from the shell. Without override, Make's
|
||||||
|
# environment-variable semantics leave CROSS pointing at the stale toolchain
|
||||||
|
# even though _RISCV_GCC was found in RISCV_TOOLCHAIN.
|
||||||
|
ifneq ($(strip $(RISCV_TOOLCHAIN)),)
|
||||||
|
override TOOLCHAIN := $(patsubst %/,%,$(dir $(_RISCV_GCC)))
|
||||||
|
override RISCV_PREFIX := $(if $(_RISCV_GCC),$(patsubst %-gcc,%-,$(notdir $(_RISCV_GCC))),riscv64-unknown-elf-)
|
||||||
|
override CROSS := $(if $(strip $(TOOLCHAIN)),$(TOOLCHAIN)/)$(RISCV_PREFIX)
|
||||||
|
else
|
||||||
TOOLCHAIN ?= $(patsubst %/,%,$(dir $(_RISCV_GCC)))
|
TOOLCHAIN ?= $(patsubst %/,%,$(dir $(_RISCV_GCC)))
|
||||||
RISCV_PREFIX ?= $(if $(_RISCV_GCC),$(patsubst %-gcc,%-,$(notdir $(_RISCV_GCC))),riscv64-unknown-elf-)
|
RISCV_PREFIX ?= $(if $(_RISCV_GCC),$(patsubst %-gcc,%-,$(notdir $(_RISCV_GCC))),riscv64-unknown-elf-)
|
||||||
CROSS ?= $(if $(strip $(TOOLCHAIN)),$(TOOLCHAIN)/)$(RISCV_PREFIX)
|
CROSS ?= $(if $(strip $(TOOLCHAIN)),$(TOOLCHAIN)/)$(RISCV_PREFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
# Some compiler-only toolchains (notably rvtc-medany) do not ship GDB. Keep
|
# Some compiler-only toolchains (notably rvtc-medany) do not ship GDB. Keep
|
||||||
# using the selected compiler toolchain, but fall back to the full local
|
# using the selected compiler toolchain, but fall back to the full local
|
||||||
@@ -45,6 +54,8 @@ CROSS ?= $(if $(strip $(TOOLCHAIN)),$(TOOLCHAIN)/)$(RISCV_PREFIX)
|
|||||||
_RISCV_GDB := $(firstword \
|
_RISCV_GDB := $(firstword \
|
||||||
$(wildcard $(TOOLCHAIN)/$(RISCV_PREFIX)gdb) \
|
$(wildcard $(TOOLCHAIN)/$(RISCV_PREFIX)gdb) \
|
||||||
$(wildcard /tools/toolchains/tc/toolchain/bin/$(RISCV_PREFIX)gdb) \
|
$(wildcard /tools/toolchains/tc/toolchain/bin/$(RISCV_PREFIX)gdb) \
|
||||||
|
$(wildcard /tools/toolchain/bin/$(RISCV_PREFIX)gdb) \
|
||||||
|
$(lastword $(sort $(wildcard /tools/Xilinx/*/gnu/riscv/lin/bin/$(RISCV_PREFIX)gdb))) \
|
||||||
$(shell command -v $(RISCV_PREFIX)gdb 2>/dev/null))
|
$(shell command -v $(RISCV_PREFIX)gdb 2>/dev/null))
|
||||||
GDB ?= $(if $(_RISCV_GDB),$(_RISCV_GDB),$(CROSS)gdb)
|
GDB ?= $(if $(_RISCV_GDB),$(_RISCV_GDB),$(CROSS)gdb)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user