Subject: bug#36685: ant-bootstrap fails on core-updates (409 dependents)

From: Ricardo Wurmus <[email-masked]>
Date: Thu, 18 Jul 2019 00:41:56 +0200

Ricardo Wurmus <[email-masked]> writes:

> I have confirmed that this is the problem by replacing “while
> (VMFile.exists(file.path))” with “while (false)”.  The build doesn’t
> fully complete then either, but it gets past the compilation of the Ant
> source files.  This clears JamVM and Jikes.

It doesn’t.

VMFile.exists always returns “true”, no matter what.  The C part is
fine, but the Java part is not, so I suspected the JVM to be at fault.

I managed to build ant-bootstrap successfully with this patch:

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 403c446a82..6ebfd0ffdf 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -152,6 +152,12 @@ and binary format defined in The Java Virtual Machine Specification.")
              "--disable-gjdoc")
        #:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'foo
+           (lambda _
+             (substitute* "native/jni/java-io/java_io_VMFile.c"
+               (("result = cpio_isFileExists.*" m)
+                (string-append m "\nfprintf(stderr, \"exists? %s : %d -- %d;\\n\", filename, result, ((result == CPNATIVE_OK) ? 1 : 0));")))
+             #t))
          (add-after 'install 'install-data
            (lambda _ (invoke "make" "install-data"))))))
     (native-inputs
@@ -186,10 +192,12 @@ language.")
     (arguments
      `(#:configure-flags
        (list (string-append "--with-classpath-install-dir="
-                            (assoc-ref %build-inputs "classpath")))))
+                            (assoc-ref %build-inputs "classpath"))
+             "--enable-ffi")))
     (inputs
      `(("classpath" ,classpath-bootstrap)
        ("jikes" ,jikes)
+       ("libffi" ,libffi)
        ("zlib" ,zlib)))
     (home-page "http://jamvm.sourceforge.net/")
     (synopsis "Small Java Virtual Machine")
@@ -258,7 +266,11 @@ JNI.")
                 ,@(if (string-prefix? "armhf" (or (%current-system)
                                                   (%current-target-system)))
                       `((string-append m "-Xnocompact "))
-                      `((string-append m "-Xnocompact -Xnoinlining ")))))
+                      `((string-append m "-Xnocompact ")))))
+
+             (substitute* "src/main/org/apache/tools/ant/version.txt"
+               (("VERSION=.*") (string-append "VERSION=" ,version "\n"))
+               (("DATE=.*") "DATE=reproducible"))
 
              ;; Disable tests because we are bootstrapping and thus don't have
              ;; any of the dependencies required to build and run the tests.

Note that the change to native/jni/java-io/java_io_VMFile.c is necessary
even though it just prints things and compares values.  So this might be
time-related or it could be other stateful behaviour.  Don’t know yet.

The changes in ant-bootstrap might not be needed.

Can someone confirm that this patch helps?

--
Ricardo