Skip to content

Commit

Permalink
Add a "--with-xlen" configure argument (#16)
Browse files Browse the repository at this point in the history
The tools had riscv64-unknown-elf-gcc hard-coded all over the place.
This lets users override that if they have a 32-bit toolchain.
  • Loading branch information
palmer-dabbelt authored and aswaterman committed Jul 12, 2016
1 parent b6c8a03 commit 7f3b666
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
prefix := @prefix@
abs_top_src_dir := @abs_top_srcdir@
XLEN := @XLEN@
instbasedir := $(DESTDIR)$(prefix)
bmarkdir := $(abs_top_src_dir)/benchmarks
isa_src_dir := $(abs_top_src_dir)/isa
Expand All @@ -14,11 +15,11 @@ install: all

benchmarks:
mkdir -p benchmarks
$(MAKE) -C benchmarks -f $(bmarkdir)/Makefile src_dir=$(bmarkdir)
$(MAKE) -C benchmarks -f $(bmarkdir)/Makefile src_dir=$(bmarkdir) XLEN=$(XLEN)

isa:
mkdir -p isa
$(MAKE) -C isa -f $(isa_src_dir)/Makefile src_dir=$(isa_src_dir)
$(MAKE) -C isa -f $(isa_src_dir)/Makefile src_dir=$(isa_src_dir) XLEN=$(XLEN)

clean:
$(MAKE) -C isa -f $(isa_src_dir)/Makefile src_dir=$(isa_src_dir) clean
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bmarks_host = \
HOST_OPTS = -std=gnu99 -DPREALLOCATE=0 -DHOST_DEBUG=1
HOST_COMP = gcc $(HOST_OPTS)

RISCV_PREFIX ?= riscv64-unknown-elf-
RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
Expand Down
20 changes: 20 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ PACKAGE_URL=''

ac_subst_vars='LTLIBOBJS
LIBOBJS
XLEN
OBJEXT
EXEEXT
ac_ct_CC
Expand Down Expand Up @@ -631,6 +632,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
with_xlen
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1245,6 +1247,11 @@ if test -n "$ac_init_help"; then
esac
cat <<\_ACEOF
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-xlen=XLEN Set XLEN, the X-register bit width (default is 64)
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
Expand Down Expand Up @@ -2515,6 +2522,19 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Check whether --with-xlen was given.
if test "${with_xlen+set}" = set; then :
withval=$with_xlen; XLEN=$withval
else
XLEN=64
fi
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ AC_INIT(riscv-tests, 1.0)
cross_compiling=yes
AC_PROG_CC

AC_ARG_WITH(xlen,
[AS_HELP_STRING([--with-xlen=XLEN],
[Set XLEN, the X-register bit width (default is 64)])],
AC_SUBST(XLEN, $withval),
AC_SUBST(XLEN, 64)
)


AC_OUTPUT(
Makefile
)
3 changes: 1 addition & 2 deletions isa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ default: all
# Build rules
#--------------------------------------------------------------------

RISCV_PREFIX ?= riscv64-unknown-elf-
RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
ENTROPY ?= -DENTROPY=$(shell echo $$$$)
RISCV_GCC_OPTS ?= $(ENTROPY) -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
RISCV_SIM ?= spike
XLEN ?= 64

vpath %.S $(src_dir)

Expand Down
2 changes: 1 addition & 1 deletion mt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bmarks = $(bmarks_vvadd) $(bmarks_matmul)
# Build rules
#--------------------------------------------------------------------

RISCV_PREFIX=riscv64-unknown-elf-
RISCV_PREFIX=riscv$(XLEN)-unknown-elf-
RISCV_GCC = $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS = -std=gnu99 -O2 -ffast-math
RISCV_LINK = $(RISCV_GCC) -T $(common)/test.ld $(incs)
Expand Down

0 comments on commit 7f3b666

Please sign in to comment.