Merge pull request #7208 from termux/openjdk

new package: openjdk-17
This commit is contained in:
Leonid Pliushch 2021-07-30 09:03:42 +03:00 committed by GitHub
commit 27999fd457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 438 additions and 0 deletions

View File

@ -0,0 +1,249 @@
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/launcher/main.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/launcher/main.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/launcher/main.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/launcher/main.c 2021-07-30 02:13:37.228016370 +0300
@@ -23,6 +23,23 @@
* questions.
*/
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
+
/*
* This file contains the main entry point into the launcher code
@@ -101,6 +118,8 @@
int jargc;
char** jargv;
const jboolean const_javaw = JNI_FALSE;
+
+ android_disable_fdsan();
#endif /* JAVAW */
{
int i, main_jargc, extra_jargc;
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/libjli/args.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/args.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/libjli/args.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/args.c 2021-07-30 02:03:19.015058522 +0300
@@ -29,6 +29,23 @@
#include <sys/stat.h>
#include <ctype.h>
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
+
#ifdef DEBUG_ARGFILE
#ifndef NO_JNI
#define NO_JNI
@@ -653,6 +670,8 @@
test_case(name[0], name + 1, sizeof(name)/sizeof(char*) - 1)
int main(int argc, char** argv) {
+ android_disable_fdsan();
+
size_t i, j;
char* case1[] = { "-version -cp \"c:\\\\java libs\\\\one.jar\" \n",
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/libjli/java.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/java.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/libjli/java.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/java.c 2021-07-30 02:11:21.382618501 +0300
@@ -50,6 +50,22 @@
* the CreateExecutionEnviroment will remove the -d<n> flags.
*/
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
#include "java.h"
#include "jni.h"
@@ -252,6 +268,8 @@
_is_java_args = javaargs;
_wc_enabled = cpwildcard;
+ android_disable_fdsan();
+
InitLauncher(javaw);
DumpState();
if (JLI_IsTraceLauncher()) {
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/jspawnhelper/jspawnhelper.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/jspawnhelper/jspawnhelper.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/jspawnhelper/jspawnhelper.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/jspawnhelper/jspawnhelper.c 2021-07-30 02:05:58.387913154 +0300
@@ -31,6 +31,23 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
+
#include "childproc.h"
extern int errno;
@@ -131,6 +148,8 @@
}
int main(int argc, char *argv[]) {
+ android_disable_fdsan();
+
ChildStuff c;
int t;
struct stat buf;
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/launcher/jexec.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/launcher/jexec.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/launcher/jexec.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/launcher/jexec.c 2021-07-30 02:05:07.323595979 +0300
@@ -84,6 +84,23 @@
# include "manifest_info.h"
#endif
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
+
static const int CRAZY_EXEC = ENOEXEC;
static const int BAD_MAGIC = ENOEXEC;
@@ -150,6 +167,8 @@
* the kernel.)
*/
int main(int argc, const char * argv[]) {
+ android_disable_fdsan();
+
/* We need to exec the original arguments using java, instead of jexec.
* Also, for Linux, it is necessary to add the "-jar" argument between
* the new arg[0], and the old arg[1]. To do this we will create a new
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/windows/native/libjli/cmdtoargs.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/windows/native/libjli/cmdtoargs.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/windows/native/libjli/cmdtoargs.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/windows/native/libjli/cmdtoargs.c 2021-07-30 02:06:52.044284731 +0300
@@ -33,6 +33,23 @@
#include <assert.h>
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
+
#ifndef IDE_STANDALONE
#include "java.h"
#include "jni.h"
@@ -382,6 +399,7 @@
#define MAXV 128
int main(int argc, char* argv[]) {
+ android_disable_fdsan();
int n;
for (n=1; n < argc; n++) {
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c 2021-07-30 02:07:34.480603856 +0300
@@ -34,6 +34,22 @@
#include "JvmLauncher.h"
#include "LinuxPackage.h"
+#ifdef __TERMUX__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+static void android_disable_fdsan() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_fdsan(){}
+#endif
#define STATUS_FAILURE 1
@@ -132,6 +148,8 @@
int main(int argc, char *argv[]) {
+ android_disable_fdsan();
+
int exitCode = STATUS_FAILURE;
JvmlLauncherData* jvmLauncherData;

View File

@ -0,0 +1,106 @@
TERMUX_PKG_HOMEPAGE=https://github.com/PojavLauncherTeam/mobile
TERMUX_PKG_DESCRIPTION="Java development kit and runtime"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=17.0
TERMUX_PKG_SRCURL=https://github.com/termux/openjdk-mobile-termux/archive/ec285598849a27f681ea6269342cf03cf382eb56.tar.gz
TERMUX_PKG_SHA256=d7c6ead9d80d0f60d98d0414e9dc87f5e18a304e420f5cd21f1aa3210c1a1528
TERMUX_PKG_DEPENDS="cups, fontconfig, freetype, libandroid-shmem, libandroid-spawn, libiconv, libpng, libx11, libxrender, zlib"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_HAS_DEBUG=false
termux_step_pre_configure() {
if [ "$TERMUX_ARCH" = "arm" ]; then
export JVM_VARIANTS="client"
else
export JVM_VARIANTS="server"
fi
# Provide fake gcc.
mkdir -p $TERMUX_PKG_SRCDIR/wrappers-bin
cat <<- EOF > $TERMUX_PKG_SRCDIR/wrappers-bin/android-wrapped-clang
#!/bin/bash
name=\$(basename "\$0")
if [ "\$name" = "android-wrapped-clang" ]; then
name=gcc
compiler=$CC
else
name=g++
compiler=$CXX
fi
if [ "\$1" = "--version" ]; then
echo "${TERMUX_HOST_PLATFORM/arm/armv7a}-\${name} (GCC) 4.9 20140827 (prerelease)"
echo "Copyright (C) 2014 Free Software Foundation, Inc."
echo "This is free software; see the source for copying conditions. There is NO"
echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
exit 0
fi
exec \$compiler "\${@/-fno-var-tracking-assignments/}"
EOF
chmod +x $TERMUX_PKG_SRCDIR/wrappers-bin/android-wrapped-clang
ln -sfr $TERMUX_PKG_SRCDIR/wrappers-bin/android-wrapped-clang \
$TERMUX_PKG_SRCDIR/wrappers-bin/android-wrapped-clang++
CC=$TERMUX_PKG_SRCDIR/wrappers-bin/android-wrapped-clang
CXX=$TERMUX_PKG_SRCDIR/wrappers-bin/android-wrapped-clang++
cat <<- EOF > $TERMUX_STANDALONE_TOOLCHAIN/devkit.info
DEVKIT_NAME="Android"
DEVKIT_TOOLCHAIN_PATH="\$DEVKIT_ROOT"
DEVKIT_SYSROOT="\$DEVKIT_ROOT/sysroot"
EOF
# OpenJDK uses same makefile for host and target builds, so we can't
# easily patch usage of librt and libpthread. Using linker scripts
# instead.
echo 'INPUT(-lc)' > $TERMUX_PREFIX/lib/librt.so
echo 'INPUT(-lc)' > $TERMUX_PREFIX/lib/libpthread.so
}
termux_step_configure() {
bash ./configure \
--openjdk-target=$TERMUX_HOST_PLATFORM \
--with-extra-cflags="$CFLAGS $CPPFLAGS -DLE_STANDALONE -DANDROID" \
--with-extra-cxxflags="$CXXFLAGS $CPPFLAGS -DLE_STANDALONE -DANDROID" \
--with-extra-ldflags="$LDFLAGS" \
--disable-precompiled-headers \
--disable-warnings-as-errors \
--enable-option-checking=fatal \
--enable-headless-only=yes \
--with-toolchain-type=gcc \
--with-jvm-variants="$JVM_VARIANTS" \
--with-devkit="$TERMUX_STANDALONE_TOOLCHAIN" \
--with-debug-level=release \
--with-cups-include="$TERMUX_PREFIX/include" \
--with-fontconfig-include="$TERMUX_PREFIX/include" \
--with-freetype-include="$TERMUX_PREFIX/include/freetype2" \
--with-freetype-lib="$TERMUX_PREFIX/lib" \
--with-libpng=system \
--with-zlib=system \
--x-includes="$TERMUX_PREFIX/include/X11" \
--x-libraries="$TERMUX_PREFIX/lib"
}
termux_step_make() {
cd build/linux-${TERMUX_ARCH/i686/x86}-${JVM_VARIANTS}-release
make JOBS=1 images
# Delete created library stubs.
rm $TERMUX_PREFIX/lib/librt.so $TERMUX_PREFIX/lib/libpthread.so
}
termux_step_make_install() {
rm -rf $TERMUX_PREFIX/opt/openjdk
mkdir -p $TERMUX_PREFIX/opt/openjdk
cp -r build/linux-${TERMUX_ARCH/i686/x86}-${JVM_VARIANTS}-release/images/jdk/* \
$TERMUX_PREFIX/opt/openjdk/
find $TERMUX_PREFIX/opt/openjdk -name "*.debuginfo" -delete
# OpenJDK is not installed into /prefix/bin.
local i
for i in $TERMUX_PREFIX/opt/openjdk/bin/*; do
if [ ! -f "$i" ]; then
continue
fi
ln -sfr $i $TERMUX_PREFIX/bin/$(basename $i)
done
}

View File

@ -0,0 +1,36 @@
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/make/modules/java.instrument/Lib.gmk mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/make/modules/java.instrument/Lib.gmk
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/make/modules/java.instrument/Lib.gmk 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/make/modules/java.instrument/Lib.gmk 2021-07-29 19:38:19.486712301 +0300
@@ -36,7 +36,6 @@
$(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \
NAME := instrument, \
OPTIMIZATION := LOW, \
- EXTRA_SRC := java.base:libtinyiconv, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBINSTRUMENT_CFLAGS), \
CFLAGS_debug := -DJPLIS_LOGGING, \
CFLAGS_release := -DNO_JPLIS_LOGGING, \
@@ -51,7 +50,7 @@
LDFLAGS_aix := -L$(SUPPORT_OUTPUTDIR)/native/java.base, \
LIBS := $(JDKLIB_LIBS), \
LIBS_unix := -ljava -ljvm $(LIBZ_LIBS), \
- LIBS_linux := -ljli $(LIBDL), \
+ LIBS_linux := -ljli -liconv $(LIBDL), \
LIBS_aix := -liconv -ljli_static $(LIBDL), \
LIBS_macosx := -ljli -liconv -framework Cocoa -framework Security \
-framework ApplicationServices, \
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/make/modules/jdk.jdwp.agent/Lib.gmk mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/make/modules/jdk.jdwp.agent/Lib.gmk
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/make/modules/jdk.jdwp.agent/Lib.gmk 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/make/modules/jdk.jdwp.agent/Lib.gmk 2021-07-29 19:38:46.415058534 +0300
@@ -59,11 +59,10 @@
EXTRA_HEADER_DIRS := \
include \
libjdwp/export, \
- EXTRA_SRC := java.base:libtinyiconv, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS := $(JDKLIB_LIBS), \
- LIBS_linux := $(LIBDL), \
+ LIBS_linux := -liconv $(LIBDL), \
LIBS_macosx := -liconv, \
LIBS_aix := -liconv, \
))

View File

@ -0,0 +1,11 @@
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/make/autoconf/libraries.m4 mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/make/autoconf/libraries.m4
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/make/autoconf/libraries.m4 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/make/autoconf/libraries.m4 2021-07-29 18:54:56.693068733 +0300
@@ -99,7 +99,6 @@
LIB_SETUP_CUPS
LIB_SETUP_FONTCONFIG
LIB_SETUP_FREETYPE
- LIB_SETUP_ALSA
LIB_SETUP_LIBFFI
LIB_SETUP_BUNDLED_LIBS
LIB_SETUP_MISC_LIBS

View File

@ -0,0 +1,36 @@
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/hotspot/os/linux/os_linux.cpp mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/hotspot/os/linux/os_linux.cpp
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/hotspot/os/linux/os_linux.cpp 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/hotspot/os/linux/os_linux.cpp 2021-07-29 17:55:29.989033099 +0300
@@ -132,7 +132,7 @@
// for timer info max values which include all bits
#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
-#if defined(MUSL_LIBC) || defined(__ANDROID__)
+#if defined(MUSL_LIBC) || defined(__ANDROID__) && !defined(__TERMUX__)
// dlvsym is not a part of POSIX
// and musl libc doesn't implement it.
static void *dlvsym(void *handle,
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2021-07-29 18:11:21.496721867 +0300
@@ -155,7 +155,7 @@
static lutimes_func* my_lutimes_func = NULL;
static fdopendir_func* my_fdopendir_func = NULL;
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(__TERMUX__)
/*
* TODO: Android lacks support for the methods listed below. In it's place are
* alternatives that use existing Android functionality, but lack reentrant
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/libjava/java_props_md.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/libjava/java_props_md.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/unix/native/libjava/java_props_md.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/unix/native/libjava/java_props_md.c 2021-07-29 18:07:42.758055414 +0300
@@ -46,7 +46,7 @@
#include "java_props_macosx.h"
#endif
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(__TERMUX__)
// From https://android.googlesource.com/platform/bionic/+/master/libc/bionic/langinfo.cpp
/*
* Copyright (C) 2016 The Android Open Source Project