projects/guix·blob wip-node-riscv64 · refs

723 lines · 31.8 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, 2024 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 (target-arm32?)
496 `((format #t "#!~a/bin/sh
497~a/bin/jamvm -classpath ~a/share/classpath/tools.zip \
498gnu.classpath.tools.~a.~a $@"
499 bash jamvm classpath tool
500 (if (string=? "native2ascii" tool)
501 "Native2ASCII" "Main")))
502 `((format #t "#!~a/bin/sh
503~a/bin/jamvm -Xnocompact -Xnoinlining -classpath ~a/share/classpath/tools.zip \
504gnu.classpath.tools.~a.~a $@"
505 bash jamvm classpath tool
506 (if (string=? "native2ascii" tool)
507 "Native2ASCII" "Main"))))))
508 (chmod (string-append bin tool) #o755))
509 (list "javah"
510 "rmic"
511 "rmid"
512 "orbd"
513 "rmiregistry"
514 "native2ascii"))))))
515 (native-inputs
516 (list bash-minimal jamvm-1-bootstrap classpath-0.99))
517 (inputs '())
518 (synopsis "Executables from GNU Classpath")
519 (description "This package provides wrappers around the tools provided by
520the GNU Classpath library. They are executed by the JamVM virtual
521machine.")))
522
523;; The last release of GNU Classpath is 0.99 and it happened in 2012. Since
524;; then Classpath has gained much more support for Java 1.6.
525(define classpath-devel
526 (let ((commit "e7c13ee0cf2005206fbec0eca677f8cf66d5a103")
527 (revision "1"))
528 (package (inherit classpath-bootstrap)
529 (version (string-append "0.99-" revision "." (string-take commit 9)))
530 (source (origin
531 (method git-fetch)
532 (uri (git-reference
533 (url "https://git.savannah.gnu.org/git/classpath.git")
534 (commit commit)))
535 (file-name (string-append "classpath-" version "-checkout"))
536 (sha256
537 (base32
538 "1v2rww76ww322mpg3s12a1kkc6gkp31bm9gcxs532h0wq285fiw4"))
539 (patches (search-patches "classpath-aarch64-support.patch"))))
540 (arguments
541 `(#:make-flags
542 ;; Ensure that the initial heap size is smaller than the maximum
543 ;; size. By default only Xmx is set, which can lead to invalid
544 ;; memory settings on some machines with a lot of memory.
545 '("JAVAC_MEM_OPT=-J-Xms512M -J-Xmx768M")
546 #:configure-flags
547 (list (string-append "--with-ecj-jar="
548 (assoc-ref %build-inputs "ecj-bootstrap")
549 "/share/java/ecj-bootstrap.jar")
550 (string-append "--with-javac="
551 (assoc-ref %build-inputs "ecj-javac-wrapper")
552 "/bin/javac")
553 (string-append "JAVA="
554 (assoc-ref %build-inputs "jamvm")
555 "/bin/jamvm")
556 "GCJ_JAVAC_TRUE=no"
557 "ac_cv_prog_java_works=yes" ; trust me
558 "--disable-Werror"
559 "--disable-gmp"
560 "--disable-gtk-peer"
561 "--disable-gconf-peer"
562 "--disable-plugin"
563 "--disable-dssi"
564 "--disable-alsa"
565 "--disable-gjdoc")
566 #:phases
567 (modify-phases %standard-phases
568 ;; XXX The bootstrap phase executes autogen.sh, which fails after
569 ;; complaining about the lack of gettext.
570 (replace 'bootstrap
571 (lambda _ (invoke "autoreconf" "-vif")))
572 (add-after 'unpack 'remove-unsupported-annotations
573 (lambda _
574 (substitute* (find-files "java" "\\.java$")
575 (("@Override") ""))))
576 (add-after 'install 'install-data
577 (lambda _ (invoke "make" "install-data"))))))
578 (native-inputs
579 (list autoconf automake libltdl libtool gettext-minimal texinfo
580 pkg-config
581 classpath-jamvm-wrappers ;for javah
582 ecj-bootstrap ecj-javac-wrapper fastjar
583 jamvm-1-bootstrap)))))
584
585(define jamvm
586 (package (inherit jamvm-1-bootstrap)
587 (version "2.0.0")
588 (source (origin
589 (method url-fetch)
590 (uri (string-append "mirror://sourceforge/jamvm/jamvm/"
591 "JamVM%20" version "/jamvm-"
592 version ".tar.gz"))
593 (sha256
594 (base32
595 "1nl0zxz8y5x8gwsrm7n32bry4dx8x70p8z3s9jbdvs8avyb8whkn"))
596 (patches
597 (search-patches "jamvm-2.0.0-disable-branch-patching.patch"
598 "jamvm-2.0.0-opcode-guard.patch"
599 "jamvm-2.0.0-aarch64-support.patch"))
600 ;; Remove precompiled software.
601 (snippet
602 '(delete-file "src/classlib/gnuclasspath/lib/classes.zip"))))
603 (build-system gnu-build-system)
604 (arguments
605 (substitute-keyword-arguments (package-arguments jamvm-1-bootstrap)
606 ((#:configure-flags _)
607 '(list (string-append "--with-classpath-install-dir="
608 (assoc-ref %build-inputs "classpath"))))))
609 (inputs
610 `(("classpath" ,classpath-devel)
611 ("ecj-javac-wrapper" ,ecj-javac-wrapper)
612 ("zip" ,zip)
613 ("zlib" ,zlib)))))
614
615(define ecj-javac-wrapper-final
616 (package (inherit ecj-javac-wrapper)
617 (native-inputs
618 (list guile-3.0 ecj-bootstrap jamvm classpath-devel))))
619
620;; We jump ahead by patching the sources of ECJ 4.2.1 so that our bootstrap
621;; JDK can build it. ECJ 4 allows us to skip the build of the first version
622;; of icedtea and build icedtea 2.x directly.
623(define ecj4-bootstrap
624 (package
625 (name "ecj-bootstrap")
626 (version "4.2.1")
627 (source (origin
628 (method url-fetch)
629 (uri (string-append "http://archive.eclipse.org/eclipse/"
630 "downloads/drops4/R-" version
631 "-201209141800/ecjsrc-" version ".jar"))
632 (sha256
633 (base32
634 "1x281p87m14zylvinkiz6gc23ss7pzlx419qjbql11jriwav4qfj"))))
635 ;; It would be so much easier if we could use the ant-build-system, but we
636 ;; cannot as we don't have ant at this point. We use ecj for
637 ;; bootstrapping the JDK.
638 (build-system gnu-build-system)
639 (arguments
640 `(#:tests? #f ; there are no tests
641 #:phases
642 (modify-phases %standard-phases
643 (replace 'unpack
644 (lambda* (#:key source #:allow-other-keys)
645 (mkdir "src")
646 (with-directory-excursion "src"
647 (invoke "gjar" "-xf" source))
648 (chdir "src")))
649 (replace 'configure
650 (lambda* (#:key inputs #:allow-other-keys)
651 (setenv "CLASSPATH"
652 (string-join
653 (cons (search-input-file inputs "/lib/rt.jar")
654 (find-files (string-append
655 (assoc-ref inputs "ant-bootstrap")
656 "/lib")
657 "\\.jar$"))
658 ":"))
659 ;; This directive is not supported by our simple bootstrap JDK.
660 (substitute* (find-files "." "\\.java$")
661 (("@Override") ""))))
662 (replace 'build
663 (lambda* (#:key inputs #:allow-other-keys)
664 ;; We can't compile these yet, but we don't need them at this
665 ;; point anyway.
666 (delete-file "org/eclipse/jdt/core/JDTCompilerAdapter.java")
667 (delete-file-recursively "org/eclipse/jdt/internal/antadapter")
668
669 ;; Create a simple manifest to make ecj executable.
670 (mkdir-p "META-INF")
671 (with-output-to-file "META-INF/MANIFESTS.MF"
672 (lambda _
673 (display "Manifest-Version: 1.0
674Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
675
676 ;; Compile it all!
677 (apply invoke "javac"
678 (find-files "." "\\.java$"))
679
680 ;; Pack it all up! We don't use "jar" here, because
681 ;; it doesn't produce reproducible zip archives.
682 ;; XXX: copied from (gnu build install)
683 (for-each (lambda (file)
684 (let ((s (lstat file)))
685 (unless (eq? (stat:type s) 'symlink)
686 (utime file 0 0 0 0))))
687 (find-files "." #:directories? #t))
688
689 ;; It is important that the manifest appears first.
690 (apply invoke "zip" "-0" "-X" "ecj-bootstrap.jar"
691 "META-INF/MANIFESTS.MF"
692 (delete "./META-INF/MANIFESTS.MF"
693 (find-files "." ".*" #:directories? #t)))))
694 (replace 'install
695 (lambda* (#:key outputs #:allow-other-keys)
696 (let ((share (string-append (assoc-ref outputs "out")
697 "/share/java/")))
698 (mkdir-p share)
699 (install-file "ecj-bootstrap.jar" share)))))))
700 (native-inputs
701 (list ant-bootstrap classpath-devel ecj-javac-wrapper-final jamvm
702 unzip zip))
703 (home-page "https://eclipse.org")
704 (synopsis "Eclipse Java development tools core batch compiler")
705 (description "This package provides the Eclipse Java core batch compiler
706for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
707requirement for all GNU Classpath releases after version 0.93. This version
708supports sufficient parts of Java 7 to build Icedtea 2.x.")
709 (license license:epl1.0)))
710
711(define ecj4-javac-wrapper
712 (package
713 (inherit ecj-javac-wrapper)
714 (native-inputs
715 (list guile-3.0 ecj4-bootstrap jamvm classpath-devel))))
716
717(define jamvm-with-ecj4
718 (package
719 (inherit jamvm)
720 (inputs
721 (modify-inputs (package-inputs jamvm)
722 (replace "ecj-javac-wrapper" ecj4-javac-wrapper)))))
723