[PATCH V2 1/4] external x64: move java balloon code out of kernel into the module java-base

7 views
Skip to first unread message

Waldemar Kozaczuk

unread,
Jan 21, 2020, 10:22:05 PM1/21/20
to osv...@googlegroups.com, Waldemar Kozaczuk
The main motivation of this patch is to eliminate compile time
dependencies in kernel on JDK headers. It achieves it by moving
java balloon shrinker implementation that requires java headers
to compile, from kernel (java/jvm) to modules/java-base.

Given that kernel code in mmu, mempool and mman depended on
jvm_balloon_shrinker directly, it was necessary to create new abstraction/interface -
jvm_balloon_api (class with pure virtual methods) - which kernel code
would use to interact with jvm balloon code if enabled. The code
moved from java/jvm to modules/java-base/balloon would provide
implementation of jvm_balloon_api hiding all direct interaction with
JNI (Java Native Interface). In essence some functions in jvm_balloon.cc
have been adopted into methods of jvm_balloon_api_impl class -
singleton implementing interface defined by jvm_balloon_api.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 5 --
core/mempool.cc | 19 ++++-
core/mmu.cc | 7 +-
include/osv/mempool.hh | 25 ++++++
libc/mman.cc | 5 +-
modules/httpserver-api/api/os.cc | 2 +-
modules/java-base/Makefile | 3 +-
.../java-base/balloon}/balloon_api.hh | 0
.../java-base/balloon}/jvm_balloon.cc | 77 +++++++++----------
.../java-base/balloon}/jvm_balloon.hh | 34 ++++----
modules/java-base/java.cc | 10 +--
modules/java-base/jni/monitor.cc | 4 +-
modules/java-isolated/Makefile | 2 +-
modules/java-non-isolated/Makefile | 3 +-
modules/java-tests/Makefile | 2 +-
15 files changed, 110 insertions(+), 88 deletions(-)
rename {java/jvm => modules/java-base/balloon}/balloon_api.hh (100%)
rename {java/jvm => modules/java-base/balloon}/jvm_balloon.cc (92%)
rename {java/jvm => modules/java-base/balloon}/jvm_balloon.hh (53%)

diff --git a/Makefile b/Makefile
index 51f76cd6..cbe90704 100644
--- a/Makefile
+++ b/Makefile
@@ -319,7 +319,6 @@ COMMON = $(autodepend) -g -Wall -Wno-pointer-arith $(CFLAGS_WERROR) -Wformat=0 -
$(kernel-defines) \
-fno-omit-frame-pointer $(compiler-specific) \
-include compiler/include/intrinsics.hh \
- $(do-sys-includes) \
$(arch-cflags) $(conf-opt) $(acpi-defines) $(tracing-flags) $(gcc-sysroot) \
$(configuration) -D__OSV__ -D__XEN_INTERFACE_VERSION__="0x00030207" -DARCH_STRING=$(ARCH_STR) $(EXTRA_FLAGS)
ifeq ($(gcc_include_env), external)
@@ -383,11 +382,8 @@ $(out)/%.o: %.s
$(makedir)
$(q-build-so)

-sys-includes = $(jdkbase)/include $(jdkbase)/include/linux
autodepend = -MD -MT $@ -MP

-do-sys-includes = $(foreach inc, $(sys-includes), -isystem $(inc))
-
tools := tools/mkfs/mkfs.so tools/cpiod/cpiod.so

$(out)/tools/%.o: COMMON += -fPIC
@@ -816,7 +812,6 @@ drivers += drivers/clock.o
drivers += drivers/clock-common.o
drivers += drivers/clockevent.o
drivers += core/elf.o
-drivers += java/jvm/jvm_balloon.o
drivers += drivers/random.o
drivers += drivers/zfs.o
drivers += drivers/null.o
diff --git a/core/mempool.cc b/core/mempool.cc
index 070f8c92..d902eea8 100644
--- a/core/mempool.cc
+++ b/core/mempool.cc
@@ -31,7 +31,6 @@
#include <osv/shrinker.h>
#include <osv/defer.hh>
#include <osv/dbg-alloc.hh>
-#include "java/jvm/jvm_balloon.hh"
#include <boost/dynamic_bitset.hpp>
#include <boost/lockfree/stack.hpp>
#include <boost/lockfree/policies.hpp>
@@ -442,7 +441,9 @@ static void on_free(size_t mem)
static void on_alloc(size_t mem)
{
free_memory.fetch_sub(mem);
- jvm_balloon_adjust_memory(min_emergency_pool_size);
+ if (balloon_api) {
+ balloon_api->adjust_memory(min_emergency_pool_size);
+ }
if ((stats::free() + stats::jvm_heap()) < watermark_lo) {
reclaimer_thread.wake();
}
@@ -1030,7 +1031,9 @@ void reclaimer::_do_reclaim()
}
}

- jvm_balloon_voluntary_return();
+ if (balloon_api) {
+ balloon_api->voluntary_return();
+ }
}
}
}
@@ -1976,4 +1979,14 @@ void free_phys_contiguous_aligned(void* p)
free_large(p);
}

+bool throttling_needed()
+{
+ if (!balloon_api) {
+ return false;
+ }
+
+ return balloon_api->ballooning();
+}
+
+jvm_balloon_api *balloon_api = nullptr;
}
diff --git a/core/mmu.cc b/core/mmu.cc
index e8a10fd8..ff3fab47 100644
--- a/core/mmu.cc
+++ b/core/mmu.cc
@@ -22,7 +22,6 @@
#include <osv/error.h>
#include <osv/trace.hh>
#include <stack>
-#include "java/jvm/jvm_balloon.hh"
#include <fs/fs.hh>
#include <osv/file.h>
#include "dump.hh"
@@ -1551,7 +1550,7 @@ error jvm_balloon_vma::sync(uintptr_t start, uintptr_t end)

void jvm_balloon_vma::fault(uintptr_t fault_addr, exception_frame *ef)
{
- if (jvm_balloon_fault(_balloon, ef, this)) {
+ if (memory::balloon_api && memory::balloon_api->fault(_balloon, ef, this)) {
return;
}
// Can only reach this case if we are doing partial copies
@@ -1578,8 +1577,8 @@ jvm_balloon_vma::~jvm_balloon_vma()
if (_effective_jvm_addr) {
// Can't just use size(), because although rare, the source and destination can
// have different alignments
- auto end = align_down(_effective_jvm_addr + balloon_size, balloon_alignment);
- auto s = end - align_up(_effective_jvm_addr, balloon_alignment);
+ auto end = align_down(_effective_jvm_addr + memory::balloon_size, memory::balloon_alignment);
+ auto s = end - align_up(_effective_jvm_addr, memory::balloon_alignment);
mmu::map_jvm(_effective_jvm_addr, s, mmu::huge_page_size, _balloon);
}
}
diff --git a/include/osv/mempool.hh b/include/osv/mempool.hh
index 8f4e61df..10fe5602 100644
--- a/include/osv/mempool.hh
+++ b/include/osv/mempool.hh
@@ -283,6 +283,31 @@ public:
/// Hold to mark self as a memory reclaimer
extern reclaimer_lock_type reclaimer_lock;

+// We will divide the balloon in units of 128Mb. That should increase the likelyhood
+// of having hugepages mapped in and out of it.
+//
+// Using constant sized balloons should help with the process of giving memory
+// back to the JVM, since we don't need to search the list of balloons until
+// we find a balloon of the desired size: any will do.
+constexpr size_t balloon_size = (128ULL << 20);
+// FIXME: Can probably do better than this. We are counting 4Mb before 1Gb to
+// account for ROMs and the such. 4Mb is probably too much (in kvm with no vga
+// we lose around 400k), but it doesn't hurt.
+constexpr size_t balloon_min_memory = (1ULL << 30) - (4 << 20);
+constexpr size_t balloon_alignment = mmu::huge_page_size;
+
+class jvm_balloon_api {
+public:
+ jvm_balloon_api() {};
+ virtual ~jvm_balloon_api() {};
+ virtual void return_heap(size_t mem) = 0;
+ virtual void adjust_memory(size_t threshold) = 0;
+ virtual void voluntary_return() = 0;
+ virtual bool fault(balloon_ptr b, exception_frame *ef, mmu::jvm_balloon_vma *vma) = 0;
+ virtual bool ballooning() = 0;
+};
+
+extern jvm_balloon_api *balloon_api;
}

#endif
diff --git a/libc/mman.cc b/libc/mman.cc
index bb573a80..d0803ac4 100644
--- a/libc/mman.cc
+++ b/libc/mman.cc
@@ -15,7 +15,6 @@
#include "osv/mount.h"
#include "libc/libc.hh"
#include <safe-ptr.hh>
-#include <java/jvm/jvm_balloon.hh>

TRACEPOINT(trace_memory_mmap, "addr=%p, length=%d, prot=%d, flags=%d, fd=%d, offset=%d", void *, size_t, int, int, int, off_t);
TRACEPOINT(trace_memory_mmap_err, "%d", int);
@@ -150,7 +149,9 @@ void *mmap(void *addr, size_t length, int prot, int flags,
// it this way now because it is simpler and I don't expect that to
// ever be harmful.
mmap_flags |= mmu::mmap_jvm_heap;
- memory::return_jvm_heap(length);
+ if (memory::balloon_api) {
+ memory::balloon_api->return_heap(length);
+ }
}
try {
ret = mmu::map_anon(addr, length, mmap_flags, mmap_perm);
diff --git a/modules/httpserver-api/api/os.cc b/modules/httpserver-api/api/os.cc
index 358a86c6..d80ab1ba 100644
--- a/modules/httpserver-api/api/os.cc
+++ b/modules/httpserver-api/api/os.cc
@@ -19,7 +19,7 @@
#include <api/unistd.h>
#include <osv/commands.hh>
#include <algorithm>
-#include "java/jvm/balloon_api.hh"
+#include "../java-base/balloon/balloon_api.hh"

extern char debug_buffer[DEBUG_BUFFER_SIZE];

diff --git a/modules/java-base/Makefile b/modules/java-base/Makefile
index d61999cf..5f4d79b0 100644
--- a/modules/java-base/Makefile
+++ b/modules/java-base/Makefile
@@ -3,7 +3,7 @@ include common.gmk
ifeq ($(arch),aarch64)
java-targets :=
else
-java-targets := obj/jni/monitor.so obj/jvm/jni_helpers.o obj/jvm/java_api.o
+java-targets := obj/jni/monitor.so obj/jvm/jni_helpers.o obj/jvm/java_api.o obj/balloon/jvm_balloon.o
endif

module: all
@@ -14,6 +14,7 @@ init:
@echo " MKDIRS"
$(call very-quiet, mkdir -p obj/jni)
$(call very-quiet, mkdir -p obj/jvm)
+ $(call very-quiet, mkdir -p obj/balloon)
.PHONY: init

clean:
diff --git a/java/jvm/balloon_api.hh b/modules/java-base/balloon/balloon_api.hh
similarity index 100%
rename from java/jvm/balloon_api.hh
rename to modules/java-base/balloon/balloon_api.hh
diff --git a/java/jvm/jvm_balloon.cc b/modules/java-base/balloon/jvm_balloon.cc
similarity index 92%
rename from java/jvm/jvm_balloon.cc
rename to modules/java-base/balloon/jvm_balloon.cc
index f7d8e322..3f589f08 100644
--- a/java/jvm/jvm_balloon.cc
+++ b/modules/java-base/balloon/jvm_balloon.cc
@@ -29,8 +29,6 @@ TRACEPOINT(trace_jvm_balloon_close, "from=%p, to=%p, condition=%s",
uintptr_t, uintptr_t, const char *);


-jvm_balloon_shrinker *balloon_shrinker = nullptr;
-
namespace memory {

// If we are under pressure, we will end up setting the voluntary return flag
@@ -45,7 +43,7 @@ void reserve_jvm_heap(size_t mem)
jvm_heap_allowance.fetch_sub(mem, std::memory_order_relaxed);
}

-void return_jvm_heap(size_t mem)
+void jvm_balloon_api_impl::return_heap(size_t mem)
{
jvm_heap_allowance.fetch_add(mem, std::memory_order_relaxed);
balloon_voluntary_return = true;
@@ -53,18 +51,14 @@ void return_jvm_heap(size_t mem)

ssize_t jvm_heap_reserved()
{
- if (!balloon_shrinker) {
+ if (!memory::balloon_api) {
return 0;
}
return (stats::free() + stats::jvm_heap()) - jvm_heap_allowance.load(std::memory_order_relaxed);
}

-void jvm_balloon_adjust_memory(size_t threshold)
+void jvm_balloon_api_impl::adjust_memory(size_t threshold)
{
- if (!balloon_shrinker) {
- return;
- }
-
// Core of the reservation system:
// The heap allowance starts as the initial memory that is reserved to
// the JVM. It means how much it can eventually use, and it is completely
@@ -72,38 +66,25 @@ void jvm_balloon_adjust_memory(size_t threshold)
// that number goes down, and when we return the balloon back, it goes
// up again.
if (jvm_heap_reserved() <= static_cast<ssize_t>(threshold)) {
- balloon_shrinker->request_memory(1);
- }
-}
-
-bool throttling_needed()
-{
- if (!balloon_shrinker) {
- return false;
+ _balloon_shrinker->request_memory(1);
}
-
- return balloon_shrinker->ballooning();
}
-};

-void jvm_balloon_voluntary_return()
+void jvm_balloon_api_impl::voluntary_return()
{
- if (!balloon_shrinker) {
- return;
- }
-
// If we freed memory and now we have more than a balloon + 20 % worth of
// reserved memory, give it back to the Java Heap. This is because it is a
// lot harder to react to JVM memory shortages than it is to react to OSv
// memory shortages - which are effectively under our control. Don't doing
// this can result in Heap exhaustions in situations where JVM allocation
// rates are very high and memory is tight
- if ((memory::jvm_heap_reserved() > 6 * static_cast<ssize_t>(balloon_size/5)) &&
+ if ((memory::jvm_heap_reserved() > 6 * static_cast<ssize_t>(memory::balloon_size/5)) &&
memory::balloon_voluntary_return.exchange(false))
{
- balloon_shrinker->release_memory(1);
+ _balloon_shrinker->release_memory(1);
}
}
+};

class balloon {
public:
@@ -127,7 +108,7 @@ private:

jobject _jref;
unsigned int _alignment;
- size_t _balloon_size = balloon_size;
+ size_t _balloon_size = memory::balloon_size;
};

mutex balloons_lock;
@@ -136,7 +117,7 @@ std::list<balloon_ptr> balloons;
namespace memory {
ssize_t get_balloon_size() {
WITH_LOCK(balloons_lock) {
- return balloons.size() * balloon_size;
+ return balloons.size() * memory::balloon_size;
}
}
}
@@ -154,7 +135,7 @@ ulong balloon::empty_area(balloon_ptr b)
return ret;
}

-balloon::balloon(unsigned char *jvm_addr, jobject jref, int alignment = mmu::huge_page_size, size_t size = balloon_size)
+balloon::balloon(unsigned char *jvm_addr, jobject jref, int alignment = mmu::huge_page_size, size_t size = memory::balloon_size)
: _jvm_addr(jvm_addr), _jref(jref), _alignment(alignment), _balloon_size(size)
{
assert(mutex_owned(&balloons_lock));
@@ -172,7 +153,7 @@ void balloon::release(JNIEnv *env)

// No need to remap. Will happen automatically when JVM touches it again
env->DeleteGlobalRef(_jref);
- memory::return_jvm_heap(minimum_size());
+ memory::balloon_api->return_heap(minimum_size());
trace_jvm_balloon_free();
}

@@ -229,7 +210,7 @@ size_t jvm_balloon_shrinker::_request_memory(JNIEnv *env, size_t size)
size_t ret = 0;

do {
- jbyteArray array = env->NewByteArray(balloon_size);
+ jbyteArray array = env->NewByteArray(memory::balloon_size);
jthrowable exc = env->ExceptionOccurred();
if (exc) {
env->ExceptionClear();
@@ -313,12 +294,12 @@ void jvm_balloon_shrinker::_thread_loop()
break;
}
size_t freed = 1;
- while ((memory::jvm_heap_reserved() < static_cast<ssize_t>(balloon_size)) && (freed != 0)) {
- uint64_t to_free = balloon_size - memory::jvm_heap_reserved();
+ while ((memory::jvm_heap_reserved() < static_cast<ssize_t>(memory::balloon_size)) && (freed != 0)) {
+ uint64_t to_free = memory::balloon_size - memory::jvm_heap_reserved();
freed = arc_sized_adjust(to_free);
}

- if (memory::jvm_heap_reserved() >= static_cast<ssize_t>(balloon_size)) {
+ if (memory::jvm_heap_reserved() >= static_cast<ssize_t>(memory::balloon_size)) {
_pending_release.fetch_sub(1);
_release_memory(env, memory::jvm_heap_reserved());
} else {
@@ -349,7 +330,8 @@ void jvm_balloon_shrinker::_thread_loop()
// part. That means copying the part that comes before the balloon, playing
// with the maps for the balloon itself, and then finish copying the part that
// comes after the balloon.
-bool jvm_balloon_fault(balloon_ptr b, exception_frame *ef, mmu::jvm_balloon_vma *vma)
+namespace memory {
+bool jvm_balloon_api_impl::fault(balloon_ptr b, exception_frame *ef, mmu::jvm_balloon_vma *vma)
{
if (!ef || mmu::is_page_fault_write_exclusive(ef->get_error())) {
if (vma->effective_jvm_addr()) {
@@ -424,6 +406,7 @@ bool jvm_balloon_fault(balloon_ptr b, exception_frame *ef, mmu::jvm_balloon_vma
#endif /* !AARCH64_PORT_STUB */
return true;
}
+};

jvm_balloon_shrinker::jvm_balloon_shrinker(JavaVM_ *vm)
: _vm(vm)
@@ -446,7 +429,7 @@ jvm_balloon_shrinker::jvm_balloon_shrinker(JavaVM_ *vm)
// down towards number. This is because if the JVM is very short on
// memory, it can quickly fill up the new balloon and may not have time
// for a new GC cycle.
- _soft_max_balloons = (_total_heap / ( 2 * balloon_size)) - 1;
+ _soft_max_balloons = (_total_heap / ( 2 * memory::balloon_size)) - 1;

auto monmethod = env->GetStaticMethodID(monitor, "MonitorGC", "(J)V");
env->CallStaticVoidMethod(monitor, monmethod, this);
@@ -461,8 +444,6 @@ jvm_balloon_shrinker::jvm_balloon_shrinker(JavaVM_ *vm)

_detach(status);

- balloon_shrinker = this;
-
// This cannot be a sched::thread because it may call into JNI functions,
// if the JVM balloon is registered as a shrinker. It expects the full pthread
// API to be functional, and for sched::threads it is not.
@@ -471,7 +452,21 @@ jvm_balloon_shrinker::jvm_balloon_shrinker(JavaVM_ *vm)
tmp.detach();
}

-jvm_balloon_shrinker::~jvm_balloon_shrinker()
+namespace memory {
+jvm_balloon_api_impl::jvm_balloon_api_impl(JavaVM *jvm)
{
- balloon_shrinker = nullptr;
+ _balloon_shrinker = new jvm_balloon_shrinker(jvm);
+ balloon_api = this;
}
+
+jvm_balloon_api_impl::~jvm_balloon_api_impl()
+{
+ delete _balloon_shrinker;
+ balloon_api = nullptr;
+}
+
+bool jvm_balloon_api_impl::ballooning()
+{
+ return _balloon_shrinker->ballooning();
+}
+};
diff --git a/java/jvm/jvm_balloon.hh b/modules/java-base/balloon/jvm_balloon.hh
similarity index 53%
rename from java/jvm/jvm_balloon.hh
rename to modules/java-base/balloon/jvm_balloon.hh
index cacc4833..a7a2dc5b 100644
--- a/java/jvm/jvm_balloon.hh
+++ b/modules/java-base/balloon/jvm_balloon.hh
@@ -15,26 +15,13 @@
#include <osv/condvar.h>
#include <atomic>

-// We will divide the balloon in units of 128Mb. That should increase the likelyhood
-// of having hugepages mapped in and out of it.
-//
-// Using constant sized balloons should help with the process of giving memory
-// back to the JVM, since we don't need to search the list of balloons until
-// we find a balloon of the desired size: any will do.
-constexpr size_t balloon_size = (128ULL << 20);
-// FIXME: Can probably do better than this. We are counting 4Mb before 1Gb to
-// account for ROMs and the such. 4Mb is probably too much (in kvm with no vga
-// we lose around 400k), but it doesn't hurt.
-constexpr size_t balloon_min_memory = (1ULL << 30) - (4 << 20);
-constexpr size_t balloon_alignment = mmu::huge_page_size;
-
class jvm_balloon_shrinker {
public:
explicit jvm_balloon_shrinker(JavaVM *vm);
void request_memory(size_t s) { _pending.fetch_add(s); _blocked.wake_one(); }
void release_memory(size_t s) { _pending_release.fetch_add(s); _blocked.wake_one(); }
bool ballooning() { return _pending.load() > 0; }
- virtual ~jvm_balloon_shrinker();
+ virtual ~jvm_balloon_shrinker() {};
private:
void _release_memory(JNIEnv *env, size_t s);
size_t _request_memory(JNIEnv *env, size_t s);
@@ -50,13 +37,18 @@ private:
std::atomic<size_t> _pending_release = {0};
};

-bool jvm_balloon_fault(balloon_ptr b, exception_frame *ef, mmu::jvm_balloon_vma *vma);
-
namespace memory {
- void return_jvm_heap(size_t size);
- void reserve_jvm_heap(size_t size);
- ssize_t jvm_heap_reserved();
- void jvm_balloon_adjust_memory(size_t threshold);
+class jvm_balloon_api_impl : public jvm_balloon_api {
+public:
+ explicit jvm_balloon_api_impl(JavaVM *jvm);
+ virtual ~jvm_balloon_api_impl();
+ virtual void return_heap(size_t mem);
+ virtual void adjust_memory(size_t threshold);
+ virtual void voluntary_return();
+ virtual bool fault(balloon_ptr b, exception_frame *ef, mmu::jvm_balloon_vma *vma);
+ virtual bool ballooning();
+private:
+ jvm_balloon_shrinker *_balloon_shrinker;
};
-void jvm_balloon_voluntary_return();
+}
#endif
diff --git a/modules/java-base/java.cc b/modules/java-base/java.cc
index 796f6e44..08a60965 100644
--- a/modules/java-base/java.cc
+++ b/modules/java-base/java.cc
@@ -12,7 +12,7 @@
#include <unistd.h>
#include <regex>
#include <osv/debug.hh>
-#include <java/jvm/jvm_balloon.hh>
+#include "balloon/jvm_balloon.hh"
#include <osv/mempool.hh>
#include "jvm/java_api.hh"
#include "osv/version.hh"
@@ -174,9 +174,9 @@ static int java_main(int argc, char **argv)
size_t auto_heap = 0;
#if 0
// Do not use total(), since that won't reflect the whole memory for the
- // machine. It then becomes counterintuitive to tell the user what is the
+ // machine. It then becomes counter intuitive to tell the user what is the
// minimum he has to set to balloon
- if (!has_xmx && (memory::phys_mem_size >= balloon_min_memory)) {
+ if (!has_xmx && (memory::phys_mem_size >= memory::balloon_min_memory)) {
auto_heap = std::min(memory::stats::free(), memory::stats::max_no_reclaim()) >> 20;
options.push_back(mkoption("-Xmx%dM", auto_heap));
if (!has_xms) {
@@ -252,8 +252,8 @@ static int java_main(int argc, char **argv)
// Manually setting the heap size is viewed as a declaration of intent. In
// that case, we'll leave the user alone. This may be revisited in the
// future, but it is certainly the safest option.
- std::unique_ptr<jvm_balloon_shrinker>
- balloon(auto_heap == 0 ? nullptr : new jvm_balloon_shrinker(jvm));
+ std::unique_ptr<memory::jvm_balloon_api_impl>
+ balloon(auto_heap == 0 ? nullptr : new memory::jvm_balloon_api_impl(jvm));

env->CallStaticVoidMethod(mainclass, mainmethod, args);

diff --git a/modules/java-base/jni/monitor.cc b/modules/java-base/jni/monitor.cc
index 18bf65b7..bb5685b1 100644
--- a/modules/java-base/jni/monitor.cc
+++ b/modules/java-base/jni/monitor.cc
@@ -1,6 +1,6 @@
#include <jni.h>
#include "monitor.hh"
-#include "java/jvm/jvm_balloon.hh"
+#include "../balloon/jvm_balloon.hh"

/*
* Class: io_osv_OSvGCMonitor
@@ -10,5 +10,5 @@
JNIEXPORT void JNICALL Java_io_osv_OSvGCMonitor_NotifyOSv(JNIEnv *env, jclass mon, jlong handle, jlong qty)
{
jvm_balloon_shrinker *shrinker = (jvm_balloon_shrinker *)handle;
- shrinker->release_memory((qty / balloon_size) + !!(qty % balloon_size));
+ shrinker->release_memory((qty / memory::balloon_size) + !!(qty % memory::balloon_size));
}
diff --git a/modules/java-isolated/Makefile b/modules/java-isolated/Makefile
index e0e15a01..15179e1f 100644
--- a/modules/java-isolated/Makefile
+++ b/modules/java-isolated/Makefile
@@ -11,7 +11,7 @@ endif
obj/java.o: $(java-base-path)/java.cc | init
$(call quiet, $(CXX) $(CXXFLAGS) -o $@ -c $(java-base-path)/java.cc -MMD, CXX $@)

-obj/java.so: obj/java.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o
+obj/java.so: obj/java.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o $(java-base-path)/obj/balloon/jvm_balloon.o
$(call quiet, $(CXX) $(CXXFLAGS) -shared -o $@ $^, LINK $@)

init:
diff --git a/modules/java-non-isolated/Makefile b/modules/java-non-isolated/Makefile
index 19e4a48f..7588aed0 100644
--- a/modules/java-non-isolated/Makefile
+++ b/modules/java-non-isolated/Makefile
@@ -11,7 +11,8 @@ endif
obj/java_non_isolated.o: $(java-base-path)/java.cc | init
$(call quiet, $(CXX) $(CXXFLAGS) -DRUN_JAVA_NON_ISOLATED -o $@ -c $(java-base-path)/java.cc -MMD, CXX $@)

-obj/java_non_isolated.so: obj/java_non_isolated.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o
+obj/java_non_isolated.so: obj/java_non_isolated.o $(java-base-path)/obj/jvm/java_api.o \
+ $(java-base-path)/obj/jvm/jni_helpers.o $(java-base-path)/obj/balloon/jvm_balloon.o
$(call quiet, $(CXX) $(CXXFLAGS) -shared -o $@ $^, LINK $@)

init:
diff --git a/modules/java-tests/Makefile b/modules/java-tests/Makefile
index dc3dbb1b..474f0ce8 100644
--- a/modules/java-tests/Makefile
+++ b/modules/java-tests/Makefile
@@ -10,7 +10,7 @@ endif
obj/java_isolated.o: $(SRC)/modules/java-base/java.cc | init
$(call quiet, $(CXX) $(CXXFLAGS) -o $@ -c $(SRC)/modules/java-base/java.cc -MMD, CXX $@)

-obj/java_isolated.so: obj/java_isolated.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o
+obj/java_isolated.so: obj/java_isolated.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o $(java-base-path)/obj/balloon/jvm_balloon.o
$(call quiet, $(CXX) $(CXXFLAGS) -shared -o $@ $^, LINK $@)

init:
--
2.20.1

Waldemar Kozaczuk

unread,
Jan 21, 2020, 10:22:09 PM1/21/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 adds new openjdk8-from-host one
as 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.

This patch also removes external/x64/openjdk.bin and external/aarch64/openjdk.bin modules.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
.gitmodules | 7 -----
Makefile | 9 +-----
external/aarch64/openjdk.bin | 1 -
external/x64/openjdk.bin | 1 -
modules/httpserver-jvm-plugin/Makefile | 3 +-
modules/java-base/common.gmk | 2 ++
modules/java/module.py | 2 +-
modules/openjdk7/module.py | 22 --------------
modules/openjdk8-from-host/.gitignore | 1 +
modules/openjdk8-from-host/Makefile | 14 +++++++++
modules/openjdk8-from-host/module.py | 40 ++++++++++++++++++++++++++
scripts/build | 11 ++++---
12 files changed, 65 insertions(+), 48 deletions(-)
delete mode 160000 external/aarch64/openjdk.bin
delete mode 160000 external/x64/openjdk.bin
delete mode 100644 modules/openjdk7/module.py
create mode 100644 modules/openjdk8-from-host/.gitignore
create mode 100644 modules/openjdk8-from-host/Makefile
create mode 100644 modules/openjdk8-from-host/module.py

diff --git a/.gitmodules b/.gitmodules
index a9fc9c64..8244a0e7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,3 @@
-[submodule "external/x64/openjdk.bin"]
- path = external/x64/openjdk.bin
- url = ../../cloudius-systems/openjdk.bin
- ignore = dirty
[submodule "external/x64/gcc.bin"]
path = external/x64/gcc.bin
url = ../../cloudius-systems/gcc.bin
@@ -24,9 +20,6 @@
[submodule "external/aarch64/misc.bin"]
path = external/aarch64/misc.bin
url = ../../cloudius-systems/aarch64-misc.bin.git
-[submodule "external/aarch64/openjdk.bin"]
- path = external/aarch64/openjdk.bin
- url = ../../cloudius-systems/aarch64-openjdk.bin.git
[submodule "modules/httpserver/swagger-ui"]
path = modules/httpserver-html5-gui/swagger-ui
url = ../../cloudius-systems/swagger-ui.git
diff --git a/Makefile b/Makefile
index cbe90704..a4b000d6 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,6 @@ 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 ($(gcc_include_env), external)
gcc-inc-base := $(dir $(shell find $(gccbase)/ -name vector | grep -v -e debug/vector$$ -e profile/vector$$))
@@ -1933,7 +1926,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/external/aarch64/openjdk.bin b/external/aarch64/openjdk.bin
deleted file mode 160000
index 443f2cca..00000000
--- a/external/aarch64/openjdk.bin
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 443f2cca797910915274a0a3a42ea8a67752c063
diff --git a/external/x64/openjdk.bin b/external/x64/openjdk.bin
deleted file mode 160000
index 019ea95e..00000000
--- a/external/x64/openjdk.bin
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 019ea95e844cc9e51c149a519391e2a99915ad39
diff --git a/modules/httpserver-jvm-plugin/Makefile b/modules/httpserver-jvm-plugin/Makefile
index fdc20bb7..e92bec2c 100644
--- a/modules/httpserver-jvm-plugin/Makefile
+++ b/modules/httpserver-jvm-plugin/Makefile
@@ -1,7 +1,6 @@

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../../include -I. -I../../arch/$(ARCH) -I../..
INCLUDES += -I../httpserver-api

# compiler flags:
diff --git a/modules/java-base/common.gmk b/modules/java-base/common.gmk
index 0e2e4690..3d0a1c98 100644
--- a/modules/java-base/common.gmk
+++ b/modules/java-base/common.gmk
@@ -1,3 +1,5 @@
+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
INCLUDES += $(shell $(CXX) -E -xc++ - -v </dev/null 2>&1 | awk '/^End/ {exit} /^ .*c\+\+/ {print "-isystem" $$0}')
diff --git a/modules/java/module.py b/modules/java/module.py
index 7af25104..114c5fb9 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-from-host')
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/modules/openjdk8-from-host/.gitignore b/modules/openjdk8-from-host/.gitignore
new file mode 100644
index 00000000..f9235a6b
--- /dev/null
+++ b/modules/openjdk8-from-host/.gitignore
@@ -0,0 +1 @@
+usr.manifest
diff --git a/modules/openjdk8-from-host/Makefile b/modules/openjdk8-from-host/Makefile
new file mode 100644
index 00000000..1bd8b898
--- /dev/null
+++ b/modules/openjdk8-from-host/Makefile
@@ -0,0 +1,14 @@
+.PHONY: module clean
+
+SRC = $(shell readlink -f ../..)
+
+javac_exe_path = $(shell realpath $$(which javac))
+javac_bin_path = $(shell dirname $(javac_exe_path))
+java_jdk_path = $(shell dirname $(javac_bin_path))
+
+module:
+ $(SRC)/scripts/manifest_from_host.sh $(java_jdk_path)/jre/lib/amd64/libsunec.so > usr.manifest
+ $(SRC)/scripts/manifest_from_host.sh -l libfreeblpriv3.so >> usr.manifest
+
+clean:
+ rm -rf usr.manifest
diff --git a/modules/openjdk8-from-host/module.py b/modules/openjdk8-from-host/module.py
new file mode 100644
index 00000000..a55c78e9
--- /dev/null
+++ b/modules/openjdk8-from-host/module.py
@@ -0,0 +1,40 @@
+from osv.modules.filemap import FileMap
+from osv.modules import api
+import os, os.path
+import subprocess
+
+api.require('java-cmd')
+provides = ['java','java8']
+
+#Verify that the jdk exists by trying to locate javac (java compiler)
+if subprocess.call(['which', 'javac']) != 0:
+ print('Could not find any jdk on the host. Please install openjdk8!')
+ os.exit(-1)
+
+java_version = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)
+if not 'openjdk version "1.8.0' in java_version:
+ print('Could not find openjdk version 8 on the host. Please install openjdk8!')
+ os.exit(-1)
+
+javac_path = subprocess.check_output(['which', 'javac']).split('\n')[0]
+javac_real_path = os.path.realpath(javac_path)
+jdk_path = os.path.dirname(os.path.dirname(javac_real_path))
+
+usr_files = FileMap()
+
+jdk_dir = os.path.basename(jdk_path)
+
+usr_files.add(jdk_path).to('/usr/lib/jvm/java') \
+ .include('jre/**') \
+ .exclude('jre/lib/security/cacerts') \
+ .exclude('jre/lib/amd64/*audio*') \
+ .exclude('jre/lib/amd64/*sound*') \
+ .exclude('') \
+ .exclude('jre/man/**') \
+ .exclude('jre/bin/**') \
+ .include('jre/bin/java')
+
+usr_files.link('/usr/lib/jvm/' + jdk_dir).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/jre/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

Waldemar Kozaczuk

unread,
Jan 21, 2020, 10:22:15 PM1/21/20
to osv...@googlegroups.com, Waldemar Kozaczuk
In essence this patch removes some obsolete libraries
from java-base manifest, changes libz module to pull
libz.so.1 from host and eliminates unneeded dependency on fonts
app.

It also removes external/x64/misc.bin module.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
.gitmodules | 4 ----
Makefile | 3 +--
modules/java-base/module.py | 1 -
modules/java-base/usr.manifest | 2 --
modules/libz/.gitignore | 1 +
modules/libz/Makefile | 4 ++++
modules/libz/usr.manifest | 1 -
scripts/build | 7 +++----
8 files changed, 9 insertions(+), 14 deletions(-)
create mode 100644 modules/libz/.gitignore
create mode 100644 modules/libz/Makefile
delete mode 100644 modules/libz/usr.manifest

diff --git a/.gitmodules b/.gitmodules
index 8244a0e7..a7588448 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -6,10 +6,6 @@
path = external/x64/acpica
url = ../../cloudius-systems/acpica
ignore = dirty
-[submodule "external/x64/misc.bin"]
- path = external/x64/misc.bin
- url = ../../cloudius-systems/misc.bin.git
- ignore = dirty
[submodule "apps"]
path = apps
url = ../../cloudius-systems/osv-apps
diff --git a/Makefile b/Makefile
index a4b000d6..76ee8e43 100644
--- a/Makefile
+++ b/Makefile
@@ -1926,8 +1926,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 gccbase="$$olddir"/$(gccbase) \
- -D miscbase="$$olddir"/$(miscbase), MKBOOTFS $@)
+ -D gccbase="$$olddir"/$(gccbase), MKBOOTFS $@)

$(out)/bootfs.o: $(out)/bootfs.bin
$(out)/bootfs.o: ASFLAGS += -I$(out)
diff --git a/modules/java-base/module.py b/modules/java-base/module.py
index 3589a53b..f480736c 100644
--- a/modules/java-base/module.py
+++ b/modules/java-base/module.py
@@ -1,5 +1,4 @@
from osv.modules import api

-api.require('fonts')
api.require('ca-certificates')
api.require('libz')
diff --git a/modules/java-base/usr.manifest b/modules/java-base/usr.manifest
index bb23a227..b7da9091 100644
--- a/modules/java-base/usr.manifest
+++ b/modules/java-base/usr.manifest
@@ -6,6 +6,4 @@
#

[manifest]
-/usr/lib/&/libexpat.so.1: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libjpeg.so.62: %(miscbase)s/usr/lib64/&
/usr/lib/jni/monitor.so: ${MODULE_DIR}/obj/jni/monitor.so
diff --git a/modules/libz/.gitignore b/modules/libz/.gitignore
new file mode 100644
index 00000000..f9235a6b
--- /dev/null
+++ b/modules/libz/.gitignore
@@ -0,0 +1 @@
+usr.manifest
diff --git a/modules/libz/Makefile b/modules/libz/Makefile
new file mode 100644
index 00000000..8d077a10
--- /dev/null
+++ b/modules/libz/Makefile
@@ -0,0 +1,4 @@
+# Take libz.so from the build machine and put it in the image.
+libz = $(shell $(CC) -print-file-name=libz.so.1)
+module:
+ echo /usr/lib/libz.so.1: $(libz) > usr.manifest
diff --git a/modules/libz/usr.manifest b/modules/libz/usr.manifest
deleted file mode 100644
index 6ecb2936..00000000
--- a/modules/libz/usr.manifest
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/libz.so.1: %(miscbase)s/usr/lib64/libz.so.1
diff --git a/scripts/build b/scripts/build
index b72a8d67..1fa11b0f 100755
--- a/scripts/build
+++ b/scripts/build
@@ -171,7 +171,6 @@ modules=${vars[modules]-!$image}

# TODO: some modules need these... Would be better if they wouldn't...
gccbase=${vars[gccbase]-"$SRC"/external/$arch/gcc.bin}
-miscbase=${vars[miscbase]-"$SRC"/external/$arch/misc.bin}

case $OUT in
/*) OSV_BUILD_PATH=$OUT;;
@@ -268,15 +267,15 @@ zfs)

if [ "$export" == "none" ]
then
- "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D gccbase="$gccbase" -D miscbase="$miscbase"
+ "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D gccbase="$gccbase"
else
export_dir=${vars[export_dir]-$SRC/build/export}
- "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D gccbase="$gccbase" -D miscbase="$miscbase"
+ "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D gccbase="$gccbase"
fi
;;
rofs)
rm -rf rofs.img
- "$SRC"/scripts/gen-rofs-img.py -o rofs.img -m usr.manifest -D gccbase="$gccbase" -D miscbase="$miscbase"
+ "$SRC"/scripts/gen-rofs-img.py -o rofs.img -m usr.manifest -D gccbase="$gccbase"

Waldemar Kozaczuk

unread,
Jan 21, 2020, 10:22:21 PM1/21/20
to osv...@googlegroups.com, Waldemar Kozaczuk
This patch in essence changes skel manifests to pull
libgcc_s.so from host instead of gcc.bin under externals.
It also removes external/x64/gcc.bin module.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
.gitmodules | 4 ----
Makefile | 8 +++++++-
scripts/build | 10 ++++------
usr.manifest.skel | 2 +-
usr_ramfs.manifest.skel | 2 +-
usr_rofs.manifest.skel | 2 +-
6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index a7588448..da6d5d62 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,3 @@
-[submodule "external/x64/gcc.bin"]
- path = external/x64/gcc.bin
- url = ../../cloudius-systems/gcc.bin
- ignore = dirty
[submodule "external/x64/acpica"]
path = external/x64/acpica
url = ../../cloudius-systems/acpica
diff --git a/Makefile b/Makefile
index 76ee8e43..69260dd6 100644
--- a/Makefile
+++ b/Makefile
@@ -1923,10 +1923,16 @@ $(bootfs_manifest_dep): phony
echo -n $(bootfs_manifest) > $(bootfs_manifest_dep) ; \
fi

+ifeq ($(arch),x64)
+libgcc_s_dir := $(dir $(shell $(CC) -print-file-name=libgcc_s.so.1))
+else
+libgcc_s_dir := ../../$(gccbase)/lib64
+endif
+
$(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 gccbase="$$olddir"/$(gccbase), MKBOOTFS $@)
+ -D libgcc_s_dir=$(libgcc_s_dir), MKBOOTFS $@)

$(out)/bootfs.o: $(out)/bootfs.bin
$(out)/bootfs.o: ASFLAGS += -I$(out)
diff --git a/scripts/build b/scripts/build
index 1fa11b0f..857039b8 100755
--- a/scripts/build
+++ b/scripts/build
@@ -169,9 +169,6 @@ aarch64) image=${vars[image]-uush};;
esac
modules=${vars[modules]-!$image}

-# TODO: some modules need these... Would be better if they wouldn't...
-gccbase=${vars[gccbase]-"$SRC"/external/$arch/gcc.bin}
-
case $OUT in
/*) OSV_BUILD_PATH=$OUT;;
*) OSV_BUILD_PATH=`pwd`/$OUT;;
@@ -256,6 +253,7 @@ kernel_end=$(($loader_size+2097151 & ~2097151))
# the case in our old build.mk).
cd $OUT

+libgcc_s_dir=$(dirname $(readlink -f $(gcc -print-file-name=libgcc_s.so.1)))
case $fs_type in
zfs)
cp loader.img bare.raw
@@ -267,15 +265,15 @@ zfs)

if [ "$export" == "none" ]
then
- "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D gccbase="$gccbase"
+ "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D libgcc_s_dir="$libgcc_s_dir"
else
export_dir=${vars[export_dir]-$SRC/build/export}
- "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D gccbase="$gccbase"
+ "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D libgcc_s_dir="$libgcc_s_dir"
fi
;;
rofs)
rm -rf rofs.img
- "$SRC"/scripts/gen-rofs-img.py -o rofs.img -m usr.manifest -D gccbase="$gccbase"
+ "$SRC"/scripts/gen-rofs-img.py -o rofs.img -m usr.manifest -D libgcc_s_dir="$libgcc_s_dir"
rofs_size=`stat --printf %s rofs.img`
img_size=$((kernel_end + rofs_size))
cp loader.img bare.raw
diff --git a/usr.manifest.skel b/usr.manifest.skel
index 0bb6cb34..32fa8056 100644
--- a/usr.manifest.skel
+++ b/usr.manifest.skel
@@ -9,7 +9,7 @@
/tools/cpiod.so: tools/cpiod/cpiod.so
/tools/mount-nfs.so: tools/mount/mount-nfs.so
/tools/umount.so: tools/mount/umount.so
-/usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
+/usr/lib/libgcc_s.so.1: %(libgcc_s_dir)s/libgcc_s.so.1
/&/etc/hosts: ../../static/&
/etc/mnttab: ->/proc/mounts
/&/etc/fstab: ../../static/&
diff --git a/usr_ramfs.manifest.skel b/usr_ramfs.manifest.skel
index 607487e1..36c5e662 100644
--- a/usr_ramfs.manifest.skel
+++ b/usr_ramfs.manifest.skel
@@ -3,7 +3,7 @@
/libvdso.so: libvdso.so
/tools/mount-nfs.so: tools/mount/mount-nfs.so
/tools/umount.so: tools/mount/umount.so
-/usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
+/usr/lib/libgcc_s.so.1: %(libgcc_s_dir)s/libgcc_s.so.1
/&/etc/hosts: ../../static/&

/etc/mnttab: ->/proc/mounts
diff --git a/usr_rofs.manifest.skel b/usr_rofs.manifest.skel
index 2d3c5d1d..ecca8110 100644
--- a/usr_rofs.manifest.skel
+++ b/usr_rofs.manifest.skel
@@ -3,7 +3,7 @@
/libvdso.so: libvdso.so
/tools/mount-nfs.so: tools/mount/mount-nfs.so
/tools/umount.so: tools/mount/umount.so
-/usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
+/usr/lib/libgcc_s.so.1: %(libgcc_s_dir)s/libgcc_s.so.1
/&/etc/hosts: ../../static/&

/etc/mnttab: ->/proc/mounts
--
2.20.1

Nadav Har'El

unread,
Jan 22, 2020, 4:52:51 AM1/22/20
to Waldemar Kozaczuk, Osv Dev
On Wed, Jan 22, 2020 at 5:22 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 adds new openjdk8-from-host one
as 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.

I'll commit this because I like this direction, but I wonder (I'm not up-to-date with the current Java
trends) - how do we know that the Java that will be installed on the host is specifically Java 8?
Shouldn't we just call it "java-from-host", because it will use whatever is available in the host -
couldn't this be Java 9, or 10, or 11, or whatever is the current version nowadays (as I said, I
really did not keep up with Java...).

--
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/20200122032153.6195-2-jwkozaczuk%40gmail.com.

Commit Bot

unread,
Jan 22, 2020, 4:58:27 AM1/22/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

external x64: move java balloon code out of kernel into the module java-base

The main motivation of this patch is to eliminate compile time
dependencies in kernel on JDK headers. It achieves it by moving
java balloon shrinker implementation that requires java headers
to compile, from kernel (java/jvm) to modules/java-base.

Given that kernel code in mmu, mempool and mman depended on
jvm_balloon_shrinker directly, it was necessary to create new abstraction/interface -
jvm_balloon_api (class with pure virtual methods) - which kernel code
would use to interact with jvm balloon code if enabled. The code
moved from java/jvm to modules/java-base/balloon would provide
implementation of jvm_balloon_api hiding all direct interaction with
JNI (Java Native Interface). In essence some functions in jvm_balloon.cc
have been adopted into methods of jvm_balloon_api_impl class -
singleton implementing interface defined by jvm_balloon_api.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200122032153.6...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/libc/mman.cc
+++ b/libc/mman.cc
@@ -15,7 +15,6 @@
#include "osv/mount.h"
#include "libc/libc.hh"
#include <safe-ptr.hh>
-#include <java/jvm/jvm_balloon.hh>

TRACEPOINT(trace_memory_mmap, "addr=%p, length=%d, prot=%d, flags=%d, fd=%d, offset=%d", void *, size_t, int, int, int, off_t);
TRACEPOINT(trace_memory_mmap_err, "%d", int);
@@ -150,7 +149,9 @@ void *mmap(void *addr, size_t length, int prot, int flags,
// it this way now because it is simpler and I don't expect that to
// ever be harmful.
mmap_flags |= mmu::mmap_jvm_heap;
- memory::return_jvm_heap(length);
+ if (memory::balloon_api) {
+ memory::balloon_api->return_heap(length);
+ }
}
try {
ret = mmu::map_anon(addr, length, mmap_flags, mmap_perm);
diff --git a/modules/httpserver-api/api/os.cc b/modules/httpserver-api/api/os.cc
--- a/modules/httpserver-api/api/os.cc
+++ b/modules/httpserver-api/api/os.cc
@@ -19,7 +19,7 @@
#include <api/unistd.h>
#include <osv/commands.hh>
#include <algorithm>
-#include "java/jvm/balloon_api.hh"
+#include "../java-base/balloon/balloon_api.hh"

extern char debug_buffer[DEBUG_BUFFER_SIZE];

diff --git a/modules/java-base/Makefile b/modules/java-base/Makefile
--- a/modules/java-base/Makefile
+++ b/modules/java-base/Makefile
@@ -3,7 +3,7 @@ include common.gmk
ifeq ($(arch),aarch64)
java-targets :=
else
-java-targets := obj/jni/monitor.so obj/jvm/jni_helpers.o obj/jvm/java_api.o
+java-targets := obj/jni/monitor.so obj/jvm/jni_helpers.o obj/jvm/java_api.o obj/balloon/jvm_balloon.o
endif

module: all
@@ -14,6 +14,7 @@ init:
@echo " MKDIRS"
$(call very-quiet, mkdir -p obj/jni)
$(call very-quiet, mkdir -p obj/jvm)
+ $(call very-quiet, mkdir -p obj/balloon)
.PHONY: init

clean:
diff --git a/modules/java-base/balloon/balloon_api.hh b/modules/java-base/balloon/balloon_api.hh
--- a/modules/java-base/balloon/balloon_api.hh
+++ b/modules/java-base/balloon/balloon_api.hh
null
diff --git a/modules/java-base/balloon/jvm_balloon.cc b/modules/java-base/balloon/jvm_balloon.cc
--- a/modules/java-base/balloon/jvm_balloon.cc
+++ b/modules/java-base/balloon/jvm_balloon.cc
@@ -29,8 +29,6 @@ TRACEPOINT(trace_jvm_balloon_close, "from=%p, to=%p, condition=%s",
uintptr_t, uintptr_t, const char *);


-jvm_balloon_shrinker *balloon_shrinker = nullptr;
-
namespace memory {

// If we are under pressure, we will end up setting the voluntary return flag
@@ -45,65 +43,48 @@ void reserve_jvm_heap(size_t mem)
jvm_heap_allowance.fetch_sub(mem, std::memory_order_relaxed);
}

-void return_jvm_heap(size_t mem)
+void jvm_balloon_api_impl::return_heap(size_t mem)
{
jvm_heap_allowance.fetch_add(mem, std::memory_order_relaxed);
balloon_voluntary_return = true;
}

ssize_t jvm_heap_reserved()
{
- if (!balloon_shrinker) {
+ if (!memory::balloon_api) {
return 0;
}
return (stats::free() + stats::jvm_heap()) - jvm_heap_allowance.load(std::memory_order_relaxed);
}

-void jvm_balloon_adjust_memory(size_t threshold)
+void jvm_balloon_api_impl::adjust_memory(size_t threshold)
{
- if (!balloon_shrinker) {
- return;
- }
-
// Core of the reservation system:
// The heap allowance starts as the initial memory that is reserved to
// the JVM. It means how much it can eventually use, and it is completely
// dissociated with the amount of memory it is using now. When we balloon,
@@ -127,7 +108,7 @@ class balloon {
diff --git a/modules/java-base/balloon/jvm_balloon.hh b/modules/java-base/balloon/jvm_balloon.hh
--- a/modules/java-base/balloon/jvm_balloon.hh
--- a/modules/java-base/jni/monitor.cc
+++ b/modules/java-base/jni/monitor.cc
@@ -1,6 +1,6 @@
#include <jni.h>
#include "monitor.hh"
-#include "java/jvm/jvm_balloon.hh"
+#include "../balloon/jvm_balloon.hh"

/*
* Class: io_osv_OSvGCMonitor
@@ -10,5 +10,5 @@
JNIEXPORT void JNICALL Java_io_osv_OSvGCMonitor_NotifyOSv(JNIEnv *env, jclass mon, jlong handle, jlong qty)
{
jvm_balloon_shrinker *shrinker = (jvm_balloon_shrinker *)handle;
- shrinker->release_memory((qty / balloon_size) + !!(qty % balloon_size));
+ shrinker->release_memory((qty / memory::balloon_size) + !!(qty % memory::balloon_size));
}
diff --git a/modules/java-isolated/Makefile b/modules/java-isolated/Makefile
--- a/modules/java-isolated/Makefile
+++ b/modules/java-isolated/Makefile
@@ -11,7 +11,7 @@ endif
obj/java.o: $(java-base-path)/java.cc | init
$(call quiet, $(CXX) $(CXXFLAGS) -o $@ -c $(java-base-path)/java.cc -MMD, CXX $@)

-obj/java.so: obj/java.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o
+obj/java.so: obj/java.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o $(java-base-path)/obj/balloon/jvm_balloon.o
$(call quiet, $(CXX) $(CXXFLAGS) -shared -o $@ $^, LINK $@)

init:
diff --git a/modules/java-non-isolated/Makefile b/modules/java-non-isolated/Makefile
--- a/modules/java-non-isolated/Makefile
+++ b/modules/java-non-isolated/Makefile
@@ -11,7 +11,8 @@ endif
obj/java_non_isolated.o: $(java-base-path)/java.cc | init
$(call quiet, $(CXX) $(CXXFLAGS) -DRUN_JAVA_NON_ISOLATED -o $@ -c $(java-base-path)/java.cc -MMD, CXX $@)

-obj/java_non_isolated.so: obj/java_non_isolated.o $(java-base-path)/obj/jvm/java_api.o $(java-base-path)/obj/jvm/jni_helpers.o
+obj/java_non_isolated.so: obj/java_non_isolated.o $(java-base-path)/obj/jvm/java_api.o \
+ $(java-base-path)/obj/jvm/jni_helpers.o $(java-base-path)/obj/balloon/jvm_balloon.o
$(call quiet, $(CXX) $(CXXFLAGS) -shared -o $@ $^, LINK $@)

init:
diff --git a/modules/java-tests/Makefile b/modules/java-tests/Makefile

Commit Bot

unread,
Jan 22, 2020, 4:58:28 AM1/22/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

external x64: replace openjdk7 module with with new openjdk8-from-host one

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 adds new openjdk8-from-host one
as 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.

This patch also removes external/x64/openjdk.bin and external/aarch64/openjdk.bin modules.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200122032153.6...@gmail.com>

---
diff --git a/.gitmodules b/.gitmodules
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,3 @@
-[submodule "external/x64/openjdk.bin"]
- path = external/x64/openjdk.bin
- url = ../../cloudius-systems/openjdk.bin
- ignore = dirty
[submodule "external/x64/gcc.bin"]
path = external/x64/gcc.bin
url = ../../cloudius-systems/gcc.bin
@@ -24,9 +20,6 @@
[submodule "external/aarch64/misc.bin"]
path = external/aarch64/misc.bin
url = ../../cloudius-systems/aarch64-misc.bin.git
-[submodule "external/aarch64/openjdk.bin"]
- path = external/aarch64/openjdk.bin
- url = ../../cloudius-systems/aarch64-openjdk.bin.git
[submodule "modules/httpserver/swagger-ui"]
path = modules/httpserver-html5-gui/swagger-ui
url = ../../cloudius-systems/swagger-ui.git
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -112,17 +112,13 @@ 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")
--- a/external/aarch64/openjdk.bin
+++ b/external/aarch64/openjdk.bin
@@ -1 +0,0 @@
-Subproject commit 443f2cca797910915274a0a3a42ea8a67752c063
diff --git a/external/x64/openjdk.bin b/external/x64/openjdk.bin
--- a/external/x64/openjdk.bin
+++ b/external/x64/openjdk.bin
@@ -1 +0,0 @@
-Subproject commit 019ea95e844cc9e51c149a519391e2a99915ad39
diff --git a/modules/httpserver-jvm-plugin/Makefile b/modules/httpserver-jvm-plugin/Makefile
--- a/modules/httpserver-jvm-plugin/Makefile
+++ b/modules/httpserver-jvm-plugin/Makefile
@@ -1,7 +1,6 @@

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../../include -I. -I../../arch/$(ARCH) -I../..
INCLUDES += -I../httpserver-api

# compiler flags:
diff --git a/modules/java-base/common.gmk b/modules/java-base/common.gmk
--- a/modules/java-base/common.gmk
+++ b/modules/java-base/common.gmk
@@ -1,3 +1,5 @@
+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
INCLUDES += $(shell $(CXX) -E -xc++ - -v </dev/null 2>&1 | awk '/^End/ {exit} /^ .*c\+\+/ {print "-isystem" $$0}')
diff --git a/modules/java/module.py b/modules/java/module.py
--- 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-from-host')
diff --git a/modules/openjdk7/module.py b/modules/openjdk7/module.py
--- a/modules/openjdk7/module.py
+++ b/modules/openjdk7/module.py
@@ -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/modules/openjdk8-from-host/.gitignore b/modules/openjdk8-from-host/.gitignore
--- a/modules/openjdk8-from-host/.gitignore
+++ b/modules/openjdk8-from-host/.gitignore
@@ -0,0 +1 @@
+usr.manifest
diff --git a/modules/openjdk8-from-host/Makefile b/modules/openjdk8-from-host/Makefile
--- a/modules/openjdk8-from-host/Makefile
+++ b/modules/openjdk8-from-host/Makefile
@@ -0,0 +1,14 @@
+.PHONY: module clean
+
+SRC = $(shell readlink -f ../..)
+
+javac_exe_path = $(shell realpath $$(which javac))
+javac_bin_path = $(shell dirname $(javac_exe_path))
+java_jdk_path = $(shell dirname $(javac_bin_path))
+
+module:
+ $(SRC)/scripts/manifest_from_host.sh $(java_jdk_path)/jre/lib/amd64/libsunec.so > usr.manifest
+ $(SRC)/scripts/manifest_from_host.sh -l libfreeblpriv3.so >> usr.manifest
+
+clean:
+ rm -rf usr.manifest
diff --git a/modules/openjdk8-from-host/module.py b/modules/openjdk8-from-host/module.py
--- a/modules/openjdk8-from-host/module.py

Commit Bot

unread,
Jan 22, 2020, 4:58:29 AM1/22/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

external x64: remove misc.bin

In essence this patch removes some obsolete libraries
from java-base manifest, changes libz module to pull
libz.so.1 from host and eliminates unneeded dependency on fonts
app.

It also removes external/x64/misc.bin module.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200122032153.6...@gmail.com>

---
diff --git a/.gitmodules b/.gitmodules
--- a/.gitmodules
+++ b/.gitmodules
@@ -6,10 +6,6 @@
path = external/x64/acpica
url = ../../cloudius-systems/acpica
ignore = dirty
-[submodule "external/x64/misc.bin"]
- path = external/x64/misc.bin
- url = ../../cloudius-systems/misc.bin.git
- ignore = dirty
[submodule "apps"]
path = apps
url = ../../cloudius-systems/osv-apps
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1926,8 +1926,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 gccbase="$$olddir"/$(gccbase) \
- -D miscbase="$$olddir"/$(miscbase), MKBOOTFS $@)
+ -D gccbase="$$olddir"/$(gccbase), MKBOOTFS $@)

$(out)/bootfs.o: $(out)/bootfs.bin
$(out)/bootfs.o: ASFLAGS += -I$(out)
diff --git a/modules/java-base/module.py b/modules/java-base/module.py
--- a/modules/java-base/module.py
+++ b/modules/java-base/module.py
@@ -1,5 +1,4 @@
from osv.modules import api

-api.require('fonts')
api.require('ca-certificates')
api.require('libz')
diff --git a/modules/java-base/usr.manifest b/modules/java-base/usr.manifest
--- a/modules/java-base/usr.manifest
+++ b/modules/java-base/usr.manifest
@@ -6,6 +6,4 @@
#

[manifest]
-/usr/lib/&/libexpat.so.1: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libjpeg.so.62: %(miscbase)s/usr/lib64/&
/usr/lib/jni/monitor.so: ${MODULE_DIR}/obj/jni/monitor.so
diff --git a/modules/libz/.gitignore b/modules/libz/.gitignore
--- a/modules/libz/.gitignore
+++ b/modules/libz/.gitignore
@@ -0,0 +1 @@
+usr.manifest
diff --git a/modules/libz/Makefile b/modules/libz/Makefile
--- a/modules/libz/Makefile
+++ b/modules/libz/Makefile
@@ -0,0 +1,4 @@
+# Take libz.so from the build machine and put it in the image.
+libz = $(shell $(CC) -print-file-name=libz.so.1)
+module:
+ echo /usr/lib/libz.so.1: $(libz) > usr.manifest
diff --git a/modules/libz/usr.manifest b/modules/libz/usr.manifest
--- a/modules/libz/usr.manifest
+++ b/modules/libz/usr.manifest
@@ -1 +0,0 @@
-/usr/lib/libz.so.1: %(miscbase)s/usr/lib64/libz.so.1
diff --git a/scripts/build b/scripts/build

Commit Bot

unread,
Jan 22, 2020, 4:58:30 AM1/22/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

external x64: remove gcc.bin

This patch in essence changes skel manifests to pull
libgcc_s.so from host instead of gcc.bin under externals.
It also removes external/x64/gcc.bin module.

References #743

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200122032153.6...@gmail.com>

---
diff --git a/.gitmodules b/.gitmodules
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,3 @@
-[submodule "external/x64/gcc.bin"]
- path = external/x64/gcc.bin
- url = ../../cloudius-systems/gcc.bin
- ignore = dirty
[submodule "external/x64/acpica"]
path = external/x64/acpica
url = ../../cloudius-systems/acpica
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1923,10 +1923,16 @@ $(bootfs_manifest_dep): phony
echo -n $(bootfs_manifest) > $(bootfs_manifest_dep) ; \
fi

+ifeq ($(arch),x64)
+libgcc_s_dir := $(dir $(shell $(CC) -print-file-name=libgcc_s.so.1))
+else
+libgcc_s_dir := ../../$(gccbase)/lib64
+endif
+
$(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 gccbase="$$olddir"/$(gccbase), MKBOOTFS $@)
+ -D libgcc_s_dir=$(libgcc_s_dir), MKBOOTFS $@)

$(out)/bootfs.o: $(out)/bootfs.bin
$(out)/bootfs.o: ASFLAGS += -I$(out)
diff --git a/scripts/build b/scripts/build
--- a/usr.manifest.skel
+++ b/usr.manifest.skel
@@ -9,7 +9,7 @@
/tools/cpiod.so: tools/cpiod/cpiod.so
/tools/mount-nfs.so: tools/mount/mount-nfs.so
/tools/umount.so: tools/mount/umount.so
-/usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
+/usr/lib/libgcc_s.so.1: %(libgcc_s_dir)s/libgcc_s.so.1
/&/etc/hosts: ../../static/&
/etc/mnttab: ->/proc/mounts
/&/etc/fstab: ../../static/&
diff --git a/usr_ramfs.manifest.skel b/usr_ramfs.manifest.skel
--- a/usr_ramfs.manifest.skel
+++ b/usr_ramfs.manifest.skel
@@ -3,7 +3,7 @@
/libvdso.so: libvdso.so
/tools/mount-nfs.so: tools/mount/mount-nfs.so
/tools/umount.so: tools/mount/umount.so
-/usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
+/usr/lib/libgcc_s.so.1: %(libgcc_s_dir)s/libgcc_s.so.1
/&/etc/hosts: ../../static/&

/etc/mnttab: ->/proc/mounts
diff --git a/usr_rofs.manifest.skel b/usr_rofs.manifest.skel

Waldek Kozaczuk

unread,
Jan 22, 2020, 7:30:52 AM1/22/20
to OSv Development


On Wednesday, January 22, 2020 at 4:52:51 AM UTC-5, Nadav Har'El wrote:

On Wed, Jan 22, 2020 at 5:22 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 adds new openjdk8-from-host one
as 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.

I'll commit this because I like this direction, but I wonder (I'm not up-to-date with the current Java
trends) - how do we know that the Java that will be installed on the host is specifically Java 8?
Shouldn't we just call it "java-from-host", because it will use whatever is available in the host -
couldn't this be Java 9, or 10, or 11, or whatever is the current version nowadays (as I said, I
really did not keep up with Java...).
The C++ code in modules/java-base should compile with headers of any Java but the Java code in the same module, more specifically the
"isolated" one, will NOT compile with java > 8 as (which is rare) some classes/interfaces have been removed (not just deprecated). So that is why we need opendjk8
to compile java code.

Let me send more detailed email later about it.

To unsubscribe from this group and stop receiving emails from it, send an email to osv...@googlegroups.com.

Nadav Har'El

unread,
Jan 22, 2020, 12:32:53 PM1/22/20
to Waldek Kozaczuk, OSv Development
On Wed, Jan 22, 2020 at 2:30 PM Waldek Kozaczuk <jwkoz...@gmail.com> wrote:


On Wednesday, January 22, 2020 at 4:52:51 AM UTC-5, Nadav Har'El wrote:

On Wed, Jan 22, 2020 at 5:22 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 adds new openjdk8-from-host one
as 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.

I'll commit this because I like this direction, but I wonder (I'm not up-to-date with the current Java
trends) - how do we know that the Java that will be installed on the host is specifically Java 8?
Shouldn't we just call it "java-from-host", because it will use whatever is available in the host -
couldn't this be Java 9, or 10, or 11, or whatever is the current version nowadays (as I said, I
really did not keep up with Java...).
The C++ code in modules/java-base should compile with headers of any Java but the Java code in the same module, more specifically the
"isolated" one, will NOT compile with java > 8 as (which is rare) some classes/interfaces have been removed (not just deprecated). So that is why we need opendjk8
to compile java code.

I guess that in some future Linux distribution, we will suddenly discover this doesn't work any more
because the host Java actually has Java 9, not 8. But I guess we can fix this later when we reach this
problem.

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/31288000-1bf0-4072-b285-b76647f92aef%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages