diff --git a/Makefile.in b/Makefile.in index f7d810774bb..36b0b44ce85 100644 --- a/Makefile.in +++ b/Makefile.in @@ -84,7 +84,11 @@ ifneq ($(XLEN),32) XLEN := 64 endif -make_tuple = riscv$(1)-unknown-$(2) +ifeq (@endian@,big) +ENDIAN_POSTFIX := be +endif + +make_tuple = riscv$(1)$(ENDIAN_POSTFIX)-unknown-$(2) LINUX_TUPLE ?= $(call make_tuple,$(XLEN),linux-gnu) NEWLIB_TUPLE ?= $(call make_tuple,$(XLEN),elf) MUSL_TUPLE ?= $(call make_tuple,$(XLEN),linux-musl) diff --git a/README.md b/README.md index a0004f3d7ae..ec8144484da 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,15 @@ If `make check-binutils` errors, check the [following documentation](./macos-bui When `make check-binutils` finishes successfully, you run the build normally with `make` or `make linux`. +### Big Endian configuration + +To build either cross-compiler with support for big endian targets, run the following command: + +``` +./configure --prefix=/opt/riscv --with-endian=big +make (target) +``` + ### Troubleshooting Build Problems Builds work best if installing into an empty directory. If you build a diff --git a/configure b/configure index 2fc589e7db6..c61a3679220 100755 --- a/configure +++ b/configure @@ -641,6 +641,7 @@ configure_host target_cxxflags target_cflags cmodel +endian gcc_checking musl_multilib_names newlib_multilib_names @@ -730,6 +731,7 @@ with_multilib_generator with_extra_multilib_test enable_gcc_checking with_cmodel +with_endian with_target_cflags with_target_cxxflags with_host @@ -1426,6 +1428,7 @@ Optional Packages: --with-extra-multilib-test="rv64gcv-lp64;rv64gcv_zba-lp64" --with-cmodel Select the code model to use when building libc and libgcc [--with-cmodel=medlow] + --with-endian Select the target endianess [--with-endian=little] --with-target-cflags Add extra target flags for C for library code --with-target-cxxflags Add extra target flags for C++ for library code --with-host=x86_64-w64-mingw32 @@ -4080,6 +4083,19 @@ WITH_SIM=$with_sim WITH_LANGUAGES=$with_languages +# Check whether --with-endian was given. +if test "${with_endian+set}" = set; then : + withval=$with_endian; +fi + +if test "x$with_endian" != x; then : + endian=$with_endian + +else + endian=little + +fi + # Check whether --enable-multilib was given. if test ${enable_multilib+y} then : @@ -4138,7 +4154,12 @@ fi if test "x$enable_multilib" = xyes then : - glibc_multilib_names="rv32imac-ilp32 rv32gc-ilp32d rv64imac-lp64 rv64gc-lp64d rv64gcv-lp64d" + glibc_multilib_names="rv32imac-ilp32 rv32gc-ilp32d rv64imac-lp64 rv64gc-lp64d" + # Vector extension is currently not supported on Big-endian systems. + if test "x$endian" = xlittle + then : + glibc_multilib_names+=" rv64gcv-lp64d" + fi else $as_nop glibc_multilib_names="$with_arch-$with_abi" @@ -4164,16 +4185,18 @@ else $as_nop fi # Check whether --enable-gcc-checking was given. -if test ${enable_gcc_checking+y} +if test ${enable_gcc_checking+y} && test "x$endian" = xlittle then : enableval=$enable_gcc_checking; fi - -if test "x$enable_gcc_checking" = xyes +# FIXME: Stage1 self-tests fail on BE builds due to lack of RVV support. Disable them for now. +if test "x$enable_gcc_checking" = xyes && "x$endian" = xlittle then : gcc_checking=--enable-checking - +elif test "x$endian" = xbig +then : + gcc_checking="--enable-checking=no --disable-stage1-checking" else $as_nop gcc_checking="" diff --git a/configure.ac b/configure.ac index 80ca038bbe0..bae4c57ffae 100644 --- a/configure.ac +++ b/configure.ac @@ -188,6 +188,10 @@ AS_IF([test "x$with_cmodel" != xno], [AC_SUBST(cmodel, -mcmodel=$with_cmodel)], [AC_SUBST(cmodel, -mcmodel=medlow)]) +AS_IF([test "x$with_endian" != x], + [AC_SUBST(endian, endian=$with_endian)], + [AC_SUBST(endian, endian=little)]) + AC_ARG_WITH(target_cflags, [AS_HELP_STRING([--with-target-cflags], [Add extra target flags for C for library code])],