[PATCH] java: eliminate openjdk7

11 views
Skip to first unread message

Waldemar Kozaczuk

unread,
Jan 14, 2020, 11:07:04 PM1/14/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Java 7 reached end of life almost 5 years ago and has since
been largely replaced by Java 8 which is still widely used.

This patch eliminates openjdk7 module and makes openjdk8-zull-full
a default java module. This patch also replaces dependencies in the
main makefile on antique openjdk7 in external/x64 with openjdk8
from host that should be installed by setup.py.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 14 +++++++-------
modules/httpserver-jvm-plugin/Makefile | 2 --
modules/java-base/common.gmk | 1 +
modules/java/module.py | 2 +-
modules/openjdk7/module.py | 22 ----------------------
scripts/build | 11 +++++------
6 files changed, 14 insertions(+), 38 deletions(-)
delete mode 100644 modules/openjdk7/module.py

diff --git a/Makefile b/Makefile
index 62277d5f..8886d1ec 100644
--- a/Makefile
+++ b/Makefile
@@ -112,7 +112,6 @@ endif
# musl/ - for some of the header files (symbolic links in include/api) and
# some of the source files ($(musl) below).
# external/x64/acpica - for the ACPICA library (see $(acpi) below).
-# external/x64/openjdk.bin - for $(java-targets) below.
# Additional submodules are need when certain make parameters are used.
ifeq (,$(wildcard musl/include))
$(error Missing musl/ directory. Please run "git submodule update --init --recursive")
@@ -120,9 +119,6 @@ endif
ifeq (,$(wildcard external/x64/acpica/source))
$(error Missing external/x64/acpica/ directory. Please run "git submodule update --init --recursive")
endif
-ifeq (,$(wildcard external/x64/openjdk.bin/usr))
- $(error Missing external/x64/openjdk.bin/ directory. Please run "git submodule update --init --recursive")
-endif

# This makefile wraps all commands with the $(quiet) or $(very-quiet) macros
# so that instead of half-a-screen-long command lines we short summaries
@@ -233,9 +229,13 @@ INCLUDES += -isystem include/glibc-compat

gccbase = external/$(arch)/gcc.bin
miscbase = external/$(arch)/misc.bin
-jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \
- -maxdepth 1 -type d -name 'java*')

+ifeq ($(arch),x64)
+ jdkbase := $(dir $(shell readlink -f $$(which javac)))/..
+else
+ jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \
+ -maxdepth 1 -type d -name 'java*')
+endif

ifeq ($(gcc_include_env), external)
gcc-inc-base := $(dir $(shell find $(gccbase)/ -name vector | grep -v -e debug/vector$$ -e profile/vector$$))
@@ -1940,7 +1940,7 @@ $(bootfs_manifest_dep): phony
$(out)/bootfs.bin: scripts/mkbootfs.py $(bootfs_manifest) $(bootfs_manifest_dep) $(tools:%=$(out)/%) \
$(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so $(out)/libvdso.so
$(call quiet, olddir=`pwd`; cd $(out); "$$olddir"/scripts/mkbootfs.py -o bootfs.bin -d bootfs.bin.d -m "$$olddir"/$(bootfs_manifest) \
- -D jdkbase="$$olddir"/$(jdkbase) -D gccbase="$$olddir"/$(gccbase) \
+ -D gccbase="$$olddir"/$(gccbase) \
-D miscbase="$$olddir"/$(miscbase), MKBOOTFS $@)

$(out)/bootfs.o: $(out)/bootfs.bin
diff --git a/modules/httpserver-jvm-plugin/Makefile b/modules/httpserver-jvm-plugin/Makefile
index fdc20bb7..bb802720 100644
--- a/modules/httpserver-jvm-plugin/Makefile
+++ b/modules/httpserver-jvm-plugin/Makefile
@@ -1,7 +1,5 @@
-
INCLUDES = -I$(src)/build/$(mode)/gen/include
INCLUDES += -I../../include -I. -I../../java -I../../arch/$(ARCH) -I../..
-INCLUDES += -I$(jdkbase)/include -I$(jdkbase)/include/linux
INCLUDES += -I../httpserver-api

# compiler flags:
diff --git a/modules/java-base/common.gmk b/modules/java-base/common.gmk
index e54a301a..1c79a6b5 100644
--- a/modules/java-base/common.gmk
+++ b/modules/java-base/common.gmk
@@ -1,3 +1,4 @@
+jdkbase = $(dir $(shell readlink -f $$(which javac)))/..

INCLUDES = -I$(src)/arch/$(arch) -I$(src) -I$(src)/include -I$(src)/arch/common
INCLUDES += -I$(src)/include/glibc-compat
diff --git a/modules/java/module.py b/modules/java/module.py
index 7af25104..0c0eb6c5 100644
--- a/modules/java/module.py
+++ b/modules/java/module.py
@@ -1,4 +1,4 @@
from osv.modules import api

api.require('java-non-isolated')
-api.require('openjdk7')
+api.require('openjdk8-zulu-full')
diff --git a/modules/openjdk7/module.py b/modules/openjdk7/module.py
deleted file mode 100644
index e4895465..00000000
--- a/modules/openjdk7/module.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from osv.modules.filemap import FileMap
-from osv.modules import api
-import os, os.path
-
-api.require('java-cmd')
-provides = ['java']
-
-usr_files = FileMap()
-
-jdkdir = os.path.basename(os.path.expandvars('${jdkbase}'))
-
-usr_files.add('${jdkbase}').to('/usr/lib/jvm/java') \
- .include('lib/**') \
- .include('jre/**') \
- .include('bin/java') \
- .exclude('jre/lib/security/cacerts') \
- .exclude('jre/lib/audio/**')
-
-usr_files.link('/usr/lib/jvm/' + jdkdir).to('java')
-usr_files.link('/usr/lib/jvm/jre').to('java/jre')
-usr_files.link('/usr/lib/jvm/java/jre/lib/security/cacerts').to('/etc/pki/java/cacerts')
-usr_files.link('/usr/bin/java').to('/usr/lib/jvm/java/bin/java')
diff --git a/scripts/build b/scripts/build
index 2a4ba957..b72a8d67 100755
--- a/scripts/build
+++ b/scripts/build
@@ -170,7 +170,6 @@ esac
modules=${vars[modules]-!$image}

# TODO: some modules need these... Would be better if they wouldn't...
-jdkbase=${vars[jdkbase]-`find "$SRC"/external/$arch/openjdk.bin/usr/lib/jvm -maxdepth 1 -type d -name 'java*'`}
gccbase=${vars[gccbase]-"$SRC"/external/$arch/gcc.bin}
miscbase=${vars[miscbase]-"$SRC"/external/$arch/misc.bin}

@@ -221,8 +220,8 @@ fi
export "$i" ;;
esac
done
- # Export the variables we already have. This makes it unnecessary to do "fs__type=$fstype jdkbase $jdkbase ..."
- export fs_type jdkbase mode OSV_BUILD_PATH
+ # Export the variables we already have. This makes it unnecessary to do "fs__type=$fstype ..."
+ export fs_type mode OSV_BUILD_PATH
# Other variables we wanted to rename, I don't know why
export ARCH=$arch OSV_BASE=$SRC
# Run what we wanted to run. It will inherit everything we exported above.
@@ -269,15 +268,15 @@ zfs)

if [ "$export" == "none" ]
then
- "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D jdkbase="$jdkbase" -D gccbase="$gccbase" -D miscbase="$miscbase"
+ "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D gccbase="$gccbase" -D miscbase="$miscbase"
else
export_dir=${vars[export_dir]-$SRC/build/export}
- "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D jdkbase="$jdkbase" -D gccbase="$gccbase" -D miscbase="$miscbase"
+ "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D gccbase="$gccbase" -D miscbase="$miscbase"
fi
;;
rofs)
rm -rf rofs.img
- "$SRC"/scripts/gen-rofs-img.py -o rofs.img -m usr.manifest -D jdkbase="$jdkbase" -D gccbase="$gccbase" -D miscbase="$miscbase"
+ "$SRC"/scripts/gen-rofs-img.py -o rofs.img -m usr.manifest -D gccbase="$gccbase" -D miscbase="$miscbase"
rofs_size=`stat --printf %s rofs.img`
img_size=$((kernel_end + rofs_size))
cp loader.img bare.raw
--
2.20.1

Nadav Har'El

unread,
Jan 15, 2020, 3:45:13 AM1/15/20
to Waldemar Kozaczuk, Osv Dev
On Wed, Jan 15, 2020 at 6:07 AM Waldemar Kozaczuk <jwkoz...@gmail.com> wrote:
Java 7 reached end of life almost 5 years ago and has since
been largely replaced by Java 8 which is still widely used.

This patch eliminates openjdk7 module and makes openjdk8-zull-full
a default java module. This patch also replaces dependencies in the
main makefile on antique openjdk7 in external/x64 with openjdk8
from host that should be installed by setup.py.

It seems you are making two conflicting statements - on the one hand the
default Java will be openjdk8-zulu-full (from apps.git) and on the other hand -
the default will be Java from the host. So which is it? It seems to me the former -
I don't see any "java-from-host" module or anything...

A downside of openjdk8-zulu-full is that our "make check" still requires
Java, and if we use openjdk8-zulu-full, it means that apps.git is now a
full-fledged requirement during our test. I'm not sure this is a big problem, but
it's definitely a change (in the past the stuff we needed for tests were all in
modules/, not apps/).

Please see some comments below.
After we do this, we should probably remove the entire JVM from external/.


 # This makefile wraps all commands with the $(quiet) or $(very-quiet) macros
 # so that instead of half-a-screen-long command lines we short summaries
@@ -233,9 +229,13 @@ INCLUDES += -isystem include/glibc-compat

 gccbase = external/$(arch)/gcc.bin
 miscbase = external/$(arch)/misc.bin
-jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \
-                         -maxdepth 1 -type d -name 'java*')

+ifeq ($(arch),x64)
+  jdkbase := $(dir $(shell readlink -f $$(which javac)))/..
+else
+  jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \
+                       -maxdepth 1 -type d -name 'java*')
+endif

Maybe a stupid question, but do we still need this "jdkbase" variable in Makefile?
Aren't you removing its only uses in Makefile, below, and reintroducing similar code in /modules/java-base/common.gmk anyway ?

--
You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/20200115040644.15786-1-jwkozaczuk%40gmail.com.

Waldek Kozaczuk

unread,
Jan 15, 2020, 8:18:04 AM1/15/20
to OSv Development


On Wednesday, January 15, 2020 at 3:45:13 AM UTC-5, Nadav Har'El wrote:

On Wed, Jan 15, 2020 at 6:07 AM Waldemar Kozaczuk <jwkoz...@gmail.com> wrote:
Java 7 reached end of life almost 5 years ago and has since
been largely replaced by Java 8 which is still widely used.

This patch eliminates openjdk7 module and makes openjdk8-zull-full
a default java module. This patch also replaces dependencies in the
main makefile on antique openjdk7 in external/x64 with openjdk8
from host that should be installed by setup.py.

It seems you are making two conflicting statements - on the one hand the
default Java will be openjdk8-zulu-full (from apps.git) and on the other hand -
the default will be Java from the host. So which is it? It seems to me the former -
I don't see any "java-from-host" module or anything...

This patch makes the installed openjdk8 a compilation dependency for both main makefile and the one
under java-base. The openjdk8-zulu-full app is the runtime dependency for the unit tests (BTW I believe the Scylla jenkins already depends on it the same way).
But I think you have a point. Why not delete openjdk7 module and create openjdk8 (we are already demanding it in setup.py) that would pull from host or simply make the java-from-hots the app?
 

A downside of openjdk8-zulu-full is that our "make check" still requires
Java, and if we use openjdk8-zulu-full, it means that apps.git is now a
full-fledged requirement during our test. I'm not sure this is a big problem, but
it's definitely a change (in the past the stuff we needed for tests were all in
modules/, not apps/).

See above. BTW our tests already depend on the fonts app which I am removing as a dependency in follow up patch (not needed). 
I did not realize that external is not whole repo and individual subdirectories can be controlled per .gitsubmodules.  


 # This makefile wraps all commands with the $(quiet) or $(very-quiet) macros
 # so that instead of half-a-screen-long command lines we short summaries
@@ -233,9 +229,13 @@ INCLUDES += -isystem include/glibc-compat

 gccbase = external/$(arch)/gcc.bin
 miscbase = external/$(arch)/misc.bin
-jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \
-                         -maxdepth 1 -type d -name 'java*')

+ifeq ($(arch),x64)
+  jdkbase := $(dir $(shell readlink -f $$(which javac)))/..
+else
+  jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \
+                       -maxdepth 1 -type d -name 'java*')
+endif

Maybe a stupid question, but do we still need this "jdkbase" variable in Makefile?
Aren't you removing its only uses in Makefile, below, and reintroducing similar code in /modules/java-base/common.gmk anyway ?

Unfortunately, we need the java headers to compile code under java/jvm directory which is still part of the main makefile (even for aarch64 though it will probably not run). It would be best if it did not. I believe some of the code under java/jvm is baloon related (which is disabled in java.cc anyway) and some code is (java_api.*) used by jvm httpserver plugin. So maybe we can split it and move ballon part to modules/java-base and remaining to modules/httpserver-jvm-plugin. For sure core/mmu.cc depends on ballon code in java/jvm but hopefully it does not depend on jdk headers to compile.

I will look into it.
To unsubscribe from this group and stop receiving emails from it, send an email to osv...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages