From unknown Mon Jun 23 06:01:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#41748] [PATCH 0/1] Fix JamVM to work with current gcc and glibc Resent-From: Simon South Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 07 Jun 2020 15:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41748 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41748@debbugs.gnu.org Cc: Simon South X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159154313726258 (code B ref -1); Sun, 07 Jun 2020 15:19:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Jun 2020 15:18:57 +0000 Received: from localhost ([127.0.0.1]:54610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhx4a-0006pS-KX for submit@debbugs.gnu.org; Sun, 07 Jun 2020 11:18:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:51090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhx4Z-0006pL-EA for submit@debbugs.gnu.org; Sun, 07 Jun 2020 11:18:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhx4Z-0000BF-9B for guix-patches@gnu.org; Sun, 07 Jun 2020 11:18:55 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:54534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhx4Y-0005t9-0o for guix-patches@gnu.org; Sun, 07 Jun 2020 11:18:55 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 2684D214A7; Sun, 7 Jun 2020 15:18:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo06-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo06-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rU9Ad7KC1Jtt; Sun, 7 Jun 2020 15:18:51 +0000 (UTC) Received: from localhost.localdomain (unknown [108.162.141.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 55B3021403; Sun, 7 Jun 2020 15:18:49 +0000 (UTC) From: Simon South Date: Sun, 7 Jun 2020 11:17:09 -0400 Message-Id: <20200607151709.21821-1-simon@simonsouth.net> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.68.200.34; envelope-from=simon@simonsouth.net; helo=mailout.easymail.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/07 11:18:52 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This patch allows JamVM 2.0.0 to be built without using outdated versions of gcc and glibc, by disabling the branch-patching optimization JamVM normally applies to code it has inlined. I've successfully built IcedTea 1.13.13 on x86_64 with this patch applied, without encountering any "Invalid instruction" errors. It also seems to work fine on aarch64. Lengthy explanation, for anyone interested in the details: JamVM's branch-patching optimization tries to improve the performance of Java's branching opcodes by replacing the load-operand-and-jump portion of their implementation with a single jump instruction directly to the handler for the opcode to which the operand points. However, the current implementation - Doesn't attempt much of an optimization, since it only replaces the final jump instruction with another (the operand is still loaded in either case). - Doesn't have any actual effect since the instruction it replaces is a duplicate synthesized by gcc that is never executed anyway. - Is prone to breakage, since it doesn't ensure the new jump instruction is the same length as the original. (This is the specific reason for the failure on x86_64: The replacement jump instruction is longer and clobbers part of the following instruction, making it invalid.) This patch simply disables the optimization within JamVM, leaving the other optimizations intact. (gcc is smart enough to no longer generate duplicate jump instructions in this case so it reduces the code size slightly, too.) Alternate solutions I considered and rejected: - Fixing the implementation. JamVM uses a label to mark within each opcode's handler where the jump instruction should be placed, and moving this label to the start of the load-and-jump sequence rather than the end appears (from stepping through the code with gdb) to fix all the issues above. However, JamVM then fails at startup, reporting an unhandle-able exception during initialization. So presumably some other part of the code relies on the current, broken implementation of this feature, and while it's probably possible to fix _that_ as well I doubt it would be worth the effort. - Disabling the optimization at runtime. Invoking JamVM with "-Xnopatching" also solves the problem, and we could just update the bootstrap procedure to do this. However JamVM 1.5.1 doesn't recognize this option and fails if it's specified, so we'd need to change the ecj-javac-wrapper package to handle the two interpreters differently or to accept an argument specifying the flags to use, and in my opinion this would be a step backwards from what exists currently. Also, since JamVM would only ever work reliably when this option is specified, it's not really much of an "option" and making its effect permanent in the code seems like a more sensible approach. -- Simon South simon@simonsouth.net Simon South (1): gnu: jamvm: Fix to work with current gcc and glibc. gnu/packages/java.scm | 7 ++--- .../jamvm-2.0.0-disable-branch-patching.patch | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch -- 2.26.2 From unknown Mon Jun 23 06:01:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#41748] [PATCH 1/1] gnu: jamvm: Fix to work with current gcc and glibc. References: <20200607151709.21821-1-simon@simonsouth.net> In-Reply-To: <20200607151709.21821-1-simon@simonsouth.net> Resent-From: Simon South Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 07 Jun 2020 15:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41748 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41748@debbugs.gnu.org Cc: Simon South Received: via spool by 41748-submit@debbugs.gnu.org id=B41748.159154322226445 (code B ref 41748); Sun, 07 Jun 2020 15:21:01 +0000 Received: (at 41748) by debbugs.gnu.org; 7 Jun 2020 15:20:22 +0000 Received: from localhost ([127.0.0.1]:54618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhx5y-0006sT-Ax for submit@debbugs.gnu.org; Sun, 07 Jun 2020 11:20:22 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:54546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhx5x-0006sD-5w for 41748@debbugs.gnu.org; Sun, 07 Jun 2020 11:20:21 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 9D81BA0799; Sun, 7 Jun 2020 15:20:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo05-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo05-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NKxnbsqK80RW; Sun, 7 Jun 2020 15:20:15 +0000 (UTC) Received: from localhost.localdomain (unknown [108.162.141.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id E8740A0075; Sun, 7 Jun 2020 15:20:13 +0000 (UTC) From: Simon South Date: Sun, 7 Jun 2020 11:18:33 -0400 Message-Id: <20200607151833.22052-1-simon@simonsouth.net> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch: New file. * gnu/packages/java.scm (jamvm)[source]: Add patch. (jamvm-1-bootstrap)[native-inputs]: Remove. --- gnu/packages/java.scm | 7 ++--- .../jamvm-2.0.0-disable-branch-patching.patch | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 43f0f37b91..9a6f6fe0df 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -254,11 +254,6 @@ language.") ("libffi" ,libffi) ("zip" ,zip) ("zlib" ,zlib))) - ;; When built with a recent GCC and glibc the configure step of icedtea-6 - ;; fails with an invalid instruction error. - (native-inputs - `(("gcc" ,gcc-5) - ("libc" ,glibc-2.28))) (home-page "http://jamvm.sourceforge.net/") (synopsis "Small Java Virtual Machine") (description "JamVM is a Java Virtual Machine conforming to the JVM @@ -708,6 +703,8 @@ machine."))) (sha256 (base32 "1nl0zxz8y5x8gwsrm7n32bry4dx8x70p8z3s9jbdvs8avyb8whkn")) + (patches + (search-patches "jamvm-2.0.0-disable-branch-patching.patch")) (snippet '(begin ;; Remove precompiled software. diff --git a/gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch b/gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch new file mode 100644 index 0000000000..a99624280f --- /dev/null +++ b/gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch @@ -0,0 +1,27 @@ +From 8d10be7345d7fe139e619cc55a22dbc86f677543 Mon Sep 17 00:00:00 2001 +From: Simon South +Date: Sat, 6 Jun 2020 18:56:56 -0400 +Subject: [PATCH] Disable branch-patching + +--- + src/init.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/init.c b/src/init.c +index 32539cf..38ad54b 100644 +--- a/src/init.c ++++ b/src/init.c +@@ -72,8 +72,8 @@ void setDefaultInitArgs(InitArgs *args) { + #ifdef INLINING + args->replication_threshold = 10; + args->profile_threshold = 10; +- args->branch_patching_dup = TRUE; +- args->branch_patching = TRUE; ++ args->branch_patching_dup = FALSE; ++ args->branch_patching = FALSE; + args->print_codestats = FALSE; + args->join_blocks = TRUE; + args->profiling = TRUE; +-- +2.25.2 + -- 2.26.2 From unknown Mon Jun 23 06:01:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#41748] [PATCH 0/1] Fix JamVM to work with current gcc and glibc Resent-From: Simon South Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 10 Jun 2020 15:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41748 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41748@debbugs.gnu.org Received: via spool by 41748-submit@debbugs.gnu.org id=B41748.15918015312858 (code B ref 41748); Wed, 10 Jun 2020 15:06:02 +0000 Received: (at 41748) by debbugs.gnu.org; 10 Jun 2020 15:05:31 +0000 Received: from localhost ([127.0.0.1]:35083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj2IA-0000jx-Sp for submit@debbugs.gnu.org; Wed, 10 Jun 2020 11:05:31 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:51454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj2I5-0000ja-D5 for 41748@debbugs.gnu.org; Wed, 10 Jun 2020 11:05:25 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id C7D5F22298 for <41748@debbugs.gnu.org>; Wed, 10 Jun 2020 15:05:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo06-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo06-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PZxG-bV3Qoeb for <41748@debbugs.gnu.org>; Wed, 10 Jun 2020 15:05:14 +0000 (UTC) Received: from laptop (unknown [108.162.141.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id E2F4120F90 for <41748@debbugs.gnu.org>; Wed, 10 Jun 2020 15:05:12 +0000 (UTC) From: Simon South References: <20200607151709.21821-1-simon@simonsouth.net> Date: Wed, 10 Jun 2020 11:03:39 -0400 In-Reply-To: <20200607151709.21821-1-simon@simonsouth.net> (Simon South's message of "Sun, 7 Jun 2020 11:17:09 -0400") Message-ID: <87a71botdg.fsf@simonsouth.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Attached is an updated version of this patch that - Adds a brief description to the patch it contains, indicating why it is necessary; and - Updates gnu/local.mk, as is apparently now required. -- Simon South simon@simonsouth.net --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-gnu-jamvm-Fix-to-work-with-current-gcc-and-glibc.patch >From 3dbc081418737b0901982f89b8eb260b6c8bd3f0 Mon Sep 17 00:00:00 2001 From: Simon South Date: Sat, 6 Jun 2020 19:53:39 -0400 Subject: [PATCH] gnu: jamvm: Fix to work with current gcc and glibc. * gnu/packages/java.scm (jamvm)[source]: Add patch. (jamvm-1-bootstrap)[native-inputs]: Remove. * gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 1 + gnu/packages/java.scm | 7 ++--- .../jamvm-2.0.0-disable-branch-patching.patch | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch diff --git a/gnu/local.mk b/gnu/local.mk index 76d6b5deba..7d65fbb605 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1107,6 +1107,7 @@ dist_patch_DATA = \ %D%/packages/patches/irrlicht-use-system-libs.patch \ %D%/packages/patches/isl-0.11.1-aarch64-support.patch \ %D%/packages/patches/jacal-fix-texinfo.patch \ + %D%/packages/patches/jamvm-2.0.0-disable-branch-patching.patch \ %D%/packages/patches/jamvm-arm.patch \ %D%/packages/patches/java-apache-ivy-port-to-latest-bouncycastle.patch \ %D%/packages/patches/java-commons-collections-fix-java8.patch \ diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 43f0f37b91..9a6f6fe0df 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -254,11 +254,6 @@ language.") ("libffi" ,libffi) ("zip" ,zip) ("zlib" ,zlib))) - ;; When built with a recent GCC and glibc the configure step of icedtea-6 - ;; fails with an invalid instruction error. - (native-inputs - `(("gcc" ,gcc-5) - ("libc" ,glibc-2.28))) (home-page "http://jamvm.sourceforge.net/") (synopsis "Small Java Virtual Machine") (description "JamVM is a Java Virtual Machine conforming to the JVM @@ -708,6 +703,8 @@ machine."))) (sha256 (base32 "1nl0zxz8y5x8gwsrm7n32bry4dx8x70p8z3s9jbdvs8avyb8whkn")) + (patches + (search-patches "jamvm-2.0.0-disable-branch-patching.patch")) (snippet '(begin ;; Remove precompiled software. diff --git a/gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch b/gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch new file mode 100644 index 0000000000..1352ed7803 --- /dev/null +++ b/gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch @@ -0,0 +1,31 @@ +From d80cfc83325f8e95d35ecd9f15b36b96fa9ed3ee Mon Sep 17 00:00:00 2001 +From: Simon South +Date: Sat, 6 Jun 2020 18:56:56 -0400 +Subject: [PATCH] Disable branch-patching + +This patch disables JamVM's branch-patching optimization, which tends +to make JamVM fail with an "Illegal instruction" error on x86_64 (and +possibly other architectures that use variable-length instructions) +when built using modern versions of gcc and glibc. +--- + src/init.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/init.c b/src/init.c +index 32539cf..38ad54b 100644 +--- a/src/init.c ++++ b/src/init.c +@@ -72,8 +72,8 @@ void setDefaultInitArgs(InitArgs *args) { + #ifdef INLINING + args->replication_threshold = 10; + args->profile_threshold = 10; +- args->branch_patching_dup = TRUE; +- args->branch_patching = TRUE; ++ args->branch_patching_dup = FALSE; ++ args->branch_patching = FALSE; + args->print_codestats = FALSE; + args->join_blocks = TRUE; + args->profiling = TRUE; +-- +2.25.2 + -- 2.26.2 --=-=-=-- From unknown Mon Jun 23 06:01:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Simon South Subject: bug#41748: closed (Re: [bug#41748] [PATCH 0/1] Fix JamVM to work with current gcc and glibc) Message-ID: References: <87bllabzww.fsf@gnu.org> <20200607151709.21821-1-simon@simonsouth.net> X-Gnu-PR-Message: they-closed 41748 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 41748@debbugs.gnu.org Date: Mon, 22 Jun 2020 20:38:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1592858282-5888-1" This is a multi-part message in MIME format... ------------=_1592858282-5888-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #41748: [PATCH 0/1] Fix JamVM to work with current gcc and glibc which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 41748@debbugs.gnu.org. --=20 41748: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D41748 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1592858282-5888-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 41748-done) by debbugs.gnu.org; 22 Jun 2020 20:37:20 +0000 Received: from localhost ([127.0.0.1]:34676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jnTBw-0001W5-K1 for submit@debbugs.gnu.org; Mon, 22 Jun 2020 16:37:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58274) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jnTBs-0001Vp-LQ for 41748-done@debbugs.gnu.org; Mon, 22 Jun 2020 16:37:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48681) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnTBk-0004oR-7k; Mon, 22 Jun 2020 16:37:10 -0400 Received: from ti0006q161-3115.bb.online.no ([88.95.106.80]:58364 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jnTBj-0004XF-3S; Mon, 22 Jun 2020 16:37:07 -0400 From: Marius Bakke To: Simon South , 41748-done@debbugs.gnu.org Subject: Re: [bug#41748] [PATCH 0/1] Fix JamVM to work with current gcc and glibc In-Reply-To: <20200607151709.21821-1-simon@simonsouth.net> References: <20200607151709.21821-1-simon@simonsouth.net> Date: Mon, 22 Jun 2020 22:37:03 +0200 Message-ID: <87bllabzww.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41748-done Cc: Simon South X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Simon South writes: > This patch allows JamVM 2.0.0 to be built without using outdated versions of > gcc and glibc, by disabling the branch-patching optimization JamVM normally > applies to code it has inlined. > > I've successfully built IcedTea 1.13.13 on x86_64 with this patch applied, > without encountering any "Invalid instruction" errors. It also seems to work > fine on aarch64. Thanks a lot for this patch, and the brilliant analysis. I have applied the updated version and will push shortly. I modified it to also remove the (gnu packages gcc) import from java.scm. \o/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl7xFm8ACgkQoqBt8qM6 VPpS6AgAxLCzzByJwscvZVkAF7DhFqsoPU55JrjAJqkTQKwK1WCMmEBSuIEsYrfx scJvskqZcdbWOtdndiapzvgA3ifa36Oi5l/Lk383JIrMnuXACZIyLPEdQ13nyebs gT2UHo+ebMG9a3dFjC5jRydCfMptD12YboqiKOS3/MwFDzfkIs1XDYfTEBm9dqFZ Io7KBcBQ3xfpa3IE9lhcpEsl1a7FpZ4Skz/HKy8e/f6zgvwr36oysV/PSWZidSMv wBuV8xTZK9iZh04l8bx6GT98FShqNVWJf5zeDV7d0V1L9GabwkcIaYY8eRSf35zk yDYNq9Vx/coZlCxgXnsxTgKDoDP+kw== =rbjk -----END PGP SIGNATURE----- --=-=-=-- ------------=_1592858282-5888-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 7 Jun 2020 15:18:57 +0000 Received: from localhost ([127.0.0.1]:54610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhx4a-0006pS-KX for submit@debbugs.gnu.org; Sun, 07 Jun 2020 11:18:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:51090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhx4Z-0006pL-EA for submit@debbugs.gnu.org; Sun, 07 Jun 2020 11:18:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhx4Z-0000BF-9B for guix-patches@gnu.org; Sun, 07 Jun 2020 11:18:55 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:54534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhx4Y-0005t9-0o for guix-patches@gnu.org; Sun, 07 Jun 2020 11:18:55 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 2684D214A7; Sun, 7 Jun 2020 15:18:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo06-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo06-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rU9Ad7KC1Jtt; Sun, 7 Jun 2020 15:18:51 +0000 (UTC) Received: from localhost.localdomain (unknown [108.162.141.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 55B3021403; Sun, 7 Jun 2020 15:18:49 +0000 (UTC) From: Simon South To: guix-patches@gnu.org Subject: [PATCH 0/1] Fix JamVM to work with current gcc and glibc Date: Sun, 7 Jun 2020 11:17:09 -0400 Message-Id: <20200607151709.21821-1-simon@simonsouth.net> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.68.200.34; envelope-from=simon@simonsouth.net; helo=mailout.easymail.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/07 11:18:52 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Simon South X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This patch allows JamVM 2.0.0 to be built without using outdated versions of gcc and glibc, by disabling the branch-patching optimization JamVM normally applies to code it has inlined. I've successfully built IcedTea 1.13.13 on x86_64 with this patch applied, without encountering any "Invalid instruction" errors. It also seems to work fine on aarch64. Lengthy explanation, for anyone interested in the details: JamVM's branch-patching optimization tries to improve the performance of Java's branching opcodes by replacing the load-operand-and-jump portion of their implementation with a single jump instruction directly to the handler for the opcode to which the operand points. However, the current implementation - Doesn't attempt much of an optimization, since it only replaces the final jump instruction with another (the operand is still loaded in either case). - Doesn't have any actual effect since the instruction it replaces is a duplicate synthesized by gcc that is never executed anyway. - Is prone to breakage, since it doesn't ensure the new jump instruction is the same length as the original. (This is the specific reason for the failure on x86_64: The replacement jump instruction is longer and clobbers part of the following instruction, making it invalid.) This patch simply disables the optimization within JamVM, leaving the other optimizations intact. (gcc is smart enough to no longer generate duplicate jump instructions in this case so it reduces the code size slightly, too.) Alternate solutions I considered and rejected: - Fixing the implementation. JamVM uses a label to mark within each opcode's handler where the jump instruction should be placed, and moving this label to the start of the load-and-jump sequence rather than the end appears (from stepping through the code with gdb) to fix all the issues above. However, JamVM then fails at startup, reporting an unhandle-able exception during initialization. So presumably some other part of the code relies on the current, broken implementation of this feature, and while it's probably possible to fix _that_ as well I doubt it would be worth the effort. - Disabling the optimization at runtime. Invoking JamVM with "-Xnopatching" also solves the problem, and we could just update the bootstrap procedure to do this. However JamVM 1.5.1 doesn't recognize this option and fails if it's specified, so we'd need to change the ecj-javac-wrapper package to handle the two interpreters differently or to accept an argument specifying the flags to use, and in my opinion this would be a step backwards from what exists currently. Also, since JamVM would only ever work reliably when this option is specified, it's not really much of an "option" and making its effect permanent in the code seems like a more sensible approach. -- Simon South simon@simonsouth.net Simon South (1): gnu: jamvm: Fix to work with current gcc and glibc. gnu/packages/java.scm | 7 ++--- .../jamvm-2.0.0-disable-branch-patching.patch | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/jamvm-2.0.0-disable-branch-patching.patch -- 2.26.2 ------------=_1592858282-5888-1--