openjdk-9-headless: make it build (at least on arm) (#820)

switch from jdk9/dev to mobile/dev repo
switch from tag based to changeset based build
add patch to use our getgr{gid,nam}_r from grp.h
remove all old patches
clean up code big time (no more custom patch format)
This commit is contained in:
Vishal Biswas 2017-03-05 18:53:52 +05:30 committed by Fredrik Fornwall
parent 67d2d61527
commit 77b0e69667
4 changed files with 109 additions and 265 deletions

View File

@ -2,119 +2,110 @@ TERMUX_PKG_HOMEPAGE=http://openjdk.java.net
TERMUX_PKG_DESCRIPTION='OpenJDK 9 Java Runtime Environment (prerelease)'
_jbuild=158
_hg_tag="jdk-9+${_jbuild}"
TERMUX_PKG_VERSION="9b$_jbuild"
TERMUX_PKG_VERSION="9.2017.3.3"
TERMUX_PKG_MAINTAINER='Vishal Biswas @vishalbiswas'
TERMUX_PKG_DEPENDS="freetype, alsa-lib"
TERMUX_PKG_DEPENDS="freetype, libpng, libffi"
# currently upstream has no support building for these arches on android
# this will change in the future
TERMUX_PKG_BLACKLISTED_ARCHES="aarch64 x86_64"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-hotspot-gtest
--disable-option-checking
--disable-warnings-as-errors
--enable-headless-only
--with-debug-level=release
--with-libffi-include=$TERMUX_PREFIX/include
--with-libffi-lib=$TERMUX_PREFIX/lib
--with-libffi=$TERMUX_PREFIX
--with-freetype=$TERMUX_PREFIX
--with-libpng=system
--with-zlib=system
"
TERMUX_PKG_CLANG=no
_cups_ver=2.2.2
termux_step_extract_package () {
_url_src=http://hg.openjdk.java.net/jdk9/dev
targzs=(${_url_src}/archive/$_hg_tag.tar.bz2
${_url_src}/corba/archive/$_hg_tag.tar.bz2
${_url_src}/hotspot/archive/$_hg_tag.tar.bz2
${_url_src}/jdk/archive/$_hg_tag.tar.bz2
${_url_src}/jaxws/archive/$_hg_tag.tar.bz2
${_url_src}/jaxp/archive/$_hg_tag.tar.bz2
${_url_src}/langtools/archive/$_hg_tag.tar.bz2
${_url_src}/nashorn/archive/$_hg_tag.tar.bz2
"https://github.com/apple/cups/releases/download/v$_cups_ver/cups-$_cups_ver-source.tar.gz")
changesets=('84493751ba37'
'6feea77d2083'
'95ce736479b8'
'e45f1067d76b'
'0ea34706c7fa'
'5695854e8831'
'39449d2a6398'
'd75af059cff6')
sha256sums=('d11fba6c6aea0d815bf37ec33b95a9eabf5cf6bd85c998d2a2945de610340a82'
'6c38a48a9a4095604b0feeaacad7fec6337186631a1d11b27215ad3b3f0f4e96'
'd646f5e0166b1877951540cac6b9eff6be130cb1324e5a63871104aad3b6d6f0'
'773d4420b556baaad69b06434b6e21b488cf8df1f437b3b83ddbbbd32e906e83'
'af5d86f1e2b4ac8773ee9e5cb799797c1e9c7e606a1618bfad0e4f7854b062d2'
'3d1b96268c6b1fc35f69b4e62be32a0a1b4ef299f95f2139b0c57b982d792869'
'94fb51401a4aa6387d0d35df4cba0d2e6560329ca842604be1752f8e4a253e33'
'23afc54946898ffc51d1e22a40a078c69441bd1c8b4a99b7e84d471e6ca1f302'
'f589bb7d5d1dc3aa0915d7cf2b808571ef2e1530cd1a6ebe76ae8f9f4994e4f6')
sha256sums=('8dba157e41bd3ffcec681d2dfc3141951f19c0a19a68d1e2568b314d0978c018'
'1a269f62e7e99b097fd7620c2ce995833336c1b79f03bd8a7af3f066f6099862'
'2fff75a970c4ae21620ece45dcb4015ec13cdfd265ab1746503adf786922d200'
'd58e2f4a7e8421a5f9396870d4a47f42dd41dfff1232e52add71410c75f35832'
'dcb0efdf5e633396957c18c0c8b54531c44d8f6c24d03c3f87cc9b41ff633957'
'7da207e287e6df85c955b5d7a45e7f747934dcaa15a12741d022c50ef89799e7'
'90980cd581b426a51fa22d77cbcb68e5ddea4c048a282cf82ef438e5da0a7bf0'
'f35e87e80ad01cec5d445e59d4b37ba55899651845081f76b6d56a348ca1ce97'
'f589bb7d5d1dc3aa0915d7cf2b808571ef2e1530cd1a6ebe76ae8f9f4994e4f6')
reponames=(dev corba hotspot jdk jaxws jaxp langtools nashorn cups)
reponames=(dev corba hotspot jdk jaxws jaxp langtools nashorn cups)
for index in "${!targzs[@]}"; do
if [ $index != '8' ]; then
filename=${reponames[index]}-`basename ${targzs[index]}`
folder=`basename $filename .tar.bz2`
folder=`echo $folder | sed 's/_/-/'`
else
filename=`basename ${targzs[index]}`
folder="cups-$_cups_ver"
fi
sum=${sha256sums[index]}
file=$TERMUX_PKG_CACHEDIR/$filename
termux_download ${targzs[index]} $file $sum
rm -Rf $folder
$TERMUX_TAR xf $file
mkdir -p $TERMUX_PKG_SRCDIR
mv $folder $TERMUX_PKG_SRCDIR/
done
}
_url_src=http://hg.openjdk.java.net/mobile/dev
TERMUX_PKG_SRCURL=$_url_src/archive/${changesets[0]}.tar.bz2
TERMUX_PKG_SHA256=${sha256sums[0]}
TERMUX_PKG_FOLDERNAME=dev-${changesets[0]}
termux_step_post_extract_package () {
for patch in $TERMUX_PKG_BUILDER_DIR/*.diff; do
sed "s%\@TAG_VER\@%${_jbuild}%g" "$patch" | \
patch --silent -p1
cd "$TERMUX_PKG_TMPDIR"
# download and extract repo archives
for index in {1..7}; do
local sum=${sha256sums[index]}
local repo=${reponames[index]}
local change=${changesets[index]}
local file=$TERMUX_PKG_CACHEDIR/$repo-$change.tar.bz2
local url=${_url_src}/$repo/archive/$change.tar.bz2
termux_download $url $file $sum
$TERMUX_TAR xf $file -C $TERMUX_PKG_SRCDIR
mv $TERMUX_PKG_SRCDIR/$repo-$change $TERMUX_PKG_SRCDIR/$repo
done
cd $TERMUX_PKG_SRCDIR/dev-$_hg_tag
chmod a+x configure
for subrepo in corba hotspot jdk jaxws jaxp langtools nashorn; do
ln -s ../${subrepo}-$_hg_tag ${subrepo}
done
ln -s ../cups-$_cups_ver cups
# setup cups source dir
file=$TERMUX_PKG_CACHEDIR/cups-$_cups_ver-source.tar.gz
url="https://github.com/apple/cups/releases/download/v$_cups_ver/`basename $file`"
termux_download $url $file ${sha256sums[8]}
$TERMUX_TAR xf $file -C $TERMUX_PKG_SRCDIR
}
# override this step to since openjdk provides their own customized guess scripts
termux_step_replace_guess_scripts () {
return
}
termux_step_pre_configure () {
TERMUX_PKG_SRCDIR=$TERMUX_PKG_SRCDIR/dev-$_hg_tag
#export MAKEFLAGS=${MAKEFLAGS/-j*}
#export CFLAGS+=" -Wno-error=deprecated-declarations -DSIGCLD=SIGCHLD"
CFLAGS="$CFLAGS -I$TERMUX_PKG_BUILDER_DIR -I$TERMUX_PREFIX/include -DTERMUX_SHMEM_STUBS"
CXXFLAGS="$CXXFLAGS -I$TERMUX_PKG_BUILDER_DIR -I$TERMUX_PREFIX/include"
#LDFLAGS="$LDFLAGS -landroid-shmem"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-cups-include=$TERMUX_PKG_SRCDIR/cups-$_cups_ver"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-cups-include=$TERMUX_PKG_SRCDIR/cups"
TERMUX_JVM_VARIANT=zero
if [ "$TERMUX_ARCH" == 'i686' -o "$TERMUX_ARCH" == 'x86_64' ]; then
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=' --with-jvm-variants=client'
TERMUX_PKG_JVM_VARIANT=client
else
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=' --with-jvm-variants=zero'
TERMUX_PKG_JVM_VARIANT=zero
fi
# might be required
# libffi dependency is required if zero interpreter is used
#if [ -o "$TERMUX_ARCH" == 'i686' -o "$TERMUX_ARCH" == 'x86_64' ]; then
# TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=' --with-jvm-variants=client'
#else
# TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=' --with-jvm-variants=zero'
#fi
cat > "$TERMUX_STANDALONE_TOOLCHAIN/devkit.info" <<HERE
DEVKIT_NAME="Android ${TERMUX_ARCH^^}"
DEVKIT_TOOLCHAIN_PATH="\$DEVKIT_ROOT/$TERMUX_HOST_PLATFORM/bin"
DEVKIT_SYSROOT="\$DEVKIT_ROOT/sysroot" i
DEVKIT_SYSROOT="\$DEVKIT_ROOT/sysroot"
HERE
export ANDROID_DEVKIT=$TERMUX_STANDALONE_TOOLCHAIN
cd $TERMUX_PKG_SRCDIR
if [ -n "$TERMUX_DEBUG" ]; then TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-debug-level=slowdebug"; fi
}
termux_step_configure () {
$TERMUX_PKG_SRCDIR/configure \
bash $TERMUX_PKG_SRCDIR/configure \
--prefix=$TERMUX_PREFIX \
--host=$TERMUX_HOST_PLATFORM \
--target=$TERMUX_HOST_PLATFORM \
--openjdk-target=$TERMUX_HOST_PLATFORM \
--with-jdk-variant=normal \
--libexecdir=$TERMUX_PREFIX/libexec \
--with-devkit=$ANDROID_DEVKIT \
--with-extra-cflags="$CFLAGS" \
--with-extra-cxxflags="$CXXFLAGS" \
--with-extra-cflags="$CPPFLAGS $CFLAGS" \
--with-extra-cxxflags="$CPPFLAGS $CXXFLAGS" \
--with-extra-ldflags="$LDFLAGS" \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS
}

View File

@ -0,0 +1,43 @@
--- ./jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2017-03-02 21:55:47.000000000 +0530
+++ ../UnixNativeDispatcher.c 2017-03-03 21:37:02.370375158 +0530
@@ -168,40 +168,6 @@
#endif
static fdopendir_func* my_fdopendir_func = NULL;
-#ifdef __ANDROID__
-/*
- * TODO: Android lacks support for the methods listed below. In it's place are
- * alternatives that use existing Android functionality, but lack reentrant
- * support. Determine if the following are the most suitable alternatives.
- *
- */
-int getgrgid_r(gid_t gid, struct group* grp, char* buf, size_t buflen, struct group** result)
-{
- *result = NULL;
- errno = 0;
- grp = getgrgid(gid);
- if (grp == NULL) {
- return errno;
- }
- // buf not used by caller (see below)
- *result = grp;
- return 0;
-}
-
-int getgrnam_r(const char *name, struct group* grp, char* buf, size_t buflen, struct group** result)
-{
- *result = NULL;
- errno = 0;
- grp = getgrnam(name);
- if (grp == NULL) {
- return errno;
- }
- // buf not used by caller (see below)
- *result = grp;
- return 0;
-}
-#endif
-
/**
* fstatat missing from glibc on Linux. Temporary workaround
* for x86/x64.

View File

@ -1,119 +0,0 @@
--- ./dev-jdk-9+@TAG_VER@/common/autoconf/flags.m4 2016-12-21 03:14:04.000000000 +0530
+++ ../../flags.m4 2017-01-22 13:35:01.668555165 +0530
@@ -1297,7 +1297,7 @@
# Set $2JVM_LIBS (per os)
if test "x$OPENJDK_$1_OS" = xlinux; then
- $2JVM_LIBS="[$]$2JVM_LIBS -lm -ldl -lpthread"
+ $2JVM_LIBS="[$]$2JVM_LIBS -lm -ldl"
elif test "x$OPENJDK_$1_OS" = xsolaris; then
# FIXME: This hard-coded path is not really proper.
if test "x$OPENJDK_$1_CPU" = xx86_64; then
--- ./jdk/make/lib/Awt2dLibraries.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/lib/Awt2dLibraries.gmk 2017-01-22 13:36:55.817520779 +0530
@@ -330,10 +330,6 @@
LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm -lc
- ifeq ($(OPENJDK_TARGET_OS), linux)
- LIBAWT_XAWT_LIBS += -lpthread
- endif
-
ifeq ($(TOOLCHAIN_TYPE), gcc)
# Turn off all warnings for the following files since they contain warnings
# that cannot be turned of individually.
@@ -906,7 +902,7 @@
LIBSPLASHSCREEN_LDFLAGS := -delayload:user32.dll
LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib
else
- LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl
+ LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -ldl
endif
$(eval $(call SetupNativeCompilation,BUILD_LIBSPLASHSCREEN, \
--- ./jdk/make/lib/NioLibraries.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/lib/NioLibraries.gmk 2017-01-22 13:38:05.550161653 +0530
@@ -69,7 +69,7 @@
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljava -lnet, \
- LIBS_linux := -lpthread $(LIBDL), \
+ LIBS_linux := $(LIBDL), \
LIBS_solaris := -ljvm -lsocket -lposix4 $(LIBDL) \
-lsendfile -lc, \
LIBS_aix := $(LIBDL), \
--- ./jdk/make/lib/Lib-jdk.sctp.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/lib/Lib-jdk.sctp.gmk 2017-01-22 13:38:39.083147832 +0530
@@ -50,7 +50,7 @@
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -lnio -lnet -ljava -ljvm, \
- LIBS_linux := -lpthread $(LIBDL), \
+ LIBS_linux := $(LIBDL), \
LIBS_solaris := -lsocket -lc, \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsctp, \
))
--- ./jdk/make/lib/CoreLibraries.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/lib/CoreLibraries.gmk 2017-01-22 13:39:17.676071246 +0530
@@ -389,7 +389,7 @@
-export:JLI_PreprocessArg \
-export:JLI_GetAppArgIndex, \
LIBS_unix := $(LIBZ), \
- LIBS_linux := $(LIBDL) -lc -lpthread, \
+ LIBS_linux := $(LIBDL) -lc, \
LIBS_solaris := $(LIBDL) -lc, \
LIBS_aix := $(LIBDL),\
LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
--- ./jdk/make/lib/Lib-jdk.jdwp.agent.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/lib/Lib-jdk.jdwp.agent.gmk 2017-01-22 13:40:42.121805959 +0530
@@ -47,7 +47,7 @@
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_windows := -export:jdwpTransport_OnLoad, \
- LIBS_linux := -lpthread, \
+ LIBS_linux := -lc, \
LIBS_solaris := -lnsl -lsocket -lc, \
LIBS_windows := $(JDKLIB_LIBS) ws2_32.lib, \
VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
--- ./jdk/make/lib/NetworkingLibraries.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/lib/NetworkingLibraries.gmk 2017-01-22 13:41:39.251151227 +0530
@@ -41,7 +41,7 @@
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_windows := -delayload:secur32.dll -delayload:iphlpapi.dll, \
LIBS_unix := -ljvm -ljava, \
- LIBS_linux := $(LIBDL) -lpthread, \
+ LIBS_linux := $(LIBDL), \
LIBS_solaris := -lnsl -lsocket $(LIBDL) -lc, \
LIBS_aix := $(LIBDL),\
LIBS_windows := ws2_32.lib jvm.lib secur32.lib iphlpapi.lib \
--- ./jdk/make/launcher/LauncherCommon.gmk 2016-12-21 03:43:34.000000000 +0530
+++ ./jdk-jdk-9+@TAG_VER@/make/launcher/LauncherCommon.gmk 2017-01-22 13:42:01.530891130 +0530
@@ -196,7 +196,7 @@
MAPFILE := $$($1_MAPFILE), \
LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \
LIBS_unix := $$($1_LIBS_unix), \
- LIBS_linux := -lpthread -ljli $(LIBDL) -lc, \
+ LIBS_linux := -ljli $(LIBDL) -lc, \
LIBS_solaris := -ljli -lthread $(LIBDL) -lc, \
LIBS_windows := $$($1_WINDOWS_JLI_LIB) \
$(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \
--- ./dev-jdk-9+@TAG_VER@//common/autoconf/generated-configure.sh 2016-12-21 03:14:04.000000000 +0530
+++ ../../generated-configure.sh 2017-01-22 14:01:05.792364527 +0530
@@ -50593,7 +50593,7 @@
# Set JVM_LIBS (per os)
if test "x$OPENJDK_TARGET_OS" = xlinux; then
- JVM_LIBS="$JVM_LIBS -lm -ldl -lpthread"
+ JVM_LIBS="$JVM_LIBS -lm -ldl"
elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
# FIXME: This hard-coded path is not really proper.
if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
@@ -51416,7 +51416,7 @@
# Set OPENJDK_BUILD_JVM_LIBS (per os)
if test "x$OPENJDK_BUILD_OS" = xlinux; then
- OPENJDK_BUILD_JVM_LIBS="$OPENJDK_BUILD_JVM_LIBS -lm -ldl -lpthread"
+ OPENJDK_BUILD_JVM_LIBS="$OPENJDK_BUILD_JVM_LIBS -lm -ldl"
elif test "x$OPENJDK_BUILD_OS" = xsolaris; then
# FIXME: This hard-coded path is not really proper.
if test "x$OPENJDK_BUILD_CPU" = xx86_64; then

View File

@ -1,71 +0,0 @@
--- ./hotspot-jdk-9+@TAG_VER@/src/os/linux/vm/os_linux.cpp 2017-01-13 05:11:16.000000000 +0530
+++ ../os_linux.cpp 2017-02-05 11:25:25.918994081 +0530
@@ -98,7 +98,9 @@
# include <string.h>
# include <syscall.h>
# include <sys/sysinfo.h>
+# ifndef __ANDROID__
# include <gnu/libc-version.h>
+# endif
# include <sys/ipc.h>
# include <sys/shm.h>
# include <link.h>
@@ -496,6 +498,7 @@
// detecting pthread library
void os::Linux::libpthread_init() {
+#ifndef __ANDROID__
// Save glibc and pthread version strings.
#if !defined(_CS_GNU_LIBC_VERSION) || \
!defined(_CS_GNU_LIBPTHREAD_VERSION)
@@ -513,6 +516,10 @@
str = (char *)malloc(n, mtInternal);
confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
os::Linux::set_libpthread_version(str);
+#else
+ os::Linux::set_glibc_version("bionic 21");
+ os::Linux::set_libpthread_version("pthread 21");
+#endif
}
/////////////////////////////////////////////////////////////////////////////
@@ -2809,7 +2816,10 @@
// If we are running with earlier version, which did not have symbol versions,
// we should use the base version.
void* os::Linux::libnuma_dlsym(void* handle, const char *name) {
- void *f = dlvsym(handle, name, "libnuma_1.1");
+ void *f = NULL;
+ #ifndef __ANDROID__
+ f = dlvsym(handle, name, "libnuma_1.1");
+ #endif
if (f == NULL) {
f = dlsym(handle, name);
}
@@ -5471,7 +5481,11 @@
// Linux doesn't yet have a (official) notion of processor sets,
// so just return the system wide load average.
int os::loadavg(double loadavg[], int nelem) {
+#ifdef __ANDROID__
+ return -1;
+#else
return ::getloadavg(loadavg, nelem);
+#endif
}
void os::pause() {
@@ -6194,7 +6208,15 @@
struct stat st;
int ret = os::stat(filename, &st);
assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno));
+#ifdef __ANDROID__
+ struct timespec ts;
+ unsigned long ms = st.st_mtime;
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000;
+ return ts;
+#else
return st.st_mtim;
+#endif
}
int os::compare_file_modified_times(const char* file1, const char* file2) {