Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v8 1/3] openjdk: new package
@ 2019-03-15 20:52 aduskett at gmail.com
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support aduskett at gmail.com
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: aduskett at gmail.com @ 2019-03-15 20:52 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

OpenJDK is a free and open-source implementation of the Java Platform.
This package provides the option to build a client or a server JVM interpreter.

The default option is the server option, as that is what the majority of users
use. This JVM interpreter loads more slowly, putting more effort into JIT
compilations to yield higher performance.

Unlike most autotools packages, OpenJDK is exceptionally different and has many
quirks, some of which are below:

- X11, alsa, and cups are required to build Java, even if it's a headless build.
  See http://hg.openjdk.java.net/jdk10/jdk10/raw-file/tip/common/doc/building.html#external-library-requirements
  for more information.

- host-zip is needed for the zip executable.

- There is no autogen.sh file, instead, a user must call "./configure autogen."

- OpenJDK ignores some variables unless passed via the environment.
  These variables are: PATH, LD, CC, CXX, and CPP.

- OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
  arguments during the linking process, which causes linking failures.
  To fix this issue, ld is set to gcc.

- If ccache is enabled, Buildroot sets CC, CXX, and CPP to the ccache binary,
  which causes the configuration error:
  "Please use --enable-ccache instead of providing a wrapped compiler."
  This error is why CC, CPP, and CXX are explicitly set to point to their
  actual binaries.

- Make -jn is unsupported. Instead, one must use the "--with-jobs=" configure
  option, and use $(MAKE1).

- Even when cross-compiling, OpenJDK builds several host-tools using the host's
  gcc. In the case of zlib, if a host doesn't have the zlib development package
  installed, OpenJDK compilation stops because zlib.h won't exist on the host
  system. Because zlib is used to compile both native tools and cross-compiled
  tools, patching make/autoconf/lib-bundled.m4 to call PKG_CHECK_MODULES for
  zlib results in the host gcc trying to use cross-compiled libraries for
  compiling native tools, which results in linking failures.
  Using --with-zlib=bundled allows OpenJDK to compile correctly.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
Changes v1 -> v2:
  - Fixed the patch name.

Changes v2 -> v3:
  - Changed the install location of the libraries and binaries to
    $(TARGET_DIR)/bin and $(TARGET_DIR)/lib.

  - Changed -with-boot-jdk location to $(HOST_DIR)/openjdk

  - Added a more in-depth commit message explaining some of the my reasoning
    for some of the quirks in the package files.

Changes v3 -> v4:
  - Changed GPLv2+ -> GPL-2.0+ (Thomas)
  - Added BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS to Config.in
  - Removed first person wordage. (Thomas)

Changes v4 -> v5:
  - Add jpeg, giflib, libpng, and zlib as dependencies. (Thomas)
  - Remove dependencies that aren't necessary. (Thomas)
  - Add better comments in the openjdk.mk file. (Matthew)
  - Change --with-boot-jdk location to just $(HOST_DIR)
  - Use newer Oracle provided cpu port for aarch64.
  - Update version to 11.0.2+9

Changes v5 -> v6:
  - Added comment about zlib in the commit message.
  - Added LCMS2 as a dependency.
  - Added more comments in Config.in
  - Added host-zip as a dependency in openjdk.mk.
  - Drop zlib as a dependency (See above comment.)
  - Changed --with-zlib=system to --with-zlib=bundled (See above comment.)
  - Cleaned up grammar in openjdk.mk.
  - Removed uneeded conf_opts in openjdk.mk.
  - Reverted previous change of --with-cpu-port=aarch64 to
    --with-cpu-port=arm64. This change breaks compiling, with missing calls to
    NativePltCall.

Changes v6 -> v7:
  - Removed AArch64 support in favor of a separate patch.
    OpenJDK works on AArch64 without the option; it just isn't as fast.
    This change makes the patch set follow section 21.5.1 of the Buildroot
    manual:
    "The patch itself should do only one change, but do it completely."
  - Fix typos (Thomas)
  - Clean up spacing in oppenjdk.mk (Thomas)
  - Add more explanations to the commit message (Thomas)
  - Clean up grammar in the openjdk.mk comments.
  - Clean up grammar in the commit message.
  - Reword many of the comments in the openjdk.mk file to better explain why
    the reasoning behind the logic.
  - Remove --prefix from configure options. This option is used only if
    "make install" is called.
  - Removed --with-extra-path=$(HOST_DIR)/bin:$(HOST_DIR)/sbin, as this is also
    not needed.
  - Change cp -rf to cp -dpfr for the OPENJDK_INSTALL_TARGET_CMDS step.

Changes v7 -> v8:
  - Break out the comment that OpenJDK requires X11 (Matthew Weber)

 DEVELOPERS                   |   1 +
 package/Config.in            |   1 +
 package/openjdk/Config.in    |  58 ++++++++++++++++++
 package/openjdk/openjdk.hash |   3 +
 package/openjdk/openjdk.mk   | 114 +++++++++++++++++++++++++++++++++++
 5 files changed, 177 insertions(+)
 create mode 100644 package/openjdk/Config.in
 create mode 100644 package/openjdk/openjdk.hash
 create mode 100644 package/openjdk/openjdk.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 8a57cb2e23..b4511bb053 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -51,6 +51,7 @@ F:	package/libsemanage/
 F:	package/libsepol/
 F:	package/libwebsockets/
 F:	package/nginx-naxsi/
+F:	package/openjdk/
 F:	package/openjdk-bin/
 F:	package/php/
 F:	package/policycoreutils/
diff --git a/package/Config.in b/package/Config.in
index ba961a22b3..573aea834e 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -669,6 +669,7 @@ menu "Mono libraries/modules"
 endmenu
 endif
 	source "package/nodejs/Config.in"
+	source "package/openjdk/Config.in"
 	source "package/perl/Config.in"
 if BR2_PACKAGE_PERL
 menu "Perl libraries/modules"
diff --git a/package/openjdk/Config.in b/package/openjdk/Config.in
new file mode 100644
index 0000000000..dff09fb89e
--- /dev/null
+++ b/package/openjdk/Config.in
@@ -0,0 +1,58 @@
+config BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
+	bool
+	default y if BR2_HOSTARCH = "x86_64"
+
+config BR2_PACKAGE_OPENJDK
+	bool "OpenJDK"
+	depends on !BR2_SOFT_FLOAT
+	depends on !BR2_STATIC_LIBS # Glibc
+	depends on BR2_INSTALL_LIBSTDCPP # cups
+	depends on BR2_TOOLCHAIN_HAS_THREADS # alsa-lib, cups, libusb
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_USE_MMU # cups
+	depends on BR2_PACKAGE_XORG7
+	select BR2_PACKAGE_ALSA_LIB
+	select BR2_PACKAGE_CUPS
+	select BR2_PACKAGE_FONTCONFIG
+	select BR2_PACKAGE_GIFLIB
+	select BR2_PACKAGE_JPEG
+	select BR2_PACKAGE_LCMS2
+	select BR2_PACKAGE_LIBPNG
+	select BR2_PACKAGE_LIBUSB
+	select BR2_PACKAGE_XLIB_LIBXRENDER
+	select BR2_PACKAGE_XLIB_LIBXT
+	select BR2_PACKAGE_XLIB_LIBXTST
+	help
+	  OpenJDK is a free and open-source implementation of the
+	  Java Platform.
+
+	  http://openjdk.java.net/
+
+if BR2_PACKAGE_OPENJDK
+
+menu "JVM Variants"
+
+config BR2_PACKAGE_OPENJDK_JVM_VARIANT_CLIENT
+	bool "client"
+	help
+	  Quick loading, but slower run-time performance.
+
+config BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER
+	bool "server"
+	default y
+	help
+	  Slower loading, but faster run-time performance.
+
+endmenu
+endif
+
+comment "OpenJDK needs X.Org"
+	depends on !BR2_PACKAGE_XORG7
+
+comment "OpenJDK needs glibc, and a toolchain w/ wchar, dynamic library, threads, C++"
+	depends on BR2_USE_MMU
+	depends on BR2_STATIC_LIBS || !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
+
+comment "OpenJDK does not support soft floats"
+	depends on BR2_SOFT_FLOAT
diff --git a/package/openjdk/openjdk.hash b/package/openjdk/openjdk.hash
new file mode 100644
index 0000000000..8b14609066
--- /dev/null
+++ b/package/openjdk/openjdk.hash
@@ -0,0 +1,3 @@
+# Locally computed
+sha256 6c69a2c1b5177659d4263545cf83e0fbcd697669b0107481372be3648af7b89b  openjdk-jdk-11.0.2+9.tar.gz
+sha256 4b9abebc4338048a7c2dc184e9f800deb349366bdf28eb23c2677a77b4c87726  LICENSE
diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
new file mode 100644
index 0000000000..23fbbf5ea2
--- /dev/null
+++ b/package/openjdk/openjdk.mk
@@ -0,0 +1,114 @@
+################################################################################
+#
+# openjdk
+#
+################################################################################
+
+OPENJDK_VERSION_MAJOR = 11.0.2
+OPENJDK_VERSION_MINOR = 9
+OPENJDK_VERSION = jdk-$(OPENJDK_VERSION_MAJOR)+$(OPENJDK_VERSION_MINOR)
+OPENJDK_SITE = $(call github,AdoptOpenJDK,openjdk-jdk11u,$(OPENJDK_VERSION))
+OPENJDK_LICENSE = GPL-2.0+ with exception
+OPENJDK_LICENSE_FILES = LICENSE
+
+# OpenJDK requires Alsa, cups, and X11 even for a headless build.
+# host-zip is needed for the zip executable.
+OPENJDK_DEPENDENCIES = \
+	host-openjdk-bin \
+	host-pkgconf \
+	host-zip \
+	alsa-lib \
+	cups \
+	fontconfig \
+	giflib \
+	jpeg \
+	lcms2 \
+	libpng \
+	libusb \
+	xlib_libXrender \
+	xlib_libXt \
+	xlib_libXtst
+
+# JVM variants
+ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_CLIENT),y)
+OPENJDK_JVM_VARIANTS += client
+endif
+
+ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER),y)
+OPENJDK_JVM_VARIANTS += server
+endif
+OPENJDK_JVM_VARIANT_LIST = $(subst $(space),$(comma),$(OPENJDK_JVM_VARIANTS))
+
+# OpenJDK ignores some variables unless passed via the environment.
+# These variables are PATH, LD, CC, CXX, and CPP.
+# OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
+# arguments during the linking process, which causes compilation failures.
+# To fix this issue, LD is set to point to gcc.
+# If ccache is enabled, Buildroot sets CC, CXX, and CPP to the ccache binary,
+# which causes the configuration error:
+# "Please use --enable-ccache instead of providing a wrapped compiler."
+# This error is why CC, CPP, and CXX are explicitly set to point to their
+# actual binaries.
+OPENJDK_CONF_ENV = \
+	PATH=$(BR_PATH) \
+	CC=$(TARGET_CC) \
+	CPP=$(TARGET_CPP) \
+	CXX=$(TARGET_CXX) \
+	LD=$(TARGET_CC)
+
+OPENJDK_CONF_OPTS = \
+	--disable-full-docs \
+	--disable-hotspot-gtest \
+	--disable-manpages \
+	--disable-warnings-as-errors \
+	--enable-headless-only \
+	--enable-openjdk-only \
+	--enable-unlimited-crypto \
+	--openjdk-target=$(GNU_TARGET_NAME) \
+	--with-boot-jdk=$(HOST_DIR) \
+	--with-debug-level=release \
+	--with-devkit=$(HOST_DIR) \
+	--with-extra-cflags="$(TARGET_CFLAGS)" \
+	--with-extra-cxxflags="$(TARGET_CXXFLAGS)" \
+	--with-giflib=system \
+	--with-jobs=$(PARALLEL_JOBS) \
+	--with-jvm-variants=$(OPENJDK_JVM_VARIANT_LIST) \
+	--with-lcms=system \
+	--with-libjpeg=system \
+	--with-libpng=system \
+	--with-native-debug-symbols=none \
+	--without-version-pre \
+	--with-sysroot=$(STAGING_DIR) \
+	--with-vendor-name="AdoptOpenJDK" \
+	--with-vendor-url="https://adoptopenjdk.net/" \
+	--with-vendor-version-string="AdoptOpenJDK" \
+	--with-version-build="$(OPENJDK_VERSION_MAJOR)" \
+	--with-version-string="$(OPENJDK_VERSION_MAJOR)" \
+	--with-zlib=bundled
+
+ifeq ($(BR2_CCACHE),y)
+OPENJDK_CONF_OPTS += \
+	--enable-ccache \
+	--with-ccache-dir=$(BR2_CCACHE_DIR)
+endif
+
+# Autogen and configure are performed in a single step.
+define OPENJDK_CONFIGURE_CMDS
+	chmod +x $(@D)/configure
+	cd $(@D); $(OPENJDK_CONF_ENV) ./configure autogen $(OPENJDK_CONF_OPTS)
+endef
+
+# Make -jn is unsupported. Instead, set the "--with-jobs=" configure option,
+# and use $(MAKE1).
+define OPENJDK_BUILD_CMDS
+	$(MAKE1) -C $(@D) legacy-jre-image
+endef
+
+# Calling make install always builds and installs the JDK instead of the JRE,
+# which makes manual installation necessary.
+define OPENJDK_INSTALL_TARGET_CMDS
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/* $(TARGET_DIR)/usr/bin/
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/
+endef
+
+$(eval $(generic-package))
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support
  2019-03-15 20:52 [Buildroot] [PATCH v8 1/3] openjdk: new package aduskett at gmail.com
@ 2019-03-15 20:52 ` aduskett at gmail.com
  2019-03-15 21:01   ` Thomas Petazzoni
  2019-03-17 13:08   ` Thomas Petazzoni
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 3/3] openjdk-hello-world: new test aduskett at gmail.com
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: aduskett at gmail.com @ 2019-03-15 20:52 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

OpenJDK has CPU ports for the AArch64 and ARM architectures.
Add support for AArch64 as the first.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
Changes v1 -> v8:
  - None

 package/openjdk/openjdk.mk | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
index 23fbbf5ea2..4934d66c3f 100644
--- a/package/openjdk/openjdk.mk
+++ b/package/openjdk/openjdk.mk
@@ -86,6 +86,11 @@ OPENJDK_CONF_OPTS = \
 	--with-version-string="$(OPENJDK_VERSION_MAJOR)" \
 	--with-zlib=bundled
 
+# If building for AArch64, use the provided CPU port.
+ifeq ($(BR2_aarch64),y)
+OPENJDK_CONF_OPTS += --with-cpu-port=aarch64 --with-abi-profile=aarch64
+endif
+
 ifeq ($(BR2_CCACHE),y)
 OPENJDK_CONF_OPTS += \
 	--enable-ccache \
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 3/3] openjdk-hello-world: new test
  2019-03-15 20:52 [Buildroot] [PATCH v8 1/3] openjdk: new package aduskett at gmail.com
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support aduskett at gmail.com
@ 2019-03-15 20:52 ` aduskett at gmail.com
  2019-03-17 13:10   ` Thomas Petazzoni
  2019-03-17 13:08 ` [Buildroot] [PATCH v8 1/3] openjdk: new package Thomas Petazzoni
  2019-03-19 21:51 ` Thomas Petazzoni
  3 siblings, 1 reply; 9+ messages in thread
From: aduskett at gmail.com @ 2019-03-15 20:52 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

This test is a simple "Hello, World" integration test of the OpenJDK package.

It compiles the Java app on the host, then runs it on an emulated AARCH64
target and verifies "Hello, World" is printed.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
Changes v1 -> v3:
  - Added this patch to the series.

Changes v3 -> v5:
  - None

Changes v5 -> v6:
  - Updated .gitlab-ci.yml entry.
  - Fixed From: and SOB line.

Changes v6 -> v7:
  - None

Changes v7 -> v8:
  - Added a 120 second timeout for the test (Matthew Weber)

 .gitlab-ci.yml                                |  1 +
 DEVELOPERS                                    |  1 +
 .../package/br2-external/openjdk/Config.in    |  1 +
 .../br2-external/openjdk/external.desc        |  1 +
 .../package/br2-external/openjdk/external.mk  |  1 +
 .../package/openjdk-hello-world/Config.in     | 26 ++++++++++++
 .../openjdk-hello-world/HelloWorld.java       |  7 ++++
 .../openjdk-hello-world.mk                    | 18 ++++++++
 support/testing/tests/package/test_openjdk.py | 42 +++++++++++++++++++
 9 files changed, 98 insertions(+)
 create mode 100644 support/testing/tests/package/br2-external/openjdk/Config.in
 create mode 100644 support/testing/tests/package/br2-external/openjdk/external.desc
 create mode 100644 support/testing/tests/package/br2-external/openjdk/external.mk
 create mode 100644 support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in
 create mode 100644 support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/HelloWorld.java
 create mode 100644 support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/openjdk-hello-world.mk
 create mode 100644 support/testing/tests/package/test_openjdk.py

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0bec55c19f..eef51e2768 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -328,6 +328,7 @@ tests.package.test_ipython.TestIPythonPy2: { extends: .runtime_test }
 tests.package.test_ipython.TestIPythonPy3: { extends: .runtime_test }
 tests.package.test_lua.TestLua: { extends: .runtime_test }
 tests.package.test_lua.TestLuajit: { extends: .runtime_test }
+tests.package.test_openjdk.TestOpenJdk: { extends: .runtime_test }
 tests.package.test_perl.TestPerl: { extends: .runtime_test }
 tests.package.test_perl_class_load.TestPerlClassLoad: { extends: .runtime_test }
 tests.package.test_perl_dbd_mysql.TestPerlDBDmysql: { extends: .runtime_test }
diff --git a/DEVELOPERS b/DEVELOPERS
index b4511bb053..ffd472d720 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1500,6 +1500,7 @@ F:	package/valijson/
 F:	package/wpa_supplicant/
 F:	package/wireless_tools/
 F:	package/xen/
+F:	support/testing/tests/package/br2-external/openjdk/
 
 N:	Mauro Condarelli <mc5686@mclink.it>
 F:	package/mc/
diff --git a/support/testing/tests/package/br2-external/openjdk/Config.in b/support/testing/tests/package/br2-external/openjdk/Config.in
new file mode 100644
index 0000000000..00c7fd4799
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/Config.in
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_OPENJDK_PATH/package/openjdk-hello-world/Config.in"
diff --git a/support/testing/tests/package/br2-external/openjdk/external.desc b/support/testing/tests/package/br2-external/openjdk/external.desc
new file mode 100644
index 0000000000..f28ba5060c
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/external.desc
@@ -0,0 +1 @@
+name: OPENJDK
diff --git a/support/testing/tests/package/br2-external/openjdk/external.mk b/support/testing/tests/package/br2-external/openjdk/external.mk
new file mode 100644
index 0000000000..54c24e8c64
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/external.mk
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_OPENJDK_PATH)/package/*/*.mk))
diff --git a/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in
new file mode 100644
index 0000000000..4f9022fb92
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in
@@ -0,0 +1,26 @@
+config BR2_PACKAGE_OPENJDK_HELLO_WORLD
+	bool "openjdk hello world"
+	depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_XORG7
+	depends on BR2_USE_WCHAR # gtk2 -> glib2
+	depends on BR2_TOOLCHAIN_HAS_THREADS # gtk2 -> glib2
+	depends on BR2_USE_MMU # gtk2 -> glib2
+	depends on BR2_INSTALL_LIBSTDCPP # gtk2, cups
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C++11
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # gtk2 -> pango -> harfbuzz
+	depends on !BR2_STATIC_LIBS
+	select BR2_PACKAGE_OPENJDK
+	help
+	  Simple class for testing openjdk
+
+comment "OpenJDK-hello-world needs a glibc toolchain w/ wchar, dynamic library, threads, C++, gcc >= 4.9"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on BR2_PACKAGE_XORG7
+	depends on !BR2_USE_WCHAR || \
+		BR2_STATIC_LIBS || \
+		!BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
+		!BR2_TOOLCHAIN_HAS_THREADS || \
+		!BR2_TOOLCHAIN_USES_GLIBC
diff --git a/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/HelloWorld.java b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/HelloWorld.java
new file mode 100644
index 0000000000..37489e44c3
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/HelloWorld.java
@@ -0,0 +1,7 @@
+public class HelloWorld
+{
+    public static void main(String[] args)
+    {
+        System.out.println("Hello, World");
+    }
+}
diff --git a/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/openjdk-hello-world.mk b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/openjdk-hello-world.mk
new file mode 100644
index 0000000000..998117b8e2
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/openjdk-hello-world.mk
@@ -0,0 +1,18 @@
+################################################################################
+#
+# openjdk hello world
+#
+################################################################################
+
+OPENJDK_HELLO_WORLD_DEPENDENCIES = openjdk
+
+define OPENJDK_HELLO_WORLD_BUILD_CMDS
+	$(INSTALL) -D $(OPENJDK_HELLO_WORLD_PKGDIR)/HelloWorld.java $(@D)/HelloWorld.java
+	$(HOST_DIR)/bin/javac $(@D)/HelloWorld.java
+endef
+
+define OPENJDK_HELLO_WORLD_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 755 $(@D)/HelloWorld.class $(TARGET_DIR)/usr/bin/HelloWorld.class
+endef
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/package/test_openjdk.py b/support/testing/tests/package/test_openjdk.py
new file mode 100644
index 0000000000..5fbb500fbd
--- /dev/null
+++ b/support/testing/tests/package/test_openjdk.py
@@ -0,0 +1,42 @@
+import os
+
+import infra.basetest
+
+
+class TestOpenJdk(infra.basetest.BRTest):
+    br2_external = [infra.filepath("tests/package/br2-external/openjdk")]
+    config = \
+        """
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.16.7"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_CPIO_GZIP=y
+        BR2_PACKAGE_XORG7=y
+        BR2_PACKAGE_OPENJDK=y
+        BR2_PACKAGE_OPENJDK_HELLO_WORLD=y
+        """
+
+    def login(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+        kern = os.path.join(self.builddir, "images", "Image")
+        self.emulator.boot(arch="aarch64",
+                           kernel=kern,
+                           kernel_cmdline=["console=ttyAMA0"],
+                           options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M", "-initrd", img])
+        self.emulator.login()
+
+    def test_run(self):
+        self.login()
+
+        cmd = "java -cp /usr/bin HelloWorld"
+        output, exit_code = self.emulator.run(cmd, 120)
+        print(output)
+        self.assertEqual(exit_code, 0)
+        self.assertEqual(output, ["Hello, World"])
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support aduskett at gmail.com
@ 2019-03-15 21:01   ` Thomas Petazzoni
  2019-03-16 17:13     ` Adam Duskett
  2019-03-17 13:08   ` Thomas Petazzoni
  1 sibling, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2019-03-15 21:01 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 15 Mar 2019 16:52:32 -0400
aduskett at gmail.com wrote:

> From: Adam Duskett <Aduskett@gmail.com>
> 
> OpenJDK has CPU ports for the AArch64 and ARM architectures.
> Add support for AArch64 as the first.
> 
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>

I am still confused by what happens on AArch64 if I only apply PATCH
1/3 in this series, but not PATCH 2/3.

Shouldn't PATCH 1/3 restrict package/openjdk to the set of
known-working architectures ? Is there some architecture specific code
in openjdk that would make it available only on a subset of the
architectures we support ?

Thanks

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support
  2019-03-15 21:01   ` Thomas Petazzoni
@ 2019-03-16 17:13     ` Adam Duskett
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Duskett @ 2019-03-16 17:13 UTC (permalink / raw)
  To: buildroot

Hey Thomas;
On Fri, Mar 15, 2019 at 5:01 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Fri, 15 Mar 2019 16:52:32 -0400
> aduskett at gmail.com wrote:
>
> > From: Adam Duskett <Aduskett@gmail.com>
> >
> > OpenJDK has CPU ports for the AArch64 and ARM architectures.
> > Add support for AArch64 as the first.
> >
> > Signed-off-by: Adam Duskett <Aduskett@gmail.com>
>
> I am still confused by what happens on AArch64 if I only apply PATCH
> 1/3 in this series, but not PATCH 2/3.
>
That would be fine. AArch64 would still work, it just wouldn't be as fast.
This patch only provides optimization.

> Shouldn't PATCH 1/3 restrict package/openjdk to the set of
> known-working architectures ? Is there some architecture specific code
> in openjdk that would make it available only on a subset of the
> architectures we support?
>
Not that I am aware of, although I haven't compiled for every
architecture either.
However; Matthew Webber has compiled for PPC64 and it seems to also work
there.

Thanks!
Adam
> Thanks
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 1/3] openjdk: new package
  2019-03-15 20:52 [Buildroot] [PATCH v8 1/3] openjdk: new package aduskett at gmail.com
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support aduskett at gmail.com
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 3/3] openjdk-hello-world: new test aduskett at gmail.com
@ 2019-03-17 13:08 ` Thomas Petazzoni
  2019-03-19 21:51 ` Thomas Petazzoni
  3 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2019-03-17 13:08 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 15 Mar 2019 16:52:31 -0400
aduskett at gmail.com wrote:

> - If ccache is enabled, Buildroot sets CC, CXX, and CPP to the ccache binary,

Actually this is not correct: CC, CXX, CPP and al. point to the
toolchain wrapper, and the use of ccache is completely hidden inside
the toolchain wrapper.

It is HOSTCC/HOSTCXX and al. and are of the form "ccache gcc".

So I've dropped this comment from the commit log and the .mk, because
it was not correct.

> - Even when cross-compiling, OpenJDK builds several host-tools using the host's
>   gcc. In the case of zlib, if a host doesn't have the zlib development package
>   installed, OpenJDK compilation stops because zlib.h won't exist on the host
>   system. Because zlib is used to compile both native tools and cross-compiled
>   tools, patching make/autoconf/lib-bundled.m4 to call PKG_CHECK_MODULES for
>   zlib results in the host gcc trying to use cross-compiled libraries for
>   compiling native tools, which results in linking failures.
>   Using --with-zlib=bundled allows OpenJDK to compile correctly.

I have fixed the package to use --with-zlib=system. The key was to pass
BUILD_SYSROOT_CFLAGS="$(HOST_CFLAGS)" and
BUILD_SYSROOT_LDFLAGS="$(HOST_LDFLAGS)" so that the host-zlib library
is properly found.


> +config BR2_PACKAGE_OPENJDK
> +	bool "OpenJDK"
> +	depends on !BR2_SOFT_FLOAT
> +	depends on !BR2_STATIC_LIBS # Glibc
> +	depends on BR2_INSTALL_LIBSTDCPP # cups
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # alsa-lib, cups, libusb
> +	depends on BR2_TOOLCHAIN_USES_GLIBC
> +	depends on BR2_USE_MMU # cups
> +	depends on BR2_PACKAGE_XORG7
> +	select BR2_PACKAGE_ALSA_LIB
> +	select BR2_PACKAGE_CUPS
> +	select BR2_PACKAGE_FONTCONFIG
> +	select BR2_PACKAGE_GIFLIB
> +	select BR2_PACKAGE_JPEG
> +	select BR2_PACKAGE_LCMS2
> +	select BR2_PACKAGE_LIBPNG
> +	select BR2_PACKAGE_LIBUSB
> +	select BR2_PACKAGE_XLIB_LIBXRENDER
> +	select BR2_PACKAGE_XLIB_LIBXT
> +	select BR2_PACKAGE_XLIB_LIBXTST

I've added:

	select BR2_PACKAGE_ZLIB


> +if BR2_PACKAGE_OPENJDK
> +
> +menu "JVM Variants"

I have dropped this menu, and in the main option, I've added a "select"
that ensures at least one of the client and/or server variants are
enabled.

> +comment "OpenJDK needs X.Org"

	depends on BR2_USE_MMU

was missing

> +	depends on !BR2_PACKAGE_XORG7
> +
> +comment "OpenJDK needs glibc, and a toolchain w/ wchar, dynamic library, threads, C++"
> +	depends on BR2_USE_MMU
> +	depends on BR2_STATIC_LIBS || !BR2_INSTALL_LIBSTDCPP || \
> +		!BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
> +
> +comment "OpenJDK does not support soft floats"

	depends on BR2_USE_MMU

was missing as well.


> +# OpenJDK ignores some variables unless passed via the environment.
> +# These variables are PATH, LD, CC, CXX, and CPP.
> +# OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
> +# arguments during the linking process, which causes compilation failures.
> +# To fix this issue, LD is set to point to gcc.
> +# If ccache is enabled, Buildroot sets CC, CXX, and CPP to the ccache binary,
> +# which causes the configuration error:
> +# "Please use --enable-ccache instead of providing a wrapped compiler."
> +# This error is why CC, CPP, and CXX are explicitly set to point to their
> +# actual binaries.

So I've dropped this explanation about ccache.

> +OPENJDK_CONF_ENV = \
> +	PATH=$(BR_PATH) \
> +	CC=$(TARGET_CC) \
> +	CPP=$(TARGET_CPP) \
> +	CXX=$(TARGET_CXX) \
> +	LD=$(TARGET_CC)

... and defined BUILD_SYSROOT_CFLAGS and BUILD_SYSROOT_LDFLAGS.

> +	--with-zlib=bundled

and used --with-zlib=system

Applied with those changes!

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support aduskett at gmail.com
  2019-03-15 21:01   ` Thomas Petazzoni
@ 2019-03-17 13:08   ` Thomas Petazzoni
  1 sibling, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2019-03-17 13:08 UTC (permalink / raw)
  To: buildroot

On Fri, 15 Mar 2019 16:52:32 -0400
aduskett at gmail.com wrote:

> From: Adam Duskett <Aduskett@gmail.com>
> 
> OpenJDK has CPU ports for the AArch64 and ARM architectures.
> Add support for AArch64 as the first.
> 
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> ---
> Changes v1 -> v8:
>   - None

Applied to master with an improved commit title/log.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 3/3] openjdk-hello-world: new test
  2019-03-15 20:52 ` [Buildroot] [PATCH v8 3/3] openjdk-hello-world: new test aduskett at gmail.com
@ 2019-03-17 13:10   ` Thomas Petazzoni
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2019-03-17 13:10 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 15 Mar 2019 16:52:33 -0400
aduskett at gmail.com wrote:

> diff --git a/DEVELOPERS b/DEVELOPERS
> index b4511bb053..ffd472d720 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1500,6 +1500,7 @@ F:	package/valijson/
>  F:	package/wpa_supplicant/
>  F:	package/wireless_tools/
>  F:	package/xen/
> +F:	support/testing/tests/package/br2-external/openjdk/

The test_openjdk.py file was not listed here, so I've added it.

> diff --git a/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in
> new file mode 100644
> index 0000000000..4f9022fb92
> --- /dev/null
> +++ b/support/testing/tests/package/br2-external/openjdk/package/openjdk-hello-world/Config.in
> @@ -0,0 +1,26 @@
> +config BR2_PACKAGE_OPENJDK_HELLO_WORLD
> +	bool "openjdk hello world"
> +	depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
> +	depends on BR2_TOOLCHAIN_USES_GLIBC
> +	depends on BR2_PACKAGE_XORG7
> +	depends on BR2_USE_WCHAR # gtk2 -> glib2
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # gtk2 -> glib2
> +	depends on BR2_USE_MMU # gtk2 -> glib2
> +	depends on BR2_INSTALL_LIBSTDCPP # gtk2, cups
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C++11
> +	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # gtk2 -> pango -> harfbuzz
> +	depends on !BR2_STATIC_LIBS
> +	select BR2_PACKAGE_OPENJDK

For a test case, I don't think it made a lot of sense to replicate all
those dependencies. For example, you were missing the dependency
on !BR2_SOFT_FLOAT.

So instead, I've replaced all of this by a much simpler;

	depends on BR2_PACKAGE_OPENJDK

Applied with this fixed.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH v8 1/3] openjdk: new package
  2019-03-15 20:52 [Buildroot] [PATCH v8 1/3] openjdk: new package aduskett at gmail.com
                   ` (2 preceding siblings ...)
  2019-03-17 13:08 ` [Buildroot] [PATCH v8 1/3] openjdk: new package Thomas Petazzoni
@ 2019-03-19 21:51 ` Thomas Petazzoni
  3 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2019-03-19 21:51 UTC (permalink / raw)
  To: buildroot

Hello Adam,

On Fri, 15 Mar 2019 16:52:31 -0400
aduskett at gmail.com wrote:

> From: Adam Duskett <Aduskett@gmail.com>
> 
> OpenJDK is a free and open-source implementation of the Java Platform.
> This package provides the option to build a client or a server JVM interpreter.

Since it was merged, this package caused a few build issues (but not
that many). I had a quick look in order to hopefully help resolving
them:

 - http://autobuild.buildroot.net/results/a03/a034e641fe163d4502fd9411af1d96c14d13c5f2/build-end.log
   http://autobuild.buildroot.net/results/84f/84f423cc795ce0957801a5f7b35c0c800f527fb1/build-end.log

   These are the same, the host machine tuple is not recognized. I
   believe the fix is as easy as adding a POST_PATCH_HOOKS that copies
   support/gnuconfig/config.sub over $(@D)/make/autoconf/build-aux/autoconf-config.sub

 - http://autobuild.buildroot.net/results/f76/f763193801c4af8289c49832811395df49b1b876/build-end.log

   This one has stuff like error: unknown type name
   'snd_rawmidi_stream_t'; did you mean 'snd_pcm_stream_t'?. The problem is that the configuration has 
   BR2_PACKAGE_ALSA_LIB_RAWMIDI disabled. I would recommend you to make
   a build of OpenJDK with BR2_PACKAGE_ALSA_LIB=y but all its
   sub-options disabled, and see which sub-options are mandatory for
   OpenJDK to build. Then you can add the relevant select
   BR2_PACKAGE_ALSA_LIB_foobaz to openjdk/Config.in

 - http://autobuild.buildroot.net/results/9d2/9d27e6389a18ddf4266511b58e827487d4a78437/build-end.log

   This one is some weird OpenJDK specific stuff, I can't really help
   here.

 - http://autobuild.buildroot.net/results/633/633b2361f7ab588fcc41fcbf5e92aa4eca895c6a/build-end.log

   Same for this one.

Best regards,

Thomas Petazzoni
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-03-19 21:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-15 20:52 [Buildroot] [PATCH v8 1/3] openjdk: new package aduskett at gmail.com
2019-03-15 20:52 ` [Buildroot] [PATCH v8 2/3] package/openjdk: package/openjdk: Add AArch64 support aduskett at gmail.com
2019-03-15 21:01   ` Thomas Petazzoni
2019-03-16 17:13     ` Adam Duskett
2019-03-17 13:08   ` Thomas Petazzoni
2019-03-15 20:52 ` [Buildroot] [PATCH v8 3/3] openjdk-hello-world: new test aduskett at gmail.com
2019-03-17 13:10   ` Thomas Petazzoni
2019-03-17 13:08 ` [Buildroot] [PATCH v8 1/3] openjdk: new package Thomas Petazzoni
2019-03-19 21:51 ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox