projects/guix·blob wip-postfix · refs

724 lines · 32.0 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2021 Ricardo Wurmus <[email protected]>
3;;; Copyright © 2021 Ludovic Courtès <[email protected]>
4;;; Copyright © 2017 Leo Famulari <[email protected]>
5;;; Copyright © 2017, 2022 Marius Bakke <[email protected]>
6;;; Copyright © 2018, 2020 Efraim Flashner <[email protected]>
7;;; Copyright © 2018 Gábor Boskovits <[email protected]>
8;;; Copyright © 2018 Mark H Weaver <[email protected]>
9;;; Copyright © 2019 Andrius Štikonas <[email protected]>
10;;; Copyright © 2020 Simon South <[email protected]>
11;;; Copyright © 2021 Guillaume Le Vaillant <[email protected]>
12;;;
13;;; This file is part of GNU Guix.
14;;;
15;;; GNU Guix is free software; you can redistribute it and/or modify it
16;;; under the terms of the GNU General Public License as published by
17;;; the Free Software Foundation; either version 3 of the License, or (at
18;;; your option) any later version.
19;;;
20;;; GNU Guix is distributed in the hope that it will be useful, but
21;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23;;; GNU General Public License for more details.
24;;;
25;;; You should have received a copy of the GNU General Public License
26;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28(define-module (gnu packages java-bootstrap)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix utils)
34 #:use-module (guix gexp)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system trivial)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages autotools)
39 #:use-module (gnu packages bash)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages gettext)
42 #:use-module (gnu packages guile)
43 #:use-module (gnu packages libffi)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages texinfo)
46 #:export (classpath-devel
47 ecj4-javac-wrapper
48 jamvm-with-ecj4
49 ant-bootstrap))
50
51
52;;;
53;;; Java bootstrap toolchain.
54;;;
55
56;; The Java bootstrap begins with Jikes, a Java compiler written in C++. We
57;; use it to build a simple version of GNU Classpath, the Java standard
58;; library. We chose version 0.93 because it is the last version that can be
59;; built with Jikes. With Jikes and this version of GNU Classpath we can
60;; build JamVM, a Java Virtual Machine. We build version 1.5.1 because it is
61;; the last version of JamVM that works with a version of GNU classpath that
62;; does not require ECJ. These three packages make up the bootstrap JDK.
63
64;; This is sufficient to build an older version of Ant, which is needed to
65;; build an older version of ECJ, an incremental Java compiler, both of which
66;; are written in Java.
67;;
68;; ECJ is needed to build the latest release (0.99) and the development
69;; version of GNU Classpath. The development version of GNU Classpath has
70;; much more support for Java 1.6 than the latest release, but we need to
71;; build 0.99 first to get a working version of javah. ECJ, the development
72;; version of GNU Classpath, and the latest version of JamVM make up the
73;; second stage JDK with which we can build the OpenJDK with the Icedtea 2.x
74;; build framework. We then build the more recent JDK Icedtea 3.x, and all
75;; other versions of OpenJDK.
76
77(define jikes
78 (package
79 (name "jikes")
80 (version "1.22")
81 (source (origin
82 (method url-fetch)
83 (uri (string-append "mirror://sourceforge/jikes/Jikes/"
84 version "/jikes-" version ".tar.bz2"))
85 (sha256
86 (base32
87 "1qqldrp74pzpy5ly421srqn30qppmm9cvjiqdngk8hf47dv2rc0c"))))
88 (build-system gnu-build-system)
89 (home-page "https://jikes.sourceforge.net/")
90 (synopsis "Compiler for the Java language")
91 (description "Jikes is a compiler that translates Java source files as
92defined in The Java Language Specification into the bytecoded instruction set
93and binary format defined in The Java Virtual Machine Specification.")
94 (license license:ibmpl1.0)))
95
96;; This is the last version of GNU Classpath that can be built without ECJ.
97(define classpath-bootstrap
98 (package
99 (name "classpath")
100 (version "0.93")
101 (source (origin
102 (method url-fetch)
103 (uri (string-append "mirror://gnu/classpath/classpath-"
104 version ".tar.gz"))
105 (sha256
106 (base32
107 "0i99wf9xd3hw1sj2sazychb9prx8nadxh2clgvk3zlmb28v0jbfz"))
108 (patches (search-patches "classpath-aarch64-support.patch"
109 "classpath-miscompilation.patch"))))
110 (build-system gnu-build-system)
111 (arguments
112 `(#:configure-flags
113 (list (string-append "JAVAC="
114 (search-input-file %build-inputs "/bin/jikes"))
115 "--disable-Werror"
116 "--disable-gmp"
117 "--disable-gtk-peer"
118 "--disable-gconf-peer"
119 "--disable-plugin"
120 "--disable-dssi"
121 "--disable-alsa"
122 "--disable-gjdoc")
123 #:phases
124 (modify-phases %standard-phases
125 (add-after 'install 'install-data
126 (lambda _ (invoke "make" "install-data"))))))
127 (native-inputs
128 (list jikes fastjar libltdl pkg-config))
129 (home-page "https://www.gnu.org/software/classpath/")
130 (synopsis "Essential libraries for Java")
131 (description "GNU Classpath is a project to create core class libraries
132for use with runtimes, compilers and tools for the Java programming
133language.")
134 ;; GPLv2 or later, with special linking exception.
135 (license license:gpl2+)))
136
137;; This is the last version of JamVM that works with a version of GNU
138;; classpath that does not require ECJ.
139(define jamvm-1-bootstrap
140 (package
141 (name "jamvm")
142 (version "1.5.1")
143 (source (origin
144 (method url-fetch)
145 (uri (string-append "mirror://sourceforge/jamvm/jamvm/"
146 "JamVM%20" version "/jamvm-"
147 version ".tar.gz"))
148 (patches (search-patches "jamvm-1.5.1-aarch64-support.patch"
149 "jamvm-1.5.1-armv7-support.patch"))
150 (sha256
151 (base32
152 "06lhi03l3b0h48pc7x58bk9my2nrcf1flpmglvys3wyad6yraf36"))
153 ;; Remove precompiled software.
154 (snippet
155 '(delete-file "lib/classes.zip"))))
156 (build-system gnu-build-system)
157 (arguments
158 `(#:configure-flags
159 (list (string-append "--with-classpath-install-dir="
160 (assoc-ref %build-inputs "classpath"))
161 "--disable-int-caching"
162 "--enable-runtime-reloc-checks"
163 "--enable-ffi")
164 #:phases
165 ,(if (string-prefix? "aarch64" (or (%current-system)
166 (%current-target-system)))
167 ;; Makefiles and the configure script need to be regenerated to
168 ;; incorporate support for AArch64.
169 '(modify-phases %standard-phases
170 (replace 'bootstrap
171 (lambda _ (invoke "autoreconf" "-vif"))))
172 '%standard-phases)))
173 (inputs
174 (list classpath-bootstrap jikes libffi
175 zip zlib))
176 (native-inputs
177 (if (string-prefix? "aarch64" (or (%current-system)
178 (%current-target-system)))
179 ;; Additional packages needed for autoreconf.
180 `(("autoconf" ,autoconf)
181 ("automake" ,automake)
182 ("libtool" ,libtool))
183 '()))
184 (home-page "https://jamvm.sourceforge.net/")
185 (synopsis "Small Java Virtual Machine")
186 (description "JamVM is a Java Virtual Machine conforming to the JVM
187specification edition 2 (blue book). It is extremely small. However, unlike
188other small VMs it supports the full spec, including object finalisation and
189JNI.")
190 (license license:gpl2+)))
191
192(define ant-bootstrap
193 (package
194 (name "ant-bootstrap")
195 ;; The 1.10.x series requires Java 8. 1.9.0 and later use generics, which
196 ;; are not supported. The 1.8.x series is the last to use only features
197 ;; supported by Jikes.
198 (version "1.8.4")
199 (source (origin
200 (method url-fetch)
201 (uri (string-append "mirror://apache/"
202 "ant/source/apache-ant-"
203 version "-src.tar.bz2"))
204 (sha256
205 (base32
206 "1cg0lga887qz5iizh6mlkxp01lciymrhmp7wzxpl6zpnldxmzrjx"))))
207 (build-system gnu-build-system)
208 (arguments
209 `(#:modules ((srfi srfi-1)
210 (guix build gnu-build-system)
211 (guix build utils))
212 #:tests? #f ; no "check" target
213 #:phases
214 (modify-phases %standard-phases
215 (delete 'bootstrap)
216 (delete 'configure)
217 (add-before 'build 'define-java-environment-variables
218 (lambda* (#:key inputs #:allow-other-keys)
219 ;; First, set environment variables (eases debugging on -K).
220 (setenv "JAVA_HOME" (assoc-ref inputs "jamvm"))
221 (setenv "JAVACMD" (search-input-file inputs "/bin/jamvm"))
222 (setenv "JAVAC" (search-input-file inputs "/bin/jikes"))
223 (setenv "CLASSPATH" (search-input-file inputs "/lib/rt.jar"))))
224 (replace 'build
225 (lambda* (#:key inputs outputs #:allow-other-keys)
226 ;; Ant complains if this file doesn't exist.
227 (setenv "HOME" "/tmp")
228 (with-output-to-file "/tmp/.ant.properties"
229 (lambda _ (display "")))
230
231 ;; Use jikes instead of javac for <javac ...> tags in build.xml
232 (setenv "ANT_OPTS" "-Dbuild.compiler=jikes")
233
234 ;; jikes produces lots of warnings, but they are not very
235 ;; interesting, so we silence them.
236 (setenv "$BOOTJAVAC_OPTS" "-nowarn")
237
238 ;; Without these JamVM options the build may freeze.
239 (substitute* "bootstrap.sh"
240 (("^\"\\$\\{JAVACMD\\}\" " m)
241 ,@(if (string-prefix? "armhf" (or (%current-system)
242 (%current-target-system)))
243 `((string-append m "-Xnocompact "))
244 `((string-append m "-Xnocompact -Xnoinlining ")))))
245
246 ;; Disable tests because we are bootstrapping and thus don't have
247 ;; any of the dependencies required to build and run the tests.
248 (substitute* "build.xml"
249 (("depends=\"jars,test-jar\"") "depends=\"jars\""))
250 (invoke "bash" "bootstrap.sh"
251 (string-append "-Ddist.dir="
252 (assoc-ref outputs "out")))))
253 (add-after 'build 'strip-jar-timestamps ;based on ant-build-system
254 (lambda* (#:key outputs #:allow-other-keys)
255 (define (repack-archive jar)
256 (let* ((dir (mkdtemp "jar-contents.XXXXXX"))
257 (manifest (string-append dir "/META-INF/MANIFESTS.MF")))
258 (with-directory-excursion dir
259 (invoke "unzip" jar))
260 (delete-file jar)
261 ;; XXX: copied from (gnu build install)
262 (for-each (lambda (file)
263 (let ((s (lstat file)))
264 (unless (eq? (stat:type s) 'symlink)
265 (utime file 0 0 0 0))))
266 (find-files dir #:directories? #t))
267 ;; It is important that the manifest appears first.
268 (with-directory-excursion dir
269 (let* ((files (find-files "." ".*" #:directories? #t))
270 ;; To ensure that the reference scanner can
271 ;; detect all store references in the jars
272 ;; we disable compression with the "-0" option.
273 (command (if (file-exists? manifest)
274 `("zip" "-0" "-X" ,jar ,manifest
275 ,@files)
276 `("zip" "-0" "-X" ,jar ,@files))))
277 (apply invoke command)))))
278 (for-each repack-archive
279 (find-files
280 (string-append (assoc-ref %outputs "out") "/lib")
281 "\\.jar$"))))
282 (delete 'install))))
283 (native-inputs
284 (list jikes jamvm-1-bootstrap unzip zip))
285 (home-page "https://ant.apache.org")
286 (synopsis "Build tool for Java")
287 (description
288 "Ant is a platform-independent build tool for Java. It is similar to
289make but is implemented using the Java language, requires the Java platform,
290and is best suited to building Java projects. Ant uses XML to describe the
291build process and its dependencies, whereas Make uses Makefile format.")
292 (license license:asl2.0)))
293
294;; Version 3.2.2 is the last version without a dependency on a full-fledged
295;; compiler for Java 1.5.
296(define ecj-bootstrap
297 (package
298 (name "ecj-bootstrap")
299 (version "3.2.2")
300 (source (origin
301 (method url-fetch)
302 (uri (string-append "http://archive.eclipse.org/eclipse/"
303 "downloads/drops/R-" version
304 "-200702121330/ecjsrc.zip"))
305 (sha256
306 (base32
307 "05hj82kxd23qaglsjkaqcj944riisjha7acf7h3ljhrjyljx8307"))))
308 ;; It would be so much easier if we could use the ant-build-system, but we
309 ;; cannot as we don't have ant at this point. We use ecj for
310 ;; bootstrapping the JDK.
311 (build-system gnu-build-system)
312 (arguments
313 `(#:tests? #f ; there are no tests
314 #:phases
315 (modify-phases %standard-phases
316 (replace 'configure
317 (lambda* (#:key inputs #:allow-other-keys)
318 (setenv "CLASSPATH"
319 (string-join
320 (cons (search-input-file inputs "/lib/rt.jar")
321 (find-files (string-append
322 (assoc-ref inputs "ant-bootstrap")
323 "/lib")
324 "\\.jar$"))
325 ":"))))
326 (replace 'build
327 (lambda* (#:key inputs #:allow-other-keys)
328 ;; The unpack phase enters the "org" directory by mistake.
329 (chdir "..")
330
331 ;; Create a simple manifest to make ecj executable.
332 (with-output-to-file "manifest"
333 (lambda _
334 (display "Manifest-Version: 1.0
335Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
336
337 ;; Compile it all!
338 (and (apply invoke "jikes"
339 (find-files "." "\\.java$"))
340 (invoke "fastjar" "cvfm"
341 "ecj-bootstrap.jar" "manifest" "."))))
342 (replace 'install
343 (lambda* (#:key outputs #:allow-other-keys)
344 (let ((share (string-append (assoc-ref outputs "out")
345 "/share/java/")))
346 (mkdir-p share)
347 (install-file "ecj-bootstrap.jar" share)))))))
348 (native-inputs
349 (list ant-bootstrap
350 unzip
351 jikes
352 jamvm-1-bootstrap
353 fastjar))
354 (home-page "https://eclipse.org")
355 (synopsis "Eclipse Java development tools core batch compiler")
356 (description "This package provides the Eclipse Java core batch compiler
357for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
358requirement for all GNU Classpath releases after version 0.93.")
359 (license license:epl1.0)))
360
361(define ecj-javac-wrapper
362 (package (inherit ecj-bootstrap)
363 (name "ecj-javac-wrapper")
364 (source #f)
365 (build-system trivial-build-system)
366 (arguments
367 `(#:modules ((guix build utils))
368 #:builder
369 ,#~(begin
370 (use-modules (guix build utils))
371 (let* ((bin (string-append #$output "/bin"))
372 (target (string-append bin "/javac"))
373 (guile (string-append (assoc-ref %build-inputs "guile")
374 "/bin/guile"))
375 (ecj (string-append #$(this-package-native-input "ecj-bootstrap")
376 "/share/java/ecj-bootstrap.jar"))
377 (java (string-append #$(this-package-native-input "jamvm")
378 "/bin/jamvm"))
379 (bootcp (let ((jvmlib (string-append
380 #$(this-package-native-input "classpath")
381 "/share/classpath")))
382 (string-append jvmlib "/glibj.zip:"
383 jvmlib "/tools.zip"))))
384 (mkdir-p bin)
385 (with-output-to-file target
386 (lambda _
387 (format #t "#!~a --no-auto-compile\n!#\n" guile)
388 (write
389 `(begin (use-modules (ice-9 match)
390 (ice-9 receive)
391 (ice-9 hash-table)
392 (srfi srfi-1)
393 (srfi srfi-26))
394 (define defaults
395 '(("-bootclasspath" ,bootcp)
396 ("-source" "1.5")
397 ("-target" "1.5")
398 ("-cp" ".")))
399 (define (main args)
400 (let ((classpath (getenv "CLASSPATH")))
401 (setenv "CLASSPATH"
402 (string-join (list ,ecj (or classpath ""))
403 ":")))
404 (receive (vm-args other-args)
405 ;; Separate VM arguments from arguments to ECJ.
406 (partition (cut string-prefix? "-J" <>)
407 (fold (lambda (default acc)
408 (if (member (first default) acc)
409 acc (append default acc)))
410 args defaults))
411 (apply system* ,java
412 (append
413 ;; Remove "-J" prefix
414 (map (cut string-drop <> 2) vm-args)
415 '("org.eclipse.jdt.internal.compiler.batch.Main")
416 (cons "-nowarn" other-args)))))
417 ;; Entry point
418 (let ((args (cdr (command-line))))
419 (if (null? args)
420 (format (current-error-port) "javac: no arguments given!\n")
421 (main args)))))))
422 (chmod target #o755)))))
423 (native-inputs
424 (list guile-3.0 ecj-bootstrap jamvm-1-bootstrap classpath-bootstrap))
425 (description "This package provides a wrapper around the @dfn{Eclipse
426compiler for Java} (ecj) with a command line interface that is compatible with
427the standard javac executable.")))
428
429;; The classpath-bootstrap was built without a virtual machine, so it does not
430;; provide a wrapper for javah. We cannot build the development version of
431;; Classpath without javah.
432(define classpath-0.99
433 (package (inherit classpath-bootstrap)
434 (version "0.99")
435 (source (origin
436 (method url-fetch)
437 (uri (string-append "mirror://gnu/classpath/classpath-"
438 version ".tar.gz"))
439 (sha256
440 (base32
441 "1j7cby4k66f1nvckm48xcmh352b1d1b33qk7l6hi7dp9i9zjjagr"))
442 (patches (search-patches "classpath-aarch64-support.patch"))))
443 (arguments
444 `(#:configure-flags
445 (list (string-append "--with-ecj-jar="
446 (assoc-ref %build-inputs "ecj-bootstrap")
447 "/share/java/ecj-bootstrap.jar")
448 (string-append "JAVAC="
449 (assoc-ref %build-inputs "ecj-javac-wrapper")
450 "/bin/javac")
451 (string-append "JAVA="
452 (assoc-ref %build-inputs "jamvm")
453 "/bin/jamvm")
454 "GCJ_JAVAC_TRUE=no"
455 "ac_cv_prog_java_works=yes" ; trust me
456 "--disable-Werror"
457 "--disable-gmp"
458 "--disable-gtk-peer"
459 "--disable-gconf-peer"
460 "--disable-plugin"
461 "--disable-dssi"
462 "--disable-alsa"
463 "--disable-gjdoc")
464 #:phases
465 (modify-phases %standard-phases
466 (add-after 'install 'install-data
467 (lambda _ (invoke "make" "install-data"))))))
468 (native-inputs
469 (list classpath-bootstrap
470 ecj-bootstrap ecj-javac-wrapper
471 fastjar jamvm-1-bootstrap
472 libltdl pkg-config))))
473
474;; We need this because classpath-bootstrap does not provide all of the tools
475;; we need to build classpath-devel.
476(define classpath-jamvm-wrappers
477 (package (inherit classpath-0.99)
478 (name "classpath-jamvm-wrappers")
479 (source #f)
480 (build-system trivial-build-system)
481 (arguments
482 (list
483 #:modules '((guix build utils))
484 #:builder
485 #~(begin
486 (use-modules (guix build utils))
487 (let ((bash #$(this-package-native-input "bash-minimal"))
488 (jamvm #$(this-package-native-input "jamvm"))
489 (classpath #$(this-package-native-input "classpath"))
490 (bin (string-append #$output "/bin/")))
491 (mkdir-p bin)
492 (for-each (lambda (tool)
493 (with-output-to-file (string-append bin tool)
494 (lambda _
495 #$@(if (string-prefix? "armhf" (or (%current-system)
496 (%current-target-system)))
497 `((format #t "#!~a/bin/sh
498~a/bin/jamvm -Xnocompact -classpath ~a/share/classpath/tools.zip \
499gnu.classpath.tools.~a.~a $@"
500 bash jamvm classpath tool
501 (if (string=? "native2ascii" tool)
502 "Native2ASCII" "Main")))
503 `((format #t "#!~a/bin/sh
504~a/bin/jamvm -Xnocompact -Xnoinlining -classpath ~a/share/classpath/tools.zip \
505gnu.classpath.tools.~a.~a $@"
506 bash jamvm classpath tool
507 (if (string=? "native2ascii" tool)
508 "Native2ASCII" "Main"))))))
509 (chmod (string-append bin tool) #o755))
510 (list "javah"
511 "rmic"
512 "rmid"
513 "orbd"
514 "rmiregistry"
515 "native2ascii"))))))
516 (native-inputs
517 (list bash-minimal jamvm-1-bootstrap classpath-0.99))
518 (inputs '())
519 (synopsis "Executables from GNU Classpath")
520 (description "This package provides wrappers around the tools provided by
521the GNU Classpath library. They are executed by the JamVM virtual
522machine.")))
523
524;; The last release of GNU Classpath is 0.99 and it happened in 2012. Since
525;; then Classpath has gained much more support for Java 1.6.
526(define classpath-devel
527 (let ((commit "e7c13ee0cf2005206fbec0eca677f8cf66d5a103")
528 (revision "1"))
529 (package (inherit classpath-bootstrap)
530 (version (string-append "0.99-" revision "." (string-take commit 9)))
531 (source (origin
532 (method git-fetch)
533 (uri (git-reference
534 (url "https://git.savannah.gnu.org/git/classpath.git")
535 (commit commit)))
536 (file-name (string-append "classpath-" version "-checkout"))
537 (sha256
538 (base32
539 "1v2rww76ww322mpg3s12a1kkc6gkp31bm9gcxs532h0wq285fiw4"))
540 (patches (search-patches "classpath-aarch64-support.patch"))))
541 (arguments
542 `(#:make-flags
543 ;; Ensure that the initial heap size is smaller than the maximum
544 ;; size. By default only Xmx is set, which can lead to invalid
545 ;; memory settings on some machines with a lot of memory.
546 '("JAVAC_MEM_OPT=-J-Xms512M -J-Xmx768M")
547 #:configure-flags
548 (list (string-append "--with-ecj-jar="
549 (assoc-ref %build-inputs "ecj-bootstrap")
550 "/share/java/ecj-bootstrap.jar")
551 (string-append "--with-javac="
552 (assoc-ref %build-inputs "ecj-javac-wrapper")
553 "/bin/javac")
554 (string-append "JAVA="
555 (assoc-ref %build-inputs "jamvm")
556 "/bin/jamvm")
557 "GCJ_JAVAC_TRUE=no"
558 "ac_cv_prog_java_works=yes" ; trust me
559 "--disable-Werror"
560 "--disable-gmp"
561 "--disable-gtk-peer"
562 "--disable-gconf-peer"
563 "--disable-plugin"
564 "--disable-dssi"
565 "--disable-alsa"
566 "--disable-gjdoc")
567 #:phases
568 (modify-phases %standard-phases
569 ;; XXX The bootstrap phase executes autogen.sh, which fails after
570 ;; complaining about the lack of gettext.
571 (replace 'bootstrap
572 (lambda _ (invoke "autoreconf" "-vif")))
573 (add-after 'unpack 'remove-unsupported-annotations
574 (lambda _
575 (substitute* (find-files "java" "\\.java$")
576 (("@Override") ""))))
577 (add-after 'install 'install-data
578 (lambda _ (invoke "make" "install-data"))))))
579 (native-inputs
580 (list autoconf automake libltdl libtool gettext-minimal texinfo
581 pkg-config
582 classpath-jamvm-wrappers ;for javah
583 ecj-bootstrap ecj-javac-wrapper fastjar
584 jamvm-1-bootstrap)))))
585
586(define jamvm
587 (package (inherit jamvm-1-bootstrap)
588 (version "2.0.0")
589 (source (origin
590 (method url-fetch)
591 (uri (string-append "mirror://sourceforge/jamvm/jamvm/"
592 "JamVM%20" version "/jamvm-"
593 version ".tar.gz"))
594 (sha256
595 (base32
596 "1nl0zxz8y5x8gwsrm7n32bry4dx8x70p8z3s9jbdvs8avyb8whkn"))
597 (patches
598 (search-patches "jamvm-2.0.0-disable-branch-patching.patch"
599 "jamvm-2.0.0-opcode-guard.patch"
600 "jamvm-2.0.0-aarch64-support.patch"))
601 ;; Remove precompiled software.
602 (snippet
603 '(delete-file "src/classlib/gnuclasspath/lib/classes.zip"))))
604 (build-system gnu-build-system)
605 (arguments
606 (substitute-keyword-arguments (package-arguments jamvm-1-bootstrap)
607 ((#:configure-flags _)
608 '(list (string-append "--with-classpath-install-dir="
609 (assoc-ref %build-inputs "classpath"))))))
610 (inputs
611 `(("classpath" ,classpath-devel)
612 ("ecj-javac-wrapper" ,ecj-javac-wrapper)
613 ("zip" ,zip)
614 ("zlib" ,zlib)))))
615
616(define ecj-javac-wrapper-final
617 (package (inherit ecj-javac-wrapper)
618 (native-inputs
619 (list guile-3.0 ecj-bootstrap jamvm classpath-devel))))
620
621;; We jump ahead by patching the sources of ECJ 4.2.1 so that our bootstrap
622;; JDK can build it. ECJ 4 allows us to skip the build of the first version
623;; of icedtea and build icedtea 2.x directly.
624(define ecj4-bootstrap
625 (package
626 (name "ecj-bootstrap")
627 (version "4.2.1")
628 (source (origin
629 (method url-fetch)
630 (uri (string-append "http://archive.eclipse.org/eclipse/"
631 "downloads/drops4/R-" version
632 "-201209141800/ecjsrc-" version ".jar"))
633 (sha256
634 (base32
635 "1x281p87m14zylvinkiz6gc23ss7pzlx419qjbql11jriwav4qfj"))))
636 ;; It would be so much easier if we could use the ant-build-system, but we
637 ;; cannot as we don't have ant at this point. We use ecj for
638 ;; bootstrapping the JDK.
639 (build-system gnu-build-system)
640 (arguments
641 `(#:tests? #f ; there are no tests
642 #:phases
643 (modify-phases %standard-phases
644 (replace 'unpack
645 (lambda* (#:key source #:allow-other-keys)
646 (mkdir "src")
647 (with-directory-excursion "src"
648 (invoke "gjar" "-xf" source))
649 (chdir "src")))
650 (replace 'configure
651 (lambda* (#:key inputs #:allow-other-keys)
652 (setenv "CLASSPATH"
653 (string-join
654 (cons (search-input-file inputs "/lib/rt.jar")
655 (find-files (string-append
656 (assoc-ref inputs "ant-bootstrap")
657 "/lib")
658 "\\.jar$"))
659 ":"))
660 ;; This directive is not supported by our simple bootstrap JDK.
661 (substitute* (find-files "." "\\.java$")
662 (("@Override") ""))))
663 (replace 'build
664 (lambda* (#:key inputs #:allow-other-keys)
665 ;; We can't compile these yet, but we don't need them at this
666 ;; point anyway.
667 (delete-file "org/eclipse/jdt/core/JDTCompilerAdapter.java")
668 (delete-file-recursively "org/eclipse/jdt/internal/antadapter")
669
670 ;; Create a simple manifest to make ecj executable.
671 (mkdir-p "META-INF")
672 (with-output-to-file "META-INF/MANIFESTS.MF"
673 (lambda _
674 (display "Manifest-Version: 1.0
675Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
676
677 ;; Compile it all!
678 (apply invoke "javac"
679 (find-files "." "\\.java$"))
680
681 ;; Pack it all up! We don't use "jar" here, because
682 ;; it doesn't produce reproducible zip archives.
683 ;; XXX: copied from (gnu build install)
684 (for-each (lambda (file)
685 (let ((s (lstat file)))
686 (unless (eq? (stat:type s) 'symlink)
687 (utime file 0 0 0 0))))
688 (find-files "." #:directories? #t))
689
690 ;; It is important that the manifest appears first.
691 (apply invoke "zip" "-0" "-X" "ecj-bootstrap.jar"
692 "META-INF/MANIFESTS.MF"
693 (delete "./META-INF/MANIFESTS.MF"
694 (find-files "." ".*" #:directories? #t)))))
695 (replace 'install
696 (lambda* (#:key outputs #:allow-other-keys)
697 (let ((share (string-append (assoc-ref outputs "out")
698 "/share/java/")))
699 (mkdir-p share)
700 (install-file "ecj-bootstrap.jar" share)))))))
701 (native-inputs
702 (list ant-bootstrap classpath-devel ecj-javac-wrapper-final jamvm
703 unzip zip))
704 (home-page "https://eclipse.org")
705 (synopsis "Eclipse Java development tools core batch compiler")
706 (description "This package provides the Eclipse Java core batch compiler
707for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
708requirement for all GNU Classpath releases after version 0.93. This version
709supports sufficient parts of Java 7 to build Icedtea 2.x.")
710 (license license:epl1.0)))
711
712(define ecj4-javac-wrapper
713 (package
714 (inherit ecj-javac-wrapper)
715 (native-inputs
716 (list guile-3.0 ecj4-bootstrap jamvm classpath-devel))))
717
718(define jamvm-with-ecj4
719 (package
720 (inherit jamvm)
721 (inputs
722 (modify-inputs (package-inputs jamvm)
723 (replace "ecj-javac-wrapper" ecj4-javac-wrapper)))))
724