Skip to content

Commit

Permalink
FEAT(loongarch): Support loongarch with 8u402
Browse files Browse the repository at this point in the history
--story=117047250
  • Loading branch information
shouhuanxiaoji authored and shiyuexw committed Apr 19, 2024
1 parent c5e90d7 commit ed6b242
Show file tree
Hide file tree
Showing 413 changed files with 112,423 additions and 205 deletions.
3 changes: 3 additions & 0 deletions common/autoconf/build-aux/autoconf-config.guess
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
loongarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
or32:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
Expand Down
1 change: 1 addition & 0 deletions common/autoconf/build-aux/autoconf-config.sub
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ case $basic_machine in
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| loongarch | loongarch64 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep \
| mips | mipsbe | mipseb | mipsel | mipsle \
Expand Down
11 changes: 11 additions & 0 deletions common/autoconf/build-aux/config.guess
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,15 @@ if [ "x$OUT" = x ]; then
fi
fi

# Test and fix little endian MIPS.
if [ "x$OUT" = x ]; then
if [ `uname -s` = Linux ]; then
if [ `uname -m` = mipsel ]; then
OUT=mipsel-unknown-linux-gnu
elif [ `uname -m` = mips64el ]; then
OUT=mips64el-unknown-linux-gnu
fi
fi
fi

echo $OUT
7 changes: 7 additions & 0 deletions common/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
# questions.
#

#
# This file has been modified by Loongson Technology in 2018. These
# modifications are Copyright (c) 2018 Loongson Technology, and are made
# available on the same license terms set forth above.
#

###############################################################################
#
# Includes and boilerplate
Expand Down Expand Up @@ -186,6 +192,7 @@ FLAGS_SETUP_INIT_FLAGS
# Now we can test some aspects on the target using configure macros.
PLATFORM_SETUP_OPENJDK_TARGET_BITS
PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
GET_BUILDER_AND_HOST_DATA

# Configure flags for the tools
FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS
Expand Down
84 changes: 84 additions & 0 deletions common/autoconf/generated-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ SET_EXECUTABLE_ORIGIN
SHARED_LIBRARY_FLAGS
CXX_FLAG_REORDER
C_FLAG_REORDER
HOST_NAME
BUILDER_NAME
BUILDER_ID
SYSROOT_LDFLAGS
SYSROOT_CFLAGS
RC_FLAGS
Expand Down Expand Up @@ -4069,6 +4072,12 @@ fi
# questions.
#

#
# This file has been modified by Loongson Technology in 2022. These
# modifications are Copyright (c) 2018, 2022, Loongson Technology, and are made
# available on the same license terms set forth above.
#

# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
# Converts autoconf style CPU name to OpenJDK style, into
# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
Expand Down Expand Up @@ -13918,6 +13927,18 @@ test -n "$target_alias" &&
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
mips64el)
VAR_CPU=mips64
VAR_CPU_ARCH=mips
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
loongarch64)
VAR_CPU=loongarch64
VAR_CPU_ARCH=loongarch
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
*)
as_fn_error $? "unsupported cpu $build_cpu" "$LINENO" 5
;;
Expand Down Expand Up @@ -14056,6 +14077,18 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; }
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
mips64el)
VAR_CPU=mips64
VAR_CPU_ARCH=mips
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
loongarch64)
VAR_CPU=loongarch64
VAR_CPU_ARCH=loongarch
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
*)
as_fn_error $? "unsupported cpu $host_cpu" "$LINENO" 5
;;
Expand Down Expand Up @@ -14178,6 +14211,8 @@ $as_echo "$COMPILE_TYPE" >&6; }
OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
elif test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
OPENJDK_TARGET_CPU_LEGACY_LIB="mips64el"
fi


Expand Down Expand Up @@ -14211,6 +14246,9 @@ $as_echo "$COMPILE_TYPE" >&6; }
elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
# On all platforms except macosx, we replace x86_64 with amd64.
OPENJDK_TARGET_CPU_OSARCH="amd64"
elif test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
# System.getProperty("os.arch"): mips64 -> mips64el
OPENJDK_TARGET_CPU_OSARCH="mips64el"
fi


Expand All @@ -14220,6 +14258,8 @@ $as_echo "$COMPILE_TYPE" >&6; }
elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
# On all platforms except macosx, we replace x86_64 with amd64.
OPENJDK_TARGET_CPU_JLI="amd64"
elif test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
OPENJDK_TARGET_CPU_JLI="mips64el"
fi
# Now setup the -D flags for building libjli.
OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
Expand All @@ -14232,6 +14272,9 @@ $as_echo "$COMPILE_TYPE" >&6; }
elif test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$TOOLCHAIN_TYPE" = xclang ; then
OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -stdlib=libc++ -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
fi
if test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"mips32el\"' -DLIBARCH64NAME='\"mips64el\"'"
fi


# Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
Expand Down Expand Up @@ -42412,6 +42455,47 @@ $as_echo "$ac_cv_c_bigendian" >&6; }
fi


BUILDER_NAME="$build_os"
BUILDER_ID="Custom build ($(date))"
if test -f /etc/issue; then
etc_issue_info=`cat /etc/issue`
if test -n "$etc_issue_info"; then
BUILDER_NAME=`cat /etc/issue | head -n 1 | cut -d " " -f 1`
fi
fi
if test -f /etc/redhat-release; then
etc_issue_info=`cat /etc/redhat-release`
if test -n "$etc_issue_info"; then
BUILDER_NAME=`cat /etc/redhat-release | head -n 1 | cut -d " " -f 1`
fi
fi
if test -f /etc/neokylin-release; then
etc_issue_info=`cat /etc/neokylin-release`
if test -n "$etc_issue_info"; then
BUILDER_NAME=`cat /etc/neokylin-release | head -n 1 | cut -d " " -f 1`
fi
fi
if test -z "$BUILDER_NAME"; then
BUILDER_NAME="unknown"
fi
BUILDER_NAME=`echo $BUILDER_NAME | sed -r "s/-//g"`
if test -n "$OPENJDK_TARGET_CPU_OSARCH"; then
HOST_NAME="$OPENJDK_TARGET_CPU_OSARCH"
else
HOST_NAME="unknown"
fi
if test -f "/usr/bin/cpp"; then
# gcc_with_arch_info=`gcc -v 2>&1 | grep '\-\-with-arch=' | sed 's/.*--with-arch=//;s/ .*$//'`
gcc_with_arch_info=`cpp -dM /dev/null | grep '\<_MIPS_ARCH\>' | sed 's/^#define _MIPS_ARCH "//;s/"$//'`
if test -n "$gcc_with_arch_info"; then
HOST_NAME="$gcc_with_arch_info"
fi
fi





# Configure flags for the tools

###############################################################################
Expand Down
71 changes: 71 additions & 0 deletions common/autoconf/platform.m4
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
# questions.
#

#
# This file has been modified by Loongson Technology in 2022. These
# modifications are Copyright (c) 2018, 2022, Loongson Technology, and are made
# available on the same license terms set forth above.
#

# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
# Converts autoconf style CPU name to OpenJDK style, into
# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
Expand Down Expand Up @@ -96,6 +102,18 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
mips64el)
VAR_CPU=mips64
VAR_CPU_ARCH=mips
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
loongarch64)
VAR_CPU=loongarch64
VAR_CPU_ARCH=loongarch
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
*)
AC_MSG_ERROR([unsupported cpu $1])
;;
Expand Down Expand Up @@ -283,6 +301,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
elif test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
OPENJDK_TARGET_CPU_LEGACY_LIB="mips64el"
fi
AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
Expand Down Expand Up @@ -316,6 +336,9 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
# On all platforms except macosx, we replace x86_64 with amd64.
OPENJDK_TARGET_CPU_OSARCH="amd64"
elif test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
# System.getProperty("os.arch"): mips64 -> mips64el
OPENJDK_TARGET_CPU_OSARCH="mips64el"
fi
AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
Expand All @@ -325,6 +348,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
# On all platforms except macosx, we replace x86_64 with amd64.
OPENJDK_TARGET_CPU_JLI="amd64"
elif test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
OPENJDK_TARGET_CPU_JLI="mips64el"
fi
# Now setup the -D flags for building libjli.
OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
Expand All @@ -337,6 +362,9 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
elif test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$TOOLCHAIN_TYPE" = xclang ; then
OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -stdlib=libc++ -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
fi
if test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"mips32el\"' -DLIBARCH64NAME='\"mips64el\"'"
fi
AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
# Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
Expand Down Expand Up @@ -550,3 +578,46 @@ AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
AC_MSG_ERROR([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
fi
])

AC_DEFUN([GET_BUILDER_AND_HOST_DATA],
[
BUILDER_NAME="$build_os"
BUILDER_ID="Custom build ($(date))"
if test -f /etc/issue; then
etc_issue_info=`cat /etc/issue`
if test -n "$etc_issue_info"; then
BUILDER_NAME=`cat /etc/issue | head -n 1 | cut -d " " -f 1`
fi
fi
if test -f /etc/redhat-release; then
etc_issue_info=`cat /etc/redhat-release`
if test -n "$etc_issue_info"; then
BUILDER_NAME=`cat /etc/redhat-release | head -n 1 | cut -d " " -f 1`
fi
fi
if test -f /etc/neokylin-release; then
etc_issue_info=`cat /etc/neokylin-release`
if test -n "$etc_issue_info"; then
BUILDER_NAME=`cat /etc/neokylin-release | head -n 1 | cut -d " " -f 1`
fi
fi
if test -z "$BUILDER_NAME"; then
BUILDER_NAME="unknown"
fi
BUILDER_NAME=`echo $BUILDER_NAME | sed -r "s/-//g"`
if test -n "$OPENJDK_TARGET_CPU_OSARCH"; then
HOST_NAME="$OPENJDK_TARGET_CPU_OSARCH"
else
HOST_NAME="unknown"
fi
if test -f "/usr/bin/cpp"; then
# gcc_with_arch_info=`gcc -v 2>&1 | grep '\-\-with-arch=' | sed 's/.*--with-arch=//;s/ .*$//'`
gcc_with_arch_info=`cpp -dM /dev/null | grep '\<_MIPS_ARCH\>' | sed 's/^#define _MIPS_ARCH "//;s/"$//'`
if test -n "$gcc_with_arch_info"; then
HOST_NAME="$gcc_with_arch_info"
fi
fi
AC_SUBST(BUILDER_ID)
AC_SUBST(BUILDER_NAME)
AC_SUBST(HOST_NAME)
])
23 changes: 23 additions & 0 deletions common/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
# questions.
#

#
# This file has been modified by Loongson Technology in 2023. These
# modifications are Copyright (c) 2018, 2023, Loongson Technology, and are made
# available on the same license terms set forth above.
#

# Configured @DATE_WHEN_CONFIGURED@ to build
# for target system @OPENJDK_TARGET_OS@-@OPENJDK_TARGET_CPU@
# (called @OPENJDK_TARGET_AUTOCONF_NAME@ by autoconf)
Expand Down Expand Up @@ -219,6 +225,23 @@ else
endif
JRE_RELEASE_VERSION:=$(FULL_VERSION)

# Build OS and host values for use in Loongson OpenJDK release
BUILDER_ID:=@BUILDER_ID@
BUILDER_NAME:=@BUILDER_NAME@
HOST_NAME:=@HOST_NAME@

# Loongson OpenJDK Version info
VER=8.1.18
ifeq ($(HOST_NAME), )
HOST_NAME=unknown
endif
ifeq ($(BUILDER_NAME), )
BUILDER_NAME=unknown
endif
HOST_NAME_STRING=-$(HOST_NAME)
BUILDER_NAME_STRING=-$(BUILDER_NAME)
LOONGSON_RUNTIME_NAME=Loongson $(VER)$(HOST_NAME_STRING)$(BUILDER_NAME_STRING)

# How to compile the code: release, fastdebug or slowdebug
DEBUG_LEVEL:=@DEBUG_LEVEL@

Expand Down
14 changes: 14 additions & 0 deletions hotspot/agent/make/saenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
#
#

#
# This file has been modified by Loongson Technology in 2020. These
# modifications are Copyright (c) 2015, 2020, Loongson Technology, and are made
# available on the same license terms set forth above.
#

# This file sets common environment variables for all SA scripts

OS=`uname`
Expand All @@ -42,6 +48,14 @@ if [ "$OS" = "Linux" ]; then
SA_LIBPATH=$STARTDIR/../src/os/linux/amd64:$STARTDIR/linux/amd64
OPTIONS="-Dsa.library.path=$SA_LIBPATH"
CPU=amd64
elif [ "$ARCH" = "mips64" ] ; then
SA_LIBPATH=$STARTDIR/../src/os/linux/mips:$STARTDIR/linux/mips
OPTIONS="-Dsa.library.path=$SA_LIBPATH"
CPU=mips
elif [ "$ARCH" = "loongarch64" ] ; then
SA_LIBPATH=$STARTDIR/../src/os/linux/loongarch64:$STARTDIR/linux/loongarch64
OPTIONS="-Dsa.library.path=$SA_LIBPATH"
CPU=loongarch64
else
SA_LIBPATH=$STARTDIR/../src/os/linux/i386:$STARTDIR/linux/i386
OPTIONS="-Dsa.library.path=$SA_LIBPATH"
Expand Down
Loading

0 comments on commit ed6b242

Please sign in to comment.