diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 908d886c5dd..33b54f8a859 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,6 +127,7 @@ can be achieved with the following labels: * [**`arch:aarch32`**](https://github.com/eclipse/omr/labels/arch%3Aaarch32) * [**`arch:aarch64`**](https://github.com/eclipse/omr/labels/arch%3Aaarch64) * [**`arch:power`**](https://github.com/eclipse/omr/labels/arch%3Apower) +* [**`arch:riscv`**](https://github.com/eclipse/omr/labels/arch%3Ariscv) * [**`arch:x86`**](https://github.com/eclipse/omr/labels/arch%3Ax86) * [**`arch:z`**](https://github.com/eclipse/omr/labels/arch%3Az)
diff --git a/README.md b/README.md index 7951182d9b1..aea6a508451 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-excepti | **Linux Power 64-bit** | [![Build-linux_ppc-64_le_gcc Status](https://ci.eclipse.org/omr/job/Build-linux_ppc-64_le_gcc/badge/icon)](https://ci.eclipse.org/omr/job/Build-linux_ppc-64_le_gcc/) | | **AIX Power 64-bit** | [![Build-aix_ppc-64 Status](https://ci.eclipse.org/omr/job/Build-aix_ppc-64/badge/icon)](https://ci.eclipse.org/omr/job/Build-aix_ppc-64/) | | **Linux Z (s390x) 64-bit** | [![Build-linux_390-64 Status](https://ci.eclipse.org/omr/job/Build-linux_390-64/badge/icon)](https://ci.eclipse.org/omr/job/Build-linux_390-64/) | +| **Linux RISCV 64-bit** | [![Linux RISCV-64 Status](https://ci.eclipse.org/omr/job/Build-linux_riscv64/badge/icon)](https://ci.eclipse.org/omr/job/Build-linux_riscv64/) | +| **Linux RISCV 64-bit Compressed Pointers** | [![Build Status](https://ci.eclipse.org/omr/job/Build-linux_riscv64_cmprssptrs/badge/icon)](https://ci.eclipse.org/omr/job/Build-linux_riscv64_cmprssptrs/) | What Is Eclipse OMR? diff --git a/compiler/env/defines.h b/compiler/env/defines.h index b43208833aa..babe386bfe6 100644 --- a/compiler/env/defines.h +++ b/compiler/env/defines.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corp. and others + * Copyright (c) 2000, 2019 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -70,6 +70,9 @@ #ifndef ARCH_ARM64 # define ARCH_ARM64 105 #endif +#ifndef ARCH_RISCV +# define ARCH_RISCV 106 +#endif /* Compilers */ #ifndef COMPILER_GCC @@ -136,6 +139,9 @@ #elif defined(__aarch64__) # define HOST_ARCH ARCH_ARM64 # define TR_HOST_64BIT 1 +#elif defined(__riscv) && defined(J9RISCV64) +# define HOST_ARCH ARCH_RISCV64 +# define TR_HOST_64BIT 1 #else # error "defines.h: unknown architecture" #endif @@ -180,6 +186,10 @@ # define TR_HOST_ARM64 1 #endif +#if (HOST_ARCH == ARCH_RISCV64) +# define TR_HOST_RISCV64 1 +#endif + /* @ddr_namespace: default */ /* FIXME: we need to document what these ifdefs do diff --git a/configure b/configure index bba67b1afc8..eceffcce9d8 100755 --- a/configure +++ b/configure @@ -685,6 +685,7 @@ OMR_INTERP_SMALL_MONITOR_SLOT OMR_INTERP_COMPRESSED_OBJECT_HEADER OMR_GC_COMPRESSED_POINTERS OMR_ENV_DATA64 +OMR_ARCH_RISCV OMR_ARCH_S390 OMR_ARCH_X86 OMR_ARCH_AARCH64 @@ -790,6 +791,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -868,6 +870,7 @@ enable_OMR_ARCH_ARM enable_OMR_ARCH_AARCH64 enable_OMR_ARCH_X86 enable_OMR_ARCH_S390 +enable_OMR_ARCH_RISCV enable_OMR_ENV_DATA64 enable_OMR_GC_COMPRESSED_POINTERS enable_OMR_INTERP_COMPRESSED_OBJECT_HEADER @@ -965,6 +968,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1217,6 +1221,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1354,7 +1367,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1507,6 +1520,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1641,6 +1655,7 @@ Optional Features: --enable-OMR_ARCH_X86 --enable-OMR_ARCH_S390 + --enable-OMR_ARCH_RISCV --enable-OMR_ENV_DATA64 --enable-OMR_GC_COMPRESSED_POINTERS @@ -1715,7 +1730,7 @@ Some influential environment variables: aix,linux,osx,win,zos OMR_HOST_ARCH The architecture of the CPU where the package will run. One of: - aarch64,arm,ppc,s390,x86 + aarch64,arm,ppc,riscv,s390,x86 OMR_TARGET_DATASIZE Specifies whether the package will run in 32- or 64-bit mode. One of: 31,32,64 @@ -2688,7 +2703,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ############################################################################### -# Copyright (c) 2015, 2018 IBM Corp. and others +# Copyright (c) 2015, 2019 IBM Corp. and others # # This program and the accompanying materials are made available under # the terms of the Eclipse Public License 2.0 which accompanies this @@ -3048,6 +3063,8 @@ if test "x$OMR_HOST_ARCH" = "x"; then : OMR_HOST_ARCH=x86 ;; #( x86_64) : OMR_HOST_ARCH=x86 ;; #( + riscv64) : + OMR_HOST_ARCH=riscv ;; #( *) : as_fn_error $? "Unable to derive OMR_HOST_ARCH from host_cpu: $host_cpu" "$LINENO" 5 ;; @@ -4397,7 +4414,11 @@ OMRGLUE=${OMRGLUE:-"./example/glue"} ## Default Variables # Set program defaults if they are undefined -ac_ext=c +# Note: Compilers have already been set up for cross-compiling in the case of RISC-V. +# Thus, the corresponding detection tests are invalid. +if test "x$OMR_CROSS_CONFIGURE" != "xyes" -o "x$OMR_HOST_ARCH" != "xriscv"; +then + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -4936,7 +4957,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_ext=cpp + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -5193,6 +5214,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +fi CCLINK=${CCLINK:-"\$(CC)"} CCLINKSHARED=${CCLINKSHARED:-"\$(CCLINK)"} @@ -6212,6 +6234,25 @@ else fi +# Check whether --enable-OMR_ARCH_RISCV was given. +if test "${enable_OMR_ARCH_RISCV+set}" = set; then : + enableval=$enable_OMR_ARCH_RISCV; if test "x${enableval}" = xyes; then : + OMR_ARCH_RISCV=1 + + $as_echo "#define OMR_ARCH_RISCV 1" >>confdefs.h + +else + OMR_ARCH_RISCV=0 + + +fi +else + OMR_ARCH_RISCV=0 + + +fi + + # Check whether --enable-OMR_ENV_DATA64 was given. if test "${enable_OMR_ENV_DATA64+set}" = set; then : diff --git a/configure.ac b/configure.ac index 57cb0b7ba71..c4340d468d5 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_ARG_VAR([OMRGLUE_INCLUDES], [Extra include directories to be passed to the C AC_ARG_VAR([lib_output_dir], [The output directory for libraries. (Default: $top_srcdir/lib)]) AC_ARG_VAR([exe_output_dir], [The output directory for executables. (Default: $top_srcdir)]) AC_ARG_VAR([OMR_HOST_OS], [The operating system where the package will run. One of: aix,linux,osx,win,zos]) -AC_ARG_VAR([OMR_HOST_ARCH], [The architecture of the CPU where the package will run. One of: aarch64,arm,ppc,s390,x86]) +AC_ARG_VAR([OMR_HOST_ARCH], [The architecture of the CPU where the package will run. One of: aarch64,arm,ppc,riscv,s390,x86]) AC_ARG_VAR([OMR_TARGET_DATASIZE], [Specifies whether the package will run in 32- or 64-bit mode. One of: 31,32,64]) AC_ARG_VAR([OMR_TOOLCHAIN], [The toolchain used to build the package. One of: gcc,xlc,msvc]) AC_ARG_VAR([OMR_TOOLS_CC], [The C compiler to use for building tools (can differ from CC).]) @@ -219,8 +219,13 @@ OMRGLUE=${OMRGLUE:-"./example/glue"} ## Default Variables # Set program defaults if they are undefined -AC_PROG_CC() -AC_PROG_CXX() +# Note: Compilers have already been set up for cross-compiling in the case of RISC-V. +# Thus, the corresponding detection tests are invalid. +if test "x$OMR_CROSS_CONFIGURE" != "xyes" -o "x$OMR_HOST_ARCH" != "xriscv"; +then + AC_PROG_CC() + AC_PROG_CXX() +fi CCLINK=${CCLINK:-"\$(CC)"} CCLINKSHARED=${CCLINKSHARED:-"\$(CCLINK)"} @@ -421,6 +426,7 @@ OMRCFG_DEFINE_FLAG_OFF([OMR_ARCH_ARM]) OMRCFG_DEFINE_FLAG_OFF([OMR_ARCH_AARCH64]) OMRCFG_DEFINE_FLAG_OFF([OMR_ARCH_X86]) OMRCFG_DEFINE_FLAG_OFF([OMR_ARCH_S390]) +OMRCFG_DEFINE_FLAG_OFF([OMR_ARCH_RISCV]) OMRCFG_DEFINE_FLAG([OMR_ENV_DATA64],[], [AS_IF([test "$OMR_TARGET_DATASIZE" = 64], diff --git a/doc/GuideForCommitters.md b/doc/GuideForCommitters.md index e71f8e976df..12f002c9786 100644 --- a/doc/GuideForCommitters.md +++ b/doc/GuideForCommitters.md @@ -106,6 +106,7 @@ following tags: | osx | 64-bit macOS | | arm | 32-bit AArch32 (cross-compile build only) | | aarch64 | 64-bit AArch64 (cross-compile build only) | +| riscv64 | 64-bit RISCV (cross-compile build & native-compile build) | For example, to launch a pull request build on all platforms: ``` diff --git a/example/glue/configure_includes/configure_linux_riscv.mk b/example/glue/configure_includes/configure_linux_riscv.mk new file mode 100644 index 00000000000..c731c484954 --- /dev/null +++ b/example/glue/configure_includes/configure_linux_riscv.mk @@ -0,0 +1,106 @@ +############################################################################### +# Copyright (c) 2019, 2019 IBM Corp. and others +# +# This program and the accompanying materials are made available under +# the terms of the Eclipse Public License 2.0 which accompanies this +# distribution and is available at http://eclipse.org/legal/epl-2.0 +# or the Apache License, Version 2.0 which accompanies this distribution +# and is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception [1] and GNU General Public +# License, version 2 with the OpenJDK Assembly Exception [2]. +# +# [1] https://www.gnu.org/software/classpath/license.html +# [2] http://openjdk.java.net/legal/assembly-exception.html +# +# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception +############################################################################### + +include $(CONFIG_INCL_DIR)/configure_common.mk + +RISCV_CROSSTOOLS_PREFIX=riscv64-unknown-linux-gnu + +ifneq (,$(findstring _riscv64, $(SPEC))) + RISCV_TARGET=riscv64-unknown-linux-gnu +else + RISCV_TARGET=riscv32-unknown-linux-gnu +endif + +CONFIGURE_ARGS += \ + --host=$(RISCV_TARGET) \ + --target=$(RISCV_TARGET) + +ifneq (,$(findstring _cross, $(SPEC))) +CONFIGURE_ARGS += \ + --build=x86_64-pc-linux-gnu \ + 'OMR_CROSS_CONFIGURE=yes' +else +CONFIGURE_ARGS += \ + --build=riscv64-pc-linux-gnu +endif + +CONFIGURE_ARGS += \ + --enable-OMR_EXAMPLE \ + --enable-OMR_GC \ + --enable-OMR_PORT \ + --enable-OMR_TEST_COMPILER \ + --enable-OMR_THREAD \ + --enable-OMR_OMRSIG \ + --enable-OMR_THR_THREE_TIER_LOCKING \ + --enable-OMR_THR_YIELD_ALG \ + --enable-OMR_THR_SPIN_WAKE_CONTROL \ + --enable-OMRTHREAD_LIB_UNIX \ + --enable-OMR_ARCH_RISCV \ + --enable-OMR_ENV_LITTLE_ENDIAN \ + --enable-OMR_GC_TLH_PREFETCH_FTA \ + --enable-OMR_PORT_CAN_RESERVE_SPECIFIC_ADDRESS \ + --enable-OMR_THR_FORK_SUPPORT \ + --enable-OMR_GC_ARRAYLETS + +ifneq (,$(findstring _riscv64, $(SPEC))) + CONFIGURE_ARGS += \ + --enable-OMR_ENV_DATA64 \ + 'OMR_TARGET_DATASIZE=64' +else + CONFIGURE_ARGS += \ + 'OMR_TARGET_DATASIZE=32' +endif + +ifneq (,$(findstring _cmprssptrs, $(SPEC))) + CONFIGURE_ARGS += \ + --enable-OMR_GC_COMPRESSED_POINTERS \ + --enable-OMR_INTERP_COMPRESSED_OBJECT_HEADER \ + --enable-OMR_INTERP_SMALL_MONITOR_SLOT +endif + +CONFIGURE_ARGS += libprefix=lib exeext= solibext=.so arlibext=.a objext=.o + +ifneq (,$(findstring _cross, $(SPEC))) + AR=$(RISCV_CROSSTOOLS_PREFIX)-ar + AS=$(RISCV_CROSSTOOLS_PREFIX)-as + CC=$(RISCV_CROSSTOOLS_PREFIX)-gcc $(SYSROOT_CFLAGS) + CXX=$(RISCV_CROSSTOOLS_PREFIX)-c++ $(SYSROOT_CFLAGS) + OBJCOPY=$(RISCV_CROSSTOOLS_PREFIX)-objcopy +else + AR=ar + AS=as + CC=gcc + CXX=c++ + OBJCOPY=objcopy +endif + +CONFIGURE_ARGS += 'AR=$(AR)' +CONFIGURE_ARGS += 'AS=$(AS)' +CONFIGURE_ARGS += 'CC=$(CC)' +CONFIGURE_ARGS += 'CXX=$(CXX)' +CONFIGURE_ARGS += 'OBJCOPY=$(OBJCOPY)' +CONFIGURE_ARGS += 'CCLINK=$$(CC)' +CONFIGURE_ARGS += 'CXXLINKSHARED=$$(CC)' +CONFIGURE_ARGS += 'CXXLINKEXE=$$(CXX)' + +CONFIGURE_ARGS += 'OMR_HOST_OS=linux' +CONFIGURE_ARGS += 'OMR_HOST_ARCH=riscv' +CONFIGURE_ARGS += 'OMR_TOOLCHAIN=gcc' diff --git a/run_configure.mk b/run_configure.mk index fc392ea8288..e66b31b96d8 100644 --- a/run_configure.mk +++ b/run_configure.mk @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2015, 2018 IBM Corp. and others +# Copyright (c) 2015, 2019 IBM Corp. and others # # This program and the accompanying materials are made available under # the terms of the Eclipse Public License 2.0 which accompanies this @@ -77,6 +77,9 @@ endif ifneq (,$(findstring linux_ppc,$(SPEC))) include $(CONFIG_INCL_DIR)/configure_linux_ppc.mk endif +ifneq (,$(findstring linux_riscv,$(SPEC))) + include $(CONFIG_INCL_DIR)/configure_linux_riscv.mk +endif ifneq (,$(findstring linux_x86,$(SPEC))) include $(CONFIG_INCL_DIR)/configure_linux_x86.mk endif diff --git a/tools/configure b/tools/configure index 8df7aeec5f2..ec60cd62884 100755 --- a/tools/configure +++ b/tools/configure @@ -2131,7 +2131,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ############################################################################### -# Copyright (c) 2015, 2016 IBM Corp. and others +# Copyright (c) 2015, 2019 IBM Corp. and others # # This program and the accompanying materials are made available under # the terms of the Eclipse Public License 2.0 which accompanies this @@ -2297,6 +2297,8 @@ case $build_cpu in #( OMR_BUILD_ARCH=x86 ;; #( x86_64) : OMR_BUILD_ARCH=x86 ;; #( + riscv64) : + OMR_BUILD_ARCH=riscv ;; #( *) : as_fn_error $? "Unable to derive OMR_BUILD_ARCH from build_cpu: $build_cpu" "$LINENO" 5 ;;