Skip to content

Commit

Permalink
Update configure scripts for RISC-V in OMR (part1/misc)
Browse files Browse the repository at this point in the history
The changes mainly include configure scripts
to enable RISC-V 64bit from the OMR perspective.

Issue: #4426

Signed-off-by: Cheng Jin <jincheng@ca.ibm.com>
  • Loading branch information
ChengJin01 committed Oct 10, 2019
1 parent bd76df0 commit 030aed3
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 11 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Expand Up @@ -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)
<br/>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -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?
Expand Down
12 changes: 11 additions & 1 deletion 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
Expand Down Expand Up @@ -70,6 +70,9 @@
#ifndef ARCH_ARM64
# define ARCH_ARM64 105
#endif
#ifndef ARCH_RISCV
# define ARCH_RISCV 106
#endif

/* Compilers */
#ifndef COMPILER_GCC
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
51 changes: 46 additions & 5 deletions configure
Expand Up @@ -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
Expand Down Expand Up @@ -790,6 +791,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}'
Expand Down Expand Up @@ -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=* \
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
;;
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)"}
Expand Down Expand Up @@ -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 :
Expand Down
12 changes: 9 additions & 3 deletions configure.ac
Expand Up @@ -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).])
Expand Down Expand Up @@ -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)"}
Expand Down Expand Up @@ -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],
Expand Down
1 change: 1 addition & 0 deletions doc/GuideForCommitters.md
Expand Up @@ -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:
```
Expand Down
106 changes: 106 additions & 0 deletions 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'
5 changes: 4 additions & 1 deletion 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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tools/configure
Expand Up @@ -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
Expand Down Expand Up @@ -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
;;
Expand Down

0 comments on commit 030aed3

Please sign in to comment.